From 1c749c767f82bbd61a450d7623e9ed8ba78eb3a3 Mon Sep 17 00:00:00 2001 From: Anzumana Taal Date: Fri, 16 Feb 2018 10:26:38 +0100 Subject: [PATCH 1/3] refactor: serve visualizer with node and gitignore --- .gitignore | 1 + app.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .gitignore create mode 100644 app.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/app.js b/app.js new file mode 100644 index 0000000..6038513 --- /dev/null +++ b/app.js @@ -0,0 +1,33 @@ +/////// variable definitions //////// +var app; +var port = 8001; + +//////// load dependencies //////// +//webserver framework +var express = require('express'); + +var vhost = require('vhost'); +//Compression for gzip Compression +var compression = require('compression'); + +function createVirtualHost(domainName, dirPath) { + return vhost(domainName, express.static(dirPath)); +} + +////// app configuration //////// +app = express(); + +//Create the virtual hosts +var internIp = createVirtualHost("127.0.0.1","visualizer/"); +var localhost = createVirtualHost("localhost","visualizer/"); +// create the static site hosting for each page +sites =[internIp, localhost]; +for(var i = 0; i< sites.length;i++){ + app.use(sites[i]); +} + + +//enable the port that the app is listening on +app.listen(port, function () { + console.log('Example app listening on port ' + port); +}); From b9cfbee2640e5f0f27499c1b63ba137779e3e97d Mon Sep 17 00:00:00 2001 From: Anzumana Taal Date: Thu, 31 Oct 2019 10:42:21 +0100 Subject: [PATCH 2/3] feat: moved some files from coffeescript to regular javascript to enable react refactor --- README.md | 20 +- src/hotkeys.js | 3219 ++++++++++++++++++++++++++++++++++++++++++++++ src/index.js | 1238 ++++++++++++++++++ src/keyboards.js | 558 ++++++++ 4 files changed, 5034 insertions(+), 1 deletion(-) create mode 100644 src/hotkeys.js create mode 100644 src/index.js create mode 100644 src/keyboards.js diff --git a/README.md b/README.md index 5b21e69..75589d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -# The Core Visualizer [See the live demo.](http://IvanVolosyuk.github.io/thecorevisualizer/visualizer) @@ -79,3 +78,22 @@ $ git add src/hotkeys.coffee visualizer/index.html $ git commit -m "Fixed hotkey file entries...." $ git push ``` + + +### Simple redirect + +Put this inside an index html that your are serving on your lading page. +This will result in the user being forwared to the new url location +``` html +The Core Visualizer has moved. + +http://jakatak.github.io/thecorevisualizer/visualizer/ + +``` + +# Help with the Refactoring +There is a lot that has to be done here. +We would like to move the project to react with redux. So that hopefully we can get more people maintaining the project. + +So far i was able to get some of the keymaps working inside of react. +For additional ideas to make the migration easier please send speak up :) diff --git a/src/hotkeys.js b/src/hotkeys.js new file mode 100644 index 0000000..44bdf21 --- /dev/null +++ b/src/hotkeys.js @@ -0,0 +1,3219 @@ +// Generated by CoffeeScript 2.2.1 +(function() { + var commandCards, i, j, k, l, m, n, o, raceCards; + + exports.commandCards = commandCards = { + global: { + PTT: { + hotkeyCode: "PTT", + displayText: "PTT" + }, + ChatAll: { + hotkeyCode: "ChatAll", + displayText: "Chat All", + if: function() { + return !this.chatting; + }, + on: function() { + return this.chatting = true; + } + }, + ChatAllies: { + hotkeyCode: "ChatAllies", + displayText: "Chat Allies", + if: function() { + return !this.chatting; + }, + on: function() { + return this.chatting = true; + } + }, + ChatCancel: { + hotkeyCode: "ChatCancel", + displayText: "Chat Cancel", + if: function() { + return this.chatting; + }, + on: function() { + return this.chatting = false; + } + }, + ChatDefault: { + hotkeyCode: "ChatDefault", + displayText: "Chat Default", + if: function() { + return !this.chatting; + }, + on: function() { + return this.chatting = true; + } + }, + ChatIndividual: { + hotkeyCode: "ChatIndividual", + displayText: "Chat Individual", + if: function() { + return !this.chatting; + }, + on: function() { + return this.chatting = true; + } + }, + ChatRecipient: { + hotkeyCode: "ChatRecipient", + displayText: "Chat Recipient", + if: function() { + return !this.chatting; + }, + on: function() { + return this.chatting = true; + } + }, + DialogDismiss: { + hotkeyCode: "DialogDismiss", + displayText: "Dialog Dismiss", + if: function() { + return this.dialog; + } + }, + MenuAchievements: { + hotkeyCode: "MenuAchievements", + displayText: "Menu Achievements" + }, + MenuGame: { + hotkeyCode: "MenuGame", + displayText: "Menu Game" + }, + MenuHelp: { + hotkeyCode: "MenuHelp", + displayText: "Menu Help" + }, + MenuMessages: { + hotkeyCode: "MenuMessages", + displayText: "Menu Messages" + }, + LeaderNone: { + hotkeyCode: "LeaderNone", + displayText: "Leader None", + if: function() { + return this.observer; + } + }, + LeaderResources: { + hotkeyCode: "LeaderResources", + displayText: "Leader Resources", + if: function() { + return this.observer; + } + }, + LeaderIncome: { + hotkeyCode: "LeaderIncome", + displayText: "Leader Income", + if: function() { + return this.observer; + } + }, + LeaderSpending: { + hotkeyCode: "LeaderSpending", + displayText: "Leader Spending", + if: function() { + return this.observer; + } + }, + LeaderUnits: { + hotkeyCode: "LeaderUnits", + displayText: "Leader Units", + if: function() { + return this.observer; + } + }, + LeaderStructures: { + hotkeyCode: "LeaderStructures", + displayText: "Leader Structures", + if: function() { + return this.observer; + } + }, + LeaderUnitsLost: { + hotkeyCode: "LeaderUnitsLost", + displayText: "Leader Units Lost", + if: function() { + return this.observer; + } + }, + LeaderProduction: { + hotkeyCode: "LeaderProduction", + displayText: "Leader Production", + if: function() { + return this.observer; + } + }, + LeaderUpgrades: { + hotkeyCode: "LeaderUpgrades", + displayText: "Leader Upgrades", + if: function() { + return this.observer; + } + }, + LeaderArmy: { + hotkeyCode: "LeaderArmy", + displayText: "Leader Army", + if: function() { + return this.observer; + } + }, + LeaderAPM: { + hotkeyCode: "LeaderAPM", + displayText: "Leader APM", + if: function() { + return this.observer; + } + }, + LeaderCPM: { + hotkeyCode: "LeaderCPM", + displayText: "Leader CPM", + if: function() { + return this.observer; + } + }, + ObserveAllPlayers: { + hotkeyCode: "ObserveAllPlayers", + displayText: "Observe All Players", + if: function() { + return this.observer; + } + }, + ObserveAutoCamera: { + hotkeyCode: "ObserveAutoCamera", + displayText: "Observe Auto Camera", + if: function() { + return this.observer; + } + }, + ObserveClearSelection: { + hotkeyCode: "ObserveClearSelection", + displayText: "Observe Clear Selection", + if: function() { + return this.observer; + } + }, + ObservePreview: { + hotkeyCode: "ObservePreview", + displayText: "Observe Preview", + if: function() { + return this.observer; + } + }, + ObserveSelected: { + hotkeyCode: "ObserveSelected", + displayText: "Observe Selected", + if: function() { + return this.observer; + } + }, + ObserveStatusBars: { + hotkeyCode: "ObserveStatusBars", + displayText: "Observe Status Bars", + if: function() { + return this.observer; + } + }, + NamePanel: { + hotkeyCode: "NamePanel", + displayText: "Name Panel", + if: function() { + return this.observer; + } + }, + StatPanelResources: { + hotkeyCode: "StatPanelResources", + displayText: "Stat Panel Resources", + if: function() { + return this.observer; + } + }, + StatPanelArmySupply: { + hotkeyCode: "StatPanelArmySupply", + displayText: "Stat Panel Army Supply", + if: function() { + return this.observer; + } + }, + StatPanelUnitsLost: { + hotkeyCode: "StatPanelUnitsLost", + displayText: "Stat Panel Units Lost", + if: function() { + return this.observer; + } + }, + StatPanelAPM: { + hotkeyCode: "StatPanelAPM", + displayText: "Stat Panel APM", + if: function() { + return this.observer; + } + }, + StatPanelCPM: { + hotkeyCode: "StatPanelCPM", + displayText: "Stat Panel CPM", + if: function() { + return this.observer; + } + }, + ToggleVersusModeSides: { + hotkeyCode: "ToggleVersusModeSides", + displayText: "Toggle Versus Mode Sides", + if: function() { + return this.observer; + } + }, + ToggleWorldPanel: { + hotkeyCode: "ToggleWorldPanel", + displayText: "Toggle World Panel", + if: function() { + return this.observer; + } + }, + AlertRecall: { + hotkeyCode: "AlertRecall", + displayText: "Alert Recall" + }, + ArmySelect: { + hotkeyCode: "ArmySelect", + displayText: "Army Select" + }, + CameraCenter: { + hotkeyCode: "CameraCenter", + displayText: "Camera Center" + }, + CameraFollow: { + hotkeyCode: "CameraFollow", + displayText: "Camera Follow" + }, + CameraTurnLeft: { + hotkeyCode: "CameraTurnLeft", + displayText: "Camera Turn Left" + }, + CameraTurnRight: { + hotkeyCode: "CameraTurnRight", + displayText: "Camera Turn Right" + }, + GameTooltipsOn: { + hotkeyCode: "GameTooltipsOn", + displayText: "Game Tooltips On" + }, + IdleWorker: { + hotkeyCode: "IdleWorker", + displayText: "Idle Worker" + }, + MinimapColors: { + hotkeyCode: "MinimapColors", + displayText: "Minimap Colors" + }, + MinimapPing: { + hotkeyCode: "MinimapPing", + displayText: "Minimap Ping" + }, + MinimapTerrain: { + hotkeyCode: "MinimapTerrain", + displayText: "Minimap Terrain" + }, + PauseGame: { + hotkeyCode: "PauseGame", + displayText: "Pause Game" + }, + QuickPing: { + hotkeyCode: "QuickPing", + displayText: "Quick Ping" + }, + QuickSave: { + hotkeyCode: "QuickSave", + displayText: "Quick Save", + if: function() { + return this.campaign; + } + }, + ReplayPlayPause: { + hotkeyCode: "ReplayPlayPause", + displayText: "Replay Play Pause", + if: function() { + return this.replay; + } + }, + ReplayRestart: { + hotkeyCode: "ReplayRestart", + displayText: "Replay Restart", + if: function() { + return this.replay; + } + }, + ReplaySkipBack: { + hotkeyCode: "ReplaySkipBack", + displayText: "Replay Skip Back", + if: function() { + return this.replay; + } + }, + ReplaySkipNext: { + hotkeyCode: "ReplaySkipNext", + displayText: "Replay Skip Next" + }, + ReplaySpeedDec: { + hotkeyCode: "ReplaySpeedDec", + displayText: "Replay Speed Dec", + if: function() { + return this.replay; + } + }, + ReplaySpeedInc: { + hotkeyCode: "ReplaySpeedInc", + displayText: "Replay Speed Inc", + if: function() { + return this.replay; + } + }, + ReplayStop: { + hotkeyCode: "ReplayStop", + displayText: "Replay Stop", + if: function() { + return this.replay; + } + }, + ReplayHide: { + hotkeyCode: "ReplayHide", + displayText: "Replay Hide", + if: function() { + return this.replay; + } + }, + SelectionCancelDrag: { + hotkeyCode: "SelectionCancelDrag", + displayText: "Selection Cancel Drag", + if: function() { + return this.dragging; + } + }, + StatusAll: { + hotkeyCode: "StatusAll", + displayText: "Status All" + }, + StatusOwner: { + hotkeyCode: "StatusOwner", + displayText: "Status Owner" + }, + StatusAlly: { + hotkeyCode: "StatusAlly", + displayText: "Status Ally" + }, + StatusEnemy: { + hotkeyCode: "StatusEnemy", + displayText: "Status Enemy" + }, + SubgroupNext: { + hotkeyCode: "SubgroupNext", + displayText: "Subgroup Next" + }, + SubgroupPrev: { + hotkeyCode: "SubgroupPrev", + displayText: "Subgroup Prev" + }, + TeamResources: { + hotkeyCode: "TeamResources", + displayText: "Team Resources" + }, + TownCamera: { + hotkeyCode: "TownCamera", + displayText: "Town Camera" + }, + Select: { + hotkeyCode: "Select", + displayText: "Select" + }, + Interact: { + hotkeyCode: "Interact", + displayText: "Interact" + } + }, + unit: { + movement: { + Move: { + displayText: 'Move', + icon: 'Move.png', + if: function() { + return !(this.buildCard || this.hallucinateCard || this.burrowed || this.sieged || this.unrooted === false); + } + }, + HoldPosition: { + hotkeyCode: 'MoveHoldPosition', + displayText: 'Hold Position', + icon: 'HoldPosition.png', + if: function() { + return !(this.buildCard || this.hallucinateCard || this.burrowed || this.sieged || this.unrooted === false); + } + }, + Patrol: { + hotkeyCode: 'MovePatrol', + displayText: 'Patrol', + icon: 'Patrol.png', + if: function() { + return !(this.buildCard || this.hallucinateCard || this.burrowed || this.sieged || this.unrooted === false); + } + }, + Stop: { + displayText: 'Stop', + icon: 'Stop.png', + if: function() { + return !(this.buildCard || this.hallucinateCard || this.burrowed || this.unrooted === false); + } + } + }, + combat: { + Attack: { + displayText: 'Attack', + icon: 'Attack.png', + if: function() { + return !(this.buildCard || this.hallucinateCard || this.unrooted || this.burrowed); + } + }, + Stop: { + displayText: 'Stop', + icon: 'Stop.png', + if: function() { + return !(this.buildCard || this.hallucinateCard || this.unrooted || this.burrowed); + } + } + }, + cancel: { + Cancel: { + displayText: 'Cancel', + icon: 'Cancel.png', + if: function() { + return !this.lifted; + } + } + }, + burrow: { + Burrow: { + icon: 'Burrow.gif', + hotkeyCode: 'BurrowDown', + displayText: 'Burrow', + if: function() { + return !(this.buildCard || this.burrowed); + }, + on: function() { + return this.burrowed = true; + } + }, + Unburrow: { + icon: 'Unburrow.gif', + hotkeyCode: 'BurrowUp', + displayText: 'Unburrow', + if: function() { + return this.burrowed; + }, + on: function() { + return this.burrowed = false; + } + } + }, + load: { + BunkerLoad: { + icon: 'Load.png', + hotkeyCode: 'BunkerLoad', + displayText: 'Load' + }, + BunkerUnloadAll: { + icon: 'UnloadAll.jpg', + hotkeyCode: 'BunkerUnloadAll', + displayText: 'Unload All' + } + }, + underconstruction: { + Halt: { + icon: 'Stop.png', + hotkeyCode: 'Halt', + displayText: 'Halt construction' + }, + SelectBuilder: { + icon: 'Selectbuilder.png', + hotkeyCode: 'SelectBuilder', + displayText: 'Select Builder' + } + }, + flying: { + Liftoff: { + icon: 'Lift.png', + hotkeyCode: 'Lift', + displayText: 'Lift Off', + if: function() { + return this.upgrade !== 'PlanetaryFortress' && !this.lifted; + }, + on: function() { + return this.lifted = true; + } + }, + Land: { + icon: 'Land.jpg', + hotkeyCode: 'Land', + displayText: 'Land', + if: function() { + return this.lifted; + }, + on: function() { + return this.lifted = false; + } + }, + Move: { + icon: 'Move.png', + hotkeyCode: 'Move', + displayText: 'Move', + if: function() { + return this.lifted; + } + }, + Patrol: { + icon: 'Patrol.png', + hotkeyCode: 'MovePatrol', + displayText: 'Patrol', + if: function() { + return this.lifted; + } + }, + Stop: { + icon: 'Stop.png', + hotkeyCode: 'Stop', + displayText: 'Stop', + if: function() { + return this.lifted; + } + } + }, + worker: { + ReturnCargo: { + icon: 'ReturnCargo.png', + hotkeyCode: 'ReturnCargo', + displayText: 'Return Cargo', + if: function() { + return !this.buildCard; + } + }, + Gather: { + icon: "Gather.png", + hotkeyCode: "GatherProt", + displayText: "Gather", + if: function() { + return !this.buildCard; + } + } + }, + rally: { + Rally: { + icon: 'Rally.jpg', + hotkeyCode: 'Rally', + displayText: 'Rally', + if: function() { + return !this.buildCard; + } + } + }, + archonWarp: { + AWrp: { + icon: "AWrp.png", + hotkeyCode: "AWrp", + displayText: "Archon Warp" + } + } + } + }; + + for (n = i = 0; i <= 9; n = ++i) { + commandCards.global[`ControlGroupRecall${n}`] = { + hotkeyCode: `ControlGroupRecall${n}`, + keyCap: `${n}`, + displayText: `Select Group ${n}`, + on: (function() { + return this.select(this.controlGroup[N]); + }).toString().replace(/N/, n.toString()) + }; + } + + for (n = j = 0; j <= 9; n = ++j) { + commandCards.global[`ControlGroupAppend${n}`] = { + hotkeyCode: `ControlGroupAppend${n}`, + keyCap: `${n}`, + displayText: `Add Selection to Group ${n}`, + on: (function() { + return this.controlGroup[N] = this.currentUnit; + }).toString().replace(/N/, n.toString()) + }; + } + + for (n = k = 0; k <= 9; n = ++k) { + commandCards.global[`ControlGroupAssign${n}`] = { + hotkeyCode: `ControlGroupAssign${n}`, + keyCap: `${n}`, + displayText: `Set Group ${n} to Selection`, + on: (function() { + return this.controlGroup[N] = this.currentUnit; + }).toString().replace(/N/, n.toString()) + }; + } + + for (n = l = 0; l <= 15; n = ++l) { + commandCards.global[`ObservePlayer${n}`] = { + hotkeyCode: `ObservePlayer${n}`, + displayText: `Observe Player ${n}` + }; + } + + for (n = m = 0; m <= 7; n = ++m) { + commandCards.global[`CameraSave${n}`] = { + hotkeyCode: `CameraSave${n}`, + keyCap: `${n}`, + displayText: `Save Camera ${n}` + }; + } + + for (n = o = 0; o <= 7; n = ++o) { + commandCards.global[`CameraView${n}`] = { + hotkeyCode: `CameraView${n}`, + keyCap: `${n}`, + displayText: `Go to Camera ${n}` + }; + } + + exports.raceCards = raceCards = { + Protoss: { + units: { + Probe: { + icon: "probe.jpg", + displayText: "Probe", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.worker'], + Cancel: { + displayText: 'Cancel', + icon: 'Cancel.png', + on: function() { + return this.buildCard = null; + }, + if: function() { + return this.buildCard; + } + }, + BuildBasic: { + displayText: 'Build Basic', + hotkeyCode: 'ProtossBuild/Probe', + icon: 'Build.png', + on: function() { + return this.buildCard = 'basic'; + }, + if: function() { + return !this.buildCard; + } + }, + BuildPylon: { + icon: "pylon.jpg", + hotkeyCode: "Pylon/Probe", + displayText: "Pylon", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildAssimilator: { + icon: "assimilator.jpg", + hotkeyCode: "Assimilator/Probe", + displayText: "Build Assimilator", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildCyberneticsCore: { + icon: "cyberneticscore.jpg", + hotkeyCode: "CyberneticsCore/Probe", + displayText: "Build Cybernetics Core", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildForge: { + icon: "forge.jpg", + hotkeyCode: "Forge/Probe", + displayText: "Build Forge", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildGateway: { + icon: "gateway.jpg", + hotkeyCode: "Gateway/Probe", + displayText: "Build Gateway", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildNexus: { + icon: "nexus.jpg", + hotkeyCode: "Nexus/Probe", + displayText: "Build Nexus", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildPhotonCannon: { + icon: "photoncannon.jpg", + hotkeyCode: "PhotonCannon/Probe", + displayText: "Build Photon Cannon", + if: function() { + return this.buildCard === 'basic'; + } + }, + BuilAdvanced: { + displayText: 'Build Advanced', + hotkeyCode: 'ProtossBuildAdvanced/Probe', + icon: 'BuildAdvanced.png', + on: function() { + return this.buildCard = 'advanced'; + }, + if: function() { + return !this.buildCard; + } + }, + BuildDarkShrine: { + icon: "darkshrine.jpg", + hotkeyCode: "DarkShrine/Probe", + displayText: "Build Dark Shrine", + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildFleetBeacon: { + icon: "fleetbeacon.jpg", + hotkeyCode: "FleetBeacon/Probe", + displayText: "Build Fleet Beacon", + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildRoboticsBay: { + icon: "roboticsbay.jpg", + hotkeyCode: "RoboticsBay/Probe", + displayText: "Build Robotics Bay", + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildRoboticsFacility: { + icon: "roboticsfacility.jpg", + hotkeyCode: "RoboticsFacility/Probe", + displayText: "Build Robotics Facility", + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildStargate: { + icon: "stargate.jpg", + hotkeyCode: "Stargate/Probe", + displayText: "Build Stargate", + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildTwilightCouncil: { + icon: "twilightcouncil.jpg", + hotkeyCode: "TwilightCouncil/Probe", + displayText: "Build Twilight Council", + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildTemplarArchive: { + icon: "templararchive.jpg", + hotkeyCode: "TemplarArchive/Probe", + displayText: "Build Templar Archive", + if: function() { + return this.buildCard === 'advanced'; + } + } + } + }, + Zealot: { + icon: "zealot.jpg", + displayText: "Zealot", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.rally'], + Charge: { + icon: "Charge.png", + hotkeyCode: "Charge/Zealot", + displayText: "Charge" + } + } + }, + Stalker: { + icon: "stalker.jpg", + displayText: "Stalker", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.rally'], + Blink: { + icon: "Blink.png", + hotkeyCode: "Blink/Stalker", + displayText: "Blink" + } + } + }, + HighTemplar: { + icon: "hightemplar.jpg", + displayText: "High Templar", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.rally', 'unit.archonWarp'], + Feedback: { + icon: "Feedback.png", + hotkeyCode: "Feedback/HighTemplar", + displayText: "Feedback" + }, + PsiStorm: { + icon: "PsiStorm.png", + hotkeyCode: "PsiStorm/HighTemplar", + displayText: "Psi Storm" + } + } + }, + DarkTemplar: { + icon: "darktemplar.jpg", + displayText: "Dark Templar", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.rally', 'unit.archonWarp'] + } + }, + Oracle: { + icon: "oracle.jpg", + displayText: "Oracle", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + LightofAiur: { + icon: "Envision.png", + hotkeyCode: "LightofAiur/Oracle", + displayText: "Envision" + }, + OracleRevelation: { + icon: "OracleRevelation.png", + hotkeyCode: "OracleRevelation/Oracle", + displayText: "Revelation" + }, + OracleWeaponOff: { + icon: "PulsarBeamOff.jpg", + hotkeyCode: "OracleWeaponOff/Oracle", + displayText: "Deactivate Pulsar Beam", + on: function() { + return this.weapon = false; + }, + if: function() { + return this.weapon; + } + }, + OracleWeaponOn: { + icon: "PulsarBeam.png", + hotkeyCode: "OracleWeaponOn/Oracle", + displayText: "Activate Pulsar Beam", + on: function() { + return this.weapon = true; + }, + if: function() { + return !this.weapon; + } + } + } + }, + MothershipCore: { + icon: "mothershipcore.jpg", + displayText: "Mothership Core", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + MorphToMothership: { + icon: "MorphToMothership.png", + hotkeyCode: "MorphToMothership/MothershipCore", + displayText: "Morph To Mothership" + }, + MothershipCoreMassRecall: { + icon: "MassRecall.png", + hotkeyCode: "MothershipCoreMassRecall/MothershipCore", + displayText: "Mass Recall" + }, + MothershipCoreWeapon: { + icon: "MothershipCoreWeapon.png", + hotkeyCode: "MothershipCoreWeapon/MothershipCore", + displayText: "Photon Overcharge" + }, + TemporalField: { + icon: "TemporalField.png", + hotkeyCode: "TemporalField/MothershipCore", + displayText: "Time Warp" + } + } + }, + Phoenix: { + icon: "phoenix.jpg", + displayText: "Phoenix", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + GravitonBeam: { + icon: "GravitonBeam.png", + hotkeyCode: "GravitonBeam/Phoenix", + displayText: "Graviton Beam" + } + } + }, + WarpPrism: { + icon: "warpprism.jpg", + displayText: "Warp Prism", + commands: { + inherit: ['unit.movement', 'unit.load'], + PhasingMode: { + icon: "PhasingMode.png", + hotkeyCode: "PhasingMode/WarpPrism", + displayText: "Phasing Mode" + }, + TransportMode: { + icon: "TransportMode.png", + hotkeyCode: "TransportMode/WarpPrism", + displayText: "Transport Mode" + } + } + }, + Sentry: { + icon: "sentry.jpg", + displayText: "Sentry", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.rally'], + Cancel: { + icon: "Cancel.png", + hotkeyCode: "Cancel", + displayText: "Cancel", + if: function() { + return this.hallucinateCard; + }, + on: function() { + return this.hallucinateCard = false; + } + }, + ArchonHallucination: { + icon: "archon.jpg", + hotkeyCode: "ArchonHallucination/Sentry", + displayText: "Archon Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + ColossusHallucination: { + icon: "colossus.jpg", + hotkeyCode: "ColossusHallucination/Sentry", + displayText: "Colossus Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + ForceField: { + icon: "ForceField.png", + hotkeyCode: "ForceField/Sentry", + displayText: "Force Field", + if: function() { + return !this.hallucinateCard; + } + }, + GuardianShield: { + icon: "GuardianShield.gif", + hotkeyCode: "GuardianShield/Sentry", + displayText: "Guardian Shield", + if: function() { + return !this.hallucinateCard; + } + }, + Hallucination: { + icon: "Hallucination.png", + hotkeyCode: "Hallucination/Sentry", + displayText: "Hallucination", + on: function() { + return this.hallucinateCard = true; + }, + if: function() { + return !this.hallucinateCard; + } + }, + HighTemplarHallucination: { + icon: "hightemplar.jpg", + hotkeyCode: "HighTemplarHallucination/Sentry", + displayText: "High Templar Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + ImmortalHallucination: { + icon: "immortal.jpg", + hotkeyCode: "ImmortalHallucination/Sentry", + displayText: "Immortal Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + OracleHallucination: { + icon: "oracle.jpg", + hotkeyCode: "OracleHallucination/Sentry", + displayText: "Oracle Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + PhoenixHallucination: { + icon: "phoenix.jpg", + hotkeyCode: "PhoenixHallucination/Sentry", + displayText: "Phoenix Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + ProbeHallucination: { + icon: "probe.jpg", + hotkeyCode: "ProbeHallucination/Sentry", + displayText: "Probe Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + StalkerHallucination: { + icon: "stalker.jpg", + hotkeyCode: "StalkerHallucination/Sentry", + displayText: "Stalker Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + VoidRayHallucination: { + icon: "voidray.jpg", + hotkeyCode: "VoidRayHallucination/Sentry", + displayText: "Void Ray Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + WarpPrismHallucination: { + icon: "warpprism.jpg", + hotkeyCode: "WarpPrismHallucination/Sentry", + displayText: "Warp Prism Hallucination", + if: function() { + return this.hallucinateCard; + } + }, + ZealotHallucination: { + icon: "zealot.jpg", + hotkeyCode: "ZealotHallucination/Sentry", + displayText: "Zealot Hallucination", + if: function() { + return this.hallucinateCard; + } + } + } + }, + VoidRay: { + icon: "voidray.jpg", + displayText: "Void Ray", + commands: { + inherit: ['unit.movement', 'unit.combat'], + VoidRaySwarmDamageBoost: { + icon: "prismatic_beams.png", + hotkeyCode: "VoidRaySwarmDamageBoost/VoidRay", + displayText: "Prismatic Alignment" + } + } + }, + Carrier: { + icon: "carrier.jpg", + displayText: "Carrier", + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + Interceptor: { + icon: "TrainInterceptors.gif", + hotkeyCode: "Interceptor/Carrier", + displayText: "Interceptor" + } + } + }, + Mothership: { + icon: "mothership.jpg", + displayText: "Mothership", + commands: { + inherit: ['unit.movement', 'unit.cancel'], + MassRecall: { + icon: "MassRecall.png", + hotkeyCode: "MassRecall/Mothership", + displayText: "Mass Recall" + }, + TemporalField: { + icon: "TemporalField.png", + hotkeyCode: "TemporalField/Mothership", + displayText: "Time Warp" + } + } + } + }, + buildings: { + Nexus: { + icon: "nexus.jpg", + displayText: "Nexus", + commands: { + inherit: ['unit.cancel', 'unit.combat', 'unit.rally'], + MothershipCore: { + icon: "mothershipcore.jpg", + hotkeyCode: "MothershipCore/Nexus", + displayText: "Mothership Core" + }, + Probe: { + icon: "probe.jpg", + hotkeyCode: "Probe/Nexus", + displayText: "Probe" + }, + TimeWarp: { + icon: "ChronoBoost.png", + hotkeyCode: "TimeWarp/Nexus", + displayText: "Time Warp" + } + } + }, + Gateway: { + icon: "gateway.jpg", + displayText: "Gateway", + commands: { + inherit: ['unit.cancel', 'unit.rally'], + DarkTemplar: { + icon: "darktemplar.jpg", + hotkeyCode: "DarkTemplar", + displayText: "Dark Templar" + }, + HighTemplar: { + icon: "hightemplar.jpg", + hotkeyCode: "HighTemplar", + displayText: "High Templar" + }, + MorphBackToGateway: { + icon: "gateway.jpg", + hotkeyCode: "MorphBackToGateway", + displayText: "Morph Back To Gateway" + }, + Stalker: { + icon: "stalker.jpg", + hotkeyCode: "Stalker", + displayText: "Stalker" + }, + UpgradeToWarpGate: { + icon: "warpgate.jpg", + hotkeyCode: "UpgradeToWarpGate/Gateway", + displayText: "Upgrade to Warp Gate" + }, + Zealot: { + icon: "zealot.jpg", + hotkeyCode: "Zealot", + displayText: "Zealot" + }, + Sentry: { + icon: "sentry.jpg", + hotkeyCode: "Sentry", + displayText: "Sentry" + } + } + }, + Forge: { + icon: "forge.jpg", + displayText: "Forge", + commands: { + inherit: ['unit.cancel'], + ProtossGroundArmorLevel1: { + icon: "ProtossGroundArmorLevel1.gif", + hotkeyCode: "ProtossGroundArmorLevel1/Forge", + displayText: "Protoss Ground Armor 1" + }, + ProtossGroundWeaponsLevel1: { + icon: "ProtossGroundWeaponsLevel1.gif", + hotkeyCode: "ProtossGroundWeaponsLevel1/Forge", + displayText: "Protoss Ground Weapons 1" + }, + ProtossShieldsLevel1: { + icon: "ProtossShieldsLevel1.gif", + hotkeyCode: "ProtossShieldsLevel1/Forge", + displayText: "Protoss Shields 1" + } + } + }, + PhotonCannon: { + icon: "photoncannon.jpg", + displayText: "Photon Cannon", + commands: { + inherit: ['unit.combat', 'unit.cancel'] + } + }, + CyberneticsCore: { + icon: "cyberneticscore.jpg", + displayText: "Cybernetics Core", + commands: { + inherit: ['unit.cancel'], + ProtossAirArmorLevel1: { + icon: "ProtossAirArmorLevel1.gif", + hotkeyCode: "ProtossAirArmorLevel1/CyberneticsCore", + displayText: "Protoss Air Armor Level1" + }, + ProtossAirWeaponsLevel1: { + icon: "ProtossAirWeaponsLevel1.gif", + hotkeyCode: "ProtossAirWeaponsLevel1/CyberneticsCore", + displayText: "Protoss Air Weapons Level1" + }, + ResearchWarpGate: { + icon: "ResearchWarpgate.gif", + hotkeyCode: "ResearchWarpGate/CyberneticsCore", + displayText: "Research Warp Gate" + } + } + }, + RoboticsFacility: { + icon: "roboticsfacility.jpg", + displayText: "Robotics Facility", + commands: { + inherit: ['unit.cancel', 'unit.rally'], + Colossus: { + icon: "colossus.jpg", + hotkeyCode: "Colossus/RoboticsFacility", + displayText: "Colossus" + }, + Immortal: { + icon: "immortal.jpg", + hotkeyCode: "Immortal/RoboticsFacility", + displayText: "Immortal" + }, + Observer: { + icon: "observer.jpg", + hotkeyCode: "Observer/RoboticsFacility", + displayText: "Observer" + }, + WarpPrism: { + icon: "warpprism.jpg", + hotkeyCode: "WarpPrism/RoboticsFacility", + displayText: "Warp Prism" + } + } + }, + RoboticsBay: { + icon: "roboticsbay.jpg", + displayText: "Robotics Bay", + commands: { + inherit: ['unit.cancel'], + ResearchExtendedThermalLance: { + icon: "ColossusRange.gif", + hotkeyCode: "ResearchExtendedThermalLance/RoboticsBay", + displayText: "Colossus Range" + }, + ResearchGraviticBooster: { + icon: "ObserverSpeed.gif", + hotkeyCode: "ResearchGraviticBooster/RoboticsBay", + displayText: "Observer Speed" + }, + ResearchGraviticDrive: { + icon: "WarpPrismSpeed.gif", + hotkeyCode: "ResearchGraviticDrive/RoboticsBay", + displayText: "Warp Prism Speed" + } + } + }, + Stargate: { + icon: "stargate.jpg", + displayText: "Stargate", + commands: { + inherit: ['unit.cancel', 'unit.rally'], + Carrier: { + icon: "carrier.jpg", + hotkeyCode: "Carrier/Stargate", + displayText: "Carrier" + }, + Oracle: { + icon: "oracle.jpg", + hotkeyCode: "Oracle/Stargate", + displayText: "Oracle" + }, + Phoenix: { + icon: "phoenix.jpg", + hotkeyCode: "Phoenix/Stargate", + displayText: "Phoenix" + }, + Sentry: { + icon: "sentry.jpg", + hotkeyCode: "Sentry/Stargate", + displayText: "Sentry" + }, + Tempest: { + icon: "Tempest.png", + hotkeyCode: "Tempest/Stargate", + displayText: "Tempest" + }, + VoidRay: { + icon: "voidray.jpg", + hotkeyCode: "VoidRay/Stargate", + displayText: "Void Ray" + } + } + }, + TwilightCouncil: { + icon: "twilightcouncil.jpg", + displayText: "Twilight Council", + commands: { + inherit: ['unit.cancel'], + ResearchCharge: { + icon: "Charge.png", + hotkeyCode: "ResearchCharge/TwilightCouncil", + displayText: "Research Charge" + }, + ResearchStalkerTeleport: { + icon: "Blink.png", + hotkeyCode: "ResearchStalkerTeleport/TwilightCouncil", + displayText: "Research Blink" + } + } + }, + TemplarArchive: { + icon: "templararchive.jpg", + displayText: "Templar Archive", + commands: { + inherit: ['unit.cancel'], + ResearchPsiStorm: { + icon: "PsiStorm.png", + hotkeyCode: "ResearchPsiStorm/TemplarArchive", + displayText: "Research Psi Storm" + } + } + }, + FleetBeacon: { + icon: "fleetbeacon.jpg", + displayText: "Fleet Beacon", + commands: { + inherit: ['unit.cancel'], + AnionPulseCrystals: { + icon: "AnionPulseCrystals.png", + hotkeyCode: "AnionPulseCrystals/FleetBeacon", + displayText: "Phoenix Range" + }, + ResearchInterceptorLaunchSpeedUpgrade: { + icon: "GravitonCatapult.gif", + hotkeyCode: "ResearchInterceptorLaunchSpeedUpgrade/FleetBeacon", + displayText: "Interceptor Launch Speed" + } + } + } + } + }, + Terran: { + units: { + SCV: { + icon: 'scv.jpg', + displayText: 'SCV', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.worker'], + Repair: { + icon: 'Repair.png', + hotkeyCode: 'Repair', + displayText: 'Repair', + if: function() { + return !this.buildCard; + } + }, + Build: { + icon: 'Build.png', + hotkeyCode: 'TerranBuild/SCV', + displayText: 'Build Basic', + if: function() { + return !this.buildCard; + }, + on: function() { + return this.buildCard = 'basic'; + } + }, + BuildAdvanced: { + icon: 'BuildAdvanced.png', + hotkeyCode: 'TerranBuildAdvanced/SCV', + displayText: 'Build Advanced', + if: function() { + return !this.buildCard; + }, + on: function() { + return this.buildCard = 'advanced'; + } + }, + Cancel: { + icon: 'Cancel.png', + hotkeyCode: 'Cancel', + displayText: 'Cancel', + if: function() { + return this.buildCard; + }, + on: function() { + return this.buildCard = null; + } + }, + BuildBarracks: { + icon: 'barracks.jpg', + hotkeyCode: 'Barracks/SCV', + displayText: 'Build Barracks', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildBunker: { + icon: 'bunker.jpg', + hotkeyCode: 'Bunker/SCV', + displayText: 'Build Bunker', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildCommandCenter: { + icon: 'commandcenter.jpg', + hotkeyCode: 'CommandCenter/SCV', + displayText: 'Build Command Center', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildEngineeringBay: { + icon: 'engineeringbay.jpg', + hotkeyCode: 'EngineeringBay/SCV', + displayText: 'Build Engineering Bay', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildMissileTurret: { + icon: 'missileturret.jpg', + hotkeyCode: 'MissileTurret/SCV', + displayText: 'Build Missile Turret', + if: function() { + return this.buildCard === 'basic'; + } + }, + Refinery: { + icon: 'Refinary.png', + hotkeyCode: 'Refinery/SCV', + displayText: 'Refinery', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildSupplyDepot: { + icon: 'supplydepot.jpg', + hotkeyCode: 'SupplyDepot/SCV', + displayText: 'Build Supply Depot', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildArmory: { + icon: 'armory.jpg', + hotkeyCode: 'Armory/SCV', + displayText: 'Build Armory', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildFactory: { + icon: 'factory.jpg', + hotkeyCode: 'Factory/SCV', + displayText: 'Build Factory', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildFusionCore: { + icon: 'fusioncore.jpg', + hotkeyCode: 'FusionCore/SCV', + displayText: 'Build Fusion Core', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildGhostAcademy: { + icon: 'ghostacademy.jpg', + hotkeyCode: 'GhostAcademy/SCV', + displayText: 'Build Ghost Academy', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildSensorTower: { + icon: 'sensortower.jpg', + hotkeyCode: 'SensorTower/SCV', + displayText: 'Build Sensor Tower', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildStarport: { + icon: 'starport.jpg', + hotkeyCode: 'Starport/SCV', + displayText: 'Build Starport', + if: function() { + return this.buildCard === 'advanced'; + } + } + } + }, + Marine: { + icon: 'marine.jpg', + displayText: 'Marine', + commands: { + inherit: ['unit.movement', 'unit.combat'], + Stim: { + icon: 'Stim.png', + hotkeyCode: 'Stim', + displayText: 'Stim' + } + } + }, + Marauder: { + icon: 'marauder.jpg', + displayText: 'Marauder', + commands: { + inherit: ['unit.movement', 'unit.combat'], + Stim: { + icon: 'Stim.png', + hotkeyCode: 'Stim', + displayText: 'Stim' + } + } + }, + Reaper: { + icon: 'reaper.jpg', + displayText: 'Reaper', + commands: { + inherit: ['unit.movement', 'unit.combat'] + } + }, + Ghost: { + icon: 'ghost.jpg', + displayText: 'Ghost', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + CloakOff: { + icon: 'Decloack.jpg', + hotkeyCode: 'CloakOff', + displayText: 'Cloak Off', + if: function() { + return this.cloaked; + }, + on: function() { + return this.cloaked = false; + } + }, + CloakOn: { + icon: 'Cloak.png', + hotkeyCode: 'CloakOnBanshee', + displayText: 'Cloak On', + if: function() { + return !this.cloaked; + }, + on: function() { + return this.cloaked = true; + } + }, + EMP: { + icon: 'EMP.png', + hotkeyCode: 'EMP/Ghost', + displayText: 'EMP' + }, + GhostHoldFire: { + icon: 'GhostHoldFire.png', + hotkeyCode: 'GhostHoldFire/Ghost', + displayText: 'Ghost Hold Fire' + }, + NukeCalldown: { + icon: 'NukeCalldown.png', + hotkeyCode: 'NukeCalldown/Ghost', + displayText: 'Nuke Calldown' + }, + Snipe: { + icon: 'Snipe.png', + hotkeyCode: 'Snipe/Ghost', + displayText: 'Snipe' + }, + WeaponsFree: { + icon: 'WeaponsFree.png', + hotkeyCode: 'WeaponsFree/Ghost', + displayText: 'Weapons Free' + } + } + }, + WidowMine: { + icon: 'widowmine.jpg', + displayText: 'Widow Mine', + commands: { + inherit: ['unit.movement'], + WidowMineBurrow: { + icon: 'WidowMineBurrow.png', + hotkeyCode: 'WidowMineBurrow/WidowMine', + displayText: 'Widow Mine Burrow', + if: function() { + return !this.burrowed; + }, + on: function() { + return this.burrowed = true; + } + }, + WidowMineUnburrow: { + icon: 'WidowMineUnburrow.jpg', + hotkeyCode: 'WidowMineUnburrow/WidowMine', + displayText: 'Widow Mine Unburrow', + if: function() { + return this.burrowed; + }, + on: function() { + return this.burrowed = false; + } + } + } + }, + Hellion: { + icon: 'hellion.jpg', + displayText: 'Hellion', + commands: { + inherit: ['unit.movement', 'unit.combat'], + MorphToHellion: { + icon: 'hellion.jpg', + hotkeyCode: 'MorphToHellion/Hellion', + displayText: 'Morph To Hellion', + if: function() { + return this.hellbat; + }, + on: function() { + return this.hellbat = false; + } + }, + MorphToHellbat: { + icon: 'hellbat.jpg', + hotkeyCode: 'MorphToHellionTank/Hellion', + displayText: 'Morph To Hellbat', + if: function() { + return !this.hellbat; + }, + on: function() { + return this.hellbat = true; + } + } + } + }, + SiegeTank: { + icon: 'siegetank.jpg', + displayText: 'Siege Tank', + commands: { + inherit: ['unit.movement', 'unit.combat'], + SiegeMode: { + icon: 'SiegeMode.png', + hotkeyCode: 'SiegeMode', + displayText: 'Siege Mode', + if: function() { + return !this.sieged; + }, + on: function() { + return this.sieged = true; + } + }, + Unsiege: { + icon: 'Unsiege.png', + hotkeyCode: 'Unsiege', + displayText: 'Unsiege', + if: function() { + return this.sieged; + }, + on: function() { + return this.sieged = false; + } + } + } + }, + Thor: { + icon: 'thor.jpg', + displayText: 'Thor', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + 'ArmorpiercingMode': { + icon: 'HighImpactPayload.png', + hotkeyCode: 'ArmorpiercingMode', + displayText: 'High Impact Payload', + if: function() { + return !this.highimpact; + }, + on: function() { + return this.highimpact = true; + } + }, + ExplosivePayload: { + icon: 'ExplosivePayload.png', + hotkeyCode: 'ExplosiveMode', + displayText: 'Explosive Payload', + if: function() { + return this.highimpact; + }, + on: function() { + return this.highimpact = false; + } + } + } + }, + Viking: { + icon: 'viking.jpg', + displayText: 'Viking', + commands: { + inherit: ['unit.movement', 'unit.combat'], + AssaultMode: { + icon: 'AssaultMode.png', + hotkeyCode: 'AssaultMode', + displayText: 'Assault Mode', + if: function() { + return !this.fightermode; + }, + on: function() { + return this.fightermode = true; + } + }, + FighterMode: { + icon: 'FighterMode.png', + hotkeyCode: 'FighterMode', + displayText: 'Fighter Mode', + if: function() { + return this.fightermode; + }, + on: function() { + return this.fightermode = false; + } + } + } + }, + Raven: { + icon: 'raven.jpg', + displayText: 'Raven', + commands: { + inherit: ['unit.movement', 'unit.combat'], + AutoTurret: { + icon: 'AutoTurret.png', + hotkeyCode: 'AutoTurret/Raven', + displayText: 'Auto Turret' + }, + BuildAutoTurret: { + icon: 'BuildAutoTurret.png', + hotkeyCode: 'BuildAutoTurret/Raven', + displayText: 'Build Auto Turret' + }, + BuildPointDefenseDrone: { + icon: 'BuildPointDefenseDrone.png', + hotkeyCode: 'BuildPointDefenseDrone/Raven', + displayText: 'Build Point Defense Drone' + }, + HunterSeekerMissile: { + icon: 'HunterSeekerMissile.png', + hotkeyCode: 'HunterSeekerMissile/Raven', + displayText: 'Hunter Seeker Missile' + }, + PointDefenseDrone: { + icon: 'PointDefenseDrone.png', + hotkeyCode: 'PointDefenseDrone/Raven', + displayText: 'Point Defense Drone' + } + } + }, + Banshee: { + icon: 'banshee.jpg', + displayText: 'Banshee', + commands: { + inherit: ['unit.movement', 'unit.combat'], + CloakOff: { + icon: 'Decloack.jpg', + hotkeyCode: 'CloakOff', + displayText: 'Cloak Off', + if: function() { + return this.cloaked; + }, + on: function() { + return this.cloaked = false; + } + }, + CloakOn: { + icon: 'Cloak.png', + hotkeyCode: 'CloakOnBanshee', + displayText: 'Cloak On', + if: function() { + return !this.cloaked; + }, + on: function() { + return this.cloaked = true; + } + } + } + }, + Medivac: { + icon: 'medivac.jpg', + displayText: 'Medivac', + commands: { + inherit: ['unit.movement', 'unit.load'], + Heal: { + icon: 'Heal.png', + hotkeyCode: 'Heal/Medivac', + displayText: 'Heal' + }, + MedivacSpeedBoost: { + icon: 'MedivacSpeedBoost.png', + hotkeyCode: 'MedivacSpeedBoost/Medivac', + displayText: 'Medivac Speed Boost' + } + } + }, + Battlecruiser: { + icon: 'battlecruiser.jpg', + displayText: 'Battlecruiser', + commands: { + inherit: ['unit.movement', 'unit.combat'], + YamatoGun: { + icon: 'YamatoGun.png', + hotkeyCode: 'YamatoGun', + displayText: 'Yamato Gun' + } + } + } + }, + buildings: { + CommandCenter: { + icon: 'commandcenter.jpg', + displayText: 'Command Center', + commands: { + inherit: ['unit.flying', 'unit.cancel'], + CommandCenterLoad: { + icon: 'Load.gif', + hotkeyCode: 'CommandCenterLoad', + displayText: 'Command Center Load', + if: function() { + return this.upgrade !== 'OrbitalCommand'; + } + }, + CommandCenterUnloadAll: { + icon: 'UnloadAll.jpg', + hotkeyCode: 'CommandCenterUnloadAll', + displayText: 'Command Center Unload All', + if: function() { + return this.upgrade !== 'OrbitalCommand'; + } + }, + BuildOrbitalCommand: { + icon: 'orbitalcommand.jpg', + hotkeyCode: 'OrbitalCommand/CommandCenter', + displayText: 'Build Orbital Command', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'OrbitalCommand'; + } + }, + BuildSCV: { + icon: 'scv.jpg', + hotkeyCode: 'SCV', + displayText: 'Build SCV', + if: function() { + return !this.lifted; + } + }, + UpgradeToPlanetaryFortress: { + icon: 'planetaryfortress.jpg', + hotkeyCode: 'UpgradeToPlanetaryFortress/CommandCenter', + displayText: 'Upgrade To Planetary Fortress', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'PlanetaryFortress'; + } + }, + CalldownMULE: { + icon: 'CalldownMULE.png', + hotkeyCode: 'CalldownMULE/OrbitalCommand', + displayText: 'Calldown MULE', + if: function() { + return this.upgrade === 'OrbitalCommand' && !this.lifted; + } + }, + Scan: { + icon: 'Scan.png', + hotkeyCode: 'Scan/OrbitalCommand', + displayText: 'Scan', + if: function() { + return this.upgrade === 'OrbitalCommand' && !this.lifted; + } + }, + SupplyDrop: { + icon: 'SupplyDrop.png', + hotkeyCode: 'SupplyDrop/OrbitalCommand', + displayText: 'Supply Drop', + if: function() { + return this.upgrade === 'OrbitalCommand' && !this.lifted; + } + }, + Attack: { + icon: 'Attack.png', + hotkeyCode: 'Attack', + displayText: 'Attack', + if: function() { + return this.upgrade === 'PlanetaryFortress'; + } + }, + Stop: { + icon: 'Stop.png', + hotkeyCode: 'StopPlanetaryFortress/PlanetaryFortress', + displayText: 'Stop', + if: function() { + return this.upgrade === 'PlanetaryFortress' || this.lifted; + } + } + } + }, + SupplyDepot: { + icon: 'supplydepot.jpg', + displayText: 'Supply Depot', + commands: { + inherit: ['unit.cancel', 'unit.underconstruction'], + Lower: { + icon: 'Lower.gif', + hotkeyCode: 'Lower/SupplyDepot', + displayText: 'Lower Supply Depot', + if: function() { + return !this.lowered; + }, + on: function() { + return this.lowered = true; + } + }, + Raise: { + icon: 'supplydepot.jpg', + hotkeyCode: 'Raise/SupplyDepotLowered', + displayText: 'Raise Supply Depot', + if: function() { + return this.lowered; + }, + on: function() { + return this.lowered = false; + } + } + } + }, + Barracks: { + icon: 'barracks.jpg', + displayText: 'Barracks', + commands: { + inherit: ['unit.flying', 'unit.cancel'], + BuildGhost: { + icon: 'ghost.jpg', + hotkeyCode: 'Ghost/Barracks', + displayText: 'Build Ghost', + if: function() { + return !this.lifted; + } + }, + BuildMarauder: { + icon: 'marauder.jpg', + hotkeyCode: 'Marauder/Barracks', + displayText: 'Build Marauder', + if: function() { + return !this.lifted; + } + }, + BuildMarine: { + icon: 'marine.jpg', + hotkeyCode: 'Marine/Barracks', + displayText: 'Build Marine', + if: function() { + return !this.lifted; + } + }, + BuildReactor: { + icon: 'reactor.jpg', + hotkeyCode: 'Reactor/Barracks', + displayText: 'Build Reactor', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'Reactor'; + } + }, + BuildReaper: { + icon: 'reaper.jpg', + hotkeyCode: 'Reaper/Barracks', + displayText: 'Build Reaper', + if: function() { + return !this.lifted; + } + }, + BuildTechLab: { + icon: 'techlab.jpg', + hotkeyCode: 'TechLabBarracks/Barracks', + displayText: 'Build Tech Lab', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'TechLab'; + } + } + } + }, + BarracksTechLab: { + icon: 'barrackstechlab.jpg', + displayText: 'Barracks Tech Lab', + commands: { + inherit: ['unit.cancel'], + ResearchStimpack: { + icon: 'Stim.png', + hotkeyCode: 'Stimpack/BarracksTechLab', + displayText: 'Research Stimpack' + }, + ResearchShieldWall: { + icon: 'CombatShield.png', + hotkeyCode: 'ResearchShieldWall/BarracksTechLab', + displayText: 'Research Combat Shield' + }, + ResearchPunisherGrenades: { + icon: 'ConcussiveShells.png', + hotkeyCode: 'ResearchPunisherGrenades/BarracksTechLab', + displayText: 'Research Concussive Shells' + } + } + }, + Bunker: { + icon: 'bunker.jpg', + displayText: 'Bunker', + commands: { + inherit: ['unit.cancel', 'unit.load', 'unit.attack'], + Salvage: { + icon: 'Salvage.gif', + hotkeyCode: 'Salvage/Bunker', + displayText: 'Salvage' + }, + Rally: { + icon: 'Rally.jpg', + hotkeyCode: 'SetBunkerRallyPoint/Bunker', + displayText: 'Rally' + } + } + }, + MissileTurret: { + icon: 'missileturret.jpg', + displayText: 'Missile Turret', + commands: { + inherit: ['unit.combat', 'unit.cancel'] + } + }, + EngineeringBay: { + icon: 'engineeringbay.jpg', + displayText: 'Engineering Bay', + commands: { + inherit: ['unit.cancel'], + ResearchHiSecAutoTracking: { + icon: 'HisecAutoTracking.gif', + hotkeyCode: 'ResearchHiSecAutoTracking/EngineeringBay', + displayText: 'Hi-Sec Auto Tracking' + }, + ResearchNeosteelFrame: { + icon: 'NeosteelFrames.gif', + hotkeyCode: 'ResearchNeosteelFrame/EngineeringBay', + displayText: 'Research Neosteel Frame' + }, + TerranInfantryArmorLevel1: { + icon: 'InfantryArmor1.gif', + hotkeyCode: 'TerranInfantryArmorLevel1/EngineeringBay', + displayText: 'Terran Infantry Armor' + }, + TerranInfantryWeaponsLevel1: { + icon: 'InfantryWeapons1.gif', + hotkeyCode: 'TerranInfantryWeaponsLevel1/EngineeringBay', + displayText: 'Terran Infantry Weapons' + }, + UpgradeBuildingArmorLevel1: { + icon: 'BuildingArmor.gif', + hotkeyCode: 'UpgradeBuildingArmorLevel1/EngineeringBay', + displayText: 'Upgrade Building Armor' + } + } + }, + Factory: { + icon: 'factory.jpg', + displayText: 'Factory', + commands: { + inherit: ['unit.flying', 'unit.cancel'], + BuildHellion: { + icon: 'hellion.jpg', + hotkeyCode: 'Hellion/Factory', + displayText: 'Build Hellion', + if: function() { + return !this.lifted; + } + }, + HellionTank: { + icon: 'hellbat.jpg', + hotkeyCode: 'HellionTank/Factory', + displayText: 'Build HellBat', + if: function() { + return !this.lifted; + } + }, + BuildSiegeTank: { + icon: 'siegetank.jpg', + hotkeyCode: 'SiegeTank/Factory', + displayText: 'Build Siege Tank', + if: function() { + return !this.lifted; + } + }, + BuildTechLab: { + icon: 'TechLab.png', + hotkeyCode: 'TechLabFactory/Factory', + displayText: 'Build Tech Lab', + if: function() { + return !this.lifted; + } + }, + BuildThor: { + icon: 'thor.jpg', + hotkeyCode: 'Thor/Factory', + displayText: 'Build Thor', + if: function() { + return !this.lifted; + } + }, + BuildWidowMine: { + icon: 'widowmine.jpg', + hotkeyCode: 'WidowMine/Factory', + displayText: 'Build Widow Mine', + if: function() { + return !this.lifted; + } + }, + BuildReactor: { + icon: 'reactor.jpg', + hotkeyCode: 'Reactor/Factory', + displayText: 'Build Reactor', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'Reactor'; + } + }, + BuildTechLab: { + icon: 'techlab.jpg', + hotkeyCode: 'TechLabFactory/Factory', + displayText: 'Build Tech Lab', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'TechLab'; + } + } + } + }, + FactoryTechLab: { + icon: 'factorytechlab.jpg', + displayText: 'Factory Tech Lab', + commands: { + inherit: ['unit.cancel'], + ResearchHighCapacityBarrels: { + icon: 'InfernalPreigniter.png', + hotkeyCode: 'ResearchHighCapacityBarrels/FactoryTechLab', + displayText: 'Research Infernal Pre-Igniter' + }, + ResearchDrillClaws: { + icon: 'DrillingClaws.png', + hotkeyCode: 'ResearchDrillClaws/FactoryTechLab', + displayText: 'Research Drill Claws' + } + } + }, + Starport: { + icon: 'starport.jpg', + displayText: 'Starport', + commands: { + inherit: ['unit.flying', 'unit.cancel'], + Banshee: { + icon: 'banshee.jpg', + hotkeyCode: 'Banshee/Starport', + displayText: 'Banshee', + if: function() { + return !this.lifted; + } + }, + BuildBattlecruiser: { + icon: 'battlecruiser.jpg', + hotkeyCode: 'Battlecruiser/Starport', + displayText: 'Build Battlecruiser', + if: function() { + return !this.lifted; + } + }, + BuildTechLabStarport: { + icon: 'BuildTechLabStarport.png', + hotkeyCode: 'BuildTechLabStarport', + displayText: 'Build Tech Lab Starport', + if: function() { + return !this.lifted; + } + }, + BuildMedivac: { + icon: 'medivac.jpg', + hotkeyCode: 'Medivac/Starport', + displayText: 'Build Medivac', + if: function() { + return !this.lifted; + } + }, + BuildRaven: { + icon: 'raven.jpg', + hotkeyCode: 'Raven/Starport', + displayText: 'Build Raven', + if: function() { + return !this.lifted; + } + }, + BuildReactor: { + icon: 'reactor.jpg', + hotkeyCode: 'Reactor/Starport', + displayText: 'Build Reactor', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'Reactor'; + } + }, + BuildTechLab: { + icon: 'techlab.jpg', + hotkeyCode: 'TechLabStarport/Starport', + displayText: 'Build Tech Lab', + if: function() { + return !(this.upgrade || this.lifted); + }, + on: function() { + return this.upgrade = 'TechLab'; + } + }, + VikingFighter: { + icon: 'viking.jpg', + hotkeyCode: 'VikingFighter/Starport', + displayText: 'Viking Fighter', + if: function() { + return !this.lifted; + } + } + } + }, + StarportTechLab: { + icon: 'starporttechlab.jpg', + displayText: 'Starport Tech Lab', + commands: { + inherit: ['unit.cancel'], + ResearchBansheeCloak: { + icon: 'Cloak.png', + hotkeyCode: 'ResearchBansheeCloak/StarportTechLab', + displayText: 'Research Banshee Cloak' + }, + ResearchDurableMaterials: { + icon: 'DurableMaterials.gif', + hotkeyCode: 'ResearchDurableMaterials/StarportTechLab', + displayText: 'Research Durable Materials' + }, + ResearchMedivacEnergyUpgrade: { + icon: 'CaduceusReactor.gif', + hotkeyCode: 'ResearchMedivacEnergyUpgrade/StarportTechLab', + displayText: 'Research Medivac Energy Upgrade' + }, + ResearchRavenEnergyUpgrade: { + icon: 'CorvidReactor.gif', + hotkeyCode: 'ResearchRavenEnergyUpgrade/StarportTechLab', + displayText: 'Research Raven Energy Upgrade' + } + } + }, + Armory: { + icon: 'armory.jpg', + displayText: 'Armory', + commands: { + inherit: ['unit.cancel'], + TerranVehicleAndShipPlatingLevel1: { + icon: 'VehiclePlating1.gif', + hotkeyCode: 'TerranVehicleAndShipPlatingLevel1/Armory', + displayText: 'Upgrade Terran Vehicle Plating' + }, + TerranVehicleAndShipWeaponsLevel1: { + icon: 'VehicleWeapons1.gif', + hotkeyCode: 'TerranVehicleAndShipWeaponsLevel1/Armory', + displayText: 'Upgrade Terran Vehicle Weapons' + } + } + }, + GhostAcademy: { + icon: 'ghostacademy.jpg', + displayText: 'Ghost Academy', + commands: { + inherit: ['unit.cancel'], + NukeArm: { + icon: 'NukeCalldown.png', + hotkeyCode: 'NukeArm/GhostAcademy', + displayText: 'Nuke Arm' + }, + ResearchPersonalCloaking: { + icon: 'Cloak.png', + hotkeyCode: 'ResearchPersonalCloaking/GhostAcademy', + displayText: 'Research Personal Cloaking' + } + } + }, + FusionCore: { + icon: 'fusioncore.jpg', + displayText: 'Fusion Core', + commands: { + inherit: ['unit.cancel'], + ResearchBattlecruiserEnergyUpgrade: { + icon: 'BehemothReactor.gif', + hotkeyCode: 'ResearchBattlecruiserEnergyUpgrade/FusionCore', + displayText: 'Research Battlecruiser Energy Upgrade' + }, + ResearchBattlecruiserSpecializations: { + icon: 'YamatoCannon.png', + hotkeyCode: 'ResearchBattlecruiserSpecializations/FusionCore', + displayText: 'Research Weapon Refit' + } + } + }, + SensorTower: { + icon: 'sensortower.jpg', + displayText: 'Sensor Tower' + } + } + }, + Zerg: { + units: { + Larva: { + icon: 'larva.jpg', + displayText: 'Larva', + commands: { + MorphToCorruptor: { + icon: 'corruptor.jpg', + hotkeyCode: 'Corruptor/Larva', + displayText: 'Morph to Corruptor', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToDrone: { + icon: 'drone.jpg', + hotkeyCode: 'Drone/Larva', + displayText: 'Morph to Drone', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToHydralisk: { + icon: 'hydralisk.jpg', + hotkeyCode: 'Hydralisk/Larva', + displayText: 'Morph to Hydralisk', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToInfestor: { + icon: 'infestor.jpg', + hotkeyCode: 'Infestor/Larva', + displayText: 'Morph to Infestor', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToMutalisk: { + icon: 'mutalisk.jpg', + hotkeyCode: 'Mutalisk/Larva', + displayText: 'Morph to Mutalisk', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToOverlord: { + icon: 'overlord.jpg', + hotkeyCode: 'Overlord/Larva', + displayText: 'Morph to Overlord', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToQueen: { + icon: 'queen.jpg', + hotkeyCode: 'Queen/Larva', + displayText: 'Morph to Queen', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToRoach: { + icon: 'roach.jpg', + hotkeyCode: 'Roach/Larva', + displayText: 'Morph to Roach', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToSwarmHost: { + icon: 'swarmhost.jpg', + hotkeyCode: 'SwarmHostMP/Larva', + displayText: 'Morph to Swarm Host', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToUltralisk: { + icon: 'ultralisk.jpg', + hotkeyCode: 'Ultralisk/Larva', + displayText: 'Morph to Ultralisk', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToViper: { + icon: 'viper.jpg', + hotkeyCode: 'Viper/Larva', + displayText: 'Morph to Viper', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + }, + MorphToZergling: { + icon: 'zergling.jpg', + hotkeyCode: 'Zergling/Larva', + displayText: 'Morph to Zergling', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Egg'); + } + } + } + }, + Egg: { + icon: 'egg.jpg', + displayText: 'Egg', + commands: { + Rally: { + icon: 'Rally.jpg', + hotkeyCode: 'RallyEgg', + displayText: 'Rally' + } + } + }, + Drone: { + icon: 'drone.jpg', + displayText: 'Drone', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow', 'unit.worker'], + BuildBasic: { + icon: 'Build.png', + hotkeyCode: 'ZergBuild/Drone', + displayText: 'Build Basic', + if: function() { + return !(this.buildCard || this.burrowed); + }, + on: function() { + return this.buildCard = 'basic'; + } + }, + BuildAdvanced: { + icon: 'BuildAdvanced.png', + hotkeyCode: 'ZergBuildAdvanced/Drone', + displayText: 'Build Advanced', + if: function() { + return !(this.buildCard || this.burrowed); + }, + on: function() { + return this.buildCard = 'advanced'; + } + }, + Cancel: { + icon: 'Cancel.png', + hotkeyCode: 'Cancel', + displayText: 'Cancel', + if: function() { + return this.buildCard; + }, + on: function() { + return this.buildCard = null; + } + }, + BuildEvolutionChamber: { + icon: 'evolutionchamber.jpg', + hotkeyCode: 'EvolutionChamber/Drone', + displayText: 'Build Evolution Chamber', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildExtractor: { + icon: 'Extractor.png', + hotkeyCode: 'Extractor/Drone', + displayText: 'Extractor', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildHatchery: { + icon: 'hatchery.jpg', + hotkeyCode: 'Hatchery/Drone', + displayText: 'Build Hatchery', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildRoachWarren: { + icon: 'roachwarren.jpg', + hotkeyCode: 'RoachWarren/Drone', + displayText: 'Build Roach Warren', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildSpawningPool: { + icon: 'spawningpool.jpg', + hotkeyCode: 'SpawningPool/Drone', + displayText: 'Build Spawning Pool', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildSpineCrawler: { + icon: 'spinecrawler.jpg', + hotkeyCode: 'SpineCrawler/Drone', + displayText: 'Build Spine Crawler', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildSporeCrawler: { + icon: 'sporecrawler.jpg', + hotkeyCode: 'SporeCrawler/Drone', + displayText: 'Build Spore Crawler', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildBanelingNest: { + icon: 'banelingnest.jpg', + hotkeyCode: 'BanelingNest/Drone', + displayText: 'Build Baneling Nest', + if: function() { + return this.buildCard === 'basic'; + } + }, + BuildHydraliskDen: { + icon: 'hydraliskden.jpg', + hotkeyCode: 'HydraliskDen/Drone', + displayText: 'Build Hydralisk Den', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildInfestationPit: { + icon: 'infestationpit.jpg', + hotkeyCode: 'InfestationPit/Drone', + displayText: 'Build Infestation Pit', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildNydusNetwork: { + icon: 'nydusnetwork.jpg', + hotkeyCode: 'NydusNetwork/Drone', + displayText: 'Build Nydus Network', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildSpire: { + icon: 'spire.jpg', + hotkeyCode: 'Spire/Drone', + displayText: 'Build Spire', + if: function() { + return this.buildCard === 'advanced'; + } + }, + BuildUltraliskCavern: { + icon: 'ultraliskcavern.jpg', + hotkeyCode: 'UltraliskCavern/Drone', + displayText: 'Build Ultralisk Cavern', + if: function() { + return this.buildCard === 'advanced'; + } + } + } + }, + Overlord: { + icon: 'overlord.jpg', + displayText: 'Overlord', + commands: { + inherit: ['unit.movement'], + GenerateCreep: { + icon: 'GenerateCreep.png', + hotkeyCode: 'GenerateCreep/Overlord', + displayText: 'Generate Creep', + if: function() { + return !this.gencreep; + }, + on: function() { + return this.gencreep = true; + } + }, + MorphToOverseer: { + icon: 'MorphToOverseer.png', + hotkeyCode: 'MorphToOverseer/Overlord', + displayText: 'Morph To Overseer' + }, + StopGenerateCreep: { + icon: 'StopGenerateCreep.png', + hotkeyCode: 'StopGenerateCreep/Overlord', + displayText: 'Stop Generate Creep', + if: function() { + return this.gencreep; + }, + on: function() { + return this.gencreep = false; + } + } + } + }, + Zergling: { + icon: 'zergling.jpg', + displayText: 'Zergling', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'], + MorphToBaneling: { + icon: 'baneling.jpg', + hotkeyCode: 'Baneling/Zergling', + displayText: 'Morph to Baneling', + if: function() { + return !this.burrowed; + } + } + } + }, + Roach: { + icon: 'roach.jpg', + displayText: 'Roach', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'] + } + }, + Queen: { + icon: 'queen.jpg', + displayText: 'Queen', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'], + BuildCreepTumor: { + icon: 'BuildCreepTumor.png', + hotkeyCode: 'BuildCreepTumor/Queen', + displayText: 'Build Creep Tumor', + if: function() { + return !this.burrowed; + } + }, + InjectLarva: { + icon: 'larva.jpg', + hotkeyCode: 'MorphMorphalisk/Queen', + displayText: 'Inject Larva', + if: function() { + return !this.burrowed; + } + }, + Transfusion: { + icon: 'Transfusion.png', + hotkeyCode: 'Transfusion/Queen', + displayText: 'Transfusion', + if: function() { + return !this.burrowed; + } + } + } + }, + Baneling: { + icon: 'baneling.jpg', + displayText: 'Baneling', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'], + DisableBuildingAttack: { + icon: 'Explode.png', + hotkeyCode: 'DisableBuildingAttack/Baneling', + displayText: 'Disable Building Attack', + if: function() { + return this.buildingAttack && !this.burrowed; + }, + on: function() { + return this.buildingAttack = false; + } + }, + EnableBuildingAttack: { + icon: 'EnableBuildingAttack.png', + hotkeyCode: 'EnableBuildingAttack/Baneling', + displayText: 'Enable Building Attack', + if: function() { + return !this.buildingAttack && !this.burrowed; + }, + on: function() { + return this.buildingAttack = true; + } + }, + Explode: { + icon: 'Explode.png', + hotkeyCode: 'Explode/Baneling', + displayText: 'Explode' + } + } + }, + Ultralisk: { + icon: 'ultralisk.jpg', + displayText: 'Ultralisk', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'] + } + }, + Hydralisk: { + icon: 'hydralisk.jpg', + displayText: 'Hydralisk', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'] + } + }, + Infestor: { + icon: 'infestor.jpg', + displayText: 'Infestor', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'], + FungalGrowth: { + icon: 'FungalGrowth.png', + hotkeyCode: 'FungalGrowth/Infestor', + displayText: 'Fungal Growth', + if: function() { + return !this.burrowed; + } + }, + InfestedTerrans: { + icon: 'InfestedTerrans.gif', + hotkeyCode: 'InfestedTerrans/Infestor', + displayText: 'Infested Terrans' + }, + NeuralParasite: { + icon: 'NeuralParasite.png', + hotkeyCode: 'NeuralParasite/Infestor', + displayText: 'Neural Parasite', + if: function() { + return !this.burrowed; + } + } + } + }, + SwarmHost: { + icon: 'swarmhost.jpg', + displayText: 'Swarm Host', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.burrow'], + SpawnLocustsBurrowed: { + icon: 'SpawnLocusts.png', + hotkeyCode: 'SwarmHost/SwarmHostBurrowedMP', + displayText: 'Spawn Locusts', + if: function() { + return this.burrowed; + } + }, + SpawnLocusts: { + icon: 'SpawnLocusts.png', + hotkeyCode: 'SwarmHost/SwarmHostMP', + displayText: 'Spawn Locusts', + if: function() { + return !this.burrowed; + } + } + } + }, + Viper: { + icon: 'viper.jpg', + displayText: 'Viper', + commands: { + inherit: ['unit.movement', 'unit.combat'], + BlindingCloud: { + icon: 'BlindingCloud.png', + hotkeyCode: 'BlindingCloud/Viper', + displayText: 'Blinding Cloud' + }, + FaceEmbrace: { + icon: 'ViperAbduct.png', + hotkeyCode: 'FaceEmbrace/Viper', + displayText: 'Abduct' + }, + ViperConsume: { + icon: 'ViperConsume.png', + hotkeyCode: 'ViperConsume/Viper', + displayText: 'Viper Consume' + } + } + }, + Corruptor: { + icon: 'corruptor.jpg', + displayText: 'Corruptor', + commands: { + inherit: ['unit.movement', 'unit.combat'], + BroodLord: { + icon: 'broodlord.jpg', + hotkeyCode: 'BroodLord/Corruptor', + displayText: 'Brood Lord' + }, + CorruptionAbility: { + icon: 'CorruptionAbility.png', + hotkeyCode: 'CorruptionAbility/Corruptor', + displayText: 'Corruption Ability' + } + } + }, + Overseer: { + icon: 'overseer.jpg', + displayText: 'Overseer', + commands: { + inherit: ['unit.movement', 'unit.combat'], + Contaminate: { + icon: 'Contaminate.png', + hotkeyCode: 'Contaminate/Overseer', + displayText: 'Contaminate' + }, + SpawnChangeling: { + icon: 'SpawnChangeling.gif', + hotkeyCode: 'SpawnChangeling/Overseer', + displayText: 'Spawn Changeling' + } + } + }, + Broodlord: { + icon: 'broodlord.jpg', + displayText: 'Broodlord', + commands: { + inherit: ['unit.movement', 'unit.combat'] + } + } + }, + buildings: { + Hatchery: { + icon: 'hatchery.jpg', + displayText: 'Hatchery', + commands: { + inherit: ['unit.cancel'], + SelectLarva: { + icon: 'larva.jpg', + hotkeyCode: 'Larva', + displayText: 'Select Larva', + on: function() { + return this.globalState.selectNew('Zerg', 'units', 'Larva'); + } + }, + Queen: { + icon: 'queen.jpg', + hotkeyCode: 'Queen', + displayText: 'Spawn Queen' + }, + EvolveVentralSacks: { + icon: 'VentralSacs.gif', + hotkeyCode: 'EvolveVentralSacks', + displayText: 'Evolve Ventral Sacks' + }, + BuildLair: { + icon: 'lair.jpg', + hotkeyCode: 'Lair/Hatchery', + displayText: 'Build Lair', + if: function() { + return !this.upgrade; + }, + on: function() { + return this.upgrade = 'Lair'; + } + }, + BuildHive: { + icon: 'hive.jpg', + hotkeyCode: 'Hive/Lair', + displayText: 'Build Hive', + if: function() { + return this.upgrade === 'Lair'; + }, + on: function() { + return this.upgrade = 'Hive'; + } + }, + ResearchBurrow: { + icon: 'Burrow.gif', + hotkeyCode: 'ResearchBurrow', + displayText: 'Research Burrow' + }, + overlordspeed: { + icon: 'PneumatizedCarapace.gif', + hotkeyCode: 'overlordspeed', + displayText: 'Pneumatized Carapace' + } + } + }, + SpineCrawler: { + icon: 'spinecrawler.jpg', + displayText: 'Spine Crawler Uprooted', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + Root: { + icon: 'Root.png', + hotkeyCode: 'SpineCrawlerRoot/SpineCrawlerUprooted', + displayText: 'Root', + on: function() { + return this.unrooted = false; + }, + if: function() { + return this.unrooted; + } + }, + Uproot: { + icon: 'Uproot.png', + hotkeyCode: 'SpineCrawlerUproot/SpineCrawler', + displayText: 'Uproot', + on: function() { + return this.unrooted = true; + }, + if: function() { + return !this.unrooted; + } + } + } + }, + SporeCrawler: { + icon: 'sporecrawler.jpg', + displayText: 'Spore Crawler', + commands: { + inherit: ['unit.movement', 'unit.combat', 'unit.cancel'], + Root: { + icon: 'Root.png', + hotkeyCode: 'SporeCrawlerRoot/SporeCrawlerUprooted', + displayText: 'Root', + on: function() { + return this.unrooted = false; + }, + if: function() { + return this.unrooted; + } + }, + Uproot: { + icon: 'Uproot.png', + hotkeyCode: 'SporeCrawlerUproot/SporeCrawler', + displayText: 'Uproot', + on: function() { + return this.unrooted = true; + }, + if: function() { + return !this.unrooted; + } + } + } + }, + SpawningPool: { + icon: 'spawningpool.jpg', + displayText: 'Spawning Pool', + commands: { + inherit: ['unit.cancel'], + zerglingattackspeed: { + icon: 'AdrenalGlands.gif', + hotkeyCode: 'zerglingattackspeed/SpawningPool', + displayText: 'Adrenal Glands' + }, + zerglingmovementspeed: { + icon: 'MetabolicBoost.gif', + hotkeyCode: 'zerglingmovementspeed/SpawningPool', + displayText: 'Metabolic Boost' + } + } + }, + RoachWarren: { + icon: 'roachwarren.jpg', + displayText: 'Roach Warren', + commands: { + inherit: ['unit.cancel'], + EvolveGlialRegeneration: { + icon: 'EvolveGlialRegeneration.gif', + hotkeyCode: 'EvolveGlialRegeneration/RoachWarren', + displayText: 'Evolve Glial Regeneration' + }, + EvolveTunnelingClaws: { + icon: 'EvolveTunnelingClaws.gif', + hotkeyCode: 'EvolveTunnelingClaws/RoachWarren', + displayText: 'Evolve Tunneling Claws' + } + } + }, + EvolutionChamber: { + icon: 'evolutionchamber.jpg', + displayText: 'Evolution Chamber', + commands: { + inherit: ['unit.cancel'], + zerggroundarmor1: { + icon: 'ZergGroundCarapace1.gif', + hotkeyCode: 'zerggroundarmor1/EvolutionChamber', + displayText: 'Ground Carapace' + }, + zergmeleeweapons1: { + icon: 'ZergMeleeAttacks1.gif', + hotkeyCode: 'zergmeleeweapons1/EvolutionChamber', + displayText: 'Melee Weapons' + }, + zergmissileweapons1: { + icon: 'ZergMissileAttacks1.gif', + hotkeyCode: 'zergmissileweapons1/EvolutionChamber', + displayText: 'Missle Weapons' + } + } + }, + HydraliskDen: { + icon: 'hydraliskden.jpg', + displayText: 'Hydralisk Den', + commands: { + inherit: ['unit.cancel'], + MuscularAugments: { + icon: 'MuscularAugments.png', + hotkeyCode: 'MuscularAugments/HydraliskDen', + displayText: 'Muscular Augments (Range)' + }, + hydraliskspeed: { + icon: 'GroovedSpines.gif', + hotkeyCode: 'hydraliskspeed/HydraliskDen', + displayText: 'Grooved Spines (Speed)' + } + } + }, + InfestationPit: { + icon: 'infestationpit.jpg', + displayText: 'Infestation Pit', + commands: { + inherit: ['unit.cancel'], + EvolveInfestorEnergyUpgrade: { + icon: 'PathogenGlands.gif', + hotkeyCode: 'EvolveInfestorEnergyUpgrade/InfestationPit', + displayText: 'Pathogen Glands' + }, + ResearchLocustLifetimeIncrease: { + icon: 'IncreasedLocustLifetime.gif', + hotkeyCode: 'ResearchLocustLifetimeIncrease/InfestationPit', + displayText: 'Enduring Locusts' + }, + ResearchNeuralParasite: { + icon: 'NeuralParasite.png', + hotkeyCode: 'ResearchNeuralParasite/InfestationPit', + displayText: 'Research Neural Parasite' + } + } + }, + UltraliskCavern: { + icon: 'ultraliskcavern.jpg', + displayText: 'Ultralisk Cavern', + commands: { + inherit: ['unit.cancel'], + EvolveChitinousPlating: { + icon: 'ChitinousPlating.gif', + hotkeyCode: 'EvolveChitinousPlating/UltraliskCavern', + displayText: 'Evolve Chitinous Plating' + } + } + }, + BanelingNest: { + icon: 'banelingnest.jpg', + displayText: 'Baneling Nest', + commands: { + inherit: ['unit.cancel'], + EvolveCentrificalHooks: { + icon: 'CentrifugalHooks.gif', + hotkeyCode: 'EvolveCentrificalHooks/BanelingNest', + displayText: 'Centrifugal Hooks' + } + } + }, + Spire: { + icon: 'spire.jpg', + displayText: 'Spire', + commands: { + inherit: ['unit.cancel'], + BuildGreaterSpire: { + icon: 'greaterspire.jpg', + hotkeyCode: 'GreaterSpire/Spire', + displayText: 'Build Greater Spire' + }, + GreaterSpireBroodlord: { + icon: 'GreaterSpireBroodlord.png', + hotkeyCode: 'GreaterSpireBroodlord/Spire', + displayText: 'Greater Spire Broodlord' + }, + zergflyerarmor1: { + icon: 'FlyerCarapace1.gif', + hotkeyCode: 'zergflyerarmor1', + displayText: 'Flyer Carapace' + }, + zergflyerattack1: { + icon: 'FlyerAttack1.gif', + hotkeyCode: 'zergflyerattack1', + displayText: 'Flyer Attacks' + } + } + }, + GreaterSpire: { + icon: 'greaterspire.jpg', + displayText: 'Greater Spire', + commands: { + inherit: ['unit.cancel'], + zergflyerarmor1: { + icon: 'FlyerCarapace1.gif', + hotkeyCode: 'zergflyerarmor1', + displayText: 'Flyer Carapace' + }, + zergflyerattack1: { + icon: 'FlyerAttack1.gif', + hotkeyCode: 'zergflyerattack1', + displayText: 'Flyer Attacks' + } + } + }, + NydusNetwork: { + icon: 'nydusnetwork.jpg', + displayText: 'Nydus Network', + commands: { + inherit: ['unit.load', 'unit.cancel'], + SummonNydusWorm: { + icon: 'NydusWorm.jpeg', + hotkeyCode: 'SummonNydusWorm/NydusNetwork', + displayText: 'Summon Nydus Worm' + }, + Stop: { + icon: 'Stop.png', + hotkeyCode: 'Stop', + displayText: 'Stop' + } + } + }, + CreepTumor: { + icon: 'creeptumor.jpg', + displayText: 'Creep Tumor', + commands: { + inherit: ['unit.cancel'], + BuildCreepTumorPropagate: { + icon: 'SpawnCreepTumor.gif', + hotkeyCode: 'BuildCreepTumorPropagate/CreepTumorBurrowed', + displayText: 'Build Creep Tumor Propagate' + } + } + } + } + } + }; + +}).call(this); diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..d128ab0 --- /dev/null +++ b/src/index.js @@ -0,0 +1,1238 @@ +// Generated by CoffeeScript 2.2.1 +(function() { + var classKeyMap, commandCards, commandClass, commandClassMap, commandDisplayMap, commandDisplayName, commandIcons, eachRace, fnJSON, germanClassKeyMap, hotkeys, indented, k, keyClass, keyClassMap, keyCodeMaps, keySizeStyles, keySizes, keyboards, loadHotkeys, preloadUrls, raceCards, raceClass, require, sizeClass, touch, unitStyles, v, + splice = [].splice, + indexOf = [].indexOf; + + require = process.mainModule.require; + + hotkeys = require('hotkeys.coffee'); + + commandCards = hotkeys.commandCards; + + raceCards = hotkeys.raceCards; + + keyboards = require('keyboards.coffee'); + + keyCodeMaps = keyboards.keyCodeMaps; + + keyboards = keyboards.keyboards; + + fnJSON = function(o) { + return JSON.stringify(o, function(k, v) { + if (typeof v === 'function') { + return v.toString(); + } else { + return v; + } + }); + }; + + loadHotkeys = function(keyText) { + var j, len, line, m, map, ref; + map = {}; + ref = keyText.split('\n'); + for (j = 0, len = ref.length; j < len; j++) { + line = ref[j]; + if (!(m = line.match(/([\w\/]+)=([\w\+,]+)/))) { + continue; + } + map[m[1]] = m[2].split(','); + } + return map; + }; + + commandDisplayMap = { + HellionTank: 'Hellbat' + }; + + commandDisplayName = function(command) { + var m; + if (m = command.match(/(ControlGroup|Camera)\w+(\d)/)) { + return m[2]; + } else { + return commandDisplayMap[command] || command.replace(/([a-z])([A-Z])/g, "$1 $2"); + } + }; + + commandClassMap = {}; + + commandClass = function(command) { + var m; + if (m = command.match(/((ControlGroup|Camera)\w+)\d/)) { + return m[1]; + } else { + return commandClassMap[command] || command; + } + }; + + String.prototype.repeat = function(n) { + if (n) { + return new Array(n + 1).join(this); + } else { + return ''; + } + }; + + String.prototype.trim = function() { + return this.replace(/(^\s+|\s+$)/g, ''); + }; + + touch = function() { + return text(' '); + }; + + classKeyMap = { + Apostrophe: '\'', + SemiColon: ';', + Slash: '/', + Comma: ',', + Grave: '`', + BracketClose: ']', + BracketOpen: '[', + CapsLock: 'CAPS', + Control: 'CTRL', + Shift: 'SHIFT', + Alt: 'ALT', + Enter: 'ENTER', + Windows: 'WIN', + Menu: 'MENU', + Space: 'SPACE', + Period: '.', + Minus: '-', + Equals: '=', + Backslash: '\\', + Tab: 'TAB', + Escape: 'ESC' + }; + + germanClassKeyMap = { + Grave: 'ö', + Apostrophe: 'ä', + SemiColon: 'ü', + BracketOpen: 'ß', + BracketClose: '´', + Equals: '+' + }; + + keyClassMap = {}; + + for (k in classKeyMap) { + v = classKeyMap[k]; + keyClassMap[v] = k; + } + + for (k in germanClassKeyMap) { + v = germanClassKeyMap[k]; + keyClassMap[v] = k; + } + + keyClass = function(key) { + if (voidKey(key)) { + return 'void'; + } else { + return keyClassMap[(key || '').split(' ')[0]] || (key || '').trim(); + } + }; + + indented = function(fn) { + return function(...args) { + var o, out, ref; + ref = args, [...args] = ref, [o] = splice.call(args, -1); + if (o === void 0) { + o = {}; + } + out = fn(...args, o); + if (typeof out === 'object') { + out = out.join('\n'); + } + out = out.replace(/\n/g, `\n${'\t'.repeat(o.indent)}`); + return out; + }; + }; + + sizeClass = function(size) { + return size.toString().replace(/\./, '-'); + }; + + keySizes = [0.5, 1, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 6]; + + keySizeStyles = indented(function() { + var j, len, results, size; + results = []; + for (j = 0, len = keySizes.length; j < len; j++) { + size = keySizes[j]; + results.push(`key-size-width '${sizeClass(size)}', ${size}`); + } + return results; + }); + + unitStyles = indented(function() { + var icons, kind, race, raceName, unit, unitName, units; + icons = []; + for (raceName in raceCards) { + race = raceCards[raceName]; + for (kind in race) { + units = race[kind]; + for (unitName in units) { + unit = units[unitName]; + icons.push(`unit-class '${unitName}', '${unit.icon}'`); + } + } + } + return icons; + }); + + raceClass = function(raceName) { + return raceName; + }; + + eachRace = indented(function(fn) { + var race, results; + results = []; + for (race in raceCards) { + results.push(fn(race)); + } + return results; + }); + + commandIcons = indented(function() { + var cat, command, commands, icons, kind, name, race, raceName, ref, ref1, unit, unitName, units; + icons = []; + for (raceName in raceCards) { + race = raceCards[raceName]; + for (kind in race) { + units = race[kind]; + for (unitName in units) { + unit = units[unitName]; + ref = unit.commands; + for (name in ref) { + command = ref[name]; + icons.push(`command-icon '${name}', '${command.icon || `${name}.png`}'`); + } + } + } + } + ref1 = commandCards.unit; + for (cat in ref1) { + commands = ref1[cat]; + for (name in commands) { + command = commands[name]; + if (command.icon) { + icons.push(`command-icon '${name}', '${command.icon || `${name}.png`}'`); + } + } + } + return icons; + }); + + preloadUrls = function() { + var command, icon; + return ((new Array).concat((function() { + var results; + results = []; + for (command in commandIconMap) { + icon = commandIconMap[command]; + results.push(`url('icons/${command}.png')`); + } + return results; + })(), (function() { + var results; + results = []; + for (command in commandUnitIconMap) { + icon = commandUnitIconMap[command]; + results.push(`url('icons/${command.toLowerCase()}.jpg')`); + } + return results; + })())).join(' '); + }; + + doctype(5); + + html(function() { + var blankRow, containerTemplate, formatKeyCap, renderKeyboard, voidKey; + head(function() { + var styles; + styles = `\nborder-radius()\n -webkit-border-radius arguments\n -moz-border-radius arguments\n border-radius arguments\nselectable(yes)\n unless yes\n -webkit-touch-callout none;\n -webkit-user-select none;\n -khtml-user-select none;\n -moz-user-select none;\n -ms-user-select none;\n user-select none;\ntransition()\n transition arguments\n -webkit-transition arguments\n -moz-transition arguments\n -o-transition arguments\n -ms-transition arguments\n\nanimation()\n animation arguments\n -webkit-animation arguments\n -moz-animation arguments\n -o-animation arguments\n -ms-animation arguments\n\ntransform()\n transform arguments\n -webkit-transform arguments\n -moz-transform arguments\n -o-transform arguments\n -ms-transform arguments\n\nbox-shadow()\n box-shadow arguments\n -webkit-box-shadow arguments\n -moz-box-shadow arguments\n -o-box-shadow arguments\n -ms-box-shadow arguments\ntext-shadow()\n text-shadow arguments\n -webkit-text-shadow arguments\n -moz-text-shadow arguments\n -o-text-shadow arguments\n -ms-text-shadow arguments\n\nuiColor = #18c6c6\nuiGlowColor = #16b6b6\n\nfade(color, alpha)\n rgba(red(color),green(color),blue(color),alpha)\n\nbody:after\n content ${(false ? dopreloadUrls : void 0)}\n display none\n\nbody\n font-family 'Helvetica', sans-serif\n\nbody\n background-color black\n margin 0\n padding 0 0 0 20px\n color white\n text-shadow white 0 0 5px\n background-image url('gray-background.png')\n background-position 202px 0px\n .left-strip\n background-image url('teal-left.png')\n width 202px\n height 100%\n position absolute\n left 0\n top 0\n z-index -10\n.grid\n width 100%\n height 100%\n position fixed\n z-index -1\n // background-image url('hex_green.png')\n background-size 80px\n opacity 0.1\n.title\n font-size 100px\n color white\n text-shadow white\n font-family Helvetica\n position fixed\n z-index -5\n right 10px\n bottom 10px\n opacity 1\n font-size 45px\n font-weight lighter\n background-image url('the-core-alpha.png')\n height 65px\n width 300px\n padding-top 300px\n text-align center\n background-repeat no-repeat\n background-size 300px\n .the\n color #ADADAD\n text-shadow #ADADAD 0 0 10px\n .braces\n color uiColor\n text-shadow uiGlowColor 0 0 10px\n.container\n width 920px\n padding 10px\n margin auto\n\n.tutorial-overlay\n position fixed\n top 0\n left 0\n width 100%\n height 100%\n z-index 499\n background-color fade(black, 70%)\n\n.tutorial\n width 700px\n height 500px\n padding 50px\n padding-top 10px\n border 4px solid fade(uiColor, 50%)\n overflow auto\n position absolute\n left 50%\n top 50%\n margin-left -400px\n margin-top -350px\n z-index 500\n border-radius 25px\n box-shadow fade(uiColor, 30%) 0 0 10px, inset fade(uiColor, 30%) 0 0 10px\n background-color fade(black, 70%)\n color white\n text-shadow fade(white, 30%) 0 0 5px\n a\n cursor pointer\n display inline-block\n margin 10px\n padding 10px\n box-shadow fade(white, 30%) 0 0 10px, inset fade(white, 30%) 0 0 10px\n background-color transparent\n transition background-color 0.5s\n &:hover\n box-shadow fade(uiColor, 50%) 0 0 10px, inset fade(uiColor, 50%) 0 0 10px\n &:active,&.selected\n background fade(uiColor, 30%)\n box-shadow fade(uiColor, 50%) 0 0 10px, inset fade(uiColor, 50%) 0 0 10px\n\n.footer\n width 65%\n margin-top 10px\n margin 10px\n background-color fade(uiColor, 15%)\n border 4px solid fade(uiColor, 30%)\n box-shadow fade(uiColor, 50%) 0px 0px 10px\n border-radius 10px\n padding 10px\n a\n cursor pointer\n margin-right 20px\n text-decoration none\n color white !important\n text-shadow white 0 0 20px\n &:hover\n text-shadow white 0 0 5px\n\n\n.keyboard\n height 400px\n overflow visible\n position relative\n .inner\n width 900px\n position relative\n transition left 1s\n .hand\n transition opacity 1s, transform 1s, left 1s\n background-image url("icons/hand.png")\n position absolute\n z-index 300\n background-size 65%\n pointer-events none\n background-repeat no-repeat\n animation pulse-opacity 4s alternate linear infinite\n width 483px\n height 299px\n\n &.display-left\n .inner\n left 330px\n .mouse\n left -260px\n .hand\n left 230px\n top 123px\n transform scaleX(-1) rotate(-9deg)\n &.display-right\n .inner\n left -300px\n .mouse\n left 1000px\n .hand\n left 189px\n top 123px\n transform rotate(-9deg)\n &.display-full\n .inner\n left 0\n .mouse\n opacity 0\n .hand\n opacity 0\n display none\n\n\nkey-color = uiColor\nkey-width = 60px\nkey-height = key-width\nkey-border-width = 2px\nkey-margin = 2px\nkey-inner-height = key-height - key-margin * 2 - key-border-width * 2\nkey-border-radius = 3px\n\ncap-margin = key-width * 0.2\n\n.mouse\n border-radius 50px\n\n border key-border-width*2 solid fade(key-color, 50%)\n box-shadow fade(key-color, 30%) 0 0 10px, inset fade(key-color, 30%) 0 0 10px\n background-color transparent\n\n width 150px\n height 200px\n padding 25px\n position absolute\n top 100px\n opacity 1\n transition opacity 1s\n .key-ForwardMouseButton,.key-BackMouseButton\n position absolute\n left -20px\n &.key-size-0-5\n .map\n width key-width\n overflow visible\n left 0 - key-width * 0.5\n .key-ForwardMouseButton\n top 60px\n .key-BackMouseButton\n top 140px\n\n.row\n height key-height\n float left\n width 100%\n &.row-0-5\n height key-width * 0.5\n\n@keyframes pulse-background\n 0%\n background-color fade(lighten(key-color, 10%), 5%)\n 100%\n background-color fade(darken(key-color, 10%), 30%)\n\n@keyframes pulse-opacity\n 0%\n opacity 0\n 100%\n opacity 0.1\n.key\n float left\n position relative\n\n &.key-void\n background-color transparent !important\n box-shadow none !important\n border-color transparent !important\n\n border-radius key-border-radius\n margin key-margin\n\n cursor pointer\n selectable false\n\n border key-border-width solid fade(key-color, 50%)\n box-shadow fade(key-color, 30%) 0 0 5px, inset fade(key-color, 30%) 0 0 5px\n background-color transparent\n\n .overlay\n position absolute\n top -4px\n left -4px\n opacity 0\n z-index 200\n height key-inner-height\n border-radius key-border-radius\n transition opacity 0.3s, top 0.3s, left 0.3s\n &.black\n background-color fade(white, 50%)\n box-shadow fade(white, 30%) 0 0 15px, inset fade(white, 30%) 0 0 15px\n &.white\n background-color fade(uiColor, 50%)\n box-shadow fade(uiColor, 50%) 0 0 15px, inset fade(uiColor, 50%) 0 0 15px\n &:hover\n .overlay.white\n opacity 1\n &.selected\n .overlay.black\n top 0\n left 0\n opacity 1\n .overlay.white\n top 0\n left 0\n opacity 0\n .cap,.maps\n top 0\n left 0\n &.key-Control, &.key-Shift, &.key-Alt\n animation pulse-background 3s alternate linear infinite\n &:hover, &:active, &.selected\n animation none\n\n height key-inner-height\n key-size-width(size, mult)\n &.key-size-{size}\n key-inner-width = (key-width * mult) - key-margin * 2 - key-border-width * 2\n width key-inner-width\n .map\n width key-inner-width\n .overlay\n width key-inner-width\n ${keySizeStyles({ + indent: 1 + })}\n\n .cap\n margin-top 15px\n text-align center\n text-shadow black 0 0 1px\n font-weight bold\n .maps\n position absolute\n top -4px\n left -4px\n transition top 0.3s, left 0.3s\n map()\n overflow hidden\n max-height key-height - key-margin * 2\n margin-top 2px\n font-size 12px\n .map\n map()\n position absolute\n top 0\n left 0\n &.map-command\n z-index 1\n background-color fade(white, 60%)\n box-shadow uiColor 0 0 15px, inset uiColor 0 0 7px\n text-shadow black 0 0 1px\n &.map-global\n z-index 10\n background-color fade(uiColor, 30%)\n box-shadow uiColor 0 0 7px, inset uiColor 0 0 7px\n color white\n text-shadow white 0 0 1px\n\n command-icon(command, icon)\n &.map-{command}\n background-image url('icons/'+icon)\n background-size contain\n background-repeat no-repeat\n border-radius key-border-radius\n height key-inner-height\n margin-top 0\n text-indent -9999px\n z-index 100\n ${commandIcons({ + indent: 2 + })}\n\n\n &.command-ControlGroupRecall,&.command-ControlGroupAppend,&.command-ControlGroupAssign,&.command-CameraSave,&.command-CameraView\n text-align center\n font-size 20px\n &:before, &:after\n font-size 15px\n display block\n map()\n &.unit-icon\n text-indent 0\n &.command-ControlGroupRecall,&.command-ControlGroupAppend,&.command-ControlGroupAssign\n background-color fade(lightgreen, 30%)\n box-shadow lightgreen 0 0 7px, inset lightgreen 0 0 7px\n &:before\n content 'Group'\n &.command-CameraSave,&.command-CameraView\n background-color fade(lightblue, 30%)\n box-shadow lightblue 0 0 7px, inset lightblue 0 0 7px\n &:before\n content 'Camera'\n &.command-CameraSave\n &:after\n content 'SET'\n background-color fade(lightgreen, 30%)\n box-shadow lightgreen 0 0 7px, inset lightgreen 0 0 7px\n &.command-ControlGroupRecall\n background-color fade(lightgreen, 30%)\n box-shadow lightgreen 0 0 7px, inset lightgreen 0 0 7px\n &:after\n background-color\n background-color fade(lightgreen, 30%)\n box-shadow lightgreen 0 0 7px, inset lightgreen 0 0 7px\n &.command-ControlGroupAppend\n &:after\n content 'ADD'\n background-color fade(lightblue, 30%)\n box-shadow lightblue 0 0 7px, inset lightblue 0 0 7px\n &.command-ControlGroupAssign\n &:after\n content 'SET'\n background-color fade(pink, 30%)\n box-shadow pink 0 0 7px, inset pink 0 0 7px\n\n.settings-bar\n height 60px\n\n .setting\n float right\n select, label\n display block\n\n\n.unit-icon\n icon-width = 50px\n icon-height = 50px\n float left\n margin 2px\n margin-bottom 10px\n border-radius 3px\n width icon-width\n height icon-height\n background-size icon-width icon-height\n background-repeat no-repeat\n\n text-indent -9999px\n\n cursor pointer\n border-width(border-width)\n border-width border-width\n border-style solid\n background-position 0 - border-width\n width icon-width - border-width * 2\n height icon-height - border-width * 2\n position relative\n\n hover-transition(time)\n transition width time, height time, background-size time, top time, margin-bottom time\n\n hover-transition 0.5s\n\n hover-size = 65px\n &.selected, &:hover\n width hover-size\n height hover-size\n background-size hover-size hover-size\n margin-bottom 0px\n &.selected, &.selected:hover\n top -15px\n &:hover\n top -7.5px\n hover-transition 0.2s\n\n\n unit-class(unit, icon)\n &.unit-{unit}\n background-image url('icons/' + icon)\n ${unitStyles({ + indent: 1 + })}\nZerg-color = #8218c6\nProtoss-color = #e6e240\nTerran-color = #c61818\n\n.races-commands\n display block\n position relative\n height 225px\n\n.race-commands\n position absolute\n top 0\n left 0\n width 1100px\n transition opacity 1s\n opacity 1\n z-index 10\n &.hide\n opacity 0\n z-index 0\n .unit-commands\n float left\n clear both\n\n\n race-unit-icon-color(race, color)\n &.race-{race}\n .unit-icon\n box-shadow color 0 0 7px, inset color 0 0 7px\n ${eachRace((function(race) { + return `race-unit-icon-color '${race}', ${race}-color`; + }), { + indent: 1 + })}\n\n .unit-commands\n margin-top 10px\n padding 5px\n border-radius 15px\n h3\n margin 0\n color black\n\n race-background-color(race, color)\n &.race-{race} .unit-commands\n background-color fade(color, 15%)\n border 4px solid fade(color, 30%)\n box-shadow fade(color, 50%) 0px 0px 10px\n &.race-{race}\n h3\n color fade(color, 50%)\n text-shadow fade(color, 30%) 0px 0px 5px\n\n ${eachRace((function(race) { + return `race-background-color '${race}', ${race}-color`; + }), { + indent: 1 + })}\n\n\n.races-icons\n margin-top -60px\n margin-bottom 5px\n height 75px\n display block\n h3\n float left\n color fade(white, 70%)\n text-shadow fade(white, 70%) 0 0 1px\n font-weight normal\n .race-icon\n transition background-color 0.5s, border-color 0.5s\n width 75px\n height 75px\n float left\n border-width 4px\n border-style solid\n border-color transparent\n border-radius 7px\n\n cursor pointer\n text-indent -9999px\n race-color(race, color)\n &.race-{race}\n &:hover, &.selected\n border 4px solid fade(color, 30%)\n box-shadow fade(color, 50%) 0px 0px 10px, inset fade(color, 50%) 0px 0px 10px\n &.selected\n background-color fade(color, 15%)\n ${eachRace((function(race) { + return `race-color '${race}', ${race}-color`; + }), { + indent: 2 + })}\n\n background-repeat no-repeat\n background-size contain\n background-color transparent\n race-background(race)\n &.race-{race}\n background-image url('icons/'+race+'.png')\n ${eachRace((function(race) { + return `race-background '${race}'`; + }), { + indent: 2 + })}\n\n.messages\n position absolute\n top 20px\n right 20px\n text-align right\n color white\n text-shadow fade(white,30%) 0 0 10px\n z-index 400\n width 400px\n height 400px\n pointer-events none\n h3\n transition top 3s, height 3s\n height 40px\n margin 0\n padding 0\n &.hide\n top -200px\n height 0px\n\n position relative\n`; + stylus(styles); + script({ + src: 'lib/zepto.min.js' + }); + script({ + src: 'lib/zepto.cookie.min.js' + }); + script({ + src: 'lib/coffeecup.js' + }); + return script('// Google AnalyticsX\n(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\');\n\nga(\'create\', \'UA-57073194-1\', \'github.io\');\nga(\'send\', \'pageview\');'); + }); + blankRow = function(row) { + return Object.keys(row).length === 0; + }; + voidKey = function(key) { + return key && key.match(/_\d+/); + }; + formatKeyCap = function(key) { + if (voidKey(key)) { + return ' '; + } + return key.split(' ')[0]; + }; + renderKeyboard = function(keyboard) { + var j, len, results, row; + keyboard || (keyboard = this.keyboard); + text; + div('.mouse', function() { + var button, ref, results, size, which; + button = function(which, size) { + return div(`.${which.toLowerCase()}-button.key.key-size-${sizeClass(size)}.key-${which}MouseButton`, function() { + div('.overlay.black', touch); + div('.overlay.white', function() { + return div('.cap', function() {}); + }); + return div('.maps', function() {}); + }); + }; + ref = { + Left: 1, + Middle: 0.5, + Right: 1, + Forward: 0.5, + Back: 0.5 + }; + results = []; + for (which in ref) { + size = ref[which]; + results.push(button(which, size)); + } + return results; + }); + results = []; + for (j = 0, len = keyboard.length; j < len; j++) { + row = keyboard[j]; + results.push(div(`.row.${(blankRow(row) ? 'row-0-5' : void 0)}`, function() { + var key, results1, size; + results1 = []; + for (key in row) { + size = row[key]; + if (typeof size === 'string') { + size = 1; + } + results1.push(div(`.key.key-${keyClass(key)}.key-size-${sizeClass(size)}`, function() { + div('.overlay.black', touch); + div('.overlay.white', function() { + return div('.cap', function() { + return formatKeyCap(key); + }); + }); + return div('.maps', function() {}); + })); + } + return results1; + })); + } + return results; + }; + containerTemplate = function() { + div('.keyboard', function() { + div('.hand', function() {}); + return div('.inner', function() {}); + }); + // renderKeyboard keyboards['US QWERTY'] + div('.settings-bar', function() { + div('.setting', function() { + label('Keyboard Layout:'); + return select('.keyboard-layout', function() { + var first, keyboard, results; + first = true; + results = []; + for (keyboard in keyboards) { + results.push(option({ + value: keyboard, + selected: first && (first = false) + }, function() { + return keyboard; + })); + } + return results; + }); + }); + div('.setting', function() { + label('Hotkeys:'); + return select('.hotkey-file', function() { + var first, name, results; + first = true; + results = []; + for (name in TheCore.currentHotkeysFiles) { + results.push(option({ + value: name, + selected: first && (first = false) + }, function() { + return name; + })); + } + return results; + }); + }); + return div('.setting', function() { + label('Display:'); + return select('.display-side', function() { + var first, ref, results, side, value; + first = true; + ref = { + right: 'Right Side', + left: 'Left Side', + full: 'Full Keyboard' + }; + results = []; + for (value in ref) { + side = ref[value]; + results.push(option({ + value: value, + selected: first && (first = false) + }, function() { + return side; + })); + } + return results; + }); + }); + }); + div('.races-icons', function() { + var race; + for (race in TheCore.raceCards) { + div(`.race-icon.race-${raceClass(race)}`, function() { + return race; + }); + } + return h3('Select a unit or building to see commands'); + }); + return div('.races-commands', function() { + var kinds, race, ref, results; + ref = TheCore.raceCards; + results = []; + for (race in ref) { + kinds = ref[race]; + results.push(div(`.race-commands.race-${raceClass(race)}`, function() { + var kind, results1, units; + results1 = []; + for (kind in kinds) { + units = kinds[kind]; + results1.push(div(`.unit-commands.kind-${kind}`, function() { + var results2, unit, unitName; + h3(function() { + return `${race} ${kind}`; + }); + results2 = []; + for (unitName in units) { + unit = units[unitName]; + results2.push(div(`.unit-icon.unit-${unitName}`, function() { + return unit.displayText || unitName; + })); + } + return results2; + })); + } + return results1; + })); + } + return results; + }); + }; + return body(function() { + div('.grid', function() {}); + div('.left-strip', function() {}); + div('.title', function() { + span('.braces', function() { + return '{  '; + }); + span('.the', function() { + return 'The'; + }); + span('.core', function() { + return 'Core'; + }); + return span('.braces', function() { + return '  }'; + }); + }); + div('.messages', function() {}); + div('.container', function() {}); + div('.tutorial-overlay', function() {}); + div('.tutorial', function() { + img({ + src: 'logo-strip.png' + }); + h1({ + style: 'text-align:center' + }, function() { + return 'Interactive Demo'; + }); + p(function() { + return ' The Core is a highly-optimized alternative hotkey layout for StarCraft 2.\nInstead of looking at a list of keys, use this tool to put your hands on the keyboard and see what does what.'; + }); + h3('The Tilt'); + img({ + src: 'tilt.jpg' + }); + p(function() { + return 'The Core is designed to be used with your off-hand on the side of your keyboard closest to your mouse, with a tilted keyboard to keep your wrist straight.'; + }); + img({ + src: 'pull-keys.jpg' + }); + p(function() { + return 'You\'ll need to press Shift, Ctrl and Shift-Ctrl a lot, so you may want to remove the keys between Alt and Ctrl.'; + }); + a('.select-corelite', function() { + return "If you're on a laptop or can't tilt your keyboard, try The Core Lite instead."; + }); + h3('There are left- and right-handed variants, and layouts for each race as well as a generic Random layout.'); + p(function() { + return 'Are you right- or left-handed?'; + }); + a('.select-hand.hand-Right', function() { + return 'Right-Handed'; + }); + a('.select-hand.hand-Left', function() { + return 'Left-Handed'; + }); + p(function() { + return 'What is your main class? (Every layout is designed to allow off-racing. If you play all three equally, choose Random.)'; + }); + a('.select-race.race-zerg', function() { + return 'Zerg'; + }); + a('.select-race.race-terran', function() { + return 'Terran'; + }); + a('.select-race.race-protoss', function() { + return 'Protoss'; + }); + a('.select-race.race-random', function() { + return 'Random'; + }); + p(function() { + return '(Don\'t worry, this is easy to change later.)'; + }); + return coffeescript(function() { + var TheCore, each, j, kind, len, ones, parts, race, races, side, sides, size, sizes; + window.TheCore = TheCore = { + version: '', + layoutCodeToDisplayName: function(code) { + return `The Core ${code} ${this.version} (${this.layoutRaces[code[0]]} ${this.layoutSides[code[1]]}-Handed ${this.layoutSizes[code[2]]})`; + }, + layoutCodeToFileName: function(code) { + return `TheCore ${code} ${this.version}.SC2Hotkeys`; + } + }; + parts = { + layoutRaces: 'Protoss Zerg Terran Random'.split(' '), + layoutSides: 'Right Left'.split(' '), + layoutSizes: 'Large Medium Small'.split(' ') + }; + for (kind in parts) { + ones = parts[kind]; + TheCore[kind] = {}; + for (j = 0, len = ones.length; j < len; j++) { + each = ones[j]; + TheCore[kind][each[0]] = each; + } + } + [races, sides, sizes] = (function() { + var ref, results; + ref = [TheCore.layoutRaces, TheCore.layoutSides, TheCore.layoutSizes]; + results = []; + for (k in ref) { + v = ref[k]; + results.push(v); + } + return results; + })(); + TheCore.layoutCodes = $.map((function() { + var results; + results = []; + for (side in sides) { + results.push((function() { + var results1; + results1 = []; + for (race in races) { + results1.push((function() { + var results2; + results2 = []; + for (size in sizes) { + results2.push(`${race}${side}${size}`); + } + return results2; + })()); + } + return results1; + })()); + } + return results; + })(), function(a) { + return $.map(a, function(n) { + return n; + }); + }); + return $(function() { + var dismiss, hand, layoutSize; + hand = race = null; + layoutSize = 'medium'; + dismiss = function() { + var c, code; + c = function(s) { + return s[0].toUpperCase(); + }; + code = `${c(race)}${c(hand)}${c(layoutSize)}`; + $('select.hotkey-file').val(TheCore.layoutCodeToDisplayName(code)).change(); + return $('.tutorial-overlay').click(); + }; + $('.select-corelite').click(function() { + $('select.hotkey-file').val("The Core Lite").change(); + return $('.tutorial-overlay').click(); + }); + $('.select-hand').click(function() { + hand = this.className.match(/hand-(\w+)/)[1]; + $('.tutorial .select-hand').removeClass('selected'); + $(this).addClass('selected'); + if (race != null) { + return dismiss(); + } + }); + return $('.select-race').click(function() { + var ref; + race = (ref = this.className.match(/race-(\w+)/)) != null ? ref[1] : void 0; + $('.tutorial .select-race').removeClass('selected'); + $(this).addClass('selected'); + if (hand != null) { + return dismiss(); + } + }); + }); + }); + }); + div('.footer', function() { + a('.show-tutorial', function() { + return 'Show Tutorial'; + }); + a({ + href: 'https://github.com/IvanVolosyuk/thecorevisualizer', + target: 'blank' + }, function() { + return 'About'; + }); + return coffeescript(function() { + return $('.footer .show-tutorial').on('click', function() { + return $('.tutorial,.tutorial-overlay').show(); + }); + }); + }); + script(`window.containerTemplate = ${containerTemplate.toString()};`); + script(`window.keyboards = ${JSON.stringify(keyboards)};`); + script(`window.keyCodeMaps = ${JSON.stringify(keyCodeMaps)};`); + script(`window.keyboardTemplate = ${renderKeyboard.toString()};`); + script(`window.touch = ${touch.toString()};`); + script(`window.blankRow = ${blankRow.toString()};`); + script(`window.formatKeyCap = ${formatKeyCap.toString()};`); + script(`window.sizeClass = ${sizeClass.toString()};`); + script(`window.raceClass = ${raceClass.toString()};`); + script(`window.keyClassMap = ${JSON.stringify(keyClassMap)};`); + script(`window.voidKey = ${voidKey.toString()};`); + script(`window.keyClass = ${keyClass.toString()};`); + script(`window.commandDisplayMap = ${JSON.stringify(commandDisplayMap)};`); + script(`window.commandDisplayName = ${commandDisplayName.toString()};`); + script(`window.commandClassMap = ${JSON.stringify(commandClassMap)};`); + script(`window.commandClass = ${commandClass.toString()};`); + script(`window.loadHotkeys = ${loadHotkeys.toString()};`); + script(`TheCore.raceCards = ${fnJSON(raceCards)};`); + script(`TheCore.commandCards = ${fnJSON(commandCards)};`); + coffeescript(function() { + return window.nextTick = function(cb) { + return setTimeout(cb, 0); + }; + }); + coffeescript(function() { + var ref, val; + TheCore.hotkeysForKeyboard = {}; + TheCore.loadTheCoreForKeyboard = function(keyboard, cb) { + var code, hotkeysFiles, j, len, loadHotkeysFile, n, path, prefix, ref; + n = null; + TheCore.currentKeyboard = keyboard; + if ((TheCore.currentHotkeysFiles = TheCore.hotkeysForKeyboard[keyboard])) { + nextTick(renderContainer); + return; + } + hotkeysFiles = TheCore.currentHotkeysFiles = TheCore.hotkeysForKeyboard[keyboard] = {}; + loadHotkeysFile = function(name, path) { + hotkeysFiles[name] = null; + n += 1; + return $.get(path, function(file) { + hotkeysFiles[name] = file; + console.log('loaded hotkey file', name, path, file.length); + if (!(n -= 1)) { + return renderContainer(); + } + }); + }; + n = 0; + prefix = `hotkeys/${(keyboard === 'USQwerty' ? '' : keyboard + '/')}`; + ref = TheCore.layoutCodes; + for (j = 0, len = ref.length; j < len; j++) { + code = ref[j]; + path = `${prefix}${TheCore.layoutCodeToFileName(code)}`; + loadHotkeysFile(TheCore.layoutCodeToDisplayName(code), path); + } + if (keyboard === 'USQwerty') { + loadHotkeysFile("The Core Lite", 'others/TheCore Lite.SC2Hotkeys'); + loadHotkeysFile("The Chameleon", 'others/Chameleon 2.0.SC2Hotkeys'); + return loadHotkeysFile("HotS Standard", 'others/Standard.SC2Hotkeys'); + } + }; + TheCore.currentKeyboard = (ref = (val = $.fn.cookie('keyboard-layout-val')), indexOf.call("USQwerty USDvorak FrenchAzerty German USColemak".split(' '), ref) >= 0) ? val : 'USQwerty'; + console.log('Loading keyboard', TheCore.currentKeyboard); + return TheCore.loadTheCoreForKeyboard(TheCore.currentKeyboard); + }); + coffeescript(function() { + return String.prototype.trim = function() { + return this.replace(/(^\s+|\s+$)/g, ''); + }; + }); + return coffeescript(function() { + window.scanHotkeys = function() { + var cname, code, details, kind, kinds, out, race, ref, ref1, unit, unitName, units; + out = ""; + ref = TheCore.raceCards; + for (race in ref) { + kinds = ref[race]; + for (kind in kinds) { + units = kinds[kind]; + for (unitName in units) { + unit = units[unitName]; + ref1 = unit.commands; + for (cname in ref1) { + details = ref1[cname]; + code = details.hotkeyCode || cname; + if (code.match(/\//)) { + if (!TheCore.currentHotkeys[code]) { + if (TheCore.currentHotkeys[code.split('/')[0]]) { + console.log(`${(code.split('/')[0])} should be ${code}`, { + it: TheCore.currentHotkeys[code.split('/')[0]] + }); + out += `${code}=${TheCore.currentHotkeys[code.split('/')[0]].join(',')}\n`; + } + } + } + } + } + } + } + return console.log('additions', out); + }; + return window.renderContainer = function() { + var Unit, attr, clearMaps, currentGroup, currentHotkeys, currentKeyboard, currentMods, currentUnit, debounceTimer, globalState, highlightModKeys, hotkeysFile, hotkeysFiles, i, key, keyPress, keyRelease, modKeyAttrs, modKeys, mouseButtons, selectedUnit, sendMessage, showCurrentUnitMaps, showGlobalMaps, showMapsForUnit, val, which, windowHandler; + currentKeyboard = TheCore.currentKeyboard; + hotkeysFiles = TheCore.currentHotkeysFiles; + loadHotkeys(((function() { + var results; + results = []; + for (k in hotkeysFiles) { + v = hotkeysFiles[k]; + results.push(v); + } + return results; + })())[0]); + $('.container').html(coffeecup.render(containerTemplate)); + $('select.keyboard-layout').val(currentKeyboard); + $('.keyboard .inner').html(coffeecup.render(keyboardTemplate, { + keyboard: keyboards[currentKeyboard], + hardcode: {touch, sizeClass, blankRow, formatKeyCap} + })); + currentMods = []; + currentGroup = []; + currentUnit = null; + TheCore.currentHotkeys = currentHotkeys = {}; + globalState = { + currentUnit: null, + controlGroup: (function() { + var j, results; + results = []; + for (i = j = 0; j <= 9; i = ++j) { + results.push(null); + } + return results; + })() + }; + sendMessage = function(text, kind) { + var message; + if (text) { + message = $(`

