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

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     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/. */
     6 const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
     8 var dialogParams;
     9 var itemCount = 0;
    11 function onLoad()
    12 {
    13   dialogParams = window.arguments[0].QueryInterface(nsIDialogParamBlock);
    15   var selectElement = document.getElementById("nicknames");
    16   itemCount = dialogParams.GetInt(0);
    18   var selIndex = dialogParams.GetInt(1);
    19   if (selIndex < 0)
    20     selIndex = 0;
    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);
    29       if (selIndex == i) {
    30         selectElement.selectedItem = menuItemNode;
    31       }
    32   }
    34   dialogParams.SetInt(0,0); // set cancel return value
    35   setDetails();
    36 }
    38 function setDetails()
    39 {
    40   var selItem = document.getElementById("nicknames").value;
    41   if (!selItem.length)
    42     return;
    44   var index = parseInt(selItem);
    45   var details = dialogParams.GetString(index+itemCount);
    46   document.getElementById("details").value = details;
    47 }
    49 function onCertSelected()
    50 {
    51   setDetails();
    52 }
    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 }
    62 function doCancel()
    63 {
    64   dialogParams.SetInt(0,0);
    65   return true;
    66 }

mercurial