refactor: trim trailing whitespace
This commit is contained in:
parent
d596211d41
commit
f1893552d3
78
main.js
78
main.js
|
@ -1,4 +1,4 @@
|
||||||
var defaultsettings =
|
var defaultsettings =
|
||||||
{
|
{
|
||||||
bgcolor: "white",
|
bgcolor: "white",
|
||||||
fontfamily: "'Inconsolata', 'Consolas', monospace",
|
fontfamily: "'Inconsolata', 'Consolas', monospace",
|
||||||
|
@ -34,7 +34,7 @@ var tags = null;
|
||||||
var currentvault = "";
|
var currentvault = "";
|
||||||
var currenttag = "";
|
var currenttag = "";
|
||||||
|
|
||||||
var stat =
|
var stat =
|
||||||
{
|
{
|
||||||
ses:
|
ses:
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ var stat =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var themes =
|
var themes =
|
||||||
{
|
{
|
||||||
Default:
|
Default:
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ var themes =
|
||||||
fontsize: "15px",
|
fontsize: "15px",
|
||||||
fontcolor: "rgb(216,222,233)",
|
fontcolor: "rgb(216,222,233)",
|
||||||
lineheight: "110%",
|
lineheight: "110%",
|
||||||
accentcolor: "rgb(249,174,88)"
|
accentcolor: "rgb(249,174,88)"
|
||||||
},
|
},
|
||||||
"Plus plus":
|
"Plus plus":
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ var themes =
|
||||||
fontsize: "15px",
|
fontsize: "15px",
|
||||||
fontcolor: "black",
|
fontcolor: "black",
|
||||||
lineheight: "110%",
|
lineheight: "110%",
|
||||||
accentcolor: "rgb(128,0,255)"
|
accentcolor: "rgb(128,0,255)"
|
||||||
},
|
},
|
||||||
Calmly:
|
Calmly:
|
||||||
{
|
{
|
||||||
|
@ -236,11 +236,11 @@ var commands = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hint: "Settings",
|
hint: "Settings",
|
||||||
action: editsettings
|
action: editsettings
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hint: "Restore default settings",
|
hint: "Restore default settings",
|
||||||
action: restoresettings
|
action: restoresettings
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hint: "Note outline",
|
hint: "Note outline",
|
||||||
|
@ -249,7 +249,7 @@ var commands = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hint: "Internal links",
|
hint: "Internal links",
|
||||||
action: showinternallinks
|
action: showinternallinks
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hint: "Switch vault",
|
hint: "Switch vault",
|
||||||
|
@ -314,7 +314,7 @@ function showinfo()
|
||||||
{
|
{
|
||||||
var tags = gettags(currentnote);
|
var tags = gettags(currentnote);
|
||||||
showtemporaryinfo(
|
showtemporaryinfo(
|
||||||
[
|
[
|
||||||
"title: " + currentnote.title,
|
"title: " + currentnote.title,
|
||||||
"vault: " + currentvault,
|
"vault: " + currentvault,
|
||||||
(tags ? "tags: " + tags : ""),
|
(tags ? "tags: " + tags : ""),
|
||||||
|
@ -345,7 +345,7 @@ function savesettings()
|
||||||
function selecttheme()
|
function selecttheme()
|
||||||
{
|
{
|
||||||
searchinlist(Object.keys(themes), loadtheme)
|
searchinlist(Object.keys(themes), loadtheme)
|
||||||
.then(t =>
|
.then(t =>
|
||||||
{
|
{
|
||||||
loadtheme(t);
|
loadtheme(t);
|
||||||
savesettings();
|
savesettings();
|
||||||
|
@ -355,16 +355,16 @@ function selecttheme()
|
||||||
function addtagfilter()
|
function addtagfilter()
|
||||||
{
|
{
|
||||||
var command = commands.find(c => c.action == addtagfilter);
|
var command = commands.find(c => c.action == addtagfilter);
|
||||||
|
|
||||||
if (!currenttag)
|
if (!currenttag)
|
||||||
{
|
{
|
||||||
tagslist()
|
tagslist()
|
||||||
.then(t =>
|
.then(t =>
|
||||||
{
|
{
|
||||||
currenttag = t;
|
currenttag = t;
|
||||||
command.hint = "Remove tag filter '" + currenttag + "'";
|
command.hint = "Remove tag filter '" + currenttag + "'";
|
||||||
setwindowtitle();
|
setwindowtitle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -386,7 +386,7 @@ function showinternallinks()
|
||||||
getnotecontent()
|
getnotecontent()
|
||||||
.match(/\[\[([^\]]*)\]\]/g || [])
|
.match(/\[\[([^\]]*)\]\]/g || [])
|
||||||
.map(l => l.replace("[[", "").replace("]]", "")))
|
.map(l => l.replace("[[", "").replace("]]", "")))
|
||||||
.then(loadnote);
|
.then(loadnote);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showoutline()
|
function showoutline()
|
||||||
|
@ -402,7 +402,7 @@ function showoutline()
|
||||||
.replace("# ", "")
|
.replace("# ", "")
|
||||||
.replace(/#/g, "\xa0\xa0\xa0\xa0");
|
.replace(/#/g, "\xa0\xa0\xa0\xa0");
|
||||||
outline[line] = pos;
|
outline[line] = pos;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
searchinlist(Object.keys(outline))
|
searchinlist(Object.keys(outline))
|
||||||
.then(line =>
|
.then(line =>
|
||||||
|
@ -512,7 +512,7 @@ function showtemporaryinfo(data)
|
||||||
|
|
||||||
filter.placeholder = "Info";
|
filter.placeholder = "Info";
|
||||||
searchinlist(data)
|
searchinlist(data)
|
||||||
.then(() =>
|
.then(() =>
|
||||||
{
|
{
|
||||||
filter.placeholder = "Search...";
|
filter.placeholder = "Search...";
|
||||||
});
|
});
|
||||||
|
@ -551,8 +551,8 @@ function logout()
|
||||||
if (isremote())
|
if (isremote())
|
||||||
{
|
{
|
||||||
window.localStorage.removeItem("password");
|
window.localStorage.removeItem("password");
|
||||||
togglepassword();
|
togglepassword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tagslist()
|
function tagslist()
|
||||||
|
@ -561,10 +561,10 @@ function tagslist()
|
||||||
|
|
||||||
localdata
|
localdata
|
||||||
.filter(n => !n.title.startsWith("."))
|
.filter(n => !n.title.startsWith("."))
|
||||||
.forEach(n =>
|
.forEach(n =>
|
||||||
{
|
{
|
||||||
var ts = gettags(n);
|
var ts = gettags(n);
|
||||||
ts.forEach(t =>
|
ts.forEach(t =>
|
||||||
{
|
{
|
||||||
tags[t] = tags[t] || [];
|
tags[t] = tags[t] || [];
|
||||||
tags[t].push(n.title);
|
tags[t].push(n.title);
|
||||||
|
@ -600,8 +600,8 @@ function share(html)
|
||||||
{
|
{
|
||||||
text: html ? md2html(getnotecontent()) : getnotecontent(),
|
text: html ? md2html(getnotecontent()) : getnotecontent(),
|
||||||
title: currentnote.title
|
title: currentnote.title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sharehtml()
|
function sharehtml()
|
||||||
|
@ -634,7 +634,7 @@ function downloadnotes()
|
||||||
|
|
||||||
function downloadlocal()
|
function downloadlocal()
|
||||||
{
|
{
|
||||||
var data =
|
var data =
|
||||||
{
|
{
|
||||||
local : JSON.parse(window.localStorage.getItem("local")),
|
local : JSON.parse(window.localStorage.getItem("local")),
|
||||||
remote : JSON.parse(window.localStorage.getItem("remote"))
|
remote : JSON.parse(window.localStorage.getItem("remote"))
|
||||||
|
@ -684,10 +684,10 @@ function applystyle()
|
||||||
document.body.style.lineHeight = settings.lineheight;
|
document.body.style.lineHeight = settings.lineheight;
|
||||||
document.body.style.color = settings.fontcolor;
|
document.body.style.color = settings.fontcolor;
|
||||||
document.body.style.caretColor = settings.accentcolor;
|
document.body.style.caretColor = settings.accentcolor;
|
||||||
|
|
||||||
if (settings.titleinaccentcolor)
|
if (settings.titleinaccentcolor)
|
||||||
{
|
{
|
||||||
title.style.color = settings.accentcolor;
|
title.style.color = settings.accentcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ function loadsettings()
|
||||||
{
|
{
|
||||||
if (typeof item[key] !== "undefined")
|
if (typeof item[key] !== "undefined")
|
||||||
{
|
{
|
||||||
settings[key] = item[key];
|
settings[key] = item[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ function init()
|
||||||
|
|
||||||
window.onbeforeunload = checksaved;
|
window.onbeforeunload = checksaved;
|
||||||
window.onclick = focuseditor;
|
window.onclick = focuseditor;
|
||||||
|
|
||||||
initsnippets();
|
initsnippets();
|
||||||
|
|
||||||
currenttag = "";
|
currenttag = "";
|
||||||
|
@ -800,11 +800,11 @@ function init()
|
||||||
window.onstorage = loadstorage;
|
window.onstorage = loadstorage;
|
||||||
if (settings.defaultpreviewinsplit && name == "right")
|
if (settings.defaultpreviewinsplit && name == "right")
|
||||||
{
|
{
|
||||||
togglepreview();
|
togglepreview();
|
||||||
}
|
}
|
||||||
else if (name == "left")
|
else if (name == "left")
|
||||||
{
|
{
|
||||||
md.focus();
|
md.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -877,7 +877,7 @@ function queryremote(params)
|
||||||
catch(error)
|
catch(error)
|
||||||
{
|
{
|
||||||
failed("Handler result is not valid. JS error: " + error);
|
failed("Handler result is not valid. JS error: " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.send(paramlist.join("&"));
|
xhr.send(paramlist.join("&"));
|
||||||
|
@ -1188,7 +1188,7 @@ function showgrep()
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
searchdialog.hidden = true;
|
searchdialog.hidden = true;
|
||||||
showgrepresult(grep(filter.value));
|
showgrepresult(grep(filter.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,7 +1198,7 @@ function showgrep()
|
||||||
if (filter.value.length > 1)
|
if (filter.value.length > 1)
|
||||||
{
|
{
|
||||||
showgrepresult(grep(filter.value));
|
showgrepresult(grep(filter.value));
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1213,7 +1213,7 @@ function commandpalette()
|
||||||
var command = commands.find(c => c.hint == hint);
|
var command = commands.find(c => c.hint == hint);
|
||||||
if (command)
|
if (command)
|
||||||
{
|
{
|
||||||
executecommand(command);
|
executecommand(command);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1339,7 +1339,7 @@ function putontop()
|
||||||
if (localdata.find(n => n == currentnote))
|
if (localdata.find(n => n == currentnote))
|
||||||
{
|
{
|
||||||
localdata.splice(localdata.indexOf(currentnote), 1);
|
localdata.splice(localdata.indexOf(currentnote), 1);
|
||||||
localdata.unshift(currentnote);
|
localdata.unshift(currentnote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1638,7 +1638,7 @@ function mainkeydownhandler()
|
||||||
if (event.key == s.key && !(s.ctrl && !event.ctrlKey && !event.altKey) && !(s.shift && !event.shiftKey))
|
if (event.key == s.key && !(s.ctrl && !event.ctrlKey && !event.altKey) && !(s.shift && !event.shiftKey))
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
executecommand(command);
|
executecommand(command);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1657,7 +1657,7 @@ function setwindowtitle()
|
||||||
function ontitlechange()
|
function ontitlechange()
|
||||||
{
|
{
|
||||||
var oldname = currentnote.title;
|
var oldname = currentnote.title;
|
||||||
|
|
||||||
if (localdata.find(n => n.title == title.value))
|
if (localdata.find(n => n.title == title.value))
|
||||||
{
|
{
|
||||||
showtemporaryinfo(title.value + " alreday exists");
|
showtemporaryinfo(title.value + " alreday exists");
|
||||||
|
@ -1728,7 +1728,7 @@ function editorkeydown()
|
||||||
insert(" ", 2);
|
insert(" ", 2);
|
||||||
}
|
}
|
||||||
// disable tab
|
// disable tab
|
||||||
/*else
|
/*else
|
||||||
{
|
{
|
||||||
insert(" ");
|
insert(" ");
|
||||||
}*/
|
}*/
|
||||||
|
@ -1745,7 +1745,7 @@ function editorkeydown()
|
||||||
// search in tags list
|
// search in tags list
|
||||||
console.log(event.key);
|
console.log(event.key);
|
||||||
tagslist()
|
tagslist()
|
||||||
.then(tag =>
|
.then(tag =>
|
||||||
{
|
{
|
||||||
insert(" " + tag);
|
insert(" " + tag);
|
||||||
md.focus();
|
md.focus();
|
||||||
|
|
Loading…
Reference in New Issue