<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-infoboxQty.js</id>
	<title>MediaWiki:Gadget-infoboxQty.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-infoboxQty.js"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-infoboxQty.js&amp;action=history"/>
	<updated>2026-04-11T05:09:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-infoboxQty.js&amp;diff=42200&amp;oldid=prev</id>
		<title>Alex at 11:06, 20 October 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-infoboxQty.js&amp;diff=42200&amp;oldid=prev"/>
		<updated>2024-10-20T11:06:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-infoboxQty.js&amp;amp;diff=42200&amp;amp;oldid=858&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-infoboxQty.js&amp;diff=858&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;/**  * Infobox quantity script  * Adds a number input box next to specific numbers in tables  * Primary use case: the price in Infobox Item  *   * TODO: add infobox monster support (for what?)  *   * USAGE:  * &lt;td&gt;&lt;span class=&quot;infobox-quantity&quot; data-val-each=&quot;100&quot; data-value=&quot;1&quot;&gt;&lt;span class=&quot;infobox-quantity-replace&quot;&gt;100&lt;/span&gt; coins&lt;/span&gt;&lt;/td&gt;  * Everything inside the td should be wrapped in the outer span, which has class=infobox-quantity and attr data-val-each=(value...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=MediaWiki:Gadget-infoboxQty.js&amp;diff=858&amp;oldid=prev"/>
		<updated>2024-10-13T00:34:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;/**  * Infobox quantity script  * Adds a number input box next to specific numbers in tables  * Primary use case: the price in Infobox Item  *   * TODO: add infobox monster support (for what?)  *   * USAGE:  * &amp;lt;td&amp;gt;&amp;lt;span class=&amp;quot;infobox-quantity&amp;quot; data-val-each=&amp;quot;100&amp;quot; data-value=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;infobox-quantity-replace&amp;quot;&amp;gt;100&amp;lt;/span&amp;gt; coins&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;  * Everything inside the td should be wrapped in the outer span, which has class=infobox-quantity and attr data-val-each=(value...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;/**&lt;br /&gt;
 * Infobox quantity script&lt;br /&gt;
 * Adds a number input box next to specific numbers in tables&lt;br /&gt;
 * Primary use case: the price in Infobox Item&lt;br /&gt;
 * &lt;br /&gt;
 * TODO: add infobox monster support (for what?)&lt;br /&gt;
 * &lt;br /&gt;
 * USAGE:&lt;br /&gt;
 * &amp;lt;td&amp;gt;&amp;lt;span class=&amp;quot;infobox-quantity&amp;quot; data-val-each=&amp;quot;100&amp;quot; data-value=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;infobox-quantity-replace&amp;quot;&amp;gt;100&amp;lt;/span&amp;gt; coins&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
 * Everything inside the td should be wrapped in the outer span, which has class=infobox-quantity and attr data-val-each=(value of each item)&lt;br /&gt;
 * Inside that span, some part should be wrapped in another span with class=infobox-quantity-replace&lt;br /&gt;
 *     this is the part that gets replaced with the result&lt;br /&gt;
 * the result is input val * data-val-each&lt;br /&gt;
 * The data-value attribute is used as the default value. If it is not specified, the input is initialised at &amp;#039;1&amp;#039;.&lt;br /&gt;
 *&lt;br /&gt;
 * this is safe for use with switch infoboxes - the input is placed outside (before) the outer span, inside the td&lt;br /&gt;
 * [[MediaWiki:Common.js/switchInfobox2.js]] has an explicit exception to work with this and this only&lt;br /&gt;
 *     (that is, $(&amp;quot;input+span&amp;quot;), with the entirety of the span being replaced on a switch)&lt;br /&gt;
 * &lt;br /&gt;
 * &lt;br /&gt;
 * originally based on [[User:Joeytje50/monstercalc.js]]&lt;br /&gt;
 */ &lt;br /&gt;
