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 difference)

Revision as of 00:10, 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.mw.util', 'mediawiki.api', 'ext.gadget.rsw-mw.util'], self.init )});