Diferencia entre revisiones de «MediaWiki:Monobook.js»

De Inciclopedia
Ir a la navegación Ir a la búsqueda
mSin resumen de edición
Sin resumen de edición
Línea 1: Línea 1:
 
/* JavaScript para la piel Monobook solamente
 
/* JavaScript para la piel Monobook solamente
  +
*/
   
  +
/* -----------------
  +
ADAPTACIÓN A VECTOR
  +
--------------------*/
  +
  +
InciAPI.AnadirPestana = function(texto){
  +
/* InciAPI.AnadirPestana (texto)
  +
Añade una nueva pestaña en "Articulo, discusión, etc.."
  +
*/
  +
var Pestana = InciAPI.AnadirHijo(
  +
InciAPI.ObtenerElemento("p-cactions").getElementsByTagName("ul")[0],
  +
"li")
  +
Pestana.innerHTML = texto;
  +
return Pestana;
  +
}
  +
  +
  +
/*
  +
Pestañas añadidas
  +
*/
  +
addOnloadHook( function(){
  +
  +
// "Compartir"
  +
InciAPI.AnadirPestana('<span class="textovisible" style="display: inline; position: relative;">' +
  +
'<span class="textooculto" style="border: none; padding: 0; margin: 0; top: 0;"><ul>' +
  +
'<li><a href="http://www.facebook.com/sharer.php?u=' + wgServer + '/wiki/' + wgPageName + '?t=' + wgPageName + '">Facebook</a></li>' +
  +
'<li><a href="http://twitter.com/home?status=' + wgServer + '/wiki/' + wgPageName + '%20' + wgPageName + '">Twitter</a></li>' +
  +
'<li><a href="http://digg.com/submit?url=' + wgServer + '/wiki/' + wgPageName + '&title=' + wgPageName + '">Digg</a></li>' +
  +
'<li><a href="http://www.stumbleupon.com/submit?url=' + wgServer + '/wiki/' + wgPageName + '&title=' + wgPageName + '">Stumbleupon</a></li>' +
  +
'<li><a href="http://www.technorati.com/faves/?add=' + wgServer + '/wiki/' + wgPageName + '">Technorati</a></li>' +
  +
'<li><a href="http://slashdot.org/bookmark.pl?url=' + wgServer + '/wiki/' + wgPageName + '&title=' + wgPageName + '">Slashdot</a></li>' +
  +
'<li><a href="http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=' + wgServer + '/wiki/' + wgPageName + '&t=' + wgPageName + '">MySpace</a></li>' +
  +
'</ul></span><a rel="nofollow" id="ca-share_feature" href="#">Compartir</a></span>');
  +
});
  +
  +
  +
/*
 
--------------------------------
 
--------------------------------
 
SISTEMA DE VOTACIÓN DE ARTÍCULOS
 
SISTEMA DE VOTACIÓN DE ARTÍCULOS

Revisión del 20:46 9 jun 2010

/* JavaScript para la piel Monobook solamente 
*/

/* -----------------
 ADAPTACIÓN A VECTOR
--------------------*/

InciAPI.AnadirPestana = function(texto){
  /* InciAPI.AnadirPestana (texto)
  Añade una nueva pestaña en "Articulo, discusión, etc.."
  */ 
  var Pestana = InciAPI.AnadirHijo(
    InciAPI.ObtenerElemento("p-cactions").getElementsByTagName("ul")[0],
    "li")  
  Pestana.innerHTML = texto;
  return Pestana;
}


