User:Cephalon Scientia/common.js

// Automating display of active Nightwave acts using an API // For use in Warframe Wikia, particular in the following page: // https://warframe.fandom.com/wiki/Nightwave/Acts_Currently_Available // Created by User:Cephalon Scientia // Made in JavaScript + jQuery 3.3.1 // Fork code at https://jsfiddle.net/chao_/7yrzkvdq/

/* Cephalon Scientia Nightwave Current Acts */ const WIKI_IMG_URL = 'https://vignette.wikia.nocookie.net/warframe/images/'; const API_URL = 'https://api.warframestat.us/pc/nightwave'; const REP_IMG_URL = WIKI_IMG_URL + '9/92/ReputationLargeBlack.png/revision/latest/scale-to-width-down/20?cb=20141029201703';  // scaled down image

const ActTypeEnum = { 'DAILY': 1, 'WEEKLY': 2, 'ELITE_WEEKLY': 3 }; Object.freeze(ActTypeEnum); // for immutability

// To map out act name to associated image in wiki // Keys are in alphabetical order, values are hexidecimal values with image name // to be concatenated to https://vignette.wikia.nocookie.net/warframe/images/ // Some acts don't have image so their values are blank, a broken image will // be returned as a result const DAILY_ACT_IMG_MAP = new Map([ ['Accelerator', '3/38/KillEnemiesWhileSliding.png'],  ['Agent', '1/14/CompleteAnyMission.png/'],  ['Air It Out', ],  ['Arsonist', 'f/fe/KillEnemiesDamageTypeFire.png'],  ['Attractive', '4/47/KillEnemiesDamageTypeMagnetic.png'],  ['Biohazard', '7/7e/KillEnemiesDamageTypeGas.png'],  ['Communicator', '5/5d/PlaceWaypoint.png'],  ['Deep Freeze', '4/4b/KillEnemiesDamageTypeCold.png'],  ['Detonator', 'c/c3/KillEnemiesDamageTypeBlast.png'],  ['Energizing', 'a/ac/EnergyOrbs.png'],  ['Everything Old is New Again', ],  ['Executioner', 'c/ca/KillEnemiesFinishingMoves.png'],  ['Expressive', 'f/f2/PerformEmote.png'],  ['Glider', '1/1d/AimGlide.png'],  ['Grafitti', '8/87/PlaceGlyph.png'],  ['Hacker', '7/75/SolveCipher.png'],  ['Kleptomaniac', '0/0d/OpenLootLocker.png'],  ['Loyalty', ''],  ['Marksman', '3/3a/GetHeadshots.png'],  ['Meltdown', 'e/e0/KillEnemiesDamageTypeCorrosive.png'], ['Mow Them Down', '9/9a/KillEnemiesWithPrimary.png'], ['Poisoner', '5/5a/KillEnemiesDamageTypePoison.png'], ['Power Trip', '9/93/KillEnemiesWithAbilities.png'], ['Reactor', '4/4b/KillEnemiesDamageTypeRadiation.png'], ['Researcher', '0/01/CodexScan.png'], ['Saver', '3/30/CollectCredits.png'], ['Sharing is Caring', '4/4e/KillEnemiesDamageTypeViral.png'], ['Shiny', 'a/a2/FindMod.png'], ['Short Circuit', '8/8a/KillEnemiesDamageTypeElectricty.png'], ['Smaller Is Bigger', 'f/f4/KillEnemiesWithSecondary.png'], ['Sword Dance', 'd/df/KillEnemiesWithMelee.png'], ['The Hunt is On', ''], ['Trampoline', 'a/aa/BulletJump.png'], ['Warning Shot', 'a/a7/KillEnemies.png'], ]);

