• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Difference between revisions of "User:Dragonjet/scripts/VotingTemplate.js"

From Kancolle Wiki
Jump to navigation Jump to search
m (Undo revision 165723 by Dragonjet (talk) undo)
m (moveModule)
Line 21: Line 21:
 
});
 
});
 
}
 
}
 +
 +
moveModule();
 
});
 
});
 +
 +
/* moveModule() Source:
 +
http://zh.kancolle.wikia.com/wiki/MediaWiki:Common.js */
 +
 +
function moveModule(){
 +
if($(".page-Home").length==0){
 +
$("#WikiaRail").append($(".move"));
 +
$(".move").show();
 +
$(".move:hidden").remove();
 +
}else{
 +
$(".move").show();
 +
}
 +
}

Revision as of 07:21, 19 November 2014

$(document).ready(function(){
	if($(".sc_vote").length>0){
		var sc_total = $(".sc_vote").length;
		var sc_votes = {};
		$(".sc_vote").each(function(){
			if(typeof sc_votes[$(this).attr("data-value")] == "undefined"){
				sc_votes[$(this).attr("data-value")] = 0;
			}
			sc_votes[$(this).attr("data-value")]+=1;
		});
		$(".sc_tally").each(function(){
			var sc_tally_percent;
			if(typeof sc_votes[$(this).attr("data-value")] == "undefined"){
				sc_tally_percent = 0;
			}else{
				sc_tally_percent = (sc_votes[$(this).attr("data-value")] / sc_total)*100;
			}
			$(".sc_tally_bar", this).css("width", sc_tally_percent+"%");
			$(".sc_tally_count", this).text(sc_votes[$(this).attr("data-value")]);
			$(".sc_tally_val", this).text(Math.round(sc_tally_percent)+"%");
		});
	}

	moveModule();
});

/* moveModule() Source:
http://zh.kancolle.wikia.com/wiki/MediaWiki:Common.js */

function moveModule(){
	if($(".page-Home").length==0){
		$("#WikiaRail").append($(".move"));
		$(".move").show();
		$(".move:hidden").remove();
	}else{
		$(".move").show();
	}
}