summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--public/js/index.js23
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();