MediaWiki:Gadget-fullwidth-search-fix.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
(function($, mw) {
// don't be too aggresive. just fix some obvious typos
var searchTerm = mw.util.getParamValue('search');
if (searchTerm !== null && mw.util.getParamValue('fulltext') === null) {
// namespace names
var colonIdx = searchTerm.indexOf(':');
if (colonIdx != -1) {
var ns = searchTerm.substring(0, colonIdx);
var page = searchTerm.substring(colonIdx + 1);
if (mw.config.get('wgNamespaceIds')[ns.toLowerCase()]) {
// valid namespace
var url = mw.config.get('wgScript') + '?search=' + encodeURIComponent(ns + ':' + page);
mw.notify('Redirecting to ' + mw.html.escape(url));
window.location.href = url;
}
}
}
})(jQuery, mediaWiki);