User:Void/testing.js: Difference between revisions

From TestWiki
Content added Content deleted
m (test)
(upd current progress)
 
Line 1: Line 1:
// <nowiki>
// <nowiki>
if( mw.config.get('wgPageName') === 'TestWiki:Request_permissions' ) {
if( mw.config.get('wgPageName') === 'TestWiki:Request_permissions' ) {
var headings = $('.mw-headline');
var headings = $('.mw-headline'), i = 0;
for(var i = 0; i < headings.length; i++) {
for( ; i < headings.length; i++) {
if(/Status: (Open|Done)/.test(headings[i].innerText)) {
if(/Status: (Open|Done)/.test(headings[i].innerText)) {
headings[i].nextSibling.lastChild.id = 'edit-' + i;
headings[i].nextSibling.lastChild.id = 'edit-' + i;
$('#edit-' + i).before('| <a click="console.log(' + i + ')">respond</a>');
$('#edit-' + i).before('| <a id="resp-click-' + i + '">respond</a>');
}
}
}
for( ; i >= 0; i--) {
attach('#resp-click-' + i, i);
}
}
}
}


function doThing(num) {
function makeResponse(num) {
console.log(num);
console.log(num);
}
function attach(id, num) {
$(id).click(function(){makeResponse(num)});
}
}



Latest revision as of 23:11, 11 September 2017

// <nowiki>
if( mw.config.get('wgPageName') === 'TestWiki:Request_permissions' ) {
	var headings = $('.mw-headline'), i = 0;
	for( ; i < headings.length; i++) {
		if(/Status: (Open|Done)/.test(headings[i].innerText)) {
			headings[i].nextSibling.lastChild.id = 'edit-' + i;
			$('#edit-' + i).before('| <a id="resp-click-' + i + '">respond</a>');
		}
	}
	for( ; i >= 0; i--) {
		attach('#resp-click-' + i, i);
	}
}

function makeResponse(num) {
	console.log(num);
}
function attach(id, num) {
	$(id).click(function(){makeResponse(num)});
}

// </nowiki>