diff --git a/app/core/ModuleLoader.coffee b/app/core/ModuleLoader.coffee index 7fe5a20e2..b5035a619 100644 --- a/app/core/ModuleLoader.coffee +++ b/app/core/ModuleLoader.coffee @@ -9,7 +9,6 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass @WADS = [ 'lib' 'views/play' - 'views/game-menu' 'views/editor' ] diff --git a/app/core/errors.coffee b/app/core/errors.coffee index 13b429ba8..bfdd36409 100644 --- a/app/core/errors.coffee +++ b/app/core/errors.coffee @@ -1,4 +1,4 @@ -errorModalTemplate = require 'templates/modal/error' +errorModalTemplate = require 'templates/core/error' {applyErrorsToForm} = require 'core/forms' module.exports.parseServerError = (text) -> @@ -42,7 +42,7 @@ module.exports.connectionFailure = connectionFailure = -> showErrorModal(html) showErrorModal = (html) -> - # TODO: make a views/modal/error_modal view for this to use so the template can reuse templates/modal/modal_base? + # TODO: make a views/modal/error_modal view for this to use so the template can reuse templates/core/modal-base? $('#modal-wrapper').html(html) $('.modal:visible').modal('hide') $('#modal-error').modal('show') diff --git a/app/core/utils.coffee b/app/core/utils.coffee index 5a4e78594..195e0a3e2 100644 --- a/app/core/utils.coffee +++ b/app/core/utils.coffee @@ -130,3 +130,13 @@ module.exports.kindaEqual = compare = (l, r) -> return true else return false + +# Fast, basic way to replace text in an element when you don't need much. +# http://stackoverflow.com/a/4962398/540620 +if document? + dummy = document.createElement 'div' + dummy.innerHTML = 'text' + TEXT = if dummy.textContent is 'text' then 'textContent' else 'innerText' + module.exports.replaceText = (elems, text) -> + elem[TEXT] = text for elem in elems + null diff --git a/app/lib/LevelSetupManager.coffee b/app/lib/LevelSetupManager.coffee index 8ebea923d..90a851e2e 100644 --- a/app/lib/LevelSetupManager.coffee +++ b/app/lib/LevelSetupManager.coffee @@ -1,6 +1,6 @@ CocoClass = require 'core/CocoClass' PlayHeroesModal = require 'views/play/modal/PlayHeroesModal' -InventoryModal = require 'views/game-menu/InventoryModal' +InventoryModal = require 'views/play/menu/InventoryModal' LevelSession = require 'models/LevelSession' SuperModel = require 'models/SuperModel' ThangType = require 'models/ThangType' diff --git a/app/lib/surface/LankBoss.coffee b/app/lib/surface/LankBoss.coffee index c6202b535..e192f92bb 100644 --- a/app/lib/surface/LankBoss.coffee +++ b/app/lib/surface/LankBoss.coffee @@ -192,7 +192,7 @@ module.exports = class LankBoss extends CocoClass updatedObstacles = [] itemsJustEquipped = [] for thang in @world.thangs when thang.exists and thang.pos - itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang + itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang if thang.equip if lank = @lanks[thang.id] lank.setThang thang # make sure Lank has latest Thang else diff --git a/app/templates/account/job_profile_code_modal.jade b/app/templates/account/job_profile_code_modal.jade index 6f5703ef6..52cabcf51 100644 --- a/app/templates/account/job_profile_code_modal.jade +++ b/app/templates/account/job_profile_code_modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3 Applicant Code for diff --git a/app/templates/community.jade b/app/templates/community-view.jade similarity index 100% rename from app/templates/community.jade rename to app/templates/community-view.jade diff --git a/app/templates/achievements/achievement-popup.jade b/app/templates/core/achievement-popup.jade similarity index 100% rename from app/templates/achievements/achievement-popup.jade rename to app/templates/core/achievement-popup.jade diff --git a/app/templates/core/auth.jade b/app/templates/core/auth.jade index 03ed223b6..42ed83c63 100644 --- a/app/templates/core/auth.jade +++ b/app/templates/core/auth.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content if mode === 'login' diff --git a/app/templates/modal/contact.jade b/app/templates/core/contact.jade similarity index 97% rename from app/templates/modal/contact.jade rename to app/templates/core/contact.jade index 7143520c2..53192fb01 100644 --- a/app/templates/modal/contact.jade +++ b/app/templates/core/contact.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="contact.contact_us") Contact CodeCombat... diff --git a/app/templates/modal/diplomat_suggestion.jade b/app/templates/core/diplomat-suggestion.jade similarity index 96% rename from app/templates/modal/diplomat_suggestion.jade rename to app/templates/core/diplomat-suggestion.jade index 56d98f33a..0864c0493 100644 --- a/app/templates/modal/diplomat_suggestion.jade +++ b/app/templates/core/diplomat-suggestion.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="diplomat_suggestion.title") Help translate CodeCombat! diff --git a/app/templates/modal/error.jade b/app/templates/core/error.jade similarity index 100% rename from app/templates/modal/error.jade rename to app/templates/core/error.jade diff --git a/app/templates/loading_error.jade b/app/templates/core/loading-error.jade similarity index 100% rename from app/templates/loading_error.jade rename to app/templates/core/loading-error.jade diff --git a/app/templates/loading.jade b/app/templates/core/loading.jade similarity index 100% rename from app/templates/loading.jade rename to app/templates/core/loading.jade diff --git a/app/templates/modal/modal_base.jade b/app/templates/core/modal-base.jade similarity index 100% rename from app/templates/modal/modal_base.jade rename to app/templates/core/modal-base.jade diff --git a/app/templates/not_found.jade b/app/templates/core/not-found.jade similarity index 100% rename from app/templates/not_found.jade rename to app/templates/core/not-found.jade diff --git a/app/templates/editor/component/add-thang-components-modal.jade b/app/templates/editor/component/add-thang-components-modal.jade index ff6ef030c..fe2bbd40f 100644 --- a/app/templates/editor/component/add-thang-components-modal.jade +++ b/app/templates/editor/component/add-thang-components-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h1 Add Components diff --git a/app/templates/editor/fork-modal.jade b/app/templates/editor/fork-modal.jade index 2b4db3463..8da18b75c 100644 --- a/app/templates/editor/fork-modal.jade +++ b/app/templates/editor/fork-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="editor.fork_title") Fork New Version diff --git a/app/templates/editor/level/component/new.jade b/app/templates/editor/level/component/new.jade index 139ecb616..94aea8a77 100644 --- a/app/templates/editor/level/component/new.jade +++ b/app/templates/editor/level/component/new.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="editor.new_component_title") Create New Component diff --git a/app/templates/editor/level/modal/generate-terrain-modal.jade b/app/templates/editor/level/modal/generate-terrain-modal.jade index e97cd739f..a2d370e57 100644 --- a/app/templates/editor/level/modal/generate-terrain-modal.jade +++ b/app/templates/editor/level/modal/generate-terrain-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="editor.pick_a_terrain") Pick a Terrain diff --git a/app/templates/editor/level/modal/world-select-modal.jade b/app/templates/editor/level/modal/world-select-modal.jade index 0c48822c2..455c7c8bc 100644 --- a/app/templates/editor/level/modal/world-select-modal.jade +++ b/app/templates/editor/level/modal/world-select-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content diff --git a/app/templates/editor/level/system/add.jade b/app/templates/editor/level/system/add.jade index 8ed1ecbc6..ec50744ae 100644 --- a/app/templates/editor/level/system/add.jade +++ b/app/templates/editor/level/system/add.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="editor.add_system_title") Add Systems to Level diff --git a/app/templates/editor/level/system/new.jade b/app/templates/editor/level/system/new.jade index 7bdf9f762..84734462a 100644 --- a/app/templates/editor/level/system/new.jade +++ b/app/templates/editor/level/system/new.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="editor.create_system_title") Create New System diff --git a/app/templates/editor/patch_modal.jade b/app/templates/editor/patch_modal.jade index 50549331e..75c86a4dc 100644 --- a/app/templates/editor/patch_modal.jade +++ b/app/templates/editor/patch_modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content .modal-header-content diff --git a/app/templates/editor/thang/vector-icon-setup-modal.jade b/app/templates/editor/thang/vector-icon-setup-modal.jade index cdfcb8268..3a06831ca 100644 --- a/app/templates/editor/thang/vector-icon-setup-modal.jade +++ b/app/templates/editor/thang/vector-icon-setup-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3 Choose Container for Vector Icon diff --git a/app/templates/home.jade b/app/templates/home-view.jade similarity index 100% rename from app/templates/home.jade rename to app/templates/home-view.jade diff --git a/app/templates/modal/confirm.jade b/app/templates/modal/confirm.jade index f7d746de4..bd8cc708c 100644 --- a/app/templates/modal/confirm.jade +++ b/app/templates/modal/confirm.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3 #{confirmTitle} diff --git a/app/templates/modal/employer_signup_modal.jade b/app/templates/modal/employer_signup_modal.jade index 3b22f222f..9b01e3666 100644 --- a/app/templates/modal/employer_signup_modal.jade +++ b/app/templates/modal/employer_signup_modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content if userIsAnonymous || !userIsAuthorized diff --git a/app/templates/modal/job_profile_contact.jade b/app/templates/modal/job_profile_contact.jade index 412d3fca8..68d06f3c0 100644 --- a/app/templates/modal/job_profile_contact.jade +++ b/app/templates/modal/job_profile_contact.jade @@ -1,4 +1,4 @@ -extends /templates/modal/contact +extends /templates/core/contact block modal-header-content h3(data-i18n="contact.contact_candidate") Contact Candidate diff --git a/app/templates/modal/model.jade b/app/templates/modal/model-modal.jade similarity index 88% rename from app/templates/modal/model.jade rename to app/templates/modal/model-modal.jade index 404dfb571..f555ac343 100644 --- a/app/templates/modal/model.jade +++ b/app/templates/modal/model-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header diff --git a/app/templates/modal/new_model.jade b/app/templates/modal/new_model.jade index c904d1b96..d88e30568 100644 --- a/app/templates/modal/new_model.jade +++ b/app/templates/modal/new_model.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="#{currentNew}") Create New #{modelLabel} diff --git a/app/templates/modal/recover.jade b/app/templates/modal/recover.jade index 76c576f92..1d5930680 100644 --- a/app/templates/modal/recover.jade +++ b/app/templates/modal/recover.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="recover.recover_account_title") Recover Account diff --git a/app/templates/modal/revert.jade b/app/templates/modal/revert.jade index 28b111337..a92ee3676 100644 --- a/app/templates/modal/revert.jade +++ b/app/templates/modal/revert.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="editor.revert_models") Revert Models diff --git a/app/templates/modal/save_version.jade b/app/templates/modal/save_version.jade index 748c541a9..29058312b 100644 --- a/app/templates/modal/save_version.jade +++ b/app/templates/modal/save_version.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content if isPatch diff --git a/app/templates/modal/versions.jade b/app/templates/modal/versions.jade index 827230ad2..7c9f7cc5c 100755 --- a/app/templates/modal/versions.jade +++ b/app/templates/modal/versions.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content if dataList diff --git a/app/templates/modal/wizard_settings.jade b/app/templates/modal/wizard_settings.jade index 5d7d91a6b..b1ec00d05 100644 --- a/app/templates/modal/wizard_settings.jade +++ b/app/templates/modal/wizard_settings.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="wizard_settings.title2") Customize Your Character diff --git a/app/templates/play/ladder/play_modal.jade b/app/templates/play/ladder/play_modal.jade index 459d7ec9e..86631c841 100644 --- a/app/templates/play/ladder/play_modal.jade +++ b/app/templates/play/ladder/play_modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="ladder.choose_opponent") Choose an Opponent diff --git a/app/templates/play/level/modal/hero-victory-modal.jade b/app/templates/play/level/modal/hero-victory-modal.jade index 5302dc502..463b69077 100644 --- a/app/templates/play/level/modal/hero-victory-modal.jade +++ b/app/templates/play/level/modal/hero-victory-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content img(src="/images/pages/play/level/modal/victory_modal_blue_banner.png")#victory-banner img(src="/images/pages/play/level/modal/victory_word.png")#victory-header.out diff --git a/app/templates/play/level/modal/infinite_loop.jade b/app/templates/play/level/modal/infinite_loop.jade index b2128482b..47152af83 100644 --- a/app/templates/play/level/modal/infinite_loop.jade +++ b/app/templates/play/level/modal/infinite_loop.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="play_level.infinite_loop_title") Infinite Loop Detected diff --git a/app/templates/play/level/modal/keyboard_shortcuts.jade b/app/templates/play/level/modal/keyboard_shortcuts.jade index 961b595d1..605d5e2ac 100644 --- a/app/templates/play/level/modal/keyboard_shortcuts.jade +++ b/app/templates/play/level/modal/keyboard_shortcuts.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="keyboard_shortcuts.keyboard_shortcuts") Keyboard Shortcuts diff --git a/app/templates/play/level/modal/reload-level-modal.jade b/app/templates/play/level/modal/reload-level-modal.jade index 5992717e1..6dae685ff 100644 --- a/app/templates/play/level/modal/reload-level-modal.jade +++ b/app/templates/play/level/modal/reload-level-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="play_level.reload_title") Reload All Code? diff --git a/app/templates/play/level/modal/victory.jade b/app/templates/play/level/modal/victory.jade index ae8621fb5..be6a4ab51 100644 --- a/app/templates/play/level/modal/victory.jade +++ b/app/templates/play/level/modal/victory.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3 diff --git a/app/templates/main-play-view.jade b/app/templates/play/main-play-view.jade similarity index 100% rename from app/templates/main-play-view.jade rename to app/templates/play/main-play-view.jade diff --git a/app/templates/game-menu/game-menu-modal.jade b/app/templates/play/menu/game-menu-modal.jade similarity index 100% rename from app/templates/game-menu/game-menu-modal.jade rename to app/templates/play/menu/game-menu-modal.jade diff --git a/app/templates/game-menu/guide-view.jade b/app/templates/play/menu/guide-view.jade similarity index 100% rename from app/templates/game-menu/guide-view.jade rename to app/templates/play/menu/guide-view.jade diff --git a/app/templates/game-menu/inventory-modal.jade b/app/templates/play/menu/inventory-modal.jade similarity index 100% rename from app/templates/game-menu/inventory-modal.jade rename to app/templates/play/menu/inventory-modal.jade diff --git a/app/templates/game-menu/item-view.jade b/app/templates/play/menu/item-view.jade similarity index 100% rename from app/templates/game-menu/item-view.jade rename to app/templates/play/menu/item-view.jade diff --git a/app/templates/game-menu/multiplayer-view.jade b/app/templates/play/menu/multiplayer-view.jade similarity index 100% rename from app/templates/game-menu/multiplayer-view.jade rename to app/templates/play/menu/multiplayer-view.jade diff --git a/app/templates/game-menu/options-view.jade b/app/templates/play/menu/options-view.jade similarity index 100% rename from app/templates/game-menu/options-view.jade rename to app/templates/play/menu/options-view.jade diff --git a/app/templates/game-menu/save-load-view.jade b/app/templates/play/menu/save-load-view.jade similarity index 100% rename from app/templates/game-menu/save-load-view.jade rename to app/templates/play/menu/save-load-view.jade diff --git a/app/templates/play/modal/play-account-modal.jade b/app/templates/play/modal/play-account-modal.jade index 1c40e212e..24c1df7df 100644 --- a/app/templates/play/modal/play-account-modal.jade +++ b/app/templates/play/modal/play-account-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="play.account") Account diff --git a/app/templates/play/modal/play-achievements-modal.jade b/app/templates/play/modal/play-achievements-modal.jade index 71e593170..02774f574 100644 --- a/app/templates/play/modal/play-achievements-modal.jade +++ b/app/templates/play/modal/play-achievements-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="play.achievements") Achievements diff --git a/app/templates/play/modal/play-level-modal.jade b/app/templates/play/modal/play-level-modal.jade index dbcce9e80..22a19a8dd 100644 --- a/app/templates/play/modal/play-level-modal.jade +++ b/app/templates/play/modal/play-level-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h1#choose-hero-header.choose-hero-active.secret(data-i18n="choose_hero.choose_hero") Choose Your Hero diff --git a/app/templates/play/modal/play-settings-modal.jade b/app/templates/play/modal/play-settings-modal.jade index ee37a395d..7f2d4460d 100644 --- a/app/templates/play/modal/play-settings-modal.jade +++ b/app/templates/play/modal/play-settings-modal.jade @@ -1,4 +1,4 @@ -extends /templates/modal/modal_base +extends /templates/core/modal-base block modal-header-content h3(data-i18n="play.settings") Settings diff --git a/app/views/CommunityView.coffee b/app/views/CommunityView.coffee index b551c3b1a..7ad076a7a 100644 --- a/app/views/CommunityView.coffee +++ b/app/views/CommunityView.coffee @@ -1,5 +1,5 @@ RootView = require 'views/core/RootView' -template = require 'templates/community' +template = require 'templates/community-view' module.exports = class CommunityView extends RootView id: 'community-view' diff --git a/app/views/HomeView.coffee b/app/views/HomeView.coffee index c05a5fbfb..dfcd381b3 100644 --- a/app/views/HomeView.coffee +++ b/app/views/HomeView.coffee @@ -1,5 +1,5 @@ RootView = require 'views/core/RootView' -template = require 'templates/home' +template = require 'templates/home-view' module.exports = class HomeView extends RootView id: 'home-view' diff --git a/app/views/core/AchievementPopup.coffee b/app/views/core/AchievementPopup.coffee index fa7367af8..9cc75e34b 100644 --- a/app/views/core/AchievementPopup.coffee +++ b/app/views/core/AchievementPopup.coffee @@ -1,5 +1,5 @@ CocoView = require 'views/core/CocoView' -template = require 'templates/achievements/achievement-popup' +template = require 'templates/core/achievement-popup' User = require '../../models/User' Achievement = require '../../models/Achievement' diff --git a/app/views/core/CocoView.coffee b/app/views/core/CocoView.coffee index 2e51b8d48..1ee382e75 100644 --- a/app/views/core/CocoView.coffee +++ b/app/views/core/CocoView.coffee @@ -1,8 +1,8 @@ SuperModel = require 'models/SuperModel' utils = require 'core/utils' CocoClass = require 'core/CocoClass' -loadingScreenTemplate = require 'templates/loading' -loadingErrorTemplate = require 'templates/loading_error' +loadingScreenTemplate = require 'templates/core/loading' +loadingErrorTemplate = require 'templates/core/loading-error' lastToggleModalCall = 0 visibleModal = null diff --git a/app/views/core/ContactModal.coffee b/app/views/core/ContactModal.coffee index 84985434d..f74458a00 100644 --- a/app/views/core/ContactModal.coffee +++ b/app/views/core/ContactModal.coffee @@ -1,5 +1,5 @@ ModalView = require 'views/core/ModalView' -template = require 'templates/modal/contact' +template = require 'templates/core/contact' forms = require 'core/forms' {sendContactMessage} = require 'core/contact' diff --git a/app/views/core/DiplomatSuggestionModal.coffee b/app/views/core/DiplomatSuggestionModal.coffee index d16de5d60..8a271ba44 100644 --- a/app/views/core/DiplomatSuggestionModal.coffee +++ b/app/views/core/DiplomatSuggestionModal.coffee @@ -1,5 +1,5 @@ ModalView = require 'views/core/ModalView' -template = require 'templates/modal/diplomat_suggestion' +template = require 'templates/core/diplomat-suggestion' {me} = require 'core/auth' forms = require 'core/forms' diff --git a/app/views/core/ModalView.coffee b/app/views/core/ModalView.coffee index e3290c137..0a5b8afc3 100644 --- a/app/views/core/ModalView.coffee +++ b/app/views/core/ModalView.coffee @@ -7,7 +7,7 @@ module.exports = class ModalView extends CocoView modalWidthPercent: null plain: false instant: false - template: require 'templates/modal/modal_base' + template: require 'templates/core/modal-base' events: 'click a': 'toggleModal' diff --git a/app/views/core/NotFoundView.coffee b/app/views/core/NotFoundView.coffee index 9a43c5399..4db47ebff 100644 --- a/app/views/core/NotFoundView.coffee +++ b/app/views/core/NotFoundView.coffee @@ -1,5 +1,5 @@ RootView = require 'views/core/RootView' -template = require 'templates/not_found' +template = require 'templates/core/not-found' module.exports = class NotFoundView extends RootView id: 'not-found-view' diff --git a/app/views/modal/ModelModal.coffee b/app/views/modal/ModelModal.coffee index 315d2db0c..ab3cc02d3 100644 --- a/app/views/modal/ModelModal.coffee +++ b/app/views/modal/ModelModal.coffee @@ -1,5 +1,5 @@ ModalView = require 'views/core/ModalView' -template = require 'templates/modal/model' +template = require 'templates/modal/model-modal' module.exports = class ModelModal extends ModalView id: 'model-modal' diff --git a/app/views/play/MainPlayView.coffee b/app/views/play/MainPlayView.coffee index 65c8aa32d..65c4b16bd 100644 --- a/app/views/play/MainPlayView.coffee +++ b/app/views/play/MainPlayView.coffee @@ -1,5 +1,5 @@ RootView = require 'views/core/RootView' -template = require 'templates/main-play-view' +template = require 'templates/play/main-play-view' LevelSession = require 'models/LevelSession' CocoCollection = require 'collections/CocoCollection' diff --git a/app/views/play/level/ControlBarView.coffee b/app/views/play/level/ControlBarView.coffee index 23600b61f..ac01f96db 100644 --- a/app/views/play/level/ControlBarView.coffee +++ b/app/views/play/level/ControlBarView.coffee @@ -2,11 +2,11 @@ CocoView = require 'views/core/CocoView' template = require 'templates/play/level/control_bar' {me} = require 'core/auth' -GameMenuModal = require 'views/game-menu/GameMenuModal' +GameMenuModal = require 'views/play/menu/GameMenuModal' RealTimeModel = require 'models/RealTimeModel' RealTimeCollection = require 'collections/RealTimeCollection' LevelSetupManager = require 'lib/LevelSetupManager' -GameMenuModal = require 'views/game-menu/GameMenuModal' +GameMenuModal = require 'views/play/menu/GameMenuModal' CampaignOptions = require 'lib/CampaignOptions' module.exports = class ControlBarView extends CocoView diff --git a/app/views/play/level/LevelHUDView.coffee b/app/views/play/level/LevelHUDView.coffee index 88479f9e7..f7ad5322c 100644 --- a/app/views/play/level/LevelHUDView.coffee +++ b/app/views/play/level/LevelHUDView.coffee @@ -2,6 +2,7 @@ CocoView = require 'views/core/CocoView' template = require 'templates/play/level/hud' prop_template = require 'templates/play/level/hud_prop' LevelOptions = require 'lib/LevelOptions' +utils = require 'core/utils' module.exports = class LevelHUDView extends CocoView id: 'thang-hud' @@ -104,7 +105,7 @@ module.exports = class LevelHUDView extends CocoView name = {knight: 'Tharin', captain: 'Anya', librarian: 'Hushbaum', sorcerer: 'Pender', 'potion-master': 'Omarn', samurai: 'Hattori', ninja: 'Amara'}[@thang.type] ? 'Hero' else name = if @thang.type then "#{@thang.id} - #{@thang.type}" else @thang.id - @$el.find('.thang-name').text name + utils.replaceText @$el.find('.thang-name'), name props = @$el.find('.thang-props') props.find('.prop').remove() #propNames = _.without @thang.hudProperties ? [], 'action' @@ -145,7 +146,7 @@ module.exports = class LevelHUDView extends CocoView labelText = prop + ': ' + @formatValue(prop, val) + ' / ' + @formatValue(prop, max) if regen labelText += ' (+' + @formatValue(prop, regen) + '/s)' - pel.find('.bar-prop-value').text(Math.round(max)) if max + utils.replaceText pel.find('.bar-prop-value'), Math.round(val) else s = @formatValue(prop, val) labelText = "#{prop}: #{s}" @@ -153,7 +154,7 @@ module.exports = class LevelHUDView extends CocoView cooldown = @thang.actions.attack.cooldown dps = @thang.attackDamage / cooldown labelText += " / #{cooldown.toFixed(2)}s (DPS: #{dps.toFixed(2)})" - pel.find('.prop-value').text s + utils.replaceText pel.find('.prop-value'), s pel.attr 'title', labelText pel diff --git a/app/views/game-menu/GameMenuModal.coffee b/app/views/play/menu/GameMenuModal.coffee similarity index 90% rename from app/views/game-menu/GameMenuModal.coffee rename to app/views/play/menu/GameMenuModal.coffee index 602f6c554..8b9ed7a35 100644 --- a/app/views/game-menu/GameMenuModal.coffee +++ b/app/views/play/menu/GameMenuModal.coffee @@ -1,10 +1,10 @@ ModalView = require 'views/core/ModalView' -template = require 'templates/game-menu/game-menu-modal' +template = require 'templates/play/menu/game-menu-modal' submenuViews = [ - require 'views/game-menu/SaveLoadView' - require 'views/game-menu/OptionsView' - require 'views/game-menu/GuideView' - require 'views/game-menu/MultiplayerView' + require 'views/play/menu/SaveLoadView' + require 'views/play/menu/OptionsView' + require 'views/play/menu/GuideView' + require 'views/play/menu/MultiplayerView' ] module.exports = class GameMenuModal extends ModalView diff --git a/app/views/game-menu/GuideView.coffee b/app/views/play/menu/GuideView.coffee similarity index 97% rename from app/views/game-menu/GuideView.coffee rename to app/views/play/menu/GuideView.coffee index cca8585cb..973b31ba3 100644 --- a/app/views/game-menu/GuideView.coffee +++ b/app/views/play/menu/GuideView.coffee @@ -1,5 +1,5 @@ CocoView = require 'views/core/CocoView' -template = require 'templates/game-menu/guide-view' +template = require 'templates/play/menu/guide-view' Article = require 'models/Article' utils = require 'core/utils' diff --git a/app/views/game-menu/InventoryModal.coffee b/app/views/play/menu/InventoryModal.coffee similarity index 99% rename from app/views/game-menu/InventoryModal.coffee rename to app/views/play/menu/InventoryModal.coffee index b4dbdd3b6..db6f9a198 100644 --- a/app/views/game-menu/InventoryModal.coffee +++ b/app/views/play/menu/InventoryModal.coffee @@ -1,5 +1,5 @@ ModalView = require 'views/core/ModalView' -template = require 'templates/game-menu/inventory-modal' +template = require 'templates/play/menu/inventory-modal' buyGemsPromptTemplate = require 'templates/play/modal/buy-gems-prompt' {me} = require 'core/auth' ThangType = require 'models/ThangType' diff --git a/app/views/game-menu/ItemView.coffee b/app/views/play/menu/ItemView.coffee similarity index 91% rename from app/views/game-menu/ItemView.coffee rename to app/views/play/menu/ItemView.coffee index 17f8c5a52..f3e427d3b 100644 --- a/app/views/game-menu/ItemView.coffee +++ b/app/views/play/menu/ItemView.coffee @@ -1,5 +1,5 @@ CocoView = require 'views/core/CocoView' -template = require 'templates/game-menu/item-view' +template = require 'templates/play/menu/item-view' module.exports = class ItemView extends CocoView className: 'item-view' diff --git a/app/views/game-menu/MultiplayerView.coffee b/app/views/play/menu/MultiplayerView.coffee similarity index 99% rename from app/views/game-menu/MultiplayerView.coffee rename to app/views/play/menu/MultiplayerView.coffee index 0f80d802d..64c15c3e7 100644 --- a/app/views/game-menu/MultiplayerView.coffee +++ b/app/views/play/menu/MultiplayerView.coffee @@ -1,5 +1,5 @@ CocoView = require 'views/core/CocoView' -template = require 'templates/game-menu/multiplayer-view' +template = require 'templates/play/menu/multiplayer-view' {me} = require 'core/auth' ThangType = require 'models/ThangType' LadderSubmissionView = require 'views/play/common/LadderSubmissionView' diff --git a/app/views/game-menu/OptionsView.coffee b/app/views/play/menu/OptionsView.coffee similarity index 98% rename from app/views/game-menu/OptionsView.coffee rename to app/views/play/menu/OptionsView.coffee index e0d83ec2f..8b76b4a1e 100644 --- a/app/views/game-menu/OptionsView.coffee +++ b/app/views/play/menu/OptionsView.coffee @@ -1,5 +1,5 @@ CocoView = require 'views/core/CocoView' -template = require 'templates/game-menu/options-view' +template = require 'templates/play/menu/options-view' {me} = require 'core/auth' ThangType = require 'models/ThangType' User = require 'models/User' diff --git a/app/views/game-menu/SaveLoadView.coffee b/app/views/play/menu/SaveLoadView.coffee similarity index 91% rename from app/views/game-menu/SaveLoadView.coffee rename to app/views/play/menu/SaveLoadView.coffee index 7e94b4b9d..f396db5b9 100644 --- a/app/views/game-menu/SaveLoadView.coffee +++ b/app/views/play/menu/SaveLoadView.coffee @@ -1,5 +1,5 @@ CocoView = require 'views/core/CocoView' -template = require 'templates/game-menu/save-load-view' +template = require 'templates/play/menu/save-load-view' {me} = require 'core/auth' ThangType = require 'models/ThangType' diff --git a/bower.json b/bower.json index e5fb7c3de..5a2fd714b 100644 --- a/bower.json +++ b/bower.json @@ -35,7 +35,6 @@ "aether": "~0.2.39", "underscore.string": "~2.3.3", "firebase": "~1.0.2", - "catiline": "~2.9.3", "d3": "~3.4.4", "jsondiffpatch": "0.1.8", "nanoscroller": "~0.8.0", diff --git a/config.coffee b/config.coffee index e83c30899..b5d6145d4 100644 --- a/config.coffee +++ b/config.coffee @@ -72,7 +72,6 @@ exports.config = #- Wads. Groups of modules by folder which are loaded as a group when needed. 'javascripts/app/lib.js': regJoin('^app/lib') 'javascripts/app/views/play.js': regJoin('^app/views/play') - 'javascripts/app/views/game-menu.js': regJoin('^app/views/game-menu') 'javascripts/app/views/editor.js': regJoin('^app/views/editor') #- world.js, used by the worker to generate the world in game @@ -140,17 +139,7 @@ exports.config = templates: defaultExtension: 'jade' joinTo: - 'javascripts/app.js': [ - regJoin('^app/templates/core') - 'app/templates/modal/error.jade' - 'app/templates/not_found.jade' - 'app/templates/achievements/achievement-popup.jade' - 'app/templates/loading.jade' - 'app/templates/loading_error.jade' - 'app/templates/modal/contact.jade' - 'app/templates/modal/modal_base.jade' - 'app/templates/modal/diplomat_suggestion.jade' - ] + 'javascripts/app.js': regJoin('^app/templates/core') 'javascripts/app/views/play.js': regJoin('^app/templates/play') 'javascripts/app/views/game-menu.js': regJoin('^app/templates/game-menu') 'javascripts/app/views/editor.js': regJoin('^app/templates/editor') @@ -195,8 +184,20 @@ for file in coffeeFiles inputFile = file.replace('./app', 'app') outputFile = file.replace('.coffee', '.js').replace('./app', 'javascripts/app') exports.config.files.javascripts.joinTo[outputFile] = inputFile - + +numBundles = 0 + for file in jadeFiles inputFile = file.replace('./app', 'app') outputFile = file.replace('.jade', '.js').replace('./app', 'javascripts/app') - exports.config.files.templates.joinTo[outputFile] = inputFile + exports.config.files.templates.joinTo[outputFile] = inputFile + + #- If a view template name matches its view, bundle it in there. + templateFileName = outputFile.match(/[^/]+$/)[0] + viewFileName = _.str.capitalize(_.str.camelize(templateFileName)) + possibleViewFilePath = outputFile.replace(templateFileName, viewFileName).replace('/templates/', '/views/') + if exports.config.files.javascripts.joinTo[possibleViewFilePath] + exports.config.files.templates.joinTo[possibleViewFilePath] = inputFile + numBundles += 1 + +console.log 'Bundled', numBundles, 'templates with their views.' \ No newline at end of file diff --git a/server/commons/Handler.coffee b/server/commons/Handler.coffee index 62dced867..92227d6e1 100644 --- a/server/commons/Handler.coffee +++ b/server/commons/Handler.coffee @@ -298,6 +298,8 @@ module.exports = class Handler getLatestVersion: (req, res, original, version) -> # can get latest overall version, latest of a major version, or a specific version + return @sendBadInputError(res, 'Invalid MongoDB id: '+original) if not Handler.isID(original) + query = { 'original': mongoose.Types.ObjectId(original) } if version? version = version.split('.') diff --git a/server_setup.coffee b/server_setup.coffee index a3f972caa..ad056068b 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -42,7 +42,10 @@ developmentLogging = (tokens, req, res) -> setupErrorMiddleware = (app) -> app.use (err, req, res, next) -> if err - res.status(500).send(error: "Something went wrong!") + if err.status and 400 <= err.status < 500 + res.status(err.status).send("Error #{err.status}") + return + res.status(err.status ? 500).send(error: "Something went wrong!") message = "Express error: #{req.method} #{req.path}: #{err.message}" log.error "#{message}, stack: #{err.stack}" hipchat.sendTowerHipChatMessage(message)