Difference between revisions of "MediaWiki:Common.js"
From Summertime Saga Wiki
(28 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
− | // | + | // Wait for document ready |
$(function() { | $(function() { | ||
− | // | + | var htmle = function(str) { |
− | + | return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | |
− | + | }; | |
− | + | if ($('body').hasClass('page-Summertime_Saga_Wiki') && $('body').hasClass('action-view') && $('body').hasClass('skin-vector') && $('#ajax-posts').length && $('#ajax-version').length) { | |
− | + | var maxPosts = 5; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | $.getJSON('/ssdata.json', function(data) { | |
− | + | $('#ajax-version').text(data.version); | |
− | + | $('#ajax-posts').html(''); | |
− | $. | ||
− | |||
− | |||
− | |||
− | + | data.posts.forEach(function(post, i) { | |
− | + | if (i >= maxPosts) { | |
+ | return; | ||
+ | } | ||
− | + | $('#ajax-posts').append('<dd><b>▪ ' + htmle(post.date) + ':</b> <a rel="nofollow" class="external text" href="https://www.patreon.com' + htmle(post.url) + '">' + htmle(post.title) + '</a></dd>'); | |
− | + | }); | |
}); | }); | ||
− | |||
− | |||
− | |||
} | } | ||
}()); | }()); |
Latest revision as of 12:21, 14 June 2019
/* Any JavaScript here will be loaded for all users on every page load. */ // Wait for document ready $(function() { var htmle = function(str) { return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); }; if ($('body').hasClass('page-Summertime_Saga_Wiki') && $('body').hasClass('action-view') && $('body').hasClass('skin-vector') && $('#ajax-posts').length && $('#ajax-version').length) { var maxPosts = 5; $.getJSON('/ssdata.json', function(data) { $('#ajax-version').text(data.version); $('#ajax-posts').html(''); data.posts.forEach(function(post, i) { if (i >= maxPosts) { return; } $('#ajax-posts').append('<dd><b>▪ ' + htmle(post.date) + ':</b> <a rel="nofollow" class="external text" href="https://www.patreon.com' + htmle(post.url) + '">' + htmle(post.title) + '</a></dd>'); }); }); } }());