summaryrefslogtreecommitdiffstats
path: root/content/passwordPrompt/passwordPrompt.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--content/passwordPrompt/passwordPrompt.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/content/passwordPrompt/passwordPrompt.js b/content/passwordPrompt/passwordPrompt.js
new file mode 100644
index 0000000..8af40d9
--- /dev/null
+++ b/content/passwordPrompt/passwordPrompt.js
@@ -0,0 +1,47 @@
+/*
+ * This file is part of TbSync.
+ *
+ * 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/.
+ */
+
+ "use strict";
+
+var tbSyncPassword = {
+
+ onload: function () {
+ let data = window.arguments[0];
+ this.resolve = window.arguments[1];
+ this.resolved = false;
+
+ this.namefield = document.getElementById("tbsync.account");
+ this.passfield = document.getElementById("tbsync.password");
+ this.userfield = document.getElementById("tbsync.user");
+
+ this.namefield.value = data.accountname;
+ this.userfield.value = data.username;
+ this.userfield.disabled = data.usernameLocked;
+
+ window.addEventListener("unload", tbSyncPassword.doCANCEL.bind(this));
+ document.getElementById("tbsync.password").focus();
+ document.getElementById("tbsync.password.ok").addEventListener("click", tbSyncPassword.doOK.bind(this));
+ document.getElementById("tbsync.password.cancel").addEventListener("click", () => window.close());
+ },
+
+ doOK: function (event) {
+ if (!this.resolved) {
+ this.resolved = true
+ this.resolve({username: this.userfield.value, password: this.passfield.value});
+ window.close();
+ }
+ },
+
+ doCANCEL: function (event) {
+ if (!this.resolved) {
+ this.resolved = true
+ this.resolve(false);
+ }
+ },
+
+};