Web Analytics Made Easy - Statcounter

[HOME PAGE] [STORES] [CLASSICISTRANIERI.COM] [FOTO] [YOUTUBE CHANNEL]

Usuari:Pasqual/scripts/topaz.js - Viquip??dia

Usuari:Pasqual/scripts/topaz.js

De Viquip??dia

Nota: Despr??s de desar, heu de posar al dia la mem??ria cau del vostre navegador per veure els canvis.

  • Mozilla/Firefox/Safari: Premeu Shift mentre cliqueu "Actualitza" (Reload), o premeu Ctrl+Shift+R (Cmd+Shift+R en un Mac Apple);
  • Internet Explorer: premeu Ctrl mentre cliqueu "Actualitza" (Refresh), o premeu Ctrl+F5;
  • Konqueror: simplement cliqueu el bot?? "Recarregar" (Reload), o premeu F5;
  • Opera: haureu d'esborrar completament la vostra mem??ria cau (cach??) a Tools???Preferences.
/*
<pre><nowiki>
Reuneix els m??duls de'n [[w:en:User:Topaz|Topaz]] seg??ents:
*[[w:en:User:Topaz/init.js]]
*[[w:en:User:Topaz/util.js]]
*[[w:en:User:Topaz/comm.js]]
*[[w:en:User:Topaz/wputil.js]]
*[[w:en:User:Topaz/statuschanger.js]]
Funcions emprades a [[w:ca:Usuari:Pasqual/scripts/commutadordestat.js]].
 
 
??NDEX:
topaz.util
 .getobj
 .add
 .add2
 .mousebtnmap
 .xmlhttpreq
 .cookie
topaz.com
 .doreq
topaz.wputil
 .username
 .iseditpage
 .pagename
 .setpagecontent
 .getpagecontent
 .getserverpagecontent
 .addpagecontent
*/
 
var topaz = new Object();
 
/****************************************  topaz.util  ****************************************/
 
topaz.util = {
getobj:function(id) {
  return document.getElementById ?
             document.getElementById(id) :
             document.all[id];
},
add:function(parent, tag, attr) {
  var el = document.createElement(tag);
  if (attr) {
    for (key in attr) {
      el[key] = attr[key];
    }
  }
  return parent.appendChild(el);
},
add2:function(parent, el0, tag, attr) {
  var el = document.createElement(tag);
  if (attr) {
    for (key in attr) {
      el[key] = attr[key];
    }
  }
  return parent.insertBefore(el, el0);
},
mousebtnmap:{
  ns:[null,1,3,2],
  ie:[null,1,2,null,3]
},
xmlhttpreq:function() {
  if (window.XMLHttpRequest) {
    xmlhttpobj = new XMLHttpRequest()
  } else {
    try {
      xmlhttpobj = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttpobj = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        xmlhttpobj = null;
      }
    }
  }
  return xmlhttpobj;
},
cookie:{
  noexpire:(function(){
    var d = new Date();
    d.setTime(d.getTime()+(365*24*60*60*1000));
    return d.toGMTString();
  })(),
 
  expire:(function(){
    var d = new Date();
    d.setTime(d.getTime()-1);
    return d.toGMTString();
  })(),
 
  get:function(name) {
    name += "-"+wgUserName;
    var cl = document.cookie.split(/;\s*/);
    for (var i=0; i<cl.length; i++) {
      var curc = cl[i].split(/\=/);
      if (curc[0] == name) {
        return(curc[1]);
      }
    }
    return null;
  },
 
  set:function(name, value) {
    name += "-"+wgUserName;
    document.cookie = name + "=" + escape(value) +
        "; expires=" + topaz.util.cookie.noexpire +
        "; path=/";
  },
 
  del:function(name) {
    name += "-"+wgUserName
    document.cookie = name+"=; expires="+topaz.util.coookie.expire+"; path=/";
  }
}
};
 
 
/*****************************************  topaz.comm  *****************************************/
 
topaz.comm = {
doreq:function(url,postdata,headers) {
  var req = topaz.util.xmlhttpreq();
  req.open(postdata?"POST":"GET", url, false);
  for(header in headers) {
    req.setRequestHeader(header,headers[header]);
  }
  req.send(postdata||null);
  return req;
}
};
 
 
/****************************************  topaz.wputil  ****************************************/
 
