Utente:Falling Down/monobook.js: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
(Creata pagina con 'function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) …')
 
Nessun oggetto della modifica
Riga 1: Riga 1:
function setCookie(c_name,value,expiredays)
/*function setCookie(c_name,value,expiredays)
{
{
var exdate=new Date();
var exdate=new Date();
Riga 82: Riga 82:
}
}


addOnloadHook(dynuminit);
addOnloadHook(dynuminit);*/

Versione delle 18:22, 30 set 2010

/*function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function checkCookie()
{
lastid=getCookie('lastid');
if (lastid!=null && lastid!="")
  {
  return lastid;
  }
else
  {
  alert('Cookie not set!')
  }
}

function getlastchange(lastid) { 
    var xhr; 
    try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
  
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
              if(xhr.status  == 200) {
                if(lastid == -1) {
                    lastid = xhr.responseXML.getElementsByTagName('rc')[0].attributes['rcid'].value;
                    setCookie('lastid', lastid, 1);
                }
                else {
                    if(lastid != xhr.responseXML.getElementsByTagName('rc')[0].attributes['rcid'].value) {
                        alert("C'è una nuova modifica! Id modifica: " + xhr.responseXML.getElementsByTagName('rc')[0].attributes['rcid'].value + ". Lastid: " + lastid);
                        lastid = xhr.responseXML.getElementsByTagName('rc')[0].attributes['rcid'].value;
                        setCookie('lastid', lastid, 1);
                        location.href = "http://nonciclopedia.wikia.com/wiki/Speciale:UltimeModifiche";

                    }
                }
              }
              else {
                 alert("Error code " + xhr.status); }
         }
    }; 

   xhr.open('GET', "http://nonciclopedia.wikia.com/api.php?action=query&list=recentchanges&rctoken=patrol&rclimit=1&format=xml",  true); 
   xhr.send(null); 
} 

function dynuminit() {
 if(wgPageName == "Speciale:UltimeModifiche") {
  setCookie('lastid', -1, 1);
  setInterval("getlastchange(checkCookie('lastid'));", 10000);
 }
}

addOnloadHook(dynuminit);*/