/* 
  Pestañas añadidas
*/
addOnloadHook( function(){

  // "Compartir"
  InciAPI.AnadirPestana('<span class="textovisible" style="display: inline; position: relative;">' +
    '<span class="textooculto" style="border: none; padding: 0; margin: 0; top: 0;"><ul>' +
    '<li><a href="http://www.facebook.com/sharer.php?u=' + wgServer + '/wiki/' + wgPageName + '?t=' + wgPageName + '">Facebook</a></li>' +
    '<li><a href="http://twitter.com/home?status=' + wgServer + '/wiki/' + wgPageName + '%20' + wgPageName + '">Twitter</a></li>' +
    '<li><a href="http://digg.com/submit?url=' + wgServer + '/wiki/' + wgPageName + '&title=' + wgPageName + '">Digg</a></li>' +
    '<li><a href="http://www.stumbleupon.com/submit?url=' + wgServer + '/wiki/' + wgPageName + '&title=' + wgPageName + '">Stumbleupon</a></li>' +
    '<li><a href="http://www.technorati.com/faves/?add=' + wgServer + '/wiki/' + wgPageName + '">Technorati</a></li>' +
    '<li><a href="http://slashdot.org/bookmark.pl?url=' + wgServer + '/wiki/' + wgPageName + '&title=' + wgPageName + '">Slashdot</a></li>' +
    '<li><a href="http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=' + wgServer + '/wiki/' + wgPageName + '&t=' + wgPageName + '">MySpace</a></li>' +
    '</ul></span><a rel="nofollow" id="ca-share_feature" href="#">Compartir</a></span>');
});


/*
--------------------------------
SISTEMA DE VOTACIÓN DE ARTÍCULOS
--------------------------------
Traído de Uncyclopedia

 ** Voting *******************************
 * By [[User:Spang|Spang]]
 * Voting system
 * Add "ratings.disabled = true" without the quotes to your JS to disable
 *
<pre><nowiki>*/

 //<nowiki>
ratings = new Object();
ratings.getCallback = {
   success : function(o) {
      var j = YAHOO.tools.JSONParse(o.responseText);
      try {
         with(j.query.wkvoteart[wgArticleId]) {
            if(typeof votesavg != undefined && votesavg) {
               ratings.avgVote = (5 >= votesavg >= 1 ? Math.round(votesavg * 10) / 10 : 5);
               ratings.text[0] = ('Puntuación media: ' + ratings.avgVote)}
            if(typeof(uservote) != 'undefined' && uservote) {
               ratings.myVote = uservote;
               ratings.hasVoted = true}
            else {
               ratings.hasVoted = false}
            ratings.paint(0)}
         }
      catch(e) {
         }
      }
   , failure : function(o) {
      ratings.out('Fallo de conexión')}
   };
ratings.vote = function(a) {
   if(wgUserName == null) {
      window.location = '/wiki/Special:Userlogin?returnto=' + wgPageName;
      return}
   var b = (ratings.hasVoted == true ? 'update':'insert');
   ratings.get = YAHOO.util.Connect.asyncRequest('GET', '/api.php?format=json&action=' + b + '&list=wkvoteart&wkuservote=1&wkctime=5&wkpage=' + wgArticleId + '&wkvote=' + a, ratings.voteCallback, null);
   ratings.myVote = a;
   ratings.paint(a, 'Espera un mes...');
   ratings.votingInProgress = true};
ratings.voteCallback = {
   success : function(o) {
      var j = YAHOO.tools.JSONParse(o.responseText);
      if(j.item.wkvoteart[3] != undefined && ratings.retried != true) {
         ratings.retried = true;
         ratings.out('ERROR, no se pudo votar...');
         ratings.get = YAHOO.util.Connect.asyncRequest('GET', '/api.php?format=json&action=delete&list=wkvoteart&wkpage=' + wgArticleId, ratings.retry, null);
         return};
      try {
         with(j.item.wkvoteart[0] == undefined ? j.item.wkvoteart : j.item.wkvoteart[0]) {
            ratings.hasVoted = true;
            ratings.myVote = vote;
            ratings.avgVote = Math.round(avgvote * 10) / 10;
            if(ratings.avgVote > 5)ratings.avgVote = 5}
         }
      catch(e) {
         ratings.out('Error: ' + e);
         ratings.votingInProgress = false;
         return}
      ratings.votingInProgress = false;
      ratings.out('¡Gracias por votar!');
      ratings.text[0] = ('Puntuación media: ' + ratings.avgVote);
      ratings.timeout = setTimeout('ratings.paint(0)', 1000)}
   , failure : function(o) {
      ratings.votingInProgress = false;
      ratings.out('Fallo de conexión :(')}
   };
