Removing calls to deprecated functionality in favor of the new versions. Old version...
[lhc/web/wiklou.git] / skins / common / search.js
1 // JS specific to Special:Search
2
3 // change the search link to what user entered
4 window.mwSearchHeaderClick = function( obj ) {
5 var searchbox = document.getElementById( 'searchText' );
6 if( searchbox === null ) {
7 searchbox = document.getElementById( 'powerSearchText' );
8 }
9 if( searchbox === null ) {
10 return; // should always have either normal or advanced search
11 }
12
13 var searchterm = searchbox.value;
14 var parts = obj.getAttribute( 'href', 2).split( 'search=' );
15 var lastpart = '';
16 var prefix = 'search=';
17 if( parts.length > 1 && parts[1].indexOf('&') >= 0 ) {
18 lastpart = parts[1].substring( parts[1].indexOf('&') );
19 } else {
20 prefix = '&search=';
21 }
22 obj.href = parts[0] + prefix + encodeURIComponent( searchterm ) + lastpart;
23 };
24
25 window.mwToggleSearchCheckboxes = function( btn ) {
26 if( !document.getElementById ) {
27 return;
28 }
29
30 var nsInputs = document.getElementById( 'powersearch' ).getElementsByTagName( 'input' );
31 var isChecked = false;
32
33 for ( var i = 0; i < nsInputs.length; i++ ) {
34 var pattern = /^ns/;
35 if ( ( nsInputs[i].type == 'checkbox' ) && ( pattern.test( nsInputs[i].name ) ) ) {
36 switch ( btn ) {
37 case 'none':
38 if ( nsInputs[i].checked ) {
39 nsInputs[i].checked = false;
40 }
41 break;
42 case 'all':
43 if ( !nsInputs[i].checked ) {
44 nsInputs[i].checked = true;
45 }
46 break;
47 }
48 }
49 }
50 };