Hash added

This commit is contained in:
George Berezhnoy 2017-02-11 19:02:00 +03:00
commit 7bdd655f54
9 changed files with 26 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -10,6 +10,7 @@ module.exports = (function (editor) {
'use strict';
editor.version = VERSION;
editor.currentHash = null;
var init = function () {
@ -79,6 +80,7 @@ module.exports = (function (editor) {
editor.state = {
jsonOutput: [],
savingDate: null,
hash : null,
blocks : [],
inputs : []
};

View file

@ -191,6 +191,7 @@
},
},
data : {
hash: 1486828599309,
savingDate: 0,
items: [
{
@ -207,7 +208,7 @@
anchor: 'Update',
},
],
count: 2
count: 2,
}
});
</script>

View file

@ -28,6 +28,7 @@ module.exports = (function (core) {
if (userSettings.data) {
editor.state.blocks = userSettings.data;
editor.currentHash = userSettings.data.hash || +new Date();
}

View file

@ -34,6 +34,7 @@ module.exports = (function (saver) {
.then(function () {
editor.state.savingDate = +new Date();
editor.state.hash = editor.currentHash;
})

View file

@ -6,9 +6,10 @@
*/
var storage = function () {
var editor = codex.editor,
LOCAL_STORAGE_KEY = 'codex.editor.savedData',
interval = null,
var editor = codex.editor,
CURRENT_ARTICLE_HASH = null,
LOCAL_STORAGE_KEY = null,
interval = null,
config_ = {
savingInterval: 1000
};
@ -34,6 +35,9 @@ var storage = function () {
}
CURRENT_ARTICLE_HASH = editor.currentHash;
LOCAL_STORAGE_KEY = 'codex.editor.savedData.'+CURRENT_ARTICLE_HASH;
config_ = config || config_;
var localData = get();
@ -49,26 +53,30 @@ var storage = function () {
editor.state.blocks = localData;
editor.renderer.rerender();
init(config_.saveInterval);
init(config_.savingInterval);
},
cancel : function () {
init(config_.saveInterval);
init(config_.savingInterval);
}
});
} else {
init(config_.savingInterval);
}
return Promise.resolve();
};
var init = function (saveInterval) {
var init = function (savingInterval) {
interval = window.setInterval(save, saveInterval);
interval = window.setInterval(save, savingInterval);
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long