Jump to content

User:Topaz/beta.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
topaz.wputil.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];
  topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit",
      "wpEdittime="+edittime+
      "&wpEditToken="+topaz.util.fullescape(edittoken)+
      "&wpTextbox1="+escape(content)+
      "&wpSummary="+escape(summary)+
      (watch?"&wpWatchthis=on":"")+
      "&wpSection=&wpSave=Save+page",
      {"Content-Type":"application/x-www-form-urlencoded"});
};

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);
  document.getElementsByTagName("html")[0].innerHTML = req.responseText;
  return req;
};
*/


/*
topaz.usermessagewatcher = new Object();

topaz.usermessagewatcher.oldonload = window.onload;
window.onload = function() {
  if (typeof topaz.usermessagewatcher.oldonload == "function") topaz.usermessagewatcher.oldonload();
  topaz.usermessagewatcher.notifying = false;
  topaz.util.cookie.set("topaz.usermessagewatcher.lastcheck", topaz.util.time());
  var divlist = topaz.util.getobj("bodyContent").getElementsByTagName("div");
  if (divlist[1] && divlist[1].className=="usermessage" ||
      divlist[2] && divlist[0].className=="tz-primarySection" && divlist[2].className=="usermessage") {
    topaz.usermessagewatcher.setnotify(1);
  } else {
    topaz.usermessagewatcher.setnotify(0);
  }
};

topaz.usermessagewatcher.setnofity = function(enabled) {
  if (enabled == topaz.usermessagewatcher.notifying) return;
  topaz.usermessagewatcher.notifying = enabled;
  topaz.util.cookie.set("topaz.usermessagewatcher.hasnew", enabled);
  if (enabled) {
    alert("topaz.usermessagewatcher: new messages");
  } else {
    alert("topaz.usermessagewatcher: NO new messages");
  }
};

topaz.usermessagewatcher.update = function() {

};

setInterval("topaz.usermessagewatcher.update()", 5000);


var req = topaz.util.xmlhttpreq();
req.open("GET", "http://en.wikipedia.org/wiki/MediaWiki:Blank", true);
req.onreadystatechange = function() {
  if (req.readyState != 4) return;
  if (req.responseText.indexOf('<div class="usermessage">You have')!=-1) {
    //alert("new messages!");
  } else {
    //alert("zero new");
  }
};
req.send(null);
*/