Add new note prompt

This commit is contained in:
Andrew-71 2024-05-08 16:49:34 +03:00
parent 7830ae3217
commit 20ca509a2b
8 changed files with 45 additions and 8 deletions

View file

@ -31,4 +31,18 @@ function beginTimeUpdater() {
setTimeout(callEveryMinute, difference);
setTimeout(updateTime, difference);
updateTime();
}
// This does NOT properly sanitize, and assumes a well-meaning user
function sanitize(title) {
return title
.trim()
.replace(/ +/g, '-')
.replace(/[!*'();:@&=+$,\/?#\[\]]/g, '')
}
// Open a new note
function newNote(text_prompt) {
name = sanitize(prompt(text_prompt + ':'))
window.location.replace('/notes/' + name)
}