User:James.Corden/common.js

From Test Wiki
Revision as of 21:51, 11 August 2024 by James.Corden (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
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);