diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/changes/changes.html | 65 | ||||
-rw-r--r-- | modules/changes/changes.js | 3 |
2 files changed, 50 insertions, 18 deletions
diff --git a/modules/changes/changes.html b/modules/changes/changes.html index 07cc7f9..2cccec4 100644 --- a/modules/changes/changes.html +++ b/modules/changes/changes.html @@ -47,7 +47,7 @@ function focusData(data){ var l=tbody.children,i; for(i=l.length-1;i>=0;i--)tbody.removeChild(l[i]); - var tr,td,s; + var tr,td,e,s,date; for(i=data.timeline.length-1;i>=0;i--){ tr=document.createElement("tr"); if(i>0&&data.timeline[i][1]==data.timeline[i-1][1]){ @@ -55,7 +55,8 @@ function focusData(data){ } td=document.createElement("td"); - td.appendChild(document.createTextNode(dateformat(new Date(data.timeline[i][0])))); + date=new Date(data.timeline[i][0]); + td.appendChild(document.createTextNode(dateformat(date))); tr.appendChild(td); td=document.createElement("td"); @@ -64,10 +65,51 @@ function focusData(data){ td.appendChild(document.createTextNode(s)); tr.appendChild(td); + td=document.createElement("td"); + e=document.createElement("a"); + e.href="javascript:void(0)"; + e.appendChild(document.createTextNode("Delete till here")); + e.addEventListener("click",(function(url,date){return function(ev){ + if(!confirm( + "This will delete history up to and including the selected date "+ + "("+dateformat(date)+"), for the following url:\n"+data.url+ + "\nIs this OK?")){ + return; + } + + fetch("DELETE","/changes/url/history",JSON.stringify({url:data.url,todate:date}),function(status,body){ + if(status!=200){ + alert("Error deleting history: ("+status+") "+body); + return; + } + focusURL(data.url); + }); + };})(data.url,date)); + td.appendChild(e); + tr.appendChild(td); + tbody.appendChild(tr); } } +function focusURL(url){ + fetch("GET","/changes/url?url="+encodeURIComponent(url),function(status,body){ + if(status!=200){ + alert("Error getting data: ("+status+") "+body); + return; + } + var data; + try { + data=JSON.parse(body); + } catch(e){ + alert("Server sent invalid data!"); + console.log("Invalid data:",data); + return; + } + focusData(data); + }); +} + function makeURLtr(url){ var tr=document.createElement("tr"); var td=document.createElement("td"); @@ -98,21 +140,7 @@ function makeURLtr(url){ td.appendChild(e); tr.addEventListener("click",function(ev){ - fetch("GET","/changes/url?url="+encodeURIComponent(url),function(status,body){ - if(status!=200){ - alert("Error getting data: ("+status+") "+body); - return; - } - var data; - try { - data=JSON.parse(body); - } catch(e){ - alert("Server sent invalid data!"); - console.log("Invalid data:",data); - return; - } - focusData(data); - }); + focusURL(url); }); tr.appendChild(td); @@ -220,6 +248,9 @@ h1{ #timelinetbl td, #timelinetbl th{ border:1px #888 solid; } +#timelinetbl td:nth-child(3){ + font-size:10px; +} tr.repeated{ color:#aaa; diff --git a/modules/changes/changes.js b/modules/changes/changes.js index b491e0b..7c21326 100644 --- a/modules/changes/changes.js +++ b/modules/changes/changes.js @@ -158,7 +158,7 @@ module.exports=function(app,io,_moddir){ persist.setItemSync("urls",urls); res.send(); }); - app.delete("/changes/url/delete",function(req,res){ + app.delete("/changes/url/history",function(req,res){ var param; try {param=JSON.parse(req.body);} catch(e){ @@ -184,6 +184,7 @@ module.exports=function(app,io,_moddir){ i--; } } + persist.setItemSync("urls",urls); res.status(200); res.send(); }); |