User:Whiteknight/remotetalk2.js
From Wikibooks, open books for an open world
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.
| Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate reading room. The code will be executed when previewing this page under some skins, including Monobook. |
|
|
Documentation for this script can be added at User:Whiteknight/remotetalk2. |
var rt = { rt.span: "WKRTSpan", rt.iframe: null, rt.alias: new Array(), }; rt.getIFrame = function() { if(rt.iframe == null) rt.iframe = wk.makeElement("iframe", {width:"100%", height:"550px"}); return rt.iframe; } rt.talkLinks = function() { var frame = wk.makeElement("div"); for(i = 0; i < rt.alias.length; i++) { var link = rt.createLink(rt.alias[i][0], rt.alias[i][1], rt.alias[i][2], rt.alias[i][3]); frame.appendChild(link); frame.appendChild(document.createTextNode(" — ")); } link = wk.makeElement("a", {href:"#" + rt.span}, "Remove"); link.onclick = rt.initFrame; frame.appendChild(link); return frame; } rt.createLink = function(project, username, linkname) { if(username == "") username = wgUserName; if(project == "") project = "wikibooks"; if(linkname == "") linkname = username + "@" + project; username = username.replace(" ", "_"); var link = wk.makeElement("a", {href:"#" + rt.span}, linkname); link.onclick = function(){ rt.getTalkPage(lang, project, username)}; return link; } rt.getTalkPage = function (lang, project, username) { var talkurl = "http://" + lang + "." + project + ".org" + "/w/index.php?title=User_talk:" + username + "&action=view&printable=yes"; var frame = wk.spanText(rt.span, ""); var iframe = rt.getIFrame(); iframe.setAttribute("src", talkurl); frame.appendChild(rt.talkLinks()); frame.appendChild(iframe); frame.appendChild(rt.talkLinks()); } rt.getAlias = function(frame) { var text = frame.innerHTML; var links = text.split(","); for(var i = 0; i < links.length; i++) { var junk = links[i].split("@"); var name = junk[0]; var project = junk[1]; rt.alias.push([project, name]) } } rt.initFrame = function() { var frame = wk.spanText(rt.span, ""); if(frame != null) { rt.getAlias(frame); frame.appendChild(rt.talkLinks()); } } if(typeof wk == "object" && wk.testVersion(2.0)) { addOnloadHook(rt.initFrame); }