summaryrefslogtreecommitdiff
path: root/modules/changes/changes.html
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-05 23:43:39 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-05 23:43:39 +0100
commitc57e57f5ba31db9b8d57f58ce98aab6eac9e48d7 (patch)
treed1d33a051d063d61b071861d6075237d779c4762 /modules/changes/changes.html
parent468e0f73f38ae64f912de3b9ac249b3b1198e76a (diff)
changes: Diffing!
Diffstat (limited to 'modules/changes/changes.html')
-rw-r--r--modules/changes/changes.html59
1 files changed, 56 insertions, 3 deletions
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]);
@@ -67,6 +68,22 @@ function focusData(data){
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)";
e.appendChild(document.createTextNode("Delete till here"));
@@ -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{
<div id="timelinecontainer">
<h2><a id="timelineheader"></a></h2>
<table id="timelinetbl">
- <thead><tr><th>Date</th><th>Hash</th></tr></thead>
+ <thead><tr>
+ <th>Date</th>
+ <th>Hash</th>
+ <th>Old</th>
+ <th>New</th>
+ </tr></thead>
<tbody id="timelinetbody"></tbody>
- </table>
+ </table> <br>
+ <input type="button" value="Show diff" onclick="doShowDiff();"> <br>
+ <pre id="diffbox"></pre>
</div>
</body>
</html>