michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * 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: michael@0: const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock; michael@0: michael@0: var dialogParams; michael@0: var itemCount = 0; michael@0: var rememberBox; michael@0: michael@0: function onLoad() michael@0: { michael@0: var cn; michael@0: var org; michael@0: var issuer; michael@0: michael@0: dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock); michael@0: cn = dialogParams.GetString(0); michael@0: org = dialogParams.GetString(1); michael@0: issuer = dialogParams.GetString(2); michael@0: michael@0: // added with bug 431819. reuse string from caps in order to avoid string changes michael@0: var capsBundle = document.getElementById("caps_bundle"); michael@0: var rememberString = capsBundle.getString("CheckMessage"); michael@0: var rememberSetting = true; michael@0: michael@0: var pref = Components.classes['@mozilla.org/preferences-service;1'] michael@0: .getService(Components.interfaces.nsIPrefService); michael@0: if (pref) { michael@0: pref = pref.getBranch(null); michael@0: try { michael@0: rememberSetting = michael@0: pref.getBoolPref("security.remember_cert_checkbox_default_setting"); michael@0: } michael@0: catch(e) { michael@0: // pref is missing michael@0: } michael@0: } michael@0: michael@0: rememberBox = document.getElementById("rememberBox"); michael@0: rememberBox.label = rememberString; michael@0: rememberBox.checked = rememberSetting; michael@0: michael@0: var bundle = document.getElementById("pippki_bundle"); michael@0: var message1 = bundle.getFormattedString("clientAuthMessage1", [org]); michael@0: var message2 = bundle.getFormattedString("clientAuthMessage2", [issuer]); michael@0: setText("hostname", cn); michael@0: setText("organization", message1); michael@0: setText("issuer", message2); michael@0: michael@0: var selectElement = document.getElementById("nicknames"); michael@0: itemCount = dialogParams.GetInt(0); michael@0: for (var i=0; i < itemCount; i++) { michael@0: var menuItemNode = document.createElement("menuitem"); michael@0: var nick = dialogParams.GetString(i+3); michael@0: menuItemNode.setAttribute("value", i); michael@0: menuItemNode.setAttribute("label", nick); // this is displayed michael@0: selectElement.firstChild.appendChild(menuItemNode); michael@0: if (i == 0) { michael@0: selectElement.selectedItem = menuItemNode; michael@0: } michael@0: } michael@0: michael@0: setDetails(); michael@0: } michael@0: michael@0: function setDetails() michael@0: { michael@0: var index = parseInt(document.getElementById("nicknames").value); michael@0: var details = dialogParams.GetString(index+itemCount+3); michael@0: document.getElementById("details").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: dialogParams.SetInt(2, rememberBox.checked); michael@0: return true; michael@0: } michael@0: michael@0: function doCancel() michael@0: { michael@0: dialogParams.SetInt(0,0); michael@0: dialogParams.SetInt(1, -1); // invalid value michael@0: dialogParams.SetInt(2, rememberBox.checked); michael@0: return true; michael@0: }