diff options
author | cbdev <cb@cbcdn.com> | 2021-10-29 20:22:18 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2021-10-29 20:22:18 +0200 |
commit | b87909c9dd7aabe7b8f8bd63138876dff5cd2200 (patch) | |
tree | 55479eea6f24c824f1aef4e3d312cad7023e5ceb /assets | |
parent | dad7fcafa4d4b2ab3fd59edb01c57a12155f0375 (diff) | |
download | cargohold-b87909c9dd7aabe7b8f8bd63138876dff5cd2200.tar.gz cargohold-b87909c9dd7aabe7b8f8bd63138876dff5cd2200.tar.bz2 cargohold-b87909c9dd7aabe7b8f8bd63138876dff5cd2200.zip |
Implement gallery view, add noscript notice, implement rudimentary overwrite protection
Diffstat (limited to 'assets')
-rw-r--r-- | assets/502.html | 1 | ||||
-rw-r--r-- | assets/cargohold.css | 10 | ||||
-rw-r--r-- | assets/cargohold.js | 29 |
3 files changed, 38 insertions, 2 deletions
diff --git a/assets/502.html b/assets/502.html new file mode 100644 index 0000000..1bc0ca4 --- /dev/null +++ b/assets/502.html @@ -0,0 +1 @@ +FIXME: Do a proper error page diff --git a/assets/cargohold.css b/assets/cargohold.css index bec6b3a..747b916 100644 --- a/assets/cargohold.css +++ b/assets/cargohold.css @@ -9,6 +9,16 @@ html { background-color: #425; } +.listing-entry > img { + display: inline-block; + width: 100%; +} + +#noscript-warning { + padding: 1em; + font-size: 110%; +} + .listing-entry, .listing-entry:visited { display: block; text-decoration: none; diff --git a/assets/cargohold.js b/assets/cargohold.js index 2ba8cc0..18dbeae 100644 --- a/assets/cargohold.js +++ b/assets/cargohold.js @@ -45,6 +45,10 @@ function queue_work(){ }; req.onreadystatechange = function(evt){ console.log("Upload for " + item.file.name + " state " + req.readyState); + if(req.readyState === XMLHttpRequest.DONE && req.status != 200){ + console.log("Upload for " + item.file.name + " failed with " + req.status); + item.node.className += " errored"; + } }; req.open("POST", 'upload'); req.send(data); @@ -100,9 +104,28 @@ function listing_clear(){ element("dirlisting").innerHTML = ""; } -function listing_add(file){ +function interface_update(access){ + if(!access.includes("c")){ + element("tab-upload-label").style.display = "none"; + } + + if(!access.includes("r")){ + element("tab-view-label").style.display = "none"; + element("tab-upload").checked = "checked"; + } +} + +function listing_add(file, style = "default"){ let link = node("a", "listing-entry", file.name); link.href = "file/" + encodeURIComponent(file.name); + + if(style == "gallery"){ + let image = node("img", "preview"); + image.src = "preview/" + encodeURIComponent(file.name); + //link.insertBefore(image, link.firstChild); + link.appendChild(image); + } + element("dirlisting").appendChild(link); } @@ -111,8 +134,10 @@ function listing_update(){ let req = new XMLHttpRequest(); req.onload = function(evt){ let data = JSON.parse(req.response); + interface_update(data.access); + for(let i = 0; i < data.files.length; i++){ - listing_add(data.files[i]); + listing_add(data.files[i], data.display); } }; req.open("GET", "listing"); |