User:James.Corden/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
Created page with "function votecount() { var a = 0; var b = 0; var results = []; var trunc; for (j=0; $("h3").eq(j).find("span").attr("id") !== undefined; j++) { results[a] = 0; results[a+1] = 0; results[a+2] = 0; for (i=0; $("h4").eq(a).nextUntil("h4").children("li").eq(i).html() !== undefined; i++) results[a] = i+1; $("td.support").eq(j).text(results[a]); for (i=0; $("h4").eq(a+1).nextUntil("h4").children("li").eq(i).html() !== undefined; i++) results[a+1] = i+1..."
 
(No difference)

Latest revision as of 21:51, 11 August 2024

function votecount() {
	var a = 0;
	var b = 0;
	var results = [];
	var trunc;
	for (j=0; $("h3").eq(j).find("span").attr("id") !== undefined; j++) {
		results[a] = 0;
		results[a+1] = 0;
		results[a+2] = 0;
		for (i=0; $("h4").eq(a).nextUntil("h4").children("li").eq(i).html() !== undefined; i++) 
			results[a] = i+1;
		$("td.support").eq(j).text(results[a]);
		for (i=0; $("h4").eq(a+1).nextUntil("h4").children("li").eq(i).html() !== undefined; i++) 
			results[a+1] = i+1;
		$("td.oppose").eq(j).text(results[a+1]);
		for (i=0; $("h4").eq(a+2).nextUntil("h4").children("li").eq(i).html() !== undefined; i++) 
			results[a+2] = i+1;
		$("td.neutral").eq(j).text(results[a+2]);
		results[a+3] = results[a]/(results[a]+results[a+1])*100;
		trunc = results[a+3].toFixed(2);
		$("td.percent").eq(j).text(trunc);
		b = $("h3").eq(j).nextUntil("h3", "h4").length + b;
		a = b;
	}
}
var PageName = mw.config.get( 'wgPageName' );
if(PageName === "User:James.Corden")
	$(votecount);