User:Whiteknight/remotetalk.js

var rt = {}; rt.span = "WKRTSpan"; rt.iframe = null; rt.pairs = null; 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.pairs.length; i++) { var nameplace = rt.pairs[i].split("@"); var link = rt.createLink(nameplace[0], nameplace[1]); 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(username, project) { if(username == "") username = wgUserName; if(project == "") project  = "wikibooks"; username = username.replace(" ", "_"); var link = wk.makeElement("a", {href:"#" + rt.span}, project); link.onclick = function{ rt.getTalkPage(project, username)}; return link; } rt.getTalkPage = function (project, username) { var talkurl = "http://" + 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.initFrame = function { var span = document.getElementById(rt.span); var items = span.innerHTML; if(rt.pairs == null) rt.pairs = items.split(","); span.innerHTML = ""; if(span != null) { span.style.display = "block"; span.appendChild(rt.talkLinks); } } $(rt.initFrame);