MediaWiki:Gadget-realtimeExchange-core.js: Difference between revisions

From RuneRealm Wiki
Jump to navigation Jump to search
Content added Content deleted
(Created page with "→‎* * Adds realtime Grand Exchange prices on the wiki * * @author JaydenKieran: 'use strict'; var conf = mw.config.get( [ 'stylepath', 'wgTitle' ] ), itemId = null, self = { →‎* * Inital loading method: init: function () { var realtimeDiv = $('.realtimePrices'); realtimeDiv.each( function () { var $this = $( this ), itemId = $this.data('itemid'); var modalOpenBtn = new OO.ui.ButtonWidget( { flags: [ 'primary' ]...")
 
No edit summary
 
Line 41: Line 41:
};
};


$(function(){mw.loader.using( ['mediawiki.mw.util', 'mediawiki.api', 'ext.gadget.rsw-mw.util'], self.init )});
$(function(){mw.loader.using( ['mediawiki.util', 'mediawiki.api', 'ext.gadget.rsw-util'], self.init )});

Latest revision as of 17:15, 17 October 2024

/**
 * Adds realtime Grand Exchange prices on the wiki
 * 
 * @author JaydenKieran
 */

'use strict';

var conf = mw.config.get( [
		'stylepath',
		'wgTitle'
	] ),
	
	itemId = null,

	self = {
		/**
		 * Inital loading method
		 */
		init: function () {
			var realtimeDiv = $('.realtimePrices');
			realtimeDiv.each( function () {
				var $this = $( this ),
					itemId = $this.data('itemid');
				
				var modalOpenBtn = new OO.ui.ButtonWidget( {
				  flags: [ 'primary' ],
				  label: 'View Real-time Prices',
				  classes: [ 'realtime-ge-openbtn' ]
				} );
				modalOpenBtn.on('click', function () {
					window.open('https://prices.runescape.wiki/osrs/item/'+itemId);
				});
				
				$this.parent().append(
					modalOpenBtn.$element
				);
			} );
		},

	};

$(function(){mw.loader.using( ['mediawiki.util', 'mediawiki.api', 'ext.gadget.rsw-util'], self.init )});