ratings.retry = {
   success : function(o) {
      ratings.get = YAHOO.util.Connect.asyncRequest('GET', '/api.php?format=json&action=insert&list=wkvoteart&wkuservote=1&wkctime=5&wkpage=' + wgArticleId + '&wkvote=' + ratings.myVote, ratings.voteCallback, null)}
   , failure : function(o) {
      ratings.out('error')}
   };
ratings.out = function(m) {
   document.getElementById('ratingMsg').innerHTML = m};
ratings.paint = function(n, m) {
   if(ratings.votingInProgress == true)return;
   YAHOO.util.Dom.setStyle(['vote-1', 'vote-2', 'vote-3', 'vote-4', 'vote-5'], 'backgroundPosition', '0 0');
   for(var l = 1; l <= n; l++) {
      YAHOO.util.Dom.setStyle('vote-' + l, 'backgroundPosition', '0 -34px')}
   if(n === 0 && (ratings.myVote != false || ratings.avgVote != undefined)) {
      var a = ratings.hasVoted == true ? '0 -34px':'0 -17px';
      var b = ratings.hasVoted != false ? ratings.myVote : ratings.avgVote;
      for(var l = 1; l <= b; l++) {
         YAHOO.util.Dom.setStyle('vote-' + l, 'backgroundPosition', a)}
      if(l - ratings.avgVote < 1 && l <= 5 && ratings.hasVoted != true) {
         var p = ratings.avgVote - (l - 1);
         var q = 0;
         switch(true) {
            case 0 < p && p <= .2 : q = '-51px';
            break;
            case.2 < p && p <= .4 : q = '-68px';
            break;
            case.4 < p && p <= .6 : q = '-85px';
            break;
            case.6 < p && p <= .8 : q = '-102px';
            break;
            case.8 < p && p < 1 : q = '-119px';
            break;
            default : };
         document.getElementById('vote-' + l).style.backgroundPosition = '0px ' + q}
      };
   if(wgUserName == null && n != 0)ratings.out('Los no registrados, no votan');
   else if(m == undefined)ratings.out(ratings.text[n]);
   else ratings.out(m)};
ratings.setup = function() {
   if(wgIsArticle == false || ratings.disabled == true)return;
   var a = document.getElementById('p-search');
   if(!a)return false;
   ratings.p = document.createElement('div');
   ratings.p.innerHTML = '<h5>Puntuación</h5><div id="ratingBody" class="pBody"><div><ul id="ratingStars" onmouseout="ratings.paint(0);"><li id="vote-1" class="voteStar" onmouseover="ratings.paint(1)" onclick="ratings.vote(1);">&nbsp;1</li><li id="vote-2" class="voteStar" onmouseover="ratings.paint(2)" onclick="ratings.vote(2);"> 2</li><li id="vote-3" class="voteStar" onmouseover="ratings.paint(3)" onclick="ratings.vote(3);"> 3</li><li id="vote-4" class="voteStar" onmouseover="ratings.paint(4)" onclick="ratings.vote(4);"> 4</li><li id="vote-5" class="voteStar" onmouseover="ratings.paint(5)" onclick="ratings.vote(5);"> 5&nbsp;</li></ul></div><span id="ratingMsg">¡Puntúa este artículo!</span></div>';
   ratings.p.className = 'portlet';
   ratings.p.id = 'p-rating';
   document.getElementById('column-one').insertBefore(ratings.p, a);
   ratings.text = new Array('¡Puntúa este artículo!', 'Caca',
    'Ni fu, ni fa', 'Legible', 'Muy bueno', '¡Nobel!');
   ratings.get = YAHOO.util.Connect.asyncRequest('GET', '/api.php?format=json&action=query&list=wkvoteart&wkuservote=1&wkctime=5&wkpage=' + wgArticleId, ratings.getCallback, null)};
YAHOO.util.Event.onContentReady('column-one', ratings.setup); 
/*</nowiki></pre>*/