added: stats on http queries
added: theme Breakers changed: deleted notes now only kept in browser local storage refactor: note renaming
This commit is contained in:
		
							parent
							
								
									79523befc2
								
							
						
					
					
						commit
						d596211d41
					
				
							
								
								
									
										91
									
								
								main.js
								
								
								
								
							
							
						
						
									
										91
									
								
								main.js
								
								
								
								
							| 
						 | 
					@ -34,6 +34,20 @@ var tags = null;
 | 
				
			||||||
var currentvault = "";
 | 
					var currentvault = "";
 | 
				
			||||||
var currenttag = "";
 | 
					var currenttag = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var stat = 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ses:
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							q: 0,
 | 
				
			||||||
 | 
							t: timestamp()
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						cur:
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							q: 0,
 | 
				
			||||||
 | 
							t: timestamp()
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var themes = 
 | 
					var themes = 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Default:
 | 
						Default:
 | 
				
			||||||
| 
						 | 
					@ -89,6 +103,15 @@ var themes =
 | 
				
			||||||
		fontcolor: "rgb(60,60,60)",
 | 
							fontcolor: "rgb(60,60,60)",
 | 
				
			||||||
		lineheight: "28.5px",
 | 
							lineheight: "28.5px",
 | 
				
			||||||
		accentcolor: "rgb(60,60,60)"
 | 
							accentcolor: "rgb(60,60,60)"
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						Breakers:
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							bgcolor: "rgb(252,253,253)",
 | 
				
			||||||
 | 
							fontfamily: "'Consolas', monospace",
 | 
				
			||||||
 | 
							fontsize: "15px",
 | 
				
			||||||
 | 
							fontcolor: "rgb(50,50,50)",
 | 
				
			||||||
 | 
							lineheight: "110%",
 | 
				
			||||||
 | 
							accentcolor: "rgb(95,180,180)"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -243,7 +266,7 @@ var commands = [
 | 
				
			||||||
	action: selecttheme
 | 
						action: selecttheme
 | 
				
			||||||
},
 | 
					},
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	hint: "Show note info",
 | 
						hint: "Show info",
 | 
				
			||||||
	action: showinfo,
 | 
						action: showinfo,
 | 
				
			||||||
	shortcut: "ctrl+w",
 | 
						shortcut: "ctrl+w",
 | 
				
			||||||
	allowunsaved: true
 | 
						allowunsaved: true
 | 
				
			||||||
| 
						 | 
					@ -290,14 +313,18 @@ var snippets = [
 | 
				
			||||||
function showinfo()
 | 
					function showinfo()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	var tags = gettags(currentnote);
 | 
						var tags = gettags(currentnote);
 | 
				
			||||||
	var info = [ 
 | 
						showtemporaryinfo(
 | 
				
			||||||
		"title: " + currentnote.title + "\n",
 | 
							[ 
 | 
				
			||||||
		"vault: " + currentvault + "\n",
 | 
								"title: " + currentnote.title,
 | 
				
			||||||
		(tags ? "tags: " + tags + "\n" : ""),
 | 
								"vault: " + currentvault,
 | 
				
			||||||
		"saved: " + saved,
 | 
								(tags ? "tags: " + tags : ""),
 | 
				
			||||||
		"word count: " + getwords()];
 | 
								"saved: " + saved,
 | 
				
			||||||
 | 
								"word count: " + getwords(),
 | 
				
			||||||
	showtemporaryinfo(info);
 | 
								"current note start: " + stat.cur.t,
 | 
				
			||||||
 | 
								"current note queries: " + stat.cur.q,
 | 
				
			||||||
 | 
								"session start: " + stat.ses.t,
 | 
				
			||||||
 | 
								"session queries: " + stat.ses.q
 | 
				
			||||||
 | 
							]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function loadtheme(theme)
 | 
					function loadtheme(theme)
 | 
				
			||||||
| 
						 | 
					@ -795,6 +822,9 @@ function queryremote(params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return new Promise( (apply, failed) => {
 | 
						return new Promise( (apply, failed) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							stat.cur.q++;
 | 
				
			||||||
 | 
							stat.ses.q++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		params.password = window.localStorage.getItem("password");
 | 
							params.password = window.localStorage.getItem("password");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		var paramlist = [];
 | 
							var paramlist = [];
 | 
				
			||||||
| 
						 | 
					@ -1519,15 +1549,12 @@ function deletenote()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (confirm('delete "' + currentnote.title + '"?'))
 | 
						if (confirm('delete "' + currentnote.title + '"?'))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		var error = rename(".deleted_" + currentnote.title);
 | 
							var trash = JSON.parse(window.localStorage.getItem("trash")) || [];
 | 
				
			||||||
		if (!error)
 | 
							trash.push(currentnote);
 | 
				
			||||||
		{
 | 
							loadlast();
 | 
				
			||||||
			loadlast();
 | 
							window.localStorage.setItem("trash", JSON.stringify(trash));
 | 
				
			||||||
		}
 | 
							localdata = localdata.filter(n => n != currentnote);
 | 
				
			||||||
		else
 | 
							datachanged();
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			console.warn("Failed to delete '" + currentnote.title + "'");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1630,17 +1657,26 @@ function setwindowtitle()
 | 
				
			||||||
function ontitlechange()
 | 
					function ontitlechange()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	var oldname = currentnote.title;
 | 
						var oldname = currentnote.title;
 | 
				
			||||||
	var error = rename(title.value);
 | 
						
 | 
				
			||||||
 | 
						if (localdata.find(n => n.title == title.value))
 | 
				
			||||||
	if (!error)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		console.log("'" + oldname + "' renamed to '" + currentnote.title + "'");
 | 
					 | 
				
			||||||
		setwindowtitle();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
							showtemporaryinfo(title.value + " alreday exists");
 | 
				
			||||||
		title.value = currentnote.title;
 | 
							title.value = currentnote.title;
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// rename internal references
 | 
				
			||||||
 | 
						localdata
 | 
				
			||||||
 | 
						.filter(note => note != currentnote)
 | 
				
			||||||
 | 
						.forEach(note =>
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							note.content = note.content.replaceAll("[[" + currentnote.title + "]]", "[[" + title.value + "]]");
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						currentnote.title = title.value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						datachanged();
 | 
				
			||||||
 | 
						setwindowtitle();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function applyfilter()
 | 
					function applyfilter()
 | 
				
			||||||
| 
						 | 
					@ -1792,6 +1828,9 @@ function loadnote(name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bindfile(note);
 | 
						bindfile(note);
 | 
				
			||||||
	putontop();
 | 
						putontop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						stat.cur.q = 0;
 | 
				
			||||||
 | 
						stat.cur.t = timestamp();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function sendpassword()
 | 
					function sendpassword()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue