r61251 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61250‎ | r61251 | r61252 >
Date:15:29, 19 January 2010
Author:ashley
Status:ok
Tags:
Comment:
cleanup to mwsuggest.js & fix some things suggested by JSLint
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/skins/common/mwsuggest.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/mwsuggest.js
@@ -42,32 +42,34 @@
4343 var os_animation_timer = null;
4444
4545 /** Timeout timer class that will fetch the results */
46 -function os_Timer(id,r,query){
 46+function os_Timer( id, r, query ) {
4747 this.id = id;
4848 this.r = r;
4949 this.query = query;
5050 }
5151
5252 /** Timer user to animate expansion/contraction of container width */
53 -function os_AnimationTimer(r, target){
 53+function os_AnimationTimer( r, target ) {
5454 this.r = r;
5555 var current = document.getElementById(r.container).offsetWidth;
56 - this.inc = Math.round((target-current) / os_animation_steps);
57 - if(this.inc < os_animation_min_step && this.inc >=0)
 56+ this.inc = Math.round( ( target - current ) / os_animation_steps );
 57+ if( this.inc < os_animation_min_step && this.inc >=0 ) {
5858 this.inc = os_animation_min_step; // minimal animation step
59 - if(this.inc > -os_animation_min_step && this.inc <0)
 59+ }
 60+ if( this.inc > -os_animation_min_step && this.inc < 0 ) {
6061 this.inc = -os_animation_min_step;
 62+ }
6163 this.target = target;
6264 }
6365
6466 /** Property class for single search box */
65 -function os_Results(name, formname){
 67+function os_Results( name, formname ) {
6668 this.searchform = formname; // id of the searchform
6769 this.searchbox = name; // id of the searchbox
68 - this.container = name+"Suggest"; // div that holds results
69 - this.resultTable = name+"Result"; // id base for the result table (+num = table row)
70 - this.resultText = name+"ResultText"; // id base for the spans within result tables (+num)
71 - this.toggle = name+"Toggle"; // div that has the toggle (enable/disable) link
 70+ this.container = name + 'Suggest'; // div that holds results
 71+ this.resultTable = name + 'Result'; // id base for the result table (+num = table row)
 72+ this.resultText = name + 'ResultText'; // id base for the spans within result tables (+num)
 73+ this.toggle = name + 'Toggle'; // div that has the toggle (enable/disable) link
7274 this.query = null; // last processed query
7375 this.results = null; // parsed titles
7476 this.resultCount = 0; // number of results
@@ -81,359 +83,384 @@
8284 }
8385
8486 /** Hide results div */
85 -function os_hideResults(r){
86 - var c = document.getElementById(r.container);
87 - if(c != null)
88 - c.style.visibility = "hidden";
 87+function os_hideResults( r ) {
 88+ var c = document.getElementById( r.container );
 89+ if( c !== null ) {
 90+ c.style.visibility = 'hidden';
 91+ }
8992 r.visible = false;
9093 r.selected = -1;
9194 }
9295
9396 /** Show results div */
94 -function os_showResults(r){
95 - if(os_is_stopped)
 97+function os_showResults( r ) {
 98+ if( os_is_stopped ) {
9699 return;
97 - if(r.stayHidden)
98 - return
99 - os_fitContainer(r);
100 - var c = document.getElementById(r.container);
 100+ }
 101+ if( r.stayHidden ) {
 102+ return;
 103+ }
 104+ os_fitContainer( r );
 105+ var c = document.getElementById( r.container );
101106 r.selected = -1;
102 - if(c != null){
 107+ if( c !== null ) {
103108 c.scrollTop = 0;
104 - c.style.visibility = "visible";
 109+ c.style.visibility = 'visible';
105110 r.visible = true;
106111 }
107112 }
108113
109 -function os_operaWidthFix(x){
 114+function os_operaWidthFix( x ) {
110115 // For browsers that don't understand overflow-x, estimate scrollbar width
111 - if(typeof document.body.style.overflowX != "string"){
 116+ if( typeof document.body.style.overflowX != 'string' ) {
112117 return 30;
113118 }
114119 return 0;
115120 }
116121
117 -function os_encodeQuery(value){
118 - if (encodeURIComponent) {
119 - return encodeURIComponent(value);
120 - }
121 - if(escape) {
122 - return escape(value);
123 - }
124 - return null;
 122+function os_encodeQuery( value ) {
 123+ if ( encodeURIComponent ) {
 124+ return encodeURIComponent( value );
 125+ }
 126+ if( escape ) {
 127+ return escape( value );
 128+ }
 129+ return null;
125130 }
126 -function os_decodeValue(value){
127 - if (decodeURIComponent) {
128 - return decodeURIComponent(value);
129 - }
130 - if(unescape){
131 - return unescape(value);
132 - }
133 - return null;
 131+
 132+function os_decodeValue( value ) {
 133+ if ( decodeURIComponent ) {
 134+ return decodeURIComponent( value );
 135+ }
 136+ if( unescape ) {
 137+ return unescape( value );
 138+ }
 139+ return null;
134140 }
135141
136142 /** Brower-dependent functions to find window inner size, and scroll status */
137143 function f_clientWidth() {
138 - return f_filterResults (
 144+ return f_filterResults(
139145 window.innerWidth ? window.innerWidth : 0,
140146 document.documentElement ? document.documentElement.clientWidth : 0,
141147 document.body ? document.body.clientWidth : 0
142148 );
143149 }
 150+
144151 function f_clientHeight() {
145 - return f_filterResults (
 152+ return f_filterResults(
146153 window.innerHeight ? window.innerHeight : 0,
147154 document.documentElement ? document.documentElement.clientHeight : 0,
148155 document.body ? document.body.clientHeight : 0
149156 );
150157 }
 158+
151159 function f_scrollLeft() {
152 - return f_filterResults (
 160+ return f_filterResults(
153161 window.pageXOffset ? window.pageXOffset : 0,
154162 document.documentElement ? document.documentElement.scrollLeft : 0,
155163 document.body ? document.body.scrollLeft : 0
156164 );
157165 }
 166+
158167 function f_scrollTop() {
159 - return f_filterResults (
 168+ return f_filterResults(
160169 window.pageYOffset ? window.pageYOffset : 0,
161170 document.documentElement ? document.documentElement.scrollTop : 0,
162171 document.body ? document.body.scrollTop : 0
163172 );
164173 }
165 -function f_filterResults(n_win, n_docel, n_body) {
 174+
 175+function f_filterResults( n_win, n_docel, n_body ) {
166176 var n_result = n_win ? n_win : 0;
167 - if (n_docel && (!n_result || (n_result > n_docel)))
 177+ if ( n_docel && ( !n_result || ( n_result > n_docel ) ) ) {
168178 n_result = n_docel;
169 - return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
 179+ }
 180+ return n_body && ( !n_result || ( n_result > n_body ) ) ? n_body : n_result;
170181 }
171182
172183 /** Get the height available for the results container */
173 -function os_availableHeight(r){
174 - var absTop = document.getElementById(r.container).style.top;
175 - var px = absTop.lastIndexOf("px");
176 - if(px > 0)
177 - absTop = absTop.substring(0,px);
178 - return f_clientHeight() - (absTop - f_scrollTop());
 184+function os_availableHeight( r ) {
 185+ var absTop = document.getElementById( r.container ).style.top;
 186+ var px = absTop.lastIndexOf( 'px' );
 187+ if( px > 0 ) {
 188+ absTop = absTop.substring( 0, px );
 189+ }
 190+ return f_clientHeight() - ( absTop - f_scrollTop() );
179191 }
180192
181 -
182193 /** Get element absolute position {left,top} */
183 -function os_getElementPosition(elemID){
184 - var offsetTrail = document.getElementById(elemID);
 194+function os_getElementPosition( elemID ) {
 195+ var offsetTrail = document.getElementById( elemID );
185196 var offsetLeft = 0;
186197 var offsetTop = 0;
187 - while (offsetTrail){
 198+ while ( offsetTrail ) {
188199 offsetLeft += offsetTrail.offsetLeft;
189200 offsetTop += offsetTrail.offsetTop;
190201 offsetTrail = offsetTrail.offsetParent;
191202 }
192 - if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
 203+ if ( navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined' ) {
193204 offsetLeft += document.body.leftMargin;
194205 offsetTop += document.body.topMargin;
195206 }
196 - return {left:offsetLeft,top:offsetTop};
 207+ return { left:offsetLeft, top:offsetTop };
197208 }
198209
199210 /** Create the container div that will hold the suggested titles */
200 -function os_createContainer(r){
201 - var c = document.createElement("div");
202 - var s = document.getElementById(r.searchbox);
203 - var pos = os_getElementPosition(r.searchbox);
 211+function os_createContainer( r ) {
 212+ var c = document.createElement( 'div' );
 213+ var s = document.getElementById( r.searchbox );
 214+ var pos = os_getElementPosition( r.searchbox );
204215 var left = pos.left;
205216 var top = pos.top + s.offsetHeight;
206 - c.className = "os-suggest";
207 - c.setAttribute("id", r.container);
208 - document.body.appendChild(c);
 217+ c.className = 'os-suggest';
 218+ c.setAttribute( 'id', r.container );
 219+ document.body.appendChild( c );
209220
210221 // dynamically generated style params
211222 // IE workaround, cannot explicitely set "style" attribute
212 - c = document.getElementById(r.container);
213 - c.style.top = top+"px";
214 - c.style.left = left+"px";
215 - c.style.width = s.offsetWidth+"px";
 223+ c = document.getElementById( r.container );
 224+ c.style.top = top + 'px';
 225+ c.style.left = left + 'px';
 226+ c.style.width = s.offsetWidth + 'px';
216227
217228 // mouse event handlers
218 - c.onmouseover = function(event) { os_eventMouseover(r.searchbox, event); };
219 - c.onmousemove = function(event) { os_eventMousemove(r.searchbox, event); };
220 - c.onmousedown = function(event) { return os_eventMousedown(r.searchbox, event); };
221 - c.onmouseup = function(event) { os_eventMouseup(r.searchbox, event); };
 229+ c.onmouseover = function( event ) { os_eventMouseover( r.searchbox, event ); };
 230+ c.onmousemove = function( event ) { os_eventMousemove( r.searchbox, event ); };
 231+ c.onmousedown = function( event ) { return os_eventMousedown( r.searchbox, event ); };
 232+ c.onmouseup = function( event ) { os_eventMouseup( r.searchbox, event ); };
222233 return c;
223234 }
224235
225236 /** change container height to fit to screen */
226 -function os_fitContainer(r){
227 - var c = document.getElementById(r.container);
228 - var h = os_availableHeight(r) - 20;
 237+function os_fitContainer( r ) {
 238+ var c = document.getElementById( r.container );
 239+ var h = os_availableHeight( r ) - 20;
229240 var inc = r.containerRow;
230 - h = parseInt(h/inc) * inc;
231 - if(h < (2 * inc) && r.resultCount > 1) // min: two results
 241+ h = parseInt( h / inc ) * inc;
 242+ if( h < ( 2 * inc ) && r.resultCount > 1 ) { // min: two results
232243 h = 2 * inc;
233 - if((h/inc) > os_max_lines_per_suggest )
 244+ }
 245+ if( ( h / inc ) > os_max_lines_per_suggest ) {
234246 h = inc * os_max_lines_per_suggest;
235 - if(h < r.containerTotal){
236 - c.style.height = h +"px";
237 - r.containerCount = parseInt(Math.round(h/inc));
238 - } else{
239 - c.style.height = r.containerTotal+"px";
 247+ }
 248+ if( h < r.containerTotal ) {
 249+ c.style.height = h + 'px';
 250+ r.containerCount = parseInt( Math.round( h / inc ) );
 251+ } else {
 252+ c.style.height = r.containerTotal + 'px';
240253 r.containerCount = r.resultCount;
241254 }
242255 }
 256+
243257 /** If some entries are longer than the box, replace text with "..." */
244 -function os_trimResultText(r){
 258+function os_trimResultText( r ) {
245259 // find max width, first see if we could expand the container to fit it
246260 var maxW = 0;
247 - for(var i=0;i<r.resultCount;i++){
248 - var e = document.getElementById(r.resultText+i);
249 - if(e.offsetWidth > maxW)
 261+ for( var i = 0; i < r.resultCount; i++ ) {
 262+ var e = document.getElementById( r.resultText + i );
 263+ if( e.offsetWidth > maxW ) {
250264 maxW = e.offsetWidth;
 265+ }
251266 }
252 - var w = document.getElementById(r.container).offsetWidth;
 267+ var w = document.getElementById( r.container ).offsetWidth;
253268 var fix = 0;
254 - if(r.containerCount < r.resultCount){
 269+ if( r.containerCount < r.resultCount ) {
255270 fix = 20; // give 20px for scrollbar
256 - } else
257 - fix = os_operaWidthFix(w);
258 - if(fix < 4)
 271+ } else {
 272+ fix = os_operaWidthFix( w );
 273+ }
 274+ if( fix < 4 ) {
259275 fix = 4; // basic padding
 276+ }
260277 maxW += fix;
261278
262279 // resize container to fit more data if permitted
263 - var normW = document.getElementById(r.searchbox).offsetWidth;
 280+ var normW = document.getElementById( r.searchbox ).offsetWidth;
264281 var prop = maxW / normW;
265 - if(prop > os_container_max_width)
 282+ if( prop > os_container_max_width ) {
266283 prop = os_container_max_width;
267 - else if(prop < 1)
 284+ } else if( prop < 1 ) {
268285 prop = 1;
 286+ }
269287 var newW = Math.round( normW * prop );
270 - if( w != newW ){
 288+ if( w != newW ) {
271289 w = newW;
272 - if( os_animation_timer != null )
273 - clearInterval(os_animation_timer.id)
274 - os_animation_timer = new os_AnimationTimer(r,w);
275 - os_animation_timer.id = setInterval("os_animateChangeWidth()",os_animation_delay);
 290+ if( os_animation_timer !== null ) {
 291+ clearInterval( os_animation_timer.id );
 292+ }
 293+ os_animation_timer = new os_AnimationTimer( r, w );
 294+ os_animation_timer.id = setInterval( "os_animateChangeWidth()", os_animation_delay );
276295 w -= fix; // this much is reserved
277296 }
278297
279298 // trim results
280 - if(w < 10)
 299+ if( w < 10 ) {
281300 return;
282 - for(var i=0;i<r.resultCount;i++){
283 - var e = document.getElementById(r.resultText+i);
 301+ }
 302+ for( var i = 0; i < r.resultCount; i++ ) {
 303+ var e = document.getElementById( r.resultText + i );
284304 var replace = 1;
285 - var lastW = e.offsetWidth+1;
 305+ var lastW = e.offsetWidth + 1;
286306 var iteration = 0;
287307 var changedText = false;
288 - while(e.offsetWidth > w && (e.offsetWidth < lastW || iteration<2)){
 308+ while( e.offsetWidth > w && ( e.offsetWidth < lastW || iteration < 2 ) ) {
289309 changedText = true;
290310 lastW = e.offsetWidth;
291311 var l = e.innerHTML;
292 - e.innerHTML = l.substring(0,l.length-replace)+"...";
 312+ e.innerHTML = l.substring( 0, l.length - replace ) + '...';
293313 iteration++;
294314 replace = 4; // how many chars to replace
295315 }
296 - if(changedText){
 316+ if( changedText ) {
297317 // show hint for trimmed titles
298 - document.getElementById(r.resultTable+i).setAttribute("title",r.results[i]);
 318+ document.getElementById( r.resultTable + i ).setAttribute( 'title', r.results[i] );
299319 }
300320 }
301321 }
302322
303323 /** Invoked on timer to animate change in container width */
304 -function os_animateChangeWidth(){
 324+function os_animateChangeWidth() {
305325 var r = os_animation_timer.r;
306 - var c = document.getElementById(r.container);
 326+ var c = document.getElementById( r.container );
307327 var w = c.offsetWidth;
308 - var normW = document.getElementById(r.searchbox).offsetWidth;
309 - var normL = os_getElementPosition(r.searchbox).left;
 328+ var normW = document.getElementById( r.searchbox ).offsetWidth;
 329+ var normL = os_getElementPosition( r.searchbox ).left;
310330 var inc = os_animation_timer.inc;
311331 var target = os_animation_timer.target;
312332 var nw = w + inc;
313 - if( (inc > 0 && nw >= target) || (inc <= 0 && nw <= target) ){
 333+ if( ( inc > 0 && nw >= target ) || ( inc <= 0 && nw <= target ) ) {
314334 // finished !
315 - c.style.width = target+"px";
316 - clearInterval(os_animation_timer.id)
 335+ c.style.width = target + 'px';
 336+ clearInterval( os_animation_timer.id );
317337 os_animation_timer = null;
318 - } else{
 338+ } else {
319339 // in-progress
320 - c.style.width = nw+"px";
321 - if(document.documentElement.dir == "rtl")
322 - c.style.left = (normL + normW + (target - nw) - os_animation_timer.target - 1)+"px";
 340+ c.style.width = nw + 'px';
 341+ if( document.documentElement.dir == 'rtl' ) {
 342+ c.style.left = ( normL + normW + ( target - nw ) - os_animation_timer.target - 1 ) + 'px';
 343+ }
323344 }
324345 }
325346
326347 /** Handles data from XMLHttpRequest, and updates the suggest results */
327 -function os_updateResults(r, query, text, cacheKey){
 348+function os_updateResults( r, query, text, cacheKey ) {
328349 os_cache[cacheKey] = text;
329350 r.query = query;
330351 r.original = query;
331 - if(text == ""){
 352+ if( text == '' ) {
332353 r.results = null;
333354 r.resultCount = 0;
334 - os_hideResults(r);
335 - } else{
 355+ os_hideResults( r );
 356+ } else {
336357 try {
337 - var p = eval('('+text+')'); // simple json parse, could do a safer one
338 - if(p.length<2 || p[1].length == 0){
 358+ var p = eval( '(' + text + ')' ); // simple json parse, could do a safer one
 359+ if( p.length < 2 || p[1].length === 0 ) {
339360 r.results = null;
340361 r.resultCount = 0;
341 - os_hideResults(r);
 362+ os_hideResults( r );
342363 return;
343364 }
344 - var c = document.getElementById(r.container);
345 - if(c == null)
346 - c = os_createContainer(r);
347 - c.innerHTML = os_createResultTable(r,p[1]);
 365+ var c = document.getElementById( r.container );
 366+ if( c === null ) {
 367+ c = os_createContainer( r );
 368+ }
 369+ c.innerHTML = os_createResultTable( r, p[1] );
348370 // init container table sizes
349 - var t = document.getElementById(r.resultTable);
 371+ var t = document.getElementById( r.resultTable );
350372 r.containerTotal = t.offsetHeight;
351373 r.containerRow = t.offsetHeight / r.resultCount;
352 - os_fitContainer(r);
353 - os_trimResultText(r);
354 - os_showResults(r);
355 - } catch(e){
 374+ os_fitContainer( r );
 375+ os_trimResultText( r );
 376+ os_showResults( r );
 377+ } catch( e ) {
356378 // bad response from server or such
357 - os_hideResults(r);
 379+ os_hideResults( r );
358380 os_cache[cacheKey] = null;
359381 }
360382 }
361383 }
362384
363385 /** Create the result table to be placed in the container div */
364 -function os_createResultTable(r, results){
365 - var c = document.getElementById(r.container);
366 - var width = c.offsetWidth - os_operaWidthFix(c.offsetWidth);
367 - var html = "<table class=\"os-suggest-results\" id=\""+r.resultTable+"\" style=\"width: "+width+"px;\">";
 386+function os_createResultTable( r, results ) {
 387+ var c = document.getElementById( r.container );
 388+ var width = c.offsetWidth - os_operaWidthFix( c.offsetWidth );
 389+ var html = '<table class="os-suggest-results" id="' + r.resultTable + '" style="width: ' + width + 'px;">';
368390 r.results = new Array();
369391 r.resultCount = results.length;
370 - for(i=0;i<results.length;i++){
371 - var title = os_decodeValue(results[i]);
 392+ for( i = 0; i < results.length; i++ ) {
 393+ var title = os_decodeValue( results[i] );
372394 r.results[i] = title;
373 - html += "<tr><td class=\"os-suggest-result\" id=\""+r.resultTable+i+"\"><span id=\""+r.resultText+i+"\">"+title+"</span></td></tr>";
 395+ html += '<tr><td class="os-suggest-result" id="' + r.resultTable + i + '"><span id="' + r.resultText + i + '">' + title + '</span></td></tr>';
374396 }
375 - html+="</table>"
 397+ html += '</table>';
376398 return html;
377399 }
378400
379401 /** Fetch namespaces from checkboxes or hidden fields in the search form,
380402 if none defined use wgSearchNamespaces global */
381 -function os_getNamespaces(r){
382 - var namespaces = "";
 403+function os_getNamespaces( r ) {
 404+ var namespaces = '';
383405 var elements = document.forms[r.searchform].elements;
384 - for(i=0; i < elements.length; i++){
 406+ for( i = 0; i < elements.length; i++ ) {
385407 var name = elements[i].name;
386 - if(typeof name != 'undefined' && name.length > 2
387 - && name[0]=='n' && name[1]=='s'
388 - && ((elements[i].type=='checkbox' && elements[i].checked)
389 - || (elements[i].type=='hidden' && elements[i].value=="1")) ){
390 - if(namespaces!="")
391 - namespaces+="|";
392 - namespaces+=name.substring(2);
 408+ if( typeof name != 'undefined' && name.length > 2 && name[0] == 'n' &&
 409+ name[1] == 's' && (
 410+ ( elements[i].type == 'checkbox' && elements[i].checked ) ||
 411+ ( elements[i].type == 'hidden' && elements[i].value == '1' )
 412+ )
 413+ ) {
 414+ if( namespaces != '' ) {
 415+ namespaces += '|';
 416+ }
 417+ namespaces += name.substring( 2 );
393418 }
394419 }
395 - if(namespaces == "")
396 - namespaces = wgSearchNamespaces.join("|");
 420+ if( namespaces == '' ) {
 421+ namespaces = wgSearchNamespaces.join('|');
 422+ }
397423 return namespaces;
398424 }
399425
400426 /** Update results if user hasn't already typed something else */
401 -function os_updateIfRelevant(r, query, text, cacheKey){
402 - var t = document.getElementById(r.searchbox);
403 - if(t != null && t.value == query){ // check if response is still relevant
404 - os_updateResults(r, query, text, cacheKey);
 427+function os_updateIfRelevant( r, query, text, cacheKey ) {
 428+ var t = document.getElementById( r.searchbox );
 429+ if( t !== null && t.value == query ) { // check if response is still relevant
 430+ os_updateResults( r, query, text, cacheKey );
405431 }
406432 r.query = query;
407433 }
408434
409435 /** Fetch results after some timeout */
410 -function os_delayedFetch(){
411 - if(os_timer == null)
 436+function os_delayedFetch() {
 437+ if( os_timer === null ) {
412438 return;
 439+ }
413440 var r = os_timer.r;
414441 var query = os_timer.query;
415442 os_timer = null;
416 - var path = wgMWSuggestTemplate.replace("{namespaces}",os_getNamespaces(r))
417 - .replace("{dbname}",wgDBname)
418 - .replace("{searchTerms}",os_encodeQuery(query));
 443+ var path = wgMWSuggestTemplate.replace( "{namespaces}", os_getNamespaces( r ) )
 444+ .replace( "{dbname}", wgDBname )
 445+ .replace( "{searchTerms}", os_encodeQuery( query ) );
419446
420447 // try to get from cache, if not fetch using ajax
421448 var cached = os_cache[path];
422 - if(cached != null){
423 - os_updateIfRelevant(r, query, cached, path);
424 - } else{
 449+ if( cached !== null ) {
 450+ os_updateIfRelevant( r, query, cached, path );
 451+ } else {
425452 var xmlhttp = sajax_init_object();
426 - if(xmlhttp){
 453+ if( xmlhttp ) {
427454 try {
428 - xmlhttp.open("GET", path, true);
429 - xmlhttp.onreadystatechange=function(){
430 - if (xmlhttp.readyState==4 && typeof os_updateIfRelevant == 'function') {
431 - os_updateIfRelevant(r, query, xmlhttp.responseText, path);
432 - }
433 - };
434 - xmlhttp.send(null);
435 - } catch (e) {
436 - if (window.location.hostname == "localhost") {
437 - alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing.");
 455+ xmlhttp.open( 'GET', path, true );
 456+ xmlhttp.onreadystatechange = function() {
 457+ if ( xmlhttp.readyState == 4 && typeof os_updateIfRelevant == 'function' ) {
 458+ os_updateIfRelevant( r, query, xmlhttp.responseText, path );
 459+ }
 460+ };
 461+ xmlhttp.send( null );
 462+ } catch ( e ) {
 463+ if ( window.location.hostname == 'localhost' ) {
 464+ alert( "Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing." );
438465 }
439466 throw e;
440467 }
@@ -442,420 +469,450 @@
443470 }
444471
445472 /** Init timed update via os_delayedUpdate() */
446 -function os_fetchResults(r, query, timeout){
447 - if(query == ""){
448 - r.query = "";
449 - os_hideResults(r);
 473+function os_fetchResults( r, query, timeout ) {
 474+ if( query == '' ) {
 475+ r.query = '';
 476+ os_hideResults( r );
450477 return;
451 - } else if(query == r.query)
 478+ } else if( query == r.query ) {
452479 return; // no change
 480+ }
453481
454482 os_is_stopped = false; // make sure we're running
455483
456 - /* var cacheKey = wgDBname+":"+query;
 484+ /* var cacheKey = wgDBname + ':' + query;
457485 var cached = os_cache[cacheKey];
458 - if(cached != null){
459 - os_updateResults(r,wgDBname,query,cached);
 486+ if( cached != null ) {
 487+ os_updateResults( r, wgDBname, query, cached );
460488 return;
461489 } */
462490
463491 // cancel any pending fetches
464 - if(os_timer != null && os_timer.id != null)
465 - clearTimeout(os_timer.id);
 492+ if( os_timer !== null && os_timer.id !== null ) {
 493+ clearTimeout( os_timer.id );
 494+ }
466495 // schedule delayed fetching of results
467 - if(timeout != 0){
468 - os_timer = new os_Timer(setTimeout("os_delayedFetch()",timeout),r,query);
469 - } else{
470 - os_timer = new os_Timer(null,r,query);
 496+ if( timeout !== 0 ) {
 497+ os_timer = new os_Timer( setTimeout( "os_delayedFetch()", timeout ), r, query );
 498+ } else {
 499+ os_timer = new os_Timer( null, r, query );
471500 os_delayedFetch(); // do it now!
472501 }
473502
474503 }
 504+
475505 /** Change the highlighted row (i.e. suggestion), from position cur to next */
476 -function os_changeHighlight(r, cur, next, updateSearchBox){
477 - if (next >= r.resultCount)
478 - next = r.resultCount-1;
479 - if (next < -1)
 506+function os_changeHighlight( r, cur, next, updateSearchBox ) {
 507+ if ( next >= r.resultCount ) {
 508+ next = r.resultCount - 1;
 509+ }
 510+ if ( next < -1 ) {
480511 next = -1;
 512+ }
481513 r.selected = next;
482 - if (cur == next)
483 - return; // nothing to do.
 514+ if ( cur == next ) {
 515+ return; // nothing to do.
 516+ }
484517
485 - if(cur >= 0){
486 - var curRow = document.getElementById(r.resultTable + cur);
487 - if(curRow != null)
488 - curRow.className = "os-suggest-result";
489 - }
490 - var newText;
491 - if(next >= 0){
492 - var nextRow = document.getElementById(r.resultTable + next);
493 - if(nextRow != null)
494 - nextRow.className = os_HighlightClass();
495 - newText = r.results[next];
496 - } else
497 - newText = r.original;
 518+ if( cur >= 0 ) {
 519+ var curRow = document.getElementById( r.resultTable + cur );
 520+ if( curRow !== null ) {
 521+ curRow.className = 'os-suggest-result';
 522+ }
 523+ }
 524+ var newText;
 525+ if( next >= 0 ) {
 526+ var nextRow = document.getElementById( r.resultTable + next );
 527+ if( nextRow !== null ) {
 528+ nextRow.className = os_HighlightClass();
 529+ }
 530+ newText = r.results[next];
 531+ } else {
 532+ newText = r.original;
 533+ }
498534
499 - // adjust the scrollbar if any
500 - if(r.containerCount < r.resultCount){
501 - var c = document.getElementById(r.container);
502 - var vStart = c.scrollTop / r.containerRow;
503 - var vEnd = vStart + r.containerCount;
504 - if(next < vStart)
505 - c.scrollTop = next * r.containerRow;
506 - else if(next >= vEnd)
507 - c.scrollTop = (next - r.containerCount + 1) * r.containerRow;
508 - }
 535+ // adjust the scrollbar if any
 536+ if( r.containerCount < r.resultCount ) {
 537+ var c = document.getElementById( r.container );
 538+ var vStart = c.scrollTop / r.containerRow;
 539+ var vEnd = vStart + r.containerCount;
 540+ if( next < vStart ) {
 541+ c.scrollTop = next * r.containerRow;
 542+ } else if( next >= vEnd ) {
 543+ c.scrollTop = ( next - r.containerCount + 1 ) * r.containerRow;
 544+ }
 545+ }
509546
510 - // update the contents of the search box
511 - if(updateSearchBox){
512 - os_updateSearchQuery(r,newText);
513 - }
 547+ // update the contents of the search box
 548+ if( updateSearchBox ) {
 549+ os_updateSearchQuery( r, newText );
 550+ }
514551 }
515552
516553 function os_HighlightClass() {
517554 var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
518 - if (match) {
519 - var webKitVersion = parseInt(match[1]);
520 - if (webKitVersion < 523) {
 555+ if ( match ) {
 556+ var webKitVersion = parseInt( match[1] );
 557+ if ( webKitVersion < 523 ) {
521558 // CSS system highlight colors broken on old Safari
522559 // https://bugs.webkit.org/show_bug.cgi?id=6129
523560 // Safari 3.0.4, 3.1 known ok
524 - return "os-suggest-result-hl-webkit";
 561+ return 'os-suggest-result-hl-webkit';
525562 }
526563 }
527 - return "os-suggest-result-hl";
 564+ return 'os-suggest-result-hl';
528565 }
529566
530 -function os_updateSearchQuery(r,newText){
531 - document.getElementById(r.searchbox).value = newText;
532 - r.query = newText;
 567+function os_updateSearchQuery( r, newText ) {
 568+ document.getElementById( r.searchbox ).value = newText;
 569+ r.query = newText;
533570 }
534571
535572 /** Find event target */
536 -function os_getTarget(e){
537 - if (!e) e = window.event;
538 - if (e.target) return e.target;
539 - else if (e.srcElement) return e.srcElement;
540 - else return null;
 573+function os_getTarget( e ) {
 574+ if ( !e ) {
 575+ e = window.event;
 576+ }
 577+ if ( e.target ) {
 578+ return e.target;
 579+ } else if ( e.srcElement ) {
 580+ return e.srcElement;
 581+ } else {
 582+ return null;
 583+ }
541584 }
542585
543586
544 -
545587 /********************
546588 * Keyboard events
547589 ********************/
548590
549591 /** Event handler that will fetch results on keyup */
550 -function os_eventKeyup(e){
551 - var targ = os_getTarget(e);
 592+function os_eventKeyup( e ) {
 593+ var targ = os_getTarget( e );
552594 var r = os_map[targ.id];
553 - if(r == null)
 595+ if( r === null ) {
554596 return; // not our event
 597+ }
555598
556599 // some browsers won't generate keypressed for arrow keys, catch it
557 - if(os_keypressed_count == 0){
558 - os_processKey(r,os_cur_keypressed,targ);
 600+ if( os_keypressed_count === 0 ) {
 601+ os_processKey( r, os_cur_keypressed, targ );
559602 }
560603 var query = targ.value;
561 - os_fetchResults(r,query,os_search_timeout);
 604+ os_fetchResults( r, query, os_search_timeout );
562605 }
563606
564607 /** catch arrows up/down and escape to hide the suggestions */
565 -function os_processKey(r,keypressed,targ){
566 - if (keypressed == 40){ // Arrow Down
567 - if (r.visible) {
568 - os_changeHighlight(r, r.selected, r.selected+1, true);
569 - } else if(os_timer == null){
570 - // user wants to get suggestions now
571 - r.query = "";
572 - os_fetchResults(r,targ.value,0);
573 - }
574 - } else if (keypressed == 38){ // Arrow Up
575 - if (r.visible){
576 - os_changeHighlight(r, r.selected, r.selected-1, true);
577 - }
578 - } else if(keypressed == 27){ // Escape
579 - document.getElementById(r.searchbox).value = r.original;
580 - r.query = r.original;
581 - os_hideResults(r);
582 - } else if(r.query != document.getElementById(r.searchbox).value){
583 - // os_hideResults(r); // don't show old suggestions
584 - }
 608+function os_processKey( r, keypressed, targ ) {
 609+ if ( keypressed == 40 ) { // Arrow Down
 610+ if ( r.visible ) {
 611+ os_changeHighlight( r, r.selected, r.selected + 1, true );
 612+ } else if( os_timer === null ) {
 613+ // user wants to get suggestions now
 614+ r.query = '';
 615+ os_fetchResults( r, targ.value, 0 );
 616+ }
 617+ } else if ( keypressed == 38 ) { // Arrow Up
 618+ if ( r.visible ) {
 619+ os_changeHighlight( r, r.selected, r.selected - 1, true );
 620+ }
 621+ } else if( keypressed == 27 ) { // Escape
 622+ document.getElementById( r.searchbox ).value = r.original;
 623+ r.query = r.original;
 624+ os_hideResults( r );
 625+ } else if( r.query != document.getElementById( r.searchbox ).value ) {
 626+ // os_hideResults( r ); // don't show old suggestions
 627+ }
585628 }
586629
587630 /** When keys is held down use a timer to output regular events */
588 -function os_eventKeypress(e){
589 - var targ = os_getTarget(e);
 631+function os_eventKeypress( e ) {
 632+ var targ = os_getTarget( e );
590633 var r = os_map[targ.id];
591 - if(r == null)
 634+ if( r === null ) {
592635 return; // not our event
 636+ }
593637
594638 var keypressed = os_cur_keypressed;
595639
596640 os_keypressed_count++;
597 - os_processKey(r,keypressed,targ);
 641+ os_processKey( r, keypressed, targ );
598642 }
599643
600 -/** Catch the key code (Firefox bug) */
601 -function os_eventKeydown(e){
602 - if (!e) e = window.event;
603 - var targ = os_getTarget(e);
 644+/** Catch the key code (Firefox bug) */
 645+function os_eventKeydown( e ) {
 646+ if ( !e ) {
 647+ e = window.event;
 648+ }
 649+ var targ = os_getTarget( e );
604650 var r = os_map[targ.id];
605 - if(r == null)
 651+ if( r === null ) {
606652 return; // not our event
 653+ }
607654
608655 os_mouse_moved = false;
609656
610 - os_cur_keypressed = (e.keyCode == undefined) ? e.which : e.keyCode;
 657+ os_cur_keypressed = ( e.keyCode === undefined ) ? e.which : e.keyCode;
611658 os_keypressed_count = 0;
612659 }
613660
614661 /** Event: loss of focus of input box */
615 -function os_eventBlur(e){
616 - var targ = os_getTarget(e);
 662+function os_eventBlur( e ) {
 663+ var targ = os_getTarget( e );
617664 var r = os_map[targ.id];
618 - if(r == null)
 665+ if( r === null ) {
619666 return; // not our event
620 - if(!os_mouse_pressed){
621 - os_hideResults(r);
 667+ }
 668+ if( !os_mouse_pressed ) {
 669+ os_hideResults( r );
622670 // force canvas to stay hidden
623 - r.stayHidden = true
 671+ r.stayHidden = true;
624672 // cancel any pending fetches
625 - if(os_timer != null && os_timer.id != null)
626 - clearTimeout(os_timer.id);
627 - os_timer = null
 673+ if( os_timer !== null && os_timer.id !== null ) {
 674+ clearTimeout( os_timer.id );
 675+ }
 676+ os_timer = null;
628677 }
629678 }
630679
631680 /** Event: focus (catch only when stopped) */
632 -function os_eventFocus(e){
633 - var targ = os_getTarget(e);
 681+function os_eventFocus( e ) {
 682+ var targ = os_getTarget( e );
634683 var r = os_map[targ.id];
635 - if(r == null)
 684+ if( r === null ) {
636685 return; // not our event
637 - r.stayHidden = false
 686+ }
 687+ r.stayHidden = false;
638688 }
639689
640690
641 -
642691 /********************
643692 * Mouse events
644693 ********************/
645694
646695 /** Mouse over the container */
647 -function os_eventMouseover(srcId, e){
648 - var targ = os_getTarget(e);
 696+function os_eventMouseover( srcId, e ) {
 697+ var targ = os_getTarget( e );
649698 var r = os_map[srcId];
650 - if(r == null || !os_mouse_moved)
 699+ if( r === null || !os_mouse_moved ) {
651700 return; // not our event
652 - var num = os_getNumberSuffix(targ.id);
653 - if(num >= 0)
654 - os_changeHighlight(r,r.selected,num,false);
655 -
 701+ }
 702+ var num = os_getNumberSuffix( targ.id );
 703+ if( num >= 0 ) {
 704+ os_changeHighlight( r, r.selected, num, false );
 705+ }
656706 }
657707
658708 /* Get row where the event occured (from its id) */
659 -function os_getNumberSuffix(id){
660 - var num = id.substring(id.length-2);
661 - if( ! (num.charAt(0) >= '0' && num.charAt(0) <= '9') )
662 - num = num.substring(1);
663 - if(os_isNumber(num))
664 - return parseInt(num);
665 - else
 709+function os_getNumberSuffix( id ) {
 710+ var num = id.substring( id.length - 2 );
 711+ if( !( num.charAt( 0 ) >= '0' && num.charAt( 0 ) <= '9' ) ) {
 712+ num = num.substring( 1 );
 713+ }
 714+ if( os_isNumber( num ) ) {
 715+ return parseInt( num );
 716+ } else {
666717 return -1;
 718+ }
667719 }
668720
669721 /** Save mouse move as last action */
670 -function os_eventMousemove(srcId, e){
 722+function os_eventMousemove( srcId, e ) {
671723 os_mouse_moved = true;
672724 }
673725
674 -/** Mouse button held down, register possible click */
675 -function os_eventMousedown(srcId, e){
676 - var targ = os_getTarget(e);
 726+/** Mouse button held down, register possible click */
 727+function os_eventMousedown( srcId, e ) {
 728+ var targ = os_getTarget( e );
677729 var r = os_map[srcId];
678 - if(r == null)
 730+ if( r === null ) {
679731 return; // not our event
680 - var num = os_getNumberSuffix(targ.id);
 732+ }
 733+ var num = os_getNumberSuffix( targ.id );
681734
682735 os_mouse_pressed = true;
683 - if(num >= 0){
 736+ if( num >= 0 ) {
684737 os_mouse_num = num;
685 - // os_updateSearchQuery(r,r.results[num]);
 738+ // os_updateSearchQuery( r, r.results[num] );
686739 }
687740 // keep the focus on the search field
688 - document.getElementById(r.searchbox).focus();
 741+ document.getElementById( r.searchbox ).focus();
689742
690743 return false; // prevents selection
691744 }
692745
693746 /** Mouse button released, check for click on some row */
694 -function os_eventMouseup(srcId, e){
695 - var targ = os_getTarget(e);
 747+function os_eventMouseup( srcId, e ) {
 748+ var targ = os_getTarget( e );
696749 var r = os_map[srcId];
697 - if(r == null)
 750+ if( r === null ) {
698751 return; // not our event
699 - var num = os_getNumberSuffix(targ.id);
 752+ }
 753+ var num = os_getNumberSuffix( targ.id );
700754
701 - if(num >= 0 && os_mouse_num == num){
702 - os_updateSearchQuery(r,r.results[num]);
703 - os_hideResults(r);
704 - document.getElementById(r.searchform).submit();
 755+ if( num >= 0 && os_mouse_num == num ) {
 756+ os_updateSearchQuery( r, r.results[num] );
 757+ os_hideResults( r );
 758+ document.getElementById( r.searchform ).submit();
705759 }
706760 os_mouse_pressed = false;
707761 // keep the focus on the search field
708 - document.getElementById(r.searchbox).focus();
 762+ document.getElementById( r.searchbox ).focus();
709763 }
710764
711765 /** Check if x is a valid integer */
712 -function os_isNumber(x){
713 - if(x == "" || isNaN(x))
 766+function os_isNumber( x ) {
 767+ if( x == '' || isNaN( x ) ) {
714768 return false;
715 - for(var i=0;i<x.length;i++){
716 - var c = x.charAt(i);
717 - if( ! (c >= '0' && c <= '9') )
 769+ }
 770+ for( var i = 0; i < x.length; i++ ) {
 771+ var c = x.charAt( i );
 772+ if( !( c >= '0' && c <= '9' ) ) {
718773 return false;
 774+ }
719775 }
720776 return true;
721777 }
722778
723 -
724779 /** When the form is submitted hide everything, cancel updates... */
725 -function os_eventOnsubmit(e){
726 - var targ = os_getTarget(e);
 780+function os_eventOnsubmit( e ) {
 781+ var targ = os_getTarget( e );
727782
728783 os_is_stopped = true;
729784 // kill timed requests
730 - if(os_timer != null && os_timer.id != null){
731 - clearTimeout(os_timer.id);
 785+ if( os_timer !== null && os_timer.id !== null ) {
 786+ clearTimeout( os_timer.id );
732787 os_timer = null;
733788 }
734789 // Hide all suggestions
735 - for(i=0;i<os_autoload_inputs.length;i++){
 790+ for( i = 0; i < os_autoload_inputs.length; i++ ) {
736791 var r = os_map[os_autoload_inputs[i]];
737 - if(r != null){
738 - var b = document.getElementById(r.searchform);
739 - if(b != null && b == targ){
 792+ if( r !== null ) {
 793+ var b = document.getElementById( r.searchform );
 794+ if( b !== null && b == targ ) {
740795 // set query value so the handler won't try to fetch additional results
741 - r.query = document.getElementById(r.searchbox).value;
 796+ r.query = document.getElementById( r.searchbox ).value;
742797 }
743 - os_hideResults(r);
 798+ os_hideResults( r );
744799 }
745800 }
746801 return true;
747802 }
748803
749 -function os_hookEvent(element, hookName, hookFunct) {
750 - if (element.addEventListener) {
751 - element.addEventListener(hookName, hookFunct, false);
752 - } else if (window.attachEvent) {
753 - element.attachEvent("on" + hookName, hookFunct);
 804+function os_hookEvent( element, hookName, hookFunct ) {
 805+ if ( element.addEventListener ) {
 806+ element.addEventListener( hookName, hookFunct, false );
 807+ } else if ( window.attachEvent ) {
 808+ element.attachEvent( 'on' + hookName, hookFunct );
754809 }
755810 }
756811
757812 /** Init Result objects and event handlers */
758 -function os_initHandlers(name, formname, element){
759 - var r = new os_Results(name, formname);
 813+function os_initHandlers( name, formname, element ) {
 814+ var r = new os_Results( name, formname );
760815 // event handler
761 - os_hookEvent(element, "keyup", function(event) { os_eventKeyup(event); });
762 - os_hookEvent(element, "keydown", function(event) { os_eventKeydown(event); });
763 - os_hookEvent(element, "keypress", function(event) { os_eventKeypress(event); });
764 - os_hookEvent(element, "blur", function(event) { os_eventBlur(event); });
765 - os_hookEvent(element, "focus", function(event) { os_eventFocus(event); });
766 - element.setAttribute("autocomplete","off");
 816+ os_hookEvent( element, 'keyup', function( event ) { os_eventKeyup( event ); } );
 817+ os_hookEvent( element, 'keydown', function( event ) { os_eventKeydown( event ); } );
 818+ os_hookEvent( element, 'keypress', function( event ) { os_eventKeypress( event ); } );
 819+ os_hookEvent( element, 'blur', function( event ) { os_eventBlur( event ); } );
 820+ os_hookEvent( element, 'focus', function( event ) { os_eventFocus( event ); } );
 821+ element.setAttribute( 'autocomplete', 'off' );
767822 // stopping handler
768 - os_hookEvent(document.getElementById(formname), "submit", function(event){ return os_eventOnsubmit(event); });
 823+ os_hookEvent( document.getElementById( formname ), 'submit', function( event ) { return os_eventOnsubmit( event ); } );
769824 os_map[name] = r;
770825 // toggle link
771 - if(document.getElementById(r.toggle) == null){
 826+ if( document.getElementById( r.toggle ) === null ) {
772827 // TODO: disable this while we figure out a way for this to work in all browsers
773 - /* if(name=='searchInput'){
 828+ /* if( name == 'searchInput' ) {
774829 // special case: place above the main search box
775 - var t = os_createToggle(r,"os-suggest-toggle");
776 - var searchBody = document.getElementById('searchBody');
 830+ var t = os_createToggle( r, 'os-suggest-toggle' );
 831+ var searchBody = document.getElementById( 'searchBody' );
777832 var first = searchBody.parentNode.firstChild.nextSibling.appendChild(t);
778 - } else{
 833+ } else {
779834 // default: place below search box to the right
780 - var t = os_createToggle(r,"os-suggest-toggle-def");
 835+ var t = os_createToggle( r, 'os-suggest-toggle-def' );
781836 var top = element.offsetTop + element.offsetHeight;
782837 var left = element.offsetLeft + element.offsetWidth;
783 - t.style.position = "absolute";
784 - t.style.top = top + "px";
785 - t.style.left = left + "px";
786 - element.parentNode.appendChild(t);
 838+ t.style.position = 'absolute';
 839+ t.style.top = top + 'px';
 840+ t.style.left = left + 'px';
 841+ element.parentNode.appendChild( t );
787842 // only now width gets calculated, shift right
788843 left -= t.offsetWidth;
789 - t.style.left = left + "px";
790 - t.style.visibility = "visible";
 844+ t.style.left = left + 'px';
 845+ t.style.visibility = 'visible';
791846 } */
792847 }
793848
794849 }
795850
796851 /** Return the span element that contains the toggle link */
797 -function os_createToggle(r,className){
798 - var t = document.createElement("span");
 852+function os_createToggle( r, className ) {
 853+ var t = document.createElement( 'span' );
799854 t.className = className;
800 - t.setAttribute("id", r.toggle);
801 - var link = document.createElement("a");
802 - link.setAttribute("href","javascript:void(0);");
803 - link.onclick = function(){ os_toggle(r.searchbox,r.searchform) };
804 - var msg = document.createTextNode(wgMWSuggestMessages[0]);
805 - link.appendChild(msg);
806 - t.appendChild(link);
 855+ t.setAttribute( 'id', r.toggle );
 856+ var link = document.createElement( 'a' );
 857+ link.setAttribute( 'href', 'javascript:void(0);' );
 858+ link.onclick = function() { os_toggle( r.searchbox, r.searchform ); };
 859+ var msg = document.createTextNode( wgMWSuggestMessages[0] );
 860+ link.appendChild( msg );
 861+ t.appendChild( link );
807862 return t;
808863 }
809864
810865 /** Call when user clicks on some of the toggle links */
811 -function os_toggle(inputId,formName){
 866+function os_toggle( inputId, formName ) {
812867 r = os_map[inputId];
813868 var msg = '';
814 - if(r == null){
815 - os_enableSuggestionsOn(inputId,formName);
 869+ if( r === null ) {
 870+ os_enableSuggestionsOn( inputId, formName );
816871 r = os_map[inputId];
817872 msg = wgMWSuggestMessages[0];
818873 } else{
819 - os_disableSuggestionsOn(inputId,formName);
 874+ os_disableSuggestionsOn( inputId, formName );
820875 msg = wgMWSuggestMessages[1];
821876 }
822877 // change message
823 - var link = document.getElementById(r.toggle).firstChild;
824 - link.replaceChild(document.createTextNode(msg),link.firstChild);
 878+ var link = document.getElementById( r.toggle ).firstChild;
 879+ link.replaceChild( document.createTextNode( msg ), link.firstChild );
825880 }
826881
827882 /** Call this to enable suggestions on input (id=inputId), on a form (name=formName) */
828 -function os_enableSuggestionsOn(inputId, formName){
829 - os_initHandlers( inputId, formName, document.getElementById(inputId) );
 883+function os_enableSuggestionsOn( inputId, formName ) {
 884+ os_initHandlers( inputId, formName, document.getElementById( inputId ) );
830885 }
831886
832887 /** Call this to disable suggestios on input box (id=inputId) */
833 -function os_disableSuggestionsOn(inputId){
 888+function os_disableSuggestionsOn( inputId ) {
834889 r = os_map[inputId];
835 - if(r != null){
 890+ if( r !== null ) {
836891 // cancel/hide results
837892 os_timer = null;
838 - os_hideResults(r);
 893+ os_hideResults( r );
839894 // turn autocomplete on !
840 - document.getElementById(inputId).setAttribute("autocomplete","on");
 895+ document.getElementById( inputId ).setAttribute( 'autocomplete', 'on' );
841896 // remove descriptor
842897 os_map[inputId] = null;
843898 }
844 -
 899+
845900 // Remove the element from the os_autoload_* arrays
846 - var index = os_autoload_inputs.indexOf(inputId);
847 - if ( index >= 0 )
 901+ var index = os_autoload_inputs.indexOf( inputId );
 902+ if ( index >= 0 ) {
848903 os_autoload_inputs[index] = os_autoload_forms[index] = '';
 904+ }
849905 }
850906
851907 /** Initialization, call upon page onload */
852908 function os_MWSuggestInit() {
853 - for(i=0;i<os_autoload_inputs.length;i++){
 909+ for( i = 0; i < os_autoload_inputs.length; i++ ) {
854910 var id = os_autoload_inputs[i];
855911 var form = os_autoload_forms[i];
856912 element = document.getElementById( id );
857 - if(element != null)
858 - os_initHandlers(id,form,element);
 913+ if( element !== null ) {
 914+ os_initHandlers( id, form, element );
 915+ }
859916 }
860917 }
861918
862 -hookEvent("load", os_MWSuggestInit);
 919+hookEvent( 'load', os_MWSuggestInit );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1658,7 +1658,7 @@
16591659 * to ensure that client-side caches do not keep obsolete copies of global
16601660 * styles.
16611661 */
1662 -$wgStyleVersion = '263';
 1662+$wgStyleVersion = '264';
16631663
16641664
16651665 # Server-side caching:

Follow-up revisions

RevisionCommit summaryAuthorDate
r61253Revert r61251 as r61252 fixes the extension (so thats presumably "Wrong")reedy15:32, 19 January 2010
r61342Revert broken r61251 use of strong equality...simetrical21:34, 21 January 2010

Status & tagging log