summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2018-02-28 21:20:29 +0100
committertomsmeding <tom.smeding@gmail.com>2018-02-28 21:20:29 +0100
commit04f196c7c5c9601a9d7e64e013cc9846c4b2e1fe (patch)
treeb05f40cb7303de8368f35700f9e162cb67a5b947
parent7cca693798b1f7d48c38416a8263470aeeacc6c7 (diff)
Put dirlisting in repository
-rw-r--r--dirlisting.html32
-rwxr-xr-xwebserver.js2
2 files changed, 33 insertions, 1 deletions
diff --git a/dirlisting.html b/dirlisting.html
new file mode 100644
index 0000000..c5a8ecf
--- /dev/null
+++ b/dirlisting.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Directory <!--DIRDIR--></title>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<script>
+var listing=[/*LISTINGLISTING*/];
+
+window.addEventListener("load",function(){
+ document.getElementById("dirdir").innerHTML=document.title.slice(10);
+ var i,div,a;
+ var e=document.getElementById("listing");
+ var pathname=location.pathname;
+ if(pathname[pathname.length-1]=="/")pathname=pathname.slice(0,pathname.length-1);
+ for(i=0;i<listing.length;i++){
+ div=document.createElement("div");
+ a=document.createElement("a");
+ a.innerHTML=listing[i];
+ a.setAttribute("href",pathname+"/"+listing[i]);
+ div.appendChild(a);
+ e.appendChild(div);
+ }
+});
+</script>
+</head>
+<body>
+<h1>Directory <span id="dirdir">&gt;&lt;</span></h1>
+<hr>
+<div id="listing"></div>
+</body>
+</html>
diff --git a/webserver.js b/webserver.js
index c59cd9f..ab524ca 100755
--- a/webserver.js
+++ b/webserver.js
@@ -102,7 +102,7 @@ function requestFile(req,res,listdirs,path,origpath){
return f!==null;
});
res.send(
- String(fs.readFileSync(cmn.rootdir+"/web_files/dirlisting.html"))
+ String(fs.readFileSync(cmn.serverdir+"/dirlisting.html"))
.replace("<!--DIRDIR-->",path)
.replace("[/*LISTINGLISTING*/]",JSON.stringify(items))
);