You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RnQ/Distro/Template/enterpassword.htm

111 lines
3.8 KiB
HTML

<html window-resizable="false" window-icon="themepicsingle:key">
<head>
<include src="common.htm" />
<style src="enterpassword.css" />
<script>
var password = $("#password"),
oldpwd = $("#oldpwd"),
newpwd = $("#newpwd"),
confirmpwd = $("#confirmpwd");
view.uniqueid = view.parameters.type != "acc" ? "loginpassword" : "accpassword";
view.isDialog = true;
if (view.icon == null) CommonNative.SetLargeWindowIcon(document, "");
if (view.parameters.type == "lockpwd") document.classList.add("lock");
CommonNative.ShowTaskbarButton(document);
setupWindow(false, view.parameters.type == "lockpwd", false);
translateWindow("span");
animateWindow();
function submitPassword() {
if (view.parameters.maxlength > 0 && password.value.length > view.parameters.maxlength) {
showAlert("warning", "Entered password is too long");
return;
} else if (password.value.length > 8 && CommonNative.IsAIM()) {
showAlert("info", "Please enter only first 8 symbols of your password");
return;
}
view.close(password.value);
}
function submitLockPassword() {
if (CommonNative.CheckLockPassword(password.value)) {
view.close();
MainNative.Unlock();
} else {
password.value = "";
showAlert("error", "The password you entered is incorrect");
}
}
function saveAccPassword() {
if (newpwd.value != confirmpwd.value) {
showAlert("warning", "You mistyped the new password. Re-type it, please.");
return;
} else if (oldpwd.value != CommonNative.GetAccountPassword()) {
showAlert("error", "The password you entered is incorrect");
return;
}
CommonNative.SaveAccountPassword(newpwd.value);
view.close();
}
var elements = $$("[novalue]");
var texts = [];
for (let element of elements) texts.push(element.attr["novalue"]);
if (texts.length > 0) {
var ttexts = CommonNative.GetTranslations(texts);
for (let [index, element] of elements.entries())
element.attr["novalue"] = ttexts[index];
}
if (view.parameters.password) password.value = view.parameters.password;
if (view.parameters.type == "acc") {
$("#acc").state.expanded = true;
$("#setaccpwd").state.focus = true;
$("#setaccpwd").on("click", () => { saveAccPassword() });
} else {
$("#login").state.expanded = true;
$("#password").state.focus = true;
if (view.parameters.type == "lockpwd") {
$("#hint").html = view.parameters.hint;
$("#hint").state.expanded = true;
$("#setloginpwd").on("click", () => { submitLockPassword() });
view.activate(true);
} else {
$("#setloginpwd").on("click", () => { submitPassword() });
}
}
document.on("keydown", (e) => {
if (e.keyCode == Event.VK_ESCAPE || (e.ctrlKey && e.keyCode == Event.VK_W)) {
view.close();
if (view.parameters.type == "lockpwd") MainNative.Quit();
} else if (e.keyCode == Event.VK_RETURN) {
if (e.target == password && view.parameters.type == "lockpwd") submitLockPassword();
else if (e.target == password) submitPassword();
else if (e.target == oldpwd || e.target == newpwd || e.target == confirmpwd) saveAccPassword();
}
}).on("closerequest", (e) => {
if (e.reason == Event.REASON_BY_CHROME && view.parameters.type == "lockpwd") {
e.preventDefault();
view.close();
MainNative.Quit();
}
});
</script>
</head>
<body>
<div id="hint"></div>
<div class="row" id="login">
<input uwp type="password" id="password" />
<button uwp id="setloginpwd"><span>OK</span></button>
</div>
<div class="row" id="acc">
<input uwp type="password" novalue="Current password" class="accpwd" id="oldpwd" />
<input uwp type="password" novalue="New password" class="accpwd" id="newpwd" />
<input uwp type="password" novalue="Re-type the new password" class="accpwd" id="confirmpwd" />
<button uwp wide id="setaccpwd"><span>Save new password</span></button>
</div>
</body>
</html>