diff --git a/main.js b/main.js index 14222b0..358ef7a 100644 --- a/main.js +++ b/main.js @@ -286,18 +286,25 @@ var snippets = [ cursor: 0 }]; +function loadtheme(theme) +{ + for (var i in themes[theme]) + { + settings[i] = themes[theme][i]; + } + applystyle(); + resize(); +} + +function savesettings() +{ + window.localStorage.setItem("settings", JSON.stringify(settings)); +} + function selecttheme() { - searchinlist(Object.keys(themes)) - .then(theme => { - for (var i in themes[theme]) - { - settings[i] = themes[theme][i]; - } - applystyle(); - resize(); - window.localStorage.setItem("settings", JSON.stringify(settings)); - }); + searchinlist(Object.keys(themes), loadtheme) + .then(savesettings); } function addtagfilter() @@ -441,7 +448,8 @@ function restoresettings() { if (confirm("Restore default settings?")) { - window.localStorage.setItem("settings", JSON.stringify(defaultsettings)); + settings = defaultsettings; + savesettings(); loadsettings(); } } @@ -613,7 +621,8 @@ function save() if (currentnote.title == "settings.json") { - window.localStorage.setItem("settings", content); + settings = JSON.parse(content); + savesettings(); } console.log("data serialized in local storage") @@ -1255,7 +1264,7 @@ function insert(text, cursoroffset = 0, nbtodelete = 0) notecontentchanged(); } -function searchinlist(list) +function searchinlist(list, customevent) { return new Promise(selectitem => { @@ -1275,6 +1284,7 @@ function searchinlist(list) searchdialog.hidden = true; selectitem(item); } + elt.customevent = customevent; filteredlist.appendChild(elt); }); @@ -1309,6 +1319,11 @@ function applyfileindex() if (i++ == fileindex) { child.className = "selected"; + if (child.customevent) + { + child.customevent(child.textContent); + filter.focus(); + } } } } @@ -1432,7 +1447,7 @@ function toggletitle() function selectnote() { - return searchinlist(list()); + return searchinlist(list()/*, loadnote*/); } function searchautocomplete() diff --git a/readme.md b/readme.md index b581382..dbf1251 100644 --- a/readme.md +++ b/readme.md @@ -2,24 +2,17 @@ ## getting started -### local +launch index.html from your web server or local computer, or try https://notes.ouvaton.org. -* download files -* launch index.html +your notes are stored in your browser local storage. -for a more app-feel on windows, try: +## remote mode -``` -chrome_proxy.exe --app=index.html -``` +you can use remote mode with your own php server to access your notes from the cloud. -### remote - -* put files on your php web server +* put the source files on your php server * navigate to index.html -* edit settings (ctrl+shift+p, settings) -* change: remote=true -* reload page +* switch to remote mode: ctrl+shift+V to protect your data by a password, edit handler.php and change `$password` variable. @@ -33,6 +26,6 @@ your password will be sent from browser to server through a POST http query with ## reclaim you data -your notes are stored in your browser local storage. download them in a single json file with ctrl+shift+s. +download your notes in a single json file with ctrl+shift+s. write a moulinette to flatten them as md files. \ No newline at end of file