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.
//<nowiki>

topaz.wikistress = new Object();
topaz.wikistress.version = 1;


/* configuration */

// change these to whatever you'd like to show up on your status page.  you can add new lines in
// the same format provided there is a comma at the end of each line but the last one.  you can
// also use wikimarkup here to, for example, display an image instead of text.
topaz.wikistress.statuscode = {
  1:'{{wstress3d|1||My current WikiStress level}}',
  NoPants:'{{wstress3d|NoPants||My current WikiStress level}}',
  numb:'{{wstress3d|numb||My current WikiStress level}}',
  2:'{{wstress3d|2||My current WikiStress level}}',
  3:'{{wstress3d|3||My current WikiStress level}}',
  4:'{{wstress3d|4||My current WikiStress level}}',
  42:'{{wstress3d|4a||My current WikiStress level}}',
  5:'{{wstress3d|5||My current WikiStress level}}',
  6:'{{wstress3d|6||My current WikiStress level}}',
  7:'{{wstress3d|7||My current WikiStress level}}',
  8:'{{wstress3d|8||My current WikiStress level}}',
  9:'{{wstress3d|9||My current WikiStress level}}'
};

// this will make wikimarkup work in your stauscodes but will disable auto-updating 
topaz.wikistress.enablewikimarkup = true;

// true to use the personal bar, false to create a panel in the left column
topaz.wikistress.usepersonalbar = false;

// true if you'd like your status page on your watchlist
topaz.wikistress.watchstatus = true;

/* end configuration */


topaz.wikistress.buttonlist = {};
topaz.wikistress.oldonload = window.onload;
window.onload = function() {
  if (typeof topaz.wikistress.oldonload == "function") {
    setTimeout('topaz.wikistress.oldonload()',50);
  }
  if (!topaz.wikistress.usepersonalbar) {
    topaz.wputil.addsidepanel("wikistress", "wikistress");
  }
  var buttonlist = [];
  for (status in topaz.wikistress.statuscode) {
    buttonlist.push(status);
    topaz.wikistress.buttonlist[status] =
        topaz.wputil.addsidepanelbutton(
          topaz.wikistress.usepersonalbar ? "p-personal" : "wikistress",
          status,
          'javascript:topaz.wikistress.setstatus("' + status + '")'
        );
  }

  if (topaz.wikistress.usepersonalbar) {
    for(var i=0; i<buttonlist.length; i++) {
      with (topaz.wikistress.buttonlist[buttonlist[i]].style) {
        if (i != buttonlist.length-1) {
          borderRight = "1px solid #aaaaaa";
          paddingRight = "2px";
        }
        if (i != 0) {
          marginLeft = "0px";
          paddingLeft = "2px";
        }
      }
    }
  }

  var spanlist = document.getElementsByTagName("span");
  for (var i=0; i<spanlist.length; i++) {
    if (spanlist[i].className == "topaz.wikistress.curstatus."+escape(topaz.wputil.username())) {
      topaz.util.cookie.set("topaz.wikistress.curstatus", spanlist[i].innerHTML);
    }
  }

  topaz.wikistress.update();
};

topaz.wikistress.setstatus = function(statusname) {
  topaz.wputil.setpagecontent(
      "User:"+topaz.wputil.username()+"/Wikistress",

      (!topaz.wikistress.enablewikimarkup ?
          '<includeonly><span class="topaz.wikistress.inlinestatus.'
          + escape(topaz.wputil.username())
          + '"></includeonly>'
      : '') +

      topaz.wikistress.statuscode[statusname] +

      (!topaz.wikistress.enablewikimarkup ?
          '<includeonly></span></includeonly>'
      : '') +

      '<span class="topaz.wikistress.curstatus.'+escape(topaz.wputil.username()) +
      '" style="display:none">'+statusname+'</span>',

      statusname,
      topaz.wikistress.watchstatus);
  topaz.util.cookie.set("topaz.wikistress.curstatus", statusname);
  topaz.wikistress.update();
};

topaz.wikistress.laststatus = null;
topaz.wikistress.update = function() {
  var curstatus = topaz.util.cookie.get("topaz.wikistress.curstatus");
  if (curstatus && curstatus != topaz.wikistress.laststatus) {
    for (status in topaz.wikistress.buttonlist) {
      with (topaz.wikistress.buttonlist[status].style) {
        if (status == curstatus) {
          fontWeight = "bold";
        } else {
          fontWeight = "normal";
        }
      }
    }

    if (!topaz.wikistress.enablewikimarkup) {
      var spanlist = document.getElementsByTagName("span");
      for (var i=0; i<spanlist.length; i++) {
        if (spanlist[i].className == "topaz.wikistress.inlinestatus."+escape(topaz.wputil.username())) {
          spanlist[i].innerHTML = topaz.wikistress.statuscode[curstatus];
        }
      }
    }
  }
  topaz.wikistress.laststatus = curstatus;
};

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


//</nowiki>