User:Assawyer/Scripts/Status switcher

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Note: This module depends on the Add LI link function.

This module will add 3 new links beside the "log out" link. These will be "in", "busy" and "out" for quickly changing your current Wikipedia status. For this to work, you'll need two additional pages:

  1. Special:Mypage/Status
  2. Special:Mypage/StatusTemplate

Note: The exact names of the subpages can be configured in the script.

The first one is the one modified by the script to hold {{User:Example/StatusTemplate|STATUS}}, where "STATUS" will be one of "in", "busy", "out". Then it is up to the "Template" to render it the way you wish. An example is:

'''<div style="border: 1px solid black; background: white; float: right; position: relative; top: -30px; padding: 5px">Example's status: {{ #switch: {{{1}}}
 | in=<span style="color: green;">IN</span>
 | busy=<span style="color: #FFAA00;">BUSY</span>
 | out=<span style="color: red;">OUT</span>
}}
</div>'''

You can tweak it to look whatever you like.

Then all you need is to put {{User:Example/Status}} on whatever pages you want the status to be displayed on and add the following function to your monobook.js.

Any comments/praises/bug reports/flames go to the author, Misza13 T C 16:48, 25 March 2006 (UTC).

//


// STATUS CHANGER
addOnloadHook(function (){
  var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
  var subpage = "/Status";
  var scheme = "/StatusTemplate";
  var linkprefix = "http://en.wikipedia.org/w/index.php?title=User:";
  var contribs = document.getElementById( 'pt-mycontris' );
  //Add the links
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=in", "In", "pt-status-in", "I'm in!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=busy", "Busy", "pt-status-busy", "I'm busy!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=out", "Out", "pt-status-out", "I'm out!", "");
  if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  statusRegExp = /&action=edit&newstatus=(.*)/;
  status = statusRegExp.exec(location.href)[1];
  //Modify the form
  document.getElementById('wpTextbox1').value = "{{User:"+user+scheme+"|"+status+"}}";
  document.getElementById('wpSummary').value = "Status: "+status;
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
});

//