Stackedit/public/recovery.html

158 lines
6.5 KiB
HTML
Raw Normal View History

2013-10-20 14:00:08 +00:00
<!DOCTYPE html>
<html>
2014-04-21 23:18:45 +00:00
2013-10-20 14:00:08 +00:00
<head>
<title>StackEdit - Recovery</title>
<link rel="canonical" href="https://stackedit.io/">
<link rel="icon" href="res-min/img/stackedit-32.ico" type="image/x-icon">
<link rel="shortcut icon" href="res-min/img/stackedit-32.ico" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="res-min/themes/default.css">
<script>
// Use http://.../?debug to serve original JavaScript files instead of minified
2013-11-05 23:03:38 +00:00
window.baseDir = 'res-min';
window.noStart = true;
window.require = {
baseUrl: window.baseDir,
2013-10-20 14:00:08 +00:00
deps: ['main']
};
2014-04-21 23:18:45 +00:00
var timer = 5;
function waitTimer() {
try {
document.getElementById('timer').textContent = --timer;
}
catch(e) {}
if(timer) {
return setTimeout(waitTimer, 1000);
}
var failure = false;
2013-10-20 14:00:08 +00:00
try {
// Try to use StackEdit dependencies to save a file
var utils = require('utils');
utils.saveAs(JSON.stringify(localStorage), "StackEdit local storage.json");
}
catch (e) {
// Try something safer
document.getElementsByTagName('textarea')[0].value = JSON.stringify(localStorage);
failure = true;
}
listFiles();
2014-04-21 23:18:45 +00:00
// 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);
2013-10-20 14:00:08 +00:00
}
2014-04-21 23:18:45 +00:00
}
setTimeout(waitTimer, 1000);
2013-10-20 14:00:08 +00:00
function show(elt) {
elt.className = elt.className.replace(/ hide/, '');
}
2013-11-03 22:34:41 +00:00
var entityMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
2014-04-21 23:18:45 +00:00
2013-11-03 22:34:41 +00:00
function escapeHtml(string) {
return String(string).replace(/[&<>"'\/]/g, function(s) {
return entityMap[s];
});
}
2014-04-21 23:18:45 +00:00
function listFiles() {
// List files
var fileListElt = document.querySelector('.file-list');
fileListElt.innerHTML = '';
var fileIndexList = (localStorage['file.list'] || '').split(';');
for (var i = 0; i < fileIndexList.length; ++i) {
var fileIndex = fileIndexList[i];
if(!fileIndex) continue;
var fileTitle = localStorage[fileIndex + '.title'];
var divElt = document.createElement('div');
divElt.innerHTML = [
'<a href="javascript:removeFile(\'',
fileIndex,
'\')" class="icon-trash"></a> ',
2013-11-03 22:34:41 +00:00
escapeHtml(fileTitle),
].join('');
fileListElt.appendChild(divElt);
}
}
2014-04-21 23:18:45 +00:00
function removeFile(fileIndex) {
var ok = confirm('Are you sure you want to remove "' + localStorage[fileIndex + '.title'] + '"?');
if(ok) {
// Protect against multiple windows
localStorage.removeItem('frontWindowId');
localStorage['file.list'] = localStorage['file.list'].replace(';' + fileIndex + ';', ';');
for (var key in localStorage){
key.indexOf(fileIndex) === 0 && localStorage.removeItem(key);
}
listFiles();
}
}
2014-04-21 23:18:45 +00:00
2013-10-20 14:00:08 +00:00
function clearLocalStorage() {
var ok = confirm('This will remove all your documents and settings. Are you sure?');
if(ok) {
localStorage.clear();
listFiles();
}
2013-10-20 14:00:08 +00:00
}
</script>
<script src="res-min/require.js"></script>
</head>
2014-04-21 23:18:45 +00:00
2013-10-20 14:00:08 +00:00
<body>
<div class="container">
<br/>
<a href="https://stackedit.io/">
2013-12-08 18:12:31 +00:00
<img src="res-min/img/logo-promo-128.png" width="316" height="64" />
2013-10-20 14:00:08 +00:00
</a>
<h3>StackEdit recovery</h3>
<p>
2014-04-21 23:18:45 +00:00
<strong>The download of your documents and settings will start in <span id="timer">5</span> seconds...</strong>
2013-10-20 14:00:08 +00:00
</p>
<p>To import your documents and settings back in StackEdit:</p>
<blockquote>
<i class="icon-provider-stackedit"></i>
<code>Menu</code>
<i class="icon-angle-right"></i>
<i class="icon-cog"></i>
<code>Settings</code>
<i class="icon-angle-right"></i>
<code>Utils</code>
<i class="icon-angle-right"></i>
<i class="icon-cog-alt"></i>
<code>Import docs & settings</code>
</blockquote>
<p class="download-success hide text-primary">
<strong>
<i class="icon-ok"></i>Documents and settings have been downloaded successfully.</strong>
</p>
<p class="download-failure hide text-danger">
<strong>
<i class="icon-cancel"></i>Download failed. Please copy/paste the following content in a file:</strong>
</p>
<p>
<textarea class="download-failure hide form-control" rows="10"></textarea>
</p>
<p class="download-success download-failure hide">To remove one document from the local storage
<a href="javascript:void(0)" onclick="show(document.querySelector('.file-list'))">click here</a>.</p>
<p class="file-list hide"></p>
<p class="download-success download-failure hide">To fully clear the local storage
<a href="javascript:void(0)" onclick="clearLocalStorage()">click here</a>.</p>
2013-10-20 14:00:08 +00:00
<p class="download-success download-failure hide">To reopen StackEdit
<a href="https://stackedit.io/">click here</a>.</p>
</div>
</body>
</html>