toolkit/mozapps/extensions/content/blocklist.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/content/blocklist.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +// -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 +
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +"use strict";
    1.11 +
    1.12 +Components.utils.import("resource://gre/modules/Services.jsm");
    1.13 +
    1.14 +var gArgs;
    1.15 +
    1.16 +function init() {
    1.17 +  var hasHardBlocks = false;
    1.18 +  var hasSoftBlocks = false;
    1.19 +  gArgs = window.arguments[0].wrappedJSObject;
    1.20 +
    1.21 +  // NOTE: We use strings from the "updates.properties" bundleset to change the
    1.22 +  // text on the "Cancel" button to "Restart Later". (bug 523784)
    1.23 +  let bundle = Services.strings.
    1.24 +              createBundle("chrome://mozapps/locale/update/updates.properties");
    1.25 +  let cancelButton = document.documentElement.getButton("cancel");
    1.26 +  cancelButton.setAttribute("label", bundle.GetStringFromName("restartLaterButton"));
    1.27 +  cancelButton.setAttribute("accesskey",
    1.28 +                            bundle.GetStringFromName("restartLaterButton.accesskey"));
    1.29 +
    1.30 +  var richlist = document.getElementById("addonList");
    1.31 +  var list = gArgs.list;
    1.32 +  list.sort(function listSort(a, b) { return String.localeCompare(a.name, b.name); });
    1.33 +  for (let listItem of list) {
    1.34 +    let item = document.createElement("richlistitem");
    1.35 +    item.setAttribute("name", listItem.name);
    1.36 +    item.setAttribute("version", listItem.version);
    1.37 +    item.setAttribute("icon", listItem.icon);
    1.38 +    if (listItem.blocked) {
    1.39 +      item.setAttribute("class", "hardBlockedAddon");
    1.40 +      hasHardBlocks = true;
    1.41 +    }
    1.42 +    else {
    1.43 +      item.setAttribute("class", "softBlockedAddon");
    1.44 +      hasSoftBlocks = true;
    1.45 +    }
    1.46 +    richlist.appendChild(item);
    1.47 +  }
    1.48 +
    1.49 +  if (hasHardBlocks && hasSoftBlocks)
    1.50 +    document.getElementById("bothMessage").hidden = false;
    1.51 +  else if (hasHardBlocks)
    1.52 +    document.getElementById("hardBlockMessage").hidden = false;
    1.53 +  else
    1.54 +    document.getElementById("softBlockMessage").hidden = false;
    1.55 +
    1.56 +  var link = document.getElementById("moreInfo");
    1.57 +  if (list.length == 1 && list[0].url) {
    1.58 +    link.setAttribute("href", list[0].url);
    1.59 +  }
    1.60 +  else {
    1.61 +    var url = Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL");
    1.62 +    link.setAttribute("href", url);
    1.63 +  }
    1.64 +}
    1.65 +
    1.66 +function finish(shouldRestartNow) {
    1.67 +  gArgs.restart = shouldRestartNow;
    1.68 +  var list = gArgs.list;
    1.69 +  var items = document.getElementById("addonList").childNodes;
    1.70 +  for (let i = 0; i < list.length; i++) {
    1.71 +    if (!list[i].blocked)
    1.72 +      list[i].disable = items[i].checked;
    1.73 +  }
    1.74 +  return true;
    1.75 +}

mercurial