Utente:Genuzzo/monobook.js: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 164: Riga 164:
else {
else {
$('#comparautenti').html($('#utenteuno').val() + ': ' + editcol.html());
$('#comparautenti').html($('#utenteuno').val() + ': ' + editcol.html());
window.utenteuno = parseInt(editcol.val().replace('.', ''));
window.utenteuno = parseInt(editcol.html().replace('.', ''));
$.get('/wiki/Speciale:Editcount/' + $('#utentedue').val(), function(data) {
$.get('/wiki/Speciale:Editcount/' + $('#utentedue').val(), function(data) {
var div = $(data.split(' skin-monobook without-adsense">')[1].split('</body>')[0]);
var div = $(data.split(' skin-monobook without-adsense">')[1].split('</body>')[0]);
Riga 170: Riga 170:
if(editcol.length != 1) $('#comparautenti').html('Utente 2 non valido!');
if(editcol.length != 1) $('#comparautenti').html('Utente 2 non valido!');
else {
else {
$('#comparautenti').html($('#comparautenti').html() + '<br>' + $('#utentedue').val() + ': ' + editcol.html() + '<br>' + 'Differenza di contributi: ' + Math.abs((parseInt(editcol.val().replace('.', ''))) - utenteuno));
$('#comparautenti').html($('#comparautenti').html() + '<br>' + $('#utentedue').val() + ': ' + editcol.html() + '<br>' + 'Differenza di contributi: ' + Math.abs((parseInt(editcol.html().replace('.', ''))) - utenteuno));
}
}
});
});

Versione delle 00:45, 26 dic 2011

/* function initSnake() {
   w = window;
   w.immaginePapocchio = document.createElement('img');
   immaginePapocchio.src = 'http://images4.wikia.nocookie.net/__cb20111220151347/nonciclopedia/images/9/9f/Papocchio_piccolo_29x25.png';
   $(document.body).append(immaginePapocchio);
   w.snake = new Array();
   w.dir = 'down';
   for(i = 0; i < 3; i++) snake[i] = new Array(0, i);
   if($('#canvassneic').length) {
document.onkeydown = function(event) {
   var keyCode; 
 
   if(event == null) {
     keyCode = window.event.keyCode; 
   }
   else  {
     keyCode = event.keyCode; 
   }
 
   switch(keyCode) {
    case 37:
      dir = 'left';
      break; 

    case 38:
      dir = 'up';
      break; 

    case 39:
      dir = 'right';
      break; 

    case 40:
      dir = 'down';
      break; 

    default: 
      break; 
  } 
}
      w.canvassneic = document.createElement('canvas');
      $('#canvassneic').html('').append(canvassneic);
      immaginePapocchio.onload = function() {setInterval(drawSnake, 300);};
   }
}



function moveSnakePoint() {
   if(dir == 'up') snake[snake.length - 1][1]--;
   else if(dir == 'down') snake[snake.length - 1][1]++;
   else if(dir == 'right') snake[snake.length - 1][0]++;
   else snake[snake.length - 1][0]--; 
}

function moveSnake() {
   oldSnake = snake.slice(0);
   for(i = snake.length - 1; i != -1; i--) {
      snake[i - 1] = oldSnake[i].slice(0);
   }
   moveSnakePoint('down');
}

function drawSnake() {  
   if (canvassneic.getContext) {  
      moveSnake();
      var ctx = canvassneic.getContext("2d");
      ctx.fillStyle = "rgb(255,255,255)";
      ctx.fillRect(0, 0, 300, 150);
      for(s = 0; s < snake.length; s++) {
         ctx.drawImage(immaginePapocchio, snake[s][0] * 25, snake[s][1] * 29, 10, 10); 
      }
   }  
}


addOnloadHook(initSnake);

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+";path=/;";
}


addOnloadHook(function() {
  if(wgUserName) {
     $.getJSON('http://nonciclopedia.wikia.com/api.php?action=query&prop=revisions&titles=Nonciclopedia:Dismissablenotice&rvprop=content|timestamp&format=json', function(data) {
        $.each(data['query']['pages'], function(key, val) {
           w.timestamp = val['revisions'][0]['timestamp'];
           if(timestamp != getCookie('gendn')) {
              w.message = val['revisions'][0]['*'];
              if (message == '') message = 'undefined';
           }
           else w.message = 'undefined';
        });
        if(message != 'undefined') {
           $.get('http://nonciclopedia.wikia.com/index.php?title=Nonciclopedia:Dismissablenotice&action=render', function(data) {
              $('#contentSub').after($('<div class="usermessage" style="display: block;">' + data + ' <small><a href="javascript:createCookie(\'gendn\', timestamp, 1000); $(\'.usermessage\').remove(); void(0);">(Cliccami per cancellare il messaggio)</a></small></div>'));
           })
        }
     });
  }
});
*/


ignorati = Array();
ignorati[ignorati.length - 1] = 'Mestruolindo';

function hideIgnoratiInUM() {
   $('.mw-userlink').each(function() {
      for(var i in ignorati) {
         if($(this).attr('title') == 'Utente:' + ignorati[i]) {
           window.mwuserlinkcount = 0;
           $(this).parent().children().each(function() {
              if($(this).attr('class') == 'mw-userlink') mwuserlinkcount++;
           });
           if(mwuserlinkcount == 1) $(this).parent().parent().parent().hide();
           break;
         }
      }
   });
}

function showIgnoratiInUM() {
   $('.mw-userlink').each(function() {
      for(var i in ignorati) {
         if($(this).attr('title') == 'Utente:' + ignorati[i]) {
           window.mwuserlinkcount = 0;
           $(this).parent().children().each(function() {
              if($(this).attr('class') == 'mw-userlink') mwuserlinkcount++;
           });
           if(mwuserlinkcount == 1) $(this).parent().parent().parent().show();
           break;
         }
      }
   });
}

function toggleIgnoratiInUM() {
   $('.mw-userlink').each(function() {
      $(this).parent().parent().parent().toggle();
   });
}

function initHideUM() {
   if(wgPageName == 'Speciale:UltimeModifiche') $('.mw-rc-label-legend').append($('<br><a href="javascript:hideIgnoratiInUM();">Nascondi ignorati</a> - <a href="javascript:showIgnoratiInUM();">Mostra ignorati</a> - <a href="javascript:toggleIgnoratiInUM();">Inverti tutti</a>'));
}

addOnloadHook(initHideUM);

//Compare edits by Genuzzo

function compareEdits() {
   $.get('/wiki/Speciale:Editcount/' + $('#utenteuno').val(), function(data) {
      var div = $(data.split(' skin-monobook without-adsense">')[1].split('</body>')[0]);
      editcol = $('.TablePager > tbody > tr > .ecrowright:nth(2)', div);
      if(editcol.length != 1) $('#comparautenti').html('Utente 1 non valido!');
      else {
         $('#comparautenti').html($('#utenteuno').val() + ': ' + editcol.html());
         window.utenteuno = parseInt(editcol.html().replace('.', ''));
         $.get('/wiki/Speciale:Editcount/' + $('#utentedue').val(), function(data) {
            var div = $(data.split(' skin-monobook without-adsense">')[1].split('</body>')[0]);
            editcol = $('.TablePager > tbody > tr > .ecrowright:nth(2)', div);
            if(editcol.length != 1) $('#comparautenti').html('Utente 2 non valido!');
            else {
               $('#comparautenti').html($('#comparautenti').html() + '<br>' + $('#utentedue').val() + ': ' + editcol.html() + '<br>' + 'Differenza di contributi: ' + Math.abs((parseInt(editcol.html().replace('.', ''))) - utenteuno));
            }
         });
      }
   });
}

function editsCompareWindow() {
   $(document.body).append($('<div style="width: 300px; height: 200px; position: fixed; top: 30%; left: 30%; border: solid 5px #000; z-index: 99999; background-color: #DDD; padding: 5px;">Quali utenti vuoi confrontare?<br>Utente 1: <input type="text" id="utenteuno"></input><br>Utente 2: <input type="text" id="utentedue"></input><br><input type="button" value="COMPARA!!!1!!!" onclick="compareEdits();"><br><div id="comparautenti"></div><a href="javascript:$(this).parent().remove(); void(0);">Clicchete</a></div>'));
}

function createEditsButton() {
   var menuList = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
   var newLi = document.createElement('li');
   newLi.setAttribute('id', 'ca-edits');
   newLi.innerHTML = '<a href="javascript:editsCompareWindow();">EditsCompare</a>';
   menuList.appendChild(newLi);
}

addOnloadHook(createEditsButton);