const WEEKLY_ACT_IMG_MAP = new Map([ ['Animator', 'a/a4/AyatanSculptures.png'],  ['Assassin', '6/66/CompleteMissionTypesAssassination.png'],  ['Cache Hunter', 'c/ce/SabotageCaches.png'],  ['Conservationist', '5/53/PerfectConservations.png'],  ['Don\'t Blow It', ],  ['Don\'t Fear The Reaper', ],  ['Earth Bounty Hunter', 'f/f9/BountiesPoE.png'],  ['Earth Fisher', '2/29/RareFishPoE.png'],  ['Earth Miner', 'f/f3/MineGemsPoE.png'],  ['Eliminator', '1/1f/MissionsOfXType.png'],  ['Enhance!', '7/79/AcquireRareMods.png'],  ['Eximus Eliminator', '2/22/KillEnemiesWeekly.png'],  ['Good Friend', '7/77/HelpClem.png'],  ['Invader', '9/9a/InvasionMissions.png'],  ['Jailer', '8/8a/CompleteMissionTypesCapture.png'],  ['Not a Warning Shot', '2/22/KillEnemiesWeekly.png'],  ['Now Boarding', ''],  ['Operative', 'e/ec/CompleteMissionTypesSpy.png'],  ['Polarized', 'b/b8/FormaWeapons.png'],  ['Protector', '3/3f/CompleteMissionTypeDefense.png'], ['Rescuer', 'f/fd/CompleteMissionTypesRescue.png'], ['Saboteur', '2/20/CompleteMissionTypesSabotage.png'], ['Sanctuary Researcher', 'a/a0/SynthesizeSimarisTargets.png'], ['Sound Sleeper', 'f/f4/NightmareMissions.png'], ['Sortie Specialist', '1/1e/SortieWarframe.png'], ['Supporter', '0/0c/SyndicateDailies.png'], ['Test Subject', 'a/a0/Weekly_EliteSanctuaryOnslaught.png'], ['Tusk Thumpin\, ], ['Unlock Relics', '5/53/UnlockRelics.png'], ['Vault Looter', '0/01/UnlockDragonVaults.png'], ['Venus Bounty Hunter', 'b/b3/BountiesOrbVallis.png'], ['Venus Fisher', 'd/d2/RareFishOrbVallis.png'], ['Venus Miner', '8/86/MineGemsOrbVallis.png'], ]);

const ELITE_ACT_IMG_MAP = new Map([ ['Ascendant', '2/2b/HallsOfAscension.png'],  ['Day Trader', '3/39/IndexRounds.png'],  ['Defense', '3/31/DefenseMissionWaveXWithFriendsClan.png'],  ['Elite Test Subject', 'd/db/EliteSanctuaryOnslaught.png'],  ['Eximus Executioner', '5/5d/KillEnemiesHardcore.png'],  ['Flying High', ],  ['Grove Guardian', '5/5d/KillEnemiesHardcore.png'],  ['Hold Your Breath', '1/11/KuvaSurvival.png'], // typo in description in API  ['Hydrolyst Hunter', 'c/c0/Hydrolists.png'],  ['Kill Profit-Taker', '7/71/OrbHeistFullParty.png'],  ['Kill Shot', '5/5d/KillEnemiesHardcore.png'],  ['Night Terror', 'a/ac/NightmareMissionsHardcore.png'],  ['Silent Eliminator', 'c/c6/ExterminationWithoutAlarms.png'],  ['Sortie Expert', '9/9e/Hardcore_Sortie.png'],  ['Survival', 'a/ab/HighLevelSurvivalWithFriendsClan.png'],  ['Unlock Relics', '5/59/UnlockRelicsHardcore.png'],  ['Walk Without Rhythm', ], ]);

$(document).ready(function { // Need this before adding more HTML elements  document.getElementById('nightwave_acts').innerHTML = '';  // Adding tabber navigation and starting div tags for tabber  // Styling based on:  // https://stackoverflow.com/questions/9760328/clearest-way-to-build-html-elements-in-jquery  // Code block can be collapsed in this styling  document.getElementById('nightwave_acts').innerHTML += $([ ' ',   ' ',      '', '♦ Daily', ' ', '', '♦♦ Weekly', ' ', '', '♦♦♦ Elite Weekly', ' ', '' ].join('\n')).prop('outerHTML');   $.get(API_URL).done(data => { let actsArr = data.activeChallenges; // elements are in JSON }); }); /* END Cephalon Scientia Nightwave Current Acts */