${text}

`); + $('.messages').append(message); + setTimeout((function() { + return message.addClass('hide'); + }), 1000); + return setTimeout((function() { + return message.remove(); + }), 5000); + } + }; + Unit = (function() { + class Unit { + constructor(race1, kind1, name1) { + var base, command, inherited, j, key, l, len, len1, name, path, ref, ref1, ref2; + this.race = race1; + this.kind = kind1; + this.name = name1; + this.icon = $(`.unit-icon.unit-${this.name}`); + this.card = TheCore.raceCards[this.race][this.kind][this.name]; + this.commands = this.card.commands; + if (this.commands.inherit) { + ref = this.commands.inherit; + for (j = 0, len = ref.length; j < len; j++) { + path = ref[j]; + path = path.split('.'); + inherited = TheCore.commandCards; + while (path.length) { + inherited = inherited[path.shift()]; + } + for (k in inherited) { + v = inherited[k]; + if ((base = this.commands)[k] == null) { + base[k] = v; + } + } + } + } + ref1 = this.commands; + for (name in ref1) { + command = ref1[name]; + ref2 = ['if', 'on']; + for (l = 0, len1 = ref2.length; l < len1; l++) { + key = ref2[l]; + if (typeof command[key] === 'string') { + command[key] = eval(`(${command[key]})`); + } + } + } + } + + static fromIcon($icon) { + var kind, race, unit; + race = (($icon.closest('.race-commands'))[0].className.match(/race-commands race-(\w+)/))[1]; + kind = (($icon.closest('.unit-commands'))[0].className.match(/unit-commands kind-(\w+)/))[1]; + unit = (($icon.closest('.unit-icon'))[0].className.match(/unit-icon unit-(\w+)/))[1]; + return new Unit(race, kind, unit); + } + + }; + + Unit.prototype.globalState = globalState; + + return Unit; + + }).call(this); + showMapsForUnit = function(unit) { + var $map, $maps, command, key, keys, mod, mods, name, ref, results; + ref = unit.commands; + results = []; + for (name in ref) { + command = ref[name]; + if (typeof command.if === 'function') { + if (!command.if.call(unit)) { + continue; + } + } + if (!(keys = currentHotkeys[command.hotkeyCode || name])) { + continue; + } + results.push((function() { + var j, len, ref1, results1; + results1 = []; + for (j = 0, len = keys.length; j < len; j++) { + key = keys[j]; + ref1 = key.split('+'), [...mods] = ref1, [key] = splice.call(mods, -1); + if (mods && (indexOf.call((function() { + var l, len1, results2; + results2 = []; + for (l = 0, len1 = currentMods.length; l < len1; l++) { + mod = currentMods[l]; + results2.push(indexOf.call(mods, mod) >= 0); + } + return results2; + })(), false) >= 0 || indexOf.call((function() { + var l, len1, results2; + results2 = []; + for (l = 0, len1 = mods.length; l < len1; l++) { + mod = mods[l]; + results2.push(indexOf.call(currentMods, mod) >= 0); + } + return results2; + })(), false) >= 0)) { + continue; + } + $maps = $(`.keyboard .key.key-${keyClass(key)} .maps`); + results1.push($map = $maps.append(`
${command.displayText || name}
`)); + } + return results1; + })()); + } + return results; + }; + showGlobalMaps = function() { + var $map, $maps, command, key, keys, m, mod, mods, name, ref, results, unit; + ref = TheCore.commandCards.global; + results = []; + for (name in ref) { + command = ref[name]; + if (command.if) { + if (typeof command.if === 'string') { + command.if = eval(`(${command.if})`); + } + if (!command.if.call(globalState)) { + continue; + } + } + if (!(keys = currentHotkeys[command.hotkeyCode || name])) { + continue; + } + results.push((function() { + var j, len, ref1, results1; + results1 = []; + for (j = 0, len = keys.length; j < len; j++) { + key = keys[j]; + ref1 = key.split('+'), [...mods] = ref1, [key] = splice.call(mods, -1); + if (mods && (indexOf.call((function() { + var l, len1, results2; + results2 = []; + for (l = 0, len1 = currentMods.length; l < len1; l++) { + mod = currentMods[l]; + results2.push(indexOf.call(mods, mod) >= 0); + } + return results2; + })(), false) >= 0 || indexOf.call((function() { + var l, len1, results2; + results2 = []; + for (l = 0, len1 = mods.length; l < len1; l++) { + mod = mods[l]; + results2.push(indexOf.call(currentMods, mod) >= 0); + } + return results2; + })(), false) >= 0)) { + continue; + } + if (name.match(/^Observe|Leader|Toggle|Replay|Stats/)) { + continue; + } + $maps = $(`.keyboard .key.key-${keyClass(key)} .maps`); + if ((m = name.match(/ControlGroup\w+(\d)/))) { + unit = globalState.controlGroup[m[1]]; + } + results1.push($map = $maps.append(`
${command.keyCap || command.displayText || name}
`)); + } + return results1; + })()); + } + return results; + }; + clearMaps = function() { + return $('.keyboard .map').remove(); + }; + selectedUnit = null; + debounceTimer = null; + $('.races-icons').on('click', '.race-icon', function() { + var $icon, race; + $icon = $(this); + race = (this.className.match(/race-icon race-(\w+)/))[1]; + $.fn.cookie('race-selected', race, { + expires: 30 + }); + $('.race-commands').addClass('hide'); + $('.races-icons .race-icon').removeClass('selected'); + $icon.addClass('selected'); + $(`.race-commands.race-${race}`).removeClass('hide'); + return $('.unit-icon.selected').click(); + }); + // $('.races-commands').on 'mouseenter', '.unit-icon', -> + // do clearMaps + // do showGlobalMaps + // showMapsForUnit Unit.fromIcon($(this)) + showCurrentUnitMaps = function() { + clearMaps(); + if (currentUnit != null) { + showMapsForUnit(currentUnit); + } + showGlobalMaps(); + if (debounceTimer) { + clearTimeout(debounceTimer); + return debounceTimer = null; + } + }; + $('.races-commands').on('click', '.unit-icon', function() { + var $el; + $el = $(this); + globalState.select(Unit.fromIcon($el)); + return sendMessage(`Select ${currentUnit.displayText || currentUnit.name.replace(/([a-z])([A-Z])/g, '$1 $2')}`); + }); + globalState.select = function(unit) { + var $el; + if (!unit) { + return; + } + $el = unit.icon; + $.fn.cookie('unit-selected', unit.name, { + expires: 30 + }); + $('.races-commands .unit-icon.selected').removeClass('selected'); + $el.addClass('selected'); + this.currentUnit = currentUnit = unit; + return showCurrentUnitMaps(); + }; + globalState.selectNew = function(...args) { + return this.select(new Unit(...args)); + }; + // $('.races-commands').on 'mouseleave', '.unit-icon', -> + // do showCurrentUnitMaps + modKeyAttrs = { + ctrlKey: 'Control', + altKey: 'Alt', + metaKey: 'Alt', + shiftKey: 'Shift' + }; + modKeys = (function() { + var results; + results = []; + for (attr in modKeyAttrs) { + key = modKeyAttrs[attr]; + results.push(key); + } + return results; + })(); + highlightModKeys = function() { + $(((function() { + var results; + results = []; + for (attr in modKeyAttrs) { + key = modKeyAttrs[attr]; + results.push(`.keyboard .key-${key}`); + } + return results; + })()).join(',')).removeClass('selected'); + return $(((function() { + var j, len, results; + results = []; + for (j = 0, len = currentMods.length; j < len; j++) { + key = currentMods[j]; + results.push(`.keyboard .key-${key}`); + } + return results; + })()).join(',')).addClass('selected'); + }; + keyPress = function(key) { + var $key, command, j, len, m, map, ref, ref1; + if (key === 'void') { + return; + } + if (indexOf.call(modKeys, key) >= 0) { + if (indexOf.call(currentMods, key) < 0) { + currentMods.push(key); + highlightModKeys(); + return showCurrentUnitMaps(); + } + } else { + $key = $(`.keyboard .key-${key}`).addClass('selected'); + ref = $key.find('.map'); + for (j = 0, len = ref.length; j < len; j++) { + map = ref[j]; + if (m = map.className.match(/map-global map-(\w+)/)) { + if ((ref1 = m[1]) === 'Select' || ref1 === 'Interact') { + return; + } + command = TheCore.commandCards.global[m[1]]; + if (command != null ? command.on : void 0) { + if (typeof command.on === 'string') { + command.on = eval(`(${command.on})`); + } + command.on.call(globalState); + } + sendMessage(command.displayText || m[1].replace(/([a-z])([A-Z])/g, '$1 $2')); + } else if (m = map.className.match(/map-command map-(\w+)/)) { + command = currentUnit != null ? currentUnit.commands[m[1]] : void 0; + if (command.on) { + command.on.call(currentUnit); + } + sendMessage(command.displayText || m[1].replace(/([a-z])([A-Z])/g, '$1 $2')); + showCurrentUnitMaps(); + } + break; + } + } + }; + keyRelease = function(key) { + if (key === 'void') { + return; + } + if (indexOf.call(modKeys, key) >= 0) { + if (indexOf.call(currentMods, key) >= 0) { + currentMods.splice(currentMods.indexOf(key), 1); + highlightModKeys(); + return showCurrentUnitMaps(); + } + } else { + return $(`.keyboard .key-${key}`).removeClass('selected'); + } + }; + $(window).on('keydown keyup', windowHandler = function(e) { + var keyFn, ref; + currentMods = (function() { + var results; + results = []; + for (attr in modKeyAttrs) { + key = modKeyAttrs[attr]; + if (e[attr]) { + results.push(key); + } + } + return results; + })(); + console.log(key, e.keyCode, currentMods); + highlightModKeys(); + key = keyClass((ref = keyCodeMaps[currentKeyboard][e.keyCode]) != null ? ref.toUpperCase() : void 0); + keyFn = (function() { + switch (e.type) { + case 'keydown': + return keyPress; + case 'keyup': + return keyRelease; + } + })(); + if (key.match(/^\w+$/)) { + keyFn(key); + } + e.preventDefault(); + return showCurrentUnitMaps(); + }); + $('.keyboard').on('mousedown', '.key', function(e) { + var $key; + $key = $(this); + key = this.className.match(/key key-(\w+)/)[1]; + return keyPress(key); + }); + $('.keyboard').on('mouseup', '.key', function(e) { + var $key; + $key = $(this); + key = this.className.match(/key key-(\w+)/)[1]; + return keyRelease(key); + }); + mouseButtons = (function() { + var j, len, ref, results; + ref = [null, 'Left', 'Middle', 'Right', 'Forward', 'Back']; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + which = ref[j]; + results.push(`${which}MouseButton`); + } + return results; + })(); + $('body').on('contextmenu', function(e) { + if (!(currentMods.length > 0)) { + return false; + } + }); + $('body').on('mousedown', function(e) { + key = mouseButtons[e.which]; + return keyPress(key); + }); + $('body').on('mouseup', function(e) { + key = mouseButtons[e.which]; + return keyRelease(key); + }); + $('select.display-side').change(function() { + var side; + $('.keyboard').removeClass(((function() { + var j, len, ref, results; + ref = ['left', 'right', 'full']; + results = []; + for (j = 0, len = ref.length; j < len; j++) { + side = ref[j]; + results.push(`display-${side}`); + } + return results; + })()).join(' ')); + $('.keyboard').addClass(`display-${$(this).val()}`); + return $.fn.cookie('display-side-val', $(this).val(), { + expires: 30 + }); + }); + $('select.hotkey-file').change(function() { + var filename, race, ref; + filename = $(this).val(); + TheCore.currentHotkeys = currentHotkeys = loadHotkeys(hotkeysFiles[filename]); + $.fn.cookie('hotkey-file-val', filename, { + expires: 30 + }); + if (filename.match(/Left/)) { + $('select.display-side').val('left').change(); + } else if (filename.match(/Right/)) { + $('select.display-side').val('right').change(); + } else { + $('select.display-side').val('full').change(); + } + if ((race = (ref = filename.match(/(Zerg|Protoss|Terran)/)) != null ? ref[1] : void 0)) { + $(`.race-icon.race-${race}`).click(); + } else if (filename.match(/Random/)) { + race = 'Zerg Protoss Terran'.split(' ')[Math.floor(Math.random() * 3)]; + $(`.race-icon.race-${race}`).click(); + } + return showCurrentUnitMaps(); + }); + $('select.keyboard-layout').change(function() { + currentKeyboard = $(this).val(); + $.fn.cookie('keyboard-layout-val', currentKeyboard, { + expires: 30 + }); + $(window).unbind(windowHandler); + return TheCore.loadTheCoreForKeyboard(currentKeyboard); + }); + $('select.display-side').val($.fn.cookie('display-side-val') || $('select.display-side option')[0].value).change(); + hotkeysFile = (val = $.fn.cookie('hotkey-file-val')) ? hotkeysFiles[val] ? val : ($.fn.cookie('tutorial-dismiss', false), $('select.hotkey-file option')[0].value) : $('select.hotkey-file option')[0].value; + $('select.hotkey-file').val(hotkeysFile).change(); + showCurrentUnitMaps(); + $(`.race-icon.race-${$.fn.cookie('race-selected') || 'Terran'}`).click(); + $(`.unit-icon.unit-${$.fn.cookie('unit-selected') || 'SCV'}`).click(); + $('.tutorial-overlay').on('click', function() { + $('.tutorial-overlay,.tutorial').hide(); + return $.fn.cookie('tutorial-dismiss', true, { + expires: 30 + }); + }); + if ($.fn.cookie('tutorial-dismiss') && $.fn.cookie('tutorial-dismiss') !== 'false') { + return $('.tutorial-overlay').click(); + } + }; + }); + }); + }); + +}).call(this); diff --git a/src/keyboards.js b/src/keyboards.js new file mode 100644 index 0000000..eecd803 --- /dev/null +++ b/src/keyboards.js @@ -0,0 +1,558 @@ +// Generated by CoffeeScript 2.2.1 +(function() { + var i, j, k, key, keyCodeMaps, keyboard, keyboards, len, len1, row, size; + + exports.keyboards = keyboards = { + 'USQwerty': [ + { + 'ESC': 'ESC', + '_0': '_0', + 'F1': 'F1', + 'F2': 'F2', + 'F3': 'F3', + 'F4': 'F4', + '_1': 0.5, + 'F5': 'F5', + 'F6': 'F6', + 'F7': 'F7', + 'F8': 'F8', + '_2': 0.5, + 'F9': 'F9', + 'F10': 'F10', + 'F11': 'F11', + 'F12': 'F12' + }, + {}, + { + '`': '`', + '1 ': '1 ', + '2 ': '2 ', + '3 ': '3 ', + '4 ': '4 ', + '5 ': '5 ', + '6 ': '6 ', + '7 ': '7 ', + '8 ': '8 ', + '9 ': '9 ', + '0 ': '0 ', + '-': '-', + '=': '=', + 'BACKSPACE': 2 + }, + { + 'TAB': 1.5, + 'Q': 'Q', + 'W': 'W', + 'E': 'E', + 'R': 'R', + 'T': 'T', + 'Y': 'Y', + 'U': 'U', + 'I': 'I', + 'O': 'O', + 'P': 'P', + '[': '[', + ']': ']', + '\\': 1.5 + }, + { + 'CAPS': 1.75, + 'A': 'A', + 'S': 'S', + 'D': 'D', + 'F': 'F', + 'G': 'G', + 'H': 'H', + 'J': 'J', + 'K': 'K', + 'L': 'L', + ';': ';', + '\'': '\'', + 'ENTER': 2.25 + }, + { + 'SHIFT L': 2.25, + 'Z': 'Z', + 'X': 'X', + 'C': 'C', + 'V': 'V', + 'B': 'B', + 'N': 'N', + 'M': 'M', + ',': ',', + '.': '.', + '/': '/', + 'SHIFT R': 2.75 + }, + { + 'CTRL L': 1.5, + 'WIN L': 'WIN L', + 'ALT L': 1.5, + 'SPACE': 6, + 'ALT R': 1.5, + 'WIN R': 'WIN R', + 'MENU': 'MENU', + 'CTRL R': 1.5 + } + ], + 'USDvorak': [ + { + 'ESC': 'ESC', + '_0': '_0', + 'F1': 'F1', + 'F2': 'F2', + 'F3': 'F3', + 'F4': 'F4', + '_1': 0.5, + 'F5': 'F5', + 'F6': 'F6', + 'F7': 'F7', + 'F8': 'F8', + '_2': 0.5, + 'F9': 'F9', + 'F10': 'F10', + 'F11': 'F11', + 'F12': 'F12' + }, + {}, + { + '`': '`', + '1 ': '1 ', + '2 ': '2 ', + '3 ': '3 ', + '4 ': '4 ', + '5 ': '5 ', + '6 ': '6 ', + '7 ': '7 ', + '8 ': '8 ', + '9 ': '9 ', + '0 ': '0 ', + '[': '[', + ']': ']', + 'BACKSPACE': 2 + }, + { + 'TAB': 1.5, + '\'': '\'', + ',': ',', + '.': '.', + 'P': 'P', + 'Y': 'Y', + 'F': 'F', + 'G': 'G', + 'C': 'C', + 'R': 'R', + 'L': 'L', + '/': '/', + '=': '=', + '\\': 1.5 + }, + { + 'CAPS': 1.75, + 'A': 'A', + 'O': 'O', + 'E': 'E', + 'U': 'U', + 'I': 'I', + 'D': 'D', + 'H': 'H', + 'T': 'T', + 'N': 'N', + 'S': 'S', + '-': '-', + 'ENTER': 2.25 + }, + { + 'SHIFT L': 2.25, + ';': ';', + 'Q': 'Q', + 'J': 'J', + 'K': 'K', + 'X': 'X', + 'B': 'B', + 'M': 'M', + 'W': 'W', + 'V': 'V', + 'Z': 'Z', + 'SHIFT R': 2.75 + }, + { + 'CTRL L': 1.5, + 'WIN L': 'WIN L', + 'ALT L': 1.5, + 'SPACE': 6, + 'ALT R': 1.5, + 'WIN R': 'WIN R', + 'MENU': 'MENU', + 'CTRL R': 1.5 + } + ], + 'FrenchAzerty': [ + { + 'ESC': 'ESC', + '_0': '_0', + 'F1': 'F1', + 'F2': 'F2', + 'F3': 'F3', + 'F4': 'F4', + '_1': 0.5, + 'F5': 'F5', + 'F6': 'F6', + 'F7': 'F7', + 'F8': 'F8', + '_2': 0.5, + 'F9': 'F9', + 'F10': 'F10', + 'F11': 'F11', + 'F12': 'F12' + }, + {}, + { + '<': '<', + '1 ': '1 ', + '2 ': '2 ', + '3 ': '3 ', + '4 ': '4 ', + '5 ': '5 ', + '6 ': '6 ', + '7 ': '7 ', + '8 ': '8 ', + '9 ': '9 ', + '0 ': '0 ', + '-': '-', + '=': '=', + 'BACKSPACE': 2 + }, + { + 'TAB': 1.5, + 'A': 'A', + 'Z': 'Z', + 'E': 'E', + 'R': 'R', + 'T': 'T', + 'Y': 'Y', + 'U': 'U', + 'I': 'I', + 'O': 'O', + 'P': 'P', + '[': '[', + ']': ']', + '\\': 1.5 + }, + { + 'CAPS': 1.75, + 'Q': 'Q', + 'S': 'S', + 'D': 'D', + 'F': 'F', + 'G': 'G', + 'H': 'H', + 'J': 'J', + 'K': 'K', + 'L': 'L', + 'M': 'M', + '`': '`', + 'ENTER': 2.25 + }, + { + 'SHIFT L': 2.25, + 'W': 'W', + 'X': 'X', + 'C': 'C', + 'V': 'V', + 'B': 'B', + 'N': 'N', + ',': ',', + ';': ';', + ':': ':', + '=': '=', + 'SHIFT R': 2.75 + }, + { + 'CTRL L': 1.5, + 'WIN L': 'WIN L', + 'ALT L': 1.5, + 'SPACE': 6, + 'ALT R': 1.5, + 'WIN R': 'WIN R', + 'MENU': 'MENU', + 'CTRL R': 1.5 + } + ], + 'German': [ + { + 'ESC': 'ESC', + '_0': '_0', + 'F1': 'F1', + 'F2': 'F2', + 'F3': 'F3', + 'F4': 'F4', + '_1': 0.5, + 'F5': 'F5', + 'F6': 'F6', + 'F7': 'F7', + 'F8': 'F8', + '_2': 0.5, + 'F9': 'F9', + 'F10': 'F10', + 'F11': 'F11', + 'F12': 'F12' + }, + {}, + { + '<': '<', + '1 ': '1 ', + '2 ': '2 ', + '3 ': '3 ', + '4 ': '4 ', + '5 ': '5 ', + '6 ': '6 ', + '7 ': '7 ', + '8 ': '8 ', + '9 ': '9 ', + '0 ': '0 ', + 'ß': 'ß', + '´': '´', + 'BACKSPACE': 2 + }, + { + 'TAB': 1.5, + 'Q': 'Q', + 'W': 'W', + 'E': 'E', + 'R': 'R', + 'T': 'T', + 'Z': 'Z', + 'U': 'U', + 'I': 'I', + 'O': 'O', + 'P': 'P', + 'ü': 'ü', + '+': '+', + '\\': 1.5 + }, + { + 'CAPS': 1.75, + 'A': 'A', + 'S': 'S', + 'D': 'D', + 'F': 'F', + 'G': 'G', + 'H': 'H', + 'J': 'J', + 'K': 'K', + 'L': 'L', + 'ö': 'ö', + 'ä': 'ä', + 'ENTER': 2.25 + }, + { + 'SHIFT L': 2.25, + 'Y': 'Y', + 'X': 'X', + 'C': 'C', + 'V': 'V', + 'B': 'B', + 'N': 'N', + 'M': 'M', + ',': ',', + '.': '.', + '-': '-', + 'SHIFT R': 2.75 + }, + { + 'CTRL L': 1.5, + 'WIN L': 'WIN L', + 'ALT L': 1.5, + 'SPACE': 6, + 'ALT R': 1.5, + 'WIN R': 'WIN R', + 'MENU': 'MENU', + 'CTRL R': 1.5 + } + ], + 'USColemak': [ + { + 'ESC': 'ESC', + '_0': '_0', + 'F1': 'F1', + 'F2': 'F2', + 'F3': 'F3', + 'F4': 'F4', + '_1': 0.5, + 'F5': 'F5', + 'F6': 'F6', + 'F7': 'F7', + 'F8': 'F8', + '_2': 0.5, + 'F9': 'F9', + 'F10': 'F10', + 'F11': 'F11', + 'F12': 'F12' + }, + {}, + { + '`': '`', + '1 ': '1 ', + '2 ': '2 ', + '3 ': '3 ', + '4 ': '4 ', + '5 ': '5 ', + '6 ': '6 ', + '7 ': '7 ', + '8 ': '8 ', + '9 ': '9 ', + '0 ': '0 ', + '-': '-', + '=': '=', + 'BACKSPACE': 2 + }, + { + 'TAB': 1.5, + 'Q': 'Q', + 'W': 'W', + 'F': 'F', + 'P': 'P', + 'G': 'G', + 'J': 'J', + 'L': 'L', + 'U': 'U', + 'Y': 'Y', + ';': ';', + '[': '[', + ']': ']', + '\\': 1.5 + }, + { + 'CAPS': 1.75, + 'A': 'A', + 'R': 'R', + 'S': 'S', + 'T': 'T', + 'D': 'D', + 'H': 'H', + 'N': 'N', + 'E': 'E', + 'I': 'I', + 'O': 'O', + '\'': '\'', + 'ENTER': 2.25 + }, + { + 'SHIFT L': 2.25, + 'Z': 'Z', + 'X': 'X', + 'C': 'C', + 'V': 'V', + 'B': 'B', + 'K': 'K', + 'M': 'M', + ',': ',', + '.': '.', + '/': '/', + 'SHIFT R': 2.75 + }, + { + 'CTRL L': 1.5, + 'WIN L': 'WIN L', + 'ALT L': 1.5, + 'SPACE': 6, + 'ALT R': 1.5, + 'WIN R': 'WIN R', + 'MENU': 'MENU', + 'CTRL R': 1.5 + } + ] + }; + + exports.keyCodeMaps = keyCodeMaps = { + 'USQwerty': { + 27: 'ESC', + 9: 'TAB', + 16: 'SHIFT', + 17: 'CTRL', + 18: 'ALT', + 32: 'SPACE', + 13: 'ENTER', + 46: 'BACKSPACE', + "48": "0", + "49": "1", + "50": "2", + "51": "3", + "52": "4", + "53": "5", + "54": "6", + "55": "7", + "56": "8", + "57": "9", + 59: ';', + "65": "a", + "66": "b", + "67": "c", + "68": "d", + "69": "e", + "70": "f", + "71": "g", + "72": "h", + "73": "i", + "74": "j", + "75": "k", + "76": "l", + "77": "m", + "78": "n", + "79": "o", + "80": "p", + "81": "q", + "82": "r", + "83": "s", + "84": "t", + "85": "u", + "86": "v", + "87": "w", + "88": "x", + "89": "y", + "90": "z", + "186": ";", + "187": "=", + "188": ",", + "189": "-", + "190": ".", + "191": "/", + "192": "`", + "219": "[", + "220": "\\", + "221": "]", + "222": "'", + 112: 'F1', + 113: 'F2', + 114: 'F3', + 115: 'F4', + 116: 'F5', + 117: 'F6', + 118: 'F7', + 119: 'F8', + 120: 'F9', + 121: 'F10', + 122: 'F11', + 123: 'F12' + } + }; + + for (k in keyboards) { + keyCodeMaps[k] = keyCodeMaps['USQwerty']; + } + + for (i = 0, len = keyboards.length; i < len; i++) { + keyboard = keyboards[i]; + for (j = 0, len1 = keyboard.length; j < len1; j++) { + row = keyboard[j]; + for (key in row) { + size = row[key]; + if (typeof size === 'string') { + row[key] = 1; + } + } + } + } + +}).call(this); From d7487316d12a7e60f5709873f6896674a0e31cb5 Mon Sep 17 00:00:00 2001 From: Anzumana Taal Date: Thu, 31 Oct 2019 10:47:39 +0100 Subject: [PATCH 3/3] feat: start of the react refactor --- react-app/.gitignore | 21 + react-app/README.md | 2433 ++++ react-app/package-lock.json | 10120 ++++++++++++++++ react-app/package.json | 17 + react-app/public/favicon.ico | Bin 0 -> 3870 bytes react-app/public/index.html | 10 + react-app/public/manifest.json | 15 + react-app/src/App.js | 697 ++ react-app/src/icons/AWrp.gif | Bin 0 -> 4931 bytes react-app/src/icons/AWrp.png | Bin 0 -> 10494 bytes react-app/src/icons/AdrenalGlands.gif | Bin 0 -> 4924 bytes react-app/src/icons/AnionPulseCrystals.png | Bin 0 -> 9203 bytes react-app/src/icons/AssaultMode.gif | Bin 0 -> 4867 bytes react-app/src/icons/AssaultMode.png | Bin 0 -> 9822 bytes react-app/src/icons/Attack.png | Bin 0 -> 4845 bytes react-app/src/icons/BehemothReactor.gif | Bin 0 -> 4833 bytes react-app/src/icons/BlindingCloud.png | Bin 0 -> 4386 bytes react-app/src/icons/Blink.png | Bin 0 -> 7424 bytes react-app/src/icons/Build.png | Bin 0 -> 4611 bytes react-app/src/icons/BuildAdvanced.png | Bin 0 -> 5452 bytes react-app/src/icons/BuildAutoTurret.png | Bin 0 -> 9082 bytes react-app/src/icons/BuildCreepTumor.png | Bin 0 -> 9251 bytes .../src/icons/BuildPointDefenseDrone.png | Bin 0 -> 8423 bytes react-app/src/icons/Build_auto_turret.gif | Bin 0 -> 4707 bytes .../src/icons/Build_point_defense_drone.gif | Bin 0 -> 4563 bytes react-app/src/icons/BuildingArmor.gif | Bin 0 -> 4611 bytes react-app/src/icons/Burrow.gif | Bin 0 -> 3399 bytes react-app/src/icons/CaduceusReactor.gif | Bin 0 -> 5117 bytes react-app/src/icons/CalldownMULE.gif | Bin 0 -> 4821 bytes react-app/src/icons/CalldownMULE.png | Bin 0 -> 9952 bytes react-app/src/icons/Cancel.png | Bin 0 -> 6391 bytes react-app/src/icons/CentrifugalHooks.gif | Bin 0 -> 4863 bytes react-app/src/icons/Charge.png | Bin 0 -> 8478 bytes react-app/src/icons/ChitinousPlating.gif | Bin 0 -> 4942 bytes react-app/src/icons/ChronoBoost.png | Bin 0 -> 6783 bytes react-app/src/icons/Cloak.png | Bin 0 -> 7681 bytes react-app/src/icons/ColossusRange.gif | Bin 0 -> 4542 bytes react-app/src/icons/CombatShield.png | Bin 0 -> 7835 bytes react-app/src/icons/ConcussiveShells.png | Bin 0 -> 7661 bytes react-app/src/icons/Contaminate.png | Bin 0 -> 11493 bytes react-app/src/icons/CorruptionAbility.png | Bin 0 -> 11325 bytes react-app/src/icons/CorvidReactor.gif | Bin 0 -> 5003 bytes react-app/src/icons/Decloack.jpg | Bin 0 -> 3782 bytes react-app/src/icons/DrillingClaws.png | Bin 0 -> 10631 bytes react-app/src/icons/DurableMaterials.gif | Bin 0 -> 4731 bytes react-app/src/icons/EMP.png | Bin 0 -> 7368 bytes react-app/src/icons/EnableBuildingAttack.png | Bin 0 -> 7882 bytes react-app/src/icons/Envision.png | Bin 0 -> 7862 bytes .../src/icons/EvolveGlialRegeneration.gif | Bin 0 -> 5012 bytes react-app/src/icons/EvolveTunnelingClaws.gif | Bin 0 -> 4795 bytes react-app/src/icons/Explode.gif | Bin 0 -> 4354 bytes react-app/src/icons/Explode.png | Bin 0 -> 6584 bytes react-app/src/icons/ExplosivePayload.png | Bin 0 -> 10745 bytes react-app/src/icons/Extractor.png | Bin 0 -> 6492 bytes react-app/src/icons/Feedback.png | Bin 0 -> 7961 bytes react-app/src/icons/FighterMode.png | Bin 0 -> 9155 bytes react-app/src/icons/Fighter_mode.gif | Bin 0 -> 4617 bytes react-app/src/icons/FlyerAttack1.gif | Bin 0 -> 5089 bytes react-app/src/icons/FlyerCarapace1.gif | Bin 0 -> 5027 bytes react-app/src/icons/ForceField.png | Bin 0 -> 8745 bytes react-app/src/icons/Force_field.gif | Bin 0 -> 4773 bytes react-app/src/icons/FungalGrowth.png | Bin 0 -> 11660 bytes react-app/src/icons/Gather.png | Bin 0 -> 6795 bytes react-app/src/icons/GenerateCreep.png | Bin 0 -> 7884 bytes react-app/src/icons/GravitonBeam.png | Bin 0 -> 8335 bytes react-app/src/icons/GravitonCatapult.gif | Bin 0 -> 4866 bytes react-app/src/icons/GroovedSpines.gif | Bin 0 -> 4939 bytes react-app/src/icons/GuardianShield.gif | Bin 0 -> 4505 bytes react-app/src/icons/Hallucination.png | Bin 0 -> 8290 bytes react-app/src/icons/Halt.png | Bin 0 -> 6679 bytes react-app/src/icons/Heal.png | Bin 0 -> 5867 bytes react-app/src/icons/HighImpactPayload.png | Bin 0 -> 11072 bytes react-app/src/icons/HisecAutoTracking.gif | Bin 0 -> 4857 bytes react-app/src/icons/HoldPosition.png | Bin 0 -> 6256 bytes react-app/src/icons/HunterSeekerMissile.png | Bin 0 -> 7847 bytes react-app/src/icons/ImpactMode.png | Bin 0 -> 11072 bytes .../src/icons/IncreasedLocustLifetime.gif | Bin 0 -> 4524 bytes react-app/src/icons/InfantryArmor1.gif | Bin 0 -> 4900 bytes react-app/src/icons/InfantryWeapons1.gif | Bin 0 -> 4650 bytes react-app/src/icons/InfernalPreigniter.png | Bin 0 -> 10263 bytes react-app/src/icons/InfestedTerrans.gif | Bin 0 -> 4936 bytes react-app/src/icons/Land.jpg | Bin 0 -> 3808 bytes react-app/src/icons/Lift.png | Bin 0 -> 5229 bytes react-app/src/icons/Load.gif | Bin 0 -> 4303 bytes react-app/src/icons/Load.png | Bin 0 -> 7097 bytes react-app/src/icons/Lower.gif | Bin 0 -> 3705 bytes react-app/src/icons/MassRecall.png | Bin 0 -> 4267 bytes react-app/src/icons/MedivacSpeedBoost.png | Bin 0 -> 9771 bytes react-app/src/icons/MetabolicBoost.gif | Bin 0 -> 4767 bytes react-app/src/icons/MorphToMothership.png | Bin 0 -> 5496 bytes react-app/src/icons/MorphToOverseer.png | Bin 0 -> 7539 bytes react-app/src/icons/MothershipCoreWeapon.png | Bin 0 -> 4039 bytes react-app/src/icons/Move.png | Bin 0 -> 6019 bytes react-app/src/icons/MuscularAugments.png | Bin 0 -> 5284 bytes react-app/src/icons/NeosteelFrames.gif | Bin 0 -> 4848 bytes react-app/src/icons/NeuralParasite.png | Bin 0 -> 12764 bytes react-app/src/icons/NukeCalldown.png | Bin 0 -> 6946 bytes react-app/src/icons/NydusWorm.jpeg | Bin 0 -> 3777 bytes react-app/src/icons/ObserverSpeed.gif | Bin 0 -> 5017 bytes react-app/src/icons/OracleRevelation.png | Bin 0 -> 4058 bytes react-app/src/icons/PathogenGlands.gif | Bin 0 -> 4907 bytes react-app/src/icons/Patrol.png | Bin 0 -> 6336 bytes react-app/src/icons/PhasingMode.png | Bin 0 -> 9574 bytes react-app/src/icons/Phasing_mode.gif | Bin 0 -> 4722 bytes react-app/src/icons/PneumatizedCarapace.gif | Bin 0 -> 4834 bytes react-app/src/icons/PrismaticAlignment.png | Bin 0 -> 7304 bytes react-app/src/icons/Protoss.png | Bin 0 -> 25608 bytes react-app/src/icons/ProtossAirArmorLevel1.gif | Bin 0 -> 4623 bytes react-app/src/icons/ProtossAirWeapons.png | Bin 0 -> 9203 bytes .../src/icons/ProtossAirWeaponsLevel1.gif | Bin 0 -> 4719 bytes .../src/icons/ProtossGroundArmorLevel1.gif | Bin 0 -> 4551 bytes .../src/icons/ProtossGroundWeaponsLevel1.gif | Bin 0 -> 4683 bytes react-app/src/icons/ProtossShieldsLevel1.gif | Bin 0 -> 4469 bytes react-app/src/icons/PsiStorm.png | Bin 0 -> 8456 bytes react-app/src/icons/PulsarBeam.png | Bin 0 -> 10637 bytes react-app/src/icons/PulsarBeamOff.jpg | Bin 0 -> 3464 bytes react-app/src/icons/Rally.jpg | Bin 0 -> 3271 bytes react-app/src/icons/Refinary.png | Bin 0 -> 8429 bytes react-app/src/icons/Repair.gif | Bin 0 -> 3556 bytes react-app/src/icons/Repair.png | Bin 0 -> 5939 bytes react-app/src/icons/ResearchWarpgate.gif | Bin 0 -> 4717 bytes react-app/src/icons/ReturnCargo.png | Bin 0 -> 6111 bytes react-app/src/icons/Root.png | Bin 0 -> 7156 bytes react-app/src/icons/Salvage.gif | Bin 0 -> 4524 bytes react-app/src/icons/Scan.png | Bin 0 -> 7235 bytes react-app/src/icons/Selectbuilder.png | Bin 0 -> 7042 bytes react-app/src/icons/Setrallypoint.png | Bin 0 -> 5041 bytes react-app/src/icons/Setworkerrallypoint.png | Bin 0 -> 5806 bytes react-app/src/icons/SiegeMode.gif | Bin 0 -> 4894 bytes react-app/src/icons/SiegeMode.png | Bin 0 -> 10232 bytes react-app/src/icons/Snipe.png | Bin 0 -> 8198 bytes react-app/src/icons/SpawnChangeling.gif | Bin 0 -> 4550 bytes react-app/src/icons/SpawnCreepTumor.gif | Bin 0 -> 4740 bytes react-app/src/icons/SpawnLocusts.png | Bin 0 -> 3700 bytes react-app/src/icons/Stim.png | Bin 0 -> 7369 bytes react-app/src/icons/Stop.png | Bin 0 -> 6637 bytes react-app/src/icons/StopGenerateCreep.png | Bin 0 -> 5429 bytes react-app/src/icons/SupplyDrop.png | Bin 0 -> 8255 bytes react-app/src/icons/Tempest.png | Bin 0 -> 52336 bytes react-app/src/icons/TemporalField.gif | Bin 0 -> 4505 bytes react-app/src/icons/TemporalField.png | Bin 0 -> 7881 bytes react-app/src/icons/Terran.png | Bin 0 -> 45195 bytes react-app/src/icons/TrainInterceptors.gif | Bin 0 -> 4316 bytes react-app/src/icons/Transfusion.png | Bin 0 -> 7059 bytes react-app/src/icons/TransportMode.gif | Bin 0 -> 4666 bytes react-app/src/icons/TransportMode.png | Bin 0 -> 10425 bytes react-app/src/icons/Transport_mode.gif | Bin 0 -> 4945 bytes react-app/src/icons/Unburrow.gif | Bin 0 -> 3253 bytes react-app/src/icons/UnloadAll.jpg | Bin 0 -> 3717 bytes react-app/src/icons/Unsiege.png | Bin 0 -> 9972 bytes react-app/src/icons/Uproot.png | Bin 0 -> 7163 bytes react-app/src/icons/VehiclePlating1.gif | Bin 0 -> 4708 bytes react-app/src/icons/VehicleWeapons1.gif | Bin 0 -> 4833 bytes react-app/src/icons/VentralSacs.gif | Bin 0 -> 4925 bytes react-app/src/icons/ViperAbduct.png | Bin 0 -> 4570 bytes react-app/src/icons/ViperConsume.png | Bin 0 -> 4371 bytes react-app/src/icons/WarpPrismSpeed.gif | Bin 0 -> 4987 bytes react-app/src/icons/WeaponsFree.png | Bin 0 -> 7410 bytes react-app/src/icons/WidowMineAttack.png | Bin 0 -> 4141 bytes react-app/src/icons/WidowMineBurrow.png | Bin 0 -> 4868 bytes react-app/src/icons/WidowMineUnburrow.jpg | Bin 0 -> 4453 bytes react-app/src/icons/archon.jpg | Bin 0 -> 3642 bytes react-app/src/icons/armory.jpg | Bin 0 -> 2855 bytes react-app/src/icons/assimilator.jpg | Bin 0 -> 3474 bytes react-app/src/icons/autoturret.jpg | Bin 0 -> 2837 bytes react-app/src/icons/baneling.jpg | Bin 0 -> 2909 bytes react-app/src/icons/banelingnest.jpg | Bin 0 -> 3696 bytes react-app/src/icons/banshee.jpg | Bin 0 -> 3021 bytes react-app/src/icons/barracks.jpg | Bin 0 -> 2422 bytes react-app/src/icons/barrackstechlab.jpg | Bin 0 -> 5430 bytes react-app/src/icons/battlecruiser.jpg | Bin 0 -> 3829 bytes react-app/src/icons/broodlord.jpg | Bin 0 -> 3387 bytes .../src/icons/btn-ability-terran-holdfire.jpg | Bin 0 -> 3758 bytes .../icons/btn-ability-terran-weaponsfree.jpg | Bin 0 -> 2445 bytes react-app/src/icons/bunker.jpg | Bin 0 -> 2312 bytes react-app/src/icons/carrier.jpg | Bin 0 -> 3549 bytes react-app/src/icons/changeling.jpg | Bin 0 -> 2516 bytes react-app/src/icons/color.jpg | Bin 0 -> 4967 bytes react-app/src/icons/colossus.jpg | Bin 0 -> 3280 bytes react-app/src/icons/commandcenter.jpg | Bin 0 -> 3835 bytes react-app/src/icons/corruptor.jpg | Bin 0 -> 3462 bytes react-app/src/icons/creeptumor.jpg | Bin 0 -> 3114 bytes react-app/src/icons/cyberneticscore.jpg | Bin 0 -> 3206 bytes react-app/src/icons/darkshrine.jpg | Bin 0 -> 2233 bytes react-app/src/icons/darktemplar.jpg | Bin 0 -> 3286 bytes react-app/src/icons/drone.jpg | Bin 0 -> 2777 bytes react-app/src/icons/dronebuildadvanced.jpg | Bin 0 -> 5603 bytes react-app/src/icons/dronebuildbasic.jpg | Bin 0 -> 5376 bytes react-app/src/icons/egg.jpg | Bin 0 -> 5702 bytes react-app/src/icons/engineeringbay.jpg | Bin 0 -> 2803 bytes react-app/src/icons/extractor.jpg | Bin 0 -> 3409 bytes react-app/src/icons/factory.jpg | Bin 0 -> 3443 bytes react-app/src/icons/factorytechlab.jpg | Bin 0 -> 5406 bytes react-app/src/icons/fleetbeacon.jpg | Bin 0 -> 3568 bytes react-app/src/icons/forge.jpg | Bin 0 -> 3367 bytes react-app/src/icons/fusioncore.jpg | Bin 0 -> 3044 bytes react-app/src/icons/gateway.jpg | Bin 0 -> 4078 bytes react-app/src/icons/ghost.jpg | Bin 0 -> 2650 bytes react-app/src/icons/ghostacademy.jpg | Bin 0 -> 2426 bytes react-app/src/icons/greaterspire.jpg | Bin 0 -> 3529 bytes react-app/src/icons/hand.png | Bin 0 -> 43236 bytes react-app/src/icons/hatchery.jpg | Bin 0 -> 4527 bytes react-app/src/icons/hellbat.jpg | Bin 0 -> 4884 bytes react-app/src/icons/hellion.jpg | Bin 0 -> 2470 bytes react-app/src/icons/hightemplar.jpg | Bin 0 -> 3584 bytes react-app/src/icons/hive.jpg | Bin 0 -> 3431 bytes react-app/src/icons/hydralisk.jpg | Bin 0 -> 2534 bytes react-app/src/icons/hydraliskden.jpg | Bin 0 -> 3811 bytes react-app/src/icons/immortal.jpg | Bin 0 -> 3929 bytes react-app/src/icons/infestationpit.jpg | Bin 0 -> 3487 bytes react-app/src/icons/infestedmarine.jpg | Bin 0 -> 3126 bytes react-app/src/icons/infestor.jpg | Bin 0 -> 3118 bytes react-app/src/icons/interceptor.jpg | Bin 0 -> 2614 bytes react-app/src/icons/lair.jpg | Bin 0 -> 3457 bytes react-app/src/icons/larva.jpg | Bin 0 -> 2159 bytes react-app/src/icons/marauder.jpg | Bin 0 -> 2577 bytes react-app/src/icons/marine.jpg | Bin 0 -> 2664 bytes react-app/src/icons/medivac.jpg | Bin 0 -> 3077 bytes react-app/src/icons/missileturret.jpg | Bin 0 -> 2692 bytes react-app/src/icons/mothership.jpg | Bin 0 -> 4902 bytes react-app/src/icons/mothershipcore.jpg | Bin 0 -> 5935 bytes react-app/src/icons/mule.jpg | Bin 0 -> 3927 bytes react-app/src/icons/mutalisk.jpg | Bin 0 -> 3084 bytes react-app/src/icons/nexus.jpg | Bin 0 -> 4765 bytes react-app/src/icons/nydusnetwork.jpg | Bin 0 -> 3714 bytes react-app/src/icons/nydusworm.jpg | Bin 0 -> 2850 bytes react-app/src/icons/observer.jpg | Bin 0 -> 2443 bytes react-app/src/icons/oracle.jpg | Bin 0 -> 5112 bytes react-app/src/icons/orbitalcommand.jpg | Bin 0 -> 3062 bytes react-app/src/icons/overlord.jpg | Bin 0 -> 2860 bytes react-app/src/icons/overseer.jpg | Bin 0 -> 2622 bytes react-app/src/icons/phoenix.jpg | Bin 0 -> 2810 bytes react-app/src/icons/photoncannon.jpg | Bin 0 -> 3174 bytes react-app/src/icons/planetaryfortress.jpg | Bin 0 -> 2988 bytes react-app/src/icons/prismatic_beams.png | Bin 0 -> 7304 bytes react-app/src/icons/probe.jpg | Bin 0 -> 4715 bytes react-app/src/icons/probebuildadvanced.jpg | Bin 0 -> 5494 bytes react-app/src/icons/probebuildbasic.jpg | Bin 0 -> 5413 bytes react-app/src/icons/protossZealot.jpg | Bin 0 -> 3391 bytes react-app/src/icons/pylon.jpg | Bin 0 -> 2577 bytes react-app/src/icons/queen.jpg | Bin 0 -> 3275 bytes react-app/src/icons/raven.jpg | Bin 0 -> 2587 bytes react-app/src/icons/reactor.jpg | Bin 0 -> 2836 bytes react-app/src/icons/reaper.jpg | Bin 0 -> 2429 bytes react-app/src/icons/refinery.jpg | Bin 0 -> 2992 bytes react-app/src/icons/roach.jpg | Bin 0 -> 3221 bytes react-app/src/icons/roachwarren.jpg | Bin 0 -> 3386 bytes react-app/src/icons/roboticsbay.jpg | Bin 0 -> 3491 bytes react-app/src/icons/roboticsfacility.jpg | Bin 0 -> 3231 bytes react-app/src/icons/scv.jpg | Bin 0 -> 3072 bytes react-app/src/icons/scvbuildadvanced.jpg | Bin 0 -> 6364 bytes react-app/src/icons/scvbuildbasic.jpg | Bin 0 -> 6053 bytes react-app/src/icons/sensortower.jpg | Bin 0 -> 1972 bytes react-app/src/icons/sentry.jpg | Bin 0 -> 3968 bytes react-app/src/icons/siegetank.jpg | Bin 0 -> 3402 bytes react-app/src/icons/spawningpool.jpg | Bin 0 -> 3362 bytes react-app/src/icons/spinecrawler.jpg | Bin 0 -> 3066 bytes react-app/src/icons/spinecrawleruprooted.jpg | Bin 0 -> 3066 bytes react-app/src/icons/spire.jpg | Bin 0 -> 3616 bytes react-app/src/icons/sporecrawler.jpg | Bin 0 -> 2960 bytes react-app/src/icons/sporecrawleruprooted.jpg | Bin 0 -> 2960 bytes react-app/src/icons/stalker.jpg | Bin 0 -> 2556 bytes react-app/src/icons/stargate.jpg | Bin 0 -> 2994 bytes react-app/src/icons/starport.jpg | Bin 0 -> 5156 bytes react-app/src/icons/starporttechlab.jpg | Bin 0 -> 5521 bytes react-app/src/icons/supplydepot.jpg | Bin 0 -> 2518 bytes react-app/src/icons/surveillancestation.jpg | Bin 0 -> 3062 bytes react-app/src/icons/swarmhost.jpg | Bin 0 -> 5392 bytes react-app/src/icons/targetingdrone.jpg | Bin 0 -> 2661 bytes react-app/src/icons/techlab.jpg | Bin 0 -> 2723 bytes react-app/src/icons/templararchive.jpg | Bin 0 -> 2885 bytes react-app/src/icons/terranYamatoCannon.png | Bin 0 -> 7621 bytes react-app/src/icons/terranYamatoGun.png | Bin 0 -> 7621 bytes react-app/src/icons/thor.jpg | Bin 0 -> 4005 bytes react-app/src/icons/twilightcouncil.jpg | Bin 0 -> 3153 bytes react-app/src/icons/ultralisk.jpg | Bin 0 -> 4291 bytes react-app/src/icons/ultraliskcavern.jpg | Bin 0 -> 3772 bytes react-app/src/icons/viking.jpg | Bin 0 -> 2915 bytes react-app/src/icons/viper.jpg | Bin 0 -> 5001 bytes react-app/src/icons/voidray.jpg | Bin 0 -> 4225 bytes react-app/src/icons/warpgate.jpg | Bin 0 -> 3487 bytes react-app/src/icons/warpprism.jpg | Bin 0 -> 4323 bytes react-app/src/icons/widowmine.jpg | Bin 0 -> 4273 bytes react-app/src/icons/zerg.png | Bin 0 -> 52892 bytes react-app/src/icons/zergEvolutionchamber.jpg | Bin 0 -> 3502 bytes react-app/src/icons/zergGroundCarapace1.gif | Bin 0 -> 4696 bytes react-app/src/icons/zergMeleeAttacks1.gif | Bin 0 -> 4954 bytes react-app/src/icons/zergMissileAttacks1.gif | Bin 0 -> 5147 bytes react-app/src/icons/zergling.jpg | Bin 0 -> 2515 bytes react-app/src/index.js | 5 + react-app/yarn.lock | 6639 ++++++++++ 291 files changed, 19957 insertions(+) create mode 100644 react-app/.gitignore create mode 100644 react-app/README.md create mode 100644 react-app/package-lock.json create mode 100644 react-app/package.json create mode 100644 react-app/public/favicon.ico create mode 100644 react-app/public/index.html create mode 100644 react-app/public/manifest.json create mode 100644 react-app/src/App.js create mode 100644 react-app/src/icons/AWrp.gif create mode 100644 react-app/src/icons/AWrp.png create mode 100644 react-app/src/icons/AdrenalGlands.gif create mode 100644 react-app/src/icons/AnionPulseCrystals.png create mode 100644 react-app/src/icons/AssaultMode.gif create mode 100644 react-app/src/icons/AssaultMode.png create mode 100644 react-app/src/icons/Attack.png create mode 100644 react-app/src/icons/BehemothReactor.gif create mode 100644 react-app/src/icons/BlindingCloud.png create mode 100644 react-app/src/icons/Blink.png create mode 100644 react-app/src/icons/Build.png create mode 100644 react-app/src/icons/BuildAdvanced.png create mode 100644 react-app/src/icons/BuildAutoTurret.png create mode 100644 react-app/src/icons/BuildCreepTumor.png create mode 100644 react-app/src/icons/BuildPointDefenseDrone.png create mode 100644 react-app/src/icons/Build_auto_turret.gif create mode 100644 react-app/src/icons/Build_point_defense_drone.gif create mode 100644 react-app/src/icons/BuildingArmor.gif create mode 100644 react-app/src/icons/Burrow.gif create mode 100644 react-app/src/icons/CaduceusReactor.gif create mode 100644 react-app/src/icons/CalldownMULE.gif create mode 100644 react-app/src/icons/CalldownMULE.png create mode 100644 react-app/src/icons/Cancel.png create mode 100644 react-app/src/icons/CentrifugalHooks.gif create mode 100644 react-app/src/icons/Charge.png create mode 100644 react-app/src/icons/ChitinousPlating.gif create mode 100644 react-app/src/icons/ChronoBoost.png create mode 100644 react-app/src/icons/Cloak.png create mode 100644 react-app/src/icons/ColossusRange.gif create mode 100644 react-app/src/icons/CombatShield.png create mode 100644 react-app/src/icons/ConcussiveShells.png create mode 100644 react-app/src/icons/Contaminate.png create mode 100644 react-app/src/icons/CorruptionAbility.png create mode 100644 react-app/src/icons/CorvidReactor.gif create mode 100755 react-app/src/icons/Decloack.jpg create mode 100644 react-app/src/icons/DrillingClaws.png create mode 100644 react-app/src/icons/DurableMaterials.gif create mode 100644 react-app/src/icons/EMP.png create mode 100644 react-app/src/icons/EnableBuildingAttack.png create mode 100644 react-app/src/icons/Envision.png create mode 100644 react-app/src/icons/EvolveGlialRegeneration.gif create mode 100644 react-app/src/icons/EvolveTunnelingClaws.gif create mode 100644 react-app/src/icons/Explode.gif create mode 100644 react-app/src/icons/Explode.png create mode 100644 react-app/src/icons/ExplosivePayload.png create mode 100644 react-app/src/icons/Extractor.png create mode 100644 react-app/src/icons/Feedback.png create mode 100644 react-app/src/icons/FighterMode.png create mode 100644 react-app/src/icons/Fighter_mode.gif create mode 100644 react-app/src/icons/FlyerAttack1.gif create mode 100644 react-app/src/icons/FlyerCarapace1.gif create mode 100644 react-app/src/icons/ForceField.png create mode 100644 react-app/src/icons/Force_field.gif create mode 100644 react-app/src/icons/FungalGrowth.png create mode 100644 react-app/src/icons/Gather.png create mode 100644 react-app/src/icons/GenerateCreep.png create mode 100644 react-app/src/icons/GravitonBeam.png create mode 100644 react-app/src/icons/GravitonCatapult.gif create mode 100644 react-app/src/icons/GroovedSpines.gif create mode 100644 react-app/src/icons/GuardianShield.gif create mode 100644 react-app/src/icons/Hallucination.png create mode 100644 react-app/src/icons/Halt.png create mode 100644 react-app/src/icons/Heal.png create mode 100644 react-app/src/icons/HighImpactPayload.png create mode 100644 react-app/src/icons/HisecAutoTracking.gif create mode 100644 react-app/src/icons/HoldPosition.png create mode 100644 react-app/src/icons/HunterSeekerMissile.png create mode 100644 react-app/src/icons/ImpactMode.png create mode 100644 react-app/src/icons/IncreasedLocustLifetime.gif create mode 100644 react-app/src/icons/InfantryArmor1.gif create mode 100644 react-app/src/icons/InfantryWeapons1.gif create mode 100644 react-app/src/icons/InfernalPreigniter.png create mode 100644 react-app/src/icons/InfestedTerrans.gif create mode 100755 react-app/src/icons/Land.jpg create mode 100644 react-app/src/icons/Lift.png create mode 100644 react-app/src/icons/Load.gif create mode 100644 react-app/src/icons/Load.png create mode 100644 react-app/src/icons/Lower.gif create mode 100644 react-app/src/icons/MassRecall.png create mode 100644 react-app/src/icons/MedivacSpeedBoost.png create mode 100644 react-app/src/icons/MetabolicBoost.gif create mode 100644 react-app/src/icons/MorphToMothership.png create mode 100644 react-app/src/icons/MorphToOverseer.png create mode 100644 react-app/src/icons/MothershipCoreWeapon.png create mode 100644 react-app/src/icons/Move.png create mode 100644 react-app/src/icons/MuscularAugments.png create mode 100644 react-app/src/icons/NeosteelFrames.gif create mode 100644 react-app/src/icons/NeuralParasite.png create mode 100644 react-app/src/icons/NukeCalldown.png create mode 100644 react-app/src/icons/NydusWorm.jpeg create mode 100644 react-app/src/icons/ObserverSpeed.gif create mode 100644 react-app/src/icons/OracleRevelation.png create mode 100644 react-app/src/icons/PathogenGlands.gif create mode 100644 react-app/src/icons/Patrol.png create mode 100644 react-app/src/icons/PhasingMode.png create mode 100644 react-app/src/icons/Phasing_mode.gif create mode 100644 react-app/src/icons/PneumatizedCarapace.gif create mode 100644 react-app/src/icons/PrismaticAlignment.png create mode 100644 react-app/src/icons/Protoss.png create mode 100644 react-app/src/icons/ProtossAirArmorLevel1.gif create mode 100644 react-app/src/icons/ProtossAirWeapons.png create mode 100644 react-app/src/icons/ProtossAirWeaponsLevel1.gif create mode 100644 react-app/src/icons/ProtossGroundArmorLevel1.gif create mode 100644 react-app/src/icons/ProtossGroundWeaponsLevel1.gif create mode 100644 react-app/src/icons/ProtossShieldsLevel1.gif create mode 100644 react-app/src/icons/PsiStorm.png create mode 100644 react-app/src/icons/PulsarBeam.png create mode 100755 react-app/src/icons/PulsarBeamOff.jpg create mode 100755 react-app/src/icons/Rally.jpg create mode 100644 react-app/src/icons/Refinary.png create mode 100644 react-app/src/icons/Repair.gif create mode 100644 react-app/src/icons/Repair.png create mode 100644 react-app/src/icons/ResearchWarpgate.gif create mode 100644 react-app/src/icons/ReturnCargo.png create mode 100644 react-app/src/icons/Root.png create mode 100644 react-app/src/icons/Salvage.gif create mode 100644 react-app/src/icons/Scan.png create mode 100644 react-app/src/icons/Selectbuilder.png create mode 100644 react-app/src/icons/Setrallypoint.png create mode 100644 react-app/src/icons/Setworkerrallypoint.png create mode 100644 react-app/src/icons/SiegeMode.gif create mode 100644 react-app/src/icons/SiegeMode.png create mode 100644 react-app/src/icons/Snipe.png create mode 100644 react-app/src/icons/SpawnChangeling.gif create mode 100644 react-app/src/icons/SpawnCreepTumor.gif create mode 100644 react-app/src/icons/SpawnLocusts.png create mode 100644 react-app/src/icons/Stim.png create mode 100644 react-app/src/icons/Stop.png create mode 100644 react-app/src/icons/StopGenerateCreep.png create mode 100644 react-app/src/icons/SupplyDrop.png create mode 100644 react-app/src/icons/Tempest.png create mode 100644 react-app/src/icons/TemporalField.gif create mode 100644 react-app/src/icons/TemporalField.png create mode 100644 react-app/src/icons/Terran.png create mode 100644 react-app/src/icons/TrainInterceptors.gif create mode 100644 react-app/src/icons/Transfusion.png create mode 100644 react-app/src/icons/TransportMode.gif create mode 100644 react-app/src/icons/TransportMode.png create mode 100644 react-app/src/icons/Transport_mode.gif create mode 100644 react-app/src/icons/Unburrow.gif create mode 100755 react-app/src/icons/UnloadAll.jpg create mode 100644 react-app/src/icons/Unsiege.png create mode 100644 react-app/src/icons/Uproot.png create mode 100644 react-app/src/icons/VehiclePlating1.gif create mode 100644 react-app/src/icons/VehicleWeapons1.gif create mode 100644 react-app/src/icons/VentralSacs.gif create mode 100644 react-app/src/icons/ViperAbduct.png create mode 100644 react-app/src/icons/ViperConsume.png create mode 100644 react-app/src/icons/WarpPrismSpeed.gif create mode 100644 react-app/src/icons/WeaponsFree.png create mode 100644 react-app/src/icons/WidowMineAttack.png create mode 100644 react-app/src/icons/WidowMineBurrow.png create mode 100755 react-app/src/icons/WidowMineUnburrow.jpg create mode 100644 react-app/src/icons/archon.jpg create mode 100644 react-app/src/icons/armory.jpg create mode 100644 react-app/src/icons/assimilator.jpg create mode 100644 react-app/src/icons/autoturret.jpg create mode 100644 react-app/src/icons/baneling.jpg create mode 100644 react-app/src/icons/banelingnest.jpg create mode 100644 react-app/src/icons/banshee.jpg create mode 100644 react-app/src/icons/barracks.jpg create mode 100644 react-app/src/icons/barrackstechlab.jpg create mode 100644 react-app/src/icons/battlecruiser.jpg create mode 100644 react-app/src/icons/broodlord.jpg create mode 100644 react-app/src/icons/btn-ability-terran-holdfire.jpg create mode 100644 react-app/src/icons/btn-ability-terran-weaponsfree.jpg create mode 100644 react-app/src/icons/bunker.jpg create mode 100644 react-app/src/icons/carrier.jpg create mode 100644 react-app/src/icons/changeling.jpg create mode 100644 react-app/src/icons/color.jpg create mode 100644 react-app/src/icons/colossus.jpg create mode 100644 react-app/src/icons/commandcenter.jpg create mode 100644 react-app/src/icons/corruptor.jpg create mode 100644 react-app/src/icons/creeptumor.jpg create mode 100644 react-app/src/icons/cyberneticscore.jpg create mode 100644 react-app/src/icons/darkshrine.jpg create mode 100644 react-app/src/icons/darktemplar.jpg create mode 100644 react-app/src/icons/drone.jpg create mode 100644 react-app/src/icons/dronebuildadvanced.jpg create mode 100644 react-app/src/icons/dronebuildbasic.jpg create mode 100644 react-app/src/icons/egg.jpg create mode 100644 react-app/src/icons/engineeringbay.jpg create mode 100644 react-app/src/icons/extractor.jpg create mode 100644 react-app/src/icons/factory.jpg create mode 100644 react-app/src/icons/factorytechlab.jpg create mode 100644 react-app/src/icons/fleetbeacon.jpg create mode 100644 react-app/src/icons/forge.jpg create mode 100644 react-app/src/icons/fusioncore.jpg create mode 100644 react-app/src/icons/gateway.jpg create mode 100644 react-app/src/icons/ghost.jpg create mode 100644 react-app/src/icons/ghostacademy.jpg create mode 100644 react-app/src/icons/greaterspire.jpg create mode 100644 react-app/src/icons/hand.png create mode 100644 react-app/src/icons/hatchery.jpg create mode 100644 react-app/src/icons/hellbat.jpg create mode 100644 react-app/src/icons/hellion.jpg create mode 100644 react-app/src/icons/hightemplar.jpg create mode 100644 react-app/src/icons/hive.jpg create mode 100644 react-app/src/icons/hydralisk.jpg create mode 100644 react-app/src/icons/hydraliskden.jpg create mode 100644 react-app/src/icons/immortal.jpg create mode 100644 react-app/src/icons/infestationpit.jpg create mode 100644 react-app/src/icons/infestedmarine.jpg create mode 100644 react-app/src/icons/infestor.jpg create mode 100644 react-app/src/icons/interceptor.jpg create mode 100644 react-app/src/icons/lair.jpg create mode 100644 react-app/src/icons/larva.jpg create mode 100644 react-app/src/icons/marauder.jpg create mode 100644 react-app/src/icons/marine.jpg create mode 100644 react-app/src/icons/medivac.jpg create mode 100644 react-app/src/icons/missileturret.jpg create mode 100644 react-app/src/icons/mothership.jpg create mode 100644 react-app/src/icons/mothershipcore.jpg create mode 100644 react-app/src/icons/mule.jpg create mode 100644 react-app/src/icons/mutalisk.jpg create mode 100644 react-app/src/icons/nexus.jpg create mode 100644 react-app/src/icons/nydusnetwork.jpg create mode 100644 react-app/src/icons/nydusworm.jpg create mode 100644 react-app/src/icons/observer.jpg create mode 100644 react-app/src/icons/oracle.jpg create mode 100644 react-app/src/icons/orbitalcommand.jpg create mode 100644 react-app/src/icons/overlord.jpg create mode 100644 react-app/src/icons/overseer.jpg create mode 100644 react-app/src/icons/phoenix.jpg create mode 100644 react-app/src/icons/photoncannon.jpg create mode 100644 react-app/src/icons/planetaryfortress.jpg create mode 100644 react-app/src/icons/prismatic_beams.png create mode 100644 react-app/src/icons/probe.jpg create mode 100644 react-app/src/icons/probebuildadvanced.jpg create mode 100644 react-app/src/icons/probebuildbasic.jpg create mode 100644 react-app/src/icons/protossZealot.jpg create mode 100644 react-app/src/icons/pylon.jpg create mode 100644 react-app/src/icons/queen.jpg create mode 100644 react-app/src/icons/raven.jpg create mode 100644 react-app/src/icons/reactor.jpg create mode 100644 react-app/src/icons/reaper.jpg create mode 100644 react-app/src/icons/refinery.jpg create mode 100644 react-app/src/icons/roach.jpg create mode 100644 react-app/src/icons/roachwarren.jpg create mode 100644 react-app/src/icons/roboticsbay.jpg create mode 100644 react-app/src/icons/roboticsfacility.jpg create mode 100644 react-app/src/icons/scv.jpg create mode 100644 react-app/src/icons/scvbuildadvanced.jpg create mode 100644 react-app/src/icons/scvbuildbasic.jpg create mode 100644 react-app/src/icons/sensortower.jpg create mode 100644 react-app/src/icons/sentry.jpg create mode 100644 react-app/src/icons/siegetank.jpg create mode 100644 react-app/src/icons/spawningpool.jpg create mode 100644 react-app/src/icons/spinecrawler.jpg create mode 100644 react-app/src/icons/spinecrawleruprooted.jpg create mode 100644 react-app/src/icons/spire.jpg create mode 100644 react-app/src/icons/sporecrawler.jpg create mode 100644 react-app/src/icons/sporecrawleruprooted.jpg create mode 100644 react-app/src/icons/stalker.jpg create mode 100644 react-app/src/icons/stargate.jpg create mode 100644 react-app/src/icons/starport.jpg create mode 100644 react-app/src/icons/starporttechlab.jpg create mode 100644 react-app/src/icons/supplydepot.jpg create mode 100644 react-app/src/icons/surveillancestation.jpg create mode 100644 react-app/src/icons/swarmhost.jpg create mode 100644 react-app/src/icons/targetingdrone.jpg create mode 100644 react-app/src/icons/techlab.jpg create mode 100644 react-app/src/icons/templararchive.jpg create mode 100644 react-app/src/icons/terranYamatoCannon.png create mode 100644 react-app/src/icons/terranYamatoGun.png create mode 100644 react-app/src/icons/thor.jpg create mode 100644 react-app/src/icons/twilightcouncil.jpg create mode 100644 react-app/src/icons/ultralisk.jpg create mode 100644 react-app/src/icons/ultraliskcavern.jpg create mode 100644 react-app/src/icons/viking.jpg create mode 100644 react-app/src/icons/viper.jpg create mode 100644 react-app/src/icons/voidray.jpg create mode 100644 react-app/src/icons/warpgate.jpg create mode 100644 react-app/src/icons/warpprism.jpg create mode 100644 react-app/src/icons/widowmine.jpg create mode 100644 react-app/src/icons/zerg.png create mode 100644 react-app/src/icons/zergEvolutionchamber.jpg create mode 100644 react-app/src/icons/zergGroundCarapace1.gif create mode 100644 react-app/src/icons/zergMeleeAttacks1.gif create mode 100644 react-app/src/icons/zergMissileAttacks1.gif create mode 100644 react-app/src/icons/zergling.jpg create mode 100644 react-app/src/index.js create mode 100644 react-app/yarn.lock diff --git a/react-app/.gitignore b/react-app/.gitignore new file mode 100644 index 0000000..d30f40e --- /dev/null +++ b/react-app/.gitignore @@ -0,0 +1,21 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/react-app/README.md b/react-app/README.md new file mode 100644 index 0000000..7c64145 --- /dev/null +++ b/react-app/README.md @@ -0,0 +1,2433 @@ +This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). + +Below you will find some information on how to perform common tasks.
+You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). + +## Table of Contents + +- [Updating to New Releases](#updating-to-new-releases) +- [Sending Feedback](#sending-feedback) +- [Folder Structure](#folder-structure) +- [Available Scripts](#available-scripts) + - [npm start](#npm-start) + - [npm test](#npm-test) + - [npm run build](#npm-run-build) + - [npm run eject](#npm-run-eject) +- [Supported Browsers](#supported-browsers) +- [Supported Language Features and Polyfills](#supported-language-features-and-polyfills) +- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) +- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) +- [Debugging in the Editor](#debugging-in-the-editor) +- [Formatting Code Automatically](#formatting-code-automatically) +- [Changing the Page ``](#changing-the-page-title) +- [Installing a Dependency](#installing-a-dependency) +- [Importing a Component](#importing-a-component) +- [Code Splitting](#code-splitting) +- [Adding a Stylesheet](#adding-a-stylesheet) +- [Post-Processing CSS](#post-processing-css) +- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc) +- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files) +- [Using the `public` Folder](#using-the-public-folder) + - [Changing the HTML](#changing-the-html) + - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system) + - [When to Use the `public` Folder](#when-to-use-the-public-folder) +- [Using Global Variables](#using-global-variables) +- [Adding Bootstrap](#adding-bootstrap) + - [Using a Custom Theme](#using-a-custom-theme) +- [Adding Flow](#adding-flow) +- [Adding a Router](#adding-a-router) +- [Adding Custom Environment Variables](#adding-custom-environment-variables) + - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html) + - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) + - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env) +- [Can I Use Decorators?](#can-i-use-decorators) +- [Fetching Data with AJAX Requests](#fetching-data-with-ajax-requests) +- [Integrating with an API Backend](#integrating-with-an-api-backend) + - [Node](#node) + - [Ruby on Rails](#ruby-on-rails) +- [Proxying API Requests in Development](#proxying-api-requests-in-development) + - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) + - [Configuring the Proxy Manually](#configuring-the-proxy-manually) + - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy) +- [Using HTTPS in Development](#using-https-in-development) +- [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) +- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) +- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) +- [Running Tests](#running-tests) + - [Filename Conventions](#filename-conventions) + - [Command Line Interface](#command-line-interface) + - [Version Control Integration](#version-control-integration) + - [Writing Tests](#writing-tests) + - [Testing Components](#testing-components) + - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) + - [Initializing Test Environment](#initializing-test-environment) + - [Focusing and Excluding Tests](#focusing-and-excluding-tests) + - [Coverage Reporting](#coverage-reporting) + - [Continuous Integration](#continuous-integration) + - [Disabling jsdom](#disabling-jsdom) + - [Snapshot Testing](#snapshot-testing) + - [Editor Integration](#editor-integration) +- [Debugging Tests](#debugging-tests) + - [Debugging Tests in Chrome](#debugging-tests-in-chrome) + - [Debugging Tests in Visual Studio Code](#debugging-tests-in-visual-studio-code) +- [Developing Components in Isolation](#developing-components-in-isolation) + - [Getting Started with Storybook](#getting-started-with-storybook) + - [Getting Started with Styleguidist](#getting-started-with-styleguidist) +- [Publishing Components to npm](#publishing-components-to-npm) +- [Making a Progressive Web App](#making-a-progressive-web-app) + - [Opting Out of Caching](#opting-out-of-caching) + - [Offline-First Considerations](#offline-first-considerations) + - [Progressive Web App Metadata](#progressive-web-app-metadata) +- [Analyzing the Bundle Size](#analyzing-the-bundle-size) +- [Deployment](#deployment) + - [Static Server](#static-server) + - [Other Solutions](#other-solutions) + - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Building for Relative Paths](#building-for-relative-paths) + - [Azure](#azure) + - [Firebase](#firebase) + - [GitHub Pages](#github-pages) + - [Heroku](#heroku) + - [Netlify](#netlify) + - [Now](#now) + - [S3 and CloudFront](#s3-and-cloudfront) + - [Surge](#surge) +- [Advanced Configuration](#advanced-configuration) +- [Troubleshooting](#troubleshooting) + - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes) + - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) + - [`npm run build` exits too early](#npm-run-build-exits-too-early) + - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) + - [`npm run build` fails to minify](#npm-run-build-fails-to-minify) + - [Moment.js locales are missing](#momentjs-locales-are-missing) +- [Alternatives to Ejecting](#alternatives-to-ejecting) +- [Something Missing?](#something-missing) + +## Updating to New Releases + +Create React App is divided into two packages: + +* `create-react-app` is a global command-line utility that you use to create new projects. +* `react-scripts` is a development dependency in the generated projects (including this one). + +You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. + +When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. + +To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. + +In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. + +We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. + +## Sending Feedback + +We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). + +## Folder Structure + +After creation, your project should look like this: + +``` +my-app/ + README.md + node_modules/ + package.json + public/ + index.html + favicon.ico + src/ + App.css + App.js + App.test.js + index.css + index.js + logo.svg +``` + +For the project to build, **these files must exist with exact filenames**: + +* `public/index.html` is the page template; +* `src/index.js` is the JavaScript entry point. + +You can delete or rename the other files. + +You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br> +You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. + +Only files inside `public` can be used from `public/index.html`.<br> +Read instructions below for using assets from JavaScript and HTML. + +You can, however, create more top-level directories.<br> +They will not be included in the production build so you can use them for things like documentation. + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.<br> +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.<br> +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.<br> +See the section about [running tests](#running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.<br> +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.<br> +Your app is ready to be deployed! + +See the section about [deployment](#deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Supported Browsers + +By default, the generated project uses the latest version of React. + +You can refer [to the React documentation](https://reactjs.org/docs/react-dom.html#browser-support) for more information about supported browsers. + +## Supported Language Features and Polyfills + +This project supports a superset of the latest JavaScript standard.<br> +In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports: + +* [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016). +* [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017). +* [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal). +* [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal) +* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal). +* [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax. + +Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). + +While we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. + +Note that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**: + +* [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) via [`object-assign`](https://github.com/sindresorhus/object-assign). +* [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) via [`promise`](https://github.com/then/promise). +* [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) via [`whatwg-fetch`](https://github.com/github/fetch). + +If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them. + +Also note that using some newer syntax features like `for...of` or `[...nonArrayValue]` causes Babel to emit code that depends on ES6 runtime features and might not work without a polyfill. When in doubt, use [Babel REPL](https://babeljs.io/repl/) to see what any specific syntax compiles down to. + +## Syntax Highlighting in the Editor + +To configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered. + +## Displaying Lint Output in the Editor + +>Note: this feature is available with `react-scripts@0.2.0` and higher.<br> +>It also only works with npm 3 or higher. + +Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. + +They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. + +You would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root: + +```js +{ + "extends": "react-app" +} +``` + +Now your editor should report the linting warnings. + +Note that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes. + +If you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules. + +## Debugging in the Editor + +**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).** + +Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. + +### Visual Studio Code + +You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed. + +Then add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory. + +```json +{ + "version": "0.2.0", + "configurations": [{ + "name": "Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceRoot}/src", + "sourceMapPathOverrides": { + "webpack:///src/*": "${webRoot}/*" + } + }] +} +``` +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. + +Having problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting). + +### WebStorm + +You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed. + +In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration. + +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm. + +The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. + +## Formatting Code Automatically + +Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). + +To format our code whenever we make a commit in git, we need to install the following dependencies: + +```sh +npm install --save husky lint-staged prettier +``` + +Alternatively you may use `yarn`: + +```sh +yarn add husky lint-staged prettier +``` + +* `husky` makes it easy to use githooks as if they are npm scripts. +* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8). +* `prettier` is the JavaScript formatter we will run before commits. + +Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root. + +Add the following line to `scripts` section: + +```diff + "scripts": { ++ "precommit": "lint-staged", + "start": "react-scripts start", + "build": "react-scripts build", +``` + +Next we add a 'lint-staged' field to the `package.json`, for example: + +```diff + "dependencies": { + // ... + }, ++ "lint-staged": { ++ "src/**/*.{js,jsx,json,css}": [ ++ "prettier --single-quote --write", ++ "git add" ++ ] ++ }, + "scripts": { +``` + +Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. + +Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://prettier.io/docs/en/editors.html) on the Prettier GitHub page. + +## Changing the Page `<title>` + +You can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else. + +Note that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML. + +If you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library. + +If you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files). + +## Installing a Dependency + +The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: + +```sh +npm install --save react-router +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router +``` + +This works for any library, not just `react-router`. + +## Importing a Component + +This project setup supports ES6 modules thanks to Babel.<br> +While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. + +For example: + +### `Button.js` + +```js +import React, { Component } from 'react'; + +class Button extends Component { + render() { + // ... + } +} + +export default Button; // Don’t forget to use export default! +``` + +### `DangerButton.js` + + +```js +import React, { Component } from 'react'; +import Button from './Button'; // Import a component from another file + +class DangerButton extends Component { + render() { + return <Button color="red" />; + } +} + +export default DangerButton; +``` + +Be aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes. + +We suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`. + +Named exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like. + +Learn more about ES6 modules: + +* [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281) +* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html) +* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules) + +## Code Splitting + +Instead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand. + +This project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module. + +Here is an example: + +### `moduleA.js` + +```js +const moduleA = 'Hello'; + +export { moduleA }; +``` +### `App.js` + +```js +import React, { Component } from 'react'; + +class App extends Component { + handleClick = () => { + import('./moduleA') + .then(({ moduleA }) => { + // Use moduleA + }) + .catch(err => { + // Handle failure + }); + }; + + render() { + return ( + <div> + <button onClick={this.handleClick}>Load</button> + </div> + ); + } +} + +export default App; +``` + +This will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button. + +You can also use it with `async` / `await` syntax if you prefer it. + +### With React Router + +If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app). + +Also check out the [Code Splitting](https://reactjs.org/docs/code-splitting.html) section in React documentation. + +## Adding a Stylesheet + +This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**: + +### `Button.css` + +```css +.Button { + padding: 20px; +} +``` + +### `Button.js` + +```js +import React, { Component } from 'react'; +import './Button.css'; // Tell Webpack that Button.js uses these styles + +class Button extends Component { + render() { + // You can use them as regular CSS styles + return <div className="Button" />; + } +} +``` + +**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-ui-engineering/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack. + +In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output. + +If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool. + +## Post-Processing CSS + +This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it. + +For example, this: + +```css +.App { + display: flex; + flex-direction: row; + align-items: center; +} +``` + +becomes this: + +```css +.App { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +``` + +If you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling). + +## Adding a CSS Preprocessor (Sass, Less etc.) + +Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)). + +Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable. In this walkthrough, we will be using Sass, but you can also use Less, or another alternative. + +First, let’s install the command-line interface for Sass: + +```sh +npm install --save node-sass-chokidar +``` + +Alternatively you may use `yarn`: + +```sh +yarn add node-sass-chokidar +``` + +Then in `package.json`, add the following lines to `scripts`: + +```diff + "scripts": { ++ "build-css": "node-sass-chokidar src/ -o src/", ++ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", +``` + +>Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation. + +Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated. + +To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions. + +To enable importing files without using relative paths, you can add the `--include-path` option to the command in `package.json`. + +``` +"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", +"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", +``` + +This will allow you to do imports like + +```scss +@import 'styles/_colors.scss'; // assuming a styles directory under src/ +@import 'nprogress/nprogress'; // importing a css file from the nprogress node module +``` + +At this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control. + +As a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `&&` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this: + +```sh +npm install --save npm-run-all +``` + +Alternatively you may use `yarn`: + +```sh +yarn add npm-run-all +``` + +Then we can change `start` and `build` scripts to include the CSS preprocessor commands: + +```diff + "scripts": { + "build-css": "node-sass-chokidar src/ -o src/", + "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", +- "start": "react-scripts start", +- "build": "react-scripts build", ++ "start-js": "react-scripts start", ++ "start": "npm-run-all -p watch-css start-js", ++ "build-js": "react-scripts build", ++ "build": "npm-run-all build-css build-js", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +``` + +Now running `npm start` and `npm run build` also builds Sass files. + +**Why `node-sass-chokidar`?** + +`node-sass` has been reported as having the following issues: + +- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker. + +- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939) + +- `node-sass` has been reported as having issues with detecting new files in a directory [#1891](https://github.com/sass/node-sass/issues/1891) + + `node-sass-chokidar` is used here as it addresses these issues. + +## Adding Images, Fonts, and Files + +With Webpack, using static assets like images and fonts works similarly to CSS. + +You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. + +To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153). + +Here is an example: + +```js +import React from 'react'; +import logo from './logo.png'; // Tell Webpack this JS file uses this image + +console.log(logo); // /logo.84287d09.png + +function Header() { + // Import result is the URL of your image + return <img src={logo} alt="Logo" />; +} + +export default Header; +``` + +This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths. + +This works in CSS too: + +```css +.Logo { + background-image: url(./logo.png); +} +``` + +Webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets. + +Please be advised that this is also a custom feature of Webpack. + +**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br> +An alternative way of handling static assets is described in the next section. + +## Using the `public` Folder + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +### Changing the HTML + +The `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title). +The `<script>` tag with the compiled code will be added to it automatically during the build process. + +### Adding Assets Outside of the Module System + +You can also add other assets to the `public` folder. + +Note that we normally encourage you to `import` assets in JavaScript files instead. +For example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files). +This mechanism provides a number of benefits: + +* Scripts and stylesheets get minified and bundled together to avoid extra network requests. +* Missing files cause compilation errors instead of 404 errors for your users. +* Result filenames include content hashes so you don’t need to worry about browsers caching their old versions. + +However there is an **escape hatch** that you can use to add an asset outside of the module system. + +If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`. + +Inside `index.html`, you can use it like this: + +```html +<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> +``` + +Only files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build. + +When you run `npm run build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL. + +In JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes: + +```js +render() { + // Note: this is an escape hatch and should be used sparingly! + // Normally we recommend using `import` for getting asset URLs + // as described in “Adding Images and Fonts” above this section. + return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />; +} +``` + +Keep in mind the downsides of this approach: + +* None of the files in `public` folder get post-processed or minified. +* Missing files will not be called at compilation time, and will cause 404 errors for your users. +* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change. + +### When to Use the `public` Folder + +Normally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript. +The `public` folder is useful as a workaround for a number of less common cases: + +* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest). +* You have thousands of images and need to dynamically reference their paths. +* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code. +* Some library may be incompatible with Webpack and you have no other option but to include it as a `<script>` tag. + +Note that if you add a `<script>` that declares global variables, you also need to read the next section on using them. + +## Using Global Variables + +When you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable. + +You can avoid this by reading the global variable explicitly from the `window` object, for example: + +```js +const $ = window.$; +``` + +This makes it obvious you are using a global variable intentionally rather than because of a typo. + +Alternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it. + +## Adding Bootstrap + +You don’t have to use [React Bootstrap](https://react-bootstrap.github.io) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps: + +Install React Bootstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well: + +```sh +npm install --save react-bootstrap bootstrap@3 +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-bootstrap bootstrap@3 +``` + +Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file: + +```js +import 'bootstrap/dist/css/bootstrap.css'; +import 'bootstrap/dist/css/bootstrap-theme.css'; +// Put any other imports below so that CSS from your +// components takes precedence over default styles. +``` + +Import required React Bootstrap components within ```src/App.js``` file or your custom component files: + +```js +import { Navbar, Jumbotron, Button } from 'react-bootstrap'; +``` + +Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap. + +### Using a Custom Theme + +Sometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).<br> +We suggest the following approach: + +* Create a new package that depends on the package you wish to customize, e.g. Bootstrap. +* Add the necessary build steps to tweak the theme, and publish your package on npm. +* Install your own theme npm package as a dependency of your app. + +Here is an example of adding a [customized Bootstrap](https://medium.com/@tacomanator/customizing-create-react-app-aa9ffb88165) that follows these steps. + +## Adding Flow + +Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. + +Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box. + +To add Flow to a Create React App project, follow these steps: + +1. Run `npm install --save flow-bin` (or `yarn add flow-bin`). +2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. +3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. +4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). + +Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. +You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience. +In the future we plan to integrate it into Create React App even more closely. + +To learn more about Flow, check out [its documentation](https://flowtype.org/). + +## Adding a Router + +Create React App doesn't prescribe a specific routing solution, but [React Router](https://reacttraining.com/react-router/) is the most popular one. + +To add it, run: + +```sh +npm install --save react-router-dom +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router-dom +``` + +To try it, delete all the code in `src/App.js` and replace it with any of the examples on its website. The [Basic Example](https://reacttraining.com/react-router/web/example/basic) is a good place to get started. + +Note that [you may need to configure your production server to support client-side routing](#serving-apps-with-client-side-routing) before deploying your app. + +## Adding Custom Environment Variables + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +Your project can consume variables declared in your environment as if they were declared locally in your JS files. By +default you will have `NODE_ENV` defined for you, and any other environment variables starting with +`REACT_APP_`. + +**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them. + +>Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +These environment variables will be defined for you on `process.env`. For example, having an environment +variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`. + +There is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production. + +These environment variables can be useful for displaying information conditionally based on where the project is +deployed or consuming sensitive data that lives outside of version control. + +First, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined +in the environment inside a `<form>`: + +```jsx +render() { + return ( + <div> + <small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small> + <form> + <input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} /> + </form> + </div> + ); +} +``` + +During the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically. + +When you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`: + +```html +<div> + <small>You are running this application in <b>development</b> mode.</small> + <form> + <input type="hidden" value="abcdef" /> + </form> +</div> +``` + +The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this +value, we need to have it defined in the environment. This can be done using two ways: either in your shell or in +a `.env` file. Both of these ways are described in the next few sections. + +Having access to the `NODE_ENV` is also useful for performing actions conditionally: + +```js +if (process.env.NODE_ENV !== 'production') { + analytics.disable(); +} +``` + +When you compile the app with `npm run build`, the minification step will strip out this condition, and the resulting bundle will be smaller. + +### Referencing Environment Variables in the HTML + +>Note: this feature is available with `react-scripts@0.9.0` and higher. + +You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example: + +```html +<title>%REACT_APP_WEBSITE_NAME% +``` + +Note that the caveats from the above section apply: + +* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work. +* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server). + +### Adding Temporary Environment Variables In Your Shell + +Defining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the +life of the shell session. + +#### Windows (cmd.exe) + +```cmd +set "REACT_APP_SECRET_CODE=abcdef" && npm start +``` + +(Note: Quotes around the variable assignment are required to avoid a trailing whitespace.) + +#### Windows (Powershell) + +```Powershell +($env:REACT_APP_SECRET_CODE = "abcdef") -and (npm start) +``` + +#### Linux, macOS (Bash) + +```bash +REACT_APP_SECRET_CODE=abcdef npm start +``` + +### Adding Development Environment Variables In `.env` + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +To define permanent environment variables, create a file called `.env` in the root of your project: + +``` +REACT_APP_SECRET_CODE=abcdef +``` +>Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid [accidentally exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +`.env` files **should be** checked into source control (with the exclusion of `.env*.local`). + +#### What other `.env` files can be used? + +>Note: this feature is **available with `react-scripts@1.0.0` and higher**. + +* `.env`: Default. +* `.env.local`: Local overrides. **This file is loaded for all environments except test.** +* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings. +* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings. + +Files on the left have more priority than files on the right: + +* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env` +* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env` +* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing) + +These variables will act as the defaults if the machine does not explicitly set them.
+Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details. + +>Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need +these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars). + +#### Expanding Environment Variables In `.env` + +>Note: this feature is available with `react-scripts@1.1.0` and higher. + +Expand variables already on your machine for use in your `.env` file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)). + +For example, to get the environment variable `npm_package_version`: + +``` +REACT_APP_VERSION=$npm_package_version +# also works: +# REACT_APP_VERSION=${npm_package_version} +``` + +Or expand variables local to the current `.env` file: + +``` +DOMAIN=www.example.com +REACT_APP_FOO=$DOMAIN/foo +REACT_APP_BAR=$DOMAIN/bar +``` + +## Can I Use Decorators? + +Many popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
+Create React App doesn’t support decorator syntax at the moment because: + +* It is an experimental proposal and is subject to change. +* The current specification version is not officially supported by Babel. +* If the specification changes, we won’t be able to write a codemod because we don’t use them internally at Facebook. + +However in many cases you can rewrite decorator-based code without decorators just as fine.
+Please refer to these two threads for reference: + +* [#214](https://github.com/facebookincubator/create-react-app/issues/214) +* [#411](https://github.com/facebookincubator/create-react-app/issues/411) + +Create React App will add decorator support when the specification advances to a stable stage. + +## Fetching Data with AJAX Requests + +React doesn't prescribe a specific approach to data fetching, but people commonly use either a library like [axios](https://github.com/axios/axios) or the [`fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) provided by the browser. Conveniently, Create React App includes a polyfill for `fetch()` so you can use it without worrying about the browser support. + +The global `fetch` function allows to easily makes AJAX requests. It takes in a URL as an input and returns a `Promise` that resolves to a `Response` object. You can find more information about `fetch` [here](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). + +This project also includes a [Promise polyfill](https://github.com/then/promise) which provides a full implementation of Promises/A+. A Promise represents the eventual result of an asynchronous operation, you can find more information about Promises [here](https://www.promisejs.org/) and [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Both axios and `fetch()` use Promises under the hood. You can also use the [`async / await`](https://davidwalsh.name/async-await) syntax to reduce the callback nesting. + +You can learn more about making AJAX requests from React components in [the FAQ entry on the React website](https://reactjs.org/docs/faq-ajax.html). + +## Integrating with an API Backend + +These tutorials will help you to integrate your app with an API backend running on another port, +using `fetch()` to access it. + +### Node +Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). + +### Ruby on Rails + +Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). + +## Proxying API Requests in Development + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +People often serve the front-end React app from the same host and port as their backend implementation.
+For example, a production setup might look like this after the app is deployed: + +``` +/ - static server returns index.html with React app +/todos - static server returns index.html with React app +/api/todos - server handles any /api/* requests using the backend implementation +``` + +Such setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development. + +To tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example: + +```js + "proxy": "http://localhost:4000", +``` + +This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy. + +Conveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development: + +``` +Fetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. +``` + +Keep in mind that `proxy` only has effect in development (with `npm start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`. + +The `proxy` option supports HTTP, HTTPS and WebSocket connections.
+If the `proxy` option is **not** flexible enough for you, alternatively you can: + +* [Configure the proxy yourself](#configuring-the-proxy-manually) +* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)). +* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app. + +### "Invalid Host Header" Errors After Configuring Proxy + +When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887). + +This shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebookincubator/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option: + +>Invalid Host header + +To work around it, you can specify your public development host in a file called `.env.development` in the root of your project: + +``` +HOST=mypublicdevhost.com +``` + +If you restart the development server now and load the app from the specified host, it should work. + +If you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:** + +``` +# NOTE: THIS IS DANGEROUS! +# It exposes your machine to attacks from the websites you visit. +DANGEROUSLY_DISABLE_HOST_CHECK=true +``` + +We don’t recommend this approach. + +### Configuring the Proxy Manually + +>Note: this feature is available with `react-scripts@1.0.0` and higher. + +If the `proxy` option is **not** flexible enough for you, you can specify an object in the following form (in `package.json`).
+You may also specify any configuration value [`http-proxy-middleware`](https://github.com/chimurai/http-proxy-middleware#options) or [`http-proxy`](https://github.com/nodejitsu/node-http-proxy#options) supports. +```js +{ + // ... + "proxy": { + "/api": { + "target": "", + "ws": true + // ... + } + } + // ... +} +``` + +All requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy. + +If you need to specify multiple proxies, you may do so by specifying additional entries. +Matches are regular expressions, so that you can use a regexp to match multiple paths. +```js +{ + // ... + "proxy": { + // Matches any request starting with /api + "/api": { + "target": "", + "ws": true + // ... + }, + // Matches any request starting with /foo + "/foo": { + "target": "", + "ssl": true, + "pathRewrite": { + "^/foo": "/foo/beta" + } + // ... + }, + // Matches /bar/abc.html but not /bar/sub/def.html + "/bar/[^/]*[.]html": { + "target": "", + // ... + }, + // Matches /baz/abc.html and /baz/sub/def.html + "/baz/.*/.*[.]html": { + "target": "" + // ... + } + } + // ... +} +``` + +### Configuring a WebSocket Proxy + +When setting up a WebSocket proxy, there are a some extra considerations to be aware of. + +If you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html). + +There’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/). + +Standard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). + +Either way, you can proxy WebSocket requests manually in `package.json`: + +```js +{ + // ... + "proxy": { + "/socket": { + // Your compatible WebSocket server + "target": "ws://", + // Tell http-proxy-middleware that this is a WebSocket proxy. + // Also allows you to proxy WebSocket requests without an additional HTTP request + // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade + "ws": true + // ... + } + } + // ... +} +``` + +## Using HTTPS in Development + +>Note: this feature is available with `react-scripts@0.4.0` and higher. + +You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the "proxy" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS. + +To do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`: + +#### Windows (cmd.exe) + +```cmd +set HTTPS=true&&npm start +``` + +#### Windows (Powershell) + +```Powershell +($env:HTTPS = $true) -and (npm start) +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +HTTPS=true npm start +``` + +Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page. + +## Generating Dynamic `` Tags on the Server + +Since Create React App doesn’t support server rendering, you might be wondering how to make `` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this: + +```html + + + + + +``` + +Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML! + +If you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases. + +## Pre-Rendering into Static HTML Files + +If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. + +There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. + +The primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines. + +You can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319). + +## Injecting Data from the Server into the Page + +Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: + +```js + + + + +``` + +Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** + +## Running Tests + +>Note: this feature is available with `react-scripts@0.3.0` and higher.
+>[Read the migration guide to learn how to enable it in older projects!](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030) + +Create React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try. + +Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness. + +While Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks. + +We recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App. + +### Filename Conventions + +Jest will look for test files with any of the following popular naming conventions: + +* Files with `.js` suffix in `__tests__` folders. +* Files with `.test.js` suffix. +* Files with `.spec.js` suffix. + +The `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder. + +We recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects. + +### Command Line Interface + +When you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code. + +The watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run: + +![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif) + +### Version Control Integration + +By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. + +Jest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests. + +Jest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository. + +### Writing Tests + +To create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended. + +Jest provides a built-in `expect()` global function for making assertions. A basic test could look like this: + +```js +import sum from './sum'; + +it('sums numbers', () => { + expect(sum(1, 2)).toEqual(3); + expect(sum(2, 2)).toEqual(4); +}); +``` + +All `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).
+You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions. + +### Testing Components + +There is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes. + +Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: + +```js +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); +``` + +This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot of value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. + +When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. + +If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: + +```sh +npm install --save enzyme enzyme-adapter-react-16 react-test-renderer +``` + +Alternatively you may use `yarn`: + +```sh +yarn add enzyme enzyme-adapter-react-16 react-test-renderer +``` + +As of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.) + +The adapter will also need to be configured in your [global setup file](#initializing-test-environment): + +#### `src/setupTests.js` +```js +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() }); +``` + +>Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it. [Read here](#initializing-test-environment) to learn how to add this after ejecting. + +Now you can write a smoke test with it: + +```js +import React from 'react'; +import { shallow } from 'enzyme'; +import App from './App'; + +it('renders without crashing', () => { + shallow(); +}); +``` + +Unlike the previous smoke test using `ReactDOM.render()`, this test only renders `` and doesn’t go deeper. For example, even if `` itself renders a `