michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock; michael@0: michael@0: var dialogParams; michael@0: var itemCount = 0; michael@0: michael@0: function onLoad() michael@0: { michael@0: dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock); michael@0: michael@0: var selectElement = document.getElementById("nicknames"); michael@0: itemCount = dialogParams.GetInt(0); michael@0: michael@0: var selIndex = dialogParams.GetInt(1); michael@0: if (selIndex < 0) michael@0: selIndex = 0; michael@0: michael@0: for (var i=0; i < itemCount; i++) { michael@0: var menuItemNode = document.createElement("menuitem"); michael@0: var nick = dialogParams.GetString(i); michael@0: menuItemNode.setAttribute("value", i); michael@0: menuItemNode.setAttribute("label", nick); // this is displayed michael@0: selectElement.firstChild.appendChild(menuItemNode); michael@0: michael@0: if (selIndex == i) { michael@0: selectElement.selectedItem = menuItemNode; michael@0: } michael@0: } michael@0: michael@0: dialogParams.SetInt(0,0); // set cancel return value michael@0: setDetails(); michael@0: } michael@0: michael@0: function setDetails() michael@0: { michael@0: var selItem = document.getElementById("nicknames").value; michael@0: if (!selItem.length) michael@0: return; michael@0: michael@0: var index = parseInt(selItem); michael@0: var details = dialogParams.GetString(index+itemCount); 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: return true; michael@0: } michael@0: michael@0: function doCancel() michael@0: { michael@0: dialogParams.SetInt(0,0); michael@0: return true; michael@0: }