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