From 6f095c3f8cfdb73ce00f6f2cbe901ab5742fa341 Mon Sep 17 00:00:00 2001 From: "justdave%syndicomm.com" <> Date: Tue, 29 May 2001 10:05:46 +0000 Subject: Fix for bug 77699 and bug 71503: fix javascript errors in quicksearch and improve IE5 compatibility Patch by Stephan Lee and Andreas Franke --- quicksearch.js | 165 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 116 insertions(+), 49 deletions(-) (limited to 'quicksearch.js') diff --git a/quicksearch.js b/quicksearch.js index e4c21868b..09515dff4 100644 --- a/quicksearch.js +++ b/quicksearch.js @@ -12,6 +12,46 @@ // // Created by // Andreas Franke +// +// Contributors: +// Stephen Lee + +// variable below should be initialised according to whether +// browser is IE 5.0 or earlier, but should be false for IE 5.5 + +var is_IE5=(navigator.appVersion.search(/MSIE 5.0/g)>0); + +// Bodge to get round IE5 not understanding "undefined", "shift" and "unshift" + +var no_result=is_IE5?"---":undefined; + +function do_unshift(l, s) { + if(is_IE5) { + l.length = l.length + 1; + for (var i=l.length-1; i>0; i--) { + l[i] = l[i-1]; + } + l[0] = s; + return l.length; + } + else { + return l.unshift(s); + } +} + +function do_shift(l) { + if(is_IE5) { + var l0=l[0]; + for (var i=0; i= 0) return f2[i]; - return undefined; + return no_result; } // `keywords' is defined externally @@ -165,14 +205,14 @@ function is_severity(str) { // `product_exceptions' is defined externally function match_product(str) { - s = str.toLowerCase(); + var s = str.toLowerCase(); return (s.length > 2) && (! member(s,product_exceptions)); } // `component_exceptions are defined externally function match_component(str) { - s = str.toLowerCase(); + var s = str.toLowerCase(); return (s.length > 2) && (! member(s,component_exceptions)); } @@ -222,27 +262,62 @@ function make_query_URL(url, input, searchLong) { status_and_resolution = ""; charts = ""; - var searchURL = url; //bugzilla + "buglist.cgi"; - var abort = false; + // declare all variables used in this function + + var searchURL = url; // bugzilla + "buglist.cgi" (or "query.cgi") + var abort = false; // global flag, checked upon return + + var i,j,k,l; // index counters used in 'for' loops + var parts,input2; // escape "quoted" parts of input + + var word; // array of words + // (space-separated parts of input2) + var alternative; // array of parts of an element of 'word' + // (separated by '|', sometimes by comma) + var comma_separated_words; // array of parts of an element of 'alternative' + var w; // current element of one of these arrays: + // word, alternative, comma_separated_words + + var w0; // first element of 'word' + var prefixes; // comma-separated parts of w0 + // (prefixes of status/resolution values) + + var expr; // used for 'priority' support + var n,separator; // used for 'votes' support + + var colon_separated_parts, fields,values,field; + // used for generic fields:values notation + + var chart,and,or; // counters used in add_chart + var negation; // boolean flag used in add_chart + + // `statuses_open' and `statuses_resolved' are defined externally + var statusOpen = statuses_open; + var statusResolved = statuses_resolved; + var statusAll = statusOpen.concat(statusResolved); + + // `resolutions' is defined externally + var bug_status = statusOpen.slice().reverse(); //reverse is just cosmetic + var resolution = new Array(); // escape everything between quotes: "foo bar" --> "foo%20bar" - var parts = input.split('"'); + parts = input.split('"'); if ((parts.length % 2) != 1) { alert('Unterminated quote'); abort = true; - return undefined; + return no_result; } - for (var i=1; i 0) { resolution = resolution.reverse(); - resolution.unshift("---"); + do_unshift(resolution,"---"); addAll(statusResolved,bug_status); } bug_status = bug_status.reverse(); @@ -336,11 +402,11 @@ function make_query_URL(url, input, searchLong) { // end of bug_status & resolution stuff - var chart = 0; - var and = 0; - var or = 0; + chart = 0; + and = 0; + or = 0; - var negation = false; + negation = false; function negate_comparison_type(type) { switch(type) { @@ -351,6 +417,7 @@ function make_query_URL(url, input, searchLong) { // e.g. "greaterthan" alert("Can't negate comparison type: `" + type + "'"); abort = true; + return "dummy"; } } @@ -379,7 +446,7 @@ function make_query_URL(url, input, searchLong) { } } - for (var i=0; i