Jump to content

User:Minesweeper.007/currentstatus.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
// STATUS CHANGER
addOnloadHook(function (){
  var subpage = "/Status";
  var scheme = "/StatusTemplate";
  var subpagelink = wgServer + "/w/index.php?title=User:" + encodeURIComponent(wgUserName + subpage);
  var logout = document.getElementById( 'pt-logout' );
  //Add the links
  addPortletLink("p-personal", subpagelink + "&action=edit&newstatus=in", "In", "pt-status-in", "I'm in!", "", logout);
  addPortletLink("p-personal", subpagelink + "&action=edit&newstatus=busy", "Busy", "pt-status-busy", "I'm busy!", "", logout);
  addPortletLink("p-personal", subpagelink + "&action=edit&newstatus=out", "Out", "pt-status-out", "I'm out!", "", logout);
  if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  var statusRegExp = /&action=edit&newstatus=(.*)/;
  var status = statusRegExp.exec(location.href)[1];
  //Modify the form
  document.getElementById('wpTextbox1').value = "{{User:"+wgUserName+scheme+"|"+status+"}}";
  document.getElementById('wpSummary').value = "Status: "+status;
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
});