MediaWiki:Gadget-armory-core.js: Difference between revisions
Created page with "//<nowiki> 'use strict'; var queryDefaults = { slot: 'armor', tradeable: 'any', cbclass: 'any', restriction: 'surface', hiderecolour: true, tier_min: 100, tier_max: 50..." |
No edit summary |
||
| (13 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
var queryDefaults = { | var queryDefaults = { | ||
slot: 'armor', | slot: 'armor', | ||
supporter: 'any', | |||
tradeable: 'any', | tradeable: 'any', | ||
modclass: 'any', | |||
restriction: 'surface', | restriction: 'surface', | ||
augmented: 'any', | |||
tier_min: 100, | tier_min: 100, | ||
tier_max: 500, | tier_max: 500, | ||
| Line 15: | Line 16: | ||
}, | }, | ||
queryMap = { | queryMap = { | ||
slot: [ ' | slot: [ 'armor', 'shields', 'weapons', 'sensors', 'engines', 'utility' ], | ||
supporter: [ 'any', 'yes', 'no' ], | |||
tradeable: [ 'any', 'yes', 'no' ], | tradeable: [ 'any', 'yes', 'no' ], | ||
modclass: [ 'any', 'Armor', 'Attack', 'Cargo Salvage', 'Cargo Scanner', 'Cargo Shielding', 'Cargo Space', 'Damage', 'Damage Reduction', 'Damage Reflection', 'Defense', 'Engine Efficiency', 'Evasion', 'Hacking', 'Heat Resistance', 'Intel', 'Salvage Chance', 'Sensor Scan Results', 'Shield', 'Shield Boost', 'Shield Recharge', 'Targeting', 'Threat', 'Weapon Recharge' ], | |||
restriction: [ 'any', 'surface', ' | restriction: [ 'any', 'surface', 'stories', 'missions', 'encounters', 'outlands', 'events', 'removed' ], | ||
augmented: [ 'any', 'able', 'yes' ], | augmented: [ 'any', 'able', 'yes' ], | ||
}, | }, | ||
currentQuery, | currentQuery, | ||
| Line 26: | Line 27: | ||
loadingGif; | loadingGif; | ||
var form, fieldset, slotDropdown, | var form, fieldset, slotDropdown, supporterSelect, tradeableSelect, classSelect, restrictionSelect, augmentedSelect, tierMinCheck, tierMaxCheck, tierMinSelect, tierMaxSelect, submitButton, resetButton, toggleAdvButton, copyPermalinkButton, pageButtons, pageFirstButton, pagePrevButton, pageNextButton, resultsLabel; | ||
var $messages, $results, $selector; | var $messages, $results, $selector; | ||
| Line 38: | Line 39: | ||
query.push(Math.max(0,queryMap.slot.indexOf(q.slot))); | query.push(Math.max(0,queryMap.slot.indexOf(q.slot))); | ||
query.push('c'); | query.push('c'); | ||
query.push(Math.max(0,queryMap. | query.push(Math.max(0,queryMap.modclass.indexOf(q.modclass))); | ||
query.push('m'); | query.push('m'); | ||
query.push(Math.max(0,queryMap. | query.push(Math.max(0,queryMap.supporter.indexOf(q.supporter))); | ||
query.push('t'); | query.push('t'); | ||
query.push(Math.max(0,queryMap.tradeable.indexOf(q.tradeable))); | query.push(Math.max(0,queryMap.tradeable.indexOf(q.tradeable))); | ||
| Line 48: | Line 49: | ||
//query.push(Math.max(0,queryMap.augmented.indexOf(q.augmented))); | //query.push(Math.max(0,queryMap.augmented.indexOf(q.augmented))); | ||
query.push('o'); | query.push('o'); | ||
if (q.tier_min_enabled) { | if (q.tier_min_enabled) { | ||
query.push('l'); | query.push('l'); | ||
| Line 76: | Line 76: | ||
align: 'left' | align: 'left' | ||
}); | }); | ||
//supporterhip | |||
supporterSelect = new OO.ui.ButtonSelectWidget({ | |||
items: [ | |||
new OO.ui.ButtonOptionWidget({ data: 'any', label: 'Any'}), | |||
], | |||
align: 'left' | |||
}); | |||
supporterSelect.selectItemByData(params.supporter); | |||
//tradeable | //tradeable | ||
| Line 94: | Line 103: | ||
items: [ | items: [ | ||
new OO.ui.ButtonOptionWidget({ data: 'any', label: 'Any', title: 'Any class' }), | new OO.ui.ButtonOptionWidget({ data: 'any', label: 'Any', title: 'Any class' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'armor', label: 'Armor' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'attack', label: 'Attack' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'cargo salvage', label: 'Cargo Salvage' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'cargo scanner', label: 'Cargo Scanner' }), | ||
new OO.ui.ButtonOptionWidget({ data: 'cargo shielding', label: 'Cargo Shielding' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'damage', label: 'Damage' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'damage reduction', label: 'Damage Reduction' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'damage reflection', label: 'Damage Reflection' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'defense', label: 'Defense' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'engine efficiency', label: 'Engine Efficiency' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'evasion', label: 'Evasion' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'hacking', label: 'Hacking' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'heat resistance', label: 'Heat Resistance' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'intel', label: 'Intel' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'salvage chance', label: 'Salvage Chance' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'sensor scan results', label: 'Sensor Scan Results' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'shield', label: 'Shield' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'shield boost', label: 'Shield Boost' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'shield recharge', label: 'Shield Recharge' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'targeting', label: 'Targeting' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'threat', label: 'Threat' }), | |||
new OO.ui.ButtonOptionWidget({ data: 'weapon recharge', label: 'Weapon Recharge' }), | |||
], | ], | ||
align: 'left' | align: 'left' | ||
}); | }); | ||
classSelect.selectItemByData(params. | classSelect.selectItemByData(params.modclass); | ||
//TODO surface | //TODO surface | ||
| Line 109: | Line 136: | ||
new OO.ui.ButtonOptionWidget({ data: 'any', label: 'Any', title: 'Everything' }), | new OO.ui.ButtonOptionWidget({ data: 'any', label: 'Any', title: 'Everything' }), | ||
new OO.ui.ButtonOptionWidget({ data: 'surface', label: 'Unrestricted', title: 'Items that are not restricted' }), | new OO.ui.ButtonOptionWidget({ data: 'surface', label: 'Unrestricted', title: 'Items that are not restricted' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'stories', label: 'Stories', title: 'Items only available from Story completions' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'missions', label: 'Missions', title: 'Items only available from Mission completions' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'encounters', label: 'Encounters', title: 'Items only available from Encounter completions' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'outlands', label: 'Outlands', title: 'Items only available from Outlands' }), | ||
new OO.ui.ButtonOptionWidget({ data: ' | new OO.ui.ButtonOptionWidget({ data: 'events', label: 'Events', title: 'Items only available from Gemini Station Events' }), | ||
] | ] | ||
}); | }); | ||
restrictionSelect.selectItemByData(params.restriction); | restrictionSelect.selectItemByData(params.restriction); | ||
//Augmentation | //Augmentation | ||
/* | /* | ||
| Line 156: | Line 180: | ||
//tierMax | //tierMax | ||
tierMaxSelect = new OO.ui.NumberInputWidget({ | tierMaxSelect = new OO.ui.NumberInputWidget({ | ||
min: | min: 0, | ||
max: 500, | max: 500, | ||
value: params.tier_max, | value: params.tier_max, | ||
| Line 184: | Line 208: | ||
//don't reset slot | //don't reset slot | ||
tradeableSelect.selectItemByData(queryDefaults.tradeable); | tradeableSelect.selectItemByData(queryDefaults.tradeable); | ||
supporterSelect.selectItemByData(queryDefaults.supporter); | |||
classSelect.selectItemByData(queryDefaults. | classSelect.selectItemByData(queryDefaults.modclass); | ||
restrictionSelect.selectItemByData(queryDefaults.restriction); | restrictionSelect.selectItemByData(queryDefaults.restriction); | ||
//augmentedSelect.selectItemByData(queryDefaults.augmented); | //augmentedSelect.selectItemByData(queryDefaults.augmented); | ||
| Line 269: | Line 293: | ||
//fieldset | //fieldset | ||
fieldset = new OO.ui.FieldsetLayout({ | fieldset = new OO.ui.FieldsetLayout({ | ||
label: ' | label: 'Armory search', | ||
id: ' | id: 'armoryFilterSelector' | ||
}); | }); | ||
| Line 277: | Line 301: | ||
new OO.ui.FieldLayout(slotDropdown, { label: 'Slot', align: 'left' }), | new OO.ui.FieldLayout(slotDropdown, { label: 'Slot', align: 'left' }), | ||
new OO.ui.FieldLayout(classSelect, { label: 'Class', align: 'left' }), | new OO.ui.FieldLayout(classSelect, { label: 'Class', align: 'left' }), | ||
new OO.ui.FieldLayout( | new OO.ui.FieldLayout(supporterSelect, { label: 'Supporter', align: 'left' }), | ||
new OO.ui.FieldLayout(tradeableSelect, { label: 'Tradeability', align: 'left' }), | new OO.ui.FieldLayout(tradeableSelect, { label: 'Tradeability', align: 'left' }), | ||
new OO.ui.FieldLayout(restrictionSelect, { label: 'Restriction', align: 'left' }), | new OO.ui.FieldLayout(restrictionSelect, { label: 'Restriction', align: 'left' }), | ||
//new OO.ui.FieldLayout(augmentedSelect, { label: 'Augmentation', align: 'left' }), | //new OO.ui.FieldLayout(augmentedSelect, { label: 'Augmentation', align: 'left' }), | ||
new OO.ui.LabelWidget({label: 'Tier filters', classes: ['armory-tier-label']}), | |||
new OO.ui.LabelWidget({label: 'Tier filters', classes: [' | |||
new OO.ui.HorizontalLayout({ | new OO.ui.HorizontalLayout({ | ||
items: [ | items: [ | ||
| Line 314: | Line 337: | ||
val = classSelect.findSelectedItem(); | val = classSelect.findSelectedItem(); | ||
if (val !== null) { | if (val !== null) { | ||
values. | values.modclass = val.getData(); | ||
} | } | ||
val = | val = supporterSelect.findSelectedItem(); | ||
if (val !== null) { | if (val !== null) { | ||
values. | values.supporter = val.getData(); | ||
} | } | ||
| Line 336: | Line 359: | ||
values.augmented = val.getData(); | values.augmented = val.getData(); | ||
}*/ | }*/ | ||
values.tier_min_enabled = tierMinCheck.isSelected(); | values.tier_min_enabled = tierMinCheck.isSelected(); | ||
| Line 368: | Line 390: | ||
switch (letter) { | switch (letter) { | ||
case 's': assignTo('slot', number); break; | case 's': assignTo('slot', number); break; | ||
case 'c': assignTo(' | case 'c': assignTo('modclass', number); break; | ||
case 'm': assignTo(' | case 'm': assignTo('supporter', number); break; | ||
case 't': assignTo('tradeable', number); break; | case 't': assignTo('tradeable', number); break; | ||
case 'r': assignTo('restriction', number); break; | case 'r': assignTo('restriction', number); break; | ||
| Line 399: | Line 421: | ||
} | } | ||
var template = [ | var template = [ | ||
'{{ | '{{Armory', | ||
'|slot='+params.slot, | '|slot='+params.slot, | ||
'| | '|modclass='+params.modclass, | ||
'| | '|supporter='+params.supporter, | ||
'|tradeable='+params.tradeable, | '|tradeable='+params.tradeable, | ||
'|restriction='+params.restriction, | '|restriction='+params.restriction, | ||
//'|augmented='+params.augmented, | //'|augmented='+params.augmented, | ||
'|tier_min='+tierMin, | '|tier_min='+tierMin, | ||
'|tier_max='+tierMax, | '|tier_max='+tierMax, | ||
| Line 469: | Line 490: | ||
page: 0 | page: 0 | ||
}, | }, | ||
table = $results.find('table. | table = $results.find('table.armory'); | ||
resultsLabel.setLabel(''); | resultsLabel.setLabel(''); | ||
| Line 483: | Line 504: | ||
if (mw.config.get('skin') !== 'minerva') { | if (mw.config.get('skin') !== 'minerva') { | ||
mw.loader.using('jquery.tablesorter', function(){ | mw.loader.using('jquery.tablesorter', function(){ | ||
$results.find('table. | $results.find('table.armory.sortable').tablesorter(); | ||
}); | }); | ||
} | } | ||
| Line 498: | Line 519: | ||
var uri = new mw.Uri(); | var uri = new mw.Uri(); | ||
var search = false, parsed; | var search = false, parsed; | ||
loadingGif = $('# | loadingGif = $('#armorySelector #armoryLoadingGif img').clone(); | ||
if (typeof(uri.query.l) === 'string') { | if (typeof(uri.query.l) === 'string') { | ||
parsed = parseShortLink(uri.query.l); | parsed = parseShortLink(uri.query.l); | ||
| Line 506: | Line 527: | ||
makeForm(queryDefaults); | makeForm(queryDefaults); | ||
} | } | ||
$selector = $('# | $selector = $('#armorySelector'); | ||
$messages = $('<div id=" | $messages = $('<div id="armoryMessages">'); | ||
$results = $('<div id=" | $results = $('<div id="armoryResults">'); | ||
$selector.empty().append(fieldset.$element).after($results).after($messages); | $selector.empty().append(fieldset.$element).after($results).after($messages); | ||
if (search) { | if (search) { | ||