Index: trunk/phase3/skins/common/mwsuggest.js |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | var id = os_autoload_inputs[i]; |
94 | 94 | var form = os_autoload_forms[i]; |
95 | 95 | element = document.getElementById( id ); |
96 | | - if( element !== null ) { |
| 96 | + if( element != null ) { |
97 | 97 | os_initHandlers( id, form, element ); |
98 | 98 | } |
99 | 99 | } |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | os_hookEvent( document.getElementById( formname ), 'submit', function( event ) { return os_eventOnsubmit( event ); } ); |
114 | 114 | os_map[name] = r; |
115 | 115 | // toggle link |
116 | | - if( document.getElementById( r.toggle ) === null ) { |
| 116 | + if( document.getElementById( r.toggle ) == null ) { |
117 | 117 | // TODO: disable this while we figure out a way for this to work in all browsers |
118 | 118 | /* if( name == 'searchInput' ) { |
119 | 119 | // special case: place above the main search box |
— | — | @@ -153,12 +153,12 @@ |
154 | 154 | function os_eventKeyup( e ) { |
155 | 155 | var targ = os_getTarget( e ); |
156 | 156 | var r = os_map[targ.id]; |
157 | | - if( r === null ) { |
| 157 | + if( r == null ) { |
158 | 158 | return; // not our event |
159 | 159 | } |
160 | 160 | |
161 | 161 | // some browsers won't generate keypressed for arrow keys, catch it |
162 | | - if( os_keypressed_count === 0 ) { |
| 162 | + if( os_keypressed_count == 0 ) { |
163 | 163 | os_processKey( r, os_cur_keypressed, targ ); |
164 | 164 | } |
165 | 165 | var query = targ.value; |
— | — | @@ -170,7 +170,7 @@ |
171 | 171 | if ( keypressed == 40 ) { // Arrow Down |
172 | 172 | if ( r.visible ) { |
173 | 173 | os_changeHighlight( r, r.selected, r.selected + 1, true ); |
174 | | - } else if( os_timer === null ) { |
| 174 | + } else if( os_timer == null ) { |
175 | 175 | // user wants to get suggestions now |
176 | 176 | r.query = ''; |
177 | 177 | os_fetchResults( r, targ.value, 0 ); |
— | — | @@ -192,7 +192,7 @@ |
193 | 193 | function os_eventKeypress( e ) { |
194 | 194 | var targ = os_getTarget( e ); |
195 | 195 | var r = os_map[targ.id]; |
196 | | - if( r === null ) { |
| 196 | + if( r == null ) { |
197 | 197 | return; // not our event |
198 | 198 | } |
199 | 199 | |
— | — | @@ -209,13 +209,13 @@ |
210 | 210 | } |
211 | 211 | var targ = os_getTarget( e ); |
212 | 212 | var r = os_map[targ.id]; |
213 | | - if( r === null ) { |
| 213 | + if( r == null ) { |
214 | 214 | return; // not our event |
215 | 215 | } |
216 | 216 | |
217 | 217 | os_mouse_moved = false; |
218 | 218 | |
219 | | - os_cur_keypressed = ( e.keyCode === undefined ) ? e.which : e.keyCode; |
| 219 | + os_cur_keypressed = ( e.keyCode == undefined ) ? e.which : e.keyCode; |
220 | 220 | os_keypressed_count = 0; |
221 | 221 | } |
222 | 222 | |
— | — | @@ -223,7 +223,7 @@ |
224 | 224 | function os_eventBlur( e ) { |
225 | 225 | var targ = os_getTarget( e ); |
226 | 226 | var r = os_map[targ.id]; |
227 | | - if( r === null ) { |
| 227 | + if( r == null ) { |
228 | 228 | return; // not our event |
229 | 229 | } |
230 | 230 | if( !os_mouse_pressed ) { |
— | — | @@ -231,7 +231,7 @@ |
232 | 232 | // force canvas to stay hidden |
233 | 233 | r.stayHidden = true; |
234 | 234 | // cancel any pending fetches |
235 | | - if( os_timer !== null && os_timer.id !== null ) { |
| 235 | + if( os_timer != null && os_timer.id != null ) { |
236 | 236 | clearTimeout( os_timer.id ); |
237 | 237 | } |
238 | 238 | os_timer = null; |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | function os_eventFocus( e ) { |
244 | 244 | var targ = os_getTarget( e ); |
245 | 245 | var r = os_map[targ.id]; |
246 | | - if( r === null ) { |
| 246 | + if( r == null ) { |
247 | 247 | return; // not our event |
248 | 248 | } |
249 | 249 | r.stayHidden = false; |
— | — | @@ -255,16 +255,16 @@ |
256 | 256 | |
257 | 257 | os_is_stopped = true; |
258 | 258 | // kill timed requests |
259 | | - if( os_timer !== null && os_timer.id !== null ) { |
| 259 | + if( os_timer != null && os_timer.id != null ) { |
260 | 260 | clearTimeout( os_timer.id ); |
261 | 261 | os_timer = null; |
262 | 262 | } |
263 | 263 | // Hide all suggestions |
264 | 264 | for( i = 0; i < os_autoload_inputs.length; i++ ) { |
265 | 265 | var r = os_map[os_autoload_inputs[i]]; |
266 | | - if( r !== null ) { |
| 266 | + if( r != null ) { |
267 | 267 | var b = document.getElementById( r.searchform ); |
268 | | - if( b !== null && b == targ ) { |
| 268 | + if( b != null && b == targ ) { |
269 | 269 | // set query value so the handler won't try to fetch additional results |
270 | 270 | r.query = document.getElementById( r.searchbox ).value; |
271 | 271 | } |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | /** Hide results div */ |
281 | 281 | function os_hideResults( r ) { |
282 | 282 | var c = document.getElementById( r.container ); |
283 | | - if( c !== null ) { |
| 283 | + if( c != null ) { |
284 | 284 | c.style.visibility = 'hidden'; |
285 | 285 | } |
286 | 286 | r.visible = false; |
— | — | @@ -297,7 +297,7 @@ |
298 | 298 | os_fitContainer( r ); |
299 | 299 | var c = document.getElementById( r.container ); |
300 | 300 | r.selected = -1; |
301 | | - if( c !== null ) { |
| 301 | + if( c != null ) { |
302 | 302 | c.scrollTop = 0; |
303 | 303 | c.style.visibility = 'visible'; |
304 | 304 | r.visible = true; |
— | — | @@ -480,7 +480,7 @@ |
481 | 481 | var newW = Math.round( normW * prop ); |
482 | 482 | if( w != newW ) { |
483 | 483 | w = newW; |
484 | | - if( os_animation_timer !== null ) { |
| 484 | + if( os_animation_timer != null ) { |
485 | 485 | clearInterval( os_animation_timer.id ); |
486 | 486 | } |
487 | 487 | os_animation_timer = new os_AnimationTimer( r, w ); |
— | — | @@ -549,14 +549,14 @@ |
550 | 550 | } else { |
551 | 551 | try { |
552 | 552 | var p = eval( '(' + text + ')' ); // simple json parse, could do a safer one |
553 | | - if( p.length < 2 || p[1].length === 0 ) { |
| 553 | + if( p.length < 2 || p[1].length == 0 ) { |
554 | 554 | r.results = null; |
555 | 555 | r.resultCount = 0; |
556 | 556 | os_hideResults( r ); |
557 | 557 | return; |
558 | 558 | } |
559 | 559 | var c = document.getElementById( r.container ); |
560 | | - if( c === null ) { |
| 560 | + if( c == null ) { |
561 | 561 | c = os_createContainer( r ); |
562 | 562 | } |
563 | 563 | c.innerHTML = os_createResultTable( r, p[1] ); |
— | — | @@ -619,7 +619,7 @@ |
620 | 620 | /** Update results if user hasn't already typed something else */ |
621 | 621 | function os_updateIfRelevant( r, query, text, cacheKey ) { |
622 | 622 | var t = document.getElementById( r.searchbox ); |
623 | | - if( t !== null && t.value == query ) { // check if response is still relevant |
| 623 | + if( t != null && t.value == query ) { // check if response is still relevant |
624 | 624 | os_updateResults( r, query, text, cacheKey ); |
625 | 625 | } |
626 | 626 | r.query = query; |
— | — | @@ -627,7 +627,7 @@ |
628 | 628 | |
629 | 629 | /** Fetch results after some timeout */ |
630 | 630 | function os_delayedFetch() { |
631 | | - if( os_timer === null ) { |
| 631 | + if( os_timer == null ) { |
632 | 632 | return; |
633 | 633 | } |
634 | 634 | var r = os_timer.r; |
— | — | @@ -639,7 +639,7 @@ |
640 | 640 | |
641 | 641 | // try to get from cache, if not fetch using ajax |
642 | 642 | var cached = os_cache[path]; |
643 | | - if( cached !== null ) { |
| 643 | + if( cached != null ) { |
644 | 644 | os_updateIfRelevant( r, query, cached, path ); |
645 | 645 | } else { |
646 | 646 | var xmlhttp = sajax_init_object(); |
— | — | @@ -682,11 +682,11 @@ |
683 | 683 | } */ |
684 | 684 | |
685 | 685 | // cancel any pending fetches |
686 | | - if( os_timer !== null && os_timer.id !== null ) { |
| 686 | + if( os_timer != null && os_timer.id != null ) { |
687 | 687 | clearTimeout( os_timer.id ); |
688 | 688 | } |
689 | 689 | // schedule delayed fetching of results |
690 | | - if( timeout !== 0 ) { |
| 690 | + if( timeout != 0 ) { |
691 | 691 | os_timer = new os_Timer( setTimeout( "os_delayedFetch()", timeout ), r, query ); |
692 | 692 | } else { |
693 | 693 | os_timer = new os_Timer( null, r, query ); |
— | — | @@ -710,14 +710,14 @@ |
711 | 711 | |
712 | 712 | if( cur >= 0 ) { |
713 | 713 | var curRow = document.getElementById( r.resultTable + cur ); |
714 | | - if( curRow !== null ) { |
| 714 | + if( curRow != null ) { |
715 | 715 | curRow.className = 'os-suggest-result'; |
716 | 716 | } |
717 | 717 | } |
718 | 718 | var newText; |
719 | 719 | if( next >= 0 ) { |
720 | 720 | var nextRow = document.getElementById( r.resultTable + next ); |
721 | | - if( nextRow !== null ) { |
| 721 | + if( nextRow != null ) { |
722 | 722 | nextRow.className = os_HighlightClass(); |
723 | 723 | } |
724 | 724 | newText = r.results[next]; |
— | — | @@ -785,7 +785,7 @@ |
786 | 786 | function os_eventMouseover( srcId, e ) { |
787 | 787 | var targ = os_getTarget( e ); |
788 | 788 | var r = os_map[srcId]; |
789 | | - if( r === null || !os_mouse_moved ) { |
| 789 | + if( r == null || !os_mouse_moved ) { |
790 | 790 | return; // not our event |
791 | 791 | } |
792 | 792 | var num = os_getNumberSuffix( targ.id ); |
— | — | @@ -816,7 +816,7 @@ |
817 | 817 | function os_eventMousedown( srcId, e ) { |
818 | 818 | var targ = os_getTarget( e ); |
819 | 819 | var r = os_map[srcId]; |
820 | | - if( r === null ) { |
| 820 | + if( r == null ) { |
821 | 821 | return; // not our event |
822 | 822 | } |
823 | 823 | var num = os_getNumberSuffix( targ.id ); |
— | — | @@ -836,7 +836,7 @@ |
837 | 837 | function os_eventMouseup( srcId, e ) { |
838 | 838 | var targ = os_getTarget( e ); |
839 | 839 | var r = os_map[srcId]; |
840 | | - if( r === null ) { |
| 840 | + if( r == null ) { |
841 | 841 | return; // not our event |
842 | 842 | } |
843 | 843 | var num = os_getNumberSuffix( targ.id ); |
— | — | @@ -883,7 +883,7 @@ |
884 | 884 | function os_toggle( inputId, formName ) { |
885 | 885 | r = os_map[inputId]; |
886 | 886 | var msg = ''; |
887 | | - if( r === null ) { |
| 887 | + if( r == null ) { |
888 | 888 | os_enableSuggestionsOn( inputId, formName ); |
889 | 889 | r = os_map[inputId]; |
890 | 890 | msg = wgMWSuggestMessages[0]; |
— | — | @@ -904,7 +904,7 @@ |
905 | 905 | /** Call this to disable suggestios on input box (id=inputId) */ |
906 | 906 | function os_disableSuggestionsOn( inputId ) { |
907 | 907 | r = os_map[inputId]; |
908 | | - if( r !== null ) { |
| 908 | + if( r != null ) { |
909 | 909 | // cancel/hide results |
910 | 910 | os_timer = null; |
911 | 911 | os_hideResults( r ); |