מדיה ויקי:Gadget-Dwim.js: הבדלים בין גרסאות בדף

no more configuration item for search suggestions. try "true" for good measure.
מ 54 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-Dwim.js יובאו
 
(13 גרסאות ביניים של 5 משתמשים אינן מוצגות)
שורה 1: שורה 1:
if ( mw.user.options.get( 'skin' ) === 'vector' ) {
if ( mw.user.options.get( 'skin' ) === 'vector' ) {
$(function() {
setTimeout( function() {
    'use strict';


// Load the search suggestion logic when focus the search box.
function dwimEventListener( e ) {
if (
e.target.id === 'searchInput' ||
/(^|\s)mw-searchInput($|\s)/.test( e.target.className )
) {
enableDwim();
document.removeEventListener( 'focusin', dwimEventListener );
}
}
document.addEventListener( 'focusin', dwimEventListener );


var hes = "qwertyuiopasdfghjkl;zxcvbnm,./'קראטוןםפשדגכעיחלךףזסבהנמצתץ",
// Load the search suggestion logic when the search box is already focused
hebeng = function ( str ) {
// because the user started typing before the JavaScript is loaded.
var hes = "qwertyuiopasdfghjkl;zxcvbnm,./'קראטוןםפשדגכעיחלךףזסבהנמצתץ";
if (
document.activeElement && (
return ( str || '' ).replace( /./g, function( c ) {
document.activeElement.id === 'searchInput' ||
var ic = hes.indexOf( c.toLowerCase() );
/(^|\s)mw-searchInput($|\s)/.test( document.activeElement.className )
return ic + 1 ? hes.charAt( ( ic + 29 ) % 58 ) : c;
)
} );
) {
};
enableDwim();
}
    var $searchBoxes = $( '#searchInput, #searchInput2, #powerSearchText, #searchText' );


    $searchBoxes.suggestions( {
function enableDwimModernVector() {
        fetch: function( query ) {
// @todo
            var $this = $( this );
}
            if ( query.length !== 0 ) {
 
                var params = {
function enableDwim() {
                    action: 'opensearch',
'use strict';
                    search: query,
if(mw.loader.getState('mediawiki.searchSuggest') === 'registered') {
                    redirects: 'return',
// Vector is using the new version of search. Exit early to avoid running incompatible code.
                    suggest: true
enableDwimModernVector();
                };
return;
                $.ajax( {
}
                    data: params,
 
                    url: mw.util.wikiScript('api'),
setTimeout( function() {
                    dataType: 'json',
var hes = "qwertyuiopasdfghjkl;zxcvbnm,./'קראטוןםפשדגכעיחלךףזסבהנמצתץ",
                    success: function( data ) {
hebeng = function ( str ) {
                        if ($.isArray( data ) && 1 in data) {
return ( str || '' ).replace( /./g, function( c ) {
                            var orig = data[1];
var ic = hes.indexOf( c.toLowerCase() );
                            $this.suggestions( 'suggestions', orig );
 
                            if ( data[1].length < 10 ) {
return ic + 1 ? hes.charAt( ( ic + 29 ) % 58 ) : c;
                                params.search = hebeng( query );
} );
                                if ( params.search === query )
};
                                    return;
                                params.limit = 10 - data[1].length;
var $searchBoxes = $(
                                $.ajax({
'#searchInput, #searchInput2, #powerSearchText, #searchText'
                                    data: params,
);
                                    url: mw.util.wikiScript('api'),
 
                                    dataType: 'json',
$searchBoxes.suggestions( {
                                    success: function( data ) {
fetch: function( query ) {
                                        if ( $.isArray( data ) && 1 in data )  
var $this = $( this ),
                                            $this.suggestions( 'suggestions', orig.concat( data[1] ) );
apiUrl = mw.util.wikiScript( 'api' );
                                    }
 
                                });
if ( query.length !== 0 ) {
                            }
var params = {
                        }
action: 'opensearch',
                    }
search: query,
                } );
redirects: 'return',
            }
suggest: true
        }
};
    });
 
}, 1200); // setTimeout
$.ajax( {
} ); // document.ready
data: params,
} // skin == vector
url: apiUrl,
dataType: 'json',
success: function( data ) {
if ( $.isArray( data ) && 1 in data ) {
var orig = data[1];
 
$this.suggestions( 'suggestions', orig );
 
if ( data[1].length < 10 ) {
params.search = hebeng( query );
if ( params.search === query ) {
return;
}
 
params.limit = 10 - data[1].length;
 
$.ajax( {
data: params,
url: apiUrl,
dataType: 'json',
success: function( data ) {
if ( $.isArray( data ) && 1 in data ) {
$this.suggestions(
'suggestions',
orig.concat( data[1] )
);
}
}
} );
}
}
}
} );
}
}
} );
}, 1200 ); // setTimeout
}
 
} // skin === vector