Page MenuHome GnuPG

No OneTemporary

diff --git a/ui/content/autocryptSetupPasswd.js b/ui/content/autocryptSetupPasswd.js
index 43f326c1..a72c1f93 100644
--- a/ui/content/autocryptSetupPasswd.js
+++ b/ui/content/autocryptSetupPasswd.js
@@ -1,75 +1,107 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*global Components: false */
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://enigmail/locale.jsm"); /*global EnigmailLocale: false */
var gInputArgs;
function onLoad() {
gInputArgs = window.arguments[0];
if (gInputArgs.dlgMode !== "input") {
document.getElementById("enigmailAutocryptSetupPasswd").buttons = "accept";
document.getElementById("dlgDesc").setAttribute("description", EnigmailLocale.getString("enigmail.acSetupPasswd.descCopyPasswd"));
let b = document.getElementById("enigmailAutocryptSetupPasswd").getButton("accept");
b.focus();
}
else {
document.getElementById("dlgDesc").setAttribute("description", EnigmailLocale.getString("enigmail.acSetupPasswd.descEnterPasswd"));
}
- if (gInputArgs.passwdType == "9x4") {
+ if (gInputArgs.passwdType == "numeric9x4") {
if ("initialPasswd" in gInputArgs) {
- //document.getElementById("l1").setAttribute("value", gInputArgs.initialPasswd.substr(0, 2));
document.getElementById("l1").value = gInputArgs.initialPasswd.substr(0, 2);
}
- if (gInputArgs.dlgMode !== "input") {
+ if (gInputArgs.dlgMode === "input") {
+ validate9x4Input();
+ }
+ else {
+ let bc = document.getElementById("bc-input");
+ bc.readOnly = true;
+ bc.setAttribute("class", "plain enigmailTitle");
for (let i = 1; i < 10; i++) {
let p = document.getElementById("l" + i);
p.value = gInputArgs.initialPasswd.substr((i - 1) * 5, 4);
- p.readOnly = true;
- p.setAttribute("class", "plain enigmailTitle");
}
}
}
else {
document.getElementById("dlg9x4").setAttribute("collapsed", true);
document.getElementById("dlgGeneric").removeAttribute("collapsed");
if (gInputArgs.dlgMode !== "input") {
let p = document.getElementById("genericPasswd");
p.value = gInputArgs.initialPasswd;
p.setAttribute("class", "plain enigmailTitle");
p.readOnly = true;
}
}
}
function onAccept() {
if (gInputArgs.dlgMode === "input") {
- if (gInputArgs.passwdType === "9x4") {
+ if (gInputArgs.passwdType === "numeric9x4") {
let passwd = "";
for (let i = 1; i < 10; i++) {
passwd += document.getElementById("l" + i).value + "-";
}
gInputArgs.password = passwd.substr(0, 44);
}
else {
gInputArgs.password = document.getElementById("genericPasswd").value;
}
}
}
+
+function onNumericInput(targetObj) {
+ if (targetObj.value.length === 4) {
+ document.commandDispatcher.advanceFocus();
+ }
+
+
+ let b = document.getElementById("enigmailAutocryptSetupPasswd").getButton("accept");
+ validate9x4Input();
+}
+
+
+function validate9x4Input() {
+ let isValid = true;
+
+ for (let i = 1; i < 10; i++) {
+ let p = document.getElementById("l" + i);
+ isValid = (p.value.search(/^[0-9]{4}$/) === 0);
+ if (!isValid) break;
+ }
+
+ let b = document.getElementById("enigmailAutocryptSetupPasswd").getButton("accept");
+ if (isValid) {
+ b.removeAttribute("disabled");
+ }
+ else {
+ b.setAttribute("disabled", "true");
+ }
+}
diff --git a/ui/content/autocryptSetupPasswd.xul b/ui/content/autocryptSetupPasswd.xul
index 287a3cbe..2a892371 100644
--- a/ui/content/autocryptSetupPasswd.xul
+++ b/ui/content/autocryptSetupPasswd.xul
@@ -1,65 +1,74 @@
<?xml version="1.0"?>
<!--
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://enigmail/skin/enigmail.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % enigMailDTD SYSTEM "chrome://enigmail/locale/enigmail.dtd" >
%enigMailDTD;
]>
<dialog id="enigmailAutocryptSetupPasswd"
title="&enigmail.acSetupPasswd.dlgTitle;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
buttons="accept,cancel"
ondialogaccept="onAccept();"
onload="onLoad();">
<script type="application/x-javascript" src="chrome://enigmail/content/autocryptSetupPasswd.js"/>
+ <broadcasterset>
+ <broadcaster id="bc-input"
+ maxlength="4"
+ multiline="false"
+ placeholder="1234"
+ size="4"
+ oninput="onNumericInput(this)"/>
+ </broadcasterset>
+
<dialogheader id="dlgDesc"
title="&enigmail.acSetupPasswd.dlgTitle;"
description="..."/>
<vbox id="dlg9x4" align="center">
<hbox align="center">
- <textbox id="l1" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l1" observes="bc-input"/>
<label value="-"/>
- <textbox id="l2" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l2" observes="bc-input"/>
<label value="-"/>
- <textbox id="l3" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l3" observes="bc-input"/>
</hbox>
<hbox align="center">
- <textbox id="l4" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l4" observes="bc-input"/>
<label value="-"/>
- <textbox id="l5" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l5" observes="bc-input"/>
<label value="-"/>
- <textbox id="l6" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l6" observes="bc-input"/>
</hbox>
<hbox align="center">
- <textbox id="l7" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l7" observes="bc-input"/>
<label value="-"/>
- <textbox id="l8" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l8" observes="bc-input"/>
<label value="-"/>
- <textbox id="l9" maxlength="4" multiline="false" placeholder="1234" size="4"/>
+ <textbox id="l9" observes="bc-input"/>
</hbox>
</vbox>
<vbox id="dlgGeneric" align="center" collapsed="true">
<hbox align="center">
<label value="&enigmail.acSetupPasswd.password;"/>
<textbox id="genericPasswd" size="45"/>
</hbox>
</vbox>
</dialog>

File Metadata

Mime Type
text/x-diff
Expires
Fri, Mar 13, 8:40 AM (1 d, 11 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
eb/7f/2b2c61ac3da922886640c075f5a1

Event Timeline