topaz.wputil = {
username:function() {
  return wgUserName
  //abans: topaz.util.getobj("pt-userpage").childNodes[0].childNodes[0].nodeValue;
},
iseditpage:function() {
  return document.title.indexOf("Editing ")==0;
},
pagename:function() {
  var iseditpage = topaz.wputil.iseditpage();
  return document.title.substr(iseditpage?8:0,document.title.indexOf(" - ")-(iseditpage?8:0));
},
addsidepanel:function(id,label) {
  var div = topaz.util.add(topaz.util.getobj("column-one"), "div", {className:"portlet",id:id});
  topaz.util.add(div, "H5").innerHTML = label;
  topaz.util.add(topaz.util.add(div, "div", {className:"pBody"}), "ul");
},
addsidepanelbutton:function(id,label,targhref) {
  var li = topaz.util.add((topaz.util.getobj(id).getElementsByTagName("ul"))[0],"li");
  with(topaz.util.add(li,"a")) {
    innerHTML = label;
    href = targhref;
  }
  return li;
},
addsidepanelbutton2:function(id,label,targhref) {
  var li = topaz.util.add2((topaz.util.getobj(id).getElementsByTagName("ul"))[0],((topaz.util.getobj(id).getElementsByTagName("ul"))[0].getElementsByTagName("li"))[0],"li");
  with(topaz.util.add(li,"a")) {
    innerHTML = label;
    href = targhref;
  }
  return li;
},
setpagecontent:function(pagename,content,summary,watch) {
  var prelimresp = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit");
  var edittime = prelimresp.responseText.match(/\<input type='hidden' value="(\d+)" name="wpEdittime" \/\>/)[1];
  var edittoken = prelimresp.responseText.match(/\<input type='hidden' value="([^"]+)" name="wpEditToken" \/\>/)[1];
  content = content.replace(/\&lt\;/gi, "<");
  content = content.replace(/\&gt\;/gi, ">");
  content = content.replace(/\&quot\;/gi, "\"");
  content = content.replace(/\&amp\;/gi, "%26");
  content = content.replace(/\&mdash\;/gi, "???");
  content = content.replace(/\&ndash\;/gi, "-");
  content = content.replace(/\&/gi, "%26");
  content = content.replace(/\%20\;/gi, "%20");
  content = content.replace(/\+/gi, "%2B")
  topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit",
      "wpEdittime="+edittime+
      "&wpEditToken="+escape(edittoken).replace(/\+/g,"%2B")+
      "&wpTextbox1="+content+
      "&wpSummary="+summary+
      (watch?"&wpWatchthis=on":"")+
      "&wpSection=&wpSave=Save+page",
      {"Content-Type":"application/x-www-form-urlencoded"});
},
getpagecontent:function (pagename) {
  var req = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=edit");
  var content = req.responseText.match(/\<textarea[\w\W]*?\>([\w\W]*?)\<\/textarea\>/)[1];
  content = content.replace(/\&lt\;/gi, "<");
  content = content.replace(/\&gt\;/gi, ">");
  content = content.replace(/\&quot\;/gi, "\"");
  content = content.replace(/\&amp\;/gi, "%26");
  content = content.replace(/\&mdash\;/gi, "???");
  content = content.replace(/\&ndash\;/gi, "-");
  content = content.replace(/\&/gi, "%26");
  content = content.replace(/\%20\;/gi, "%20");
  content = content.replace(/\+/gi, "%2B")
  return content;
},
getpagecontentserver:function (server, pagename) {
  var req = topaz.comm.doreq(server + "/w/index.php?title="+pagename+"&action=edit");
  var content = req.responseText.match(/\<textarea[\w\W]*?\>([\w\W]*?)\<\/textarea\>/)[1];
  content = content.replace(/\&lt\;/gi, "<");
  content = content.replace(/\&gt\;/gi, ">");
  content = content.replace(/\&quot\;/gi, "\"");
  content = content.replace(/\&amp\;/gi, "%26");
  content = content.replace(/\&mdash\;/gi, "???");
  content = content.replace(/\&ndash\;/gi, "-");
  content = content.replace(/\&/gi, "%26");
  content = content.replace(/\%20\;/gi, "%20");
  content = content.replace(/\+/gi, "%2B")
  return content;
},
addpagecontent:function(pagename,addContent,summary,watch) {
  var newContent = '';
  var prelimresp = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit");
  var edittime = prelimresp.responseText.match(/\<input type='hidden' value="(\d+)" name="wpEdittime" \/\>/)[1];
  var edittoken = prelimresp.responseText.match(/\<input type='hidden' value="([^"]+)" name="wpEditToken" \/\>/)[1];
  var req = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=edit");
  var oldContent = req.responseText.match(/\<textarea[\w\W]*?\>([\w\W]*?)\<\/textarea\>/)[1];
  oldContent = oldContent.replace(/\&lt\;/gi, "<");
  oldContent = oldContent.replace(/\&gt\;/gi, ">");
  oldContent = oldContent.replace(/\&quot\;/gi, "\"");
  oldContent = oldContent.replace(/\&amp\;/gi, "%26");
  oldContent = oldContent.replace(/\&mdash\;/gi, "???");
  oldContent = oldContent.replace(/\&ndash\;/gi, "-");
  oldContent = oldContent.replace(/\&/gi, "%26");
  oldContent = oldContent.replace(/\%20\;/gi, "%20");
  oldContent = oldContent.replace(/\+/gi, "%2B")
 
  addContent = addContent.replace(/\&lt\;/gi, "<");
  addContent = addContent.replace(/\&gt\;/gi, ">");
  addContent = addContent.replace(/\&quot\;/gi, "\"");
  addContent = addContent.replace(/\&amp\;/gi, "%26");
  addContent = addContent.replace(/\&mdash\;/gi, "???");
  addContent = addContent.replace(/\&ndash\;/gi, "-");
  addContent = addContent.replace(/\&/gi, "%26");
  addContent = addContent.replace(/\%20\;/gi, "%20");
  addContent = addContent.replace(/\+/gi, "%2B")
 
  newContent = oldContent + addContent;
 
  topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit",
      "wpEdittime="+edittime+
      "&wpEditToken="+escape(edittoken).replace(/\+/g,"%2B")+
      "&wpTextbox1="+ newContent +
      "&wpSummary="+ summary +
      (watch?"&wpWatchthis=on":"")+
      "&wpSection=&wpSave=Save+page",
      {"Content-Type":"application/x-www-form-urlencoded"});
},
readpagecontent:function (pagename) {
  var req = topaz.comm.doreq("/w/index.php?title="+pagename);
  var content = req.responseText.match(/\<textarea[\w\W]*?\>([\w\W]*?)\<\/textarea\>/)[1];
  content = content.replace(/\&lt\;/gi, "<");
  content = content.replace(/\&gt\;/gi, ">");
  content = content.replace(/\&quot\;/gi, "\"");
  content = content.replace(/\&amp\;/gi, "%26");
  content = content.replace(/\&mdash\;/gi, "???");
  content = content.replace(/\&ndash\;/gi, "-");
  content = content.replace(/\&/gi, "%26");
  content = content.replace(/\%20\;/gi, "%20");
  content = content.replace(/\+/gi, "%2B")
  return content;
},
getspecialpagecontent:function (pagename) {
  var req = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=raw");
  var content = req.responseText.match(/\<ol start=\'\d\d?\' class=\'special\'\>([\w\W]*?)\<\/ol\>/)[1];
  content = content.replace(/\&lt\;/gi, "<");
  content = content.replace(/\&gt\;/gi, ">");
  content = content.replace(/\&quot\;/gi, "\"");
  content = content.replace(/\&amp\;/gi, "%26");
  content = content.replace(/\&mdash\;/gi, "???");
  content = content.replace(/\&ndash\;/gi, "-");
  content = content.replace(/\&/gi, "%26");
  content = content.replace(/\%20\;/gi, "%20");
  content = content.replace(/\+/gi, "%2B")
  return content;
}
};
 
 
/*
</nowiki>
</pre>
*/