User:Cqm/efficiency.js/fletching.js

/** * Fletching efficiency calculator * * Loosely based on MediaWiki:Common.js/calc.js by Quarenon * @author Cqm */   'use strict'; rswiki.efficiency = rswiki.efficiency || {}; rswiki.efficiency.fletching = ( function {            // income            money = 0,            // error boolean            // used for checking income value is an integer            err = false,            // list of items            // this is the order they will be in when the table is generated            // so this is what you need to edit to alter said order            items = [                'Arrow shaft',                'Headless arrow',                'Bronze arrow',                'Iron arrow',                'Steel arrow',                'Mithril arrow',                'Broad arrow',                'Adamant arrow',                'Rune arrow',                'Dragon arrow',                'Bronze dart',                'Off-hand bronze dart',                'Iron dart',                'Off-hand iron dart',                'Steel dart',                'Off-hand steel dart', 'Mithril dart', 'Off-hand mithril dart', 'Adamant dart', 'Off-hand adamant dart', 'Rune dart', 'Off-hand rune dart', 'Dragon dart', 'Off-hand dragon dart', 'Shortbow (u)', 'Shieldbow (u)', 'Oak shortbow (u)', 'Oak shieldbow (u)', 'Willow shortbow (u)', 'Willow shieldbow (u)', 'Maple shortbow (u)', 'Maple shieldbow (u)', 'Yew shortbow (u)', 'Yew shieldbow (u)', 'Magic shortbow (u)', 'Magic shieldbow (u)', 'Shortbow', 'Shieldbow', 'Oak shortbow', 'Oak shieldbow', 'Willow shortbow', 'Willow shieldbow', 'Maple shortbow', 'Maple shieldbow', 'Yew shortbow', 'Yew shieldbow', 'Magic shortbow', 'Magic shieldbow', 'Wooden stock', 'Oak stock', 'Willow stock', 'Teak stock', 'Maple stock', 'Mahogany stock', 'Yew stock', 'Magic stock', 'Bronze c'bow (u)', 'Iron c'bow (u)', 'Steel c'bow (u)', 'Mithril c'bow (u)', 'Adamant c'bow (u)', 'Runite c'bow (u)', 'Dragon c'bow (u)', 'Bronze crossbow', 'Off-hand bronze crossbow', 'Bronze 2h crossbow', 'Iron crossbow', 'Off-hand iron crossbow', 'Iron 2h crossbow', 'Steel crossbow', 'Off-hand steel crossbow', 'Steel 2h crossbow', 'Mith crossbow', 'Off-hand mithril crossbow', 'Mithril 2h crossbow', 'Adamant crossbow', 'Off-hand adamant crossbow', 'Adamant 2h crossbow', 'Rune crossbow', 'Off-hand rune crossbow', 'Rune 2h crossbow', 'Dragon crossbow', 'Off-hand dragon crossbow', 'Dragon 2h crossbow', 'Bronze bolts', 'Iron bolts', 'Silver bolts', 'Steel bolts', 'Mithril bolts', 'Broad-tipped bolts', 'Adamant bolts', 'Runite bolts', 'Opal bolts', 'Pearl bolts', 'Topaz bolts', 'Barbed bolts', 'Sapphire bolts', 'Emerald bolts', 'Ruby bolts', 'Diamond bolts', 'Dragon bolts', 'Onyx bolts', 'Ascension bolts', 'Opal bolt tips', 'Jade bolt tips', 'Pearl bolt tips', 'Pearl bolt tips', 'Topaz bolt tips', 'Sapphire bolt tips', 'Emerald bolt tips', 'Ruby bolt tips', 'Diamond bolt tips', 'Dragon bolt tips', 'Onyx bolt tips', 'Bronze brutal', 'Iron brutal', 'Steel brutal', 'Black brutal', 'Mithril brutal', 'Adamant brutal', 'Rune brutal', ],
 * ( function ( $, mw, rswiki ) {

// data object // this contains static data by default (ingredients, level, xp, profit and num/hour           // price and image are added when the script is run            // when adding items remember to add them to the items array above, this data object            // and add their ingredients to the ingredients object if not already there            data = {                                'Arrow shaft': {                    ingredients: ['Logs'],                    lvl: 1,                    xp: 0.333,                    profit: function  {                        return data['Arrow shaft'].price - data['Logs'].price /1;                    },                    num: 26250                },                'Headless arrow': {                    ingredients: ['Arrow shaft', 'Feather'],                    lvl: 1,                    xp: 1,                    profit: function  {                        return data['Headless arrow'].price - data['Arrow shaft'].price - data['Feather'].price; },                   num: 40000 },               'Bronze arrow': { ingredients: ['Headless arrow', 'Bronze arrowhead'], lvl: 1, xp: 2.6, profit: function { return data['Bronze arrow'].price - data['Headless arrow'].price - data['Bronze arrowheads'].price; },                   num: 40000 },               'Iron arrow': { ingredients: ['Headless arrow', 'Iron arrowhead'], lvl: 15, xp: 3.8, profit: function { return data['Iron arrow'].price - data['Headless arrow'].price - data['Iron arrowheads'].price; },                   num: 40000 },               'Steel arrow': { ingredients: ['Headless arrow', 'Steel arrowhead'], lvl: 30, xp: 6.3, profit: function { return data['Steel arrow'].price - data['Headless arrow'].price - data['Steel arrowheads'].price; },                   num: 40000 },               'Mithril arrow': { ingredients: ['Headless arrow', 'Mithril arrowhead'], lvl: 45, xp: 8.8, profit: function { return data['Mithril arrow'].price - data['Headless arrow'].price - data['Mithril arrowheads'].price; },                   num: 40000 },               'Broad arrow': { ingredients: ['Headless arrow', 'Broad arrowheads'], lvl: 52, xp: 15, profit: function { return data['Headless arrow'].price - data['Broad arrowheads'].price; },                   num: 40000 },               'Adamant arrow': { ingredients: ['Headless arrow', 'Adamant arrowhead'], lvl: 60, xp: 10, profit: function { return data['Adamant arrow'].price - data['Headless arrow'].price - data['Adamant arrowheads'].price; },                   num: 40000 },               'Rune arrow': { ingredients: ['Headless arrow', 'Rune arrowhead'], lvl: 75, xp: 13.8, profit: function { return data['Rune arrow'].price - data['Headless arrow'].price - data['Rune arrowheads'].price; },                   num: 40000 },               'Dragon arrow': { ingredients: ['Headless arrow', 'Dragon arrowhead'], lvl: 90, xp: 16.3, profit: function { return data['Dragon arrow'].price - data['Headless arrow'].price - data['Dragon arrowheads'].price; },                   num: 40000 },               'Bronze dart': { ingredients: ['Feather', 'Bronze dart tip'], lvl: 1, xp: 1.8, profit: function { return data['Bronze dart'].price - data['Bronze dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand bronze dart': { ingredients: ['Feather', 'Bronze dart tip'], lvl: 1, xp: 1.8, profit: function { return data['Off-hand bronze dart'].price - data['Bronze dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Iron dart': { ingredients: ['Feather', 'Iron dart tip'], lvl: 22, xp: 3.8, profit: function { return data['Iron dart'].price - data['Iron dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand iron dart': { ingredients: ['Feather', 'Iron dart tip'], lvl: 22, xp: 3.8, profit: function { return data['Off-hand iron dart'].price - data['Iron dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Steel dart': { ingredients: ['Feather', 'Steel dart tip'], lvl: 37, xp: 7.5, profit: function { return data['Steel dart'].price - data['Steel dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand steel dart': { ingredients: ['Feather', 'Steel dart tip'], lvl: 37, xp: 7.5, profit: function { return data['Off-hand steel dart'].price - data['Steel dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Mithril dart': { ingredients: ['Feather', 'Mithril dart tip'], lvl: 52, xp: 11.2, profit: function { return data['Mithril dart'].price - data['Mithril dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand mithril dart': { ingredients: ['Feather', 'Mithril dart tip'], lvl: 52, xp: 11.2, profit: function { return data['Off-hand mithril dart'].price - data['Mithril dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Adamant dart': { ingredients: ['Feather', 'Adamant dart tip'], lvl: 67, xp: 15, profit: function { return data['Adamant dart'].price - data['Adamant dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand adamant dart': { ingredients: ['Feather', 'Adamant dart tip'], lvl: 67, xp: 15, profit: function { return data['Off-hand adamant dart'].price - data['Adamant dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Rune dart': { ingredients: ['Feather', 'Rune dart tip'], lvl: 81, xp: 18.8, profit: function { return data['Rune dart'].price - data['Rune dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand rune dart': { ingredients: ['Feather', 'Rune dart tip'], lvl: 81, xp: 18.8, profit: function { return data['Off-hand rune dart'].price - data['Rune dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Dragon dart': { ingredients: ['Feather', 'Dragon dart tip'], lvl: 95, xp: 25, profit: function { return data['Dragon dart'].price - data['Dragon dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Off-hand dragon dart': { ingredients: ['Feather', 'Dragon dart tip'], lvl: 95, xp: 25, profit: function { return data['Off-hand dragon dart'].price - data['Dragon dart tip'].price - data['Feather'].price; },                   num: 50000 },               'Shortbow (u)': { ingredients: ['Logs'], lvl: 1, xp: 5, profit: function { return data['Shortbow (u)'].price - data['Logs'].price; },                   num: 1750 },               'Shieldbow (u)': { ingredients: ['Logs'], lvl: 10, xp: 10, profit: function { return data['Shieldbow (u)'].price - data['Logs'].price; },                   num: 1750 },               'Oak shortbow (u)': { ingredients: ['Oak logs'], lvl: 20, xp: 16.5, profit: function { return data['Oak shortbow (u)'].price - data['Oak logs'].price; },                   num: 1750 },               'Oak shieldbow (u)': { ingredients: ['Oak logs'], lvl: 25, xp: 25, profit: function { return data['Oak shieldbow (u)'].price - data['Oak logs'].price; },                   num: 1750 },               'Willow shortbow (u)': { ingredients: ['Willow logs'], lvl: 35, xp: 33.25, profit: function { return data['Willow shortbow (u)'].price - data['Willow logs'].price; },                   num: 1750 },               'Willow shieldbow (u)': { ingredients: ['Willow logs'], lvl: 40, xp: 41.5, profit: function { return data['Willow shieldbow (u)'].price - data['Willow logs'].price; },                   num: 1750 },               'Maple shortbow (u)': { ingredients: ['Maple logs'], lvl: 50, xp: 50, profit: function { return data['Maple shortbow (u)'].price - data['Maple logs'].price; },                   num: 1750 },               'Maple shieldbow (u)': { ingredients: ['Maple logs'], lvl: 55, xp: 58.3, profit: function { return data['Maple shieldbow (u)'].price - data['Maple logs'].price; },                   num: 1750 },               'Yew shortbow (u)': { ingredients: ['Yew logs'], lvl: 65, xp: 67.5, profit: function { return data['Yew shortbow (u)'].price - data['Yew logs'].price; },                   num: 1750 },               'Yew shieldbow (u)': { ingredients: ['Yew logs'], lvl: 70, xp: 75, profit: function { return data['Yew shieldbow (u)'].price - data['Yew logs'].price; },                   num: 1750 },               'Magic shortbow (u)': { ingredients: ['Magic logs'], lvl: 80, xp: 83.3, profit: function { return data['Magic shortbow (u)'].price - data['Magic logs'].price; },                   num: 1750 },               'Magic shieldbow (u)': { ingredients: ['Magic logs'], lvl: 85, xp: 91.5, profit: function { return data['Magic shieldbow (u)'].price - data['Magic logs'].price; },                   num: 1750 },               'Shortbow': { ingredients: ['Shortbow (u)', 'Bowstring'], lvl: 1, xp: 5, profit: function { return data['Shortbow'].price - data['Shortbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Shieldbow': { ingredients: ['Shieldbow (u)', 'Bowstring'], lvl: 10, xp: 10, profit: function { return data['Shieldbow'].price - data['Shieldbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Oak shortbow': { ingredients: ['Oak shortbow (u)', 'Bowstring'], lvl: 20, xp: 16.5, profit: function { return data['Oak shortbow'].price - data['Oak shortbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Oak shieldbow': { ingredients: ['Oak shieldbow (u)', 'Bowstring'], lvl: 25, xp: 25, profit: function { return data['Oak shieldbow'].price - data['Oak shieldbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Willow shortbow': { ingredients: ['Willow shortbow (u)', 'Bowstring'], lvl: 35, xp: 33.25, profit: function { return data['Willow shortbow'].price - data['Willow shortbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Willow shieldbow': { ingredients: ['Willow shieldbow (u)', 'Bowstring'], lvl: 40, xp: 41.5, profit: function { return data['Willow shieldbow'].price - data['Willow shieldbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Maple shortbow': { ingredients: ['Maple shortbow (u)', 'Bowstring'], lvl: 50, xp: 50, profit: function { return data['Maple shortbow'].price - data['Maple shortbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Maple shieldbow': { ingredients: ['Maple shieldbow (u)', 'Bowstring'], lvl: 55, xp: 58.3, profit: function { return data['Maple shieldbow'].price - data['Maple shieldbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Yew shortbow': { ingredients: ['Yew shortbow (u)', 'Bowstring'], lvl: 65, xp: 67.5, profit: function { return data['Yew shortbow'].price - data['Yew shortbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Yew shieldbow': { ingredients: ['Yew shieldbow (u)', 'Bowstring'], lvl: 70, xp: 75, profit: function { return data['Yew shieldbow'].price - data['Yew shieldbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Magic shortbow': { ingredients: ['Magic shortbow (u)', 'Bowstring'], lvl: 80, xp: 83.3, profit: function { return data['Magic shortbow'].price - data['Magic shortbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Magic shieldbow': { ingredients: ['Magic shieldbow (u)', 'Bowstring'], lvl: 85, xp: 91.5, profit: function { return data['Magic shieldbow'].price - data['Magic shieldbow (u)'].price - data['Bowstring'].price; },                   num: 2520 },               'Wooden stock': { ingredients: ['Logs'], lvl: 9, xp: 6, profit: function { return data['Wooden stock'].price - data['Logs'].price; },                   num: 1750 },               'Oak stock': { ingredients: ['Oak logs'], lvl: 24, xp: 16, profit: function { return data['Oak stock'].price - data['Oak logs'].price; },                   num: 1750 },               'Willow stock': { ingredients: ['Willow logs'], lvl: 39, xp: 22, profit: function { return data['Willow stock'].price - data['Willow logs'].price; },                   num: 1750 },               'Teak stock': { ingredients: ['Teak logs'], lvl: 46, xp: 27, profit: function { return data['Teak stock'].price - data['Teak logs'].price; },                   num: 1750 },               'Maple stock': { ingredients: ['Maple logs'], lvl: 54, xp: 32, profit: function { return data['Maple stock'].price - data['Maple logs'].price; },                   num: 1750 },               'Mahogany stock': { ingredients: ['Mahogany logs'], lvl: 61, xp: 41, profit: function { return data['Mahogany stock'].price - data['Mahogany logs'].price; },                   num: 1750 },               'Yew stock': { ingredients: ['Yew logs'], lvl: 69, xp: 50, profit: function { return data['Yew stock'].price - data['Yew logs'].price; },                   num: 1750 },               'Magic stock': { ingredients: ['Magic logs'], lvl: 94, xp: 100, profit: function { return data['Magic stock'].price - data['Magic logs'].price; },                   num: 1750 },               'Bronze c'bow (u)': { ingredients: ['Bronze limbs', 'Wooden stock'], lvl: 9, xp: 12, profit: function { return data['Bronze c'bow (u)'].price - data['Bronze limbs'].price - data['Wooden stock'].price; },                   num: 2000 },               'Iron c'bow (u)': { ingredients: ['Iron limbs', 'Willow stock'], lvl: 39, xp: 44, profit: function { return data['Iron c'bow (u)'].price - data['Iron limbs'].price - data['Willow stock'].price; },                   num: 2000 },               'Steel c'bow (u)': { ingredients: ['Steel limbs', 'Teak stock'], lvl: 46, xp: 54, profit: function { return data['Steel c'bow (u)'].price - data['Steel limbs'].price - data['Teak stock'].price; },                   num: 2000 },               'Mithril c'bow (u)': { ingredients: ['Mithril limbs', 'Maple stock'], lvl: 54, xp: 64, profit: function { return data['Mithril c'bow (u)'].price - data['Mithril limbs'].price - data['Maple stock'].price; },                   num: 2000 },               'Adamant c'bow (u)': { ingredients: ['Adamantite limbs', 'Mahogany stock'], lvl: 61, xp: 82, profit: function { return data['Adamant c'bow (u)'].price - data['Adamantite limbs'].price - data['Mahogany stock'].price; },                   num: 2000 },               'Runite c'bow (u)': { ingredients: ['Runite limbs', 'Yew stock'], lvl: 69, xp: 100, profit: function { return data['Runite c'bow (u)'].price - data['Runite limbs'].price - data['Yew stock'].price; },                   num: 2000 },               'Dragon c'bow (u)': { ingredients: ['Dragon limbs', 'Magic stock'], lvl: 94, xp: 200, profit: function { return data['Dragon c'bow (u)'].price - data['Dragon limbs'].price - data['Magic stock'].price; },                   num: 2000 },               'Bronze crossbow': { ingredients: ['Bronze c'bow (u)', 'Crossbow string'], lvl: 9, xp: 6, profit: function { return data['Bronze crossbow'].price - data['Bronze c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand bronze crossbow': { ingredients: ['Bronze c'bow (u)', 'Crossbow string'], lvl: 9, xp: 6, profit: function { return data['Off-hand bronze crossbow'].price - data['Bronze c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Bronze 2h crossbow': { ingredients: ['Bronze c'bow (u)', 'Crossbow string'], lvl: 9, xp: 6, profit: function { return data['Bronze 2h crossbow'].price - data['Bronze c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Iron crossbow': { ingredients: ['Iron c'bow (u)', 'Crossbow string'], lvl: 24, xp: 16, profit: function { return data['Iron crossbow'].price - data['Iron c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand iron crossbow': { ingredients: ['Iron c'bow (u)', 'Crossbow string'], lvl: 24, xp: 16, profit: function { return data['Off-hand iron crossbow'].price - data['Iron c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Iron 2h crossbow': { ingredients: ['Iron c'bow (u)', 'Crossbow string'], lvl: 24, xp: 16, profit: function { return data['Iron 2h crossbow'].price - data['Iron c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Steel crossbow': { ingredients: ['Steel c'bow (u)', 'Crossbow string'], lvl: 39, xp: 22, profit: function { return data['Steel crossbow'].price - data['Steel c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand steel crossbow': { ingredients: ['Steel c'bow (u)', 'Crossbow string'], lvl: 39, xp: 22, profit: function { return data['Off-hand steel crossbow'].price - data['Steel c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Steel 2h crossbow': { ingredients: ['Steel c'bow (u)', 'Crossbow string'], lvl: 39, xp: 22, profit: function { return data['Steel 2h crossbow'].price - data['Steel c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Mith crossbow': { ingredients: ['Mithril c'bow (u)', 'Crossbow string'], lvl: 54, xp: 32, profit: function { return data['Mith crossbow'].price - data['Mithril c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand mithril crossbow': { ingredients: ['Mithril c'bow (u)', 'Crossbow string'], lvl: 54, xp: 32, profit: function { return data['Off-hand mithril crossbow'].price - data['Mithril c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Mithril 2h crossbow': { ingredients: ['Mithril c'bow (u)', 'Crossbow string'], lvl: 54, xp: 32, profit: function { return data['Mithril 2h crossbow'].price - data['Mithril c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Adamant crossbow': { ingredients: ['Adamant c'bow (u)', 'Crossbow string'], lvl: 61, xp: 41, profit: function { return data['Adamant crossbow'].price - data['Adamant c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand adamant crossbow': { ingredients: ['Adamant c'bow (u)', 'Crossbow string'], lvl: 61, xp: 41, profit: function { return data['Off-hand adamant crossbow'].price - data['Adamant c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Adamant 2h crossbow': { ingredients: ['Adamant c'bow (u)', 'Crossbow string'], lvl: 61, xp: 41, profit: function { return data['Adamant 2h crossbow'].price - data['Adamant c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Rune crossbow': { ingredients: ['Runite c'bow (u)', 'Crossbow string'], lvl: 69, xp: 50, profit: function { return data['Rune crossbow'].price - data['Runite c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand rune crossbow': { ingredients: ['Runite c'bow (u)', 'Crossbow string'], lvl: 69, xp: 50, profit: function { return data['Off-hand rune crossbow'].price - data['Runite c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Rune 2h crossbow': { ingredients: ['Runite c'bow (u)', 'Crossbow string'], lvl: 69, xp: 50, profit: function { return data['Rune 2h crossbow'].price - data['Runite c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Dragon crossbow': { ingredients: ['Dragon c'bow (u)', 'Crossbow string'], lvl: 94, xp: 100, profit: function { return data['Dragon crossbow'].price - data['Dragon c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Off-hand dragon crossbow': { ingredients: ['Dragon c'bow (u)', 'Crossbow string'], lvl: 94, xp: 100, profit: function { return data['Off-hand dragon crossbow'].price - data['Dragon c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Dragon 2h crossbow': { ingredients: ['Dragon c'bow (u)', 'Crossbow string'], lvl: 94, xp: 100, profit: function { return data['Dragon 2h crossbow'].price - data['Dragon c'bow (u)'].price - data['Crossbow string'].price; },                   num: 2000 },               'Bronze bolts': { ingredients: ['Bronze bolts (unf)', 'Feather'], lvl: 9, xp: 0.5, profit: function { return data['Bronze bolts'].price - data['Bronze bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Iron bolts': { ingredients: ['Iron bolts (unf)', 'Feather'], lvl: 19, xp: 1.5, profit: function { return data['Iron bolts'].price - data['Iron bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Silver bolts': { ingredients: ['Silver bolts (unf)', 'Feather'], lvl: 43, xp: 2.5, profit: function { return data['Silver bolts'].price - data['Silver bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Steel bolts': { ingredients: ['Steel bolts (unf)', 'Feather'], lvl: 46, xp: 3.5, profit: function { return data['Steel bolts'].price - data['Steel bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Mithril bolts': { ingredients: ['Mithril bolts (unf)', 'Feather'], lvl: 54, xp: 5, profit: function { return data['Mithril bolts'].price - data['Mithril bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Broad-tipped bolts': { ingredients: ['Unfinished broad bolts', 'Feather'], lvl: 55, xp: 3, profit: function { return data['Broad-tipped bolts'].price - data['Unfinished broad bolts'].price - data['Feather'].price; },                   num: 50000 },               'Adamant bolts': { ingredients: ['Adamant bolts (unf)', 'Feather'], lvl: 61, xp: 7, profit: function { return data['Adamant bolts'].price - data['Adamant bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Runite bolts': { ingredients: ['Runite bolts (unf)', 'Feather'], lvl: 69, xp: 10, profit: function { return data['Runite bolts'].price - data['Runite bolts (unf)'].price - data['Feather'].price; },                   num: 50000 },               'Opal bolts': { ingredients: ['Opal bolt tips', 'Bronze bolts'], lvl: 11, xp: 1.6, profit: function { return data['Opal bolts'].price - data['Opal bolt tips'].price - data['Bronze bolts'].price; },                   num: 25000 },               'Pearl bolts': { ingredients: ['Pearl bolt tips', 'Iron bolts'], lvl: 41, xp: 3.2, profit: function { return data['Pearl bolts'].price - data['Pearl bolt tips'].price - data['Iron bolts'].price; },                   num: 25000 },               'Topaz bolts': { ingredients: ['Topaz bolt tips', 'Steel bolts'], lvl: 48, xp: 3.9, profit: function { return data['Topaz bolts'].price - data['Topaz bolt tips'].price - data['Steel bolts'].price; },                   num: 25000 },               'Barbed bolts': { ingredients: ['Barb bolt tips', 'Bronze bolts'], lvl: 51, xp: 9.5, profit: function { return data['Barbed bolts'].price - data['Barb bolttips'].price - data['Bronze bolts'].price; },                   num: 25000 },               'Sapphire bolts': { ingredients: ['Sapphire bolt tips', 'Mithril bolts'], lvl: 56, xp: 4.7, profit: function { return data['Sapphire bolts'].price - data['Sapphire bolt tips'].price - data['Mithril bolts'].price; },                   num: 25000 },               'Emerald bolts': { ingredients: ['Emerald bolt tips', 'Mithril bolts'], lvl: 58, xp: 5.5, profit: function { return data['Emerald bolts'].price - data['Emerald bolt tips'].price - data['Mithril bolts'].price; },                   num: 25000 },               'Ruby bolts': { ingredients: ['Ruby bolt tips', 'Adamant bolts'], lvl: 63, xp: 6.3, profit: function { return data['Ruby bolts'].price - data['Ruby bolt tips'].price - data['Adamant bolts'].price; },                   num: 25000 },               'Diamond bolts': { ingredients: ['Diamond bolt tips', 'Adamant bolts'], lvl: 65, xp: 7, profit: function { return data['Diamond bolts'].price - data['Diamond bolt tips'].price - data['Adamant bolts'].price; },                   num: 25000 },               'Dragon bolts': { ingredients: ['Dragon bolt tips', 'Runite bolts'], lvl: 71, xp: 8.2, profit: function { return data['Dragon bolts'].price - data['Dragon bolt tips'].price - data['Runite bolts'].price; },                   num: 25000 },               'Onyx bolts': { ingredients: ['Onyx bolt tips', 'Runite bolts'], lvl: 73, xp: 9.4, profit: function { return data['Onyx bolts'].price - data['Onyx bolt tips'].price - data['Runite bolts'].price; },                   num: 25000 },               'Ascension bolts': { ingredients: ['Ascension shard'], lvl: 90, xp: 20, profit: function { return data['Ascension bolts'].price - data['Ascension shard'].price; },                   num: 18000 },               'Opal bolt tips': { ingredients: ['Opal'], lvl: 11, xp: 1.6, profit: function { return data['Opal bolt tips'].price - data['Opal'].price /1; },                   num: 17280 },               'Jade bolt tips': { ingredients: ['Jade'], lvl: 26, xp: 2.4, profit: function { return data['Jade bolt tips'].price - data['Jade'].price /1; },                   num: 17280 },               'Pearl bolt tips': { ingredients: ['Oyster pearl'], lvl: 41, xp: 3.2, profit: function { return data['Pearl bolt tips'].price - data['Oyster pearl'].price /; },                   num: 17280 },               'Pearl bolt tips': { ingredients: ['Oyster pearls'], lvl: 41, xp: 3.2, profit: function { return data['Pearl bolt tips'].price - data['Oyster pearls'].price /2; },                   num: 17280 },               'Topaz bolt tips': { ingredients: ['Red topaz'], lvl: 48, xp: 3.9, profit: function { return data['Topaz bolt tips'].price - data['Red topaz'].price /1; },                   num: 17280 },               'Sapphire bolt tips': { ingredients: ['Sapphire'], lvl: 56, xp: 4.7, profit: function { return data['Sapphire bolt tips'].price - data['Sapphire'].price /1; },                   num: 17280 },               'Emerald bolt tips': { ingredients: ['Emerald'], lvl: 58, xp: 5.5, profit: function { return data['Emerald bolt tips'].price - data['Emerald'].price /1; },                   num: 17280 },               'Ruby bolt tips': { ingredients: ['Ruby'], lvl: 63, xp: 6.3, profit: function { return data['Ruby bolt tips'].price - data['Ruby'].price /1; },                   num: 17280 },               'Diamond bolt tips': { ingredients: ['Diamond'], lvl: 65, xp: 7, profit: function { return data['Diamond bolt tips'].price - data['Diamond'].price /1; },                   num: 17280 },               'Dragon bolt tips': { ingredients: ['Dragonstone'], lvl: 71, xp: 8.2, profit: function { return data['Dragon bolt tips'].price - data['Dragonstone'].price /1; },                   num: 17280 },               'Onyx bolt tips': { ingredients: ['Onyx'], lvl: 73, xp: 9.4, profit: function { return data['Onyx bolt tips'].price - data['Onyx'].price /1; },                   num: 17280 },               'Bronze brutal': { ingredients: ['Flighted ogre arrow', 'Bronze nails'], lvl: 7, xp: 1.4, profit: function { return data['Bronze brutal'].price - data['Flighted ogre arrow'].price - data['Bronze nails'].price; },                   num: 15000 },               'Iron brutal': { ingredients: ['Flighted ogre arrow', 'Iron nails'], lvl: 18, xp: 2.6, profit: function { return data['Iron brutal'].price - data['Flighted ogre arrow'].price - data['Iron nails'].price; },                   num: 15000 },               'Steel brutal': { ingredients: ['Flighted ogre arrow', 'Steel nails'], lvl: 33, xp: 5.1, profit: function { return data['Steel brutal'].price - data['Flighted ogre arrow'].price - data['Steel nails'].price; },                   num: 15000 },               'Black brutal': { ingredients: ['Flighted ogre arrow', 'Black nails'], lvl: 38, xp: 6.4, profit: function { return data['Black brutal'].price - data['Flighted ogre arrow'].price - data['Black nails'].price; },                   num: 15000 },               'Mithril brutal': { ingredients: ['Flighted ogre arrow', 'Mithril nails'], lvl: 49, xp: 7.5, profit: function { return data['Mithril brutal'].price - data['Flighted ogre arrow'].price - data['Mithril nails'].price; },                   num: 15000 },               'Adamant brutal': { ingredients: ['Flighted ogre arrow', 'Adamantite nails'], lvl: 62, xp: 10.1, profit: function { return data['Adamant brutal'].price - data['Flighted ogre arrow'].price - data['Adamantite nails'].price; },                   num: 15000 },               'Rune brutal': { ingredients: ['Flighted ogre arrow', 'Rune nails'], lvl: 77, xp: 12.5, profit: function { return data['Rune brutal'].price - data['Flighted ogre arrow'].price - data['Rune nails'].price; },                   num: 15000 },           },            // this is out ingredients object // by default each entry is an empty object which is filled out when the script runs // some entries here are duplicates of the data object // but there's negligible performance difference, so don't worry ing = { 'Arrow shaft': {}, 'Logs': {}, 'Headless arrow': {}, 'Feather': {}, 'Bronze arrow': {}, 'Bronze arrowheads': {}, 'Iron arrow': {}, 'Iron arrowheads': {}, 'Steel arrow': {}, 'Steel arrowheads': {}, 'Mithril arrow': {}, 'Mithril arrowheads': {}, 'Broad arrowheads': {}, 'Adamant arrow': {}, 'Adamant arrowheads': {}, 'Rune arrow': {}, 'Rune arrowheads': {}, 'Dragon arrow': {}, 'Dragon arrowheads': {}, 'Bronze dart': {}, 'Bronze dart tip': {}, 'Off-hand bronze dart': {}, 'Iron dart': {}, 'Iron dart tip': {}, 'Off-hand iron dart': {}, 'Steel dart': {}, 'Steel dart tip': {}, 'Off-hand steel dart': {}, 'Mithril dart': {}, 'Mithril dart tip': {}, 'Off-hand mithril dart': {}, 'Adamant dart': {}, 'Adamant dart tip': {}, 'Off-hand adamant dart': {}, 'Rune dart': {}, 'Rune dart tip': {}, 'Off-hand rune dart': {}, 'Dragon dart': {}, 'Dragon dart tip': {}, 'Off-hand dragon dart': {}, 'Shortbow (u)': {}, 'Shieldbow (u)': {}, 'Oak shortbow (u)': {}, 'Oak logs': {}, 'Oak shieldbow (u)': {}, 'Willow shortbow (u)': {}, 'Willow logs': {}, 'Willow shieldbow (u)': {}, 'Maple shortbow (u)': {}, 'Maple logs': {}, 'Maple shieldbow (u)': {}, 'Yew shortbow (u)': {}, 'Yew logs': {}, 'Yew shieldbow (u)': {}, 'Magic shortbow (u)': {}, 'Magic logs': {}, 'Magic shieldbow (u)': {}, 'Shortbow': {}, 'Bowstring': {}, 'Shieldbow': {}, 'Oak shortbow': {}, 'Oak shieldbow': {}, 'Willow shortbow': {}, 'Willow shieldbow': {}, 'Maple shortbow': {}, 'Maple shieldbow': {}, 'Yew shortbow': {}, 'Yew shieldbow': {}, 'Magic shortbow': {}, 'Magic shieldbow': {}, 'Wooden stock': {}, 'Oak stock': {}, 'Willow stock': {}, 'Teak stock': {}, 'Teak logs': {}, 'Maple stock': {}, 'Mahogany stock': {}, 'Mahogany logs': {}, 'Yew stock': {}, 'Magic stock': {}, 'Bronze c'bow (u)': {}, 'Bronze limbs': {}, 'Iron c'bow (u)': {}, 'Iron limbs': {}, 'Steel c'bow (u)': {}, 'Steel limbs': {}, 'Mithril c'bow (u)': {}, 'Mithril limbs': {}, 'Adamant c'bow (u)': {}, 'Adamantite limbs': {}, 'Runite c'bow (u)': {}, 'Runite limbs': {}, 'Dragon c'bow (u)': {}, 'Dragon limbs': {}, 'Bronze crossbow': {}, 'Crossbow string': {}, 'Off-hand bronze crossbow': {}, 'Bronze 2h crossbow': {}, 'Iron crossbow': {}, 'Off-hand iron crossbow': {}, 'Iron 2h crossbow': {}, 'Steel crossbow': {}, 'Off-hand steel crossbow': {}, 'Steel 2h crossbow': {}, 'Mith crossbow': {}, 'Off-hand mithril crossbow': {}, 'Mithril 2h crossbow': {}, 'Adamant crossbow': {}, 'Off-hand adamant crossbow': {}, 'Adamant 2h crossbow': {}, 'Rune crossbow': {}, 'Off-hand rune crossbow': {}, 'Rune 2h crossbow': {}, 'Dragon crossbow': {}, 'Off-hand dragon crossbow': {}, 'Dragon 2h crossbow': {}, 'Bronze bolts': {}, 'Bronze bolts (unf)': {}, 'Iron bolts': {}, 'Iron bolts (unf)': {}, 'Silver bolts': {}, 'Silver bolts (unf)': {}, 'Steel bolts': {}, 'Steel bolts (unf)': {}, 'Mithril bolts': {}, 'Mithril bolts (unf)': {}, 'Broad-tipped bolts': {}, 'Unfinished broad bolts': {}, 'Adamant bolts': {}, 'Adamant bolts (unf)': {}, 'Runite bolts': {}, 'Runite bolts (unf)': {}, 'Opal bolts': {}, 'Opal bolt tips': {}, 'Pearl bolts': {}, 'Pearl bolt tips': {}, 'Topaz bolts': {}, 'Topaz bolt tips': {}, 'Barbed bolts': {}, 'Barb bolttips': {}, 'Sapphire bolts': {}, 'Sapphire bolt tips': {}, 'Emerald bolts': {}, 'Emerald bolt tips': {}, 'Ruby bolts': {}, 'Ruby bolt tips': {}, 'Diamond bolts': {}, 'Diamond bolt tips': {}, 'Dragon bolts': {}, 'Dragon bolt tips': {}, 'Onyx bolts': {}, 'Onyx bolt tips': {}, 'Ascension bolts': {}, 'Ascension shard': {}, 'Opal': {}, 'Jade bolt tips': {}, 'Jade': {}, 'Oyster pearl': {}, 'Oyster pearls': {}, 'Red topaz': {}, 'Sapphire': {}, 'Emerald': {}, 'Ruby': {}, 'Diamond': {}, 'Dragonstone': {}, 'Onyx': {}, 'Bronze brutal': {}, 'Flighted ogre arrow': {}, 'Bronze nails': {}, 'Iron brutal': {}, 'Iron nails': {}, 'Steel brutal': {}, 'Steel nails': {}, 'Black brutal': {}, 'Black nails': {}, 'Mithril brutal': {}, 'Mithril nails': {}, 'Adamant brutal': {}, 'Adamantite nails': {}, 'Rune brutal': {}, 'Rune nails': {}, 'Broad arrow': {}, };

/**        * Fills out price and image keys in data * Fills out price keys in ing */       function getData {

$( '#efficiency-data>tbody>tr' ).each( function {

var $td = $( this ).children( 'td' ), key, price, img;

$td.each( function ( i ) {                   if ( i === 0 ) {                        key = $( this ).text.trim;                    } else if ( i === 1 ) {                        price = $( this ).text.trim;                    } else if ( i === 2 ) {                        img = $( this ).children( 'a' ).attr( 'href' );                    }                } ); data[key].price = parseInt( price, 10 ); data[key].image = '';

} );           $( '#efficiency-ingredients>tbody>tr' ).each( function  {

var $td = $( this ).children( 'td' ), key, price;

$td.each( function ( i ) {                   if ( i === 0 ) {                        key = $( this ).text.trim;                    } else if ( i === 1 ) {                        price = $( this ).text.trim;                    }                } );

ing[key].price = parseInt( price, 10 );

} );

}

/**        *         */        function throwError( text ) {

var $result = $( '#fletching-result' ); $result.empty; $result.append(               $( ' ' )                    .css( 'background', '#f00' )                    .text( text )            );

return false;

}

/**        *         */        function checkMods {

err = false;

money = $( '#fletching-form-income' ).val .replace( /,/g, '' );

// check money is an integer if ( money !== '' + parseInt( money, 10 ) ) { throwError( 'Income must be an integer.' ); err = true; return; }

money = parseInt( money, 10 );

}

/**        *         */        function generate {

var $result = $( '#fletching-result' ), text = '', i,               j,                item, info, eff;

checkMods;

if ( err ) { console.log( 'error' ); return false; }

console.log( 'continue' );

text += ' ';

$result.html( text );

mw.loader.using( 'jquery.tablesorter', function {                $( '#fletching-table' ).tablesorter;                rswiki.common.autosort;            } );

return false; }

/**        *         */        function buildForm {

var $form = $( '#fletching-form' ); $form.empty; $form.append(               $( ' ' )                    .on( 'submit', generate )                    .attr( { action: '#', id: 'fletching-form-inner' } )                   .append( $( ' ' )                           .attr( {                                class: 'wikitable'                            } ) .append(                               $( ' ' )                                    .append( $( ' ' )                                           .append(                                                $( ' ' )                                                    .append( $( ' ' )                                                           .attr( 'for', 'fletching-form-income' ) .text( 'Income' ) ),                                               $( ' ' )                                                    .append( $( ' ' )                                                           .attr( {                                                                type: 'text',                                                                id: 'fletching-form-income',                                                                value: '500000'                                                            } ) )                                           ),                                        $( ' ' )                                            .append(                                                $( ' ' )                                                    .append( $( ' ' )                                                           .attr( 'for', 'fletching-form-scroll' ) .text( 'Scroll of cleansing?' ) ),                                               $( ' ' )                                                    .append( $( ' ' )                                                           .attr( {                                                                type: 'checkbox',                                                                id: 'fletching-form-scroll'                                                            } ) )                                           ),                                        $( ' ' )                                            .append(                                                $( ' ' )                                                    .append( $( ' ' )                                                           .attr( 'for', 'fletching-form-outfit' ) .text( 'Factory outfit?' ) ),                                               $( ' ' )                                                    .append( $( ' ' )                                                           .attr( 'id', 'fletching-form-outfit' ) .append(                                                               $( ' ' )                                                                    .attr( 'value', '0' )                                                                    .text( '0 pieces' ),                                                                $( ' ' )                                                                    .attr( 'value', '3' )                                                                    .text( '3 pieces' ),                                                                $( ' ' )                                                                    .attr( 'value', '5' )                                                                    .text( '5 pieces' )                                                            ) )                                           ),                                        $( ' ' )                                            .append(                                                $( ' ' )                                                    .append( $( ' ' )                                                           .attr( 'for', 'fletching-form-mory' ) .text( 'Elite Morytania Tasks?' ) ),                                               $( ' ' )                                                    .append( $( ' ' )                                                           .attr( {                                                                type: 'checkbox',                                                                id: 'fletching-form-mory'                                                            } ) )                                           ),                                        $( ' ' )                                            .append(                                                $( ' ' )                                                    .append( $( ' ' )                                                           .attr( 'for', 'fletching-form-desert' ) .text( 'Desert amulet 4 equipped?' ) ),                                               $( ' ' )                                                    .append( $( ' ' )                                                           .attr( {                                                                type: 'checkbox',                                                                id: 'fletching-form-desert'                                                            } ) )                                           ),                                        $( ' ' )                                            .append(                                                $( ' ' )                                                    .css( 'text-align', 'center' )                                                    .attr( 'colspan', '2' )                                                    .append( $( ' ' )                                                           .attr( {                                                                type: 'submit',                                                                value: 'Submit'                                                            } ) )                                           )                                    )                            )                    )            );

generate;

}

getData; console.log( ing, data );

return { build: buildForm };

} );

$( rswiki.efficiency.fletching.build );

} ( this.jQuery, this.mediaWiki, this.rswiki = this.rswiki || {} ) );