MediaWiki:Mobile.js
Ir a la navegación
Ir a la búsqueda
Nota: Después de publicar, quizás necesite actualizar la caché de su navegador para ver los cambios.
- Firefox/Safari: Mantenga presionada la tecla Shift mientras pulsa el botón Actualizar, o presiona Ctrl+F5 o Ctrl+R (⌘+R en Mac)
- Google Chrome: presione Ctrl+Shift+R (⌘+Shift+R en Mac)
- Internet Explorer/Edge: mantenga presionada Ctrl mientras pulsa Actualizar, o presione Ctrl+F5
- Opera: Presiona Ctrl+F5.
/* Cualquier código JavaScript escrito aquí se cargará para los usuarios de la versión móvil */
// Los timeouts hacen falta porque estos scripts se cargan antes que la skin móvil DE LOS COJONES
// así que con el setTimeout ponemos el proceso de cargar js y css al final de la cola
if (!window.importStylesheetPage) {
window.importStylesheetPage = function(page, wiki) {
setTimeout(function() {
if (!wiki || wiki == 'inciclopedia') {
mw.loader.load( mw.config.get('wgScript') + '?title='+encodeURIComponent(page)+'&action=raw&ctype=text/css', 'text/css' );
} else {
mw.log('No se pueden importar estilos de otros wikis con importStylesheetPage ('+page+', '+wiki+')');
}
}, 0);
};
}
if (!window.importScriptPage) {
window.importScriptPage = function(page, wiki) {
setTimeout(function() { if (!wiki || wiki == 'inciclopedia') {
mw.loader.load( mw.config.get('wgScript') + '?title='+encodeURIComponent(page)+'&action=raw&ctype=text/javascript' );
} else {
mw.log('No se pueden importar scripts de otros wikis con importScriptPage ('+page+', '+wiki+')');
}}, 0);
};
}
if (!window.importScriptURI) {
window.importScriptURI = function(uri) {
mw.loader.load( uri );
};
}
/* Add to MediaWiki:Mobile.js for custom Mobile Menu links
for MW-1.34.2 with MobileFrontend and MinervaNeue
Just replace span text and href to add links */
var timer = setInterval(function() {
if ($('.menu ul:first').length) {
console.log("mobile menu exists");
clearInterval(timer);
$('.menu ul:first').after(
'<ul> \
<li> \
<a href="/wiki/Foro:Forúnculo" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Forúnculo</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Especial:CambiosRecientes" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Cambios recientes</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Inciclopedia:Donaciones" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Donaciones</span> \
</a> \
</li> \
<li> \
<a href="https://discord.gg/fUUFtrY" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Discord</span> \
</item>\
</a> \
</li> \
<li> \
<a href="/wiki/Especial:SubirArchivo" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Subir imagen/archivo</span> \
</a> \
</li> \
<li>\
<a href="/wiki/Ayuda:Portada" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Ayuda</span> \
</a> \
</li> \
<li>\
<a href="https://inciclopedia.atlassian.net/servicedesk/customer/portals" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-mapPin"> \
<span>Contactar</span> \
</a> \
</li> \
</ul> \
<ul class="level1" style="padding-bottom: 0;"> \
<li> \
<a href="#" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-wikimedia-menu-base20"> \
<span>Votaciones</span> \
</a> \
</li> \
<ul class ="level2"> \
<li> \
<a href="/wiki/Inciclopedia:VPD" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Futuros Destacados</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Inciclopedia:VPD" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Destacados Locales</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Inciclopedia:VPDP" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Destacados Temáticos</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Inciclopedia:VPI" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Imágenes destacadas</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Inciclopedia:VPB" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Artículos a borrar</span> \
</a> \
</li> \
</ul> \
</ul> \
<ul class="level1"> \
<li> \
<a href="#" \
class="mw-ui-icon mw-ui-icon-before mw-ui-icon-wikimedia-menu-base20"> \
<span>Proyectos</span> \
</a> \
</li> \
<ul class ="level2"> \
<li> \
<a href="/wiki/Incinoticias:Portada" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Incinoticias</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Incilibros" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Incilibros</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Inciclopedia:Incionario" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Incionario</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Incitables:Portada" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Incitables</span> \
</a> \
</li> \
<li> \
<a href="/wiki/Incijuegos:Portada" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>Incijuegos</span> \
</a> \
</li> \
<li> \
<a href="/wiki/ATunes" \
class="mw-ui-icon mw-ui-icon-before"> \
<span>aTunes</span> \
</a> \
</li> \
</ul> \
</ul>'
);
$(".menu").find(".level2").hide(); // hide level2 until level1 is clicked
$(".level1").click(function(event){
$(this).find(".level2").slideToggle(500);
}); // if level1 is clicked, dropdown level2
}
}, 100); // check every 100ms
// Borradores para editor móvil
function installDrafts() {
/* Desactivado hasta que se arregle
$(".overlay-header.header.initial-header.hideable > .header-action").prepend('<span id="incibuttons"><button class="mw-ui-icon mw-ui-icon-element mw-ui-icon-download" style="height: 12px;" id="saveDraft" title="Guardar borrador"></button><button class="mw-ui-icon mw-ui-icon-element mw-ui-icon-history" style="height: 12px;" id="recoverDraft" title="Recuperar borrador"></button><button class="mw-ui-icon mw-ui-icon-element mw-ui-icon-signature" style="height: 12px;" id="sign" title="Firmar"></button></span>');
$("#saveDraft").click(saveDraftBtn);
$("#recoverDraft").click(recoverDraftBtn);
$("#sign").click(signBtn);
*/
}
function saveDraftBtn() {
if (window.isSaving) {
return alert("Estoy guardando...");
}
window.isSaving = true;
savedQuery = "https://inciclopedia.org/w/api.php?action=query&prop=revisions&titles=Usuario:" + encodeURIComponent(mw.config.values['wgUserName'] + "/Borradores/" + mw.config.values['wgPageName']) + "&rvprop=content&formatversion=2&format=json";
console.log("GET a " + savedQuery);
$.getJSON({
url: savedQuery
}).done(function (data) {
const txt = $("#wikitext-editor").val();
if (data["query"] && data["query"]["pages"] && data["query"]["pages"][0] && data["query"]["pages"][0]["revisions"] && data["query"]["pages"][0]["revisions"][0] && !confirm("Ya existe un borrador. ¿Sobreescribir?")) {
window.isSaving = false;
return;
}
console.log("A por el CSRF");
$.getJSON({
url: "https://inciclopedia.org/w/api.php?action=query&meta=tokens&format=json"
}).done(function (data) {
csrfToken = data["query"]["tokens"]["csrftoken"];
query = "https://inciclopedia.org/w/api.php"
console.log("POST a " + query);
$.post(query, {
"action": "edit",
"title": "Usuario:" + mw.config.values['wgUserName'] + "/Borradores/" + mw.config.values['wgPageName'],
"token": csrfToken,
"minor": true,
"summary": "Guardando borrador",
"text": txt,
"format": "json"
}, function(data) {
if (data && data["edit"] && data["edit"]["result"] == "Success") {
alert("Borrador guardado en tu página de usuario! Puedes verlo en Usuario:" + mw.config.values['wgUserName'] + "/Borradores/" + mw.config.values['wgPageName'])
} else {
alert("Es posible que algo haya ido mal guardando el borrador :(");
}
window.isSaving = false;
})
});
});
}
function recoverDraftBtn() {
$.getJSON({
url: "https://inciclopedia.org/w/api.php?action=query&prop=revisions&titles=Usuario:" + encodeURIComponent(mw.config.values['wgUserName'] + "/Borradores/" + mw.config.values['wgPageName']) + "&rvprop=content&formatversion=2&format=json"
}).done(function (data) {
if (data["query"] && data["query"]["pages"] && data["query"]["pages"][0] && data["query"]["pages"][0]["revisions"] && data["query"]["pages"][0]["revisions"][0]) {
wikitext = data["query"]["pages"][0]["revisions"][0]["content"];
if (confirm("Se sobreescribirá el contenido que estás editando con el de tu borrador. ¿Seguro que quieres hacer eso?")) {
$("#wikitext-editor").val(wikitext);
$("#wikitext-editor")[0].dispatchEvent(new Event('input', { bubbles: true }));
}
} else {
return alert("No tienes borradores guardados para este artículo");
}
});
}
// https://stackoverflow.com/questions/11076975/how-to-insert-text-into-the-textarea-at-the-current-cursor-position
function typeInTextarea(newText, el) {
const start = el.selectionStart;
const end = el.selectionEnd;
el.setRangeText(newText, start, end, 'select');
el.dispatchEvent(new Event('input', { bubbles: true }));
}
function signBtn() {
typeInTextarea(" \~\~\~\~", $("#wikitext-editor")[0]);
}
function draftsHook() {
if ($(".overlay-header.save-header.hideable.hidden").length && !$("#saveDraft").length) { installDrafts(); }
setTimeout(draftsHook, 500);
}
setTimeout(draftsHook, 500);
function installCookies() {
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://inciclopedia.statuspage.io/embed/script.js";
$("body").append(s);
var s2 = document.createElement("script");
s2.type = "text/javascript";
s2.src = "https://www.googletagmanager.com/gtag/js?id=G-DYPTG8PW3E";
$("head").append(s2);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-DYPTG8PW3E');
}
if (document.cookie.match(/^(.*;)?\s*cookie_notice\s*=\s*1+(.*)?$/)) {
installCookies();
}
/*
-------------------------------------
CSS Y JS PERSONALIZADO DE LAS PÁGINAS
-------------------------------------
Para añadir .js o .css específico para una página.
Véase [[Mediawiki:Inciskin]] para más información
*/
// Si se trata de una subpágina primero buscamos el CSS y JS de la página padre
if (mw.config.get('wgPageName') && (mw.config.get('wgAction') == 'view' || mw.config.get('wgAction') == 'edit') && document.location.href.indexOf('diff=') == -1)
{
if (mw.config.get('wgPageName').indexOf("/") != -1) {
var pagina = mw.config.get('wgPageName').slice(0, mw.config.get('wgPageName').indexOf("/"));
importStylesheetPage('MediaWiki:InciskinMobile/CSS/' + pagina + '.css', 'inciclopedia');
importStylesheetPage('MediaWiki:InciskinMobile/' + mw.config.get('skin') + '/' + pagina + '.css', 'inciclopedia');
importScriptPage('MediaWiki:InciskinMobile/JS/' + pagina + '.js', 'inciclopedia');
importScriptPage('MediaWiki:InciskinMobile/' + mw.config.get('skin') + '/' + pagina + '.js', 'inciclopedia');
};
importStylesheetPage('MediaWiki:InciskinMobile/CSS/' + mw.config.get('wgPageName') + '.css', 'inciclopedia');
importStylesheetPage('MediaWiki:InciskinMobile/' + mw.config.get('skin') + '/' + mw.config.get('wgPageName') + '.css', 'inciclopedia');
importScriptPage('MediaWiki:InciskinMobile/JS/' + mw.config.get('wgPageName') + '.js', 'inciclopedia');
importScriptPage('MediaWiki:InciskinMobile/' + mw.config.get('skin') + '/' + mw.config.get('wgPageName') + '.js', 'inciclopedia');
};
// Plantilla:Aleatorio
$(".bloquealeatorio").each(function (idx, it) {
const items = $(it).children();
items.each(function (idx, it) {
$(it).hide();
})
const result = Math.floor(Math.random() * items.length);
$(items[result]).show();
});
// Cookie warning...
/*! cookie-notice-js v1.2.2 by Alessandro Benoit 2022-02-23 */
/*! cookie-notice-js v1.2.2 by Alessandro Benoit 2022-02-23 */
!function(){"use strict";var h,v={messageLocales:{it:"Utilizziamo i cookie per essere sicuri che tu possa avere la migliore esperienza sul nostro sito. Se continui ad utilizzare questo sito assumiamo che tu ne sia felice.",en:"We use cookies to make sure you can have the best experience on our website. If you continue to use this site we assume that you will be happy with it.",de:"Wir verwenden Cookies um sicherzustellen dass Sie das beste Erlebnis auf unserer Website haben.",oc:"Utilizam de cookies per vos provesir la melhora experiéncia possibla sus nòstre site web. Se contunhatz d'utilizar aqueste site web considerarem que sètz d'acòrdi amb aquò.",fr:"Nous utilisons des cookies afin d'être sûr que vous pouvez avoir la meilleure expérience sur notre site. Si vous continuez à utiliser ce site, nous supposons que vous acceptez.",hu:"Sütiket használunk a honlapunkkon a legjobb felhasználói élmény érdekében. Ha tovább használja a weblapot, akkor úgy vesszük, hogy egyetért."},cookieNoticePosition:"bottom",learnMoreLinkEnabled:!1,learnMoreLinkHref:"/cookie-banner-information.html",learnMoreLinkText:{it:"Saperne di più",en:"Learn more",de:"Mehr erfahren",oc:"Ne saber mai",fr:"En savoir plus",hu:"Tudjon meg többet"},buttonLocales:{en:"Ok",oc:"D'acòrdi",hu:"Oké"},expiresIn:30,buttonBgColor:"#d35400",buttonTextColor:"#fff",noticeBgColor:"#000",noticeTextColor:"#fff",linkColor:"#009fdd"};function g(e){var o=(document.documentElement.lang||navigator.language||navigator.userLanguage).substr(0,2);return e[o]?e[o]:e.en}document.addEventListener("DOMContentLoaded",function(){h||new cookieNoticeJS}),window.cookieNoticeJS=function(){if(void 0===h&&(h=this,document.cookie="testCookie=1",-1!=document.cookie.indexOf("testCookie")&&-1==document.cookie.indexOf("cookie_notice"))){var e,o,t,n,i,r,a=function e(o,t){var n;for(n in t)t.hasOwnProperty(n)&&("object"==typeof o[n]?o[n]=e(o[n],t[n]):o[n]=t[n]);return o}(v,arguments[0]||{}),s=function(e,o,t,n){var i=document.createElement("div"),r=i.style;i.innerHTML=e+" ",i.setAttribute("id","cookieNotice"),r.position="fixed","top"===n?r.top="0":r.bottom="0";return r.left="0",r.right="0",r.background=o,r.color=t,r["z-index"]="999",r.padding="10px 5px",r["text-align"]="center",r["font-size"]="12px",r["line-height"]="28px",r.fontFamily="Helvetica neue, Helvetica, sans-serif",i}(g(a.messageLocales),a.noticeBgColor,a.noticeTextColor,a.cookieNoticePosition);if(a.learnMoreLinkEnabled){var c=g(a.learnMoreLinkText);o=c,t=a.learnMoreLinkHref,n=a.linkColor,i=document.createElement("a"),r=i.style,i.href=t,i.textContent=o,i.target="_blank",i.className="learn-more",r.color=n,r["text-decoration"]="none",r.display="inline",e=i}var l,u,d,p,m,k=g(a.buttonLocales),f=(l=k,u=a.buttonBgColor,d=a.buttonTextColor,p=document.createElement("a"),m=p.style,p.href="#",p.innerHTML=l,p.className="confirm",m.background=u,m.color=d,m["text-decoration"]="none",m.display="inline-block",m.padding="0 15px",m.margin="0 0 0 10px",p);f.addEventListener("click",function(e){installCookies();var o,t,n,i;e.preventDefault(),o=60*parseInt(a.expiresIn+"",10)*1e3*60*24,t=new Date,(n=new Date).setTime(t.getTime()+o),document.cookie="cookie_notice=1; expires="+n.toUTCString()+"; path=/;",(i=s).style.opacity=1,function e(){(i.style.opacity-=.1)<.01?i.parentNode.removeChild(i):setTimeout(e,40)}()});var b=document.body.appendChild(s);e&&b.appendChild(e),b.appendChild(f)}}}();
new cookieNoticeJS({
'cookieNoticePosition': 'top',
'expiresIn': 180,
// Localizations of the notice message
'messageLocales': {
'es': 'Usamos cookies y Google Analytics para mejorar tu experiencia en Inciclopedia. Si continúas en Inciclopedia, consientes el uso de cookies.'
},
// Localizations of the dismiss button text
'buttonLocales': {
'es': 'OK'
},
// Shows the "learn more button (default=false)
'learnMoreLinkEnabled':true,
// The href of the learn more link must be applied if (learnMoreLinkEnabled=true)
'learnMoreLinkHref':'https://inciclopedia.org/wiki/Inciclopedia:Pol%C3%ADtica_de_privacidad',
// Text for optional learn more button
'learnMoreLinkText':{
'es':'Saber más'
},
// Dismiss button background color
'buttonBgColor': '#447ff5',
// Dismiss button text color
'buttonTextColor': '#fff',
// Notice background color
'noticeBgColor': '#f6f6f6',
// Notice text color
'noticeTextColor': '#000000',
// the lernMoreLink color (default='#009fdd')
'linkColor':'#447ff5'
});