User:Whiteknight/per book/Wikibooks:Reading room.js

//

$(function {  var editlinks = wk.getElementsByClass("editsection");  for(var i = 0; i < editlinks.length; i++) {    var j = i + 1    var b = document.createElement("a");    b.href = "javascript:TagSection(" + j + ");";    b.innerHTML = "tag";    b.id = "WK_Tag_" + j;    var c = document.createElement("a");    c.href = "javascript:DeleteSection(" + j + ");";    c.innerHTML = "delete";    c.id = "WK_Delete_" + j;    wk.appendChildren(editlinks[i], ["[", b, "][", c, "]"]);  } });

function TagSection(j) { wk.postEdit(wgPageName,              "",               "tagging unsigned section with timestamp",               {section:j, filter:addTopNote}); wk.toggleDisplay("WK_Tag_" + j, "none"); }

function DeleteSection(j) { if(confirm("Delete this section?")) { wk.postEdit(wgPageName,                "",                 "removing bad or old conversation",                {section:j}); wk.toggleDisplay("WK_Delete_" + j, "none"); } }

function addTopNote(pagetext, text) { var lines = pagetext.split("\n"); var title = lines.shift; pagetext = title + "\n" + text; for(var i = 0; i < lines.length; i++) { pagetext = pagetext + "\n" + lines[i]; } return pagetext; } //