From c57e57f5ba31db9b8d57f58ce98aab6eac9e48d7 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 5 Jan 2017 23:43:39 +0100 Subject: changes: Diffing! --- modules/changes/changes.html | 59 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) (limited to 'modules/changes/changes.html') diff --git a/modules/changes/changes.html b/modules/changes/changes.html index 739cb28..a7cd439 100644 --- a/modules/changes/changes.html +++ b/modules/changes/changes.html @@ -44,6 +44,7 @@ function focusData(data){ if(!header.firstChild)header.appendChild(document.createTextNode(data.url)); else header.firstChild.nodeValue=data.url; header.setAttribute("href",data.url); + document.getElementById("diffbox").innerHTML=""; var l=tbody.children,i; for(i=l.length-1;i>=0;i--)tbody.removeChild(l[i]); @@ -66,6 +67,22 @@ function focusData(data){ td.appendChild(document.createTextNode(s)); tr.appendChild(td); + td=document.createElement("td"); + e=document.createElement("input"); + e.setAttribute("type","radio"); + e.setAttribute("name","diffold"); + e.setAttribute("value",data.timeline[i][0]); + td.appendChild(e); + tr.appendChild(td); + + td=document.createElement("td"); + e=document.createElement("input"); + e.setAttribute("type","radio"); + e.setAttribute("name","diffnew"); + e.setAttribute("value",data.timeline[i][0]); + td.appendChild(e); + tr.appendChild(td); + td=document.createElement("td"); e=document.createElement("a"); e.href="javascript:void(0)"; @@ -182,6 +199,30 @@ function addURLbutton(){ }); } +function doShowDiff(){ + var oldradio=document.querySelector("input[name=diffold]:checked"); + var newradio=document.querySelector("input[name=diffnew]:checked"); + if(!oldradio||!newradio){ + alert("Select two different records to perform a diff"); + return; + } + var olddate=oldradio.value; + var newdate=newradio.value; + var url=document.getElementById("timelineheader").firstChild.nodeValue; + fetch("POST","/changes/diff", + JSON.stringify({url:url,olddate:olddate,newdate:newdate}), + function(status,body){ + var diffbox; + if(status==200){ + diffbox=document.getElementById("diffbox"); + if(diffbox.firstChild)diffbox.removeChild(diffbox.firstChild); + diffbox.appendChild(document.createTextNode(body)); + } else { + alert("Error: ("+status+") "+body); + } + }); +} + function addURLkeypress(ev){ if(ev.keyCode==10||ev.keyCode==13)addURLbutton(); } @@ -251,8 +292,13 @@ h1{ #timelinetbl td, #timelinetbl th{ border:1px #888 solid; } -#timelinetbl td:nth-child(3){ +#timelinetbl td:nth-child(3), #timelinetbl td:nth-child(4){ + text-align:center; +} +#timelinetbl td:nth-child(5){ font-size:10px; + padding-left:40px; + padding-right:10px; } tr.repeated{ @@ -285,9 +331,16 @@ tr.repeated{

- + + + + + + -
DateHash
DateHashOldNew
+
+
+

 
-- cgit v1.2.3-70-g09d2