changed: use prompt instead of authent page
This commit is contained in:
		
							parent
							
								
									ca4a54f36a
								
							
						
					
					
						commit
						cc0b0ad328
					
				| 
						 | 
					@ -22,13 +22,6 @@
 | 
				
			||||||
			<div id="network"></div>
 | 
								<div id="network"></div>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<div id="authentpage" hidden>
 | 
					 | 
				
			||||||
			<div id="bigtitle">notes</div>
 | 
					 | 
				
			||||||
			<div>
 | 
					 | 
				
			||||||
				<input id="password" type="password" placeholder="pass phrase..." onkeydown="sendpassword()" onblur="sendpassword()" ></input>
 | 
					 | 
				
			||||||
			</div>
 | 
					 | 
				
			||||||
		</div>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		<div id="searchdialog" oninput="applyfilter()" hidden>
 | 
							<div id="searchdialog" oninput="applyfilter()" hidden>
 | 
				
			||||||
			<div>
 | 
								<div>
 | 
				
			||||||
				<input id="filter" placeholder="search..." autocomplete="off"></input>
 | 
									<input id="filter" placeholder="search..." autocomplete="off"></input>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										48
									
								
								main.js
								
								
								
								
							
							
						
						
									
										48
									
								
								main.js
								
								
								
								
							| 
						 | 
					@ -15,7 +15,8 @@ var defaultsettings =
 | 
				
			||||||
	titlebydefault: false,
 | 
						titlebydefault: false,
 | 
				
			||||||
	linksinnewtab: true,
 | 
						linksinnewtab: true,
 | 
				
			||||||
	colors: true,
 | 
						colors: true,
 | 
				
			||||||
	bulletrendering: "•"
 | 
						bulletrendering: "•",
 | 
				
			||||||
 | 
						password: ""
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//builtin
 | 
					//builtin
 | 
				
			||||||
| 
						 | 
					@ -128,10 +129,6 @@ var commands = [
 | 
				
			||||||
	action: searchtags,
 | 
						action: searchtags,
 | 
				
			||||||
	shortcut: "ctrl+shift+T"
 | 
						shortcut: "ctrl+shift+T"
 | 
				
			||||||
},
 | 
					},
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	hint: "Log out",
 | 
					 | 
				
			||||||
	action: logout,
 | 
					 | 
				
			||||||
},
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	hint: "Toggle split view",
 | 
						hint: "Toggle split view",
 | 
				
			||||||
	action: togglesplit
 | 
						action: togglesplit
 | 
				
			||||||
| 
						 | 
					@ -993,15 +990,6 @@ function isremote()
 | 
				
			||||||
	return currentvault == "remote";
 | 
						return currentvault == "remote";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function logout()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (isremote())
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		window.localStorage.removeItem("password");
 | 
					 | 
				
			||||||
		togglepassword();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function tagslist()
 | 
					function tagslist()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tags = {};
 | 
						tags = {};
 | 
				
			||||||
| 
						 | 
					@ -1340,7 +1328,12 @@ function init()
 | 
				
			||||||
				window.localStorage.setItem("remote", JSON.stringify(data));
 | 
									window.localStorage.setItem("remote", JSON.stringify(data));
 | 
				
			||||||
				loadstorage();
 | 
									loadstorage();
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
			.catch(remotecallfailed);
 | 
								.catch(err =>
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										settings.password = prompt("Password: ", settings.password);
 | 
				
			||||||
 | 
										savesettings();
 | 
				
			||||||
 | 
										init();
 | 
				
			||||||
 | 
									});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
| 
						 | 
					@ -1367,15 +1360,6 @@ function init()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function togglepassword()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	password.value = "";
 | 
					 | 
				
			||||||
	authentpage.hidden = false;
 | 
					 | 
				
			||||||
	notepage.style.display = "none";
 | 
					 | 
				
			||||||
	document.title = "notes";
 | 
					 | 
				
			||||||
	password.focus();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function cvdt(text)
 | 
					function cvdt(text)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	var day = text.substr(0,8);
 | 
						var day = text.substr(0,8);
 | 
				
			||||||
| 
						 | 
					@ -1445,7 +1429,7 @@ function queryremote(params)
 | 
				
			||||||
		stat.cur.q++;
 | 
							stat.cur.q++;
 | 
				
			||||||
		stat.ses.q++;
 | 
							stat.ses.q++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		params.password = window.localStorage.getItem("password");
 | 
							params.password = settings.password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		var paramlist = [];
 | 
							var paramlist = [];
 | 
				
			||||||
		for (var i in params)
 | 
							for (var i in params)
 | 
				
			||||||
| 
						 | 
					@ -1484,8 +1468,7 @@ function queryremote(params)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						if (data.error == "authent")
 | 
											if (data.error == "authent")
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							failed();
 | 
												failed("Authent failed");
 | 
				
			||||||
							togglepassword();
 | 
					 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						else
 | 
											else
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
| 
						 | 
					@ -1498,7 +1481,6 @@ function queryremote(params)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					else
 | 
										else
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						authentpage.hidden = true;
 | 
					 | 
				
			||||||
						notepage.style.display = "table";
 | 
											notepage.style.display = "table";
 | 
				
			||||||
						apply(data);
 | 
											apply(data);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
| 
						 | 
					@ -2846,16 +2828,6 @@ function loadnote(name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function sendpassword()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (!authentpage.hidden && (event.type == "blur" || event.key == "Enter"))
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		event.preventDefault();
 | 
					 | 
				
			||||||
		window.localStorage.setItem("password", password.value);
 | 
					 | 
				
			||||||
		init();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function focuseditor()
 | 
					function focuseditor()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (document.documentElement == event.srcElement)
 | 
						if (document.documentElement == event.srcElement)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue