security/manager/pki/resources/content/certpicker.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0161a76da45d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
7
8 var dialogParams;
9 var itemCount = 0;
10
11 function onLoad()
12 {
13 dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock);
14
15 var selectElement = document.getElementById("nicknames");
16 itemCount = dialogParams.GetInt(0);
17
18 var selIndex = dialogParams.GetInt(1);
19 if (selIndex < 0)
20 selIndex = 0;
21
22 for (var i=0; i < itemCount; i++) {
23 var menuItemNode = document.createElement("menuitem");
24 var nick = dialogParams.GetString(i);
25 menuItemNode.setAttribute("value", i);
26 menuItemNode.setAttribute("label", nick); // this is displayed
27 selectElement.firstChild.appendChild(menuItemNode);
28
29 if (selIndex == i) {
30 selectElement.selectedItem = menuItemNode;
31 }
32 }
33
34 dialogParams.SetInt(0,0); // set cancel return value
35 setDetails();
36 }
37
38 function setDetails()
39 {
40 var selItem = document.getElementById("nicknames").value;
41 if (!selItem.length)
42 return;
43
44 var index = parseInt(selItem);
45 var details = dialogParams.GetString(index+itemCount);
46 document.getElementById("details").value = details;
47 }
48
49 function onCertSelected()
50 {
51 setDetails();
52 }
53
54 function doOK()
55 {
56 dialogParams.SetInt(0,1);
57 var index = parseInt(document.getElementById("nicknames").value);
58 dialogParams.SetInt(1, index);
59 return true;
60 }
61
62 function doCancel()
63 {
64 dialogParams.SetInt(0,0);
65 return true;
66 }

mercurial