MediaWiki:BibleGet.js

From Seeds of the Word, the encyclopedia of the influence of the Gospel on culture
Revision as of 14:22, September 10, 2020 by Johnrdorazio (talk | contribs)

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($,mw){
	$(document).ready(function(){
		if( $('.bibleQuoteRef').length > 0 ){
			console.log("There are bible quotes on this page!");
			$('.bibleQuoteRef').each(function(){
				let $span = $(this);
				let version = $(this).attr('data-version');
				let ref = $(this).attr('data-ref');
				$.ajax({
					method: 'POST',
					url: 'bgetHelper.php',
					data: {
						"version": version, 
						"ref": ref
					},
					success: function(data){
						console.log("data returned from ajax request:");
						console.log(data);
						/*
						let $bGetTIP = $('<div>', {
							"class": "bibleGetQuote", 
							"data-ref": ref,
							"html": data
						});
						$bGetTIP.append($('<p>',{"text": " — powered by BibleGet I/O","css":{"font-size":".9em","text-align":"right","font-style":"italic","font-weight":"bold","color":"gray"}}));
						$('body').append($bGetTIP);
						
						$span.on('mouseenter', function(){
							$bGetTIP.show();
							let top = $span.offset().top;
							let left = $span.offset().left + $span.outerWidth() + 15;
							$bGetTIP.css({"top":top,"left":left});
						});
						*/
						/*
						$span.on('mousemove', function(){
							let top = $span.offset().top;
							let left = $span.offset().left + $span.outerWidth();
							$bGetTIP.css({"top":top,"left":left});
						});
						*/
						/*
						$span.on('mouseleave', function(){
							$bGetTIP.fadeOut('slow');
						});
						
						console.log("Injected Bible quote for ref = " + ref + " with value obtained from BibleGet service:");
						*/
					},
					error: function(jqXHR, textStatus, errorThrown){
						console.log("There was an error while trying to communicate with the BibleGet server:")
						console.log(errorThrown + ' ' + textStatus + ': ' + jqXHR.responseText);
					}
				});
			});
		}
	});
})(jQuery,mw);