MediaWiki:Common.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
codice duplicato in Monobook.js e Vector.js; sposto qui
rimuovo codice non più utile (cfr. http://en.wikipedia.org/w/index.php?title=MediaWiki%3ACommon.js&action=historysubmit&diff=367031092&oldid=365941730)
Riga 424:
}
})
 
 
/** Mobile Redirect Helper ************************************************
*
* Redirects to the mobile-optimized gateway at it.m.wikipedia.org
* for viewers on iPhone, iPod Touch, Palm Pre, and Android devices.
*
* You can turn off the redirect by setting the cookie "stopMobileRedirect=true"
*
* This code cannot be imported, because the JS only loads after all other files
* and this was causing major issues for users with mobile devices. Must be loaded
* *before* the images and etc of the page on all mobile devices.
*
* Maintainer: [[User:Brion VIBBER]], [[User:hcatlin]]
*/
if (/(Android|iPhone|iPod|webOS|NetFront|Opera Mini|SEMC-Browser|PlayStation Portable|Nintendo Wii)/.test(navigator.userAgent)) {
var wgMainPageName = 'Pagina_principale';
var stopMobileRedirectCookieExists = function() {
return (document.cookie.indexOf("stopMobileRedirect=true") >= 0);
}
var mobileSiteLink = function() {
if (mw.config.get('wgCanonicalNamespace') == 'Special' && mw.config.get('wgCanonicalSpecialPageName') == 'Search') {
var pageLink = '?search=' + encodeURIComponent(document.getElementById('searchText').value);
} else if (mw.config.get('wgPageName') == wgMainPageName) {
var pageLink = '::Home'; // Special case
} else {
var pageLink = encodeURIComponent(mw.config.get('wgPageName')).replace('%2F','/').replace('%3A',':');
}
return 'http://' + mw.config.get('wgContentLanguage') + '.m.wikipedia.org/wiki/' + pageLink + "?wasRedirected=true"
 
}
if (!stopMobileRedirectCookieExists()) {
document.___location = mobileSiteLink();
}
}
 
/** extract a URL parameter from the current URL **********