1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/manager/pki/resources/content/certpicker.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock; 1.10 + 1.11 +var dialogParams; 1.12 +var itemCount = 0; 1.13 + 1.14 +function onLoad() 1.15 +{ 1.16 + dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock); 1.17 + 1.18 + var selectElement = document.getElementById("nicknames"); 1.19 + itemCount = dialogParams.GetInt(0); 1.20 + 1.21 + var selIndex = dialogParams.GetInt(1); 1.22 + if (selIndex < 0) 1.23 + selIndex = 0; 1.24 + 1.25 + for (var i=0; i < itemCount; i++) { 1.26 + var menuItemNode = document.createElement("menuitem"); 1.27 + var nick = dialogParams.GetString(i); 1.28 + menuItemNode.setAttribute("value", i); 1.29 + menuItemNode.setAttribute("label", nick); // this is displayed 1.30 + selectElement.firstChild.appendChild(menuItemNode); 1.31 + 1.32 + if (selIndex == i) { 1.33 + selectElement.selectedItem = menuItemNode; 1.34 + } 1.35 + } 1.36 + 1.37 + dialogParams.SetInt(0,0); // set cancel return value 1.38 + setDetails(); 1.39 +} 1.40 + 1.41 +function setDetails() 1.42 +{ 1.43 + var selItem = document.getElementById("nicknames").value; 1.44 + if (!selItem.length) 1.45 + return; 1.46 + 1.47 + var index = parseInt(selItem); 1.48 + var details = dialogParams.GetString(index+itemCount); 1.49 + document.getElementById("details").value = details; 1.50 +} 1.51 + 1.52 +function onCertSelected() 1.53 +{ 1.54 + setDetails(); 1.55 +} 1.56 + 1.57 +function doOK() 1.58 +{ 1.59 + dialogParams.SetInt(0,1); 1.60 + var index = parseInt(document.getElementById("nicknames").value); 1.61 + dialogParams.SetInt(1, index); 1.62 + return true; 1.63 +} 1.64 + 1.65 +function doCancel() 1.66 +{ 1.67 + dialogParams.SetInt(0,0); 1.68 + return true; 1.69 +}