aboutsummaryrefslogtreecommitdiffstats
path: root/lib/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/main.js')
-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('"', '"', '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) {