Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lejmr committed Mar 5, 2020
1 parent 0c7dc9c commit 0807980
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function edit_cb(image)

var draft = localStorage.getItem('.draft-' + name);

// Prefer the draft from browser cache
if(draft == null){
// Try to find on-disk stored draft file
jQuery.post(
Expand All @@ -48,10 +49,11 @@ function edit_cb(image)
},
function(data) {
if (data.content != 'NaN') {
// Convert to string
draft = data + "";

// Set draft from received data
draft = data;

// Handle the discard
// Handle the discard - remove on disk
if (!confirm("A version of this diagram from " + new Date(data.lastModified) + " is available. Would you like to continue editing?"))
{
// clean draft variable
Expand All @@ -70,10 +72,10 @@ function edit_cb(image)
}
}
);
}

if (draft != null)
}
else
{

draft = JSON.parse(draft);

if (!confirm("A version of this diagram from " + new Date(draft.lastModified) + " is available. Would you like to continue editing?"))
Expand Down

0 comments on commit 0807980

Please sign in to comment.