4,683
edits
mNo edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
<syntaxhighlight lang="javascript" line> | <syntaxhighlight lang="javascript" line> | ||
function disambiguation(searchTerm, returnEquipmentTemplate=false) { | function disambiguation(searchTerm, returnEquipmentTemplate=false) { | ||
let search = (item) => !item.isModded && item.name.toLowerCase().includes(searchTerm.toLowerCase()); | |||
let wikiIcon = (item, icon, extras, postText) => { | |||
if (!returnEquipmentTemplate) { | if (!returnEquipmentTemplate) { | ||
numResults++; | |||
extras = extras.replaceAll('${NAME}', `${item.name}`); | extras = extras.replaceAll('${NAME}', `${item.name}`); | ||
let expIcon = `${item.namespace.includes('TotH') ? ' {{TotH}}' : item.namespace.includes('AoD') ? ' {{AoD}}' : item.namespace.includes('ItA') ? ' {{ItA}}' : ' {{Melvor}}'}`; | let expIcon = `${item.namespace.includes('TotH') ? ' {{TotH}}' : item.namespace.includes('AoD') ? ' {{AoD}}' : item.namespace.includes('ItA') ? ' {{ItA}}' : ' {{Melvor}}'}`; | ||
Line 21: | Line 22: | ||
return `|${item.name}`; | return `|${item.name}`; | ||
} | } | ||
let pushResults = (arr, header, icon, extras='', postText='') => { | |||
if (arr.length > 0 && !returnEquipmentTemplate && !results.includes(header)) | if (arr.length > 0 && !returnEquipmentTemplate && !results.includes(header)) | ||
results += header; | results += header; | ||
Line 29: | Line 30: | ||
}); | }); | ||
} | } | ||
let results = ''; | let results = '', numResults = 0; | ||
if (returnEquipmentTemplate) results += `{{UserContentVersion|${gameVersion.substr(1)}}}\n\n= ${searchTerm} Equipment =\n== Melee Weapons ==\n{{EquipmentTableFromList\n\n}}\n== Ranged Weapons & Ammo ==\n{{EquipmentTableFromList\n\n}}\n== Armour ==\n{{EquipmentTableFromList\n|includeModifiers=false`; | if (returnEquipmentTemplate) results += `{{UserContentVersion|${gameVersion.substr(1)}}}\n\n= ${searchTerm} Equipment =\n== Melee Weapons ==\n{{EquipmentTableFromList\n\n}}\n== Ranged Weapons & Ammo ==\n{{EquipmentTableFromList\n\n}}\n== Armour ==\n{{EquipmentTableFromList\n|includeModifiers=false`; | ||
if (!returnEquipmentTemplate) results += `{{Disam}}\n{{UserContentVersion|${gameVersion.substr(1)}}}\n\n'''${searchTerm}''' may refer to:`; | if (!returnEquipmentTemplate) results += `{{Disam}}\n{{UserContentVersion|${gameVersion.substr(1)}}}\n\n'''${searchTerm}''' may refer to:`; | ||
Line 61: | Line 62: | ||
self.nw?.Clipboard.get().set ? self.nw?.Clipboard?.get().set(results, 'text') : copy(results); | self.nw?.Clipboard.get().set ? self.nw?.Clipboard?.get().set(results, 'text') : copy(results); | ||
console.log(results); | console.log(results); | ||
notifyPlayer(game.attack, `Copied results for ${searchTerm} to clipboard`, 'success', 0); | notifyPlayer(game.attack, `Copied ${numResults} results for ${searchTerm} to clipboard`, 'success', 0); | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |