Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
No edit summary
 
No edit summary
Line 3: Line 3:
// Wait for document ready
// Wait for document ready
$(function() {
$(function() {
// Set progress bar
var htmle = function(str) {
var issueProgress = $('.issue-progress');
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
if (issueProgress.length !== 0) {
};
issueProgress.html('<img src="http://summertimesaga.com/api/build/progress/img.png?width=500&color=eaeced&nc=' + Math.random() + '" alt="" border="0"/>');
}


// Test code for youtube embeds -sam9
if ($('body').hasClass('page-Summertime_Saga_Wiki') && $('body').hasClass('action-view') && $('body').hasClass('skin-vector') && $('#ajax-posts').length && $('#ajax-version').length) {
// Example tag: <span class="vid" data-id="YT_ID">VID_TITLE</span>
var maxPosts = 5;
var vidTags = $('.vid');


// Check to make sure vid tags exist
$.getJSON('/ssdata.json', function(data) {
if (vidTags.length !== 0) {
$('#ajax-version').text(data.version);
// Click handler
$('#ajax-posts').html('');
$('#content').on('click', '.vid-embed', function(e) {
e.preventDefault();


var elm = $(this);
data.posts.forEach(function(post, i) {
$.magnificPopup.open({
if (i >= maxPosts) {
items: {
return;
src : elm.attr('href'),
type : 'iframe'
}
}
$('#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>');
});
});
});
});
// Main parsing function
var parseTags = function() {
// Loop through our tags
vidTags.each(function() {
var elm = $(this);
var vidId = elm.data('id');
var title = elm.text();
// i.ytimg.com/vi/' + vidId + '/maxresdefault.jpg
elm.replaceWith('<a class="vid-embed" href="https://youtube.com/watch?v=' + vidId + '" target="_blank" title="' + title + '" style="background-image:url(//img.youtube.com/vi/' + vidId + '/mqdefault.jpg)"><div class="vid-mask"><span class="vid-embed-title">' + title + '</span><div class="vid-play"></div></div></a>');
});
};
// Load magnificPopup if it isn't already
if (typeof $.magnificPopup === 'undefined') {
// Temporary work around due to lack of server access
$.getScript('//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js', function() {
var headElm = $('head');
// Load magnificPopup CSS
headElm.append('<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"/>');
// Run our main function
parseTags();
});
} else {
// Run our main function
parseTags();
}
}
}
}());
}());

Revision as of 11: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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
	};

	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>');
			});
		});
	}
}());