]> Softwares of Agnibho - sysrev.git/commitdiff
Confirm before reloading from URL master
authorAgnibho Mondal <mondal@agnibho.com>
Mon, 31 May 2021 20:22:14 +0000 (01:52 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Mon, 31 May 2021 20:22:14 +0000 (01:52 +0530)
script.js

index ac948e62667840787abc580b247e7dfbf2c9de74..a0bcdb2160a2235ee2f33a0b3deb1b4898a82b31 100644 (file)
--- a/script.js
+++ b/script.js
@@ -5,7 +5,7 @@ var urlParams=new URLSearchParams(window.location.search);
 if(urlParams.has("doi")){
   doi="https://"+urlParams.get("doi")+"/";
 }
-if(localStorage.getItem("bibliographies")){
+if(localStorage.getItem("bibliographies")!=null){
   bibgraph=JSON.parse(localStorage.getItem("bibliographies"));
 }
 function write(){
@@ -56,6 +56,7 @@ function showAllBibs(){
   });
 }
 $(document).ready(function(){
+  showAllBibs();
   $(".step-selector").on("click", ".to-select", function(e){
     e.preventDefault();
     $(this).children("input").prop("checked", !$(this).children("input").prop("checked"));
@@ -70,7 +71,14 @@ $(document).ready(function(){
       file="";
     }
     $.getJSON(urlParams.get("src")+"?callback=?"+file, function(data){
-      bibgraph[data.config.id]=data;
+      if(typeof bibgraph[data.config.id]=="undefined"){
+        bibgraph[data.config.id]=data;
+      }
+      else{
+        if(confirm("Data with same ID already exists. Overwrite?")){
+          bibgraph[data.config.id]=data;
+        }
+      }
       write();
       showAllBibs();
     });