$(function () {&lt;br /&gt;
	mw.hook(&amp;#039;wikipage.content&amp;#039;).add(function init( $content ) {&lt;br /&gt;
		// Delegated event so it works for any new inputs that get generated later on.&lt;br /&gt;
		$(&amp;#039;body&amp;#039;).on(&amp;#039;keyup click change mousewheel&amp;#039;, &amp;#039;input.QtyCalc&amp;#039;, function (event) {&lt;br /&gt;
			var warn = &amp;#039;&amp;#039;,&lt;br /&gt;
			warn2 = &amp;#039;&amp;#039;,&lt;br /&gt;
			val = 1,&lt;br /&gt;
			$this = $(this),&lt;br /&gt;
			$ifbq = $(event.currentTarget).parent(),&lt;br /&gt;
			$rep = $ifbq.find(&amp;#039;span.infobox-quantity-replace&amp;#039;),&lt;br /&gt;
			each = $ifbq.attr(&amp;#039;data-val-each&amp;#039;),&lt;br /&gt;
			formula = $ifbq.attr(&amp;#039;data-formula&amp;#039;);&lt;br /&gt;
			// check if nonnumeric entered (generally if type=number not supported)&lt;br /&gt;
			// if so, setup warnings&lt;br /&gt;
			if ($this.val().search(/[^0-9]/g) != -1) {&lt;br /&gt;
				warn = &amp;#039;&amp;lt;abbr title=&amp;quot;non-numeric characters are ignored&amp;quot; class=&amp;quot;explain&amp;quot;&amp;gt;&amp;#039;;&lt;br /&gt;
				warn2 = &amp;#039;&amp;lt;/abbr&amp;gt;&amp;#039;;&lt;br /&gt;
			}&lt;br /&gt;
			//sanitise val, parse to int&lt;br /&gt;
			val = parseInt($this.val().replace(/[^0-9]/g, &amp;#039;&amp;#039;));&lt;br /&gt;
			if (isNaN(val)) {&lt;br /&gt;
				val = 1; // invalid number -&amp;gt; just use 1&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			$rep.html(warn + rswiki.addCommas(each * val) + warn2);&lt;br /&gt;
		});&lt;br /&gt;
		&lt;br /&gt;
		/**&lt;br /&gt;
		* generic one-value calc&lt;br /&gt;
		* compatible with most (switch) infoboxes made with [[Module:Infobox]]&lt;br /&gt;
		* Takes an argument `el` which must be a selector for the parent element, or the element itself.&lt;br /&gt;
		*/&lt;br /&gt;
		rswiki.initQtyBox = function(el) {&lt;br /&gt;
			$(el).find(&amp;#039;td &amp;gt; span.infobox-quantity&amp;#039;).not(&amp;#039;:has(input)&amp;#039;).each(function(i,e){&lt;br /&gt;
				var $self = $(e);&lt;br /&gt;
				var $input = $(&amp;#039;&amp;lt;input&amp;gt;&amp;#039;)&lt;br /&gt;
					.attr({&lt;br /&gt;
						id: &amp;#039;QtyCalc&amp;#039;+i,&lt;br /&gt;
						class: &amp;#039;QtyCalc&amp;#039;,&lt;br /&gt;
						type: &amp;#039;number&amp;#039;,&lt;br /&gt;
						value: $self.data(&amp;#039;value&amp;#039;) || &amp;#039;1&amp;#039;,&lt;br /&gt;
						maxlength: &amp;#039;10&amp;#039;,&lt;br /&gt;
						min: &amp;#039;0&amp;#039;,&lt;br /&gt;
						max: &amp;#039;9999999999&amp;#039;,&lt;br /&gt;
					})&lt;br /&gt;
					.css({&lt;br /&gt;
						width: &amp;#039;65px&amp;#039;,&lt;br /&gt;
						&amp;#039;margin-right&amp;#039;: &amp;#039;0.25em&amp;#039;,&lt;br /&gt;
					})&lt;br /&gt;
					.prependTo($self)&lt;br /&gt;
					.trigger(&amp;#039;change&amp;#039;);&lt;br /&gt;
			});&lt;br /&gt;
		};&lt;br /&gt;
	&lt;br /&gt;
		// init boxes in on the whole page&lt;br /&gt;
		rswiki.initQtyBox( $content );&lt;br /&gt;
	});&lt;br /&gt;
})&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>