aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan@mozilla.com>2010-07-09 14:29:05 -0700
committerEhsan Akhgari <ehsan@mozilla.com>2010-07-09 14:29:05 -0700
commitad947c60ac734f5b3b70eec6e12f5c123baab36f (patch)
tree9ea635bac7990f3dc5ca879d8a76887a6d5b5fe1
parentc889af0aae7a564662727e67823f8bcca6359199 (diff)
downloadbugzilla-triage-ad947c60ac734f5b3b70eec6e12f5c123baab36f.tar.gz
Remove the support for user name autocomplete because bugzilla.mozilla.org is moving to Bugzilla 3.6 which provides this functionality by default
-rw-r--r--lib/main.js121
1 files changed, 0 insertions, 121 deletions
diff --git a/lib/main.js b/lib/main.js
index 1fb0c95..bc5d503 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -87,15 +87,6 @@ function tweakBugzilla(d) {
if (!/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(d.location.href))
return;
- // Create autocomplete widgets for places where user IDs are typed
- autoCompleteUser(d, "#newcc", true); // CC field on bug pages
- autoCompleteUser(d, "#assigned_to"); // bug assignee
- autoCompleteUser(d, "input[type=text][name^=requestee_type-]", true); // requestee's on attachment pages
- autoCompleteUser(d, "input[name=email1],input[name=email2]"); // user fields on search page
- autoCompleteUser(d, "input[name=cc]", true); // CC field on new bug page
- autoCompleteUser(d, "input[name=assigned_to]"); // assignee field on new bug page
- autoCompleteUser(d, "input[name=new_watchedusers]", true); // user watch field in user email prefs
-
if (!d.getElementById("comments")) // don't process the mid-air collision pages
return;
@@ -1083,118 +1074,6 @@ function htmlEncode(str) {
.replace('"', '&quot;', 'g');
}
-function autoCompleteUser(doc, field, multiple) {
- // First, inject our autocomplete helper if needed
- const helperID = "bztw_autocomplete_helper";
- if (!doc.getElementById(helperID)) {
- function getAuthParams() {
- const BZTW_AC_DISABLE = "jetpack.bugzillaTweaks.userAutoCompleteDisabled";
- var prefs = require("preferences-service");
- if (prefs.get(BZTW_AC_DISABLE, false))
- return null;
-
- var bzCookies = require("cookiemanager").getHostCookies("bugzilla.mozilla.org");
- var loginID = null, auth = null;
- for (var i = 0; i < bzCookies.length; ++i) {
- var cookie = bzCookies[i];
- switch (cookie.name) {
- case "Bugzilla_login":
- loginID = cookie.value;
- break;
- case "Bugzilla_logincookie":
- auth = cookie.value;
- break;
- }
- }
- if (loginID != null && auth != null) {
- return "userid=" + loginID + "&cookie=" + auth;
- }
- return null;
- }
- function bztw_setupUserAutoComplete(field, multiple) {
- var Bugzilla = {
- BASE_URL: "https://api-dev.bugzilla.mozilla.org/latest/user?" + BZTW_AUTHPARAMS + "&match=",
- currReq: null,
- getUsers: function(query, success, prefix) {
- function onLoad() {
- var suggs = [];
- var results = JSON.parse(xhr.responseText);
- // Use a maximum of 100 elements
- results.users.splice(100, 999999);
- results.users.forEach(function (user) {
- suggs.push({label: user.real_name || user.name,
- value: prefix + user.name});
- });
- success(suggs);
- }
- if (this.currReq) {
- this.currReq.abort();
- }
- var xhr = new XMLHttpRequest();
- var url = this.BASE_URL + encodeURI(query);
- xhr.open("GET", url);
- xhr.setRequestHeader("Accept", "application/json");
- xhr.setRequestHeader("Content-Type", "application/json");
- xhr.addEventListener("load", onLoad, false);
- xhr.send(null);
- this.currReq = xhr;
- }
- };
-
- var options = {
- minLength: 3,
- delay: 1000,
- source: function(request, response) {
- var prefix = "";
- if (multiple) {
- var commaIndex = request.term.lastIndexOf(",");
- if (commaIndex >= 0) {
- prefix = request.term.substr(0, commaIndex + 1);
- request.term = request.term.substr(commaIndex + 1).trim();
- }
- }
- Bugzilla.getUsers(request.term, response, prefix);
- }
- };
- $(field).autocomplete(options);
- }
- var authParams = getAuthParams();
- if (!authParams)
- return;
- var link = doc.createElement("link");
- link.rel = "stylesheet";
- link.type = "text/css";
- link.href = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/base/jquery-ui.css";
- doc.querySelector("head").appendChild(link);
- var style = doc.createElement("style");
- style.type = "text/css";
- style.appendChild(doc.createTextNode(
- ".ui-autocomplete { max-height: 400px; font-size: 100%; overflow-y: scroll; }"
- ));
- doc.querySelector("head").appendChild(style);
- var script = doc.createElement("script");
- script.type = "text/javascript";
- script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";
- doc.body.appendChild(script);
- script = doc.createElement("script");
- script.type = "text/javascript";
- script.src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js";
- doc.body.appendChild(script);
- script = doc.createElement("script");
- script.id = helperID;
- script.type = "text/javascript";
- script.appendChild(doc.createTextNode("var BZTW_AUTHPARAMS = '" + authParams + "';" +
- bztw_setupUserAutoComplete.toSource()));
- doc.body.appendChild(script);
- }
- var script = doc.createElement("script");
- script.type = "text/javascript";
- script.appendChild(doc.createTextNode(
- "bztw_setupUserAutoComplete(\"" + field + "\", " + (!!multiple) + ");"
- ));
- doc.body.appendChild(script);
-}
-
function addAssignToSelfButton(d) {
var userName = getUserName(d);
if (userName) {