From: Agnibho Mondal Date: Mon, 31 May 2021 20:22:14 +0000 (+0530) Subject: Confirm before reloading from URL X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=sysrev.git Confirm before reloading from URL --- diff --git a/script.js b/script.js index ac948e6..a0bcdb2 100644 --- 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(); });