michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock; michael@0: michael@0: var dialogParams; michael@0: var itemCount = 0; michael@0: michael@0: function onLoad() michael@0: { michael@0: dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock); michael@0: michael@0: var hostname = dialogParams.GetString(0); michael@0: var bundle = document.getElementById("pippki_bundle"); michael@0: var intro = bundle.getFormattedString("formSigningIntro", [hostname]); michael@0: setText("sign.intro", intro); michael@0: michael@0: document.getElementById("sign.text").value = dialogParams.GetString(1); michael@0: michael@0: var selectElement = document.getElementById("nicknames"); michael@0: itemCount = dialogParams.GetInt(0); michael@0: for (var index = 0; index < itemCount; ++index) { michael@0: var menuItemNode = document.createElement("menuitem"); michael@0: var nick = dialogParams.GetString(2 + 2 * index); michael@0: menuItemNode.setAttribute("value", index); michael@0: menuItemNode.setAttribute("label", nick); // this is displayed michael@0: selectElement.firstChild.appendChild(menuItemNode); michael@0: if (index == 0) { michael@0: selectElement.selectedItem = menuItemNode; michael@0: } michael@0: } michael@0: setDetails(); michael@0: document.getElementById("pw").focus(); michael@0: } michael@0: michael@0: function setDetails() michael@0: { michael@0: var index = parseInt(document.getElementById("nicknames").value); michael@0: if (index == "NaN") michael@0: return; michael@0: michael@0: var details = dialogParams.GetString(2 + (2 * index + 1)); michael@0: document.getElementById("certdetails").value = details; michael@0: } michael@0: michael@0: function onCertSelected() michael@0: { michael@0: setDetails(); michael@0: } michael@0: michael@0: function doOK() michael@0: { michael@0: dialogParams.SetInt(0, 1); michael@0: var index = parseInt(document.getElementById("nicknames").value); michael@0: dialogParams.SetInt(1, index); michael@0: var password = document.getElementById("pw").value; michael@0: dialogParams.SetString(0, password); michael@0: return true; michael@0: } michael@0: michael@0: function doCancel() michael@0: { michael@0: dialogParams.SetInt(0, 0); michael@0: return true; michael@0: }