diff options
author | Wu Cheng-Han | 2016-09-18 16:33:33 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2016-09-18 16:33:33 +0800 |
commit | f1c9874ed077e9880a5362d93bd2c6c054c1ddc1 (patch) | |
tree | 29847f520dd1b568cff3c3f6c2ab83956b92fbbc /public | |
parent | 3840308ab6cbda7a9a9aa57f1700165e7c95d250 (diff) |
Update to support save mode to url and parse mode from url
Diffstat (limited to 'public')
-rw-r--r-- | public/js/index.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/public/js/index.js b/public/js/index.js index c800cd9d..e192db59 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -195,10 +195,16 @@ var supportExtraTags = [ } ]; var modeType = { - edit: {}, - view: {}, - both: {} -} + edit: { + name: "edit" + }, + view: { + name: "view" + }, + both: { + name: "both" + } +}; var statusType = { connected: { msg: "CONNECTED", @@ -215,7 +221,7 @@ var statusType = { label: "label-danger", fa: "fa-plug" } -} +}; var defaultMode = modeType.view; //global vars @@ -1133,6 +1139,8 @@ function changeMode(type) { ui.area.view.show(); break; } + // save mode to url + if (history.replaceState && loaded) history.replaceState(null, "", serverurl + '/' + noteid + '?' + currentMode.name); if (currentMode == modeType.view) { editor.getInputField().blur(); } @@ -2416,6 +2424,11 @@ socket.on('refresh', function (data) { else currentMode = modeType.both; } + // parse mode from url + if (window.location.search.length > 0) { + var urlMode = modeType[window.location.search.substr(1)]; + if (urlMode) currentMode = urlMode; + } changeMode(currentMode); if (nocontent && !visibleXS) { editor.focus(); |