|
|
|
@ -20,7 +20,7 @@ function ontextarea(e) {
|
|
|
|
function onsave(e) {
|
|
|
|
function onsave(e) {
|
|
|
|
let saveButton = document.getElementById('saveButton');
|
|
|
|
let saveButton = document.getElementById('saveButton');
|
|
|
|
saveButton.disabled = true;
|
|
|
|
saveButton.disabled = true;
|
|
|
|
let text = save(document.getElementById('ta'), document.getElementById('mdnotes'));
|
|
|
|
let text = save(document.getElementById('ta'), document.getElementById('cheezenotes'));
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
xhttp.onreadystatechange = function () {
|
|
|
|
xhttp.onreadystatechange = function () {
|
|
|
|
if (this.readyState == 4 && this.status != 200) {
|
|
|
|
if (this.readyState == 4 && this.status != 200) {
|
|
|
|
@ -33,11 +33,16 @@ function onsave(e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onload(e) {
|
|
|
|
function onload(e) {
|
|
|
|
load(document.getElementById('ta'), document.getElementById('mdnotes'));
|
|
|
|
load(document.getElementById('ta'), document.getElementById('cheezenotes'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onedit(e) {
|
|
|
|
function onedit(e) {
|
|
|
|
console.log('onedit');
|
|
|
|
|
|
|
|
|
|
|
|
if (e.inputType == 'insertCompositionText') {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
timeoutSave();
|
|
|
|
timeoutSave();
|
|
|
|
saveButton.disabled = false;
|
|
|
|
saveButton.disabled = false;
|
|
|
|
let ret = getStartPositionInLine();
|
|
|
|
let ret = getStartPositionInLine();
|
|
|
|
@ -45,14 +50,14 @@ function onedit(e) {
|
|
|
|
let position = ret[1];
|
|
|
|
let position = ret[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (line.innerText == '\n') {
|
|
|
|
if (line.innerText == '\n') {
|
|
|
|
line.className = 'mdnotes_line';
|
|
|
|
line.className = 'cheezenotes_line';
|
|
|
|
line.classList.add('body');
|
|
|
|
line.classList.add('body');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let prevline = line.previousSibling;
|
|
|
|
let prevline = line.previousSibling;
|
|
|
|
if (prevline != null && prevline.innerText == '\n') {
|
|
|
|
if (prevline != null && prevline.innerText == '\n') {
|
|
|
|
prevline.className = 'mdnotes_line';
|
|
|
|
prevline.className = 'cheezenotes_line';
|
|
|
|
prevline.classList.add('body');
|
|
|
|
prevline.classList.add('body');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,24 +89,24 @@ function onkeydown(e) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onkeypress(e) {
|
|
|
|
function onkeyup(e) {
|
|
|
|
if (e.key !== 'Escape') {
|
|
|
|
if (e.key !== 'Escape') {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
document.getElementById('mdnotes').blur();
|
|
|
|
document.getElementById('cheezenotes').blur();
|
|
|
|
if (saveButton.disabled == false) {
|
|
|
|
if (saveButton.disabled == false) {
|
|
|
|
onsave();
|
|
|
|
onsave();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onkeyup(e) {
|
|
|
|
function onkeypress(e) {
|
|
|
|
if (e.key !== 'Escape') {
|
|
|
|
if (e.key !== 'Escape') {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
document.getElementById('mdnotes').blur();
|
|
|
|
document.getElementById('cheezenotes').blur();
|
|
|
|
if (saveButton.disabled == false) {
|
|
|
|
if (saveButton.disabled == false) {
|
|
|
|
onsave();
|
|
|
|
onsave();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -112,7 +117,7 @@ function onpaste(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
timeoutSave();
|
|
|
|
timeoutSave();
|
|
|
|
let data = e.clipboardData.getData('text/plain');
|
|
|
|
let data = e.clipboardData.getData('text/plain');
|
|
|
|
appendData(document.getElementById('mdnotes'), data);
|
|
|
|
appendData(document.getElementById('cheezenotes'), data);
|
|
|
|
saveButton.disabled = false;
|
|
|
|
saveButton.disabled = false;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -123,11 +128,11 @@ function oncopy(e) {
|
|
|
|
|
|
|
|
|
|
|
|
function onlockbutton(e) {
|
|
|
|
function onlockbutton(e) {
|
|
|
|
let lockButton = document.getElementById('lockButton');
|
|
|
|
let lockButton = document.getElementById('lockButton');
|
|
|
|
let mdnotes = document.getElementById('mdnotes');
|
|
|
|
let cheezenotes = document.getElementById('cheezenotes');
|
|
|
|
if (lockButton.checked) {
|
|
|
|
if (lockButton.checked) {
|
|
|
|
mdnotes.contentEditable = false;
|
|
|
|
cheezenotes.contentEditable = false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
mdnotes.contentEditable = true;
|
|
|
|
cheezenotes.contentEditable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -147,21 +152,21 @@ function init(pagename = null) {
|
|
|
|
/*if (pagename != null) {
|
|
|
|
/*if (pagename != null) {
|
|
|
|
window.history.replaceState(null, '', '/page/' + pagename);
|
|
|
|
window.history.replaceState(null, '', '/page/' + pagename);
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
let mdnotesdiv = document.getElementById('mdnotes');
|
|
|
|
let cheezenotesdiv = document.getElementById('cheezenotes');
|
|
|
|
|
|
|
|
|
|
|
|
dpwidth(mdnotesdiv);
|
|
|
|
dpwidth(cheezenotesdiv);
|
|
|
|
|
|
|
|
|
|
|
|
mdnotesdiv.addEventListener('input', onedit);
|
|
|
|
cheezenotesdiv.addEventListener('input', onedit);
|
|
|
|
mdnotesdiv.addEventListener('keyup', onkeyup);
|
|
|
|
cheezenotesdiv.addEventListener('keyup', onkeyup);
|
|
|
|
mdnotesdiv.addEventListener('keypress', onkeypress);
|
|
|
|
cheezenotesdiv.addEventListener('keypress', onkeypress);
|
|
|
|
mdnotesdiv.addEventListener('keydown', onkeydown);
|
|
|
|
cheezenotesdiv.addEventListener('keydown', onkeydown);
|
|
|
|
mdnotesdiv.addEventListener('paste', onpaste);
|
|
|
|
cheezenotesdiv.addEventListener('paste', onpaste);
|
|
|
|
mdnotesdiv.addEventListener('copy', oncopy);
|
|
|
|
cheezenotesdiv.addEventListener('copy', oncopy);
|
|
|
|
mdnotesdiv.addEventListener('blur', () => {redrawTables(mdnotesdiv); onsave()});
|
|
|
|
cheezenotesdiv.addEventListener('blur', () => { redrawTables(cheezenotesdiv); onsave() });
|
|
|
|
mdnotesdiv.addEventListener('focus', () => {redrawTables(mdnotesdiv, dpwidth());});
|
|
|
|
cheezenotesdiv.addEventListener('focus', () => { redrawTables(cheezenotesdiv, dpwidth()); });
|
|
|
|
mdnotesdiv.addEventListener('drag', ondrag);
|
|
|
|
cheezenotesdiv.addEventListener('drag', ondrag);
|
|
|
|
mdnotesdiv.addEventListener('dragenter', ondragenter);
|
|
|
|
cheezenotesdiv.addEventListener('dragenter', ondragenter);
|
|
|
|
mdnotesdiv.addEventListener('dragleave', ondragleave);
|
|
|
|
cheezenotesdiv.addEventListener('dragleave', ondragleave);
|
|
|
|
|
|
|
|
|
|
|
|
let saveButton = document.getElementById('saveButton');
|
|
|
|
let saveButton = document.getElementById('saveButton');
|
|
|
|
saveButton.disabled = true;
|
|
|
|
saveButton.disabled = true;
|
|
|
|
|