From 951ef0d578130106e303e5586f53404a900ccf9c Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 31 May 2010 16:51:50 +0200 Subject: Reshuffling to Jetpack-SDK directory layout. --- bugzillaComments.js | 344 ---------------------------------------------------- 1 file changed, 344 deletions(-) delete mode 100644 bugzillaComments.js (limited to 'bugzillaComments.js') diff --git a/bugzillaComments.js b/bugzillaComments.js deleted file mode 100644 index 6ae3e81..0000000 --- a/bugzillaComments.js +++ /dev/null @@ -1,344 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Bugzilla Comments Jetpack code. - * - * The Initial Developer of the Original Code is - * Philipp Kewisch - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Matěj Cepl - * Mark Banner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var manifest = { - settings: [ - { - name: "jsonURL", - type: "text", - label: "URL for Comments Pack" - }, - { - name: "enabledPacks", - type: "text", - label: "Enabled Comment Packages" - } - ] -}; -jetpack.future.import("jetpack.storage.settings"); -jetpack.future.import("jetpack.pageMods"); - -// Container for loaded package json data. -var gJSONData = null; - -//////////////////////////////////////////////////////////////// -// Helper functions -//////////////////////////////////////////////////////////////// -var hlpr = { - valToArray: function valToArray(val) { - let arr = []; - if (typeof val == "string") { - arr = [val]; - } else if ($.isArray(val)) { - arr = val; - } - return arr; - }, - - addCSVValue: function addCSVValue(str, value) { - let parts = (str.trim().length > 0 ? str.split(",") : []); - if (parts.indexOf(value) < 0) { - parts.concat(hlpr.valToArray(value)); - } - return parts.join(","); - }, - - removeCSVValue: function removeCSVValue(str, value) { - let parts = (str.trim().length > 0 ? str.split(",") : []); - for each (let val in hlpr.valToArray(value)) { - let pos = parts.indexOf(val); - if (pos > -1) { - parts.splice(pos, 1); - } - } - return parts.join(","); - }, - - selectOption: function selectOption(select, value) { - let doc = select[0].ownerDocument; - select.val(value); - - let e = doc.createEvent("HTMLEvents"); - e.initEvent("change", true, true); - select[0].dispatchEvent(e); - }, - - clickElement: function clickElement(element) { - let doc = element[0].ownerDocument; - let e = doc.createEvent("MouseEvents"); - e.initMouseEvent("click", true, true, doc.defaultView, - 0, 0, 0, 0, 0, false, false, false, false, 0, null); - element[0].dispatchEvent(e); - } -}; - -//////////////////////////////////////////////////////////////// -// Basic Bugzilla modifications -//////////////////////////////////////////////////////////////// - -function BaseBugzilla(doc) { - this.doc = doc; - this.init(); -} - -BaseBugzilla.prototype = { - doc: null, - - get: function installedPackages() { - // TODO does this really need to by dynamic? - let installedPackages = {}; - if (gJSONData && ("commentPackages" in gJSONData)) { - let enabledPackages = jetpack.storage.settings.enabledPacks.split(/[, ]/); - for each (let pkg in enabledPackages) { - if (pkg in gJSONData.commentPackages) { - installedPackages[pkg] = gJSONData.commentPackages[pkg]; - } - } - } - return installedPackages; - }, - - init: function base_init() { - this.initCommentsDropdown(); - }, - - initCommentsDropdown: function base_initCommentsDropdown() { - let ca = $("
" + - " " + - "