Add a default autosave canvas to localstorage

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2273 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Dale Harvey 2013-01-09 23:14:35 +00:00
parent 944e652a01
commit 89416b0ac6
1 changed files with 14 additions and 0 deletions

View File

@ -40,6 +40,7 @@
// changed in the UI and are stored in the browser, config can not
curConfig = {
canvasName: 'default',
canvas_expansion: 3,
dimensions: [640,480],
initFill: {
@ -254,6 +255,12 @@
} else if(urldata.url) {
svgEditor.loadFromURL(urldata.url);
}
} else {
var name = 'svgedit-' + Editor.curConfig.canvasName;
var cached = window.localStorage.getItem(name);
if (cached) {
Editor.loadFromString(cached);
}
}
})();
@ -4364,6 +4371,13 @@
canv_menu.enableContextMenuItems('#delete,#cut,#copy');
window.onbeforeunload = function() {
if ('localStorage' in window) {
var name = 'svgedit-' + Editor.curConfig.canvasName;
window.localStorage.setItem(name, svgCanvas.getSvgString());
Editor.show_save_warning = false;
}
// Suppress warning if page is empty
if(undoMgr.getUndoStackSize() === 0) {
Editor.show_save_warning = false;