// User scripts.
// The thing to remember about Javascript is that it's basically lisp with a
// slightly fucked syntax.
//var hello2;
/*
importScript("User:Tony_Sidaway/hello3.js");
hookEvent("load",
function() {
hello3();});
*/
/*
var tony=new Object();
alert("Before import");
importScript("User:Tony_Sidaway/buttons.js");
alert("After import");
// An array of ButtonMapping objects
tony.buttonMappings = new Array(
new tony.ButtonMapping("1", "Do the first command", function(x) {alert("Doing the first command");}),
new tony.ButtonMapping("2", "Do the second command", function(x) {alert("Doing the second command");}),
new tony.ButtonMapping("3", "Do the third command", function(x) {alert("Doing the third command");}));
// A function to perform a task that needs the jQuery library
function tony.withjQueryDo(thunk) {
// Cologne Blue skin, unlike the newer Vector skin, doesn't load jQuery :(
if (typeof jQuery == "undefined") {
mw.loader.load("//bits.wikimedia.org/skins-1.5/common/jquery.min.js");
}
thunk();
}
// alert(tony.userNames(logTable));
function tony.userNames(tab) {
var firstCols=jQuery("tbody > tr > :first-child", tab);
return firstCols.map(
function(ind) {
if (jQuery("span", this).length>0) {
jQuery("span > a", this).get().innerHTML;
} else {
jQuery("a", this).get().innerHTML;
}
});
}
// A function to add the buttons specified in the buttonMappings array.
function tony.addButtons() {
tony.withjQueryDo (
function() {
hookEvent("load",
function() {
jQuery.prototype.stringMap=function(mapFunctionReturningString) {
return this.map(mapFunctionReturningString).get().join("");
};
jQuery("#my-table").append(
jQuery(tony.buttonMappings).stringMap(
function(button, b) {
return "<tr><td><button onclick='tony.buttonMappings["+
button+
"].doFunc()'>"+b.label+"</button></td><td>"+
b.description+"</td></tr>";
}));
jQuery.get(escape("/wiki/Wikipedia:General sanctions/Climate change probation/Log"),
// jQuery.get(escape("/wiki/Main Page"),
function(html) {
// alert("Hello");
// alert("html is "+((html == "undefined")? "not defined": "defined"));
// alert(html.substring(1,100));
// format and output result
var logTable=jQuery("#notification_table_2010_03", html);
// alert(logTable.html());
// alert(jQuery("tbody > tr", logTable).filter(function(index){return jQuery("td", this).length > 0;}).map(function(ind,el){alert((el == "undefined")? "el is undefined": el.html()); return el.first();}).html());
//alert(jQuery("tbody > tr > :first-child > span > a", logTable).text());
alert(tony.userNames(logTable).get().join(" "));
jQuery("#my-table2").replaceWith(logTable);
});
});
});
}
// A tony.Wikipedia class or namespace to hold relevant static methods
function tony.Wikipedia() {
}
// A static method to call a thunk only if on a certain page performing a
// specified action.
function tony.Wikipedia.doIfPageAction(namespaceNumber, title, action, thunk) {
if (wgNamespaceNumber==namespaceNumber &&
wgAction == action &&
wgTitle == title) {
thunk();
}
}
// A static method to call a thunk only if viewing a certain user subpage.
function tony.Wikipedia.doIfViewingUserSubPage (subPage, thunk) {
tony.Wikipedia.doIfPageAction(2, wgUserName + "/" + subPage, "view", thunk);
}
// Add the buttons only if viewing a certain user sub-page.
tony.Wikipedia.doIfViewingUserSubPage("Control panel", tony.addButtons);
*/