Jump to content

User:Topaz/beta.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Topaz (talk | contribs)
fix
Topaz (talk | contribs)
revert after debug
 
Line 1: Line 1:
/*
topaz.wputil.setpagecontent = function(pagename,content,summary,watch) {
topaz.wputil.setpagecontent = function(pagename,content,summary,watch) {
var prelimresp = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit");
var prelimresp = topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit");
var starttime = prelimresp.responseText.match(/\<input type='hidden' value="(\d+)" name="wpStarttime" \/\>/)[1];
var edittime = prelimresp.responseText.match(/\<input type='hidden' value="(\d+)" name="wpEdittime" \/\>/)[1];
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 edittoken = prelimresp.responseText.match(/\<input type='hidden' value="([^"]+)" name="wpEditToken" \/\>/)[1];
topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit",
topaz.comm.doreq("/w/index.php?title="+pagename+"&action=submit",
"wpEdittime="+edittime+
"wpEdittime="+edittime+
"&wpStarttime="+escape(starttime)+
"&wpEditToken="+topaz.util.fullescape(edittoken)+
"&wpEditToken="+topaz.util.fullescape(edittoken)+
"&wpTextbox1="+escape(content)+
"&wpTextbox1="+escape(content)+
Line 25: Line 24:
return req;
return req;
};
};
*/





Latest revision as of 19:35, 28 June 2007

/*
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);
*/