From 5252d20aacd29d2077ad34f1262d481c981632b0 Mon Sep 17 00:00:00 2001 From: benweet Date: Tue, 22 Apr 2014 00:18:45 +0100 Subject: [PATCH] Added recovery in error 404 page --- public/error_404.html | 5 +++-- public/recovery.html | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/public/error_404.html b/public/error_404.html index 7cc35b25..18b28e94 100644 --- a/public/error_404.html +++ b/public/error_404.html @@ -1,6 +1,6 @@ - + StackEdit - 404 @@ -9,13 +9,14 @@ - +

404 — Page not found

+

Need StackEdit recovery?

diff --git a/public/recovery.html b/public/recovery.html index de25fe9f..90480a9b 100644 --- a/public/recovery.html +++ b/public/recovery.html @@ -1,6 +1,6 @@ - + StackEdit - Recovery @@ -16,7 +16,15 @@ baseUrl: window.baseDir, deps: ['main'] }; - setTimeout(function() { + var timer = 5; + function waitTimer() { + try { + document.getElementById('timer').textContent = --timer; + } + catch(e) {} + if(timer) { + return setTimeout(waitTimer, 1000); + } var failure = false; try { // Try to use StackEdit dependencies to save a file @@ -29,14 +37,15 @@ failure = true; } listFiles(); - + // Show finish messages var eltList = document.querySelectorAll(failure ? '.download-failure' : '.download-success'); for (var i = 0; i < eltList.length; ++i) { var elt = eltList[i]; show(elt); } - }, 5000); + } + setTimeout(waitTimer, 1000); function show(elt) { elt.className = elt.className.replace(/ hide/, ''); @@ -50,14 +59,14 @@ "'": ''', "/": '/' }; - + function escapeHtml(string) { return String(string).replace(/[&<>"'\/]/g, function(s) { return entityMap[s]; }); } - - function listFiles() { + + function listFiles() { // List files var fileListElt = document.querySelector('.file-list'); fileListElt.innerHTML = ''; @@ -76,7 +85,7 @@ fileListElt.appendChild(divElt); } } - + function removeFile(fileIndex) { var ok = confirm('Are you sure you want to remove "' + localStorage[fileIndex + '.title'] + '"?'); if(ok) { @@ -89,7 +98,7 @@ listFiles(); } } - + function clearLocalStorage() { var ok = confirm('This will remove all your documents and settings. Are you sure?'); if(ok) { @@ -100,7 +109,7 @@ - +

@@ -109,7 +118,7 @@

StackEdit recovery

- The download of your documents and settings will start in 5 seconds... + The download of your documents and settings will start in 5 seconds...

To import your documents and settings back in StackEdit: