User:Whiteknight/per book/User:Whiteknight.js

Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
  • Konqueror: simply click the Reload button, or press F5;
  • Opera users may need to completely clear their cache in Tools→Preferences.
//<pre>javascripts that I only load for pages in my own personal namespace

function wk_import_script(name) {
  name = encodeURIComponent(name.replace(/ /g, '_' ));
  var scriptElem = document.createElement('script');
  scriptElem.setAttribute('type', 'text/javascript');
  scriptElem.setAttribute('src',  '/w/index.php?title=' + name + '&action=raw&ctype=text/javascript');
  document.getElementsByTagName('head')[0].appendChild(scriptElem);
}

wk_import_script('User:Whiteknight/pagetester.js');
wk_import_script('User:Whiteknight/graph.js');

if(wgPageName == "User:Whiteknight") addOnloadHook(function() {
  var stat;
  if(stat = document.getElementById("WK_Status_Span")) {
    a = document.createElement("a");
    a.href = "javascript:WKChangeStatus();";
    a.innerHTML = "Change";
    b = document.createElement("a");
    b.href = "javascript:WKDeleteStatus();";
    b.innerHTML = "Remove";
    wk.appendChildren(stat, ["[", a, "][", b, "]"]);
  }
});

function WKChangeStatus() {
  var span = document.getElementById("WK_Status_Span_2");
  var stat = prompt("New Status:", (span == null)?(""):(span.innerHTML));
  if(stat != "" && stat != null) {
    wk.postEdit("User:Whiteknight/Stat", stat, "updating status", null);
    if(span != null) { 
      span.innerHTML = stat;
      wk.toggleDisplay(span, "block");
    }
    else {
      span = document.createElement("div");
      span.setAttribute("class", "PrettyTextBox");
      span.setAttribute("id", "WK_Status_Span_2");
      span.style.textAlign = "center";
      span.innerHTML = stat;
      var shell = document.getElementById("WK_Status_Span");
      shell.appendChild(span);
    }
  }
}

function WKDeleteStatus() {
  if(confirm("Do you want to delete your status?")) {
    wk.postEdit("User:Whiteknight/Stat", "", "removing status message", null);
    wk.toggleDisplay("WK_Status_Span_2", "none");
  }
}

//</pre>