siteDataRemoveSelected.js (1672B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */ 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 "use strict"; 7 8 /** 9 * This dialog will ask the user to confirm that they really want to delete all 10 * site data for a number of hosts. 11 */ 12 window.addEventListener("load", () => { 13 document.addEventListener("dialogaccept", function () { 14 window.arguments[0].allowed = true; 15 }); 16 document.addEventListener("dialogcancel", function () { 17 window.arguments[0].allowed = false; 18 }); 19 20 let list = document.getElementById("removalList"); 21 22 let hosts = window.arguments[0].hosts; 23 24 if (!hosts) { 25 throw new Error("Must specify hosts option in arguments."); 26 } 27 let dialog = document.getElementById("SiteDataRemoveSelectedDialog"); 28 if (hosts.length == 1) { 29 dialog.classList.add("single-entry"); 30 document.l10n.setAttributes( 31 document.getElementById("removing-description"), 32 "site-data-removing-single-desc", 33 { 34 baseDomain: hosts[0], 35 } 36 ); 37 return; 38 } 39 dialog.classList.add("multi-entry"); 40 hosts.sort(); 41 let fragment = document.createDocumentFragment(); 42 for (let host of hosts) { 43 let listItem = document.createXULElement("richlistitem"); 44 let label = document.createXULElement("label"); 45 if (host) { 46 label.setAttribute("value", host); 47 } else { 48 document.l10n.setAttributes(label, "site-data-local-file-host"); 49 } 50 listItem.appendChild(label); 51 fragment.appendChild(listItem); 52 } 53 list.appendChild(fragment); 54 });