|
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 hostname = dialogParams.GetString(0); |
|
16 var bundle = document.getElementById("pippki_bundle"); |
|
17 var intro = bundle.getFormattedString("formSigningIntro", [hostname]); |
|
18 setText("sign.intro", intro); |
|
19 |
|
20 document.getElementById("sign.text").value = dialogParams.GetString(1); |
|
21 |
|
22 var selectElement = document.getElementById("nicknames"); |
|
23 itemCount = dialogParams.GetInt(0); |
|
24 for (var index = 0; index < itemCount; ++index) { |
|
25 var menuItemNode = document.createElement("menuitem"); |
|
26 var nick = dialogParams.GetString(2 + 2 * index); |
|
27 menuItemNode.setAttribute("value", index); |
|
28 menuItemNode.setAttribute("label", nick); // this is displayed |
|
29 selectElement.firstChild.appendChild(menuItemNode); |
|
30 if (index == 0) { |
|
31 selectElement.selectedItem = menuItemNode; |
|
32 } |
|
33 } |
|
34 setDetails(); |
|
35 document.getElementById("pw").focus(); |
|
36 } |
|
37 |
|
38 function setDetails() |
|
39 { |
|
40 var index = parseInt(document.getElementById("nicknames").value); |
|
41 if (index == "NaN") |
|
42 return; |
|
43 |
|
44 var details = dialogParams.GetString(2 + (2 * index + 1)); |
|
45 document.getElementById("certdetails").value = details; |
|
46 } |
|
47 |
|
48 function onCertSelected() |
|
49 { |
|
50 setDetails(); |
|
51 } |
|
52 |
|
53 function doOK() |
|
54 { |
|
55 dialogParams.SetInt(0, 1); |
|
56 var index = parseInt(document.getElementById("nicknames").value); |
|
57 dialogParams.SetInt(1, index); |
|
58 var password = document.getElementById("pw").value; |
|
59 dialogParams.SetString(0, password); |
|
60 return true; |
|
61 } |
|
62 |
|
63 function doCancel() |
|
64 { |
|
65 dialogParams.SetInt(0, 0); |
|
66 return true; |
|
67 } |