changed: readme

chaned: live preview of theme
This commit is contained in:
quenousimporte 2023-01-23 12:50:52 +01:00
parent 2dc58df8f7
commit 33e8c36357
2 changed files with 36 additions and 28 deletions

43
main.js
View File

@ -286,18 +286,25 @@ var snippets = [
cursor: 0 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() function selecttheme()
{ {
searchinlist(Object.keys(themes)) searchinlist(Object.keys(themes), loadtheme)
.then(theme => { .then(savesettings);
for (var i in themes[theme])
{
settings[i] = themes[theme][i];
}
applystyle();
resize();
window.localStorage.setItem("settings", JSON.stringify(settings));
});
} }
function addtagfilter() function addtagfilter()
@ -441,7 +448,8 @@ function restoresettings()
{ {
if (confirm("Restore default settings?")) if (confirm("Restore default settings?"))
{ {
window.localStorage.setItem("settings", JSON.stringify(defaultsettings)); settings = defaultsettings;
savesettings();
loadsettings(); loadsettings();
} }
} }
@ -613,7 +621,8 @@ function save()
if (currentnote.title == "settings.json") if (currentnote.title == "settings.json")
{ {
window.localStorage.setItem("settings", content); settings = JSON.parse(content);
savesettings();
} }
console.log("data serialized in local storage") console.log("data serialized in local storage")
@ -1255,7 +1264,7 @@ function insert(text, cursoroffset = 0, nbtodelete = 0)
notecontentchanged(); notecontentchanged();
} }
function searchinlist(list) function searchinlist(list, customevent)
{ {
return new Promise(selectitem => return new Promise(selectitem =>
{ {
@ -1275,6 +1284,7 @@ function searchinlist(list)
searchdialog.hidden = true; searchdialog.hidden = true;
selectitem(item); selectitem(item);
} }
elt.customevent = customevent;
filteredlist.appendChild(elt); filteredlist.appendChild(elt);
}); });
@ -1309,6 +1319,11 @@ function applyfileindex()
if (i++ == fileindex) if (i++ == fileindex)
{ {
child.className = "selected"; child.className = "selected";
if (child.customevent)
{
child.customevent(child.textContent);
filter.focus();
}
} }
} }
} }
@ -1432,7 +1447,7 @@ function toggletitle()
function selectnote() function selectnote()
{ {
return searchinlist(list()); return searchinlist(list()/*, loadnote*/);
} }
function searchautocomplete() function searchautocomplete()

View File

@ -2,24 +2,17 @@
## getting started ## getting started
### local launch index.html from your web server or local computer, or try https://notes.ouvaton.org.
* download files your notes are stored in your browser local storage.
* launch index.html
for a more app-feel on windows, try: ## remote mode
``` you can use remote mode with your own php server to access your notes from the cloud.
chrome_proxy.exe --app=index.html
```
### remote * put the source files on your php server
* put files on your php web server
* navigate to index.html * navigate to index.html
* edit settings (ctrl+shift+p, settings) * switch to remote mode: ctrl+shift+V
* change: remote=true
* reload page
to protect your data by a password, edit handler.php and change `$password` variable. 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 ## 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. write a moulinette to flatten them as md files.