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.
/* ====================================
Top Ten List module
Version 1.5: Now with vertical height control!
21 May 2014
Principal maintainer: [[User MarkvA]]
=====================================
$(function() {
var addRightRailModule = true;
if (wgNamespaceNumber !== 700) {
if (addRightRailModule === true) {
// Add the module to the right rail
$('#WikiaRail').bind('DOMNodeInserted', function(event) {
var sidebar = $('#WikiaRecentActivity');
var headerText = 'Vote!';
var topTenList = 'Test List';
var maxEntries = 8;
if (sidebar.size()) {
var listID = topTenList.replace(/[^A-Za-z0-9]/g,'_');
$('#WikiaRail').unbind('DOMNodeInserted');
var comboString = '<div data-maxentries="'+ maxEntries +'" data-toptenlist="'+ topTenList +'" data-headertext="'+ headerText +'" id="WikiaTopTenModule" class="WikiaTopTenModule module WikiaTopTenRightRail"><h1 class="header">'+ headerText +'</h1><div class="list" id='+ listID +'><div style="text-align:center;" class="loader"><img src="http://static.wikia.com/common/skins/common/images/ajax.gif" alt="Loading..." /></div></div></div>';
var listSelector = $(comboString).insertBefore(sidebar);
// Load the top 10 list and insert it into the module
$.getJSON(wgScript,{ 'action': 'ajax', 'rs': 'TopListHelper::checkListStatus', 'title': topTenList, 'cb' : Math.random() }, function(data, status, xhr) {
if (status === "error") {
$('.list',listSelector).text('An error occurred while loading the top 10 list.');
}
else {
var canVote = data.canVote;
$('.list',listSelector).load('/wiki/Top_10_list:'+ escape(topTenList) +'?action=render #toplists-list-body ul', function(data, status, xhr) {
if (status === "error" && xhr.status !== 404) {
$('.list',listSelector).text('An error occurred while loading the top 10 list.');
}
else if (xhr.status === 404) {
$('.list',listSelector).text('The top 10 list could not be found.');
}
else {
styleList(listSelector);
cutEntries(listSelector,maxEntries);
if (canVote !== true) {
$('.VoteButton',listSelector).remove();
}
}
});
}
});
}
});
}
// Add the module to the .Top10Module div's
$('.Top10Module').each(function() {
var that = this;
var headerText = $(this).attr('data-headertext');
var topTenList = $(this).attr('data-toptenlist');
var maxEntries = $(this).attr('data-maxentries');
var listID = topTenList.replace(/[^A-Za-z0-9]/g,'_');
var comboString = '<div data-maxentries="'+ maxEntries +'" data-toptenlist="'+ topTenList +'" data-headertext="'+ headerText +'" id="WikiaTopTenModule" class="WikiaTopTenModule WikiaTopTenInArticle"><h1 class="header">'+ headerText +'</h1><div class="list" id='+ listID +'><div style="text-align:center;" class="loader"><img src="http://static.wikia.com/common/skins/common/images/ajax.gif" alt="Loading..." /></div></div></div>';
var listSelector = $(comboString).appendTo(this);
$.getJSON(wgScript,{ 'action': 'ajax', 'rs': 'TopListHelper::checkListStatus', 'title': topTenList, 'cb' : Math.random() }, function(data, status, xhr) {
if (status === "error") {
$('.list',listSelector).text('An error occurred while loading the top 10 list.');
}
else {
var canVote = data.canVote;
$('.list',listSelector).load('/wiki/Top_10_list:'+ escape(topTenList) +'?action=render #toplists-list-body ul', function(data, status, xhr) {
if (status === "error" && xhr.status !== 404) {
$('.list',listSelector).text('An error occurred while loading the top 10 list.');
}
else if (xhr.status === 404) {
$('.list',listSelector).text('The top 10 list could not be found.');
}
else {
styleList(listSelector);
cutEntries(listSelector,maxEntries);
if (canVote !== true) {
$('.VoteButton',listSelector).remove();
}
}
});
}
});
});
// Add event handlers to the top 10 buttons
$('.WikiaPage').on('click', '.WikiaTopTenModule .VoteButton', function() {
var that = this;
var item = $(this).attr('id');
var list = unescape($(this).parents('.list').attr('id'));
var id = $(this).parents('.list').attr('id');
var maxEntries = $(this).parents('.WikiaTopTenModule').attr('data-maxentries');
var listSelector = $(this).parents('.WikiaTopTenModule');
$(this).parents('.WikiaTopTenModule').find('.header').append('<img class="ajax-loader" id="ajax-loader-'+ id +'" src="http://static.wikia.com/common/skins/common/images/ajax.gif" alt="Loading...">');
$('.VoteButton',listSelector).css('visibility','hidden');
$.ajax({
url: wgScript,
type: "GET",
dataType: "json",
timeout: 10000,
data: { action: 'ajax', rs: 'TopListHelper::voteItem', title: list+'/'+item }
}).done(function(data) {
$('#ajax-loader-'+ id).remove();
var success = data.result;
var html = data.listBody;
if (success !== true) {
$('#'+ id +' .VoteButton').hide("slow", function() { $(this).remove(); })
}
else {
var listSelectorNew = $('.list',listSelector).html(html);
setTimeout(function() {
$('#' + id +' .VoteButton').hide("slow", function() { $(this).remove(); })
},100);
styleList(listSelectorNew);
cutEntries(listSelectorNew,maxEntries);
}
}).fail(function(data) {
$('#ajax-loader-'+ id).remove();
alert('An error occurred while submitting the vote.');
});
});
function styleList(id) {
$('.NewItemForm',id).remove();
$('.create-new-list',id).remove();
$('p',id).remove();
$('.ItemVotes br',id).replaceWith(' ');
$('.ItemNumber',id).each(function() {
$(this).html($(this).html().replace(/\#/g,''));
});
}
function cutEntries(id,max) {
var max = parseInt(max) - 1;
$('li:eq('+ max +')',id).nextAll('li').remove();
}
}
});
/* Social Icons */
function SocialIcons() {
var userArray = wgPageName.split(":");
$('.WikiaRail').prepend('<div style="right:-1px; top:108px; position: absolute;"><div style="position: absolute;" class="SocialIcon"><div style="float:right;"><a href="https://www.facebook.com/pages/Destinypedia/498321176909780?fref=ts"><img src="http://images.wikia.com/destinypedia/images/8/8f/Facebook_Icon.png"></a></div></div><div style="position: absolute; margin-top:42px" class="SocialIcon"><div style="float:right;"><a href="http://www.twitter.com/DpediaTeam"><img src="http://images.wikia.com/destinypedia/images/9/92/Twitter_Icon.png"></a></div></div><div style="position: absolute; margin-top:84px" class="SocialIcon"><div style="float:right;"><a href="http://halo.wikia.com/wiki/Special:RecentChanges?feed=rss&type=html"><img src="http://images.wikia.com/destinypedia/images/c/c7/RSS_Icon.png"></a></div></div><div style="position: absolute; margin-top:126px" class="SocialIcon"><div style="float:right;"><a href="https://www.bungie.net/en-us/Groups/Detail?groupId=18278"><img src="http://images.wikia.com/destinypedia/images/2/2e/Bungie_Icon.png"></a></div></div><div style="position: absolute; margin-top:168px" class="SocialIcon"><div style="float:right;"><a href="http://www.wikia.com/Mobile%2FGameGuides"><img src="http://images.wikia.com/destinypedia/images/c/c0/Game_Guides_Icon.png"></a></div></div></div>');
}
if (mw.config.get("wgNamespaceNumber") != "user") {
addOnloadHook(SocialIcons);
}
*/