diff --git a/.gitignore b/.gitignore index 1cb23ccadb..002780bbdc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ config.json npm-debug.log lib website/public/bower_components +website/public/new-stuff.html website/build newrelic_agent.log .bower-tmp @@ -22,4 +23,8 @@ test/*.js test/*.map website/public/docs *.sublime-workspace +coverage coverage.html +common/dist/scripts/habitrpg-shared.js + +test/spec/translations.js diff --git a/.jshintrc b/.jshintrc index d1064e9ba9..bb52bcabd2 100644 --- a/.jshintrc +++ b/.jshintrc @@ -5,6 +5,7 @@ "browser": true, "node": true, + "mocha": true, "asi": true, "boss": true, diff --git a/.travis.yml b/.travis.yml index 3f33964032..dcd028fd9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,15 @@ language: node_js node_js: - '0.10' - - mongodb +before_install: + - "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10" + - "echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list" + - "sudo apt-get update" + - "sudo apt-get install mongodb-org-server" before_script: - 'npm install -g grunt-cli mocha' - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - cp config.json.example config.json + - "until nc -z localhost 27017; do echo Waiting for MongoDB; sleep 1; done" + - "export DISPLAY=:99" +after_script: + - "./node_modules/.bin/lcov-result-merger 'coverage/**/*.info' | ./node_modules/coveralls/bin/coveralls.js" diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index bacc54d3f8..0000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,282 +0,0 @@ -My app - Changelog -# (2014-02-15) - - -## Documentation - -- **rebirth:** Bullet point about repurchase of limited ed gear after Rebirth - ([d3f4a561](watch/commits/d3f4a561fdf137e5d8f406bae03be4fef1caff22)) - - -## Bug Fixes - -- **#2003:** healer gear not showing - ([949cd97b](watch/commits/949cd97b91b42e9450eba559bbfea17e239ab100)) -- **#2375:** merge in @SabreCat's stats.jade changes "More elegant show/hide setup for attribute bonuses" - ([518f200a](watch/commits/518f200a8fc7373b44ed7d7b5f016d921b0746bd)) -- **allocateNow:** Send empty object to user.ops per @colegleason suggestion - ([f6e12fa2](watch/commits/f6e12fa25e4366622db3e6f1b6ab03e848b49e10)) -- **batch-update:** send errors to client if batch-update found an error, crash pid. - ([f9679629](watch/commits/f967962996be69a5335454610af76d10e1db08b8)) -- **beastmaster:** fixes #2557, adds opacity to previously-owned pets after they're mounted. You can earn them back again - ([5caaff1c](watch/commits/5caaff1cea1a68fe572e7ddf4aac50248b13df5d)) -- **bosses:** don't reset progress.up when starting a new quest. We want to be able to carry over damage from the same day a boss battle begins, even if the dailies were completed before battle-start. Fixes #2168 - ([4efd0f5e](watch/commits/4efd0f5ed8708f2491dd483f93e3d7a268a6337d)) -- **bower:** updated jquery directory - ([191b789d](watch/commits/191b789d760a7bdc7d1b53727f6127b677c78c94)) -- **bs3:** - - fix to MemberModalCtrl parameter - ([ebd1df93](watch/commits/ebd1df932e28263e5cc01e8a35f545ab26f1e8bd)) - - port pet feeding bar - ([5db96ebc](watch/commits/5db96ebca2fbd5b64f49af03a5137ea80f6b1673)) -- **buffs:** Move help bubble to left of special buffs - ([4f911a68](watch/commits/4f911a68d805742e6744383948eea6f224f2b0ea)) -- **challenges:** - - better handling of deleted challenges. If !chal, break the task.challenge. Move the function into userController#score so we have access to next, etc. fixes #1883 - ([33b326b5](watch/commits/33b326b59685ea6e50f9950094d009460ce80094)) - - challenge csv export now has proper filename - ([36f21196](watch/commits/36f21196f466260b7cd52b283c50b9e16943f668), - [#2689](watch/issues/2689)) -- **classes:** - - misc fixes - ([d2121a85](watch/commits/d2121a858716cb5a532a53ee9c5a1adaa74a7f69)) - - misc class fixes (not @snicker, ng-if on item store since we dynamically swap it sometimes) - ([478be611](watch/commits/478be6111337cd200374f7f31b959725c6a0b945)) -- **css:** - - temp fix for bailey height - ([c8faffcc](watch/commits/c8faffcc7289090990c3a17ab8c07a00069f5ce4)) - - menu and gems wallet margin - ([975b5165](watch/commits/975b5165730477310aa64bac27ddc07a34ea6c1d)) - - lighter columns title - ([a22e2814](watch/commits/a22e28143f74302c8340c3d33b01af9714875523)) - - better food tray - ([1c41c4dd](watch/commits/1c41c4ddb9a5b04297a371bc4d6aba013ce33f17)) -- **errors:** - - `return next(err)` when experiencing errors, instead of res.json(500,{err:err}). Let the top-level error handler handle this (needed for upcoming versionerror discarding) - ([bf5e9016](watch/commits/bf5e9016a4cb7889b3a9e39b90eb35cb8f7f9ec8)) - - handle if err.message == undefined, send err - ([b42dacf2](watch/commits/b42dacf2035d62453b585cfcf453829a423b59de)) -- **event-tracking:** - - typo - ([ff9d4b88](watch/commits/ff9d4b886ef7a98da0514975441a8bb845496c31)) - - stripe sub, not pp - ([0c99976b](watch/commits/0c99976bf5a3c7f04f031d62a8b07c862c85a0a9)) -- **find_uniq_user:** fix - ([ecbe780e](watch/commits/ecbe780e70549b1470504efe052f238c89a9db14)) -- **footer:** ensure window.env is accessible from static pages, so we can get deferred scripts on frontpage (esp google analytics) - ([67ee011a](watch/commits/67ee011aa35969db93e2d7dc1cd1e1f587f146de)) -- **groups:** - - pass missing next into Like function - ([afee0968](watch/commits/afee0968f8f6923847e186d3e11b9745ced9606e)) - - send error if +1 errored - ([5b6c4427](watch/commits/5b6c4427b504b6143f24bfee314f562b9803c5a4)) -- **hall:** let's try $gt instead of $ne:null, the query is still slow - ([a72b0131](watch/commits/a72b013131cfc7fa5d3affdbfe59b5b3cb15ae89)) -- **i18n:** do not save user language for now - ([094a4be0](watch/commits/094a4be0015f0f0deaaf94a0734193eb40a8beae)) -- **misc:** - - some styles & translations - ([8f19f225](watch/commits/8f19f225f104960b3cf27e229a5571e014be697c)) - - isStaticPage and debug buttons - ([19139f56](watch/commits/19139f562b8e68ed43f4cab748920f1e0634e86e)) -- **missing-gems:** remove ad-removal from script, since ads are part of subscription - ([e1240dde](watch/commits/e1240dde1d3dcaca4235fad384fea5c07a3706bf)) -- **mongoose:** typo - ([2786b362](watch/commits/2786b362067efdd245c3efa3a4891021fcfaab2d)) -- **mounts:** - - fix pets & mounts css to position the user based on pet/mount equip - ([37340d23](watch/commits/37340d23180da02d3742dc9be40a5fb780ecb13b)) - - Move avatar upward when mounted regardless of pet - ([bc1adeb1](watch/commits/bc1adeb1277103a5ca1f756e175ed68bbe837a2f)) -- **nodemon:** - - Add another ignore for weirdsauce Windoze dev environments - ([3fda08c3](watch/commits/3fda08c366793c8fbcbf701a9594ae3b2fd8bbea)) - - ignore CHANGELOG.md on watch - ([d6c55952](watch/commits/d6c55952da8b49f36e9d8e4570d80931d081343d)) -- **party:** Round boss health up instead of to nearest integer - ([626da568](watch/commits/626da5681f5ea95700f8ddf40587c7184926971c), - [#2504](watch/issues/2504)) -- **paypal:** fixes #2492, remove environment check for now, only have production-mode option. revisit - ([1dc68112](watch/commits/1dc68112d131e4ebdec32ddff938eb6311d6565f)) -- **performance:** cache spritesmith image, fix #2633 - ([f03d7d7d](watch/commits/f03d7d7dde4f8cb39babd2b982d77e7f88f349b7)) -- **pets:** add questPets to UserSchema.items.mounts too fixes #2814 - ([42766125](watch/commits/42766125d5c8870f25c3a0a001473f700b8f6cc1)) -- **profile:** fix bug where empty profile displayed on username click - ([0579c432](watch/commits/0579c432489c4a038e8c9f95ea3b285f5abc146f), - [#2465](watch/issues/2465)) -- **quests:** - - quests with a level cap cannot be bought before that level. - ([dab9ddbd](watch/commits/dab9ddbda27f5e10e4545fea703deebfe2dd9975), - [#2707](watch/issues/2707)) - - bug fix to multi-drop - ([f478d10c](watch/commits/f478d10c20f816cd104b3f0da814c189957f45f5)) - - list multiple rewards in dialog - ([e48c7277](watch/commits/e48c7277f8256cf827790aece51e897fe0439374)) -- **readme:** remove text about translations wip - ([f2bb1fd2](watch/commits/f2bb1fd26e44a9eb0ba325776bf335e021beeece)) -- **settings:** - - remove unnecessary code - ([5f0cf657](watch/commits/5f0cf6575c0dc4cfc041956e3dc27898d8b4242d)) - - reintroduce space between captions and help bubbles stripped during localization - ([5ddf09fe](watch/commits/5ddf09fe13c7f8d844c8c47be0fb8f8b2fd1df33)) -- **spells:** - - temp workaround for spell & task being undefined. #2649 #2640 - ([241d0414](watch/commits/241d04140f5db77929d9f597d232f55843bb0f5d)) - - more $rootScope spell-casting bug fixes - ([47bd6dcb](watch/commits/47bd6dcb79778d90d6f3ddeb003c3d8e45433333)) - - add some spells tests, don't send up body to spell paths - ([e0646bb9](watch/commits/e0646bb98d44b6874b5259107c9be5fa34c58933)) - - some $rootScope.applying action fixes so cast-ending is immediate instead of waiting on response. Also, slim down party population to the essentials to avoid RequestEntityTooLarge - ([c6f7ab8a](watch/commits/c6f7ab8a5c6f4e382208a928b90ba5f4eba9cd37)) - - to cancel spell-casting - ([a1df41ad](watch/commits/a1df41ad8165cd9eb6d2d5d59c7fe404edde716c)) -- **stable:** show hatchable combo when petOwned>0 (fyi @deilann) - ([51bff238](watch/commits/51bff23885ca0080e7e71ff752daa0950ae923ae)) -- **stats:** Better layout for attribute point allocation - ([d782fc6b](watch/commits/d782fc6b6a3cd7e90d327c93a5764626b2990c74)) -- **swagger:** fix jade script warning in swagger - ([2e2fcfcf](watch/commits/2e2fcfcf464fbae21bff9e1be1ca915f071b976b)) -- **tests:** - - include select2 in test manifest - ([38b4cea7](watch/commits/38b4cea73299f51c4db7f6b2eb12533d219745f8)) - - don't use cluster in tests, else we get "connection refused" - ([7a479098](watch/commits/7a479098dc6535654e322c737d80813790967941)) -- **todos:** - - add migration for dateCreated & dateCompleted #2478 - ([4cc39f16](watch/commits/4cc39f16a13f5fb9f0e3ddde7d274c0f224f4a0e)) - - add dateCompleted to todos so they're archived 3 days after completion, not 3 days after creation. Fixes #2478 - ([b1afc177](watch/commits/b1afc177aa4bfc4cbd9b847e40431db91666d9c3)) -- **toolbar:** - - Tweak Settings drop-down - ([e241429c](watch/commits/e241429cc3d2eca18d2f5a9726f6caa6270a1b02)) - - Tweak icon popovers - ([4454204f](watch/commits/4454204f47f80e64119f7896bf246259173d115b)) - - tweaks - ([5501d57e](watch/commits/5501d57e107c0bc7085847b0c808f027360fa405)) -- **translation:** Fix #2585. - ([06200acc](watch/commits/06200accada462c3234ab407cfb0f6b684e5effe)) -- **translations:** - - fix #2564 and similar ones - ([42740902](watch/commits/42740902055a3807532028a5dfb39eff905c104f)) - - add env.t to rootScope - ([13131087](watch/commits/13131087ff9563d2d174b2c978102f0dc2b87387)) - - remove translations for privacy & terms - ([a9095f34](watch/commits/a9095f346479336be13b2bf341666b908fa30b3d)) - - merge @luveluen pull request, fix some syntax - ([a6c67f17](watch/commits/a6c67f17815558f19895b8f67d29c40c14689f09)) - - @lefnire now everything is ok - ([52decb7e](watch/commits/52decb7edeefb4755ea832b0cf63eaeea5e93259)) - - correct some variables - ([fba73953](watch/commits/fba739535bc1b630d73eb469448e9c3706043efd)) - - revert some views - ([d000c706](watch/commits/d000c70679ae0e13d9bec749295e42cc8e299c95)) -- **user:** - - make sure next is passed to all routes, and is available in err-back of batch updates - ([0c21f54c](watch/commits/0c21f54c67b52b07c417fd8216c6b04bce59d0ab)) - - if need to upgrade site, send 501, not 400 - ([ab86ba11](watch/commits/ab86ba11bdb3379a8d8fa1814879640d61c57227)) - - PUT user retricted path errors are 401, not 500 - ([0aec4caa](watch/commits/0aec4caa785c3b12e15f1c2e19c5b67b20d1a6e1)) -- **winston:** typo - ([83b3739f](watch/commits/83b3739f4671a08466e057242f936140d5c739ef)) - - -## Features - -- **administrators:** start adding features page for admin accounts - ([f7f4a0c1](watch/commits/f7f4a0c166558ba7e5461732f7bb6d7bcac25f88)) -- **attributes:** Add backfill button in flat and classbased allocation modes - ([76a7ab5b](watch/commits/76a7ab5bcce2d486dab3f447f0659ba870d1ff7e)) -- **bailey:** notif about STWC updates + scroll-purchase deadlines (@colegleason) - ([90176444](watch/commits/90176444e9c7a318040829e8b71d1493b5d58e9e)) -- **bug-crushing:** add the critical hammer of bug-crushing - ([00af5f7d](watch/commits/00af5f7d0258b0f7dddef8ede40bd825b057748a)) -- **challenges:** - - add angular-ui-select2 for simpler find/select challenge winner. - ([9fa45217](watch/commits/9fa452173989889c48ed696a45cf4a1dc16294a4)) - - add button for csv export - ([ae0d758d](watch/commits/ae0d758d8fc751219a693fee7f3e3ebcfbd67590)) - - add csv export for challenge progress. WIP, will refine this over time - but we need it something like this for the STWC come 1/31. - ([16a602f9](watch/commits/16a602f94c3b7c99d49e42b47b4835b65a243690)) - - markdown in challenge-descriptions - ([41233c7b](watch/commits/41233c7b167905eeccfdff5589789e002ec23f97)) -- **cheating:** prevent +habit spamming with a 10s timer - ([ad4ca665](watch/commits/ad4ca6655a3bdd870bb08173530372f81fdc9102)) -- **event-tracking:** - - better page-view tracking via ui-router - ([b093717b](watch/commits/b093717b8d54b61e5d4b44b0d56a1f43308f078c)) - - track registration count - ([72b6c9bc](watch/commits/72b6c9bc9189275909804f9ecab18e9fe1f69d27)) - - pass ga to server user.ops - ([9217b517](watch/commits/9217b5174ab9ab4754269263b214f6bfe45d4f1d)) - - track ecommerce events - ([d89fb17b](watch/commits/d89fb17b03b2e2c0fb1da77fb13cc660a5b6c9d1)) - - add server-side GA tracking for ecommerce events - ([f7b4a04a](watch/commits/f7b4a04a590ade26871abc726ade2c666176488e)) - - start adding some client-side GA event-tracking - ([ffb42906](watch/commits/ffb42906e1d7c6bd8f01e715d98d96426bc6d0de)) -- **groups:** add group chat notifications - ([ce82be63](watch/commits/ce82be637d1d707e899aeee5f315da69367fa367)) -- **habitBirthday:** add habitrpg birthday event. includes cakes for all pets, absurd party robes, npc swap, badge, etc. @lemoness - ([aff885c0](watch/commits/aff885c05c03bd70beeb0db8d68922671fc46309)) -- **homepage:** - - start cleaning up homepage, add navbar for play button & upcoming links - ([0ddaae4d](watch/commits/0ddaae4d7525277e696a57d20234e49cd6fd1cbc)) - - use .marketing for centering, add playbutton as static in footer. This is pretty ugly (http://gyazo.com/215e20729569689ab48cf56c71c1fe28), let's iterate / prettify. @deilann - ([47bcaf83](watch/commits/47bcaf83e760dbb266ae7ff2f7299c2a1cdf3712)) -- **marketing:** - - more copy for mobile - ([cbb44847](watch/commits/cbb448478edfd0003c43d20ed216bab20d25dadd)) - - start fleshing out the about page with images, content, etc. Create separate videos page - ([cb079977](watch/commits/cb079977e6f35f9308ab28158373dd3e1de9f798)) - - add video tuts on "learn more" page until we have some copy - ([5028707c](watch/commits/5028707c7b174b5e050c7c1662155e781a6b415b)) - - some frontpage updates, a screenshot, & "contact us" button mods - ([a582a054](watch/commits/a582a0546d680d36a21c507deff725a6c38fdb28)) -- **premium:** - - subscriber mystery item (doesn't yet do anything) - ([d0342628](watch/commits/d0342628340ce7dce95fa20177ccbcfe1ebf93e6)) - - backport server code for premium subs (it's just ccard handling & uer model stuff) - ([3660f1a8](watch/commits/3660f1a85c1447de118f334a145d0d7698b93981)) - - updates to group plans info page - ([66f95cdd](watch/commits/66f95cdd4cfb698fddc765a77b66d29e31eb1361)) - - backport client-side premium code to public repo, it's client-side anyway (@colegleason @paglias) - ([2e18f0eb](watch/commits/2e18f0eb82f5efc77544d33d1db3fbb9cc583124)) -- **quests:** - - add flags.levelDrops for dropping items at certain levels - ([78315d82](watch/commits/78315d828ba9a1033526b9a72b7c385281e6ad0a)) - - allow dropping scrolls in quests - ([54064deb](watch/commits/54064debf3c95390b5507acd826f9db3339b9f09)) - - allow html in quest notes - ([800231cf](watch/commits/800231cf6481351032d4e5143edd54f5e7e3a179)) - - add level requirement for quests - ([9e69d795](watch/commits/9e69d7959f174955f44429a94f22ce40fc5f7861)) - - add canBuy so we can exclude certain items from the market (if you can only find them on quest-drop, etc). This isn't the prettiest, change? - ([f16654d2](watch/commits/f16654d2354dc86cc7c52e1cf0562f850cf203be)) - - allow quests to drop multiple items - ([d9e5725e](watch/commits/d9e5725ee13f7e9ad329fc548537d5265cf483ca)) -- **rainbow-hair:** add rainbow hair colors - ([82d9233d](watch/commits/82d9233d99167d6704c878884dcc49a55cc7d884)) -- **restore:** add restore-gp back in. Parly to end the winter event, partly due to the convo at #2681 regarding subscriptions. Fixes #2681 - ([179316e1](watch/commits/179316e10fa7597b08573d94721861baa3dbbb1c)) -- **toolbar:** - - try with icons instead of text, test against prod / beta & get a vote. - ([7456f00d](watch/commits/7456f00dc6122ad293652b7a32fb4ce671f75241)) - - add toolbar featuring navigation, gems / subs, bailey, & chat / invite notifications - ([f72cb213](watch/commits/f72cb21300c078b439b3334bfa3e205ba04dc949)) -- **tracking:** gems > toolbar separately from wallet - ([f6abfc67](watch/commits/f6abfc67b31808c0e2d325c235747260855338c9)) -- **valentine:** valentine event - ([fd6eb872](watch/commits/fd6eb8724eae38d02849ffccb09f1f9c7d8e490d)) -- **winter:** - - remove purchasable winter hair colors, keep available if they purchased during event - ([f8796e90](watch/commits/f8796e9028d4f4cd2b5c5ede1734d2876d174dc9)) - - remove winter scrolls & snowballs - ([52f8f0d5](watch/commits/52f8f0d5b0fdf4271fcb5f7d497ad3bf544c24e8)) - - -## Docs - -- **rebirth:** Bullet point about repurchase of limited ed gear after Rebirth - diff --git a/Gruntfile.js b/Gruntfile.js index 2fe125c003..58ca8f524b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,7 +13,7 @@ module.exports = function(grunt) { // totalDims.width += dims.width; // totalDims.height += dims.height; // }) - var COUNT = 6;//Math.ceil( (totalDims.width * totalDims.height) / (1024*1024*3) ); + var COUNT = 7;//Math.ceil( (totalDims.width * totalDims.height) / (1024*1024*3) ); //console.log({totalDims:totalDims,COUNT:COUNT}); var sprite = {}; @@ -31,7 +31,7 @@ module.exports = function(grunt) { // For hair, skins, beards, etc. we want to output a '.customize-options.WHATEVER' class, which works as a // 60x60 image pointing at the proper part of the 90x90 sprite. // We set up the custom info here, and the template makes use of it. - if (sprite.name.match(/hair|skin|beard|mustach|shirt|flower/) || sprite.name=='head_0') { + if (sprite.name.match(/hair|skin|beard|mustach|shirt|flower|^headAccessory_special_\w+Ears/) || sprite.name=='head_0') { sprite.custom = { px: { offset_x: "-" + (sprite.x + 25) + "px", @@ -57,25 +57,6 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - git_changelog: { - minimal: { - options: { - repo_url: 'https://github.com/habitrpg/habitrpg', - appName : 'HabitRPG', - branch_name: 'develop' - } - }, - extended: { - options: { - file: 'EXTENDEDCHANGELOG.md', - repo_url: 'https://github.com/habitrpg/habitrpg', - appName : 'HabitRPG', - branch_name: 'develop', - grep_commits: '^perf|^style|^fix|^feat|^docs|^refactor|^chore|BREAKING' - } - } - }, - karma: { unit: { configFile: 'karma.conf.js' @@ -154,8 +135,8 @@ module.exports = function(grunt) { fileNameFormat: '${name}-${hash}.${ext}' }, src: [ - 'website/build/*.js', - 'website/build/*.css', + 'website/build/*.js', + 'website/build/*.css', 'website/build/favicon.ico', 'website/build/common/dist/sprites/*.png', 'website/build/common/img/sprites/backer-only/*.gif', @@ -166,7 +147,7 @@ module.exports = function(grunt) { } }, - nodemon: { + nodemon: { dev: { script: '<%= pkg.main %>' } @@ -174,7 +155,7 @@ module.exports = function(grunt) { watch: { dev: { - files: ['website/public/**/*.styl'], // 'public/**/*.js' Not needed because not in production + files: ['website/public/**/*.styl', 'common/script/**/*.coffee'], // 'public/**/*.js' Not needed because not in production tasks: [ 'build:dev' ], options: { nospawn: true @@ -202,7 +183,7 @@ module.exports = function(grunt) { _.each(files[key].js, function(val){ var path = "./"; - if( val.indexOf('common/') == -1) + if( val.indexOf('common/') == -1) path = './website/public/'; js.push(path + val); }); @@ -213,7 +194,7 @@ module.exports = function(grunt) { var path = "./"; if( val.indexOf('common/') == -1) { path = (val == 'app.css' || val == 'static.css') ? './website/build/' : './website/public/'; - } + } css.push(path + val) }); @@ -229,11 +210,30 @@ module.exports = function(grunt) { // Register tasks. grunt.registerTask('compile:sprites', ['clean:sprite', 'sprite', 'cssmin']); - grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']); - grunt.registerTask('build:dev', ['browserify', 'stylus']); + grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres','prepare:staticNewStuff']); + grunt.registerTask('build:dev', ['browserify', 'stylus', 'prepare:staticNewStuff']); + grunt.registerTask('build:test', ['test:prepare:translations', 'build:dev']); grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]); + grunt.registerTask('test:prepare:translations', function() { + require('coffee-script'); + var i18n = require('./website/src/i18n'), + fs = require('fs'); + fs.writeFileSync('test/spec/translations.js', + "if(!window.env) window.env = {};\n" + + "window.env.translations = " + JSON.stringify(i18n.translations['en']) + ';'); + }); + + grunt.registerTask('prepare:staticNewStuff', function() { + var jade = require('jade'), + fs = require('fs'); + fs.writeFileSync( + './website/public/new-stuff.html', + jade.compileFile('./website/views/shared/new-stuff.jade')() + ); + }); + if(process.env.NODE_ENV == 'production') grunt.registerTask('default', ['build:prod']); else @@ -252,6 +252,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-spritesmith'); grunt.loadNpmTasks('grunt-hashres'); grunt.loadNpmTasks('grunt-karma'); - grunt.loadNpmTasks('git-changelog'); }; diff --git a/README.md b/README.md index 65113909eb..7c7ad55172 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -HabitRPG [![Build Status](https://travis-ci.org/HabitRPG/habitrpg.png?branch=develop)](https://travis-ci.org/HabitRPG/habitrpg) [![Code Climate](https://codeclimate.com/github/HabitRPG/habitrpg.png)](https://codeclimate.com/github/HabitRPG/habitrpg) [![Bountysource](https://api.bountysource.com/badge/tracker?tracker_id=68393)](https://www.bountysource.com/trackers/68393-habitrpg?utm_source=68393&utm_medium=shield&utm_campaign=TRACKER_BADGE) [![Dependency Status](https://gemnasium.com/HabitRPG/habitrpg.svg)](https://gemnasium.com/HabitRPG/habitrpg) +HabitRPG [![Build Status](https://travis-ci.org/HabitRPG/habitrpg.png?branch=develop)](https://travis-ci.org/HabitRPG/habitrpg) [![Code Climate](https://codeclimate.com/github/HabitRPG/habitrpg.png)](https://codeclimate.com/github/HabitRPG/habitrpg) [![Coverage Status](https://coveralls.io/repos/HabitRPG/habitrpg/badge.svg?branch=develop)](https://coveralls.io/r/HabitRPG/habitrpg?branch=develop) [![Bountysource](https://api.bountysource.com/badge/tracker?tracker_id=68393)](https://www.bountysource.com/trackers/68393-habitrpg?utm_source=68393&utm_medium=shield&utm_campaign=TRACKER_BADGE) [![Dependency Status](https://gemnasium.com/HabitRPG/habitrpg.svg)](https://gemnasium.com/HabitRPG/habitrpg) =============== [HabitRPG](https://habitrpg.com) is an open source habit building program which treats your life like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor. diff --git a/archive/CHANGELOG_ARCHIVED.md b/archive/CHANGELOG_ARCHIVED.md new file mode 100644 index 0000000000..59950d5c4c --- /dev/null +++ b/archive/CHANGELOG_ARCHIVED.md @@ -0,0 +1,34 @@ +My app - Changelog +# (2015-05-08) + +## Bug Fixes + +- **Spring:** WHO IS LESLIE + ([6685e935](watch/commits/6685e93554a1274dedb55dae054e787fb80eb440)) +- **invite-friends:** text should be valid for both parties and guilds + ([54e82a14](watch/commits/54e82a14a252c3b9923449a7ef7cee6033a5d160)) +- **mystery:** It's 2015 now, Sabe + ([00252f20](watch/commits/00252f200481f06de9bccd1e55275d5366b03919)) +- **scoring:** move gainMP into score + ([2fc0cb8f](watch/commits/2fc0cb8fa1b3b5975c16653cb110be2f03b5427e)) +- **slimes:** Tweaks and missing sprite + ([7d1a58ca](watch/commits/7d1a58ca002af9dac19aba65d6465bd23b28d649)) + + +## Features + +- **Spring:** Flung + ([d50d4ad8](watch/commits/d50d4ad8bb0f89e39ceb6562e0f8f392f94b5444)) +- **emails:** add support for weekly recap emails + ([37f7db3c](watch/commits/37f7db3c4e3859d03fd55a44e63819e273a06442)) +- **i18n:** upload japanese, serbian and chinese (taiwan) + ([ee7ba19e](watch/commits/ee7ba19ed17e72b33cbef8a324266617d384f852)) +- **mystery:** April Subscribee Items + ([7a7fc968](watch/commits/7a7fc96818ffd7f92738e8c6cc8a59e48d60597d)) +- **pets:** Slime Quest + ([f13c6cba](watch/commits/f13c6cba0026c645b19a0b1355ba2c5b27f80878)) +- **quests:** Boss damage from Habits + ([43dcded0](watch/commits/43dcded051b602d8a4efc30eef45365abfd238b4)) +- **scoring:** MP gain from Habits and Dailies + ([7b22244f](watch/commits/7b22244f0123cf649c9f2aada0811f35a565688d)) + diff --git a/bower.json b/bower.json index 4581445b88..54fec9e612 100644 --- a/bower.json +++ b/bower.json @@ -31,14 +31,14 @@ "github-buttons": "git://github.com/mdo/github-buttons.git", "marked": "~0.2.9", "Angular-At-Directive": "git://github.com/snicker/Angular-At-Directive#master", - "js-emoji": "https://github.com/iamcal/js-emoji.git", + "js-emoji": "git://github.com/snicker/js-emoji#master", "sticky": "*", - "swagger-ui": "git://github.com/wordnik/swagger-ui.git", + "swagger-ui": "git://github.com/wordnik/swagger-ui.git#v2.0.24", "ngInfiniteScroll": "1.0.0", "jquery-colorbox": "~1.4.36", "pnotify": "~1.3.1", "jquery-ui": "~1.10.3", - "hello": "~1.3.1", + "hello": "~1.5.0", "css-social-buttons": "https://github.com/samcollins/css-social-buttons.git", "angular-filter": "~0.5.1", "angular-ui-router": "~0.2.13" diff --git a/common/css/index.css b/common/css/index.css index e8ef45d8b3..c4291dc644 100644 --- a/common/css/index.css +++ b/common/css/index.css @@ -7,7 +7,7 @@ background: url("/common/img/sprites/npc_ian.gif") no-repeat; width: 78px; height: 135px; -} +} .Gems { display:inline-block; @@ -37,6 +37,12 @@ margin-right: 10px; } +.multi-achievement { + margin: auto; + padding-left: 0.5em; + padding-right: 0.5em; +} + [class*="Mount_Head_"], [class*="Mount_Body_"]{ margin-top:18px; /* Sprite accommodates 105x123 box */ } diff --git a/common/dist/scripts/habitrpg-shared.js b/common/dist/scripts/habitrpg-shared.js deleted file mode 100644 index 3bb0bc7bf8..0000000000 --- a/common/dist/scripts/habitrpg-shared.js +++ /dev/null @@ -1,16994 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 70; - }) - }, - 1: { - text: t('weaponSpecial1Text'), - notes: t('weaponSpecial1Notes', { - attrs: 6 - }), - str: 6, - per: 6, - con: 6, - int: 6, - value: 170, - canOwn: (function(u) { - var _ref; - return +((_ref = u.contributor) != null ? _ref.level : void 0) >= 4; - }) - }, - 2: { - text: t('weaponSpecial2Text'), - notes: t('weaponSpecial2Notes', { - attrs: 25 - }), - str: 25, - per: 25, - value: 200, - canOwn: (function(u) { - var _ref; - return (+((_ref = u.backer) != null ? _ref.tier : void 0) >= 300) || (u.items.gear.owned.weapon_special_2 != null); - }) - }, - 3: { - text: t('weaponSpecial3Text'), - notes: t('weaponSpecial3Notes', { - attrs: 17 - }), - str: 17, - int: 17, - con: 17, - value: 200, - canOwn: (function(u) { - var _ref; - return (+((_ref = u.backer) != null ? _ref.tier : void 0) >= 300) || (u.items.gear.owned.weapon_special_3 != null); - }) - }, - critical: { - text: t('weaponSpecialCriticalText'), - notes: t('weaponSpecialCriticalNotes', { - attrs: 40 - }), - str: 40, - per: 40, - value: 200, - canOwn: (function(u) { - var _ref; - return !!((_ref = u.contributor) != null ? _ref.critical : void 0); - }) - }, - yeti: { - event: events.winter, - specialClass: 'warrior', - text: t('weaponSpecialYetiText'), - notes: t('weaponSpecialYetiNotes', { - str: 15 - }), - str: 15, - value: 90 - }, - ski: { - event: events.winter, - specialClass: 'rogue', - text: t('weaponSpecialSkiText'), - notes: t('weaponSpecialSkiNotes', { - str: 8 - }), - str: 8, - value: 90 - }, - candycane: { - event: events.winter, - specialClass: 'wizard', - twoHanded: true, - text: t('weaponSpecialCandycaneText'), - notes: t('weaponSpecialCandycaneNotes', { - int: 15, - per: 7 - }), - int: 15, - per: 7, - value: 160 - }, - snowflake: { - event: events.winter, - specialClass: 'healer', - text: t('weaponSpecialSnowflakeText'), - notes: t('weaponSpecialSnowflakeNotes', { - int: 9 - }), - int: 9, - value: 90 - }, - springRogue: { - event: events.spring, - specialClass: 'rogue', - text: t('weaponSpecialSpringRogueText'), - notes: t('weaponSpecialSpringRogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - springWarrior: { - event: events.spring, - specialClass: 'warrior', - text: t('weaponSpecialSpringWarriorText'), - notes: t('weaponSpecialSpringWarriorNotes', { - str: 15 - }), - value: 90, - str: 15 - }, - springMage: { - event: events.spring, - specialClass: 'wizard', - twoHanded: true, - text: t('weaponSpecialSpringMageText'), - notes: t('weaponSpecialSpringMageNotes', { - int: 15, - per: 7 - }), - value: 160, - int: 15, - per: 7 - }, - springHealer: { - event: events.spring, - specialClass: 'healer', - text: t('weaponSpecialSpringHealerText'), - notes: t('weaponSpecialSpringHealerNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - summerRogue: { - event: events.summer, - specialClass: 'rogue', - text: t('weaponSpecialSummerRogueText'), - notes: t('weaponSpecialSummerRogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - summerWarrior: { - event: events.summer, - specialClass: 'warrior', - text: t('weaponSpecialSummerWarriorText'), - notes: t('weaponSpecialSummerWarriorNotes', { - str: 15 - }), - value: 90, - str: 15 - }, - summerMage: { - event: events.summer, - specialClass: 'wizard', - twoHanded: true, - text: t('weaponSpecialSummerMageText'), - notes: t('weaponSpecialSummerMageNotes', { - int: 15, - per: 7 - }), - value: 160, - int: 15, - per: 7 - }, - summerHealer: { - event: events.summer, - specialClass: 'healer', - text: t('weaponSpecialSummerHealerText'), - notes: t('weaponSpecialSummerHealerNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - fallRogue: { - event: events.fall, - specialClass: 'rogue', - text: t('weaponSpecialFallRogueText'), - notes: t('weaponSpecialFallRogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - fallWarrior: { - event: events.fall, - specialClass: 'warrior', - text: t('weaponSpecialFallWarriorText'), - notes: t('weaponSpecialFallWarriorNotes', { - str: 15 - }), - value: 90, - str: 15 - }, - fallMage: { - event: events.fall, - specialClass: 'wizard', - twoHanded: true, - text: t('weaponSpecialFallMageText'), - notes: t('weaponSpecialFallMageNotes', { - int: 15, - per: 7 - }), - value: 160, - int: 15, - per: 7 - }, - fallHealer: { - event: events.fall, - specialClass: 'healer', - text: t('weaponSpecialFallHealerText'), - notes: t('weaponSpecialFallHealerNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - winter2015Rogue: { - event: events.winter2015, - specialClass: 'rogue', - text: t('weaponSpecialWinter2015RogueText'), - notes: t('weaponSpecialWinter2015RogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - winter2015Warrior: { - event: events.winter2015, - specialClass: 'warrior', - text: t('weaponSpecialWinter2015WarriorText'), - notes: t('weaponSpecialWinter2015WarriorNotes', { - str: 15 - }), - value: 90, - str: 15 - }, - winter2015Mage: { - event: events.winter2015, - specialClass: 'wizard', - twoHanded: true, - text: t('weaponSpecialWinter2015MageText'), - notes: t('weaponSpecialWinter2015MageNotes', { - int: 15, - per: 7 - }), - value: 160, - int: 15, - per: 7 - }, - winter2015Healer: { - event: events.winter2015, - specialClass: 'healer', - text: t('weaponSpecialWinter2015HealerText'), - notes: t('weaponSpecialWinter2015HealerNotes', { - int: 9 - }), - value: 90, - int: 9 - } - }, - mystery: { - 201411: { - text: t('weaponMystery201411Text'), - notes: t('weaponMystery201411Notes'), - mystery: '201411', - value: 0 - }, - 201502: { - text: t('weaponMystery201502Text'), - notes: t('weaponMystery201502Notes'), - mystery: '201502', - value: 0 - }, - 301404: { - text: t('weaponMystery301404Text'), - notes: t('weaponMystery301404Notes'), - mystery: '301404', - value: 0 - } - } - }, - armor: { - base: { - 0: { - text: t('armorBase0Text'), - notes: t('armorBase0Notes'), - value: 0 - } - }, - warrior: { - 1: { - text: t('armorWarrior1Text'), - notes: t('armorWarrior1Notes', { - con: 3 - }), - con: 3, - value: 30 - }, - 2: { - text: t('armorWarrior2Text'), - notes: t('armorWarrior2Notes', { - con: 5 - }), - con: 5, - value: 45 - }, - 3: { - text: t('armorWarrior3Text'), - notes: t('armorWarrior3Notes', { - con: 7 - }), - con: 7, - value: 65 - }, - 4: { - text: t('armorWarrior4Text'), - notes: t('armorWarrior4Notes', { - con: 9 - }), - con: 9, - value: 90 - }, - 5: { - text: t('armorWarrior5Text'), - notes: t('armorWarrior5Notes', { - con: 11 - }), - con: 11, - value: 120, - last: true - } - }, - rogue: { - 1: { - text: t('armorRogue1Text'), - notes: t('armorRogue1Notes', { - per: 6 - }), - per: 6, - value: 30 - }, - 2: { - text: t('armorRogue2Text'), - notes: t('armorRogue2Notes', { - per: 9 - }), - per: 9, - value: 45 - }, - 3: { - text: t('armorRogue3Text'), - notes: t('armorRogue3Notes', { - per: 12 - }), - per: 12, - value: 65 - }, - 4: { - text: t('armorRogue4Text'), - notes: t('armorRogue4Notes', { - per: 15 - }), - per: 15, - value: 90 - }, - 5: { - text: t('armorRogue5Text'), - notes: t('armorRogue5Notes', { - per: 18 - }), - per: 18, - value: 120, - last: true - } - }, - wizard: { - 1: { - text: t('armorWizard1Text'), - notes: t('armorWizard1Notes', { - int: 2 - }), - int: 2, - value: 30 - }, - 2: { - text: t('armorWizard2Text'), - notes: t('armorWizard2Notes', { - int: 4 - }), - int: 4, - value: 45 - }, - 3: { - text: t('armorWizard3Text'), - notes: t('armorWizard3Notes', { - int: 6 - }), - int: 6, - value: 65 - }, - 4: { - text: t('armorWizard4Text'), - notes: t('armorWizard4Notes', { - int: 9 - }), - int: 9, - value: 90 - }, - 5: { - text: t('armorWizard5Text'), - notes: t('armorWizard5Notes', { - int: 12 - }), - int: 12, - value: 120, - last: true - } - }, - healer: { - 1: { - text: t('armorHealer1Text'), - notes: t('armorHealer1Notes', { - con: 6 - }), - con: 6, - value: 30 - }, - 2: { - text: t('armorHealer2Text'), - notes: t('armorHealer2Notes', { - con: 9 - }), - con: 9, - value: 45 - }, - 3: { - text: t('armorHealer3Text'), - notes: t('armorHealer3Notes', { - con: 12 - }), - con: 12, - value: 65 - }, - 4: { - text: t('armorHealer4Text'), - notes: t('armorHealer4Notes', { - con: 15 - }), - con: 15, - value: 90 - }, - 5: { - text: t('armorHealer5Text'), - notes: t('armorHealer5Notes', { - con: 18 - }), - con: 18, - value: 120, - last: true - } - }, - special: { - 0: { - text: t('armorSpecial0Text'), - notes: t('armorSpecial0Notes', { - con: 20 - }), - con: 20, - value: 150, - canOwn: (function(u) { - var _ref; - return +((_ref = u.backer) != null ? _ref.tier : void 0) >= 45; - }) - }, - 1: { - text: t('armorSpecial1Text'), - notes: t('armorSpecial1Notes', { - attrs: 6 - }), - con: 6, - str: 6, - per: 6, - int: 6, - value: 170, - canOwn: (function(u) { - var _ref; - return +((_ref = u.contributor) != null ? _ref.level : void 0) >= 2; - }) - }, - 2: { - text: t('armorSpecial2Text'), - notes: t('armorSpecial2Notes', { - attrs: 25 - }), - int: 25, - con: 25, - value: 200, - canOwn: (function(u) { - var _ref; - return +((_ref = u.backer) != null ? _ref.tier : void 0) >= 300 || (u.items.gear.owned.armor_special_2 != null); - }) - }, - yeti: { - event: events.winter, - specialClass: 'warrior', - text: t('armorSpecialYetiText'), - notes: t('armorSpecialYetiNotes', { - con: 9 - }), - con: 9, - value: 90 - }, - ski: { - event: events.winter, - specialClass: 'rogue', - text: t('armorSpecialSkiText'), - notes: t('armorSpecialSkiNotes', { - per: 15 - }), - per: 15, - value: 90 - }, - candycane: { - event: events.winter, - specialClass: 'wizard', - text: t('armorSpecialCandycaneText'), - notes: t('armorSpecialCandycaneNotes', { - int: 9 - }), - int: 9, - value: 90 - }, - snowflake: { - event: events.winter, - specialClass: 'healer', - text: t('armorSpecialSnowflakeText'), - notes: t('armorSpecialSnowflakeNotes', { - con: 15 - }), - con: 15, - value: 90 - }, - birthday: { - event: events.birthday, - text: t('armorSpecialBirthdayText'), - notes: t('armorSpecialBirthdayNotes'), - value: 0 - }, - springRogue: { - event: events.spring, - specialClass: 'rogue', - text: t('armorSpecialSpringRogueText'), - notes: t('armorSpecialSpringRogueNotes', { - per: 15 - }), - value: 90, - per: 15 - }, - springWarrior: { - event: events.spring, - specialClass: 'warrior', - text: t('armorSpecialSpringWarriorText'), - notes: t('armorSpecialSpringWarriorNotes', { - con: 9 - }), - value: 90, - con: 9 - }, - springMage: { - event: events.spring, - specialClass: 'wizard', - text: t('armorSpecialSpringMageText'), - notes: t('armorSpecialSpringMageNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - springHealer: { - event: events.spring, - specialClass: 'healer', - text: t('armorSpecialSpringHealerText'), - notes: t('armorSpecialSpringHealerNotes', { - con: 15 - }), - value: 90, - con: 15 - }, - summerRogue: { - event: events.summer, - specialClass: 'rogue', - text: t('armorSpecialSummerRogueText'), - notes: t('armorSpecialSummerRogueNotes', { - per: 15 - }), - value: 90, - per: 15 - }, - summerWarrior: { - event: events.summer, - specialClass: 'warrior', - text: t('armorSpecialSummerWarriorText'), - notes: t('armorSpecialSummerWarriorNotes', { - con: 9 - }), - value: 90, - con: 9 - }, - summerMage: { - event: events.summer, - specialClass: 'wizard', - text: t('armorSpecialSummerMageText'), - notes: t('armorSpecialSummerMageNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - summerHealer: { - event: events.summer, - specialClass: 'healer', - text: t('armorSpecialSummerHealerText'), - notes: t('armorSpecialSummerHealerNotes', { - con: 15 - }), - value: 90, - con: 15 - }, - fallRogue: { - event: events.fall, - specialClass: 'rogue', - text: t('armorSpecialFallRogueText'), - notes: t('armorSpecialFallRogueNotes', { - per: 15 - }), - value: 90, - per: 15 - }, - fallWarrior: { - event: events.fall, - specialClass: 'warrior', - text: t('armorSpecialFallWarriorText'), - notes: t('armorSpecialFallWarriorNotes', { - con: 9 - }), - value: 90, - con: 9 - }, - fallMage: { - event: events.fall, - specialClass: 'wizard', - text: t('armorSpecialFallMageText'), - notes: t('armorSpecialFallMageNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - fallHealer: { - event: events.fall, - specialClass: 'healer', - text: t('armorSpecialFallHealerText'), - notes: t('armorSpecialFallHealerNotes', { - con: 15 - }), - value: 90, - con: 15 - }, - winter2015Rogue: { - event: events.winter2015, - specialClass: 'rogue', - text: t('armorSpecialWinter2015RogueText'), - notes: t('armorSpecialWinter2015RogueNotes', { - per: 15 - }), - value: 90, - per: 15 - }, - winter2015Warrior: { - event: events.winter2015, - specialClass: 'warrior', - text: t('armorSpecialWinter2015WarriorText'), - notes: t('armorSpecialWinter2015WarriorNotes', { - con: 9 - }), - value: 90, - con: 9 - }, - winter2015Mage: { - event: events.winter2015, - specialClass: 'wizard', - text: t('armorSpecialWinter2015MageText'), - notes: t('armorSpecialWinter2015MageNotes', { - int: 9 - }), - value: 90, - int: 9 - }, - winter2015Healer: { - event: events.winter2015, - specialClass: 'healer', - text: t('armorSpecialWinter2015HealerText'), - notes: t('armorSpecialWinter2015HealerNotes', { - con: 15 - }), - value: 90, - con: 15 - }, - birthday2015: { - text: t('armorSpecialBirthday2015Text'), - notes: t('armorSpecialBirthday2015Notes'), - value: 0, - canOwn: (function(u) { - return u.items.gear.owned.armor_special_birthday2015 != null; - }) - }, - gaymerx: { - event: events.gaymerx, - text: t('armorSpecialGaymerxText'), - notes: t('armorSpecialGaymerxNotes'), - value: 0 - } - }, - mystery: { - 201402: { - text: t('armorMystery201402Text'), - notes: t('armorMystery201402Notes'), - mystery: '201402', - value: 0 - }, - 201403: { - text: t('armorMystery201403Text'), - notes: t('armorMystery201403Notes'), - mystery: '201403', - value: 0 - }, - 201405: { - text: t('armorMystery201405Text'), - notes: t('armorMystery201405Notes'), - mystery: '201405', - value: 0 - }, - 201406: { - text: t('armorMystery201406Text'), - notes: t('armorMystery201406Notes'), - mystery: '201406', - value: 0 - }, - 201407: { - text: t('armorMystery201407Text'), - notes: t('armorMystery201407Notes'), - mystery: '201407', - value: 0 - }, - 201408: { - text: t('armorMystery201408Text'), - notes: t('armorMystery201408Notes'), - mystery: '201408', - value: 0 - }, - 201409: { - text: t('armorMystery201409Text'), - notes: t('armorMystery201409Notes'), - mystery: '201409', - value: 0 - }, - 201410: { - text: t('armorMystery201410Text'), - notes: t('armorMystery201410Notes'), - mystery: '201410', - value: 0 - }, - 201412: { - text: t('armorMystery201412Text'), - notes: t('armorMystery201412Notes'), - mystery: '201412', - value: 0 - }, - 201501: { - text: t('armorMystery201501Text'), - notes: t('armorMystery201501Notes'), - mystery: '201501', - value: 0 - }, - 301404: { - text: t('armorMystery301404Text'), - notes: t('armorMystery301404Notes'), - mystery: '301404', - value: 0 - } - } - }, - head: { - base: { - 0: { - text: t('headBase0Text'), - notes: t('headBase0Notes'), - value: 0 - } - }, - warrior: { - 1: { - text: t('headWarrior1Text'), - notes: t('headWarrior1Notes', { - str: 2 - }), - str: 2, - value: 15 - }, - 2: { - text: t('headWarrior2Text'), - notes: t('headWarrior2Notes', { - str: 4 - }), - str: 4, - value: 25 - }, - 3: { - text: t('headWarrior3Text'), - notes: t('headWarrior3Notes', { - str: 6 - }), - str: 6, - value: 40 - }, - 4: { - text: t('headWarrior4Text'), - notes: t('headWarrior4Notes', { - str: 9 - }), - str: 9, - value: 60 - }, - 5: { - text: t('headWarrior5Text'), - notes: t('headWarrior5Notes', { - str: 12 - }), - str: 12, - value: 80, - last: true - } - }, - rogue: { - 1: { - text: t('headRogue1Text'), - notes: t('headRogue1Notes', { - per: 2 - }), - per: 2, - value: 15 - }, - 2: { - text: t('headRogue2Text'), - notes: t('headRogue2Notes', { - per: 4 - }), - per: 4, - value: 25 - }, - 3: { - text: t('headRogue3Text'), - notes: t('headRogue3Notes', { - per: 6 - }), - per: 6, - value: 40 - }, - 4: { - text: t('headRogue4Text'), - notes: t('headRogue4Notes', { - per: 9 - }), - per: 9, - value: 60 - }, - 5: { - text: t('headRogue5Text'), - notes: t('headRogue5Notes', { - per: 12 - }), - per: 12, - value: 80, - last: true - } - }, - wizard: { - 1: { - text: t('headWizard1Text'), - notes: t('headWizard1Notes', { - per: 2 - }), - per: 2, - value: 15 - }, - 2: { - text: t('headWizard2Text'), - notes: t('headWizard2Notes', { - per: 3 - }), - per: 3, - value: 25 - }, - 3: { - text: t('headWizard3Text'), - notes: t('headWizard3Notes', { - per: 5 - }), - per: 5, - value: 40 - }, - 4: { - text: t('headWizard4Text'), - notes: t('headWizard4Notes', { - per: 7 - }), - per: 7, - value: 60 - }, - 5: { - text: t('headWizard5Text'), - notes: t('headWizard5Notes', { - per: 10 - }), - per: 10, - value: 80, - last: true - } - }, - healer: { - 1: { - text: t('headHealer1Text'), - notes: t('headHealer1Notes', { - int: 2 - }), - int: 2, - value: 15 - }, - 2: { - text: t('headHealer2Text'), - notes: t('headHealer2Notes', { - int: 3 - }), - int: 3, - value: 25 - }, - 3: { - text: t('headHealer3Text'), - notes: t('headHealer3Notes', { - int: 5 - }), - int: 5, - value: 40 - }, - 4: { - text: t('headHealer4Text'), - notes: t('headHealer4Notes', { - int: 7 - }), - int: 7, - value: 60 - }, - 5: { - text: t('headHealer5Text'), - notes: t('headHealer5Notes', { - int: 9 - }), - int: 9, - value: 80, - last: true - } - }, - special: { - 0: { - text: t('headSpecial0Text'), - notes: t('headSpecial0Notes', { - int: 20 - }), - int: 20, - value: 150, - canOwn: (function(u) { - var _ref; - return +((_ref = u.backer) != null ? _ref.tier : void 0) >= 45; - }) - }, - 1: { - text: t('headSpecial1Text'), - notes: t('headSpecial1Notes', { - attrs: 6 - }), - con: 6, - str: 6, - per: 6, - int: 6, - value: 170, - canOwn: (function(u) { - var _ref; - return +((_ref = u.contributor) != null ? _ref.level : void 0) >= 3; - }) - }, - 2: { - text: t('headSpecial2Text'), - notes: t('headSpecial2Notes', { - attrs: 25 - }), - int: 25, - str: 25, - value: 200, - canOwn: (function(u) { - var _ref; - return (+((_ref = u.backer) != null ? _ref.tier : void 0) >= 300) || (u.items.gear.owned.head_special_2 != null); - }) - }, - nye: { - event: events.winter, - text: t('headSpecialNyeText'), - notes: t('headSpecialNyeNotes'), - value: 0 - }, - yeti: { - event: events.winter, - specialClass: 'warrior', - text: t('headSpecialYetiText'), - notes: t('headSpecialYetiNotes', { - str: 9 - }), - str: 9, - value: 60 - }, - ski: { - event: events.winter, - specialClass: 'rogue', - text: t('headSpecialSkiText'), - notes: t('headSpecialSkiNotes', { - per: 9 - }), - per: 9, - value: 60 - }, - candycane: { - event: events.winter, - specialClass: 'wizard', - text: t('headSpecialCandycaneText'), - notes: t('headSpecialCandycaneNotes', { - per: 7 - }), - per: 7, - value: 60 - }, - snowflake: { - event: events.winter, - specialClass: 'healer', - text: t('headSpecialSnowflakeText'), - notes: t('headSpecialSnowflakeNotes', { - int: 7 - }), - int: 7, - value: 60 - }, - springRogue: { - event: events.spring, - specialClass: 'rogue', - text: t('headSpecialSpringRogueText'), - notes: t('headSpecialSpringRogueNotes', { - per: 9 - }), - value: 60, - per: 9 - }, - springWarrior: { - event: events.spring, - specialClass: 'warrior', - text: t('headSpecialSpringWarriorText'), - notes: t('headSpecialSpringWarriorNotes', { - str: 9 - }), - value: 60, - str: 9 - }, - springMage: { - event: events.spring, - specialClass: 'wizard', - text: t('headSpecialSpringMageText'), - notes: t('headSpecialSpringMageNotes', { - per: 7 - }), - value: 60, - per: 7 - }, - springHealer: { - event: events.spring, - specialClass: 'healer', - text: t('headSpecialSpringHealerText'), - notes: t('headSpecialSpringHealerNotes', { - int: 7 - }), - value: 60, - int: 7 - }, - summerRogue: { - event: events.summer, - specialClass: 'rogue', - text: t('headSpecialSummerRogueText'), - notes: t('headSpecialSummerRogueNotes', { - per: 9 - }), - value: 60, - per: 9 - }, - summerWarrior: { - event: events.summer, - specialClass: 'warrior', - text: t('headSpecialSummerWarriorText'), - notes: t('headSpecialSummerWarriorNotes', { - str: 9 - }), - value: 60, - str: 9 - }, - summerMage: { - event: events.summer, - specialClass: 'wizard', - text: t('headSpecialSummerMageText'), - notes: t('headSpecialSummerMageNotes', { - per: 7 - }), - value: 60, - per: 7 - }, - summerHealer: { - event: events.summer, - specialClass: 'healer', - text: t('headSpecialSummerHealerText'), - notes: t('headSpecialSummerHealerNotes', { - int: 7 - }), - value: 60, - int: 7 - }, - fallRogue: { - event: events.fall, - specialClass: 'rogue', - text: t('headSpecialFallRogueText'), - notes: t('headSpecialFallRogueNotes', { - per: 9 - }), - value: 60, - per: 9 - }, - fallWarrior: { - event: events.fall, - specialClass: 'warrior', - text: t('headSpecialFallWarriorText'), - notes: t('headSpecialFallWarriorNotes', { - str: 9 - }), - value: 60, - str: 9 - }, - fallMage: { - event: events.fall, - specialClass: 'wizard', - text: t('headSpecialFallMageText'), - notes: t('headSpecialFallMageNotes', { - per: 7 - }), - value: 60, - per: 7 - }, - fallHealer: { - event: events.fall, - specialClass: 'healer', - text: t('headSpecialFallHealerText'), - notes: t('headSpecialFallHealerNotes', { - int: 7 - }), - value: 60, - int: 7 - }, - winter2015Rogue: { - event: events.winter2015, - specialClass: 'rogue', - text: t('headSpecialWinter2015RogueText'), - notes: t('headSpecialWinter2015RogueNotes', { - per: 9 - }), - value: 60, - per: 9 - }, - winter2015Warrior: { - event: events.winter2015, - specialClass: 'warrior', - text: t('headSpecialWinter2015WarriorText'), - notes: t('headSpecialWinter2015WarriorNotes', { - str: 9 - }), - value: 60, - str: 9 - }, - winter2015Mage: { - event: events.winter2015, - specialClass: 'wizard', - text: t('headSpecialWinter2015MageText'), - notes: t('headSpecialWinter2015MageNotes', { - per: 7 - }), - value: 60, - per: 7 - }, - winter2015Healer: { - event: events.winter2015, - specialClass: 'healer', - text: t('headSpecialWinter2015HealerText'), - notes: t('headSpecialWinter2015HealerNotes', { - int: 7 - }), - value: 60, - int: 7 - }, - nye2014: { - text: t('headSpecialNye2014Text'), - notes: t('headSpecialNye2014Notes'), - value: 0, - canOwn: (function(u) { - return u.items.gear.owned.head_special_nye2014 != null; - }) - }, - gaymerx: { - event: events.gaymerx, - text: t('headSpecialGaymerxText'), - notes: t('headSpecialGaymerxNotes'), - value: 0 - } - }, - mystery: { - 201402: { - text: t('headMystery201402Text'), - notes: t('headMystery201402Notes'), - mystery: '201402', - value: 0 - }, - 201405: { - text: t('headMystery201405Text'), - notes: t('headMystery201405Notes'), - mystery: '201405', - value: 0 - }, - 201406: { - text: t('headMystery201406Text'), - notes: t('headMystery201406Notes'), - mystery: '201406', - value: 0 - }, - 201407: { - text: t('headMystery201407Text'), - notes: t('headMystery201407Notes'), - mystery: '201407', - value: 0 - }, - 201408: { - text: t('headMystery201408Text'), - notes: t('headMystery201408Notes'), - mystery: '201408', - value: 0 - }, - 201411: { - text: t('headMystery201411Text'), - notes: t('headMystery201411Notes'), - mystery: '201411', - value: 0 - }, - 201412: { - text: t('headMystery201412Text'), - notes: t('headMystery201412Notes'), - mystery: '201412', - value: 0 - }, - 201501: { - text: t('headMystery201501Text'), - notes: t('headMystery201501Notes'), - mystery: '201501', - value: 0 - }, - 301404: { - text: t('headMystery301404Text'), - notes: t('headMystery301404Notes'), - mystery: '301404', - value: 0 - }, - 301405: { - text: t('headMystery301405Text'), - notes: t('headMystery301405Notes'), - mystery: '301405', - value: 0 - } - } - }, - shield: { - base: { - 0: { - text: t('shieldBase0Text'), - notes: t('shieldBase0Notes'), - value: 0 - } - }, - warrior: { - 1: { - text: t('shieldWarrior1Text'), - notes: t('shieldWarrior1Notes', { - con: 2 - }), - con: 2, - value: 20 - }, - 2: { - text: t('shieldWarrior2Text'), - notes: t('shieldWarrior2Notes', { - con: 3 - }), - con: 3, - value: 35 - }, - 3: { - text: t('shieldWarrior3Text'), - notes: t('shieldWarrior3Notes', { - con: 5 - }), - con: 5, - value: 50 - }, - 4: { - text: t('shieldWarrior4Text'), - notes: t('shieldWarrior4Notes', { - con: 7 - }), - con: 7, - value: 70 - }, - 5: { - text: t('shieldWarrior5Text'), - notes: t('shieldWarrior5Notes', { - con: 9 - }), - con: 9, - value: 90, - last: true - } - }, - rogue: { - 0: { - text: t('weaponRogue0Text'), - notes: t('weaponRogue0Notes'), - str: 0, - value: 0 - }, - 1: { - text: t('weaponRogue1Text'), - notes: t('weaponRogue1Notes', { - str: 2 - }), - str: 2, - value: 20 - }, - 2: { - text: t('weaponRogue2Text'), - notes: t('weaponRogue2Notes', { - str: 3 - }), - str: 3, - value: 35 - }, - 3: { - text: t('weaponRogue3Text'), - notes: t('weaponRogue3Notes', { - str: 4 - }), - str: 4, - value: 50 - }, - 4: { - text: t('weaponRogue4Text'), - notes: t('weaponRogue4Notes', { - str: 6 - }), - str: 6, - value: 70 - }, - 5: { - text: t('weaponRogue5Text'), - notes: t('weaponRogue5Notes', { - str: 8 - }), - str: 8, - value: 90 - }, - 6: { - text: t('weaponRogue6Text'), - notes: t('weaponRogue6Notes', { - str: 10 - }), - str: 10, - value: 120, - last: true - } - }, - wizard: {}, - healer: { - 1: { - text: t('shieldHealer1Text'), - notes: t('shieldHealer1Notes', { - con: 2 - }), - con: 2, - value: 20 - }, - 2: { - text: t('shieldHealer2Text'), - notes: t('shieldHealer2Notes', { - con: 4 - }), - con: 4, - value: 35 - }, - 3: { - text: t('shieldHealer3Text'), - notes: t('shieldHealer3Notes', { - con: 6 - }), - con: 6, - value: 50 - }, - 4: { - text: t('shieldHealer4Text'), - notes: t('shieldHealer4Notes', { - con: 9 - }), - con: 9, - value: 70 - }, - 5: { - text: t('shieldHealer5Text'), - notes: t('shieldHealer5Notes', { - con: 12 - }), - con: 12, - value: 90, - last: true - } - }, - special: { - 0: { - text: t('shieldSpecial0Text'), - notes: t('shieldSpecial0Notes', { - per: 20 - }), - per: 20, - value: 150, - canOwn: (function(u) { - var _ref; - return +((_ref = u.backer) != null ? _ref.tier : void 0) >= 45; - }) - }, - 1: { - text: t('shieldSpecial1Text'), - notes: t('shieldSpecial1Notes', { - attrs: 6 - }), - con: 6, - str: 6, - per: 6, - int: 6, - value: 170, - canOwn: (function(u) { - var _ref; - return +((_ref = u.contributor) != null ? _ref.level : void 0) >= 5; - }) - }, - goldenknight: { - text: t('shieldSpecialGoldenknightText'), - notes: t('shieldSpecialGoldenknightNotes', { - attrs: 25 - }), - con: 25, - per: 25, - value: 200, - canOwn: (function(u) { - return u.items.gear.owned.shield_special_goldenknight != null; - }) - }, - yeti: { - event: events.winter, - specialClass: 'warrior', - text: t('shieldSpecialYetiText'), - notes: t('shieldSpecialYetiNotes', { - con: 7 - }), - con: 7, - value: 70 - }, - ski: { - event: events.winter, - specialClass: 'rogue', - text: t('weaponSpecialSkiText'), - notes: t('weaponSpecialSkiNotes', { - str: 8 - }), - str: 8, - value: 90 - }, - snowflake: { - event: events.winter, - specialClass: 'healer', - text: t('shieldSpecialSnowflakeText'), - notes: t('shieldSpecialSnowflakeNotes', { - con: 9 - }), - con: 9, - value: 70 - }, - springRogue: { - event: events.spring, - specialClass: 'rogue', - text: t('shieldSpecialSpringRogueText'), - notes: t('shieldSpecialSpringRogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - springWarrior: { - event: events.spring, - specialClass: 'warrior', - text: t('shieldSpecialSpringWarriorText'), - notes: t('shieldSpecialSpringWarriorNotes', { - con: 7 - }), - value: 70, - con: 7 - }, - springHealer: { - event: events.spring, - specialClass: 'healer', - text: t('shieldSpecialSpringHealerText'), - notes: t('shieldSpecialSpringHealerNotes', { - con: 9 - }), - value: 70, - con: 9 - }, - summerRogue: { - event: events.summer, - specialClass: 'rogue', - text: t('shieldSpecialSummerRogueText'), - notes: t('shieldSpecialSummerRogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - summerWarrior: { - event: events.summer, - specialClass: 'warrior', - text: t('shieldSpecialSummerWarriorText'), - notes: t('shieldSpecialSummerWarriorNotes', { - con: 7 - }), - value: 70, - con: 7 - }, - summerHealer: { - event: events.summer, - specialClass: 'healer', - text: t('shieldSpecialSummerHealerText'), - notes: t('shieldSpecialSummerHealerNotes', { - con: 9 - }), - value: 70, - con: 9 - }, - fallRogue: { - event: events.fall, - specialClass: 'rogue', - text: t('shieldSpecialFallRogueText'), - notes: t('shieldSpecialFallRogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - fallWarrior: { - event: events.fall, - specialClass: 'warrior', - text: t('shieldSpecialFallWarriorText'), - notes: t('shieldSpecialFallWarriorNotes', { - con: 7 - }), - value: 70, - con: 7 - }, - fallHealer: { - event: events.fall, - specialClass: 'healer', - text: t('shieldSpecialFallHealerText'), - notes: t('shieldSpecialFallHealerNotes', { - con: 9 - }), - value: 70, - con: 9 - }, - winter2015Rogue: { - event: events.winter2015, - specialClass: 'rogue', - text: t('shieldSpecialWinter2015RogueText'), - notes: t('shieldSpecialWinter2015RogueNotes', { - str: 8 - }), - value: 80, - str: 8 - }, - winter2015Warrior: { - event: events.winter2015, - specialClass: 'warrior', - text: t('shieldSpecialWinter2015WarriorText'), - notes: t('shieldSpecialWinter2015WarriorNotes', { - con: 7 - }), - value: 70, - con: 7 - }, - winter2015Healer: { - event: events.winter2015, - specialClass: 'healer', - text: t('shieldSpecialWinter2015HealerText'), - notes: t('shieldSpecialWinter2015HealerNotes', { - con: 9 - }), - value: 70, - con: 9 - } - }, - mystery: { - 301405: { - text: t('shieldMystery301405Text'), - notes: t('shieldMystery301405Notes'), - mystery: '301405', - value: 0 - } - } - }, - back: { - base: { - 0: { - text: t('backBase0Text'), - notes: t('backBase0Notes'), - value: 0 - } - }, - mystery: { - 201402: { - text: t('backMystery201402Text'), - notes: t('backMystery201402Notes'), - mystery: '201402', - value: 0 - }, - 201404: { - text: t('backMystery201404Text'), - notes: t('backMystery201404Notes'), - mystery: '201404', - value: 0 - }, - 201410: { - text: t('backMystery201410Text'), - notes: t('backMystery201410Notes'), - mystery: '201410', - value: 0 - } - }, - special: { - wondercon_red: { - text: t('backSpecialWonderconRedText'), - notes: t('backSpecialWonderconRedNotes'), - value: 0, - mystery: 'wondercon' - }, - wondercon_black: { - text: t('backSpecialWonderconBlackText'), - notes: t('backSpecialWonderconBlackNotes'), - value: 0, - mystery: 'wondercon' - } - } - }, - body: { - base: { - 0: { - text: t('bodyBase0Text'), - notes: t('bodyBase0Notes'), - value: 0 - } - }, - special: { - wondercon_red: { - text: t('bodySpecialWonderconRedText'), - notes: t('bodySpecialWonderconRedNotes'), - value: 0, - mystery: 'wondercon' - }, - wondercon_gold: { - text: t('bodySpecialWonderconGoldText'), - notes: t('bodySpecialWonderconGoldNotes'), - value: 0, - mystery: 'wondercon' - }, - wondercon_black: { - text: t('bodySpecialWonderconBlackText'), - notes: t('bodySpecialWonderconBlackNotes'), - value: 0, - mystery: 'wondercon' - }, - summerHealer: { - event: events.summer, - specialClass: 'healer', - text: t('bodySpecialSummerHealerText'), - notes: t('bodySpecialSummerHealerNotes'), - value: 20 - }, - summerMage: { - event: events.summer, - specialClass: 'wizard', - text: t('bodySpecialSummerMageText'), - notes: t('bodySpecialSummerMageNotes'), - value: 20 - } - } - }, - headAccessory: { - base: { - 0: { - text: t('headAccessoryBase0Text'), - notes: t('headAccessoryBase0Notes'), - value: 0, - last: true - } - }, - special: { - springRogue: { - event: events.spring, - specialClass: 'rogue', - text: t('headAccessorySpecialSpringRogueText'), - notes: t('headAccessorySpecialSpringRogueNotes'), - value: 20 - }, - springWarrior: { - event: events.spring, - specialClass: 'warrior', - text: t('headAccessorySpecialSpringWarriorText'), - notes: t('headAccessorySpecialSpringWarriorNotes'), - value: 20 - }, - springMage: { - event: events.spring, - specialClass: 'wizard', - text: t('headAccessorySpecialSpringMageText'), - notes: t('headAccessorySpecialSpringMageNotes'), - value: 20 - }, - springHealer: { - event: events.spring, - specialClass: 'healer', - text: t('headAccessorySpecialSpringHealerText'), - notes: t('headAccessorySpecialSpringHealerNotes'), - value: 20 - } - }, - mystery: { - 201403: { - text: t('headAccessoryMystery201403Text'), - notes: t('headAccessoryMystery201403Notes'), - mystery: '201403', - value: 0 - }, - 201404: { - text: t('headAccessoryMystery201404Text'), - notes: t('headAccessoryMystery201404Notes'), - mystery: '201404', - value: 0 - }, - 201409: { - text: t('headAccessoryMystery201409Text'), - notes: t('headAccessoryMystery201409Notes'), - mystery: '201409', - value: 0 - }, - 201502: { - text: t('headAccessoryMystery201502Text'), - notes: t('headAccessoryMystery201502Notes'), - mystery: '201502', - value: 0 - }, - 301405: { - text: t('headAccessoryMystery301405Text'), - notes: t('headAccessoryMystery301405Notes'), - mystery: '301405', - value: 0 - } - } - }, - eyewear: { - base: { - 0: { - text: t('eyewearBase0Text'), - notes: t('eyewearBase0Notes'), - value: 0, - last: true - } - }, - special: { - wondercon_red: { - text: t('eyewearSpecialWonderconRedText'), - notes: t('eyewearSpecialWonderconRedNotes'), - value: 0, - mystery: 'wondercon' - }, - wondercon_black: { - text: t('eyewearSpecialWonderconBlackText'), - notes: t('eyewearSpecialWonderconBlackNotes'), - value: 0, - mystery: 'wondercon' - }, - summerRogue: { - event: events.summer, - specialClass: 'rogue', - text: t('eyewearSpecialSummerRogueText'), - notes: t('eyewearSpecialSummerRogueNotes'), - value: 20 - }, - summerWarrior: { - event: events.summer, - specialClass: 'warrior', - text: t('eyewearSpecialSummerWarriorText'), - notes: t('eyewearSpecialSummerWarriorNotes'), - value: 20 - } - }, - mystery: { - 301404: { - text: t('eyewearMystery301404Text'), - notes: t('eyewearMystery301404Notes'), - mystery: '301404', - value: 0 - }, - 301405: { - text: t('eyewearMystery301405Text'), - notes: t('eyewearMystery301405Notes'), - mystery: '301405', - value: 0 - } - } - } -}; - - -/* - The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since - they are needed in different froms at different points in the app - */ - -api.gear = { - tree: gear, - flat: {} -}; - -_.each(gearTypes, function(type) { - return _.each(classes.concat(['base', 'special', 'mystery']), function(klass) { - return _.each(gear[type][klass], function(item, i) { - var key, _canOwn; - key = "" + type + "_" + klass + "_" + i; - _.defaults(item, { - type: type, - key: key, - klass: klass, - index: i, - str: 0, - int: 0, - per: 0, - con: 0 - }); - if (item.event) { - _canOwn = item.canOwn || (function() { - return true; - }); - item.canOwn = function(u) { - return _canOwn(u) && ((u.items.gear.owned[key] != null) || (moment().isAfter(item.event.start) && moment().isBefore(item.event.end))) && (item.specialClass ? u.stats["class"] === item.specialClass : true); - }; - } - if (item.mystery) { - item.canOwn = function(u) { - return u.items.gear.owned[key] != null; - }; - } - return api.gear.flat[key] = item; - }); - }); -}); - - -/* - Time Traveler Store, mystery sets need their items mapped in - */ - -_.each(api.mystery, function(v, k) { - return v.items = _.where(api.gear.flat, { - mystery: k - }); -}); - -api.timeTravelerStore = function(owned) { - var ownedKeys; - ownedKeys = _.keys((typeof owned.toObject === "function" ? owned.toObject() : void 0) || owned); - return _.reduce(api.mystery, function(m, v, k) { - if (k === 'wondercon' || ~ownedKeys.indexOf(v.items[0].key)) { - return m; - } - m[k] = v; - return m; - }, {}); -}; - - -/* - --------------------------------------------------------------- - Potion - --------------------------------------------------------------- - */ - -api.potion = { - type: 'potion', - text: t('potionText'), - notes: t('potionNotes'), - value: 25, - key: 'potion' -}; - - -/* - --------------------------------------------------------------- - Classes - --------------------------------------------------------------- - */ - -api.classes = classes; - - -/* - --------------------------------------------------------------- - Gear Types - --------------------------------------------------------------- - */ - -api.gearTypes = gearTypes; - - -/* - --------------------------------------------------------------- - Spells - --------------------------------------------------------------- - Text, notes, and mana are obvious. The rest: - - * {target}: one of [task, self, party, user]. This is very important, because if the cast() function is expecting one - thing and receives another, it will cause errors. `self` is used for self buffs, multi-task debuffs, AOEs (eg, meteor-shower), - etc. Basically, use self for anything that's not [task, party, user] and is an instant-cast - - * {cast}: the function that's run to perform the ability's action. This is pretty slick - because this is exported to the - web, this function can be performed on the client and on the server. `user` param is self (needed for determining your - own stats for effectiveness of cast), and `target` param is one of [task, party, user]. In the case of `self` spells, - you act on `user` instead of `target`. You can trust these are the correct objects, as long as the `target` attr of the - spell is correct. Take a look at habitrpg/src/models/user.js and habitrpg/src/models/task.js for what attributes are - available on each model. Note `task.value` is its "redness". If party is passed in, it's an array of users, - so you'll want to iterate over them like: `_.each(target,function(member){...})` - - Note, user.stats.mp is docked after automatically (it's appended to functions automatically down below in an _.each) - */ - -diminishingReturns = function(bonus, max, halfway) { - if (halfway == null) { - halfway = max / 2; - } - return max * (bonus / (bonus + halfway)); -}; - -api.spells = { - wizard: { - fireball: { - text: t('spellWizardFireballText'), - mana: 10, - lvl: 11, - target: 'task', - notes: t('spellWizardFireballNotes'), - cast: function(user, target) { - var bonus; - bonus = user._statsComputed.int * user.fns.crit('per'); - target.value += diminishingReturns(bonus * .02, 4); - bonus *= Math.ceil((target.value < 0 ? 1 : target.value + 1) * .075); - user.stats.exp += diminishingReturns(bonus, 75); - return user.party.quest.progress.up += diminishingReturns(bonus * .1, 50, 30); - } - }, - mpheal: { - text: t('spellWizardMPHealText'), - mana: 30, - lvl: 12, - target: 'party', - notes: t('spellWizardMPHealNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - var bonus; - bonus = Math.ceil(user._statsComputed.int * .1); - if (bonus > 25) { - bonus = 25; - } - return member.stats.mp += bonus; - }); - } - }, - earth: { - text: t('spellWizardEarthText'), - mana: 35, - lvl: 13, - target: 'party', - notes: t('spellWizardEarthNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - var _base; - if ((_base = member.stats.buffs).int == null) { - _base.int = 0; - } - return member.stats.buffs.int += Math.ceil(user._statsComputed.int * .05); - }); - } - }, - frost: { - text: t('spellWizardFrostText'), - mana: 40, - lvl: 14, - target: 'self', - notes: t('spellWizardFrostNotes'), - cast: function(user, target) { - return user.stats.buffs.streaks = true; - } - } - }, - warrior: { - smash: { - text: t('spellWarriorSmashText'), - mana: 10, - lvl: 11, - target: 'task', - notes: t('spellWarriorSmashNotes'), - cast: function(user, target) { - target.value += 2.5 * (user._statsComputed.str / (user._statsComputed.str + 50)) * user.fns.crit('con'); - return user.party.quest.progress.up += Math.ceil(user._statsComputed.str * .2); - } - }, - defensiveStance: { - text: t('spellWarriorDefensiveStanceText'), - mana: 25, - lvl: 12, - target: 'self', - notes: t('spellWarriorDefensiveStanceNotes'), - cast: function(user, target) { - var _base; - if ((_base = user.stats.buffs).con == null) { - _base.con = 0; - } - return user.stats.buffs.con += Math.ceil(user._statsComputed.con * .05); - } - }, - valorousPresence: { - text: t('spellWarriorValorousPresenceText'), - mana: 20, - lvl: 13, - target: 'party', - notes: t('spellWarriorValorousPresenceNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - var _base; - if ((_base = member.stats.buffs).str == null) { - _base.str = 0; - } - return member.stats.buffs.str += Math.ceil(user._statsComputed.str * .05); - }); - } - }, - intimidate: { - text: t('spellWarriorIntimidateText'), - mana: 15, - lvl: 14, - target: 'party', - notes: t('spellWarriorIntimidateNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - var _base; - if ((_base = member.stats.buffs).con == null) { - _base.con = 0; - } - return member.stats.buffs.con += Math.ceil(user._statsComputed.con * .03); - }); - } - } - }, - rogue: { - pickPocket: { - text: t('spellRoguePickPocketText'), - mana: 10, - lvl: 11, - target: 'task', - notes: t('spellRoguePickPocketNotes'), - cast: function(user, target) { - var bonus; - bonus = (target.value < 0 ? 1 : target.value + 2) + (user._statsComputed.per * 0.5); - return user.stats.gp += 25 * (bonus / (bonus + 75)); - } - }, - backStab: { - text: t('spellRogueBackStabText'), - mana: 15, - lvl: 12, - target: 'task', - notes: t('spellRogueBackStabNotes'), - cast: function(user, target) { - var bonus, _crit; - _crit = user.fns.crit('str', .3); - target.value += _crit * .03; - bonus = (target.value < 0 ? 1 : target.value + 1) * _crit; - user.stats.exp += bonus; - return user.stats.gp += bonus; - } - }, - toolsOfTrade: { - text: t('spellRogueToolsOfTradeText'), - mana: 25, - lvl: 13, - target: 'party', - notes: t('spellRogueToolsOfTradeNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - var _base; - if ((_base = member.stats.buffs).per == null) { - _base.per = 0; - } - return member.stats.buffs.per += Math.ceil(user._statsComputed.per * .03); - }); - } - }, - stealth: { - text: t('spellRogueStealthText'), - mana: 45, - lvl: 14, - target: 'self', - notes: t('spellRogueStealthNotes'), - cast: function(user, target) { - var _base; - if ((_base = user.stats.buffs).stealth == null) { - _base.stealth = 0; - } - return user.stats.buffs.stealth += Math.ceil(user.dailys.length * user._statsComputed.per / 100); - } - } - }, - healer: { - heal: { - text: t('spellHealerHealText'), - mana: 15, - lvl: 11, - target: 'self', - notes: t('spellHealerHealNotes'), - cast: function(user, target) { - user.stats.hp += (user._statsComputed.con + user._statsComputed.int + 5) * .075; - if (user.stats.hp > 50) { - return user.stats.hp = 50; - } - } - }, - brightness: { - text: t('spellHealerBrightnessText'), - mana: 15, - lvl: 12, - target: 'self', - notes: t('spellHealerBrightnessNotes'), - cast: function(user, target) { - return _.each(user.tasks, function(target) { - if (target.type === 'reward') { - return; - } - return target.value += 1.5 * (user._statsComputed.int / (user._statsComputed.int + 40)); - }); - } - }, - protectAura: { - text: t('spellHealerProtectAuraText'), - mana: 30, - lvl: 13, - target: 'party', - notes: t('spellHealerProtectAuraNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - var _base; - if ((_base = member.stats.buffs).con == null) { - _base.con = 0; - } - return member.stats.buffs.con += Math.ceil(user._statsComputed.con * .15); - }); - } - }, - heallAll: { - text: t('spellHealerHealAllText'), - mana: 25, - lvl: 14, - target: 'party', - notes: t('spellHealerHealAllNotes'), - cast: function(user, target) { - return _.each(target, function(member) { - member.stats.hp += (user._statsComputed.con + user._statsComputed.int + 5) * .04; - if (member.stats.hp > 50) { - return member.stats.hp = 50; - } - }); - } - } - }, - special: { - snowball: { - text: t('spellSpecialSnowballAuraText'), - mana: 0, - value: 15, - target: 'user', - notes: t('spellSpecialSnowballAuraNotes'), - cast: function(user, target) { - var _base; - target.stats.buffs.snowball = true; - if ((_base = target.achievements).snowball == null) { - _base.snowball = 0; - } - target.achievements.snowball++; - return user.items.special.snowball--; - } - }, - salt: { - text: t('spellSpecialSaltText'), - mana: 0, - value: 5, - immediateUse: true, - target: 'self', - notes: t('spellSpecialSaltNotes'), - cast: function(user, target) { - user.stats.buffs.snowball = false; - return user.stats.gp -= 5; - } - }, - spookDust: { - text: t('spellSpecialSpookDustText'), - mana: 0, - value: 15, - target: 'user', - notes: t('spellSpecialSpookDustNotes'), - cast: function(user, target) { - var _base; - target.stats.buffs.spookDust = true; - if ((_base = target.achievements).spookDust == null) { - _base.spookDust = 0; - } - target.achievements.spookDust++; - return user.items.special.spookDust--; - } - }, - opaquePotion: { - text: t('spellSpecialOpaquePotionText'), - mana: 0, - value: 5, - immediateUse: true, - target: 'self', - notes: t('spellSpecialOpaquePotionNotes'), - cast: function(user, target) { - user.stats.buffs.spookDust = false; - return user.stats.gp -= 5; - } - }, - nye: { - text: t('nyeCard'), - mana: 0, - value: 10, - immediateUse: true, - silent: true, - target: 'user', - notes: t('nyeCardNotes'), - cast: function(user, target) { - var _base; - if (user === target) { - if ((_base = user.achievements).nye == null) { - _base.nye = 0; - } - user.achievements.nye++; - } else { - _.each([user, target], function(t) { - var _base1; - if ((_base1 = t.achievements).nye == null) { - _base1.nye = 0; - } - return t.achievements.nye++; - }); - } - if (!target.items.special.nyeReceived) { - target.items.special.nyeReceived = []; - } - target.items.special.nyeReceived.push(user.profile.name); - if (typeof target.markModified === "function") { - target.markModified('items.special.nyeReceived'); - } - return user.stats.gp -= 10; - } - }, - valentine: { - text: t('valentineCard'), - mana: 0, - value: 10, - immediateUse: true, - silent: true, - target: 'user', - notes: t('valentineCardNotes'), - cast: function(user, target) { - var _base; - if (user === target) { - if ((_base = user.achievements).valentine == null) { - _base.valentine = 0; - } - user.achievements.valentine++; - } else { - _.each([user, target], function(t) { - var _base1; - if ((_base1 = t.achievements).valentine == null) { - _base1.valentine = 0; - } - return t.achievements.valentine++; - }); - } - if (!target.items.special.valentineReceived) { - target.items.special.valentineReceived = []; - } - target.items.special.valentineReceived.push(user.profile.name); - if (typeof target.markModified === "function") { - target.markModified('items.special.valentineReceived'); - } - return user.stats.gp -= 10; - } - } - } -}; - -_.each(api.spells, function(spellClass) { - return _.each(spellClass, function(spell, key) { - var _cast; - spell.key = key; - _cast = spell.cast; - return spell.cast = function(user, target) { - _cast(user, target); - return user.stats.mp -= spell.mana; - }; - }); -}); - -api.special = api.spells.special; - - -/* - --------------------------------------------------------------- - Drops - --------------------------------------------------------------- - */ - -api.dropEggs = { - Wolf: { - text: t('dropEggWolfText'), - adjective: t('dropEggWolfAdjective') - }, - TigerCub: { - text: t('dropEggTigerCubText'), - mountText: t('dropEggTigerCubMountText'), - adjective: t('dropEggTigerCubAdjective') - }, - PandaCub: { - text: t('dropEggPandaCubText'), - mountText: t('dropEggPandaCubMountText'), - adjective: t('dropEggPandaCubAdjective') - }, - LionCub: { - text: t('dropEggLionCubText'), - mountText: t('dropEggLionCubMountText'), - adjective: t('dropEggLionCubAdjective') - }, - Fox: { - text: t('dropEggFoxText'), - adjective: t('dropEggFoxAdjective') - }, - FlyingPig: { - text: t('dropEggFlyingPigText'), - adjective: t('dropEggFlyingPigAdjective') - }, - Dragon: { - text: t('dropEggDragonText'), - adjective: t('dropEggDragonAdjective') - }, - Cactus: { - text: t('dropEggCactusText'), - adjective: t('dropEggCactusAdjective') - }, - BearCub: { - text: t('dropEggBearCubText'), - mountText: t('dropEggBearCubMountText'), - adjective: t('dropEggBearCubAdjective') - } -}; - -_.each(api.dropEggs, function(egg, key) { - return _.defaults(egg, { - canBuy: true, - value: 3, - key: key, - notes: t('eggNotes', { - eggText: egg.text, - eggAdjective: egg.adjective - }), - mountText: egg.text - }); -}); - -api.questEggs = { - Gryphon: { - text: t('questEggGryphonText'), - adjective: t('questEggGryphonAdjective'), - canBuy: false - }, - Hedgehog: { - text: t('questEggHedgehogText'), - adjective: t('questEggHedgehogAdjective'), - canBuy: false - }, - Deer: { - text: t('questEggDeerText'), - adjective: t('questEggDeerAdjective'), - canBuy: false - }, - Egg: { - text: t('questEggEggText'), - adjective: t('questEggEggAdjective'), - canBuy: false, - noMount: true - }, - Rat: { - text: t('questEggRatText'), - adjective: t('questEggRatAdjective'), - canBuy: false - }, - Octopus: { - text: t('questEggOctopusText'), - adjective: t('questEggOctopusAdjective'), - canBuy: false - }, - Seahorse: { - text: t('questEggSeahorseText'), - adjective: t('questEggSeahorseAdjective'), - canBuy: false - }, - Parrot: { - text: t('questEggParrotText'), - adjective: t('questEggParrotAdjective'), - canBuy: false - }, - Rooster: { - text: t('questEggRoosterText'), - adjective: t('questEggRoosterAdjective'), - canBuy: false - }, - Spider: { - text: t('questEggSpiderText'), - adjective: t('questEggSpiderAdjective'), - canBuy: false - }, - Owl: { - text: t('questEggOwlText'), - adjective: t('questEggOwlAdjective'), - canBuy: false - }, - Penguin: { - text: t('questEggPenguinText'), - adjective: t('questEggPenguinAdjective'), - canBuy: false - }, - TRex: { - text: t('questEggTRexText'), - adjective: t('questEggTRexAdjective'), - canBuy: false - }, - Rock: { - text: t('questEggRockText'), - adjective: t('questEggRockAdjective'), - canBuy: false - } -}; - -_.each(api.questEggs, function(egg, key) { - return _.defaults(egg, { - canBuy: false, - value: 3, - key: key, - notes: t('eggNotes', { - eggText: egg.text, - eggAdjective: egg.adjective - }), - mountText: egg.text - }); -}); - -api.eggs = _.assign(_.cloneDeep(api.dropEggs), api.questEggs); - -api.specialPets = { - 'Wolf-Veteran': 'veteranWolf', - 'Wolf-Cerberus': 'cerberusPup', - 'Dragon-Hydra': 'hydra', - 'Turkey-Base': 'turkey', - 'BearCub-Polar': 'polarBearPup', - 'MantisShrimp-Base': 'mantisShrimp', - 'JackOLantern-Base': 'jackolantern', - 'Mammoth-Base': 'mammoth' -}; - -api.specialMounts = { - 'BearCub-Polar': 'polarBear', - 'LionCub-Ethereal': 'etherealLion', - 'MantisShrimp-Base': 'mantisShrimp', - 'Turkey-Base': 'turkey', - 'Mammoth-Base': 'mammoth' -}; - -api.hatchingPotions = { - Base: { - value: 2, - text: t('hatchingPotionBase') - }, - White: { - value: 2, - text: t('hatchingPotionWhite') - }, - Desert: { - value: 2, - text: t('hatchingPotionDesert') - }, - Red: { - value: 3, - text: t('hatchingPotionRed') - }, - Shade: { - value: 3, - text: t('hatchingPotionShade') - }, - Skeleton: { - value: 3, - text: t('hatchingPotionSkeleton') - }, - Zombie: { - value: 4, - text: t('hatchingPotionZombie') - }, - CottonCandyPink: { - value: 4, - text: t('hatchingPotionCottonCandyPink') - }, - CottonCandyBlue: { - value: 4, - text: t('hatchingPotionCottonCandyBlue') - }, - Golden: { - value: 5, - text: t('hatchingPotionGolden') - } -}; - -_.each(api.hatchingPotions, function(pot, key) { - return _.defaults(pot, { - key: key, - value: 2, - notes: t('hatchingPotionNotes', { - potText: pot.text - }) - }); -}); - -api.pets = _.transform(api.dropEggs, function(m, egg) { - return _.defaults(m, _.transform(api.hatchingPotions, function(m2, pot) { - return m2[egg.key + "-" + pot.key] = true; - })); -}); - -api.questPets = _.transform(api.questEggs, function(m, egg) { - return _.defaults(m, _.transform(api.hatchingPotions, function(m2, pot) { - return m2[egg.key + "-" + pot.key] = true; - })); -}); - -api.mounts = _.transform(api.dropEggs, function(m, egg) { - return _.defaults(m, _.transform(api.hatchingPotions, function(m2, pot) { - return m2[egg.key + "-" + pot.key] = true; - })); -}); - -api.questMounts = _.transform(api.questEggs, function(m, egg) { - return _.defaults(m, _.transform(api.hatchingPotions, function(m2, pot) { - return m2[egg.key + "-" + pot.key] = true; - })); -}); - -api.food = { - Meat: { - canBuy: true, - canDrop: true, - text: t('foodMeat'), - target: 'Base', - article: '' - }, - Milk: { - canBuy: true, - canDrop: true, - text: t('foodMilk'), - target: 'White', - article: '' - }, - Potatoe: { - canBuy: true, - canDrop: true, - text: t('foodPotatoe'), - target: 'Desert', - article: 'a ' - }, - Strawberry: { - canBuy: true, - canDrop: true, - text: t('foodStrawberry'), - target: 'Red', - article: 'a ' - }, - Chocolate: { - canBuy: true, - canDrop: true, - text: t('foodChocolate'), - target: 'Shade', - article: '' - }, - Fish: { - canBuy: true, - canDrop: true, - text: t('foodFish'), - target: 'Skeleton', - article: 'a ' - }, - RottenMeat: { - canBuy: true, - canDrop: true, - text: t('foodRottenMeat'), - target: 'Zombie', - article: '' - }, - CottonCandyPink: { - canBuy: true, - canDrop: true, - text: t('foodCottonCandyPink'), - target: 'CottonCandyPink', - article: '' - }, - CottonCandyBlue: { - canBuy: true, - canDrop: true, - text: t('foodCottonCandyBlue'), - target: 'CottonCandyBlue', - article: '' - }, - Honey: { - canBuy: true, - canDrop: true, - text: t('foodHoney'), - target: 'Golden', - article: '' - }, - Saddle: { - canBuy: true, - canDrop: false, - text: t('foodSaddleText'), - value: 5, - notes: t('foodSaddleNotes') - }, - Cake_Skeleton: { - canBuy: false, - canDrop: false, - text: t('foodCakeSkeleton'), - target: 'Skeleton', - article: '' - }, - Cake_Base: { - canBuy: false, - canDrop: false, - text: t('foodCakeBase'), - target: 'Base', - article: '' - }, - Cake_CottonCandyBlue: { - canBuy: false, - canDrop: false, - text: t('foodCakeCottonCandyBlue'), - target: 'CottonCandyBlue', - article: '' - }, - Cake_CottonCandyPink: { - canBuy: false, - canDrop: false, - text: t('foodCakeCottonCandyPink'), - target: 'CottonCandyPink', - article: '' - }, - Cake_Shade: { - canBuy: false, - canDrop: false, - text: t('foodCakeShade'), - target: 'Shade', - article: '' - }, - Cake_White: { - canBuy: false, - canDrop: false, - text: t('foodCakeWhite'), - target: 'White', - article: '' - }, - Cake_Golden: { - canBuy: false, - canDrop: false, - text: t('foodCakeGolden'), - target: 'Golden', - article: '' - }, - Cake_Zombie: { - canBuy: false, - canDrop: false, - text: t('foodCakeZombie'), - target: 'Zombie', - article: '' - }, - Cake_Desert: { - canBuy: false, - canDrop: false, - text: t('foodCakeDesert'), - target: 'Desert', - article: '' - }, - Cake_Red: { - canBuy: false, - canDrop: false, - text: t('foodCakeRed'), - target: 'Red', - article: '' - }, - Candy_Skeleton: { - canBuy: false, - canDrop: false, - text: t('foodCandySkeleton'), - target: 'Skeleton', - article: '' - }, - Candy_Base: { - canBuy: false, - canDrop: false, - text: t('foodCandyBase'), - target: 'Base', - article: '' - }, - Candy_CottonCandyBlue: { - canBuy: false, - canDrop: false, - text: t('foodCandyCottonCandyBlue'), - target: 'CottonCandyBlue', - article: '' - }, - Candy_CottonCandyPink: { - canBuy: false, - canDrop: false, - text: t('foodCandyCottonCandyPink'), - target: 'CottonCandyPink', - article: '' - }, - Candy_Shade: { - canBuy: false, - canDrop: false, - text: t('foodCandyShade'), - target: 'Shade', - article: '' - }, - Candy_White: { - canBuy: false, - canDrop: false, - text: t('foodCandyWhite'), - target: 'White', - article: '' - }, - Candy_Golden: { - canBuy: false, - canDrop: false, - text: t('foodCandyGolden'), - target: 'Golden', - article: '' - }, - Candy_Zombie: { - canBuy: false, - canDrop: false, - text: t('foodCandyZombie'), - target: 'Zombie', - article: '' - }, - Candy_Desert: { - canBuy: false, - canDrop: false, - text: t('foodCandyDesert'), - target: 'Desert', - article: '' - }, - Candy_Red: { - canBuy: false, - canDrop: false, - text: t('foodCandyRed'), - target: 'Red', - article: '' - } -}; - -_.each(api.food, function(food, key) { - return _.defaults(food, { - value: 1, - key: key, - notes: t('foodNotes') - }); -}); - -api.quests = { - dilatory: { - text: t("questDilatoryText"), - notes: t("questDilatoryNotes"), - completion: t("questDilatoryCompletion"), - value: 0, - canBuy: false, - boss: { - name: t("questDilatoryBoss"), - hp: 5000000, - str: 1, - def: 1, - rage: { - title: t("questDilatoryBossRageTitle"), - description: t("questDilatoryBossRageDescription"), - value: 4000000, - tavern: t('questDilatoryBossRageTavern'), - stables: t('questDilatoryBossRageStables'), - market: t('questDilatoryBossRageMarket') - } - }, - drop: { - items: [ - { - type: 'pets', - key: 'MantisShrimp-Base', - text: t('questDilatoryDropMantisShrimpPet') - }, { - type: 'mounts', - key: 'MantisShrimp-Base', - text: t('questDilatoryDropMantisShrimpMount') - }, { - type: 'food', - key: 'Meat', - text: t('foodMeat') - }, { - type: 'food', - key: 'Milk', - text: t('foodMilk') - }, { - type: 'food', - key: 'Potatoe', - text: t('foodPotatoe') - }, { - type: 'food', - key: 'Strawberry', - text: t('foodStrawberry') - }, { - type: 'food', - key: 'Chocolate', - text: t('foodChocolate') - }, { - type: 'food', - key: 'Fish', - text: t('foodFish') - }, { - type: 'food', - key: 'RottenMeat', - text: t('foodRottenMeat') - }, { - type: 'food', - key: 'CottonCandyPink', - text: t('foodCottonCandyPink') - }, { - type: 'food', - key: 'CottonCandyBlue', - text: t('foodCottonCandyBlue') - }, { - type: 'food', - key: 'Honey', - text: t('foodHoney') - } - ], - gp: 0, - exp: 0 - } - }, - stressbeast: { - text: t("questStressbeastText"), - notes: t("questStressbeastNotes"), - completion: t("questStressbeastCompletion"), - completionChat: t("questStressbeastCompletionChat"), - value: 0, - canBuy: false, - boss: { - name: t("questStressbeastBoss"), - hp: 2750000, - str: 1, - def: 1, - rage: { - title: t("questStressbeastBossRageTitle"), - description: t("questStressbeastBossRageDescription"), - value: 1450000, - healing: .3, - stables: t('questStressbeastBossRageStables'), - bailey: t('questStressbeastBossRageBailey'), - guide: t('questStressbeastBossRageGuide') - }, - desperation: { - threshold: 500000, - str: 3.5, - def: 2, - text: t('questStressbeastDesperation') - } - }, - drop: { - items: [ - { - type: 'pets', - key: 'Mammoth-Base', - text: t('questStressbeastDropMammothPet') - }, { - type: 'mounts', - key: 'Mammoth-Base', - text: t('questStressbeastDropMammothMount') - }, { - type: 'food', - key: 'Meat', - text: t('foodMeat') - }, { - type: 'food', - key: 'Milk', - text: t('foodMilk') - }, { - type: 'food', - key: 'Potatoe', - text: t('foodPotatoe') - }, { - type: 'food', - key: 'Strawberry', - text: t('foodStrawberry') - }, { - type: 'food', - key: 'Chocolate', - text: t('foodChocolate') - }, { - type: 'food', - key: 'Fish', - text: t('foodFish') - }, { - type: 'food', - key: 'RottenMeat', - text: t('foodRottenMeat') - }, { - type: 'food', - key: 'CottonCandyPink', - text: t('foodCottonCandyPink') - }, { - type: 'food', - key: 'CottonCandyBlue', - text: t('foodCottonCandyBlue') - }, { - type: 'food', - key: 'Honey', - text: t('foodHoney') - } - ], - gp: 0, - exp: 0 - } - }, - evilsanta: { - canBuy: false, - text: t('questEvilSantaText'), - notes: t('questEvilSantaNotes'), - completion: t('questEvilSantaCompletion'), - value: 4, - boss: { - name: t('questEvilSantaBoss'), - hp: 300, - str: 1 - }, - drop: { - items: [ - { - type: 'mounts', - key: 'BearCub-Polar', - text: t('questEvilSantaDropBearCubPolarMount') - } - ], - gp: 20, - exp: 100 - } - }, - evilsanta2: { - canBuy: false, - text: t('questEvilSanta2Text'), - notes: t('questEvilSanta2Notes'), - completion: t('questEvilSanta2Completion'), - value: 4, - previous: 'evilsanta', - collect: { - tracks: { - text: t('questEvilSanta2CollectTracks'), - count: 20 - }, - branches: { - text: t('questEvilSanta2CollectBranches'), - count: 10 - } - }, - drop: { - items: [ - { - type: 'pets', - key: 'BearCub-Polar', - text: t('questEvilSanta2DropBearCubPolarPet') - } - ], - gp: 20, - exp: 100 - } - }, - gryphon: { - text: t('questGryphonText'), - notes: t('questGryphonNotes'), - completion: t('questGryphonCompletion'), - value: 4, - boss: { - name: t('questGryphonBoss'), - hp: 300, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Gryphon', - text: t('questGryphonDropGryphonEgg') - }, { - type: 'eggs', - key: 'Gryphon', - text: t('questGryphonDropGryphonEgg') - }, { - type: 'eggs', - key: 'Gryphon', - text: t('questGryphonDropGryphonEgg') - } - ], - gp: 25, - exp: 125 - } - }, - hedgehog: { - text: t('questHedgehogText'), - notes: t('questHedgehogNotes'), - completion: t('questHedgehogCompletion'), - value: 4, - boss: { - name: t('questHedgehogBoss'), - hp: 400, - str: 1.25 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Hedgehog', - text: t('questHedgehogDropHedgehogEgg') - }, { - type: 'eggs', - key: 'Hedgehog', - text: t('questHedgehogDropHedgehogEgg') - }, { - type: 'eggs', - key: 'Hedgehog', - text: t('questHedgehogDropHedgehogEgg') - } - ], - gp: 30, - exp: 125 - } - }, - ghost_stag: { - text: t('questGhostStagText'), - notes: t('questGhostStagNotes'), - completion: t('questGhostStagCompletion'), - value: 4, - boss: { - name: t('questGhostStagBoss'), - hp: 1200, - str: 2.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Deer', - text: t('questGhostStagDropDeerEgg') - }, { - type: 'eggs', - key: 'Deer', - text: t('questGhostStagDropDeerEgg') - }, { - type: 'eggs', - key: 'Deer', - text: t('questGhostStagDropDeerEgg') - } - ], - gp: 80, - exp: 800 - } - }, - vice1: { - text: t('questVice1Text'), - notes: t('questVice1Notes'), - value: 4, - lvl: 30, - boss: { - name: t('questVice1Boss'), - hp: 750, - str: 1.5 - }, - drop: { - items: [ - { - type: 'quests', - key: "vice2", - text: t('questVice1DropVice2Quest') - } - ], - gp: 20, - exp: 100 - } - }, - vice2: { - text: t('questVice2Text'), - notes: t('questVice2Notes'), - value: 4, - lvl: 35, - previous: 'vice1', - collect: { - lightCrystal: { - text: t('questVice2CollectLightCrystal'), - count: 45 - } - }, - drop: { - items: [ - { - type: 'quests', - key: 'vice3', - text: t('questVice2DropVice3Quest') - } - ], - gp: 20, - exp: 75 - } - }, - vice3: { - text: t('questVice3Text'), - notes: t('questVice3Notes'), - completion: t('questVice3Completion'), - previous: 'vice2', - value: 4, - lvl: 40, - boss: { - name: t('questVice3Boss'), - hp: 1500, - str: 3 - }, - drop: { - items: [ - { - type: 'gear', - key: "weapon_special_2", - text: t('questVice3DropWeaponSpecial2') - }, { - type: 'eggs', - key: 'Dragon', - text: t('questVice3DropDragonEgg') - }, { - type: 'eggs', - key: 'Dragon', - text: t('questVice3DropDragonEgg') - }, { - type: 'hatchingPotions', - key: 'Shade', - text: t('questVice3DropShadeHatchingPotion') - }, { - type: 'hatchingPotions', - key: 'Shade', - text: t('questVice3DropShadeHatchingPotion') - } - ], - gp: 100, - exp: 1000 - } - }, - egg: { - text: t('questEggHuntText'), - notes: t('questEggHuntNotes'), - completion: t('questEggHuntCompletion'), - value: 1, - canBuy: false, - collect: { - plainEgg: { - text: t('questEggHuntCollectPlainEgg'), - count: 100 - } - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - }, { - type: 'eggs', - key: 'Egg', - text: t('questEggHuntDropPlainEgg') - } - ], - gp: 0, - exp: 0 - } - }, - rat: { - text: t('questRatText'), - notes: t('questRatNotes'), - completion: t('questRatCompletion'), - value: 4, - boss: { - name: t('questRatBoss'), - hp: 1200, - str: 2.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Rat', - text: t('questRatDropRatEgg') - }, { - type: 'eggs', - key: 'Rat', - text: t('questRatDropRatEgg') - }, { - type: 'eggs', - key: 'Rat', - text: t('questRatDropRatEgg') - } - ], - gp: 80, - exp: 800 - } - }, - octopus: { - text: t('questOctopusText'), - notes: t('questOctopusNotes'), - completion: t('questOctopusCompletion'), - value: 4, - boss: { - name: t('questOctopusBoss'), - hp: 1200, - str: 2.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Octopus', - text: t('questOctopusDropOctopusEgg') - }, { - type: 'eggs', - key: 'Octopus', - text: t('questOctopusDropOctopusEgg') - }, { - type: 'eggs', - key: 'Octopus', - text: t('questOctopusDropOctopusEgg') - } - ], - gp: 80, - exp: 800 - } - }, - dilatory_derby: { - text: t('questSeahorseText'), - notes: t('questSeahorseNotes'), - completion: t('questSeahorseCompletion'), - value: 4, - boss: { - name: t('questSeahorseBoss'), - hp: 300, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Seahorse', - text: t('questSeahorseDropSeahorseEgg') - }, { - type: 'eggs', - key: 'Seahorse', - text: t('questSeahorseDropSeahorseEgg') - }, { - type: 'eggs', - key: 'Seahorse', - text: t('questSeahorseDropSeahorseEgg') - } - ], - gp: 25, - exp: 125 - } - }, - atom1: { - text: t('questAtom1Text'), - notes: t('questAtom1Notes'), - value: 4, - lvl: 15, - collect: { - soapBars: { - text: t('questAtom1CollectSoapBars'), - count: 20 - } - }, - drop: { - items: [ - { - type: 'quests', - key: "atom2", - text: t('questAtom1Drop') - } - ], - gp: 7, - exp: 50 - } - }, - atom2: { - text: t('questAtom2Text'), - notes: t('questAtom2Notes'), - previous: 'atom1', - value: 4, - lvl: 15, - boss: { - name: t('questAtom2Boss'), - hp: 300, - str: 1 - }, - drop: { - items: [ - { - type: 'quests', - key: "atom3", - text: t('questAtom2Drop') - } - ], - gp: 20, - exp: 100 - } - }, - atom3: { - text: t('questAtom3Text'), - notes: t('questAtom3Notes'), - previous: 'atom2', - completion: t('questAtom3Completion'), - value: 4, - lvl: 15, - boss: { - name: t('questAtom3Boss'), - hp: 800, - str: 1.5 - }, - drop: { - items: [ - { - type: 'gear', - key: "head_special_2", - text: t('headSpecial2Text') - }, { - type: 'hatchingPotions', - key: "Base", - text: t('questAtom3DropPotion') - }, { - type: 'hatchingPotions', - key: "Base", - text: t('questAtom3DropPotion') - } - ], - gp: 25, - exp: 125 - } - }, - harpy: { - text: t('questHarpyText'), - notes: t('questHarpyNotes'), - completion: t('questHarpyCompletion'), - value: 4, - boss: { - name: t('questHarpyBoss'), - hp: 600, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Parrot', - text: t('questHarpyDropParrotEgg') - }, { - type: 'eggs', - key: 'Parrot', - text: t('questHarpyDropParrotEgg') - }, { - type: 'eggs', - key: 'Parrot', - text: t('questHarpyDropParrotEgg') - } - ], - gp: 43, - exp: 350 - } - }, - rooster: { - text: t('questRoosterText'), - notes: t('questRoosterNotes'), - completion: t('questRoosterCompletion'), - value: 4, - boss: { - name: t('questRoosterBoss'), - hp: 300, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Rooster', - text: t('questRoosterDropRoosterEgg') - }, { - type: 'eggs', - key: 'Rooster', - text: t('questRoosterDropRoosterEgg') - }, { - type: 'eggs', - key: 'Rooster', - text: t('questRoosterDropRoosterEgg') - } - ], - gp: 25, - exp: 125 - } - }, - spider: { - text: t('questSpiderText'), - notes: t('questSpiderNotes'), - completion: t('questSpiderCompletion'), - value: 4, - boss: { - name: t('questSpiderBoss'), - hp: 400, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Spider', - text: t('questSpiderDropSpiderEgg') - }, { - type: 'eggs', - key: 'Spider', - text: t('questSpiderDropSpiderEgg') - }, { - type: 'eggs', - key: 'Spider', - text: t('questSpiderDropSpiderEgg') - } - ], - gp: 31, - exp: 200 - } - }, - moonstone1: { - text: t('questMoonstone1Text'), - notes: t('questMoonstone1Notes'), - value: 4, - lvl: 60, - collect: { - moonstone: { - text: t('questMoonstone1CollectMoonstone'), - count: 500 - } - }, - drop: { - items: [ - { - type: 'quests', - key: "moonstone2", - text: t('questMoonstone1DropMoonstone2Quest') - } - ], - gp: 50, - exp: 100 - } - }, - moonstone2: { - text: t('questMoonstone2Text'), - notes: t('questMoonstone2Notes'), - value: 4, - lvl: 65, - previous: 'moonstone1', - boss: { - name: t('questMoonstone2Boss'), - hp: 1500, - str: 3 - }, - drop: { - items: [ - { - type: 'quests', - key: 'moonstone3', - text: t('questMoonstone2DropMoonstone3Quest') - } - ], - gp: 500, - exp: 1000 - } - }, - moonstone3: { - text: t('questMoonstone3Text'), - notes: t('questMoonstone3Notes'), - completion: t('questMoonstone3Completion'), - previous: 'moonstone2', - value: 4, - lvl: 70, - boss: { - name: t('questMoonstone3Boss'), - hp: 2000, - str: 3.5 - }, - drop: { - items: [ - { - type: 'gear', - key: "armor_special_2", - text: t('armorSpecial2Text') - }, { - type: 'food', - key: 'RottenMeat', - text: t('questMoonstone3DropRottenMeat') - }, { - type: 'food', - key: 'RottenMeat', - text: t('questMoonstone3DropRottenMeat') - }, { - type: 'food', - key: 'RottenMeat', - text: t('questMoonstone3DropRottenMeat') - }, { - type: 'food', - key: 'RottenMeat', - text: t('questMoonstone3DropRottenMeat') - }, { - type: 'food', - key: 'RottenMeat', - text: t('questMoonstone3DropRottenMeat') - }, { - type: 'hatchingPotions', - key: 'Zombie', - text: t('questMoonstone3DropZombiePotion') - }, { - type: 'hatchingPotions', - key: 'Zombie', - text: t('questMoonstone3DropZombiePotion') - }, { - type: 'hatchingPotions', - key: 'Zombie', - text: t('questMoonstone3DropZombiePotion') - } - ], - gp: 900, - exp: 1500 - } - }, - goldenknight1: { - text: t('questGoldenknight1Text'), - notes: t('questGoldenknight1Notes'), - value: 4, - lvl: 40, - collect: { - testimony: { - text: t('questGoldenknight1CollectTestimony'), - count: 300 - } - }, - drop: { - items: [ - { - type: 'quests', - key: "goldenknight2", - text: t('questGoldenknight1DropGoldenknight2Quest') - } - ], - gp: 15, - exp: 120 - } - }, - goldenknight2: { - text: t('questGoldenknight2Text'), - notes: t('questGoldenknight2Notes'), - value: 4, - previous: 'goldenknight1', - lvl: 45, - boss: { - name: t('questGoldenknight2Boss'), - hp: 1000, - str: 3 - }, - drop: { - items: [ - { - type: 'quests', - key: 'goldenknight3', - text: t('questGoldenknight2DropGoldenknight3Quest') - } - ], - gp: 75, - exp: 750 - } - }, - goldenknight3: { - text: t('questGoldenknight3Text'), - notes: t('questGoldenknight3Notes'), - completion: t('questGoldenknight3Completion'), - previous: 'goldenknight2', - value: 4, - lvl: 50, - boss: { - name: t('questGoldenknight3Boss'), - hp: 1700, - str: 3.5 - }, - drop: { - items: [ - { - type: 'food', - key: 'Honey', - text: t('questGoldenknight3DropHoney') - }, { - type: 'food', - key: 'Honey', - text: t('questGoldenknight3DropHoney') - }, { - type: 'food', - key: 'Honey', - text: t('questGoldenknight3DropHoney') - }, { - type: 'hatchingPotions', - key: 'Golden', - text: t('questGoldenknight3DropGoldenPotion') - }, { - type: 'hatchingPotions', - key: 'Golden', - text: t('questGoldenknight3DropGoldenPotion') - }, { - type: 'gear', - key: 'shield_special_goldenknight', - text: t('questGoldenknight3DropWeapon') - } - ], - gp: 900, - exp: 1500 - } - }, - basilist: { - text: t('questBasilistText'), - notes: t('questBasilistNotes'), - completion: t('questBasilistCompletion'), - canBuy: false, - value: 4, - boss: { - name: t('questBasilistBoss'), - hp: 100, - str: 0.5 - }, - drop: { - gp: 8, - exp: 42 - } - }, - owl: { - text: t('questOwlText'), - notes: t('questOwlNotes'), - completion: t('questOwlCompletion'), - value: 4, - boss: { - name: t('questOwlBoss'), - hp: 500, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Owl', - text: t('questOwlDropOwlEgg') - }, { - type: 'eggs', - key: 'Owl', - text: t('questOwlDropOwlEgg') - }, { - type: 'eggs', - key: 'Owl', - text: t('questOwlDropOwlEgg') - } - ], - gp: 37, - exp: 275 - } - }, - penguin: { - text: t('questPenguinText'), - notes: t('questPenguinNotes'), - completion: t('questPenguinCompletion'), - value: 4, - boss: { - name: t('questPenguinBoss'), - hp: 400, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Penguin', - text: t('questPenguinDropPenguinEgg') - }, { - type: 'eggs', - key: 'Penguin', - text: t('questPenguinDropPenguinEgg') - }, { - type: 'eggs', - key: 'Penguin', - text: t('questPenguinDropPenguinEgg') - } - ], - gp: 31, - exp: 200 - } - }, - trex: { - text: t('questTRexText'), - notes: t('questTRexNotes'), - completion: t('questTRexCompletion'), - value: 4, - boss: { - name: t('questTRexBoss'), - hp: 800, - str: 2 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'TRex', - text: t('questTRexDropTRexEgg') - }, { - type: 'eggs', - key: 'TRex', - text: t('questTRexDropTRexEgg') - }, { - type: 'eggs', - key: 'TRex', - text: t('questTRexDropTRexEgg') - } - ], - gp: 55, - exp: 500 - } - }, - trex_undead: { - text: t('questTRexUndeadText'), - notes: t('questTRexUndeadNotes'), - completion: t('questTRexUndeadCompletion'), - value: 4, - boss: { - name: t('questTRexUndeadBoss'), - hp: 500, - str: 2, - rage: { - title: t("questTRexUndeadRageTitle"), - description: t("questTRexUndeadRageDescription"), - value: 50, - healing: .3, - effect: t('questTRexUndeadRageEffect') - } - }, - drop: { - items: [ - { - type: 'eggs', - key: 'TRex', - text: t('questTRexDropTRexEgg') - }, { - type: 'eggs', - key: 'TRex', - text: t('questTRexDropTRexEgg') - }, { - type: 'eggs', - key: 'TRex', - text: t('questTRexDropTRexEgg') - } - ], - gp: 55, - exp: 500 - } - }, - rock: { - text: t('questRockText'), - notes: t('questRockNotes'), - completion: t('questRockCompletion'), - value: 4, - boss: { - name: t('questRockBoss'), - hp: 400, - str: 1.5 - }, - drop: { - items: [ - { - type: 'eggs', - key: 'Rock', - text: t('questRockDropRockEgg') - }, { - type: 'eggs', - key: 'Rock', - text: t('questRockDropRockEgg') - }, { - type: 'eggs', - key: 'Rock', - text: t('questRockDropRockEgg') - } - ], - gp: 31, - exp: 200 - } - } -}; - -_.each(api.quests, function(v, key) { - var b; - _.defaults(v, { - key: key, - canBuy: true - }); - b = v.boss; - if (b) { - _.defaults(b, { - str: 1, - def: 1 - }); - if (b.rage) { - return _.defaults(b.rage, { - title: t('bossRageTitle'), - description: t('bossRageDescription') - }); - } - } -}); - -api.backgrounds = { - backgrounds062014: { - beach: { - text: t('backgroundBeachText'), - notes: t('backgroundBeachNotes') - }, - fairy_ring: { - text: t('backgroundFairyRingText'), - notes: t('backgroundFairyRingNotes') - }, - forest: { - text: t('backgroundForestText'), - notes: t('backgroundForestNotes') - } - }, - backgrounds072014: { - open_waters: { - text: t('backgroundOpenWatersText'), - notes: t('backgroundOpenWatersNotes') - }, - coral_reef: { - text: t('backgroundCoralReefText'), - notes: t('backgroundCoralReefNotes') - }, - seafarer_ship: { - text: t('backgroundSeafarerShipText'), - notes: t('backgroundSeafarerShipNotes') - } - }, - backgrounds082014: { - volcano: { - text: t('backgroundVolcanoText'), - notes: t('backgroundVolcanoNotes') - }, - clouds: { - text: t('backgroundCloudsText'), - notes: t('backgroundCloudsNotes') - }, - dusty_canyons: { - text: t('backgroundDustyCanyonsText'), - notes: t('backgroundDustyCanyonsNotes') - } - }, - backgrounds092014: { - thunderstorm: { - text: t('backgroundThunderstormText'), - notes: t('backgroundThunderstormNotes') - }, - autumn_forest: { - text: t('backgroundAutumnForestText'), - notes: t('backgroundAutumnForestNotes') - }, - harvest_fields: { - text: t('backgroundHarvestFieldsText'), - notes: t('backgroundHarvestFieldsNotes') - } - }, - backgrounds102014: { - graveyard: { - text: t('backgroundGraveyardText'), - notes: t('backgroundGraveyardNotes') - }, - haunted_house: { - text: t('backgroundHauntedHouseText'), - notes: t('backgroundHauntedHouseNotes') - }, - pumpkin_patch: { - text: t('backgroundPumpkinPatchText'), - notes: t('backgroundPumpkinPatchNotes') - } - }, - backgrounds112014: { - harvest_feast: { - text: t('backgroundHarvestFeastText'), - notes: t('backgroundHarvestFeastNotes') - }, - sunset_meadow: { - text: t('backgroundSunsetMeadowText'), - notes: t('backgroundSunsetMeadowNotes') - }, - starry_skies: { - text: t('backgroundStarrySkiesText'), - notes: t('backgroundStarrySkiesNotes') - } - }, - backgrounds122014: { - iceberg: { - text: t('backgroundIcebergText'), - notes: t('backgroundIcebergNotes') - }, - twinkly_lights: { - text: t('backgroundTwinklyLightsText'), - notes: t('backgroundTwinklyLightsNotes') - }, - south_pole: { - text: t('backgroundSouthPoleText'), - notes: t('backgroundSouthPoleNotes') - } - }, - backgrounds012015: { - ice_cave: { - text: t('backgroundIceCaveText'), - notes: t('backgroundIceCaveNotes') - }, - frigid_peak: { - text: t('backgroundFrigidPeakText'), - notes: t('backgroundFrigidPeakNotes') - }, - snowy_pines: { - text: t('backgroundSnowyPinesText'), - notes: t('backgroundSnowyPinesNotes') - } - }, - backgrounds022015: { - blacksmithy: { - text: t('backgroundBlacksmithyText'), - notes: t('backgroundBlacksmithyNotes') - }, - crystal_cave: { - text: t('backgroundCrystalCaveText'), - notes: t('backgroundCrystalCaveNotes') - }, - distant_castle: { - text: t('backgroundDistantCastleText'), - notes: t('backgroundDistantCastleNotes') - } - }, - backgrounds032015: { - spring_rain: { - text: t('backgroundSpringRainText'), - notes: t('backgroundSpringRainNotes') - }, - stained_glass: { - text: t('backgroundStainedGlassText'), - notes: t('backgroundStainedGlassNotes') - }, - rolling_hills: { - text: t('backgroundRollingHillsText'), - notes: t('backgroundRollingHillsNotes') - } - } -}; - -api.subscriptionBlocks = { - basic_earned: { - months: 1, - price: 5 - }, - basic_3mo: { - months: 3, - price: 15 - }, - basic_6mo: { - months: 6, - price: 30 - }, - google_6mo: { - months: 6, - price: 24, - discount: true, - original: 30 - }, - basic_12mo: { - months: 12, - price: 48 - } -}; - -_.each(api.subscriptionBlocks, function(b, k) { - return b.key = k; -}); - -repeat = { - m: true, - t: true, - w: true, - th: true, - f: true, - s: true, - su: true -}; - -api.userDefaults = { - habits: [ - { - type: 'habit', - text: t('defaultHabit1Text'), - notes: t('defaultHabit1Notes'), - value: 0, - up: true, - down: false, - attribute: 'per' - }, { - type: 'habit', - text: t('defaultHabit2Text'), - notes: t('defaultHabit2Notes'), - value: 0, - up: false, - down: true, - attribute: 'con' - }, { - type: 'habit', - text: t('defaultHabit3Text'), - notes: t('defaultHabit3Notes'), - value: 0, - up: true, - down: true, - attribute: 'str' - } - ], - dailys: [ - { - type: 'daily', - text: t('defaultDaily1Text'), - notes: t('defaultDaily1Notes'), - value: 0, - completed: false, - repeat: repeat, - attribute: 'per' - }, { - type: 'daily', - text: t('defaultDaily2Text'), - notes: t('defaultDaily2Notes'), - value: 3, - completed: false, - repeat: repeat, - attribute: 'con' - }, { - type: 'daily', - text: t('defaultDaily3Text'), - notes: t('defaultDaily3Notes'), - value: -10, - completed: false, - repeat: repeat, - attribute: 'int' - }, { - type: 'daily', - text: t('defaultDaily4Text'), - notes: t('defaultDaily4Notes'), - checklist: [ - { - completed: true, - text: t('defaultDaily4Checklist1') - }, { - completed: false, - text: t('defaultDaily4Checklist2') - }, { - completed: false, - text: t('defaultDaily4Checklist3') - } - ], - completed: false, - repeat: repeat, - attribute: 'str' - } - ], - todos: [ - { - type: 'todo', - text: t('defaultTodo1Text'), - notes: t('defaultTodoNotes'), - completed: false, - attribute: 'int' - }, { - type: 'todo', - text: t('defaultTodo2Text'), - notes: t('defaultTodoNotes'), - checklist: [ - { - completed: false, - text: t('defaultTodo2Checklist1') - }, { - completed: false, - text: t('defaultTodo2Checklist2') - }, { - completed: false, - text: t('defaultTodo2Checklist3') - } - ], - completed: false, - attribute: 'per' - }, { - type: 'todo', - text: t('defaultTodo3Text'), - notes: t('defaultTodoNotes'), - checklist: [ - { - completed: false, - text: t('defaultTodo3Checklist1') - }, { - completed: false, - text: t('defaultTodo3Checklist2') - }, { - completed: false, - text: t('defaultTodo3Checklist3') - } - ], - completed: false, - attribute: 'per' - }, { - type: 'todo', - text: t('defaultTodo4Text'), - notes: t('defaultTodoNotes'), - checklist: [ - { - completed: false, - text: t('defaultTodo4Checklist1') - }, { - completed: false, - text: t('defaultTodo4Checklist2') - }, { - completed: false, - text: t('defaultTodo4Checklist3') - } - ], - completed: false, - attribute: 'per' - }, { - type: 'todo', - text: t('defaultTodo5Text'), - notes: t('defaultTodoNotes'), - completed: false, - attribute: 'per' - } - ], - rewards: [ - { - type: 'reward', - text: t('defaultReward1Text'), - notes: t('defaultReward1Notes'), - value: 20 - }, { - type: 'reward', - text: t('defaultReward2Text'), - notes: t('defaultReward2Notes'), - value: 10 - } - ], - tags: [ - { - name: t('defaultTag1') - }, { - name: t('defaultTag2') - }, { - name: t('defaultTag3') - } - ] -}; - - -},{"./i18n.coffee":3,"lodash":6,"moment":7}],3:[function(require,module,exports){ -var _; - -_ = require('lodash'); - -module.exports = { - strings: null, - translations: {}, - t: function(stringName) { - var clonedVars, e, locale, string, stringNotFound, vars; - vars = arguments[1]; - if (_.isString(arguments[1])) { - vars = null; - locale = arguments[1]; - } else if (arguments[2] != null) { - vars = arguments[1]; - locale = arguments[2]; - } - if ((locale == null) || (!module.exports.strings && !module.exports.translations[locale])) { - locale = 'en'; - } - string = !module.exports.strings ? module.exports.translations[locale][stringName] : module.exports.strings[stringName]; - clonedVars = _.clone(vars) || {}; - clonedVars.locale = locale; - if (string) { - try { - return _.template(string, clonedVars); - } catch (_error) { - e = _error; - return 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'; - } - } else { - stringNotFound = !module.exports.strings ? module.exports.translations[locale].stringNotFound : module.exports.strings.stringNotFound; - try { - return _.template(stringNotFound, { - string: stringName - }); - } catch (_error) { - e = _error; - return 'Error processing string. Please report to http://github.com/HabitRPG/habitrpg.'; - } - } - } -}; - - -},{"lodash":6}],4:[function(require,module,exports){ -(function (process){ -var $w, api, content, i18n, moment, preenHistory, sanitizeOptions, sortOrder, _, - __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; - -moment = require('moment'); - -_ = require('lodash'); - -content = require('./content.coffee'); - -i18n = require('./i18n.coffee'); - -api = module.exports = {}; - -api.i18n = i18n; - -$w = api.$w = function(s) { - return s.split(' '); -}; - -api.dotSet = function(obj, path, val) { - var arr; - arr = path.split('.'); - return _.reduce(arr, (function(_this) { - return function(curr, next, index) { - if ((arr.length - 1) === index) { - curr[next] = val; - } - return curr[next] != null ? curr[next] : curr[next] = {}; - }; - })(this), obj); -}; - -api.dotGet = function(obj, path) { - return _.reduce(path.split('.'), ((function(_this) { - return function(curr, next) { - return curr != null ? curr[next] : void 0; - }; - })(this)), obj); -}; - - -/* - Reflists are arrays, but stored as objects. Mongoose has a helluvatime working with arrays (the main problem for our - syncing issues) - so the goal is to move away from arrays to objects, since mongoose can reference elements by ID - no problem. To maintain sorting, we use these helper functions: - */ - -api.refPush = function(reflist, item, prune) { - if (prune == null) { - prune = 0; - } - item.sort = _.isEmpty(reflist) ? 0 : _.max(reflist, 'sort').sort + 1; - if (!(item.id && !reflist[item.id])) { - item.id = api.uuid(); - } - return reflist[item.id] = item; -}; - -api.planGemLimits = { - convRate: 20, - convCap: 25 -}; - - -/* - ------------------------------------------------------ - Time / Day - ------------------------------------------------------ - */ - - -/* - Each time we're performing date math (cron, task-due-days, etc), we need to take user preferences into consideration. - Specifically {dayStart} (custom day start) and {timezoneOffset}. This function sanitizes / defaults those values. - {now} is also passed in for various purposes, one example being the test scripts scripts testing different "now" times - */ - -sanitizeOptions = function(o) { - var dayStart, now, timezoneOffset, _ref; - dayStart = !_.isNaN(+o.dayStart) && (0 <= (_ref = +o.dayStart) && _ref <= 24) ? +o.dayStart : 0; - timezoneOffset = o.timezoneOffset ? +o.timezoneOffset : +moment().zone(); - now = o.now ? moment(o.now).zone(timezoneOffset) : moment(+(new Date)).zone(timezoneOffset); - return { - dayStart: dayStart, - timezoneOffset: timezoneOffset, - now: now - }; -}; - -api.startOfWeek = api.startOfWeek = function(options) { - var o; - if (options == null) { - options = {}; - } - o = sanitizeOptions(options); - return moment(o.now).startOf('week'); -}; - -api.startOfDay = function(options) { - var dayStart, o; - if (options == null) { - options = {}; - } - o = sanitizeOptions(options); - dayStart = moment(o.now).startOf('day').add({ - hours: o.dayStart - }); - if (moment(o.now).hour() < o.dayStart) { - dayStart.subtract({ - days: 1 - }); - } - return dayStart; -}; - -api.dayMapping = { - 0: 'su', - 1: 'm', - 2: 't', - 3: 'w', - 4: 'th', - 5: 'f', - 6: 's' -}; - - -/* - Absolute diff from "yesterday" till now - */ - -api.daysSince = function(yesterday, options) { - var o; - if (options == null) { - options = {}; - } - o = sanitizeOptions(options); - return Math.abs(api.startOfDay(_.defaults({ - now: yesterday - }, o)).diff(api.startOfDay(_.defaults({ - now: o.now - }, o)), 'days')); -}; - - -/* - Should the user do this taks on this date, given the task's repeat options and user.preferences.dayStart? - */ - -api.shouldDo = function(day, repeat, options) { - var o, selected; - if (options == null) { - options = {}; - } - if (!repeat) { - return false; - } - o = sanitizeOptions(options); - selected = repeat[api.dayMapping[api.startOfDay(_.defaults({ - now: day - }, o)).day()]]; - return selected; -}; - - -/* - ------------------------------------------------------ - Scoring - ------------------------------------------------------ - */ - -api.tnl = function(lvl) { - return Math.round(((Math.pow(lvl, 2) * 0.25) + (10 * lvl) + 139.75) / 10) * 10; -}; - - -/* - A hyperbola function that creates diminishing returns, so you can't go to infinite (eg, with Exp gain). - {max} The asymptote - {bonus} All the numbers combined for your point bonus (eg, task.value * user.stats.int * critChance, etc) - {halfway} (optional) the point at which the graph starts bending - */ - -api.diminishingReturns = function(bonus, max, halfway) { - if (halfway == null) { - halfway = max / 2; - } - return max * (bonus / (bonus + halfway)); -}; - -api.monod = function(bonus, rateOfIncrease, max) { - return rateOfIncrease * max * bonus / (rateOfIncrease * bonus + max); -}; - - -/* -Preen history for users with > 7 history entries -This takes an infinite array of single day entries [day day day day day...], and turns it into a condensed array -of averages, condensing more the further back in time we go. Eg, 7 entries each for last 7 days; 1 entry each week -of this month; 1 entry for each month of this year; 1 entry per previous year: [day*7 week*4 month*12 year*infinite] - */ - -preenHistory = function(history) { - var newHistory, preen, thisMonth; - history = _.filter(history, function(h) { - return !!h; - }); - newHistory = []; - preen = function(amount, groupBy) { - var groups; - groups = _.chain(history).groupBy(function(h) { - return moment(h.date).format(groupBy); - }).sortBy(function(h, k) { - return k; - }).value(); - groups = groups.slice(-amount); - groups.pop(); - return _.each(groups, function(group) { - newHistory.push({ - date: moment(group[0].date).toDate(), - value: _.reduce(group, (function(m, obj) { - return m + obj.value; - }), 0) / group.length - }); - return true; - }); - }; - preen(50, "YYYY"); - preen(moment().format('MM'), "YYYYMM"); - thisMonth = moment().format('YYYYMM'); - newHistory = newHistory.concat(_.filter(history, function(h) { - return moment(h.date).format('YYYYMM') === thisMonth; - })); - return newHistory; -}; - - -/* - Update the in-browser store with new gear. FIXME this was in user.fns, but it was causing strange issues there - */ - -sortOrder = _.reduce(content.gearTypes, (function(m, v, k) { - m[v] = k; - return m; -}), {}); - -api.updateStore = function(user) { - var changes; - if (!user) { - return; - } - changes = []; - _.each(content.gearTypes, function(type) { - var found; - found = _.find(content.gear.tree[type][user.stats["class"]], function(item) { - return !user.items.gear.owned[item.key]; - }); - if (found) { - changes.push(found); - } - return true; - }); - changes = changes.concat(_.filter(content.gear.flat, function(v) { - var _ref; - return ((_ref = v.klass) === 'special' || _ref === 'mystery') && !user.items.gear.owned[v.key] && (typeof v.canOwn === "function" ? v.canOwn(user) : void 0); - })); - changes.push(content.potion); - return _.sortBy(changes, function(c) { - return sortOrder[c.type]; - }); -}; - - -/* ------------------------------------------------------- -Content ------------------------------------------------------- - */ - -api.content = content; - - -/* ------------------------------------------------------- -Misc Helpers ------------------------------------------------------- - */ - -api.uuid = function() { - return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) { - var r, v; - r = Math.random() * 16 | 0; - v = (c === "x" ? r : r & 0x3 | 0x8); - return v.toString(16); - }); -}; - -api.countExists = function(items) { - return _.reduce(items, (function(m, v) { - return m + (v ? 1 : 0); - }), 0); -}; - - -/* -Even though Mongoose handles task defaults, we want to make sure defaults are set on the client-side before -sending up to the server for performance - */ - -api.taskDefaults = function(task) { - var defaults, _ref, _ref1, _ref2; - if (task == null) { - task = {}; - } - if (!(task.type && ((_ref = task.type) === 'habit' || _ref === 'daily' || _ref === 'todo' || _ref === 'reward'))) { - task.type = 'habit'; - } - defaults = { - id: api.uuid(), - text: task.id != null ? task.id : '', - notes: '', - priority: 1, - challenge: {}, - attribute: 'str', - dateCreated: new Date() - }; - _.defaults(task, defaults); - if (task.type === 'habit') { - _.defaults(task, { - up: true, - down: true - }); - } - if ((_ref1 = task.type) === 'habit' || _ref1 === 'daily') { - _.defaults(task, { - history: [] - }); - } - if ((_ref2 = task.type) === 'daily' || _ref2 === 'todo') { - _.defaults(task, { - completed: false - }); - } - if (task.type === 'daily') { - _.defaults(task, { - streak: 0, - repeat: { - su: 1, - m: 1, - t: 1, - w: 1, - th: 1, - f: 1, - s: 1 - } - }); - } - task._id = task.id; - if (task.value == null) { - task.value = task.type === 'reward' ? 10 : 0; - } - if (!_.isNumber(task.priority)) { - task.priority = 1; - } - return task; -}; - -api.percent = function(x, y, dir) { - var roundFn; - switch (dir) { - case "up": - roundFn = Math.ceil; - break; - case "down": - roundFn = Math.floor; - break; - default: - roundFn = Math.round; - } - if (x === 0) { - x = 1; - } - return Math.max(0, roundFn(x / y * 100)); -}; - - -/* -Remove whitespace #FIXME are we using this anywwhere? Should we be? - */ - -api.removeWhitespace = function(str) { - if (!str) { - return ''; - } - return str.replace(/\s/g, ''); -}; - - -/* -Encode the download link for .ics iCal file - */ - -api.encodeiCalLink = function(uid, apiToken) { - var loc, _ref; - loc = (typeof window !== "undefined" && window !== null ? window.location.host : void 0) || (typeof process !== "undefined" && process !== null ? (_ref = process.env) != null ? _ref.BASE_URL : void 0 : void 0) || ''; - return encodeURIComponent("http://" + loc + "/v1/users/" + uid + "/calendar.ics?apiToken=" + apiToken); -}; - - -/* -Gold amount from their money - */ - -api.gold = function(num) { - if (num) { - return Math.floor(num); - } else { - return "0"; - } -}; - - -/* -Silver amount from their money - */ - -api.silver = function(num) { - if (num) { - return ("0" + Math.floor((num - Math.floor(num)) * 100)).slice(-2); - } else { - return "00"; - } -}; - - -/* -Task classes given everything about the class - */ - -api.taskClasses = function(task, filters, dayStart, lastCron, showCompleted, main) { - var classes, completed, enabled, filter, priority, repeat, type, value, _ref; - if (filters == null) { - filters = []; - } - if (dayStart == null) { - dayStart = 0; - } - if (lastCron == null) { - lastCron = +(new Date); - } - if (showCompleted == null) { - showCompleted = false; - } - if (main == null) { - main = false; - } - if (!task) { - return; - } - type = task.type, completed = task.completed, value = task.value, repeat = task.repeat, priority = task.priority; - if (main) { - if (!task._editing) { - for (filter in filters) { - enabled = filters[filter]; - if (enabled && !((_ref = task.tags) != null ? _ref[filter] : void 0)) { - return 'hidden'; - } - } - } - } - classes = type; - if (task._editing) { - classes += " beingEdited"; - } - if (type === 'todo' || type === 'daily') { - if (completed || (type === 'daily' && !api.shouldDo(+(new Date), task.repeat, { - dayStart: dayStart - }))) { - classes += " completed"; - } else { - classes += " uncompleted"; - } - } else if (type === 'habit') { - if (task.down && task.up) { - classes += ' habit-wide'; - } - if (!task.down && !task.up) { - classes += ' habit-narrow'; - } - } - if (priority === 1) { - classes += ' difficulty-easy'; - } else if (priority === 1.5) { - classes += ' difficulty-medium'; - } else if (priority === 2) { - classes += ' difficulty-hard'; - } - if (value < -20) { - classes += ' color-worst'; - } else if (value < -10) { - classes += ' color-worse'; - } else if (value < -1) { - classes += ' color-bad'; - } else if (value < 1) { - classes += ' color-neutral'; - } else if (value < 5) { - classes += ' color-good'; - } else if (value < 10) { - classes += ' color-better'; - } else { - classes += ' color-best'; - } - return classes; -}; - - -/* -Friendly timestamp - */ - -api.friendlyTimestamp = function(timestamp) { - return moment(timestamp).format('MM/DD h:mm:ss a'); -}; - - -/* -Does user have new chat messages? - */ - -api.newChatMessages = function(messages, lastMessageSeen) { - if (!((messages != null ? messages.length : void 0) > 0)) { - return false; - } - return (messages != null ? messages[0] : void 0) && (messages[0].id !== lastMessageSeen); -}; - - -/* -are any tags active? - */ - -api.noTags = function(tags) { - return _.isEmpty(tags) || _.isEmpty(_.filter(tags, function(t) { - return t; - })); -}; - - -/* -Are there tags applied? - */ - -api.appliedTags = function(userTags, taskTags) { - var arr; - arr = []; - _.each(userTags, function(t) { - if (t == null) { - return; - } - if (taskTags != null ? taskTags[t.id] : void 0) { - return arr.push(t.name); - } - }); - return arr.join(', '); -}; - -api.countPets = function(originalCount, pets) { - var count, pet; - count = originalCount != null ? originalCount : _.size(pets); - for (pet in content.questPets) { - if (pets[pet]) { - count--; - } - } - for (pet in content.specialPets) { - if (pets[pet]) { - count--; - } - } - return count; -}; - -api.countMounts = function(originalCount, mounts) { - var count2, mount; - count2 = originalCount != null ? originalCount : _.size(mounts); - for (mount in content.questPets) { - if (mounts[mount]) { - count2--; - } - } - for (mount in content.specialMounts) { - if (mounts[mount]) { - count2--; - } - } - return count2; -}; - -api.countTriad = function(pets) { - var count3, egg, potion; - count3 = 0; - for (egg in content.dropEggs) { - for (potion in content.hatchingPotions) { - if (pets[egg + "-" + potion] > 0) { - count3++; - } - } - } - return count3; -}; - - -/* ------------------------------------------------------- -User (prototype wrapper to give it ops, helper funcs, and virtuals ------------------------------------------------------- - */ - - -/* -User is now wrapped (both on client and server), adding a few new properties: - * getters (_statsComputed, tasks, etc) - * user.fns, which is a bunch of helper functions - These were originally up above, but they make more sense belonging to the user object so we don't have to pass - the user object all over the place. In fact, we should pull in more functions such as cron(), updateStats(), etc. - * user.ops, which is super important: - -If a function is inside user.ops, it has magical properties. If you call it on the client it updates the user object in -the browser and when it's done it automatically POSTs to the server, calling src/controllers/user.js#OP_NAME (the exact same name -of the op function). The first argument req is {query, body, params}, it's what the express controller function -expects. This means we call our functions as if we were calling an Express route. Eg, instead of score(task, direction), -we call score({params:{id:task.id,direction:direction}}). This also forces us to think about our routes (whether to use -params, query, or body for variables). see http://stackoverflow.com/questions/4024271/rest-api-best-practices-where-to-put-parameters - -If `src/controllers/user.js#OP_NAME` doesn't exist on the server, it's automatically added. It runs the code in user.ops.OP_NAME -to update the user model server-side, then performs `user.save()`. You can see this in action for `user.ops.buy`. That -function doesn't exist on the server - so the client calls it, it updates user in the browser, auto-POSTs to server, server -handles it by calling `user.ops.buy` again (to update user on the server), and then saves. We can do this for -everything that doesn't need any code difference from what's in user.ops.OP_NAME for special-handling server-side. If we -*do* need special handling, just add `src/controllers/user.js#OP_NAME` to override the user.ops.OP_NAME, and be -sure to call user.ops.OP_NAME at some point within the overridden function. - -TODO - * Is this the best way to wrap the user object? I thought of using user.prototype, but user is an object not a Function. - user on the server is a Mongoose model, so we can use prototype - but to do it on the client, we'd probably have to - move to $resource for user - * Move to $resource! - */ - -api.wrap = function(user, main) { - if (main == null) { - main = true; - } - if (user._wrapped) { - return; - } - user._wrapped = true; - if (main) { - user.ops = { - update: function(req, cb) { - _.each(req.body, function(v, k) { - user.fns.dotSet(k, v); - return true; - }); - return typeof cb === "function" ? cb(null, user) : void 0; - }, - sleep: function(req, cb) { - user.preferences.sleep = !user.preferences.sleep; - return typeof cb === "function" ? cb(null, {}) : void 0; - }, - revive: function(req, cb) { - var cl, gearOwned, item, losableItems, lostItem, lostStat, _base; - if (!(user.stats.hp <= 0)) { - return typeof cb === "function" ? cb({ - code: 400, - message: "Cannot revive if not dead" - }) : void 0; - } - _.merge(user.stats, { - hp: 50, - exp: 0, - gp: 0 - }); - if (user.stats.lvl > 1) { - user.stats.lvl--; - } - lostStat = user.fns.randomVal(_.reduce(['str', 'con', 'per', 'int'], (function(m, k) { - if (user.stats[k]) { - m[k] = k; - } - return m; - }), {})); - if (lostStat) { - user.stats[lostStat]--; - } - cl = user.stats["class"]; - gearOwned = (typeof (_base = user.items.gear.owned).toObject === "function" ? _base.toObject() : void 0) || user.items.gear.owned; - losableItems = {}; - _.each(gearOwned, function(v, k) { - var itm; - if (v) { - itm = content.gear.flat['' + k]; - if (itm) { - if ((itm.value > 0 || k === 'weapon_warrior_0') && (itm.klass === cl || (itm.klass === 'special' && (!itm.specialClass || itm.specialClass === cl)))) { - return losableItems['' + k] = '' + k; - } - } - } - }); - lostItem = user.fns.randomVal(losableItems); - if (item = content.gear.flat[lostItem]) { - user.items.gear.owned[lostItem] = false; - if (user.items.gear.equipped[item.type] === lostItem) { - user.items.gear.equipped[item.type] = "" + item.type + "_base_0"; - } - if (user.items.gear.costume[item.type] === lostItem) { - user.items.gear.costume[item.type] = "" + item.type + "_base_0"; - } - } - if (typeof user.markModified === "function") { - user.markModified('items.gear'); - } - return typeof cb === "function" ? cb((item ? { - code: 200, - message: i18n.t('messageLostItem', { - itemText: item.text(req.language) - }, req.language) - } : null), user) : void 0; - }, - reset: function(req, cb) { - var gear; - user.habits = []; - user.dailys = []; - user.todos = []; - user.rewards = []; - user.stats.hp = 50; - user.stats.lvl = 1; - user.stats.gp = 0; - user.stats.exp = 0; - gear = user.items.gear; - _.each(['equipped', 'costume'], function(type) { - gear[type].armor = 'armor_base_0'; - gear[type].weapon = 'weapon_base_0'; - gear[type].head = 'head_base_0'; - return gear[type].shield = 'shield_base_0'; - }); - if (typeof gear.owned === 'undefined') { - gear.owned = {}; - } - _.each(gear.owned, function(v, k) { - if (gear.owned[k]) { - gear.owned[k] = false; - } - return true; - }); - gear.owned.weapon_warrior_0 = true; - if (typeof user.markModified === "function") { - user.markModified('items.gear.owned'); - } - user.preferences.costume = false; - return typeof cb === "function" ? cb(null, user) : void 0; - }, - reroll: function(req, cb, ga) { - if (user.balance < 1) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } - user.balance--; - _.each(user.tasks, function(task) { - if (task.type !== 'reward') { - return task.value = 0; - } - }); - user.stats.hp = 50; - if (typeof cb === "function") { - cb(null, user); - } - return ga != null ? ga.event('purchase', 'reroll').send() : void 0; - }, - rebirth: function(req, cb, ga) { - var flags, gear, lvl, stats; - if (user.balance < 2 && user.stats.lvl < 100) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } - if (user.stats.lvl < 100) { - user.balance -= 2; - } - if (user.stats.lvl < 100) { - lvl = user.stats.lvl; - } else { - lvl = 100; - } - _.each(user.tasks, function(task) { - if (task.type !== 'reward') { - task.value = 0; - } - if (task.type === 'daily') { - return task.streak = 0; - } - }); - stats = user.stats; - stats.buffs = {}; - stats.hp = 50; - stats.lvl = 1; - stats["class"] = 'warrior'; - _.each(['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'], function(value) { - return stats[value] = 0; - }); - gear = user.items.gear; - _.each(['equipped', 'costume'], function(type) { - gear[type] = {}; - gear[type].armor = 'armor_base_0'; - gear[type].weapon = 'weapon_warrior_0'; - gear[type].head = 'head_base_0'; - return gear[type].shield = 'shield_base_0'; - }); - if (user.items.currentPet) { - user.ops.equip({ - params: { - type: 'pet', - key: user.items.currentPet - } - }); - } - if (user.items.currentMount) { - user.ops.equip({ - params: { - type: 'mount', - key: user.items.currentMount - } - }); - } - _.each(gear.owned, function(v, k) { - if (gear.owned[k]) { - gear.owned[k] = false; - return true; - } - }); - gear.owned.weapon_warrior_0 = true; - if (typeof user.markModified === "function") { - user.markModified('items.gear.owned'); - } - user.preferences.costume = false; - flags = user.flags; - if (!(user.achievements.ultimateGear || user.achievements.beastMaster)) { - flags.rebirthEnabled = false; - } - flags.itemsEnabled = false; - flags.dropsEnabled = false; - flags.classSelected = false; - flags.levelDrops = {}; - if (!user.achievements.rebirths) { - user.achievements.rebirths = 1; - user.achievements.rebirthLevel = lvl; - } else if (lvl > user.achievements.rebirthLevel || lvl === 100) { - user.achievements.rebirths++; - user.achievements.rebirthLevel = lvl; - } - user.stats.buffs = {}; - if (typeof cb === "function") { - cb(null, user); - } - return ga != null ? ga.event('purchase', 'Rebirth').send() : void 0; - }, - allocateNow: function(req, cb) { - _.times(user.stats.points, user.fns.autoAllocate); - user.stats.points = 0; - if (typeof user.markModified === "function") { - user.markModified('stats'); - } - return typeof cb === "function" ? cb(null, user.stats) : void 0; - }, - clearCompleted: function(req, cb) { - _.remove(user.todos, function(t) { - var _ref; - return t.completed && !((_ref = t.challenge) != null ? _ref.id : void 0); - }); - if (typeof user.markModified === "function") { - user.markModified('todos'); - } - return typeof cb === "function" ? cb(null, user.todos) : void 0; - }, - sortTask: function(req, cb) { - var from, id, movedTask, task, tasks, to, _ref; - id = req.params.id; - _ref = req.query, to = _ref.to, from = _ref.from; - task = user.tasks[id]; - if (!task) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messageTaskNotFound', req.language) - }) : void 0; - } - if (!((to != null) && (from != null))) { - return typeof cb === "function" ? cb('?to=__&from=__ are required') : void 0; - } - tasks = user["" + task.type + "s"]; - movedTask = tasks.splice(from, 1)[0]; - if (to === -1) { - tasks.push(movedTask); - } else { - tasks.splice(to, 0, movedTask); - } - return typeof cb === "function" ? cb(null, tasks) : void 0; - }, - updateTask: function(req, cb) { - var task, _ref; - if (!(task = user.tasks[(_ref = req.params) != null ? _ref.id : void 0])) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messageTaskNotFound', req.language) - }) : void 0; - } - _.merge(task, _.omit(req.body, ['checklist', 'id', 'type'])); - if (req.body.checklist) { - task.checklist = req.body.checklist; - } - if (typeof task.markModified === "function") { - task.markModified('tags'); - } - return typeof cb === "function" ? cb(null, task) : void 0; - }, - deleteTask: function(req, cb) { - var i, task, _ref; - task = user.tasks[(_ref = req.params) != null ? _ref.id : void 0]; - if (!task) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messageTaskNotFound', req.language) - }) : void 0; - } - i = user[task.type + "s"].indexOf(task); - if (~i) { - user[task.type + "s"].splice(i, 1); - } - return typeof cb === "function" ? cb(null, {}) : void 0; - }, - addTask: function(req, cb) { - var task; - task = api.taskDefaults(req.body); - user["" + task.type + "s"].unshift(task); - if (user.preferences.newTaskEdit) { - task._editing = true; - } - if (user.preferences.tagsCollapsed) { - task._tags = true; - } - if (user.preferences.advancedCollapsed) { - task._advanced = true; - } - if (typeof cb === "function") { - cb(null, task); - } - return task; - }, - addTag: function(req, cb) { - if (user.tags == null) { - user.tags = []; - } - user.tags.push({ - name: req.body.name, - id: req.body.id || api.uuid() - }); - return typeof cb === "function" ? cb(null, user.tags) : void 0; - }, - sortTag: function(req, cb) { - var from, to, _ref; - _ref = req.query, to = _ref.to, from = _ref.from; - if (!((to != null) && (from != null))) { - return typeof cb === "function" ? cb('?to=__&from=__ are required') : void 0; - } - user.tags.splice(to, 0, user.tags.splice(from, 1)[0]); - return typeof cb === "function" ? cb(null, user.tags) : void 0; - }, - updateTag: function(req, cb) { - var i, tid; - tid = req.params.id; - i = _.findIndex(user.tags, { - id: tid - }); - if (!~i) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messageTagNotFound', req.language) - }) : void 0; - } - user.tags[i].name = req.body.name; - return typeof cb === "function" ? cb(null, user.tags[i]) : void 0; - }, - deleteTag: function(req, cb) { - var i, tag, tid; - tid = req.params.id; - i = _.findIndex(user.tags, { - id: tid - }); - if (!~i) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messageTagNotFound', req.language) - }) : void 0; - } - tag = user.tags[i]; - delete user.filters[tag.id]; - user.tags.splice(i, 1); - _.each(user.tasks, function(task) { - return delete task.tags[tag.id]; - }); - _.each(['habits', 'dailys', 'todos', 'rewards'], function(type) { - return typeof user.markModified === "function" ? user.markModified(type) : void 0; - }); - return typeof cb === "function" ? cb(null, user.tags) : void 0; - }, - addWebhook: function(req, cb) { - var wh; - wh = user.preferences.webhooks; - api.refPush(wh, { - url: req.body.url, - enabled: req.body.enabled || true, - id: req.body.id - }); - if (typeof user.markModified === "function") { - user.markModified('preferences.webhooks'); - } - return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0; - }, - updateWebhook: function(req, cb) { - _.merge(user.preferences.webhooks[req.params.id], req.body); - if (typeof user.markModified === "function") { - user.markModified('preferences.webhooks'); - } - return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0; - }, - deleteWebhook: function(req, cb) { - delete user.preferences.webhooks[req.params.id]; - if (typeof user.markModified === "function") { - user.markModified('preferences.webhooks'); - } - return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0; - }, - clearPMs: function(req, cb) { - user.inbox.messages = {}; - if (typeof user.markModified === "function") { - user.markModified('inbox.messages'); - } - return typeof cb === "function" ? cb(null, user.inbox.messages) : void 0; - }, - deletePM: function(req, cb) { - delete user.inbox.messages[req.params.id]; - if (typeof user.markModified === "function") { - user.markModified('inbox.messages.' + req.params.id); - } - return typeof cb === "function" ? cb(null, user.inbox.messages) : void 0; - }, - blockUser: function(req, cb) { - var i; - i = user.inbox.blocks.indexOf(req.params.uuid); - if (~i) { - user.inbox.blocks.splice(i, 1); - } else { - user.inbox.blocks.push(req.params.uuid); - } - if (typeof user.markModified === "function") { - user.markModified('inbox.blocks'); - } - return typeof cb === "function" ? cb(null, user.inbox.blocks) : void 0; - }, - feed: function(req, cb) { - var egg, eggText, evolve, food, message, pet, petDisplayName, potion, potionText, userPets, _ref, _ref1, _ref2; - _ref = req.params, pet = _ref.pet, food = _ref.food; - food = content.food[food]; - _ref1 = pet.split('-'), egg = _ref1[0], potion = _ref1[1]; - userPets = user.items.pets; - potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion; - eggText = content.eggs[egg] ? content.eggs[egg].text() : egg; - petDisplayName = i18n.t('petName', { - potion: potionText, - egg: eggText - }); - if (!userPets[pet]) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messagePetNotFound', req.language) - }) : void 0; - } - if (!((_ref2 = user.items.food) != null ? _ref2[food.key] : void 0)) { - return typeof cb === "function" ? cb({ - code: 404, - message: i18n.t('messageFoodNotFound', req.language) - }) : void 0; - } - if (content.specialPets[pet] || (egg === "Egg")) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageCannotFeedPet', req.language) - }) : void 0; - } - if (user.items.mounts[pet]) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageAlreadyMount', req.language) - }) : void 0; - } - message = ''; - evolve = function() { - userPets[pet] = -1; - user.items.mounts[pet] = true; - if (pet === user.items.currentPet) { - user.items.currentPet = ""; - } - return message = i18n.t('messageEvolve', { - egg: petDisplayName - }, req.language); - }; - if (food.key === 'Saddle') { - evolve(); - } else { - if (food.target === potion) { - userPets[pet] += 5; - message = i18n.t('messageLikesFood', { - egg: petDisplayName, - foodText: food.text(req.language) - }, req.language); - } else { - userPets[pet] += 2; - message = i18n.t('messageDontEnjoyFood', { - egg: petDisplayName, - foodText: food.text(req.language) - }, req.language); - } - if (userPets[pet] >= 50 && !user.items.mounts[pet]) { - evolve(); - } - } - user.items.food[food.key]--; - return typeof cb === "function" ? cb({ - code: 200, - message: message - }, userPets[pet]) : void 0; - }, - buySpecialSpell: function(req, cb) { - var item, key, message, _base; - key = req.params.key; - item = content.special[key]; - if (user.stats.gp < item.value) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageNotEnoughGold', req.language) - }) : void 0; - } - user.stats.gp -= item.value; - if ((_base = user.items.special)[key] == null) { - _base[key] = 0; - } - user.items.special[key]++; - if (typeof user.markModified === "function") { - user.markModified('items.special'); - } - message = i18n.t('messageBought', { - itemText: item.text(req.language) - }, req.language); - return typeof cb === "function" ? cb({ - code: 200, - message: message - }, _.pick(user, $w('items stats'))) : void 0; - }, - purchase: function(req, cb, ga) { - var convCap, convRate, item, key, price, type, _ref, _ref1, _ref2, _ref3; - _ref = req.params, type = _ref.type, key = _ref.key; - if (type === 'gems' && key === 'gem') { - _ref1 = api.planGemLimits, convRate = _ref1.convRate, convCap = _ref1.convCap; - convCap += user.purchased.plan.consecutive.gemCapExtra; - if (!((_ref2 = user.purchased) != null ? (_ref3 = _ref2.plan) != null ? _ref3.customerId : void 0 : void 0)) { - return typeof cb === "function" ? cb({ - code: 401, - message: "Must subscribe to purchase gems with GP" - }, req) : void 0; - } - if (!(user.stats.gp >= convRate)) { - return typeof cb === "function" ? cb({ - code: 401, - message: "Not enough Gold" - }) : void 0; - } - if (user.purchased.plan.gemsBought >= convCap) { - return typeof cb === "function" ? cb({ - code: 401, - message: "You've reached the Gold=>Gem conversion cap (" + convCap + ") for this month. We have this to prevent abuse / farming. The cap will reset within the first three days of next month." - }) : void 0; - } - user.balance += .25; - user.purchased.plan.gemsBought++; - user.stats.gp -= convRate; - return typeof cb === "function" ? cb({ - code: 200, - message: "+1 Gems" - }, _.pick(user, $w('stats balance'))) : void 0; - } - if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food' && type !== 'quests' && type !== 'gear') { - return typeof cb === "function" ? cb({ - code: 404, - message: ":type must be in [eggs,hatchingPotions,food,quests,gear]" - }, req) : void 0; - } - if (type === 'gear') { - item = content.gear.flat[key]; - if (user.items.gear.owned[key]) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('alreadyHave', req.language) - }) : void 0; - } - price = (item.twoHanded ? 2 : 1) / 4; - } else { - item = content[type][key]; - price = item.value / 4; - } - if (!item) { - return typeof cb === "function" ? cb({ - code: 404, - message: ":key not found for Content." + type - }, req) : void 0; - } - if (user.balance < price) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } - user.balance -= price; - if (type === 'gear') { - user.items.gear.owned[key] = true; - } else { - if (!(user.items[type][key] > 0)) { - user.items[type][key] = 0; - } - user.items[type][key]++; - } - if (typeof cb === "function") { - cb(null, _.pick(user, $w('items balance'))); - } - return ga != null ? ga.event('purchase', key).send() : void 0; - }, - releasePets: function(req, cb) { - var pet; - if (user.balance < 1) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } else { - user.balance--; - for (pet in content.pets) { - user.items.pets[pet] = 0; - } - if (!user.achievements.beastMasterCount) { - user.achievements.beastMasterCount = 0; - } - user.achievements.beastMasterCount++; - user.items.currentPet = ""; - } - return typeof cb === "function" ? cb(null, user) : void 0; - }, - releaseMounts: function(req, cb) { - var mount; - if (user.balance < 1) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } else { - user.balance -= 1; - user.items.currentMount = ""; - for (mount in content.pets) { - user.items.mounts[mount] = null; - } - if (!user.achievements.mountMasterCount) { - user.achievements.mountMasterCount = 0; - } - user.achievements.mountMasterCount++; - } - return typeof cb === "function" ? cb(null, user) : void 0; - }, - releaseBoth: function(req, cb) { - var animal, giveTriadBingo; - if (user.balance < 1.5) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } else { - giveTriadBingo = true; - user.balance -= 1.5; - user.items.currentMount = ""; - user.items.currentPet = ""; - for (animal in content.pets) { - if (user.items.pets[animal] === -1) { - giveTriadBingo = false; - } - user.items.pets[animal] = 0; - user.items.mounts[animal] = null; - } - if (!user.achievements.beastMasterCount) { - user.achievements.beastMasterCount = 0; - } - user.achievements.beastMasterCount++; - if (!user.achievements.mountMasterCount) { - user.achievements.mountMasterCount = 0; - } - user.achievements.mountMasterCount++; - if (giveTriadBingo) { - if (!user.achievements.triadBingoCount) { - user.achievements.triadBingoCount = 0; - } - user.achievements.triadBingoCount++; - } - } - return typeof cb === "function" ? cb(null, user) : void 0; - }, - buy: function(req, cb) { - var item, key, message; - key = req.params.key; - item = key === 'potion' ? content.potion : content.gear.flat[key]; - if (!item) { - return typeof cb === "function" ? cb({ - code: 404, - message: "Item '" + key + " not found (see https://github.com/HabitRPG/habitrpg-shared/blob/develop/script/content.coffee)" - }) : void 0; - } - if (user.stats.gp < item.value) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageNotEnoughGold', req.language) - }) : void 0; - } - if ((item.canOwn != null) && !item.canOwn(user)) { - return typeof cb === "function" ? cb({ - code: 401, - message: "You can't own this item" - }) : void 0; - } - if (item.key === 'potion') { - user.stats.hp += 15; - if (user.stats.hp > 50) { - user.stats.hp = 50; - } - } else { - user.items.gear.equipped[item.type] = item.key; - user.items.gear.owned[item.key] = true; - message = user.fns.handleTwoHanded(item, null, req); - if (message == null) { - message = i18n.t('messageBought', { - itemText: item.text(req.language) - }, req.language); - } - if (!user.achievements.ultimateGear && item.last) { - user.fns.ultimateGear(); - } - } - user.stats.gp -= item.value; - return typeof cb === "function" ? cb({ - code: 200, - message: message - }, _.pick(user, $w('items achievements stats'))) : void 0; - }, - buyMysterySet: function(req, cb) { - var mysterySet, _ref; - if (!(user.purchased.plan.consecutive.trinkets > 0)) { - return typeof cb === "function" ? cb({ - code: 401, - message: "You don't have enough Mystic Hourglasses" - }) : void 0; - } - mysterySet = (_ref = content.timeTravelerStore(user.items.gear.owned)) != null ? _ref[req.params.key] : void 0; - if ((typeof window !== "undefined" && window !== null ? window.confirm : void 0) != null) { - if (!window.confirm("Buy this full set of items for 1 Mystic Hourglass?")) { - return; - } - } - if (!mysterySet) { - return typeof cb === "function" ? cb({ - code: 404, - message: "Mystery set not found, or set already owned" - }) : void 0; - } - _.each(mysterySet.items, function(i) { - return user.items.gear.owned[i.key] = true; - }); - user.purchased.plan.consecutive.trinkets--; - return typeof cb === "function" ? cb(null, _.pick(user, $w('items purchased.plan.consecutive'))) : void 0; - }, - sell: function(req, cb) { - var key, type, _ref; - _ref = req.params, key = _ref.key, type = _ref.type; - if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food') { - return typeof cb === "function" ? cb({ - code: 404, - message: ":type not found. Must bes in [eggs, hatchingPotions, food]" - }) : void 0; - } - if (!user.items[type][key]) { - return typeof cb === "function" ? cb({ - code: 404, - message: ":key not found for user.items." + type - }) : void 0; - } - user.items[type][key]--; - user.stats.gp += content[type][key].value; - return typeof cb === "function" ? cb(null, _.pick(user, $w('stats items'))) : void 0; - }, - equip: function(req, cb) { - var item, key, message, type, _ref; - _ref = [req.params.type || 'equipped', req.params.key], type = _ref[0], key = _ref[1]; - switch (type) { - case 'mount': - if (!user.items.mounts[key]) { - return typeof cb === "function" ? cb({ - code: 404, - message: ":You do not own this mount." - }) : void 0; - } - user.items.currentMount = user.items.currentMount === key ? '' : key; - break; - case 'pet': - if (!user.items.pets[key]) { - return typeof cb === "function" ? cb({ - code: 404, - message: ":You do not own this pet." - }) : void 0; - } - user.items.currentPet = user.items.currentPet === key ? '' : key; - break; - case 'costume': - case 'equipped': - item = content.gear.flat[key]; - if (!user.items.gear.owned[key]) { - return typeof cb === "function" ? cb({ - code: 404, - message: ":You do not own this gear." - }) : void 0; - } - if (user.items.gear[type][item.type] === key) { - user.items.gear[type][item.type] = "" + item.type + "_base_0"; - message = i18n.t('messageUnEquipped', { - itemText: item.text(req.language) - }, req.language); - } else { - user.items.gear[type][item.type] = item.key; - message = user.fns.handleTwoHanded(item, type, req); - } - if (typeof user.markModified === "function") { - user.markModified("items.gear." + type); - } - } - return typeof cb === "function" ? cb((message ? { - code: 200, - message: message - } : null), user.items) : void 0; - }, - hatch: function(req, cb) { - var egg, hatchingPotion, pet, _ref; - _ref = req.params, egg = _ref.egg, hatchingPotion = _ref.hatchingPotion; - if (!(egg && hatchingPotion)) { - return typeof cb === "function" ? cb({ - code: 404, - message: "Please specify query.egg & query.hatchingPotion" - }) : void 0; - } - if (!(user.items.eggs[egg] > 0 && user.items.hatchingPotions[hatchingPotion] > 0)) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageMissingEggPotion', req.language) - }) : void 0; - } - pet = "" + egg + "-" + hatchingPotion; - if (user.items.pets[pet] && user.items.pets[pet] > 0) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageAlreadyPet', req.language) - }) : void 0; - } - user.items.pets[pet] = 5; - user.items.eggs[egg]--; - user.items.hatchingPotions[hatchingPotion]--; - return typeof cb === "function" ? cb({ - code: 200, - message: i18n.t('messageHatched', req.language) - }, user.items) : void 0; - }, - unlock: function(req, cb, ga) { - var alreadyOwns, cost, fullSet, k, path, split, v; - path = req.query.path; - fullSet = ~path.indexOf(","); - cost = ~path.indexOf('background.') ? fullSet ? 3.75 : 1.75 : fullSet ? 1.25 : 0.5; - alreadyOwns = !fullSet && user.fns.dotGet("purchased." + path) === true; - if (user.balance < cost && !alreadyOwns) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } - if (fullSet) { - _.each(path.split(","), function(p) { - user.fns.dotSet("purchased." + p, true); - return true; - }); - } else { - if (alreadyOwns) { - split = path.split('.'); - v = split.pop(); - k = split.join('.'); - if (k === 'background' && v === user.preferences.background) { - v = ''; - } - user.fns.dotSet("preferences." + k, v); - return typeof cb === "function" ? cb(null, req) : void 0; - } - user.fns.dotSet("purchased." + path, true); - } - user.balance -= cost; - if (typeof user.markModified === "function") { - user.markModified('purchased'); - } - if (typeof cb === "function") { - cb(null, _.pick(user, $w('purchased preferences'))); - } - return ga != null ? ga.event('purchase', path).send() : void 0; - }, - changeClass: function(req, cb, ga) { - var klass, _ref; - klass = (_ref = req.query) != null ? _ref["class"] : void 0; - if (klass === 'warrior' || klass === 'rogue' || klass === 'wizard' || klass === 'healer') { - user.stats["class"] = klass; - user.flags.classSelected = true; - _.each(["weapon", "armor", "shield", "head"], function(type) { - var foundKey; - foundKey = false; - _.findLast(user.items.gear.owned, function(v, k) { - if (~k.indexOf(type + "_" + klass) && v === true) { - return foundKey = k; - } - }); - user.items.gear.equipped[type] = foundKey ? foundKey : type === "weapon" ? "weapon_" + klass + "_0" : type === "shield" && klass === "rogue" ? "shield_rogue_0" : "" + type + "_base_0"; - if (type === "weapon" || (type === "shield" && klass === "rogue")) { - user.items.gear.owned["" + type + "_" + klass + "_0"] = true; - } - return true; - }); - } else { - if (user.preferences.disableClasses) { - user.preferences.disableClasses = false; - user.preferences.autoAllocate = false; - } else { - if (!(user.balance >= .75)) { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('notEnoughGems', req.language) - }) : void 0; - } - user.balance -= .75; - } - _.merge(user.stats, { - str: 0, - con: 0, - per: 0, - int: 0, - points: user.stats.lvl - }); - user.flags.classSelected = false; - if (ga != null) { - ga.event('purchase', 'changeClass').send(); - } - } - return typeof cb === "function" ? cb(null, _.pick(user, $w('stats flags items preferences'))) : void 0; - }, - disableClasses: function(req, cb) { - user.stats["class"] = 'warrior'; - user.flags.classSelected = true; - user.preferences.disableClasses = true; - user.preferences.autoAllocate = true; - user.stats.str = user.stats.lvl; - user.stats.points = 0; - return typeof cb === "function" ? cb(null, _.pick(user, $w('stats flags preferences'))) : void 0; - }, - allocate: function(req, cb) { - var stat; - stat = req.query.stat || 'str'; - if (user.stats.points > 0) { - user.stats[stat]++; - user.stats.points--; - if (stat === 'int') { - user.stats.mp++; - } - } - return typeof cb === "function" ? cb(null, _.pick(user, $w('stats'))) : void 0; - }, - readValentine: function(req, cb) { - user.items.special.valentineReceived.shift(); - if (typeof user.markModified === "function") { - user.markModified('items.special.valentineReceived'); - } - return typeof cb === "function" ? cb(null, 'items.special') : void 0; - }, - openMysteryItem: function(req, cb, ga) { - var item, _ref, _ref1; - item = (_ref = user.purchased.plan) != null ? (_ref1 = _ref.mysteryItems) != null ? _ref1.shift() : void 0 : void 0; - if (!item) { - return typeof cb === "function" ? cb({ - code: 400, - message: "Empty" - }) : void 0; - } - item = content.gear.flat[item]; - user.items.gear.owned[item.key] = true; - if (typeof user.markModified === "function") { - user.markModified('purchased.plan.mysteryItems'); - } - if (typeof window !== 'undefined') { - (user._tmp != null ? user._tmp : user._tmp = {}).drop = { - type: 'gear', - dialog: "" + (item.text(req.language)) + " inside!" - }; - } - return typeof cb === "function" ? cb(null, user.items.gear.owned) : void 0; - }, - readNYE: function(req, cb) { - user.items.special.nyeReceived.shift(); - if (typeof user.markModified === "function") { - user.markModified('items.special.nyeReceived'); - } - return typeof cb === "function" ? cb(null, 'items.special') : void 0; - }, - score: function(req, cb) { - var addPoints, calculateDelta, calculateReverseDelta, changeTaskValue, delta, direction, id, mpDelta, multiplier, num, options, stats, subtractPoints, task, th, _ref; - _ref = req.params, id = _ref.id, direction = _ref.direction; - task = user.tasks[id]; - options = req.query || {}; - _.defaults(options, { - times: 1, - cron: false - }); - user._tmp = {}; - stats = { - gp: +user.stats.gp, - hp: +user.stats.hp, - exp: +user.stats.exp - }; - task.value = +task.value; - task.streak = ~~task.streak; - if (task.priority == null) { - task.priority = 1; - } - if (task.value > stats.gp && task.type === 'reward') { - return typeof cb === "function" ? cb({ - code: 401, - message: i18n.t('messageNotEnoughGold', req.language) - }) : void 0; - } - delta = 0; - calculateDelta = function() { - var currVal, nextDelta, _ref1; - currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value; - nextDelta = Math.pow(0.9747, currVal) * (direction === 'down' ? -1 : 1); - if (((_ref1 = task.checklist) != null ? _ref1.length : void 0) > 0) { - if (direction === 'down' && task.type === 'daily' && options.cron) { - nextDelta *= 1 - _.reduce(task.checklist, (function(m, i) { - return m + (i.completed ? 1 : 0); - }), 0) / task.checklist.length; - } - if (task.type === 'todo') { - nextDelta *= 1 + _.reduce(task.checklist, (function(m, i) { - return m + (i.completed ? 1 : 0); - }), 0); - } - } - return nextDelta; - }; - calculateReverseDelta = function() { - var calc, closeEnough, currVal, diff, nextDelta, testVal, _ref1; - currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value; - testVal = currVal + Math.pow(0.9747, currVal) * (direction === 'down' ? -1 : 1); - closeEnough = 0.00001; - while (true) { - calc = testVal + Math.pow(0.9747, testVal); - diff = currVal - calc; - if (Math.abs(diff) < closeEnough) { - break; - } - if (diff > 0) { - testVal -= diff; - } else { - testVal += diff; - } - } - nextDelta = testVal - currVal; - if (((_ref1 = task.checklist) != null ? _ref1.length : void 0) > 0) { - if (task.type === 'todo') { - nextDelta *= 1 + _.reduce(task.checklist, (function(m, i) { - return m + (i.completed ? 1 : 0); - }), 0); - } - } - return nextDelta; - }; - changeTaskValue = function() { - return _.times(options.times, function() { - var nextDelta, _ref1; - nextDelta = !options.cron && direction === 'down' ? calculateReverseDelta() : calculateDelta(); - if (task.type !== 'reward') { - if (user.preferences.automaticAllocation === true && user.preferences.allocationMode === 'taskbased' && !(task.type === 'todo' && direction === 'down')) { - user.stats.training[task.attribute] += nextDelta; - } - if (direction === 'up' && !(task.type === 'habit' && !task.down)) { - user.party.quest.progress.up = user.party.quest.progress.up || 0; - if ((_ref1 = task.type) === 'daily' || _ref1 === 'todo') { - user.party.quest.progress.up += nextDelta * (1 + (user._statsComputed.str / 200)); - } - } - task.value += nextDelta; - } - return delta += nextDelta; - }); - }; - addPoints = function() { - var afterStreak, currStreak, gpMod, intBonus, perBonus, streakBonus, _crit; - _crit = (delta > 0 ? user.fns.crit() : 1); - if (_crit > 1) { - user._tmp.crit = _crit; - } - intBonus = 1 + (user._statsComputed.int * .025); - stats.exp += Math.round(delta * intBonus * task.priority * _crit * 6); - perBonus = 1 + user._statsComputed.per * .02; - gpMod = delta * task.priority * _crit * perBonus; - return stats.gp += task.streak ? (currStreak = direction === 'down' ? task.streak - 1 : task.streak, streakBonus = currStreak / 100 + 1, afterStreak = gpMod * streakBonus, currStreak > 0 ? gpMod > 0 ? user._tmp.streakBonus = afterStreak - gpMod : void 0 : void 0, afterStreak) : gpMod; - }; - subtractPoints = function() { - var conBonus, hpMod; - conBonus = 1 - (user._statsComputed.con / 250); - if (conBonus < .1) { - conBonus = 0.1; - } - hpMod = delta * conBonus * task.priority * 2; - return stats.hp += Math.round(hpMod * 10) / 10; - }; - switch (task.type) { - case 'habit': - changeTaskValue(); - if (delta > 0) { - addPoints(); - } else { - subtractPoints(); - } - th = (task.history != null ? task.history : task.history = []); - if (th[th.length - 1] && moment(th[th.length - 1].date).isSame(new Date, 'day')) { - th[th.length - 1].value = task.value; - } else { - th.push({ - date: +(new Date), - value: task.value - }); - } - if (typeof user.markModified === "function") { - user.markModified("habits." + (_.findIndex(user.habits, { - id: task.id - })) + ".history"); - } - break; - case 'daily': - if (options.cron) { - changeTaskValue(); - subtractPoints(); - if (!user.stats.buffs.streaks) { - task.streak = 0; - } - } else { - changeTaskValue(); - if (direction === 'down') { - delta = calculateDelta(); - } - addPoints(); - if (direction === 'up') { - task.streak = task.streak ? task.streak + 1 : 1; - if ((task.streak % 21) === 0) { - user.achievements.streak = user.achievements.streak ? user.achievements.streak + 1 : 1; - } - } else { - if ((task.streak % 21) === 0) { - user.achievements.streak = user.achievements.streak ? user.achievements.streak - 1 : 0; - } - task.streak = task.streak ? task.streak - 1 : 0; - } - } - break; - case 'todo': - if (options.cron) { - changeTaskValue(); - } else { - task.dateCompleted = direction === 'up' ? new Date : void 0; - changeTaskValue(); - if (direction === 'down') { - delta = calculateDelta(); - } - addPoints(); - multiplier = _.max([ - _.reduce(task.checklist, (function(m, i) { - return m + (i.completed ? 1 : 0); - }), 1), 1 - ]); - mpDelta = _.max([multiplier, .01 * user._statsComputed.maxMP * multiplier]); - mpDelta *= user._tmp.crit || 1; - if (direction === 'down') { - mpDelta *= -1; - } - user.stats.mp += mpDelta; - if (user.stats.mp >= user._statsComputed.maxMP) { - user.stats.mp = user._statsComputed.maxMP; - } - if (user.stats.mp < 0) { - user.stats.mp = 0; - } - } - break; - case 'reward': - changeTaskValue(); - stats.gp -= Math.abs(task.value); - num = parseFloat(task.value).toFixed(2); - if (stats.gp < 0) { - stats.hp += stats.gp; - stats.gp = 0; - } - } - user.fns.updateStats(stats, req); - if (typeof window === 'undefined') { - if (direction === 'up') { - user.fns.randomDrop({ - task: task, - delta: delta - }, req); - } - } - if (typeof cb === "function") { - cb(null, user); - } - return delta; - } - }; - } - user.fns = { - getItem: function(type) { - var item; - item = content.gear.flat[user.items.gear.equipped[type]]; - if (!item) { - return content.gear.flat["" + type + "_base_0"]; - } - return item; - }, - handleTwoHanded: function(item, type, req) { - var message, weapon, _ref; - if (type == null) { - type = 'equipped'; - } - if (item.type === "shield" && ((_ref = (weapon = content.gear.flat[user.items.gear[type].weapon])) != null ? _ref.twoHanded : void 0)) { - user.items.gear[type].weapon = 'weapon_base_0'; - message = i18n.t('messageTwoHandled', { - gearText: weapon.text(req.language) - }, req.language); - } - if (item.twoHanded) { - user.items.gear[type].shield = "shield_base_0"; - message = i18n.t('messageTwoHandled', { - gearText: item.text(req.language) - }, req.language); - } - return message; - }, - - /* - Because the same op needs to be performed on the client and the server (critical hits, item drops, etc), - we need things to be "random", but technically predictable so that they don't go out-of-sync - */ - predictableRandom: function(seed) { - var x; - if (!seed || seed === Math.PI) { - seed = _.reduce(user.stats, (function(m, v) { - if (_.isNumber(v)) { - return m + v; - } else { - return m; - } - }), 0); - } - x = Math.sin(seed++) * 10000; - return x - Math.floor(x); - }, - crit: function(stat, chance) { - if (stat == null) { - stat = 'str'; - } - if (chance == null) { - chance = .03; - } - if (user.fns.predictableRandom() <= chance * (1 + user._statsComputed[stat] / 100)) { - return 1.5 + (.02 * user._statsComputed[stat]); - } else { - return 1; - } - }, - - /* - Get a random property from an object - returns random property (the value) - */ - randomVal: function(obj, options) { - var array, rand; - array = (options != null ? options.key : void 0) ? _.keys(obj) : _.values(obj); - rand = user.fns.predictableRandom(options != null ? options.seed : void 0); - array.sort(); - return array[Math.floor(rand * array.length)]; - }, - - /* - This allows you to set object properties by dot-path. Eg, you can run pathSet('stats.hp',50,user) which is the same as - user.stats.hp = 50. This is useful because in our habitrpg-shared functions we're returning changesets as {path:value}, - so that different consumers can implement setters their own way. Derby needs model.set(path, value) for example, where - Angular sets object properties directly - in which case, this function will be used. - */ - dotSet: function(path, val) { - return api.dotSet(user, path, val); - }, - dotGet: function(path) { - return api.dotGet(user, path); - }, - randomDrop: function(modifiers, req) { - var acceptableDrops, chance, drop, dropK, dropMultiplier, quest, rarity, task, _base, _base1, _base2, _name, _name1, _name2, _ref, _ref1, _ref2, _ref3; - task = modifiers.task; - chance = _.min([Math.abs(task.value - 21.27), 37.5]) / 150 + .02; - chance *= task.priority * (1 + (task.streak / 100 || 0)) * (1 + (user._statsComputed.per / 100)) * (1 + (user.contributor.level / 40 || 0)) * (1 + (user.achievements.rebirths / 20 || 0)) * (1 + (user.achievements.streak / 200 || 0)) * (user._tmp.crit || 1) * (1 + .5 * (_.reduce(task.checklist, (function(m, i) { - return m + (i.completed ? 1 : 0); - }), 0) || 0)); - chance = api.diminishingReturns(chance, 0.75); - quest = content.quests[(_ref = user.party.quest) != null ? _ref.key : void 0]; - if ((quest != null ? quest.collect : void 0) && user.fns.predictableRandom(user.stats.gp) < chance) { - dropK = user.fns.randomVal(quest.collect, { - key: true - }); - user.party.quest.progress.collect[dropK]++; - if (typeof user.markModified === "function") { - user.markModified('party.quest.progress'); - } - } - dropMultiplier = ((_ref1 = user.purchased) != null ? (_ref2 = _ref1.plan) != null ? _ref2.customerId : void 0 : void 0) ? 2 : 1; - if ((api.daysSince(user.items.lastDrop.date, user.preferences) === 0) && (user.items.lastDrop.count >= dropMultiplier * (5 + Math.floor(user._statsComputed.per / 25) + (user.contributor.level || 0)))) { - return; - } - if (((_ref3 = user.flags) != null ? _ref3.dropsEnabled : void 0) && user.fns.predictableRandom(user.stats.exp) < chance) { - rarity = user.fns.predictableRandom(user.stats.gp); - if (rarity > .6) { - drop = user.fns.randomVal(_.where(content.food, { - canDrop: true - })); - if ((_base = user.items.food)[_name = drop.key] == null) { - _base[_name] = 0; - } - user.items.food[drop.key] += 1; - drop.type = 'Food'; - drop.dialog = i18n.t('messageDropFood', { - dropArticle: drop.article, - dropText: drop.text(req.language), - dropNotes: drop.notes(req.language) - }, req.language); - } else if (rarity > .3) { - drop = user.fns.randomVal(_.where(content.eggs, { - canBuy: true - })); - if ((_base1 = user.items.eggs)[_name1 = drop.key] == null) { - _base1[_name1] = 0; - } - user.items.eggs[drop.key]++; - drop.type = 'Egg'; - drop.dialog = i18n.t('messageDropEgg', { - dropText: drop.text(req.language), - dropNotes: drop.notes(req.language) - }, req.language); - } else { - acceptableDrops = rarity < .02 ? ['Golden'] : rarity < .09 ? ['Zombie', 'CottonCandyPink', 'CottonCandyBlue'] : rarity < .18 ? ['Red', 'Shade', 'Skeleton'] : ['Base', 'White', 'Desert']; - drop = user.fns.randomVal(_.pick(content.hatchingPotions, (function(v, k) { - return __indexOf.call(acceptableDrops, k) >= 0; - }))); - if ((_base2 = user.items.hatchingPotions)[_name2 = drop.key] == null) { - _base2[_name2] = 0; - } - user.items.hatchingPotions[drop.key]++; - drop.type = 'HatchingPotion'; - drop.dialog = i18n.t('messageDropPotion', { - dropText: drop.text(req.language), - dropNotes: drop.notes(req.language) - }, req.language); - } - user._tmp.drop = drop; - user.items.lastDrop.date = +(new Date); - return user.items.lastDrop.count++; - } - }, - - /* - Updates user stats with new stats. Handles death, leveling up, etc - {stats} new stats - {update} if aggregated changes, pass in userObj as update. otherwise commits will be made immediately - */ - autoAllocate: function() { - return user.stats[(function() { - var diff, ideal, preference, stats, suggested; - switch (user.preferences.allocationMode) { - case "flat": - stats = _.pick(user.stats, $w('con str per int')); - return _.invert(stats)[_.min(stats)]; - case "classbased": - ideal = [user.stats.lvl / 7 * 3, user.stats.lvl / 7 * 2, user.stats.lvl / 7, user.stats.lvl / 7]; - preference = (function() { - switch (user.stats["class"]) { - case "wizard": - return ["int", "per", "con", "str"]; - case "rogue": - return ["per", "str", "int", "con"]; - case "healer": - return ["con", "int", "str", "per"]; - default: - return ["str", "con", "per", "int"]; - } - })(); - diff = [user.stats[preference[0]] - ideal[0], user.stats[preference[1]] - ideal[1], user.stats[preference[2]] - ideal[2], user.stats[preference[3]] - ideal[3]]; - suggested = _.findIndex(diff, (function(val) { - if (val === _.min(diff)) { - return true; - } - })); - if (~suggested) { - return preference[suggested]; - } else { - return "str"; - } - case "taskbased": - suggested = _.invert(user.stats.training)[_.max(user.stats.training)]; - _.merge(user.stats.training, { - str: 0, - int: 0, - con: 0, - per: 0 - }); - return suggested || "str"; - default: - return "str"; - } - })()]++; - }, - updateStats: function(stats, req) { - var tnl; - if (stats.hp <= 0) { - return user.stats.hp = 0; - } - user.stats.hp = stats.hp; - user.stats.gp = stats.gp >= 0 ? stats.gp : 0; - tnl = api.tnl(user.stats.lvl); - if (stats.exp >= tnl) { - user.stats.exp = stats.exp; - while (stats.exp >= tnl) { - stats.exp -= tnl; - user.stats.lvl++; - tnl = api.tnl(user.stats.lvl); - if (user.preferences.automaticAllocation) { - user.fns.autoAllocate(); - } else { - user.stats.points = user.stats.lvl - (user.stats.con + user.stats.str + user.stats.per + user.stats.int); - } - user.stats.hp = 50; - } - } - user.stats.exp = stats.exp; - if (user.flags == null) { - user.flags = {}; - } - if (!user.flags.customizationsNotification && (user.stats.exp > 5 || user.stats.lvl > 1)) { - user.flags.customizationsNotification = true; - } - if (!user.flags.itemsEnabled && (user.stats.exp > 10 || user.stats.lvl > 1)) { - user.flags.itemsEnabled = true; - } - if (!user.flags.partyEnabled && user.stats.lvl >= 3) { - user.flags.partyEnabled = true; - } - if (!user.flags.dropsEnabled && user.stats.lvl >= 4) { - user.flags.dropsEnabled = true; - if (user.items.eggs["Wolf"] > 0) { - user.items.eggs["Wolf"]++; - } else { - user.items.eggs["Wolf"] = 1; - } - } - if (!user.flags.classSelected && user.stats.lvl >= 10) { - user.flags.classSelected; - } - _.each({ - vice1: 30, - atom1: 15, - moonstone1: 60, - goldenknight1: 40 - }, function(lvl, k) { - var _base, _base1, _ref; - if (!((_ref = user.flags.levelDrops) != null ? _ref[k] : void 0) && user.stats.lvl >= lvl) { - if ((_base = user.items.quests)[k] == null) { - _base[k] = 0; - } - user.items.quests[k]++; - ((_base1 = user.flags).levelDrops != null ? _base1.levelDrops : _base1.levelDrops = {})[k] = true; - if (typeof user.markModified === "function") { - user.markModified('flags.levelDrops'); - } - return user._tmp.drop = _.defaults(content.quests[k], { - type: 'Quest', - dialog: i18n.t('messageFoundQuest', { - questText: content.quests[k].text(req.language) - }, req.language) - }); - } - }); - if (!user.flags.rebirthEnabled && (user.stats.lvl >= 50 || user.achievements.ultimateGear || user.achievements.beastMaster)) { - user.flags.rebirthEnabled = true; - } - if (user.stats.lvl >= 100 && !user.flags.freeRebirth) { - return user.flags.freeRebirth = true; - } - }, - - /* - ------------------------------------------------------ - Cron - ------------------------------------------------------ - */ - - /* - At end of day, add value to all incomplete Daily & Todo tasks (further incentive) - For incomplete Dailys, deduct experience - Make sure to run this function once in a while as server will not take care of overnight calculations. - And you have to run it every time client connects. - {user} - */ - cron: function(options) { - var clearBuffs, daysMissed, expTally, lvl, lvlDiv2, now, perfect, plan, progress, todoTally, _base, _base1, _base2, _base3, _progress, _ref, _ref1, _ref2; - if (options == null) { - options = {}; - } - now = +options.now || +(new Date); - daysMissed = api.daysSince(user.lastCron, _.defaults({ - now: now - }, user.preferences)); - if (!(daysMissed > 0)) { - return; - } - user.auth.timestamps.loggedin = new Date(); - user.lastCron = now; - if (user.items.lastDrop.count > 0) { - user.items.lastDrop.count = 0; - } - perfect = true; - clearBuffs = { - str: 0, - int: 0, - per: 0, - con: 0, - stealth: 0, - streaks: false - }; - plan = (_ref = user.purchased) != null ? _ref.plan : void 0; - if (plan != null ? plan.customerId : void 0) { - if (moment(plan.dateUpdated).format('MMYYYY') !== moment().format('MMYYYY')) { - plan.gemsBought = 0; - plan.dateUpdated = new Date(); - _.defaults(plan.consecutive, { - count: 0, - offset: 0, - trinkets: 0, - gemCapExtra: 0 - }); - plan.consecutive.count++; - if (plan.consecutive.offset > 0) { - plan.consecutive.offset--; - } else if (plan.consecutive.count % 3 === 0) { - plan.consecutive.trinkets++; - plan.consecutive.gemCapExtra += 5; - if (plan.consecutive.gemCapExtra > 25) { - plan.consecutive.gemCapExtra = 25; - } - } - } - if (plan.dateTerminated && moment(plan.dateTerminated).isBefore(+(new Date))) { - _.merge(plan, { - planId: null, - customerId: null, - paymentMethod: null - }); - _.merge(plan.consecutive, { - count: 0, - offset: 0, - gemCapExtra: 0 - }); - if (typeof user.markModified === "function") { - user.markModified('purchased.plan'); - } - } - } - if (user.preferences.sleep === true) { - user.stats.buffs = clearBuffs; - return; - } - todoTally = 0; - if ((_base = user.party.quest.progress).down == null) { - _base.down = 0; - } - user.todos.concat(user.dailys).forEach(function(task) { - var absVal, completed, delta, id, repeat, scheduleMisses, type; - if (!task) { - return; - } - id = task.id, type = task.type, completed = task.completed, repeat = task.repeat; - if ((type === 'daily') && !completed && user.stats.buffs.stealth && user.stats.buffs.stealth--) { - return; - } - if (!completed) { - scheduleMisses = daysMissed; - if ((type === 'daily') && repeat) { - scheduleMisses = 0; - _.times(daysMissed, function(n) { - var thatDay; - thatDay = moment(now).subtract({ - days: n + 1 - }); - if (api.shouldDo(thatDay, repeat, user.preferences)) { - return scheduleMisses++; - } - }); - } - if (scheduleMisses > 0) { - if (type === 'daily') { - perfect = false; - } - delta = user.ops.score({ - params: { - id: task.id, - direction: 'down' - }, - query: { - times: scheduleMisses, - cron: true - } - }); - if (type === 'daily') { - user.party.quest.progress.down += delta; - } - } - } - switch (type) { - case 'daily': - (task.history != null ? task.history : task.history = []).push({ - date: +(new Date), - value: task.value - }); - task.completed = false; - return _.each(task.checklist, (function(i) { - i.completed = false; - return true; - })); - case 'todo': - absVal = completed ? Math.abs(task.value) : task.value; - return todoTally += absVal; - } - }); - user.habits.forEach(function(task) { - if (task.up === false || task.down === false) { - if (Math.abs(task.value) < 0.1) { - return task.value = 0; - } else { - return task.value = task.value / 2; - } - } - }); - ((_base1 = (user.history != null ? user.history : user.history = {})).todos != null ? _base1.todos : _base1.todos = []).push({ - date: now, - value: todoTally - }); - expTally = user.stats.exp; - lvl = 0; - while (lvl < (user.stats.lvl - 1)) { - lvl++; - expTally += api.tnl(lvl); - } - ((_base2 = user.history).exp != null ? _base2.exp : _base2.exp = []).push({ - date: now, - value: expTally - }); - if (!((_ref1 = user.purchased) != null ? (_ref2 = _ref1.plan) != null ? _ref2.customerId : void 0 : void 0)) { - user.fns.preenUserHistory(); - if (typeof user.markModified === "function") { - user.markModified('history'); - } - if (typeof user.markModified === "function") { - user.markModified('dailys'); - } - } - user.stats.buffs = perfect ? ((_base3 = user.achievements).perfect != null ? _base3.perfect : _base3.perfect = 0, user.achievements.perfect++, user.stats.lvl < 100 ? lvlDiv2 = Math.ceil(user.stats.lvl / 2) : lvlDiv2 = 50, { - str: lvlDiv2, - int: lvlDiv2, - per: lvlDiv2, - con: lvlDiv2, - stealth: 0, - streaks: false - }) : clearBuffs; - user.stats.mp += _.max([10, .1 * user._statsComputed.maxMP]); - if (user.stats.mp > user._statsComputed.maxMP) { - user.stats.mp = user._statsComputed.maxMP; - } - progress = user.party.quest.progress; - _progress = _.cloneDeep(progress); - _.merge(progress, { - down: 0, - up: 0 - }); - progress.collect = _.transform(progress.collect, (function(m, v, k) { - return m[k] = 0; - })); - return _progress; - }, - preenUserHistory: function(minHistLen) { - if (minHistLen == null) { - minHistLen = 7; - } - _.each(user.habits.concat(user.dailys), function(task) { - var _ref; - if (((_ref = task.history) != null ? _ref.length : void 0) > minHistLen) { - task.history = preenHistory(task.history); - } - return true; - }); - _.defaults(user.history, { - todos: [], - exp: [] - }); - if (user.history.exp.length > minHistLen) { - user.history.exp = preenHistory(user.history.exp); - } - if (user.history.todos.length > minHistLen) { - return user.history.todos = preenHistory(user.history.todos); - } - }, - ultimateGear: function() { - var gear, lastGearClassTypeMatrix, ownedLastGear, shouldGrant; - gear = typeof window !== "undefined" && window !== null ? user.items.gear.owned : user.items.gear.owned.toObject(); - ownedLastGear = _.chain(content.gear.flat).pick(_.keys(gear)).values().filter(function(gear) { - return gear.last; - }); - lastGearClassTypeMatrix = {}; - _.each(content.classes, function(klass) { - lastGearClassTypeMatrix[klass] = {}; - return _.each(['armor', 'weapon', 'shield', 'head'], function(type) { - lastGearClassTypeMatrix[klass][type] = false; - return true; - }); - }); - ownedLastGear.each(function(gear) { - if (gear.twoHanded) { - lastGearClassTypeMatrix[gear.klass]["shield"] = true; - } - return lastGearClassTypeMatrix[gear.klass][gear.type] = true; - }); - shouldGrant = _(lastGearClassTypeMatrix).values().reduce((function(ans, klass) { - return ans || _(klass).values().reduce((function(ans, gearType) { - return ans && gearType; - }), true); - }), false).valueOf(); - return user.achievements.ultimateGear = shouldGrant; - }, - nullify: function() { - user.ops = null; - user.fns = null; - return user = null; - } - }; - Object.defineProperty(user, '_statsComputed', { - get: function() { - var computed; - computed = _.reduce(['per', 'con', 'str', 'int'], (function(_this) { - return function(m, stat) { - m[stat] = _.reduce($w('stats stats.buffs items.gear.equipped.weapon items.gear.equipped.armor items.gear.equipped.head items.gear.equipped.shield'), function(m2, path) { - var item, val; - val = user.fns.dotGet(path); - return m2 + (~path.indexOf('items.gear') ? (item = content.gear.flat[val], (+(item != null ? item[stat] : void 0) || 0) * ((item != null ? item.klass : void 0) === user.stats["class"] || (item != null ? item.specialClass : void 0) === user.stats["class"] ? 1.5 : 1)) : +val[stat] || 0); - }, 0); - if (user.stats.lvl < 100) { - m[stat] += (user.stats.lvl - 1) / 2; - } else { - m[stat] += 50; - } - return m; - }; - })(this), {}); - computed.maxMP = computed.int * 2 + 30; - return computed; - } - }); - return Object.defineProperty(user, 'tasks', { - get: function() { - var tasks; - tasks = user.habits.concat(user.dailys).concat(user.todos).concat(user.rewards); - return _.object(_.pluck(tasks, "id"), tasks); - } - }); -}; - - -}).call(this,require('_process')) -},{"./content.coffee":2,"./i18n.coffee":3,"_process":5,"lodash":6,"moment":7}],5:[function(require,module,exports){ -// shim for using process in browser - -var process = module.exports = {}; -var queue = []; -var draining = false; - -function drainQueue() { - if (draining) { - return; - } - draining = true; - var currentQueue; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - var i = -1; - while (++i < len) { - currentQueue[i](); - } - len = queue.length; - } - draining = false; -} -process.nextTick = function (fun) { - queue.push(fun); - if (!draining) { - setTimeout(drainQueue, 0); - } -}; - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],6:[function(require,module,exports){ -(function (global){ -/** - * @license - * Lo-Dash 2.4.1 (Custom Build) - * Build: `lodash modern -o ./dist/lodash.js` - * Copyright 2012-2013 The Dojo Foundation - * Based on Underscore.js 1.5.2 - * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ -;(function() { - - /** Used as a safe reference for `undefined` in pre ES5 environments */ - var undefined; - - /** Used to pool arrays and objects used internally */ - var arrayPool = [], - objectPool = []; - - /** Used to generate unique IDs */ - var idCounter = 0; - - /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */ - var keyPrefix = +new Date + ''; - - /** Used as the size when optimizations are enabled for large arrays */ - var largeArraySize = 75; - - /** Used as the max size of the `arrayPool` and `objectPool` */ - var maxPoolSize = 40; - - /** Used to detect and test whitespace */ - var whitespace = ( - // whitespace - ' \t\x0B\f\xA0\ufeff' + - - // line terminators - '\n\r\u2028\u2029' + - - // unicode category "Zs" space separators - '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' - ); - - /** Used to match empty string literals in compiled template source */ - var reEmptyStringLeading = /\b__p \+= '';/g, - reEmptyStringMiddle = /\b(__p \+=) '' \+/g, - reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - - /** - * Used to match ES6 template delimiters - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals - */ - var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - - /** Used to match regexp flags from their coerced string values */ - var reFlags = /\w*$/; - - /** Used to detected named functions */ - var reFuncName = /^\s*function[ \n\r\t]+\w/; - - /** Used to match "interpolate" template delimiters */ - var reInterpolate = /<%=([\s\S]+?)%>/g; - - /** Used to match leading whitespace and zeros to be removed */ - var reLeadingSpacesAndZeros = RegExp('^[' + whitespace + ']*0+(?=.$)'); - - /** Used to ensure capturing order of template delimiters */ - var reNoMatch = /($^)/; - - /** Used to detect functions containing a `this` reference */ - var reThis = /\bthis\b/; - - /** Used to match unescaped characters in compiled string literals */ - var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; - - /** Used to assign default `context` object properties */ - var contextProps = [ - 'Array', 'Boolean', 'Date', 'Function', 'Math', 'Number', 'Object', - 'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN', - 'parseInt', 'setTimeout' - ]; - - /** Used to make template sourceURLs easier to identify */ - var templateCounter = 0; - - /** `Object#toString` result shortcuts */ - var argsClass = '[object Arguments]', - arrayClass = '[object Array]', - boolClass = '[object Boolean]', - dateClass = '[object Date]', - funcClass = '[object Function]', - numberClass = '[object Number]', - objectClass = '[object Object]', - regexpClass = '[object RegExp]', - stringClass = '[object String]'; - - /** Used to identify object classifications that `_.clone` supports */ - var cloneableClasses = {}; - cloneableClasses[funcClass] = false; - cloneableClasses[argsClass] = cloneableClasses[arrayClass] = - cloneableClasses[boolClass] = cloneableClasses[dateClass] = - cloneableClasses[numberClass] = cloneableClasses[objectClass] = - cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; - - /** Used as an internal `_.debounce` options object */ - var debounceOptions = { - 'leading': false, - 'maxWait': 0, - 'trailing': false - }; - - /** Used as the property descriptor for `__bindData__` */ - var descriptor = { - 'configurable': false, - 'enumerable': false, - 'value': null, - 'writable': false - }; - - /** Used to determine if values are of the language type Object */ - var objectTypes = { - 'boolean': false, - 'function': true, - 'object': true, - 'number': false, - 'string': false, - 'undefined': false - }; - - /** Used to escape characters for inclusion in compiled string literals */ - var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - /** Used as a reference to the global object */ - var root = (objectTypes[typeof window] && window) || this; - - /** Detect free variable `exports` */ - var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - - /** Detect free variable `module` */ - var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - - /** Detect the popular CommonJS extension `module.exports` */ - var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; - - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ - var freeGlobal = objectTypes[typeof global] && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) { - root = freeGlobal; - } - - /*--------------------------------------------------------------------------*/ - - /** - * The base implementation of `_.indexOf` without support for binary searches - * or `fromIndex` constraints. - * - * @private - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value or `-1`. - */ - function baseIndexOf(array, value, fromIndex) { - var index = (fromIndex || 0) - 1, - length = array ? array.length : 0; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * An implementation of `_.contains` for cache objects that mimics the return - * signature of `_.indexOf` by returning `0` if the value is found, else `-1`. - * - * @private - * @param {Object} cache The cache object to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns `0` if `value` is found, else `-1`. - */ - function cacheIndexOf(cache, value) { - var type = typeof value; - cache = cache.cache; - - if (type == 'boolean' || value == null) { - return cache[value] ? 0 : -1; - } - if (type != 'number' && type != 'string') { - type = 'object'; - } - var key = type == 'number' ? value : keyPrefix + value; - cache = (cache = cache[type]) && cache[key]; - - return type == 'object' - ? (cache && baseIndexOf(cache, value) > -1 ? 0 : -1) - : (cache ? 0 : -1); - } - - /** - * Adds a given value to the corresponding cache object. - * - * @private - * @param {*} value The value to add to the cache. - */ - function cachePush(value) { - var cache = this.cache, - type = typeof value; - - if (type == 'boolean' || value == null) { - cache[value] = true; - } else { - if (type != 'number' && type != 'string') { - type = 'object'; - } - var key = type == 'number' ? value : keyPrefix + value, - typeCache = cache[type] || (cache[type] = {}); - - if (type == 'object') { - (typeCache[key] || (typeCache[key] = [])).push(value); - } else { - typeCache[key] = true; - } - } - } - - /** - * Used by `_.max` and `_.min` as the default callback when a given - * collection is a string value. - * - * @private - * @param {string} value The character to inspect. - * @returns {number} Returns the code unit of given character. - */ - function charAtCallback(value) { - return value.charCodeAt(0); - } - - /** - * Used by `sortBy` to compare transformed `collection` elements, stable sorting - * them in ascending order. - * - * @private - * @param {Object} a The object to compare to `b`. - * @param {Object} b The object to compare to `a`. - * @returns {number} Returns the sort order indicator of `1` or `-1`. - */ - function compareAscending(a, b) { - var ac = a.criteria, - bc = b.criteria, - index = -1, - length = ac.length; - - while (++index < length) { - var value = ac[index], - other = bc[index]; - - if (value !== other) { - if (value > other || typeof value == 'undefined') { - return 1; - } - if (value < other || typeof other == 'undefined') { - return -1; - } - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to return the same value for - // `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247 - // - // This also ensures a stable sort in V8 and other engines. - // See http://code.google.com/p/v8/issues/detail?id=90 - return a.index - b.index; - } - - /** - * Creates a cache object to optimize linear searches of large arrays. - * - * @private - * @param {Array} [array=[]] The array to search. - * @returns {null|Object} Returns the cache object or `null` if caching should not be used. - */ - function createCache(array) { - var index = -1, - length = array.length, - first = array[0], - mid = array[(length / 2) | 0], - last = array[length - 1]; - - if (first && typeof first == 'object' && - mid && typeof mid == 'object' && last && typeof last == 'object') { - return false; - } - var cache = getObject(); - cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false; - - var result = getObject(); - result.array = array; - result.cache = cache; - result.push = cachePush; - - while (++index < length) { - result.push(array[index]); - } - return result; - } - - /** - * Used by `template` to escape characters for inclusion in compiled - * string literals. - * - * @private - * @param {string} match The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeStringChar(match) { - return '\\' + stringEscapes[match]; - } - - /** - * Gets an array from the array pool or creates a new one if the pool is empty. - * - * @private - * @returns {Array} The array from the pool. - */ - function getArray() { - return arrayPool.pop() || []; - } - - /** - * Gets an object from the object pool or creates a new one if the pool is empty. - * - * @private - * @returns {Object} The object from the pool. - */ - function getObject() { - return objectPool.pop() || { - 'array': null, - 'cache': null, - 'criteria': null, - 'false': false, - 'index': 0, - 'null': false, - 'number': null, - 'object': null, - 'push': null, - 'string': null, - 'true': false, - 'undefined': false, - 'value': null - }; - } - - /** - * Releases the given array back to the array pool. - * - * @private - * @param {Array} [array] The array to release. - */ - function releaseArray(array) { - array.length = 0; - if (arrayPool.length < maxPoolSize) { - arrayPool.push(array); - } - } - - /** - * Releases the given object back to the object pool. - * - * @private - * @param {Object} [object] The object to release. - */ - function releaseObject(object) { - var cache = object.cache; - if (cache) { - releaseObject(cache); - } - object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null; - if (objectPool.length < maxPoolSize) { - objectPool.push(object); - } - } - - /** - * Slices the `collection` from the `start` index up to, but not including, - * the `end` index. - * - * Note: This function is used instead of `Array#slice` to support node lists - * in IE < 9 and to ensure dense arrays are returned. - * - * @private - * @param {Array|Object|string} collection The collection to slice. - * @param {number} start The start index. - * @param {number} end The end index. - * @returns {Array} Returns the new array. - */ - function slice(array, start, end) { - start || (start = 0); - if (typeof end == 'undefined') { - end = array ? array.length : 0; - } - var index = -1, - length = end - start || 0, - result = Array(length < 0 ? 0 : length); - - while (++index < length) { - result[index] = array[start + index]; - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Create a new `lodash` function using the given context object. - * - * @static - * @memberOf _ - * @category Utilities - * @param {Object} [context=root] The context object. - * @returns {Function} Returns the `lodash` function. - */ - function runInContext(context) { - // Avoid issues with some ES3 environments that attempt to use values, named - // after built-in constructors like `Object`, for the creation of literals. - // ES5 clears this up by stating that literals must use built-in constructors. - // See http://es5.github.io/#x11.1.5. - context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; - - /** Native constructor references */ - var Array = context.Array, - Boolean = context.Boolean, - Date = context.Date, - Function = context.Function, - Math = context.Math, - Number = context.Number, - Object = context.Object, - RegExp = context.RegExp, - String = context.String, - TypeError = context.TypeError; - - /** - * Used for `Array` method references. - * - * Normally `Array.prototype` would suffice, however, using an array literal - * avoids issues in Narwhal. - */ - var arrayRef = []; - - /** Used for native method references */ - var objectProto = Object.prototype; - - /** Used to restore the original `_` reference in `noConflict` */ - var oldDash = context._; - - /** Used to resolve the internal [[Class]] of values */ - var toString = objectProto.toString; - - /** Used to detect if a method is native */ - var reNative = RegExp('^' + - String(toString) - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - .replace(/toString| for [^\]]+/g, '.*?') + '$' - ); - - /** Native method shortcuts */ - var ceil = Math.ceil, - clearTimeout = context.clearTimeout, - floor = Math.floor, - fnToString = Function.prototype.toString, - getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, - hasOwnProperty = objectProto.hasOwnProperty, - push = arrayRef.push, - setTimeout = context.setTimeout, - splice = arrayRef.splice, - unshift = arrayRef.unshift; - - /** Used to set meta data on functions */ - var defineProperty = (function() { - // IE 8 only accepts DOM elements - try { - var o = {}, - func = isNative(func = Object.defineProperty) && func, - result = func(o, o, o) && func; - } catch(e) { } - return result; - }()); - - /* Native method shortcuts for methods with the same name as other `lodash` methods */ - var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, - nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, - nativeIsFinite = context.isFinite, - nativeIsNaN = context.isNaN, - nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, - nativeMax = Math.max, - nativeMin = Math.min, - nativeParseInt = context.parseInt, - nativeRandom = Math.random; - - /** Used to lookup a built-in constructor by [[Class]] */ - var ctorByClass = {}; - ctorByClass[arrayClass] = Array; - ctorByClass[boolClass] = Boolean; - ctorByClass[dateClass] = Date; - ctorByClass[funcClass] = Function; - ctorByClass[objectClass] = Object; - ctorByClass[numberClass] = Number; - ctorByClass[regexpClass] = RegExp; - ctorByClass[stringClass] = String; - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a `lodash` object which wraps the given value to enable intuitive - * method chaining. - * - * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: - * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, - * and `unshift` - * - * Chaining is supported in custom builds as long as the `value` method is - * implicitly or explicitly included in the build. - * - * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, - * `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`, - * `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, - * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, - * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`, - * `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, - * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, - * `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, - * and `zip` - * - * The non-chainable wrapper functions are: - * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, - * `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`, - * `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, - * `template`, `unescape`, `uniqueId`, and `value` - * - * The wrapper functions `first` and `last` return wrapped values when `n` is - * provided, otherwise they return unwrapped values. - * - * Explicit chaining can be enabled by using the `_.chain` method. - * - * @name _ - * @constructor - * @category Chaining - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns a `lodash` instance. - * @example - * - * var wrapped = _([1, 2, 3]); - * - * // returns an unwrapped value - * wrapped.reduce(function(sum, num) { - * return sum + num; - * }); - * // => 6 - * - * // returns a wrapped value - * var squares = wrapped.map(function(num) { - * return num * num; - * }); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ - function lodash(value) { - // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor - return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__')) - ? value - : new lodashWrapper(value); - } - - /** - * A fast path for creating `lodash` wrapper objects. - * - * @private - * @param {*} value The value to wrap in a `lodash` instance. - * @param {boolean} chainAll A flag to enable chaining for all methods - * @returns {Object} Returns a `lodash` instance. - */ - function lodashWrapper(value, chainAll) { - this.__chain__ = !!chainAll; - this.__wrapped__ = value; - } - // ensure `new lodashWrapper` is an instance of `lodash` - lodashWrapper.prototype = lodash.prototype; - - /** - * An object used to flag environments features. - * - * @static - * @memberOf _ - * @type Object - */ - var support = lodash.support = {}; - - /** - * Detect if functions can be decompiled by `Function#toString` - * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). - * - * @memberOf _.support - * @type boolean - */ - support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext); - - /** - * Detect if `Function#name` is supported (all but IE). - * - * @memberOf _.support - * @type boolean - */ - support.funcNames = typeof Function.name == 'string'; - - /** - * By default, the template delimiters used by Lo-Dash are similar to those in - * embedded Ruby (ERB). Change the following template settings to use alternative - * delimiters. - * - * @static - * @memberOf _ - * @type Object - */ - lodash.templateSettings = { - - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'escape': /<%-([\s\S]+?)%>/g, - - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'evaluate': /<%([\s\S]+?)%>/g, - - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'interpolate': reInterpolate, - - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type string - */ - 'variable': '', - - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type Object - */ - 'imports': { - - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type Function - */ - '_': lodash - } - }; - - /*--------------------------------------------------------------------------*/ - - /** - * The base implementation of `_.bind` that creates the bound function and - * sets its meta data. - * - * @private - * @param {Array} bindData The bind data array. - * @returns {Function} Returns the new bound function. - */ - function baseBind(bindData) { - var func = bindData[0], - partialArgs = bindData[2], - thisArg = bindData[4]; - - function bound() { - // `Function#bind` spec - // http://es5.github.io/#x15.3.4.5 - if (partialArgs) { - // avoid `arguments` object deoptimizations by using `slice` instead - // of `Array.prototype.slice.call` and not assigning `arguments` to a - // variable as a ternary expression - var args = slice(partialArgs); - push.apply(args, arguments); - } - // mimic the constructor's `return` behavior - // http://es5.github.io/#x13.2.2 - if (this instanceof bound) { - // ensure `new bound` is an instance of `func` - var thisBinding = baseCreate(func.prototype), - result = func.apply(thisBinding, args || arguments); - return isObject(result) ? result : thisBinding; - } - return func.apply(thisArg, args || arguments); - } - setBindData(bound, bindData); - return bound; - } - - /** - * The base implementation of `_.clone` without argument juggling or support - * for `thisArg` binding. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. - * @param {Function} [callback] The function to customize cloning values. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates clones with source counterparts. - * @returns {*} Returns the cloned value. - */ - function baseClone(value, isDeep, callback, stackA, stackB) { - if (callback) { - var result = callback(value); - if (typeof result != 'undefined') { - return result; - } - } - // inspect [[Class]] - var isObj = isObject(value); - if (isObj) { - var className = toString.call(value); - if (!cloneableClasses[className]) { - return value; - } - var ctor = ctorByClass[className]; - switch (className) { - case boolClass: - case dateClass: - return new ctor(+value); - - case numberClass: - case stringClass: - return new ctor(value); - - case regexpClass: - result = ctor(value.source, reFlags.exec(value)); - result.lastIndex = value.lastIndex; - return result; - } - } else { - return value; - } - var isArr = isArray(value); - if (isDeep) { - // check for circular references and return corresponding clone - var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); - - var length = stackA.length; - while (length--) { - if (stackA[length] == value) { - return stackB[length]; - } - } - result = isArr ? ctor(value.length) : {}; - } - else { - result = isArr ? slice(value) : assign({}, value); - } - // add array properties assigned by `RegExp#exec` - if (isArr) { - if (hasOwnProperty.call(value, 'index')) { - result.index = value.index; - } - if (hasOwnProperty.call(value, 'input')) { - result.input = value.input; - } - } - // exit for shallow clone - if (!isDeep) { - return result; - } - // add the source value to the stack of traversed objects - // and associate it with its clone - stackA.push(value); - stackB.push(result); - - // recursively populate clone (susceptible to call stack limits) - (isArr ? forEach : forOwn)(value, function(objValue, key) { - result[key] = baseClone(objValue, isDeep, callback, stackA, stackB); - }); - - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } - return result; - } - - /** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} prototype The object to inherit from. - * @returns {Object} Returns the new object. - */ - function baseCreate(prototype, properties) { - return isObject(prototype) ? nativeCreate(prototype) : {}; - } - // fallback for browsers without `Object.create` - if (!nativeCreate) { - baseCreate = (function() { - function Object() {} - return function(prototype) { - if (isObject(prototype)) { - Object.prototype = prototype; - var result = new Object; - Object.prototype = null; - } - return result || context.Object(); - }; - }()); - } - - /** - * The base implementation of `_.createCallback` without support for creating - * "_.pluck" or "_.where" style callbacks. - * - * @private - * @param {*} [func=identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. - * @param {number} [argCount] The number of arguments the callback accepts. - * @returns {Function} Returns a callback function. - */ - function baseCreateCallback(func, thisArg, argCount) { - if (typeof func != 'function') { - return identity; - } - // exit early for no `thisArg` or already bound by `Function#bind` - if (typeof thisArg == 'undefined' || !('prototype' in func)) { - return func; - } - var bindData = func.__bindData__; - if (typeof bindData == 'undefined') { - if (support.funcNames) { - bindData = !func.name; - } - bindData = bindData || !support.funcDecomp; - if (!bindData) { - var source = fnToString.call(func); - if (!support.funcNames) { - bindData = !reFuncName.test(source); - } - if (!bindData) { - // checks if `func` references the `this` keyword and stores the result - bindData = reThis.test(source); - setBindData(func, bindData); - } - } - } - // exit early if there are no `this` references or `func` is bound - if (bindData === false || (bindData !== true && bindData[1] & 1)) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 2: return function(a, b) { - return func.call(thisArg, a, b); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - } - return bind(func, thisArg); - } - - /** - * The base implementation of `createWrapper` that creates the wrapper and - * sets its meta data. - * - * @private - * @param {Array} bindData The bind data array. - * @returns {Function} Returns the new function. - */ - function baseCreateWrapper(bindData) { - var func = bindData[0], - bitmask = bindData[1], - partialArgs = bindData[2], - partialRightArgs = bindData[3], - thisArg = bindData[4], - arity = bindData[5]; - - var isBind = bitmask & 1, - isBindKey = bitmask & 2, - isCurry = bitmask & 4, - isCurryBound = bitmask & 8, - key = func; - - function bound() { - var thisBinding = isBind ? thisArg : this; - if (partialArgs) { - var args = slice(partialArgs); - push.apply(args, arguments); - } - if (partialRightArgs || isCurry) { - args || (args = slice(arguments)); - if (partialRightArgs) { - push.apply(args, partialRightArgs); - } - if (isCurry && args.length < arity) { - bitmask |= 16 & ~32; - return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]); - } - } - args || (args = arguments); - if (isBindKey) { - func = thisBinding[key]; - } - if (this instanceof bound) { - thisBinding = baseCreate(func.prototype); - var result = func.apply(thisBinding, args); - return isObject(result) ? result : thisBinding; - } - return func.apply(thisBinding, args); - } - setBindData(bound, bindData); - return bound; - } - - /** - * The base implementation of `_.difference` that accepts a single array - * of values to exclude. - * - * @private - * @param {Array} array The array to process. - * @param {Array} [values] The array of values to exclude. - * @returns {Array} Returns a new array of filtered values. - */ - function baseDifference(array, values) { - var index = -1, - indexOf = getIndexOf(), - length = array ? array.length : 0, - isLarge = length >= largeArraySize && indexOf === baseIndexOf, - result = []; - - if (isLarge) { - var cache = createCache(values); - if (cache) { - indexOf = cacheIndexOf; - values = cache; - } else { - isLarge = false; - } - } - while (++index < length) { - var value = array[index]; - if (indexOf(values, value) < 0) { - result.push(value); - } - } - if (isLarge) { - releaseObject(values); - } - return result; - } - - /** - * The base implementation of `_.flatten` without support for callback - * shorthands or `thisArg` binding. - * - * @private - * @param {Array} array The array to flatten. - * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {boolean} [isStrict=false] A flag to restrict flattening to arrays and `arguments` objects. - * @param {number} [fromIndex=0] The index to start from. - * @returns {Array} Returns a new flattened array. - */ - function baseFlatten(array, isShallow, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, - length = array ? array.length : 0, - result = []; - - while (++index < length) { - var value = array[index]; - - if (value && typeof value == 'object' && typeof value.length == 'number' - && (isArray(value) || isArguments(value))) { - // recursively flatten arrays (susceptible to call stack limits) - if (!isShallow) { - value = baseFlatten(value, isShallow, isStrict); - } - var valIndex = -1, - valLength = value.length, - resIndex = result.length; - - result.length += valLength; - while (++valIndex < valLength) { - result[resIndex++] = value[valIndex]; - } - } else if (!isStrict) { - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.isEqual`, without support for `thisArg` binding, - * that allows partial "_.where" style comparisons. - * - * @private - * @param {*} a The value to compare. - * @param {*} b The other value to compare. - * @param {Function} [callback] The function to customize comparing values. - * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons. - * @param {Array} [stackA=[]] Tracks traversed `a` objects. - * @param {Array} [stackB=[]] Tracks traversed `b` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(a, b, callback, isWhere, stackA, stackB) { - // used to indicate that when comparing objects, `a` has at least the properties of `b` - if (callback) { - var result = callback(a, b); - if (typeof result != 'undefined') { - return !!result; - } - } - // exit early for identical values - if (a === b) { - // treat `+0` vs. `-0` as not equal - return a !== 0 || (1 / a == 1 / b); - } - var type = typeof a, - otherType = typeof b; - - // exit early for unlike primitive values - if (a === a && - !(a && objectTypes[type]) && - !(b && objectTypes[otherType])) { - return false; - } - // exit early for `null` and `undefined` avoiding ES3's Function#call behavior - // http://es5.github.io/#x15.3.4.4 - if (a == null || b == null) { - return a === b; - } - // compare [[Class]] names - var className = toString.call(a), - otherClass = toString.call(b); - - if (className == argsClass) { - className = objectClass; - } - if (otherClass == argsClass) { - otherClass = objectClass; - } - if (className != otherClass) { - return false; - } - switch (className) { - case boolClass: - case dateClass: - // coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal - return +a == +b; - - case numberClass: - // treat `NaN` vs. `NaN` as equal - return (a != +a) - ? b != +b - // but treat `+0` vs. `-0` as not equal - : (a == 0 ? (1 / a == 1 / b) : a == +b); - - case regexpClass: - case stringClass: - // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) - // treat string primitives and their corresponding object instances as equal - return a == String(b); - } - var isArr = className == arrayClass; - if (!isArr) { - // unwrap any `lodash` wrapped values - var aWrapped = hasOwnProperty.call(a, '__wrapped__'), - bWrapped = hasOwnProperty.call(b, '__wrapped__'); - - if (aWrapped || bWrapped) { - return baseIsEqual(aWrapped ? a.__wrapped__ : a, bWrapped ? b.__wrapped__ : b, callback, isWhere, stackA, stackB); - } - // exit for functions and DOM nodes - if (className != objectClass) { - return false; - } - // in older versions of Opera, `arguments` objects have `Array` constructors - var ctorA = a.constructor, - ctorB = b.constructor; - - // non `Object` object instances with different constructors are not equal - if (ctorA != ctorB && - !(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) && - ('constructor' in a && 'constructor' in b) - ) { - return false; - } - } - // assume cyclic structures are equal - // the algorithm for detecting cyclic structures is adapted from ES 5.1 - // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) - var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); - - var length = stackA.length; - while (length--) { - if (stackA[length] == a) { - return stackB[length] == b; - } - } - var size = 0; - result = true; - - // add `a` and `b` to the stack of traversed objects - stackA.push(a); - stackB.push(b); - - // recursively compare objects and arrays (susceptible to call stack limits) - if (isArr) { - // compare lengths to determine if a deep comparison is necessary - length = a.length; - size = b.length; - result = size == length; - - if (result || isWhere) { - // deep compare the contents, ignoring non-numeric properties - while (size--) { - var index = length, - value = b[size]; - - if (isWhere) { - while (index--) { - if ((result = baseIsEqual(a[index], value, callback, isWhere, stackA, stackB))) { - break; - } - } - } else if (!(result = baseIsEqual(a[size], value, callback, isWhere, stackA, stackB))) { - break; - } - } - } - } - else { - // deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys` - // which, in this case, is more costly - forIn(b, function(value, key, b) { - if (hasOwnProperty.call(b, key)) { - // count the number of properties. - size++; - // deep compare each property value. - return (result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, callback, isWhere, stackA, stackB)); - } - }); - - if (result && !isWhere) { - // ensure both objects have the same number of properties - forIn(a, function(value, key, a) { - if (hasOwnProperty.call(a, key)) { - // `size` will be `-1` if `a` has more properties than `b` - return (result = --size > -1); - } - }); - } - } - stackA.pop(); - stackB.pop(); - - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } - return result; - } - - /** - * The base implementation of `_.merge` without argument juggling or support - * for `thisArg` binding. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} [callback] The function to customize merging properties. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates values with source counterparts. - */ - function baseMerge(object, source, callback, stackA, stackB) { - (isArray(source) ? forEach : forOwn)(source, function(source, key) { - var found, - isArr, - result = source, - value = object[key]; - - if (source && ((isArr = isArray(source)) || isPlainObject(source))) { - // avoid merging previously merged cyclic sources - var stackLength = stackA.length; - while (stackLength--) { - if ((found = stackA[stackLength] == source)) { - value = stackB[stackLength]; - break; - } - } - if (!found) { - var isShallow; - if (callback) { - result = callback(value, source); - if ((isShallow = typeof result != 'undefined')) { - value = result; - } - } - if (!isShallow) { - value = isArr - ? (isArray(value) ? value : []) - : (isPlainObject(value) ? value : {}); - } - // add `source` and associated `value` to the stack of traversed objects - stackA.push(source); - stackB.push(value); - - // recursively merge objects and arrays (susceptible to call stack limits) - if (!isShallow) { - baseMerge(value, source, callback, stackA, stackB); - } - } - } - else { - if (callback) { - result = callback(value, source); - if (typeof result == 'undefined') { - result = source; - } - } - if (typeof result != 'undefined') { - value = result; - } - } - object[key] = value; - }); - } - - /** - * The base implementation of `_.random` without argument juggling or support - * for returning floating-point numbers. - * - * @private - * @param {number} min The minimum possible value. - * @param {number} max The maximum possible value. - * @returns {number} Returns a random number. - */ - function baseRandom(min, max) { - return min + floor(nativeRandom() * (max - min + 1)); - } - - /** - * The base implementation of `_.uniq` without support for callback shorthands - * or `thisArg` binding. - * - * @private - * @param {Array} array The array to process. - * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function} [callback] The function called per iteration. - * @returns {Array} Returns a duplicate-value-free array. - */ - function baseUniq(array, isSorted, callback) { - var index = -1, - indexOf = getIndexOf(), - length = array ? array.length : 0, - result = []; - - var isLarge = !isSorted && length >= largeArraySize && indexOf === baseIndexOf, - seen = (callback || isLarge) ? getArray() : result; - - if (isLarge) { - var cache = createCache(seen); - indexOf = cacheIndexOf; - seen = cache; - } - while (++index < length) { - var value = array[index], - computed = callback ? callback(value, index, array) : value; - - if (isSorted - ? !index || seen[seen.length - 1] !== computed - : indexOf(seen, computed) < 0 - ) { - if (callback || isLarge) { - seen.push(computed); - } - result.push(value); - } - } - if (isLarge) { - releaseArray(seen.array); - releaseObject(seen); - } else if (callback) { - releaseArray(seen); - } - return result; - } - - /** - * Creates a function that aggregates a collection, creating an object composed - * of keys generated from the results of running each element of the collection - * through a callback. The given `setter` function sets the keys and values - * of the composed object. - * - * @private - * @param {Function} setter The setter function. - * @returns {Function} Returns the new aggregator function. - */ - function createAggregator(setter) { - return function(collection, callback, thisArg) { - var result = {}; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - var value = collection[index]; - setter(result, value, callback(value, index, collection), collection); - } - } else { - forOwn(collection, function(value, key, collection) { - setter(result, value, callback(value, key, collection), collection); - }); - } - return result; - }; - } - - /** - * Creates a function that, when called, either curries or invokes `func` - * with an optional `this` binding and partially applied arguments. - * - * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of method flags to compose. - * The bitmask may be composed of the following flags: - * 1 - `_.bind` - * 2 - `_.bindKey` - * 4 - `_.curry` - * 8 - `_.curry` (bound) - * 16 - `_.partial` - * 32 - `_.partialRight` - * @param {Array} [partialArgs] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [partialRightArgs] An array of arguments to append to those - * provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new function. - */ - function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { - var isBind = bitmask & 1, - isBindKey = bitmask & 2, - isCurry = bitmask & 4, - isCurryBound = bitmask & 8, - isPartial = bitmask & 16, - isPartialRight = bitmask & 32; - - if (!isBindKey && !isFunction(func)) { - throw new TypeError; - } - if (isPartial && !partialArgs.length) { - bitmask &= ~16; - isPartial = partialArgs = false; - } - if (isPartialRight && !partialRightArgs.length) { - bitmask &= ~32; - isPartialRight = partialRightArgs = false; - } - var bindData = func && func.__bindData__; - if (bindData && bindData !== true) { - // clone `bindData` - bindData = slice(bindData); - if (bindData[2]) { - bindData[2] = slice(bindData[2]); - } - if (bindData[3]) { - bindData[3] = slice(bindData[3]); - } - // set `thisBinding` is not previously bound - if (isBind && !(bindData[1] & 1)) { - bindData[4] = thisArg; - } - // set if previously bound but not currently (subsequent curried functions) - if (!isBind && bindData[1] & 1) { - bitmask |= 8; - } - // set curried arity if not yet set - if (isCurry && !(bindData[1] & 4)) { - bindData[5] = arity; - } - // append partial left arguments - if (isPartial) { - push.apply(bindData[2] || (bindData[2] = []), partialArgs); - } - // append partial right arguments - if (isPartialRight) { - unshift.apply(bindData[3] || (bindData[3] = []), partialRightArgs); - } - // merge flags - bindData[1] |= bitmask; - return createWrapper.apply(null, bindData); - } - // fast path for `_.bind` - var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper; - return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); - } - - /** - * Used by `escape` to convert characters to HTML entities. - * - * @private - * @param {string} match The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; - } - - /** - * Gets the appropriate "indexOf" function. If the `_.indexOf` method is - * customized, this method returns the custom method, otherwise it returns - * the `baseIndexOf` function. - * - * @private - * @returns {Function} Returns the "indexOf" function. - */ - function getIndexOf() { - var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result; - return result; - } - - /** - * Checks if `value` is a native function. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a native function, else `false`. - */ - function isNative(value) { - return typeof value == 'function' && reNative.test(value); - } - - /** - * Sets `this` binding data on a given function. - * - * @private - * @param {Function} func The function to set data on. - * @param {Array} value The data array to set. - */ - var setBindData = !defineProperty ? noop : function(func, value) { - descriptor.value = value; - defineProperty(func, '__bindData__', descriptor); - }; - - /** - * A fallback implementation of `isPlainObject` which checks if a given value - * is an object created by the `Object` constructor, assuming objects created - * by the `Object` constructor have no inherited enumerable properties and that - * there are no `Object.prototype` extensions. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - */ - function shimIsPlainObject(value) { - var ctor, - result; - - // avoid non Object objects, `arguments` objects, and DOM elements - if (!(value && toString.call(value) == objectClass) || - (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor))) { - return false; - } - // In most environments an object's own properties are iterated before - // its inherited properties. If the last iterated property is an object's - // own property then there are no inherited enumerable properties. - forIn(value, function(value, key) { - result = key; - }); - return typeof result == 'undefined' || hasOwnProperty.call(value, result); - } - - /** - * Used by `unescape` to convert HTML entities to characters. - * - * @private - * @param {string} match The matched character to unescape. - * @returns {string} Returns the unescaped character. - */ - function unescapeHtmlChar(match) { - return htmlUnescapes[match]; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Checks if `value` is an `arguments` object. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`. - * @example - * - * (function() { return _.isArguments(arguments); })(1, 2, 3); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ - function isArguments(value) { - return value && typeof value == 'object' && typeof value.length == 'number' && - toString.call(value) == argsClass || false; - } - - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - var isArray = nativeIsArray || function(value) { - return value && typeof value == 'object' && typeof value.length == 'number' && - toString.call(value) == arrayClass || false; - }; - - /** - * A fallback implementation of `Object.keys` which produces an array of the - * given object's own enumerable property names. - * - * @private - * @type Function - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property names. - */ - var shimKeys = function(object) { - var index, iterable = object, result = []; - if (!iterable) return result; - if (!(objectTypes[typeof object])) return result; - for (index in iterable) { - if (hasOwnProperty.call(iterable, index)) { - result.push(index); - } - } - return result - }; - - /** - * Creates an array composed of the own enumerable property names of an object. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property names. - * @example - * - * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - * // => ['one', 'two', 'three'] (property order is not guaranteed across environments) - */ - var keys = !nativeKeys ? shimKeys : function(object) { - if (!isObject(object)) { - return []; - } - return nativeKeys(object); - }; - - /** - * Used to convert characters to HTML entities: - * - * Though the `>` character is escaped for symmetry, characters like `>` and `/` - * don't require escaping in HTML and have no special meaning unless they're part - * of a tag or an unquoted attribute value. - * http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact") - */ - var htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - }; - - /** Used to convert HTML entities to characters */ - var htmlUnescapes = invert(htmlEscapes); - - /** Used to match HTML entities and HTML characters */ - var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'), - reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g'); - - /*--------------------------------------------------------------------------*/ - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources will overwrite property assignments of previous - * sources. If a callback is provided it will be executed to produce the - * assigned values. The callback is bound to `thisArg` and invoked with two - * arguments; (objectValue, sourceValue). - * - * @static - * @memberOf _ - * @type Function - * @alias extend - * @category Objects - * @param {Object} object The destination object. - * @param {...Object} [source] The source objects. - * @param {Function} [callback] The function to customize assigning values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the destination object. - * @example - * - * _.assign({ 'name': 'fred' }, { 'employer': 'slate' }); - * // => { 'name': 'fred', 'employer': 'slate' } - * - * var defaults = _.partialRight(_.assign, function(a, b) { - * return typeof a == 'undefined' ? b : a; - * }); - * - * var object = { 'name': 'barney' }; - * defaults(object, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } - */ - var assign = function(object, source, guard) { - var index, iterable = object, result = iterable; - if (!iterable) return result; - var args = arguments, - argsIndex = 0, - argsLength = typeof guard == 'number' ? 2 : args.length; - if (argsLength > 3 && typeof args[argsLength - 2] == 'function') { - var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2); - } else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') { - callback = args[--argsLength]; - } - while (++argsIndex < argsLength) { - iterable = args[argsIndex]; - if (iterable && objectTypes[typeof iterable]) { - var ownIndex = -1, - ownProps = objectTypes[typeof iterable] && keys(iterable), - length = ownProps ? ownProps.length : 0; - - while (++ownIndex < length) { - index = ownProps[ownIndex]; - result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]; - } - } - } - return result - }; - - /** - * Creates a clone of `value`. If `isDeep` is `true` nested objects will also - * be cloned, otherwise they will be assigned by reference. If a callback - * is provided it will be executed to produce the cloned values. If the - * callback returns `undefined` cloning will be handled by the method instead. - * The callback is bound to `thisArg` and invoked with one argument; (value). - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. - * @param {Function} [callback] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the cloned value. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * var shallow = _.clone(characters); - * shallow[0] === characters[0]; - * // => true - * - * var deep = _.clone(characters, true); - * deep[0] === characters[0]; - * // => false - * - * _.mixin({ - * 'clone': _.partialRight(_.clone, function(value) { - * return _.isElement(value) ? value.cloneNode(false) : undefined; - * }) - * }); - * - * var clone = _.clone(document.body); - * clone.childNodes.length; - * // => 0 - */ - function clone(value, isDeep, callback, thisArg) { - // allows working with "Collections" methods without using their `index` - // and `collection` arguments for `isDeep` and `callback` - if (typeof isDeep != 'boolean' && isDeep != null) { - thisArg = callback; - callback = isDeep; - isDeep = false; - } - return baseClone(value, isDeep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); - } - - /** - * Creates a deep clone of `value`. If a callback is provided it will be - * executed to produce the cloned values. If the callback returns `undefined` - * cloning will be handled by the method instead. The callback is bound to - * `thisArg` and invoked with one argument; (value). - * - * Note: This method is loosely based on the structured clone algorithm. Functions - * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and - * objects created by constructors other than `Object` are cloned to plain `Object` objects. - * See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to deep clone. - * @param {Function} [callback] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the deep cloned value. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * var deep = _.cloneDeep(characters); - * deep[0] === characters[0]; - * // => false - * - * var view = { - * 'label': 'docs', - * 'node': element - * }; - * - * var clone = _.cloneDeep(view, function(value) { - * return _.isElement(value) ? value.cloneNode(true) : undefined; - * }); - * - * clone.node == view.node; - * // => false - */ - function cloneDeep(value, callback, thisArg) { - return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); - } - - /** - * Creates an object that inherits from the given `prototype` object. If a - * `properties` object is provided its own enumerable properties are assigned - * to the created object. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true - */ - function create(prototype, properties) { - var result = baseCreate(prototype); - return properties ? assign(result, properties) : result; - } - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property will be ignored. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {Object} object The destination object. - * @param {...Object} [source] The source objects. - * @param- {Object} [guard] Allows working with `_.reduce` without using its - * `key` and `object` arguments as sources. - * @returns {Object} Returns the destination object. - * @example - * - * var object = { 'name': 'barney' }; - * _.defaults(object, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } - */ - var defaults = function(object, source, guard) { - var index, iterable = object, result = iterable; - if (!iterable) return result; - var args = arguments, - argsIndex = 0, - argsLength = typeof guard == 'number' ? 2 : args.length; - while (++argsIndex < argsLength) { - iterable = args[argsIndex]; - if (iterable && objectTypes[typeof iterable]) { - var ownIndex = -1, - ownProps = objectTypes[typeof iterable] && keys(iterable), - length = ownProps ? ownProps.length : 0; - - while (++ownIndex < length) { - index = ownProps[ownIndex]; - if (typeof result[index] == 'undefined') result[index] = iterable[index]; - } - } - } - return result - }; - - /** - * This method is like `_.findIndex` except that it returns the key of the - * first element that passes the callback check, instead of the element itself. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {string|undefined} Returns the key of the found element, else `undefined`. - * @example - * - * var characters = { - * 'barney': { 'age': 36, 'blocked': false }, - * 'fred': { 'age': 40, 'blocked': true }, - * 'pebbles': { 'age': 1, 'blocked': false } - * }; - * - * _.findKey(characters, function(chr) { - * return chr.age < 40; - * }); - * // => 'barney' (property order is not guaranteed across environments) - * - * // using "_.where" callback shorthand - * _.findKey(characters, { 'age': 1 }); - * // => 'pebbles' - * - * // using "_.pluck" callback shorthand - * _.findKey(characters, 'blocked'); - * // => 'fred' - */ - function findKey(object, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - forOwn(object, function(value, key, object) { - if (callback(value, key, object)) { - result = key; - return false; - } - }); - return result; - } - - /** - * This method is like `_.findKey` except that it iterates over elements - * of a `collection` in the opposite order. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {string|undefined} Returns the key of the found element, else `undefined`. - * @example - * - * var characters = { - * 'barney': { 'age': 36, 'blocked': true }, - * 'fred': { 'age': 40, 'blocked': false }, - * 'pebbles': { 'age': 1, 'blocked': true } - * }; - * - * _.findLastKey(characters, function(chr) { - * return chr.age < 40; - * }); - * // => returns `pebbles`, assuming `_.findKey` returns `barney` - * - * // using "_.where" callback shorthand - * _.findLastKey(characters, { 'age': 40 }); - * // => 'fred' - * - * // using "_.pluck" callback shorthand - * _.findLastKey(characters, 'blocked'); - * // => 'pebbles' - */ - function findLastKey(object, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - forOwnRight(object, function(value, key, object) { - if (callback(value, key, object)) { - result = key; - return false; - } - }); - return result; - } - - /** - * Iterates over own and inherited enumerable properties of an object, - * executing the callback for each property. The callback is bound to `thisArg` - * and invoked with three arguments; (value, key, object). Callbacks may exit - * iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * Shape.prototype.move = function(x, y) { - * this.x += x; - * this.y += y; - * }; - * - * _.forIn(new Shape, function(value, key) { - * console.log(key); - * }); - * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) - */ - var forIn = function(collection, callback, thisArg) { - var index, iterable = collection, result = iterable; - if (!iterable) return result; - if (!objectTypes[typeof iterable]) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - for (index in iterable) { - if (callback(iterable[index], index, collection) === false) return result; - } - return result - }; - - /** - * This method is like `_.forIn` except that it iterates over elements - * of a `collection` in the opposite order. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * Shape.prototype.move = function(x, y) { - * this.x += x; - * this.y += y; - * }; - * - * _.forInRight(new Shape, function(value, key) { - * console.log(key); - * }); - * // => logs 'move', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'move' - */ - function forInRight(object, callback, thisArg) { - var pairs = []; - - forIn(object, function(value, key) { - pairs.push(key, value); - }); - - var length = pairs.length; - callback = baseCreateCallback(callback, thisArg, 3); - while (length--) { - if (callback(pairs[length--], pairs[length], object) === false) { - break; - } - } - return object; - } - - /** - * Iterates over own enumerable properties of an object, executing the callback - * for each property. The callback is bound to `thisArg` and invoked with three - * arguments; (value, key, object). Callbacks may exit iteration early by - * explicitly returning `false`. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * console.log(key); - * }); - * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) - */ - var forOwn = function(collection, callback, thisArg) { - var index, iterable = collection, result = iterable; - if (!iterable) return result; - if (!objectTypes[typeof iterable]) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - var ownIndex = -1, - ownProps = objectTypes[typeof iterable] && keys(iterable), - length = ownProps ? ownProps.length : 0; - - while (++ownIndex < length) { - index = ownProps[ownIndex]; - if (callback(iterable[index], index, collection) === false) return result; - } - return result - }; - - /** - * This method is like `_.forOwn` except that it iterates over elements - * of a `collection` in the opposite order. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * console.log(key); - * }); - * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' - */ - function forOwnRight(object, callback, thisArg) { - var props = keys(object), - length = props.length; - - callback = baseCreateCallback(callback, thisArg, 3); - while (length--) { - var key = props[length]; - if (callback(object[key], key, object) === false) { - break; - } - } - return object; - } - - /** - * Creates a sorted array of property names of all enumerable properties, - * own and inherited, of `object` that have function values. - * - * @static - * @memberOf _ - * @alias methods - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property names that have function values. - * @example - * - * _.functions(_); - * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] - */ - function functions(object) { - var result = []; - forIn(object, function(value, key) { - if (isFunction(value)) { - result.push(key); - } - }); - return result.sort(); - } - - /** - * Checks if the specified property name exists as a direct property of `object`, - * instead of an inherited property. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @param {string} key The name of the property to check. - * @returns {boolean} Returns `true` if key is a direct property, else `false`. - * @example - * - * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); - * // => true - */ - function has(object, key) { - return object ? hasOwnProperty.call(object, key) : false; - } - - /** - * Creates an object composed of the inverted keys and values of the given object. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to invert. - * @returns {Object} Returns the created inverted object. - * @example - * - * _.invert({ 'first': 'fred', 'second': 'barney' }); - * // => { 'fred': 'first', 'barney': 'second' } - */ - function invert(object) { - var index = -1, - props = keys(object), - length = props.length, - result = {}; - - while (++index < length) { - var key = props[index]; - result[object[key]] = key; - } - return result; - } - - /** - * Checks if `value` is a boolean value. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`. - * @example - * - * _.isBoolean(null); - * // => false - */ - function isBoolean(value) { - return value === true || value === false || - value && typeof value == 'object' && toString.call(value) == boolClass || false; - } - - /** - * Checks if `value` is a date. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a date, else `false`. - * @example - * - * _.isDate(new Date); - * // => true - */ - function isDate(value) { - return value && typeof value == 'object' && toString.call(value) == dateClass || false; - } - - /** - * Checks if `value` is a DOM element. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a DOM element, else `false`. - * @example - * - * _.isElement(document.body); - * // => true - */ - function isElement(value) { - return value && value.nodeType === 1 || false; - } - - /** - * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a - * length of `0` and objects with no own enumerable properties are considered - * "empty". - * - * @static - * @memberOf _ - * @category Objects - * @param {Array|Object|string} value The value to inspect. - * @returns {boolean} Returns `true` if the `value` is empty, else `false`. - * @example - * - * _.isEmpty([1, 2, 3]); - * // => false - * - * _.isEmpty({}); - * // => true - * - * _.isEmpty(''); - * // => true - */ - function isEmpty(value) { - var result = true; - if (!value) { - return result; - } - var className = toString.call(value), - length = value.length; - - if ((className == arrayClass || className == stringClass || className == argsClass ) || - (className == objectClass && typeof length == 'number' && isFunction(value.splice))) { - return !length; - } - forOwn(value, function() { - return (result = false); - }); - return result; - } - - /** - * Performs a deep comparison between two values to determine if they are - * equivalent to each other. If a callback is provided it will be executed - * to compare values. If the callback returns `undefined` comparisons will - * be handled by the method instead. The callback is bound to `thisArg` and - * invoked with two arguments; (a, b). - * - * @static - * @memberOf _ - * @category Objects - * @param {*} a The value to compare. - * @param {*} b The other value to compare. - * @param {Function} [callback] The function to customize comparing values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'name': 'fred' }; - * var copy = { 'name': 'fred' }; - * - * object == copy; - * // => false - * - * _.isEqual(object, copy); - * // => true - * - * var words = ['hello', 'goodbye']; - * var otherWords = ['hi', 'goodbye']; - * - * _.isEqual(words, otherWords, function(a, b) { - * var reGreet = /^(?:hello|hi)$/i, - * aGreet = _.isString(a) && reGreet.test(a), - * bGreet = _.isString(b) && reGreet.test(b); - * - * return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; - * }); - * // => true - */ - function isEqual(a, b, callback, thisArg) { - return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2)); - } - - /** - * Checks if `value` is, or can be coerced to, a finite number. - * - * Note: This is not the same as native `isFinite` which will return true for - * booleans and empty strings. See http://es5.github.io/#x15.1.2.5. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is finite, else `false`. - * @example - * - * _.isFinite(-101); - * // => true - * - * _.isFinite('10'); - * // => true - * - * _.isFinite(true); - * // => false - * - * _.isFinite(''); - * // => false - * - * _.isFinite(Infinity); - * // => false - */ - function isFinite(value) { - return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value)); - } - - /** - * Checks if `value` is a function. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - */ - function isFunction(value) { - return typeof value == 'function'; - } - - /** - * Checks if `value` is the language type of Object. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ - function isObject(value) { - // check if the value is the ECMAScript language type of Object - // http://es5.github.io/#x8 - // and avoid a V8 bug - // http://code.google.com/p/v8/issues/detail?id=2291 - return !!(value && objectTypes[typeof value]); - } - - /** - * Checks if `value` is `NaN`. - * - * Note: This is not the same as native `isNaN` which will return `true` for - * `undefined` and other non-numeric values. See http://es5.github.io/#x15.1.2.4. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is `NaN`, else `false`. - * @example - * - * _.isNaN(NaN); - * // => true - * - * _.isNaN(new Number(NaN)); - * // => true - * - * isNaN(undefined); - * // => true - * - * _.isNaN(undefined); - * // => false - */ - function isNaN(value) { - // `NaN` as a primitive is the only value that is not equal to itself - // (perform the [[Class]] check first to avoid errors with some host objects in IE) - return isNumber(value) && value != +value; - } - - /** - * Checks if `value` is `null`. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is `null`, else `false`. - * @example - * - * _.isNull(null); - * // => true - * - * _.isNull(undefined); - * // => false - */ - function isNull(value) { - return value === null; - } - - /** - * Checks if `value` is a number. - * - * Note: `NaN` is considered a number. See http://es5.github.io/#x8.5. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a number, else `false`. - * @example - * - * _.isNumber(8.4 * 5); - * // => true - */ - function isNumber(value) { - return typeof value == 'number' || - value && typeof value == 'object' && toString.call(value) == numberClass || false; - } - - /** - * Checks if `value` is an object created by the `Object` constructor. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * _.isPlainObject(new Shape); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - */ - var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { - if (!(value && toString.call(value) == objectClass)) { - return false; - } - var valueOf = value.valueOf, - objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); - - return objProto - ? (value == objProto || getPrototypeOf(value) == objProto) - : shimIsPlainObject(value); - }; - - /** - * Checks if `value` is a regular expression. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a regular expression, else `false`. - * @example - * - * _.isRegExp(/fred/); - * // => true - */ - function isRegExp(value) { - return value && typeof value == 'object' && toString.call(value) == regexpClass || false; - } - - /** - * Checks if `value` is a string. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a string, else `false`. - * @example - * - * _.isString('fred'); - * // => true - */ - function isString(value) { - return typeof value == 'string' || - value && typeof value == 'object' && toString.call(value) == stringClass || false; - } - - /** - * Checks if `value` is `undefined`. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true - */ - function isUndefined(value) { - return typeof value == 'undefined'; - } - - /** - * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through the callback. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, key, object). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new object with values of the results of each `callback` execution. - * @example - * - * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; }); - * // => { 'a': 3, 'b': 6, 'c': 9 } - * - * var characters = { - * 'fred': { 'name': 'fred', 'age': 40 }, - * 'pebbles': { 'name': 'pebbles', 'age': 1 } - * }; - * - * // using "_.pluck" callback shorthand - * _.mapValues(characters, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } - */ - function mapValues(object, callback, thisArg) { - var result = {}; - callback = lodash.createCallback(callback, thisArg, 3); - - forOwn(object, function(value, key, object) { - result[key] = callback(value, key, object); - }); - return result; - } - - /** - * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined` into the destination object. Subsequent sources - * will overwrite property assignments of previous sources. If a callback is - * provided it will be executed to produce the merged values of the destination - * and source properties. If the callback returns `undefined` merging will - * be handled by the method instead. The callback is bound to `thisArg` and - * invoked with two arguments; (objectValue, sourceValue). - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The destination object. - * @param {...Object} [source] The source objects. - * @param {Function} [callback] The function to customize merging properties. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the destination object. - * @example - * - * var names = { - * 'characters': [ - * { 'name': 'barney' }, - * { 'name': 'fred' } - * ] - * }; - * - * var ages = { - * 'characters': [ - * { 'age': 36 }, - * { 'age': 40 } - * ] - * }; - * - * _.merge(names, ages); - * // => { 'characters': [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] } - * - * var food = { - * 'fruits': ['apple'], - * 'vegetables': ['beet'] - * }; - * - * var otherFood = { - * 'fruits': ['banana'], - * 'vegetables': ['carrot'] - * }; - * - * _.merge(food, otherFood, function(a, b) { - * return _.isArray(a) ? a.concat(b) : undefined; - * }); - * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] } - */ - function merge(object) { - var args = arguments, - length = 2; - - if (!isObject(object)) { - return object; - } - // allows working with `_.reduce` and `_.reduceRight` without using - // their `index` and `collection` arguments - if (typeof args[2] != 'number') { - length = args.length; - } - if (length > 3 && typeof args[length - 2] == 'function') { - var callback = baseCreateCallback(args[--length - 1], args[length--], 2); - } else if (length > 2 && typeof args[length - 1] == 'function') { - callback = args[--length]; - } - var sources = slice(arguments, 1, length), - index = -1, - stackA = getArray(), - stackB = getArray(); - - while (++index < length) { - baseMerge(object, sources[index], callback, stackA, stackB); - } - releaseArray(stackA); - releaseArray(stackB); - return object; - } - - /** - * Creates a shallow clone of `object` excluding the specified properties. - * Property names may be specified as individual arguments or as arrays of - * property names. If a callback is provided it will be executed for each - * property of `object` omitting the properties the callback returns truey - * for. The callback is bound to `thisArg` and invoked with three arguments; - * (value, key, object). - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The source object. - * @param {Function|...string|string[]} [callback] The properties to omit or the - * function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns an object without the omitted properties. - * @example - * - * _.omit({ 'name': 'fred', 'age': 40 }, 'age'); - * // => { 'name': 'fred' } - * - * _.omit({ 'name': 'fred', 'age': 40 }, function(value) { - * return typeof value == 'number'; - * }); - * // => { 'name': 'fred' } - */ - function omit(object, callback, thisArg) { - var result = {}; - if (typeof callback != 'function') { - var props = []; - forIn(object, function(value, key) { - props.push(key); - }); - props = baseDifference(props, baseFlatten(arguments, true, false, 1)); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - result[key] = object[key]; - } - } else { - callback = lodash.createCallback(callback, thisArg, 3); - forIn(object, function(value, key, object) { - if (!callback(value, key, object)) { - result[key] = value; - } - }); - } - return result; - } - - /** - * Creates a two dimensional array of an object's key-value pairs, - * i.e. `[[key1, value1], [key2, value2]]`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns new array of key-value pairs. - * @example - * - * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments) - */ - function pairs(object) { - var index = -1, - props = keys(object), - length = props.length, - result = Array(length); - - while (++index < length) { - var key = props[index]; - result[index] = [key, object[key]]; - } - return result; - } - - /** - * Creates a shallow clone of `object` composed of the specified properties. - * Property names may be specified as individual arguments or as arrays of - * property names. If a callback is provided it will be executed for each - * property of `object` picking the properties the callback returns truey - * for. The callback is bound to `thisArg` and invoked with three arguments; - * (value, key, object). - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The source object. - * @param {Function|...string|string[]} [callback] The function called per - * iteration or property names to pick, specified as individual property - * names or arrays of property names. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns an object composed of the picked properties. - * @example - * - * _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name'); - * // => { 'name': 'fred' } - * - * _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) { - * return key.charAt(0) != '_'; - * }); - * // => { 'name': 'fred' } - */ - function pick(object, callback, thisArg) { - var result = {}; - if (typeof callback != 'function') { - var index = -1, - props = baseFlatten(arguments, true, false, 1), - length = isObject(object) ? props.length : 0; - - while (++index < length) { - var key = props[index]; - if (key in object) { - result[key] = object[key]; - } - } - } else { - callback = lodash.createCallback(callback, thisArg, 3); - forIn(object, function(value, key, object) { - if (callback(value, key, object)) { - result[key] = value; - } - }); - } - return result; - } - - /** - * An alternative to `_.reduce` this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable properties through a callback, with each callback execution - * potentially mutating the `accumulator` object. The callback is bound to - * `thisArg` and invoked with four arguments; (accumulator, value, key, object). - * Callbacks may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Array|Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the accumulated value. - * @example - * - * var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) { - * num *= num; - * if (num % 2) { - * return result.push(num) < 3; - * } - * }); - * // => [1, 9, 25] - * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; - * }); - * // => { 'a': 3, 'b': 6, 'c': 9 } - */ - function transform(object, callback, accumulator, thisArg) { - var isArr = isArray(object); - if (accumulator == null) { - if (isArr) { - accumulator = []; - } else { - var ctor = object && object.constructor, - proto = ctor && ctor.prototype; - - accumulator = baseCreate(proto); - } - } - if (callback) { - callback = lodash.createCallback(callback, thisArg, 4); - (isArr ? forEach : forOwn)(object, function(value, index, object) { - return callback(accumulator, value, index, object); - }); - } - return accumulator; - } - - /** - * Creates an array composed of the own enumerable property values of `object`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property values. - * @example - * - * _.values({ 'one': 1, 'two': 2, 'three': 3 }); - * // => [1, 2, 3] (property order is not guaranteed across environments) - */ - function values(object) { - var index = -1, - props = keys(object), - length = props.length, - result = Array(length); - - while (++index < length) { - result[index] = object[props[index]]; - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates an array of elements from the specified indexes, or keys, of the - * `collection`. Indexes may be specified as individual arguments or as arrays - * of indexes. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {...(number|number[]|string|string[])} [index] The indexes of `collection` - * to retrieve, specified as individual indexes or arrays of indexes. - * @returns {Array} Returns a new array of elements corresponding to the - * provided indexes. - * @example - * - * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); - * // => ['a', 'c', 'e'] - * - * _.at(['fred', 'barney', 'pebbles'], 0, 2); - * // => ['fred', 'pebbles'] - */ - function at(collection) { - var args = arguments, - index = -1, - props = baseFlatten(args, true, false, 1), - length = (args[2] && args[2][args[1]] === collection) ? 1 : props.length, - result = Array(length); - - while(++index < length) { - result[index] = collection[props[index]]; - } - return result; - } - - /** - * Checks if a given value is present in a collection using strict equality - * for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the - * offset from the end of the collection. - * - * @static - * @memberOf _ - * @alias include - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {*} target The value to check for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if the `target` element is found, else `false`. - * @example - * - * _.contains([1, 2, 3], 1); - * // => true - * - * _.contains([1, 2, 3], 1, 2); - * // => false - * - * _.contains({ 'name': 'fred', 'age': 40 }, 'fred'); - * // => true - * - * _.contains('pebbles', 'eb'); - * // => true - */ - function contains(collection, target, fromIndex) { - var index = -1, - indexOf = getIndexOf(), - length = collection ? collection.length : 0, - result = false; - - fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; - if (isArray(collection)) { - result = indexOf(collection, target, fromIndex) > -1; - } else if (typeof length == 'number') { - result = (isString(collection) ? collection.indexOf(target, fromIndex) : indexOf(collection, target, fromIndex)) > -1; - } else { - forOwn(collection, function(value) { - if (++index >= fromIndex) { - return !(result = value === target); - } - }); - } - return result; - } - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through the callback. The corresponding value - * of each key is the number of times the key was returned by the callback. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); - * // => { '4': 1, '6': 2 } - * - * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); - * // => { '4': 1, '6': 2 } - * - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } - */ - var countBy = createAggregator(function(result, value, key) { - (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); - }); - - /** - * Checks if the given callback returns truey value for **all** elements of - * a collection. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias all - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {boolean} Returns `true` if all elements passed the callback check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes']); - * // => false - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * // using "_.pluck" callback shorthand - * _.every(characters, 'age'); - * // => true - * - * // using "_.where" callback shorthand - * _.every(characters, { 'age': 36 }); - * // => false - */ - function every(collection, callback, thisArg) { - var result = true; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - if (!(result = !!callback(collection[index], index, collection))) { - break; - } - } - } else { - forOwn(collection, function(value, index, collection) { - return (result = !!callback(value, index, collection)); - }); - } - return result; - } - - /** - * Iterates over elements of a collection, returning an array of all elements - * the callback returns truey for. The callback is bound to `thisArg` and - * invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias select - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of elements that passed the callback check. - * @example - * - * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - * // => [2, 4, 6] - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true } - * ]; - * - * // using "_.pluck" callback shorthand - * _.filter(characters, 'blocked'); - * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] - * - * // using "_.where" callback shorthand - * _.filter(characters, { 'age': 36 }); - * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }] - */ - function filter(collection, callback, thisArg) { - var result = []; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - var value = collection[index]; - if (callback(value, index, collection)) { - result.push(value); - } - } - } else { - forOwn(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result.push(value); - } - }); - } - return result; - } - - /** - * Iterates over elements of a collection, returning the first element that - * the callback returns truey for. The callback is bound to `thisArg` and - * invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias detect, findWhere - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the found element, else `undefined`. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true }, - * { 'name': 'pebbles', 'age': 1, 'blocked': false } - * ]; - * - * _.find(characters, function(chr) { - * return chr.age < 40; - * }); - * // => { 'name': 'barney', 'age': 36, 'blocked': false } - * - * // using "_.where" callback shorthand - * _.find(characters, { 'age': 1 }); - * // => { 'name': 'pebbles', 'age': 1, 'blocked': false } - * - * // using "_.pluck" callback shorthand - * _.find(characters, 'blocked'); - * // => { 'name': 'fred', 'age': 40, 'blocked': true } - */ - function find(collection, callback, thisArg) { - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - var value = collection[index]; - if (callback(value, index, collection)) { - return value; - } - } - } else { - var result; - forOwn(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return false; - } - }); - return result; - } - } - - /** - * This method is like `_.find` except that it iterates over elements - * of a `collection` from right to left. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the found element, else `undefined`. - * @example - * - * _.findLast([1, 2, 3, 4], function(num) { - * return num % 2 == 1; - * }); - * // => 3 - */ - function findLast(collection, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - forEachRight(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return false; - } - }); - return result; - } - - /** - * Iterates over elements of a collection, executing the callback for each - * element. The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). Callbacks may exit iteration early by - * explicitly returning `false`. - * - * Note: As with other "Collections" methods, objects with a `length` property - * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` - * may be used for object iteration. - * - * @static - * @memberOf _ - * @alias each - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); - * // => logs each number and returns '1,2,3' - * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - * // => logs each number and returns the object (property order is not guaranteed across environments) - */ - function forEach(collection, callback, thisArg) { - var index = -1, - length = collection ? collection.length : 0; - - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { - while (++index < length) { - if (callback(collection[index], index, collection) === false) { - break; - } - } - } else { - forOwn(collection, callback); - } - return collection; - } - - /** - * This method is like `_.forEach` except that it iterates over elements - * of a `collection` from right to left. - * - * @static - * @memberOf _ - * @alias eachRight - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); - * // => logs each number from right to left and returns '3,2,1' - */ - function forEachRight(collection, callback, thisArg) { - var length = collection ? collection.length : 0; - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { - while (length--) { - if (callback(collection[length], length, collection) === false) { - break; - } - } - } else { - var props = keys(collection); - length = props.length; - forOwn(collection, function(value, key, collection) { - key = props ? props[--length] : --length; - return callback(collection[key], key, collection); - }); - } - return collection; - } - - /** - * Creates an object composed of keys generated from the results of running - * each element of a collection through the callback. The corresponding value - * of each key is an array of the elements responsible for generating the key. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false` - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * // using "_.pluck" callback shorthand - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } - */ - var groupBy = createAggregator(function(result, value, key) { - (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); - }); - - /** - * Creates an object composed of keys generated from the results of running - * each element of the collection through the given callback. The corresponding - * value of each key is the last element responsible for generating the key. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var keys = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.indexBy(keys, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - */ - var indexBy = createAggregator(function(result, value, key) { - result[key] = value; - }); - - /** - * Invokes the method named by `methodName` on each element in the `collection` - * returning an array of the results of each invoked method. Additional arguments - * will be provided to each invoked method. If `methodName` is a function it - * will be invoked for, and `this` bound to, each element in the `collection`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|string} methodName The name of the method to invoke or - * the function invoked per iteration. - * @param {...*} [arg] Arguments to invoke the method with. - * @returns {Array} Returns a new array of the results of each invoked method. - * @example - * - * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] - * - * _.invoke([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] - */ - function invoke(collection, methodName) { - var args = slice(arguments, 2), - index = -1, - isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); - - forEach(collection, function(value) { - result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); - }); - return result; - } - - /** - * Creates an array of values by running each element in the collection - * through the callback. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias collect - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of the results of each `callback` execution. - * @example - * - * _.map([1, 2, 3], function(num) { return num * 3; }); - * // => [3, 6, 9] - * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); - * // => [3, 6, 9] (property order is not guaranteed across environments) - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * // using "_.pluck" callback shorthand - * _.map(characters, 'name'); - * // => ['barney', 'fred'] - */ - function map(collection, callback, thisArg) { - var index = -1, - length = collection ? collection.length : 0; - - callback = lodash.createCallback(callback, thisArg, 3); - if (typeof length == 'number') { - var result = Array(length); - while (++index < length) { - result[index] = callback(collection[index], index, collection); - } - } else { - result = []; - forOwn(collection, function(value, key, collection) { - result[++index] = callback(value, key, collection); - }); - } - return result; - } - - /** - * Retrieves the maximum value of a collection. If the collection is empty or - * falsey `-Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the maximum value. - * @example - * - * _.max([4, 2, 8, 6]); - * // => 8 - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * _.max(characters, function(chr) { return chr.age; }); - * // => { 'name': 'fred', 'age': 40 }; - * - * // using "_.pluck" callback shorthand - * _.max(characters, 'age'); - * // => { 'name': 'fred', 'age': 40 }; - */ - function max(collection, callback, thisArg) { - var computed = -Infinity, - result = computed; - - // allows working with functions like `_.map` without using - // their `index` argument as a callback - if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) { - callback = null; - } - if (callback == null && isArray(collection)) { - var index = -1, - length = collection.length; - - while (++index < length) { - var value = collection[index]; - if (value > result) { - result = value; - } - } - } else { - callback = (callback == null && isString(collection)) - ? charAtCallback - : lodash.createCallback(callback, thisArg, 3); - - forEach(collection, function(value, index, collection) { - var current = callback(value, index, collection); - if (current > computed) { - computed = current; - result = value; - } - }); - } - return result; - } - - /** - * Retrieves the minimum value of a collection. If the collection is empty or - * falsey `Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the minimum value. - * @example - * - * _.min([4, 2, 8, 6]); - * // => 2 - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * _.min(characters, function(chr) { return chr.age; }); - * // => { 'name': 'barney', 'age': 36 }; - * - * // using "_.pluck" callback shorthand - * _.min(characters, 'age'); - * // => { 'name': 'barney', 'age': 36 }; - */ - function min(collection, callback, thisArg) { - var computed = Infinity, - result = computed; - - // allows working with functions like `_.map` without using - // their `index` argument as a callback - if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) { - callback = null; - } - if (callback == null && isArray(collection)) { - var index = -1, - length = collection.length; - - while (++index < length) { - var value = collection[index]; - if (value < result) { - result = value; - } - } - } else { - callback = (callback == null && isString(collection)) - ? charAtCallback - : lodash.createCallback(callback, thisArg, 3); - - forEach(collection, function(value, index, collection) { - var current = callback(value, index, collection); - if (current < computed) { - computed = current; - result = value; - } - }); - } - return result; - } - - /** - * Retrieves the value of a specified property from all elements in the collection. - * - * @static - * @memberOf _ - * @type Function - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {string} property The name of the property to pluck. - * @returns {Array} Returns a new array of property values. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * _.pluck(characters, 'name'); - * // => ['barney', 'fred'] - */ - var pluck = map; - - /** - * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through the callback, where each successive - * callback execution consumes the return value of the previous execution. If - * `accumulator` is not provided the first element of the collection will be - * used as the initial `accumulator` value. The callback is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, index|key, collection). - * - * @static - * @memberOf _ - * @alias foldl, inject - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [accumulator] Initial value of the accumulator. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the accumulated value. - * @example - * - * var sum = _.reduce([1, 2, 3], function(sum, num) { - * return sum + num; - * }); - * // => 6 - * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; - * return result; - * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } - */ - function reduce(collection, callback, accumulator, thisArg) { - if (!collection) return accumulator; - var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); - - var index = -1, - length = collection.length; - - if (typeof length == 'number') { - if (noaccum) { - accumulator = collection[++index]; - } - while (++index < length) { - accumulator = callback(accumulator, collection[index], index, collection); - } - } else { - forOwn(collection, function(value, index, collection) { - accumulator = noaccum - ? (noaccum = false, value) - : callback(accumulator, value, index, collection) - }); - } - return accumulator; - } - - /** - * This method is like `_.reduce` except that it iterates over elements - * of a `collection` from right to left. - * - * @static - * @memberOf _ - * @alias foldr - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [accumulator] Initial value of the accumulator. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the accumulated value. - * @example - * - * var list = [[0, 1], [2, 3], [4, 5]]; - * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); - * // => [4, 5, 2, 3, 0, 1] - */ - function reduceRight(collection, callback, accumulator, thisArg) { - var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); - forEachRight(collection, function(value, index, collection) { - accumulator = noaccum - ? (noaccum = false, value) - : callback(accumulator, value, index, collection); - }); - return accumulator; - } - - /** - * The opposite of `_.filter` this method returns the elements of a - * collection that the callback does **not** return truey for. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of elements that failed the callback check. - * @example - * - * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - * // => [1, 3, 5] - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true } - * ]; - * - * // using "_.pluck" callback shorthand - * _.reject(characters, 'blocked'); - * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }] - * - * // using "_.where" callback shorthand - * _.reject(characters, { 'age': 36 }); - * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] - */ - function reject(collection, callback, thisArg) { - callback = lodash.createCallback(callback, thisArg, 3); - return filter(collection, function(value, index, collection) { - return !callback(value, index, collection); - }); - } - - /** - * Retrieves a random element or `n` random elements from a collection. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to sample. - * @param {number} [n] The number of elements to sample. - * @param- {Object} [guard] Allows working with functions like `_.map` - * without using their `index` arguments as `n`. - * @returns {Array} Returns the random sample(s) of `collection`. - * @example - * - * _.sample([1, 2, 3, 4]); - * // => 2 - * - * _.sample([1, 2, 3, 4], 2); - * // => [3, 1] - */ - function sample(collection, n, guard) { - if (collection && typeof collection.length != 'number') { - collection = values(collection); - } - if (n == null || guard) { - return collection ? collection[baseRandom(0, collection.length - 1)] : undefined; - } - var result = shuffle(collection); - result.length = nativeMin(nativeMax(0, n), result.length); - return result; - } - - /** - * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to shuffle. - * @returns {Array} Returns a new shuffled collection. - * @example - * - * _.shuffle([1, 2, 3, 4, 5, 6]); - * // => [4, 1, 6, 3, 5, 2] - */ - function shuffle(collection) { - var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); - - forEach(collection, function(value) { - var rand = baseRandom(0, ++index); - result[index] = result[rand]; - result[rand] = value; - }); - return result; - } - - /** - * Gets the size of the `collection` by returning `collection.length` for arrays - * and array-like objects or the number of own enumerable properties for objects. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns `collection.length` or number of own enumerable properties. - * @example - * - * _.size([1, 2]); - * // => 2 - * - * _.size({ 'one': 1, 'two': 2, 'three': 3 }); - * // => 3 - * - * _.size('pebbles'); - * // => 7 - */ - function size(collection) { - var length = collection ? collection.length : 0; - return typeof length == 'number' ? length : keys(collection).length; - } - - /** - * Checks if the callback returns a truey value for **any** element of a - * collection. The function returns as soon as it finds a passing value and - * does not iterate over the entire collection. The callback is bound to - * `thisArg` and invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias any - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {boolean} Returns `true` if any element passed the callback check, - * else `false`. - * @example - * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true } - * ]; - * - * // using "_.pluck" callback shorthand - * _.some(characters, 'blocked'); - * // => true - * - * // using "_.where" callback shorthand - * _.some(characters, { 'age': 1 }); - * // => false - */ - function some(collection, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - if ((result = callback(collection[index], index, collection))) { - break; - } - } - } else { - forOwn(collection, function(value, index, collection) { - return !(result = callback(value, index, collection)); - }); - } - return !!result; - } - - /** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through the callback. This method - * performs a stable sort, that is, it will preserve the original sort order - * of equal elements. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an array of property names is provided for `callback` the collection - * will be sorted by each property value. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of sorted elements. - * @example - * - * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); - * // => [3, 1, 2] - * - * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); - * // => [3, 1, 2] - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 }, - * { 'name': 'barney', 'age': 26 }, - * { 'name': 'fred', 'age': 30 } - * ]; - * - * // using "_.pluck" callback shorthand - * _.map(_.sortBy(characters, 'age'), _.values); - * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]] - * - * // sorting by multiple properties - * _.map(_.sortBy(characters, ['name', 'age']), _.values); - * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] - */ - function sortBy(collection, callback, thisArg) { - var index = -1, - isArr = isArray(callback), - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); - - if (!isArr) { - callback = lodash.createCallback(callback, thisArg, 3); - } - forEach(collection, function(value, key, collection) { - var object = result[++index] = getObject(); - if (isArr) { - object.criteria = map(callback, function(key) { return value[key]; }); - } else { - (object.criteria = getArray())[0] = callback(value, key, collection); - } - object.index = index; - object.value = value; - }); - - length = result.length; - result.sort(compareAscending); - while (length--) { - var object = result[length]; - result[length] = object.value; - if (!isArr) { - releaseArray(object.criteria); - } - releaseObject(object); - } - return result; - } - - /** - * Converts the `collection` to an array. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to convert. - * @returns {Array} Returns the new converted array. - * @example - * - * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); - * // => [2, 3, 4] - */ - function toArray(collection) { - if (collection && typeof collection.length == 'number') { - return slice(collection); - } - return values(collection); - } - - /** - * Performs a deep comparison of each element in a `collection` to the given - * `properties` object, returning an array of all elements that have equivalent - * property values. - * - * @static - * @memberOf _ - * @type Function - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Object} props The object of property values to filter by. - * @returns {Array} Returns a new array of elements that have the given properties. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }, - * { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] } - * ]; - * - * _.where(characters, { 'age': 36 }); - * // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }] - * - * _.where(characters, { 'pets': ['dino'] }); - * // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }] - */ - var where = filter; - - /*--------------------------------------------------------------------------*/ - - /** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are all falsey. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to compact. - * @returns {Array} Returns a new array of filtered values. - * @example - * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] - */ - function compact(array) { - var index = -1, - length = array ? array.length : 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (value) { - result.push(value); - } - } - return result; - } - - /** - * Creates an array excluding all values of the provided arrays using strict - * equality for comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to process. - * @param {...Array} [values] The arrays of values to exclude. - * @returns {Array} Returns a new array of filtered values. - * @example - * - * _.difference([1, 2, 3, 4, 5], [5, 2, 10]); - * // => [1, 3, 4] - */ - function difference(array) { - return baseDifference(array, baseFlatten(arguments, true, true, 1)); - } - - /** - * This method is like `_.find` except that it returns the index of the first - * element that passes the callback check, instead of the element itself. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true }, - * { 'name': 'pebbles', 'age': 1, 'blocked': false } - * ]; - * - * _.findIndex(characters, function(chr) { - * return chr.age < 20; - * }); - * // => 2 - * - * // using "_.where" callback shorthand - * _.findIndex(characters, { 'age': 36 }); - * // => 0 - * - * // using "_.pluck" callback shorthand - * _.findIndex(characters, 'blocked'); - * // => 1 - */ - function findIndex(array, callback, thisArg) { - var index = -1, - length = array ? array.length : 0; - - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length) { - if (callback(array[index], index, array)) { - return index; - } - } - return -1; - } - - /** - * This method is like `_.findIndex` except that it iterates over elements - * of a `collection` from right to left. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': true }, - * { 'name': 'fred', 'age': 40, 'blocked': false }, - * { 'name': 'pebbles', 'age': 1, 'blocked': true } - * ]; - * - * _.findLastIndex(characters, function(chr) { - * return chr.age > 30; - * }); - * // => 1 - * - * // using "_.where" callback shorthand - * _.findLastIndex(characters, { 'age': 36 }); - * // => 0 - * - * // using "_.pluck" callback shorthand - * _.findLastIndex(characters, 'blocked'); - * // => 2 - */ - function findLastIndex(array, callback, thisArg) { - var length = array ? array.length : 0; - callback = lodash.createCallback(callback, thisArg, 3); - while (length--) { - if (callback(array[length], length, array)) { - return length; - } - } - return -1; - } - - /** - * Gets the first element or first `n` elements of an array. If a callback - * is provided elements at the beginning of the array are returned as long - * as the callback returns truey. The callback is bound to `thisArg` and - * invoked with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias head, take - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback] The function called - * per element or the number of elements to return. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the first element(s) of `array`. - * @example - * - * _.first([1, 2, 3]); - * // => 1 - * - * _.first([1, 2, 3], 2); - * // => [1, 2] - * - * _.first([1, 2, 3], function(num) { - * return num < 3; - * }); - * // => [1, 2] - * - * var characters = [ - * { 'name': 'barney', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.first(characters, 'blocked'); - * // => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }] - * - * // using "_.where" callback shorthand - * _.pluck(_.first(characters, { 'employer': 'slate' }), 'name'); - * // => ['barney', 'fred'] - */ - function first(array, callback, thisArg) { - var n = 0, - length = array ? array.length : 0; - - if (typeof callback != 'number' && callback != null) { - var index = -1; - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length && callback(array[index], index, array)) { - n++; - } - } else { - n = callback; - if (n == null || thisArg) { - return array ? array[0] : undefined; - } - } - return slice(array, 0, nativeMin(nativeMax(0, n), length)); - } - - /** - * Flattens a nested array (the nesting can be to any depth). If `isShallow` - * is truey, the array will only be flattened a single level. If a callback - * is provided each element of the array is passed through the callback before - * flattening. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to flatten. - * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new flattened array. - * @example - * - * _.flatten([1, [2], [3, [[4]]]]); - * // => [1, 2, 3, 4]; - * - * _.flatten([1, [2], [3, [[4]]]], true); - * // => [1, 2, 3, [[4]]]; - * - * var characters = [ - * { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] }, - * { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] } - * ]; - * - * // using "_.pluck" callback shorthand - * _.flatten(characters, 'pets'); - * // => ['hoppy', 'baby puss', 'dino'] - */ - function flatten(array, isShallow, callback, thisArg) { - // juggle arguments - if (typeof isShallow != 'boolean' && isShallow != null) { - thisArg = callback; - callback = (typeof isShallow != 'function' && thisArg && thisArg[isShallow] === array) ? null : isShallow; - isShallow = false; - } - if (callback != null) { - array = map(array, callback, thisArg); - } - return baseFlatten(array, isShallow); - } - - /** - * Gets the index at which the first occurrence of `value` is found using - * strict equality for comparisons, i.e. `===`. If the array is already sorted - * providing `true` for `fromIndex` will run a faster binary search. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {boolean|number} [fromIndex=0] The index to search from or `true` - * to perform a binary search on a sorted array. - * @returns {number} Returns the index of the matched value or `-1`. - * @example - * - * _.indexOf([1, 2, 3, 1, 2, 3], 2); - * // => 1 - * - * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); - * // => 4 - * - * _.indexOf([1, 1, 2, 2, 3, 3], 2, true); - * // => 2 - */ - function indexOf(array, value, fromIndex) { - if (typeof fromIndex == 'number') { - var length = array ? array.length : 0; - fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0); - } else if (fromIndex) { - var index = sortedIndex(array, value); - return array[index] === value ? index : -1; - } - return baseIndexOf(array, value, fromIndex); - } - - /** - * Gets all but the last element or last `n` elements of an array. If a - * callback is provided elements at the end of the array are excluded from - * the result as long as the callback returns truey. The callback is bound - * to `thisArg` and invoked with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback=1] The function called - * per element or the number of elements to exclude. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a slice of `array`. - * @example - * - * _.initial([1, 2, 3]); - * // => [1, 2] - * - * _.initial([1, 2, 3], 2); - * // => [1] - * - * _.initial([1, 2, 3], function(num) { - * return num > 1; - * }); - * // => [1] - * - * var characters = [ - * { 'name': 'barney', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.initial(characters, 'blocked'); - * // => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }] - * - * // using "_.where" callback shorthand - * _.pluck(_.initial(characters, { 'employer': 'na' }), 'name'); - * // => ['barney', 'fred'] - */ - function initial(array, callback, thisArg) { - var n = 0, - length = array ? array.length : 0; - - if (typeof callback != 'number' && callback != null) { - var index = length; - callback = lodash.createCallback(callback, thisArg, 3); - while (index-- && callback(array[index], index, array)) { - n++; - } - } else { - n = (callback == null || thisArg) ? 1 : callback || n; - } - return slice(array, 0, nativeMin(nativeMax(0, length - n), length)); - } - - /** - * Creates an array of unique values present in all provided arrays using - * strict equality for comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {...Array} [array] The arrays to inspect. - * @returns {Array} Returns an array of shared values. - * @example - * - * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2] - */ - function intersection() { - var args = [], - argsIndex = -1, - argsLength = arguments.length, - caches = getArray(), - indexOf = getIndexOf(), - trustIndexOf = indexOf === baseIndexOf, - seen = getArray(); - - while (++argsIndex < argsLength) { - var value = arguments[argsIndex]; - if (isArray(value) || isArguments(value)) { - args.push(value); - caches.push(trustIndexOf && value.length >= largeArraySize && - createCache(argsIndex ? args[argsIndex] : seen)); - } - } - var array = args[0], - index = -1, - length = array ? array.length : 0, - result = []; - - outer: - while (++index < length) { - var cache = caches[0]; - value = array[index]; - - if ((cache ? cacheIndexOf(cache, value) : indexOf(seen, value)) < 0) { - argsIndex = argsLength; - (cache || seen).push(value); - while (--argsIndex) { - cache = caches[argsIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) { - continue outer; - } - } - result.push(value); - } - } - while (argsLength--) { - cache = caches[argsLength]; - if (cache) { - releaseObject(cache); - } - } - releaseArray(caches); - releaseArray(seen); - return result; - } - - /** - * Gets the last element or last `n` elements of an array. If a callback is - * provided elements at the end of the array are returned as long as the - * callback returns truey. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback] The function called - * per element or the number of elements to return. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the last element(s) of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - * - * _.last([1, 2, 3], 2); - * // => [2, 3] - * - * _.last([1, 2, 3], function(num) { - * return num > 1; - * }); - * // => [2, 3] - * - * var characters = [ - * { 'name': 'barney', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.pluck(_.last(characters, 'blocked'), 'name'); - * // => ['fred', 'pebbles'] - * - * // using "_.where" callback shorthand - * _.last(characters, { 'employer': 'na' }); - * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }] - */ - function last(array, callback, thisArg) { - var n = 0, - length = array ? array.length : 0; - - if (typeof callback != 'number' && callback != null) { - var index = length; - callback = lodash.createCallback(callback, thisArg, 3); - while (index-- && callback(array[index], index, array)) { - n++; - } - } else { - n = callback; - if (n == null || thisArg) { - return array ? array[length - 1] : undefined; - } - } - return slice(array, nativeMax(0, length - n)); - } - - /** - * Gets the index at which the last occurrence of `value` is found using strict - * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used - * as the offset from the end of the collection. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the matched value or `-1`. - * @example - * - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); - * // => 4 - * - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); - * // => 1 - */ - function lastIndexOf(array, value, fromIndex) { - var index = array ? array.length : 0; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1; - } - while (index--) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * Removes all provided values from the given array using strict equality for - * comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to modify. - * @param {...*} [value] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3, 1, 2, 3]; - * _.pull(array, 2, 3); - * console.log(array); - * // => [1, 1] - */ - function pull(array) { - var args = arguments, - argsIndex = 0, - argsLength = args.length, - length = array ? array.length : 0; - - while (++argsIndex < argsLength) { - var index = -1, - value = args[argsIndex]; - while (++index < length) { - if (array[index] === value) { - splice.call(array, index--, 1); - length--; - } - } - } - return array; - } - - /** - * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to but not including `end`. If `start` is less than `stop` a - * zero-length range is created unless a negative `step` is specified. - * - * @static - * @memberOf _ - * @category Arrays - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns a new range array. - * @example - * - * _.range(4); - * // => [0, 1, 2, 3] - * - * _.range(1, 5); - * // => [1, 2, 3, 4] - * - * _.range(0, 20, 5); - * // => [0, 5, 10, 15] - * - * _.range(0, -4, -1); - * // => [0, -1, -2, -3] - * - * _.range(1, 4, 0); - * // => [1, 1, 1] - * - * _.range(0); - * // => [] - */ - function range(start, end, step) { - start = +start || 0; - step = typeof step == 'number' ? step : (+step || 1); - - if (end == null) { - end = start; - start = 0; - } - // use `Array(length)` so engines like Chakra and V8 avoid slower modes - // http://youtu.be/XAqIpGU8ZZk#t=17m25s - var index = -1, - length = nativeMax(0, ceil((end - start) / (step || 1))), - result = Array(length); - - while (++index < length) { - result[index] = start; - start += step; - } - return result; - } - - /** - * Removes all elements from an array that the callback returns truey for - * and returns an array of removed elements. The callback is bound to `thisArg` - * and invoked with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to modify. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of removed elements. - * @example - * - * var array = [1, 2, 3, 4, 5, 6]; - * var evens = _.remove(array, function(num) { return num % 2 == 0; }); - * - * console.log(array); - * // => [1, 3, 5] - * - * console.log(evens); - * // => [2, 4, 6] - */ - function remove(array, callback, thisArg) { - var index = -1, - length = array ? array.length : 0, - result = []; - - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length) { - var value = array[index]; - if (callback(value, index, array)) { - result.push(value); - splice.call(array, index--, 1); - length--; - } - } - return result; - } - - /** - * The opposite of `_.initial` this method gets all but the first element or - * first `n` elements of an array. If a callback function is provided elements - * at the beginning of the array are excluded from the result as long as the - * callback returns truey. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias drop, tail - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback=1] The function called - * per element or the number of elements to exclude. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a slice of `array`. - * @example - * - * _.rest([1, 2, 3]); - * // => [2, 3] - * - * _.rest([1, 2, 3], 2); - * // => [3] - * - * _.rest([1, 2, 3], function(num) { - * return num < 3; - * }); - * // => [3] - * - * var characters = [ - * { 'name': 'barney', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.pluck(_.rest(characters, 'blocked'), 'name'); - * // => ['fred', 'pebbles'] - * - * // using "_.where" callback shorthand - * _.rest(characters, { 'employer': 'slate' }); - * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }] - */ - function rest(array, callback, thisArg) { - if (typeof callback != 'number' && callback != null) { - var n = 0, - index = -1, - length = array ? array.length : 0; - - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length && callback(array[index], index, array)) { - n++; - } - } else { - n = (callback == null || thisArg) ? 1 : nativeMax(0, callback); - } - return slice(array, n); - } - - /** - * Uses a binary search to determine the smallest index at which a value - * should be inserted into a given sorted array in order to maintain the sort - * order of the array. If a callback is provided it will be executed for - * `value` and each element of `array` to compute their sort ranking. The - * callback is bound to `thisArg` and invoked with one argument; (value). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedIndex([20, 30, 50], 40); - * // => 2 - * - * // using "_.pluck" callback shorthand - * _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); - * // => 2 - * - * var dict = { - * 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } - * }; - * - * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - * return dict.wordToNumber[word]; - * }); - * // => 2 - * - * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - * return this.wordToNumber[word]; - * }, dict); - * // => 2 - */ - function sortedIndex(array, value, callback, thisArg) { - var low = 0, - high = array ? array.length : low; - - // explicitly reference `identity` for better inlining in Firefox - callback = callback ? lodash.createCallback(callback, thisArg, 1) : identity; - value = callback(value); - - while (low < high) { - var mid = (low + high) >>> 1; - (callback(array[mid]) < value) - ? low = mid + 1 - : high = mid; - } - return low; - } - - /** - * Creates an array of unique values, in order, of the provided arrays using - * strict equality for comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {...Array} [array] The arrays to inspect. - * @returns {Array} Returns an array of combined values. - * @example - * - * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2, 3, 5, 4] - */ - function union() { - return baseUniq(baseFlatten(arguments, true, true)); - } - - /** - * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. If the array is sorted, providing - * `true` for `isSorted` will use a faster algorithm. If a callback is provided - * each element of `array` is passed through the callback before uniqueness - * is computed. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias unique - * @category Arrays - * @param {Array} array The array to process. - * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a duplicate-value-free array. - * @example - * - * _.uniq([1, 2, 1, 3, 1]); - * // => [1, 2, 3] - * - * _.uniq([1, 1, 2, 2, 3], true); - * // => [1, 2, 3] - * - * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); - * // => ['A', 'b', 'C'] - * - * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2.5, 3] - * - * // using "_.pluck" callback shorthand - * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ - function uniq(array, isSorted, callback, thisArg) { - // juggle arguments - if (typeof isSorted != 'boolean' && isSorted != null) { - thisArg = callback; - callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted; - isSorted = false; - } - if (callback != null) { - callback = lodash.createCallback(callback, thisArg, 3); - } - return baseUniq(array, isSorted, callback); - } - - /** - * Creates an array excluding all provided values using strict equality for - * comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to filter. - * @param {...*} [value] The values to exclude. - * @returns {Array} Returns a new array of filtered values. - * @example - * - * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); - * // => [2, 3, 4] - */ - function without(array) { - return baseDifference(array, slice(arguments, 1)); - } - - /** - * Creates an array that is the symmetric difference of the provided arrays. - * See http://en.wikipedia.org/wiki/Symmetric_difference. - * - * @static - * @memberOf _ - * @category Arrays - * @param {...Array} [array] The arrays to inspect. - * @returns {Array} Returns an array of values. - * @example - * - * _.xor([1, 2, 3], [5, 2, 1, 4]); - * // => [3, 5, 4] - * - * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); - * // => [1, 4, 5] - */ - function xor() { - var index = -1, - length = arguments.length; - - while (++index < length) { - var array = arguments[index]; - if (isArray(array) || isArguments(array)) { - var result = result - ? baseUniq(baseDifference(result, array).concat(baseDifference(array, result))) - : array; - } - } - return result || []; - } - - /** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second - * elements of the given arrays, and so on. - * - * @static - * @memberOf _ - * @alias unzip - * @category Arrays - * @param {...Array} [array] Arrays to process. - * @returns {Array} Returns a new array of grouped elements. - * @example - * - * _.zip(['fred', 'barney'], [30, 40], [true, false]); - * // => [['fred', 30, true], ['barney', 40, false]] - */ - function zip() { - var array = arguments.length > 1 ? arguments : arguments[0], - index = -1, - length = array ? max(pluck(array, 'length')) : 0, - result = Array(length < 0 ? 0 : length); - - while (++index < length) { - result[index] = pluck(array, index); - } - return result; - } - - /** - * Creates an object composed from arrays of `keys` and `values`. Provide - * either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` - * or two arrays, one of `keys` and one of corresponding `values`. - * - * @static - * @memberOf _ - * @alias object - * @category Arrays - * @param {Array} keys The array of keys. - * @param {Array} [values=[]] The array of values. - * @returns {Object} Returns an object composed of the given keys and - * corresponding values. - * @example - * - * _.zipObject(['fred', 'barney'], [30, 40]); - * // => { 'fred': 30, 'barney': 40 } - */ - function zipObject(keys, values) { - var index = -1, - length = keys ? keys.length : 0, - result = {}; - - if (!values && length && !isArray(keys[0])) { - values = []; - } - while (++index < length) { - var key = keys[index]; - if (values) { - result[key] = values[index]; - } else if (key) { - result[key[0]] = key[1]; - } - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a function that executes `func`, with the `this` binding and - * arguments of the created function, only after being called `n` times. - * - * @static - * @memberOf _ - * @category Functions - * @param {number} n The number of times the function must be called before - * `func` is executed. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('Done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => logs 'Done saving!', after all saves have completed - */ - function after(n, func) { - if (!isFunction(func)) { - throw new TypeError; - } - return function() { - if (--n < 1) { - return func.apply(this, arguments); - } - }; - } - - /** - * Creates a function that, when called, invokes `func` with the `this` - * binding of `thisArg` and prepends any additional `bind` arguments to those - * provided to the bound function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var func = function(greeting) { - * return greeting + ' ' + this.name; - * }; - * - * func = _.bind(func, { 'name': 'fred' }, 'hi'); - * func(); - * // => 'hi fred' - */ - function bind(func, thisArg) { - return arguments.length > 2 - ? createWrapper(func, 17, slice(arguments, 2), null, thisArg) - : createWrapper(func, 1, null, null, thisArg); - } - - /** - * Binds methods of an object to the object itself, overwriting the existing - * method. Method names may be specified as individual arguments or as arrays - * of method names. If no method names are provided all the function properties - * of `object` will be bound. - * - * @static - * @memberOf _ - * @category Functions - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...string} [methodName] The object method names to - * bind, specified as individual method names or arrays of method names. - * @returns {Object} Returns `object`. - * @example - * - * var view = { - * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } - * }; - * - * _.bindAll(view); - * jQuery('#docs').on('click', view.onClick); - * // => logs 'clicked docs', when the button is clicked - */ - function bindAll(object) { - var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), - index = -1, - length = funcs.length; - - while (++index < length) { - var key = funcs[index]; - object[key] = createWrapper(object[key], 1, null, null, object); - } - return object; - } - - /** - * Creates a function that, when called, invokes the method at `object[key]` - * and prepends any additional `bindKey` arguments to those provided to the bound - * function. This method differs from `_.bind` by allowing bound functions to - * reference methods that will be redefined or don't yet exist. - * See http://michaux.ca/articles/lazy-function-definition-pattern. - * - * @static - * @memberOf _ - * @category Functions - * @param {Object} object The object the method belongs to. - * @param {string} key The key of the method. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var object = { - * 'name': 'fred', - * 'greet': function(greeting) { - * return greeting + ' ' + this.name; - * } - * }; - * - * var func = _.bindKey(object, 'greet', 'hi'); - * func(); - * // => 'hi fred' - * - * object.greet = function(greeting) { - * return greeting + 'ya ' + this.name + '!'; - * }; - * - * func(); - * // => 'hiya fred!' - */ - function bindKey(object, key) { - return arguments.length > 2 - ? createWrapper(key, 19, slice(arguments, 2), null, object) - : createWrapper(key, 3, null, null, object); - } - - /** - * Creates a function that is the composition of the provided functions, - * where each function consumes the return value of the function that follows. - * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. - * Each function is executed with the `this` binding of the composed function. - * - * @static - * @memberOf _ - * @category Functions - * @param {...Function} [func] Functions to compose. - * @returns {Function} Returns the new composed function. - * @example - * - * var realNameMap = { - * 'pebbles': 'penelope' - * }; - * - * var format = function(name) { - * name = realNameMap[name.toLowerCase()] || name; - * return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); - * }; - * - * var greet = function(formatted) { - * return 'Hiya ' + formatted + '!'; - * }; - * - * var welcome = _.compose(greet, format); - * welcome('pebbles'); - * // => 'Hiya Penelope!' - */ - function compose() { - var funcs = arguments, - length = funcs.length; - - while (length--) { - if (!isFunction(funcs[length])) { - throw new TypeError; - } - } - return function() { - var args = arguments, - length = funcs.length; - - while (length--) { - args = [funcs[length].apply(this, args)]; - } - return args[0]; - }; - } - - /** - * Creates a function which accepts one or more arguments of `func` that when - * invoked either executes `func` returning its result, if all `func` arguments - * have been provided, or returns a function that accepts one or more of the - * remaining `func` arguments, and so on. The arity of `func` can be specified - * if `func.length` is not sufficient. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @returns {Function} Returns the new curried function. - * @example - * - * var curried = _.curry(function(a, b, c) { - * console.log(a + b + c); - * }); - * - * curried(1)(2)(3); - * // => 6 - * - * curried(1, 2)(3); - * // => 6 - * - * curried(1, 2, 3); - * // => 6 - */ - function curry(func, arity) { - arity = typeof arity == 'number' ? arity : (+arity || func.length); - return createWrapper(func, 4, null, null, null, arity); - } - - /** - * Creates a function that will delay the execution of `func` until after - * `wait` milliseconds have elapsed since the last time it was invoked. - * Provide an options object to indicate that `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. Subsequent calls - * to the debounced function will return the result of the last `func` call. - * - * Note: If `leading` and `trailing` options are `true` `func` will be called - * on the trailing edge of the timeout only if the the debounced function is - * invoked more than once during the `wait` timeout. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to debounce. - * @param {number} wait The number of milliseconds to delay. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=false] Specify execution on the leading edge of the timeout. - * @param {number} [options.maxWait] The maximum time `func` is allowed to be delayed before it's called. - * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // avoid costly calculations while the window size is in flux - * var lazyLayout = _.debounce(calculateLayout, 150); - * jQuery(window).on('resize', lazyLayout); - * - * // execute `sendMail` when the click event is fired, debouncing subsequent calls - * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * }); - * - * // ensure `batchLog` is executed once after 1 second of debounced calls - * var source = new EventSource('/stream'); - * source.addEventListener('message', _.debounce(batchLog, 250, { - * 'maxWait': 1000 - * }, false); - */ - function debounce(func, wait, options) { - var args, - maxTimeoutId, - result, - stamp, - thisArg, - timeoutId, - trailingCall, - lastCalled = 0, - maxWait = false, - trailing = true; - - if (!isFunction(func)) { - throw new TypeError; - } - wait = nativeMax(0, wait) || 0; - if (options === true) { - var leading = true; - trailing = false; - } else if (isObject(options)) { - leading = options.leading; - maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0); - trailing = 'trailing' in options ? options.trailing : trailing; - } - var delayed = function() { - var remaining = wait - (now() - stamp); - if (remaining <= 0) { - if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - } - var isCalled = trailingCall; - maxTimeoutId = timeoutId = trailingCall = undefined; - if (isCalled) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = null; - } - } - } else { - timeoutId = setTimeout(delayed, remaining); - } - }; - - var maxDelayed = function() { - if (timeoutId) { - clearTimeout(timeoutId); - } - maxTimeoutId = timeoutId = trailingCall = undefined; - if (trailing || (maxWait !== wait)) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = null; - } - } - }; - - return function() { - args = arguments; - stamp = now(); - thisArg = this; - trailingCall = trailing && (timeoutId || !leading); - - if (maxWait === false) { - var leadingCall = leading && !timeoutId; - } else { - if (!maxTimeoutId && !leading) { - lastCalled = stamp; - } - var remaining = maxWait - (stamp - lastCalled), - isCalled = remaining <= 0; - - if (isCalled) { - if (maxTimeoutId) { - maxTimeoutId = clearTimeout(maxTimeoutId); - } - lastCalled = stamp; - result = func.apply(thisArg, args); - } - else if (!maxTimeoutId) { - maxTimeoutId = setTimeout(maxDelayed, remaining); - } - } - if (isCalled && timeoutId) { - timeoutId = clearTimeout(timeoutId); - } - else if (!timeoutId && wait !== maxWait) { - timeoutId = setTimeout(delayed, wait); - } - if (leadingCall) { - isCalled = true; - result = func.apply(thisArg, args); - } - if (isCalled && !timeoutId && !maxTimeoutId) { - args = thisArg = null; - } - return result; - }; - } - - /** - * Defers executing the `func` function until the current call stack has cleared. - * Additional arguments will be provided to `func` when it is invoked. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to defer. - * @param {...*} [arg] Arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.defer(function(text) { console.log(text); }, 'deferred'); - * // logs 'deferred' after one or more milliseconds - */ - function defer(func) { - if (!isFunction(func)) { - throw new TypeError; - } - var args = slice(arguments, 1); - return setTimeout(function() { func.apply(undefined, args); }, 1); - } - - /** - * Executes the `func` function after `wait` milliseconds. Additional arguments - * will be provided to `func` when it is invoked. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay execution. - * @param {...*} [arg] Arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.delay(function(text) { console.log(text); }, 1000, 'later'); - * // => logs 'later' after one second - */ - function delay(func, wait) { - if (!isFunction(func)) { - throw new TypeError; - } - var args = slice(arguments, 2); - return setTimeout(function() { func.apply(undefined, args); }, wait); - } - - /** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it will be used to determine the cache key for storing the result - * based on the arguments provided to the memoized function. By default, the - * first argument provided to the memoized function is used as the cache key. - * The `func` is executed with the `this` binding of the memoized function. - * The result cache is exposed as the `cache` property on the memoized function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] A function used to resolve the cache key. - * @returns {Function} Returns the new memoizing function. - * @example - * - * var fibonacci = _.memoize(function(n) { - * return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); - * }); - * - * fibonacci(9) - * // => 34 - * - * var data = { - * 'fred': { 'name': 'fred', 'age': 40 }, - * 'pebbles': { 'name': 'pebbles', 'age': 1 } - * }; - * - * // modifying the result cache - * var get = _.memoize(function(name) { return data[name]; }, _.identity); - * get('pebbles'); - * // => { 'name': 'pebbles', 'age': 1 } - * - * get.cache.pebbles.name = 'penelope'; - * get('pebbles'); - * // => { 'name': 'penelope', 'age': 1 } - */ - function memoize(func, resolver) { - if (!isFunction(func)) { - throw new TypeError; - } - var memoized = function() { - var cache = memoized.cache, - key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0]; - - return hasOwnProperty.call(cache, key) - ? cache[key] - : (cache[key] = func.apply(this, arguments)); - } - memoized.cache = {}; - return memoized; - } - - /** - * Creates a function that is restricted to execute `func` once. Repeat calls to - * the function will return the value of the first call. The `func` is executed - * with the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // `initialize` executes `createApplication` once - */ - function once(func) { - var ran, - result; - - if (!isFunction(func)) { - throw new TypeError; - } - return function() { - if (ran) { - return result; - } - ran = true; - result = func.apply(this, arguments); - - // clear the `func` variable so the function may be garbage collected - func = null; - return result; - }; - } - - /** - * Creates a function that, when called, invokes `func` with any additional - * `partial` arguments prepended to those provided to the new function. This - * method is similar to `_.bind` except it does **not** alter the `this` binding. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { return greeting + ' ' + name; }; - * var hi = _.partial(greet, 'hi'); - * hi('fred'); - * // => 'hi fred' - */ - function partial(func) { - return createWrapper(func, 16, slice(arguments, 1)); - } - - /** - * This method is like `_.partial` except that `partial` arguments are - * appended to those provided to the new function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var defaultsDeep = _.partialRight(_.merge, _.defaults); - * - * var options = { - * 'variable': 'data', - * 'imports': { 'jq': $ } - * }; - * - * defaultsDeep(options, _.templateSettings); - * - * options.variable - * // => 'data' - * - * options.imports - * // => { '_': _, 'jq': $ } - */ - function partialRight(func) { - return createWrapper(func, 32, null, slice(arguments, 1)); - } - - /** - * Creates a function that, when executed, will only call the `func` function - * at most once per every `wait` milliseconds. Provide an options object to - * indicate that `func` should be invoked on the leading and/or trailing edge - * of the `wait` timeout. Subsequent calls to the throttled function will - * return the result of the last `func` call. - * - * Note: If `leading` and `trailing` options are `true` `func` will be called - * on the trailing edge of the timeout only if the the throttled function is - * invoked more than once during the `wait` timeout. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to throttle. - * @param {number} wait The number of milliseconds to throttle executions to. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=true] Specify execution on the leading edge of the timeout. - * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // avoid excessively updating the position while scrolling - * var throttled = _.throttle(updatePosition, 100); - * jQuery(window).on('scroll', throttled); - * - * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); - */ - function throttle(func, wait, options) { - var leading = true, - trailing = true; - - if (!isFunction(func)) { - throw new TypeError; - } - if (options === false) { - leading = false; - } else if (isObject(options)) { - leading = 'leading' in options ? options.leading : leading; - trailing = 'trailing' in options ? options.trailing : trailing; - } - debounceOptions.leading = leading; - debounceOptions.maxWait = wait; - debounceOptions.trailing = trailing; - - return debounce(func, wait, debounceOptions); - } - - /** - * Creates a function that provides `value` to the wrapper function as its - * first argument. Additional arguments provided to the function are appended - * to those provided to the wrapper function. The wrapper is executed with - * the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Functions - * @param {*} value The value to wrap. - * @param {Function} wrapper The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '

' + func(text) + '

'; - * }); - * - * p('Fred, Wilma, & Pebbles'); - * // => '

Fred, Wilma, & Pebbles

' - */ - function wrap(value, wrapper) { - return createWrapper(wrapper, 16, [value]); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a function that returns `value`. - * - * @static - * @memberOf _ - * @category Utilities - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new function. - * @example - * - * var object = { 'name': 'fred' }; - * var getter = _.constant(object); - * getter() === object; - * // => true - */ - function constant(value) { - return function() { - return value; - }; - } - - /** - * Produces a callback bound to an optional `thisArg`. If `func` is a property - * name the created callback will return the property value for a given element. - * If `func` is an object the created callback will return `true` for elements - * that contain the equivalent object properties, otherwise it will return `false`. - * - * @static - * @memberOf _ - * @category Utilities - * @param {*} [func=identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. - * @param {number} [argCount] The number of arguments the callback accepts. - * @returns {Function} Returns a callback function. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * // wrap to create custom callback shorthands - * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) { - * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback); - * return !match ? func(callback, thisArg) : function(object) { - * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3]; - * }; - * }); - * - * _.filter(characters, 'age__gt38'); - * // => [{ 'name': 'fred', 'age': 40 }] - */ - function createCallback(func, thisArg, argCount) { - var type = typeof func; - if (func == null || type == 'function') { - return baseCreateCallback(func, thisArg, argCount); - } - // handle "_.pluck" style callback shorthands - if (type != 'object') { - return property(func); - } - var props = keys(func), - key = props[0], - a = func[key]; - - // handle "_.where" style callback shorthands - if (props.length == 1 && a === a && !isObject(a)) { - // fast path the common case of providing an object with a single - // property containing a primitive value - return function(object) { - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); - }; - } - return function(object) { - var length = props.length, - result = false; - - while (length--) { - if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { - break; - } - } - return result; - }; - } - - /** - * Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their - * corresponding HTML entities. - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} string The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escape('Fred, Wilma, & Pebbles'); - * // => 'Fred, Wilma, & Pebbles' - */ - function escape(string) { - return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); - } - - /** - * This method returns the first argument provided to it. - * - * @static - * @memberOf _ - * @category Utilities - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'name': 'fred' }; - * _.identity(object) === object; - * // => true - */ - function identity(value) { - return value; - } - - /** - * Adds function properties of a source object to the destination object. - * If `object` is a function methods will be added to its prototype as well. - * - * @static - * @memberOf _ - * @category Utilities - * @param {Function|Object} [object=lodash] object The destination object. - * @param {Object} source The object of functions to add. - * @param {Object} [options] The options object. - * @param {boolean} [options.chain=true] Specify whether the functions added are chainable. - * @example - * - * function capitalize(string) { - * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - * } - * - * _.mixin({ 'capitalize': capitalize }); - * _.capitalize('fred'); - * // => 'Fred' - * - * _('fred').capitalize().value(); - * // => 'Fred' - * - * _.mixin({ 'capitalize': capitalize }, { 'chain': false }); - * _('fred').capitalize(); - * // => 'Fred' - */ - function mixin(object, source, options) { - var chain = true, - methodNames = source && functions(source); - - if (!source || (!options && !methodNames.length)) { - if (options == null) { - options = source; - } - ctor = lodashWrapper; - source = object; - object = lodash; - methodNames = functions(source); - } - if (options === false) { - chain = false; - } else if (isObject(options) && 'chain' in options) { - chain = options.chain; - } - var ctor = object, - isFunc = isFunction(ctor); - - forEach(methodNames, function(methodName) { - var func = object[methodName] = source[methodName]; - if (isFunc) { - ctor.prototype[methodName] = function() { - var chainAll = this.__chain__, - value = this.__wrapped__, - args = [value]; - - push.apply(args, arguments); - var result = func.apply(object, args); - if (chain || chainAll) { - if (value === result && isObject(result)) { - return this; - } - result = new ctor(result); - result.__chain__ = chainAll; - } - return result; - }; - } - }); - } - - /** - * Reverts the '_' variable to its previous value and returns a reference to - * the `lodash` function. - * - * @static - * @memberOf _ - * @category Utilities - * @returns {Function} Returns the `lodash` function. - * @example - * - * var lodash = _.noConflict(); - */ - function noConflict() { - context._ = oldDash; - return this; - } - - /** - * A no-operation function. - * - * @static - * @memberOf _ - * @category Utilities - * @example - * - * var object = { 'name': 'fred' }; - * _.noop(object) === undefined; - * // => true - */ - function noop() { - // no operation performed - } - - /** - * Gets the number of milliseconds that have elapsed since the Unix epoch - * (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @category Utilities - * @example - * - * var stamp = _.now(); - * _.defer(function() { console.log(_.now() - stamp); }); - * // => logs the number of milliseconds it took for the deferred function to be called - */ - var now = isNative(now = Date.now) && now || function() { - return new Date().getTime(); - }; - - /** - * Converts the given value into an integer of the specified radix. - * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the - * `value` is a hexadecimal, in which case a `radix` of `16` is used. - * - * Note: This method avoids differences in native ES3 and ES5 `parseInt` - * implementations. See http://es5.github.io/#E. - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} value The value to parse. - * @param {number} [radix] The radix used to interpret the value to parse. - * @returns {number} Returns the new integer value. - * @example - * - * _.parseInt('08'); - * // => 8 - */ - var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) { - // Firefox < 21 and Opera < 15 follow the ES3 specified implementation of `parseInt` - return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0); - }; - - /** - * Creates a "_.pluck" style function, which returns the `key` value of a - * given object. - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} key The name of the property to retrieve. - * @returns {Function} Returns the new function. - * @example - * - * var characters = [ - * { 'name': 'fred', 'age': 40 }, - * { 'name': 'barney', 'age': 36 } - * ]; - * - * var getName = _.property('name'); - * - * _.map(characters, getName); - * // => ['barney', 'fred'] - * - * _.sortBy(characters, getName); - * // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] - */ - function property(key) { - return function(object) { - return object[key]; - }; - } - - /** - * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number will be - * returned. If `floating` is truey or either `min` or `max` are floats a - * floating-point number will be returned instead of an integer. - * - * @static - * @memberOf _ - * @category Utilities - * @param {number} [min=0] The minimum possible value. - * @param {number} [max=1] The maximum possible value. - * @param {boolean} [floating=false] Specify returning a floating-point number. - * @returns {number} Returns a random number. - * @example - * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 - * - * _.random(5, true); - * // => a floating-point number between 0 and 5 - * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(min, max, floating) { - var noMin = min == null, - noMax = max == null; - - if (floating == null) { - if (typeof min == 'boolean' && noMax) { - floating = min; - min = 1; - } - else if (!noMax && typeof max == 'boolean') { - floating = max; - noMax = true; - } - } - if (noMin && noMax) { - max = 1; - } - min = +min || 0; - if (noMax) { - max = min; - min = 0; - } else { - max = +max || 0; - } - if (floating || min % 1 || max % 1) { - var rand = nativeRandom(); - return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1)))), max); - } - return baseRandom(min, max); - } - - /** - * Resolves the value of property `key` on `object`. If `key` is a function - * it will be invoked with the `this` binding of `object` and its result returned, - * else the property value is returned. If `object` is falsey then `undefined` - * is returned. - * - * @static - * @memberOf _ - * @category Utilities - * @param {Object} object The object to inspect. - * @param {string} key The name of the property to resolve. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { - * 'cheese': 'crumpets', - * 'stuff': function() { - * return 'nonsense'; - * } - * }; - * - * _.result(object, 'cheese'); - * // => 'crumpets' - * - * _.result(object, 'stuff'); - * // => 'nonsense' - */ - function result(object, key) { - if (object) { - var value = object[key]; - return isFunction(value) ? object[key]() : value; - } - } - - /** - * A micro-templating method that handles arbitrary delimiters, preserves - * whitespace, and correctly escapes quotes within interpolated code. - * - * Note: In the development build, `_.template` utilizes sourceURLs for easier - * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl - * - * For more information on precompiling templates see: - * http://lodash.com/custom-builds - * - * For more information on Chrome extension sandboxes see: - * http://developer.chrome.com/stable/extensions/sandboxingEval.html - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} text The template text. - * @param {Object} data The data object used to populate the text. - * @param {Object} [options] The options object. - * @param {RegExp} [options.escape] The "escape" delimiter. - * @param {RegExp} [options.evaluate] The "evaluate" delimiter. - * @param {Object} [options.imports] An object to import into the template as local variables. - * @param {RegExp} [options.interpolate] The "interpolate" delimiter. - * @param {string} [sourceURL] The sourceURL of the template's compiled source. - * @param {string} [variable] The data object variable name. - * @returns {Function|string} Returns a compiled function when no `data` object - * is given, else it returns the interpolated text. - * @example - * - * // using the "interpolate" delimiter to create a compiled template - * var compiled = _.template('hello <%= name %>'); - * compiled({ 'name': 'fred' }); - * // => 'hello fred' - * - * // using the "escape" delimiter to escape HTML in data property values - * _.template('<%- value %>', { 'value': ' + + + + + + + + + + + + + + + +
+

Motivate yourself and your team!

+ +
+

Join 200,000 players making it fun to achieve goals! + +

+
+
Featured in
+ + + + + + + + +
+
+ +
+
+
+

HabitRPG is a free habit building and productivity app that treats your real life like a game. With in-game rewards and punishments to motivate you and a strong social network to inspire you, HabitRPG can help you achieve your goals to become healthy, hard-working, and happy.

+
+ + + + +
+

Players use HabitRPG to manage...

+
+ + +
+
+ +
+

Join us on a mini-quest!

+ + +
+ +
+

Complete a task to earn gold!

+
+

+
+ + +
+ + + + + +
+ + + +
+ +
+ +
+

As you stay productive, you unlock new content!

+
+ + + + + + +
+ +
+ + + + +
+
+ +
+ + + + + + +
+ +
+

Miss a daily goal?

+ + + +
+
+ +
+
+
 
+
+
+

Lose health!

+ + + +
+ +
+

Battle monsters with your friends!

+ + +
+
+
+
+
+
 
+
+
+
+ +
+
+
+
+
+
+
 
+
+
+
+
+ +

If you slack off, they all get hurt!

+ + + +
+ + +
+

We also feature...

+ +
+
+ +
+ + +
+
+
+

Pets and Mounts

+

Eggs and items drop when you complete your tasks. Be as productive as possible to collect pets and mounts!

+
+
+
+
+ + +
+ +
+ + +
+
+
+

Achievement Badges

+

Do something totally awesome? Get a badge and show it off!

+
+
+
+ +
+
+ +
+ + + + +
+
+
+

Equipment and extras

+

Buy limited edition equipment, potions, and other virtual goodies in our Market with your task rewards!

+
+
+
+
+ +
+
+ +
+ +
+
+
+

Social play

+

Join common-interest groups with like-minded people.

Create Challenges to compete against other users.

+
+
+
+
+
+ + + +
+
+
+
+

Join 200,000 players making it fun to achieve goals!

+
+
+
+
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/website/public/front/images/.DS_Store b/website/public/front/images/.DS_Store new file mode 100644 index 0000000000..a032bfd2f7 Binary files /dev/null and b/website/public/front/images/.DS_Store differ diff --git a/website/public/front/images/Feeding_Time.png b/website/public/front/images/Feeding_Time.png new file mode 100644 index 0000000000..ecae556c6e Binary files /dev/null and b/website/public/front/images/Feeding_Time.png differ diff --git a/website/public/front/images/Guilds Sample Screen.png b/website/public/front/images/Guilds Sample Screen.png new file mode 100644 index 0000000000..af4dea8378 Binary files /dev/null and b/website/public/front/images/Guilds Sample Screen.png differ diff --git a/website/public/front/images/HabitRPGPromoPostCard6.png b/website/public/front/images/HabitRPGPromoPostCard6.png new file mode 100644 index 0000000000..a81708db03 Binary files /dev/null and b/website/public/front/images/HabitRPGPromoPostCard6.png differ diff --git a/website/public/front/images/HabitRPGPromoThin.png b/website/public/front/images/HabitRPGPromoThin.png new file mode 100644 index 0000000000..695b8c34cf Binary files /dev/null and b/website/public/front/images/HabitRPGPromoThin.png differ diff --git a/website/public/front/images/Habitica_banner_by_uncommoncriminal.png b/website/public/front/images/Habitica_banner_by_uncommoncriminal.png new file mode 100644 index 0000000000..aab8656f7f Binary files /dev/null and b/website/public/front/images/Habitica_banner_by_uncommoncriminal.png differ diff --git a/website/public/front/images/Habitica_map_by_uncommoncriminal.png b/website/public/front/images/Habitica_map_by_uncommoncriminal.png new file mode 100644 index 0000000000..72c985848b Binary files /dev/null and b/website/public/front/images/Habitica_map_by_uncommoncriminal.png differ diff --git a/website/public/front/images/Healer.png b/website/public/front/images/Healer.png new file mode 100644 index 0000000000..197a9f9d57 Binary files /dev/null and b/website/public/front/images/Healer.png differ diff --git a/website/public/front/images/Mount.png b/website/public/front/images/Mount.png new file mode 100644 index 0000000000..af9cabd8fd Binary files /dev/null and b/website/public/front/images/Mount.png differ diff --git a/website/public/front/images/Mount_Body_Dragon-Golden.png b/website/public/front/images/Mount_Body_Dragon-Golden.png new file mode 100644 index 0000000000..7b8c1295eb Binary files /dev/null and b/website/public/front/images/Mount_Body_Dragon-Golden.png differ diff --git a/website/public/front/images/Mount_Body_Dragon-Red.png b/website/public/front/images/Mount_Body_Dragon-Red.png new file mode 100644 index 0000000000..00df0c4c7d Binary files /dev/null and b/website/public/front/images/Mount_Body_Dragon-Red.png differ diff --git a/website/public/front/images/Mount_Body_Wolf-Base.png b/website/public/front/images/Mount_Body_Wolf-Base.png new file mode 100644 index 0000000000..0dc0945f89 Binary files /dev/null and b/website/public/front/images/Mount_Body_Wolf-Base.png differ diff --git a/website/public/front/images/Mount_Head_Dragon-Golden.png b/website/public/front/images/Mount_Head_Dragon-Golden.png new file mode 100644 index 0000000000..6efd547a0f Binary files /dev/null and b/website/public/front/images/Mount_Head_Dragon-Golden.png differ diff --git a/website/public/front/images/Mount_Head_Dragon-Red.png b/website/public/front/images/Mount_Head_Dragon-Red.png new file mode 100644 index 0000000000..23b4eeddbc Binary files /dev/null and b/website/public/front/images/Mount_Head_Dragon-Red.png differ diff --git a/website/public/front/images/Mount_Head_Wolf-Base.png b/website/public/front/images/Mount_Head_Wolf-Base.png new file mode 100644 index 0000000000..ebe89cdb63 Binary files /dev/null and b/website/public/front/images/Mount_Head_Wolf-Base.png differ diff --git a/website/public/front/images/Party-Header.png b/website/public/front/images/Party-Header.png new file mode 100644 index 0000000000..a6b8f5630c Binary files /dev/null and b/website/public/front/images/Party-Header.png differ diff --git a/website/public/front/images/Pet-Dragon-Red.png b/website/public/front/images/Pet-Dragon-Red.png new file mode 100644 index 0000000000..1422b074e7 Binary files /dev/null and b/website/public/front/images/Pet-Dragon-Red.png differ diff --git a/website/public/front/images/Pet-Fox-Red.png b/website/public/front/images/Pet-Fox-Red.png new file mode 100644 index 0000000000..01ed9304d7 Binary files /dev/null and b/website/public/front/images/Pet-Fox-Red.png differ diff --git a/website/public/front/images/Promo_springclasses2015.png b/website/public/front/images/Promo_springclasses2015.png new file mode 100644 index 0000000000..01410e644c Binary files /dev/null and b/website/public/front/images/Promo_springclasses2015.png differ diff --git a/website/public/front/images/Quest_dilatory_drag'on.png b/website/public/front/images/Quest_dilatory_drag'on.png new file mode 100644 index 0000000000..d3904c947e Binary files /dev/null and b/website/public/front/images/Quest_dilatory_drag'on.png differ diff --git a/website/public/front/images/Quest_dilatory_drag'onSmall.png b/website/public/front/images/Quest_dilatory_drag'onSmall.png new file mode 100644 index 0000000000..2311b42f7e Binary files /dev/null and b/website/public/front/images/Quest_dilatory_drag'onSmall.png differ diff --git a/website/public/front/images/Rogue.png b/website/public/front/images/Rogue.png new file mode 100644 index 0000000000..138fa94b75 Binary files /dev/null and b/website/public/front/images/Rogue.png differ diff --git a/website/public/front/images/SAMPLEadventurers.png b/website/public/front/images/SAMPLEadventurers.png new file mode 100644 index 0000000000..d12303a026 Binary files /dev/null and b/website/public/front/images/SAMPLEadventurers.png differ diff --git a/website/public/front/images/TVreward.png b/website/public/front/images/TVreward.png new file mode 100644 index 0000000000..570a52e0dc Binary files /dev/null and b/website/public/front/images/TVreward.png differ diff --git a/website/public/front/images/VICE_by_Baconsaur.png b/website/public/front/images/VICE_by_Baconsaur.png new file mode 100644 index 0000000000..bc53415d18 Binary files /dev/null and b/website/public/front/images/VICE_by_Baconsaur.png differ diff --git a/website/public/front/images/Warrior.png b/website/public/front/images/Warrior.png new file mode 100644 index 0000000000..43c46c6f8c Binary files /dev/null and b/website/public/front/images/Warrior.png differ diff --git a/website/public/front/images/Wizard.png b/website/public/front/images/Wizard.png new file mode 100644 index 0000000000..d8c2b3cbb3 Binary files /dev/null and b/website/public/front/images/Wizard.png differ diff --git a/website/public/front/images/achievement-perfect.png b/website/public/front/images/achievement-perfect.png new file mode 100644 index 0000000000..b9c9afafe1 Binary files /dev/null and b/website/public/front/images/achievement-perfect.png differ diff --git a/website/public/front/images/achievement-triadbingo.png b/website/public/front/images/achievement-triadbingo.png new file mode 100644 index 0000000000..26db28450b Binary files /dev/null and b/website/public/front/images/achievement-triadbingo.png differ diff --git a/website/public/front/images/avatar/.DS_Store b/website/public/front/images/avatar/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/website/public/front/images/avatar/.DS_Store differ diff --git a/website/public/front/images/avatar/Warrior.png b/website/public/front/images/avatar/Warrior.png new file mode 100644 index 0000000000..4428e4a571 Binary files /dev/null and b/website/public/front/images/avatar/Warrior.png differ diff --git a/website/public/front/images/avatar/avatar.png b/website/public/front/images/avatar/avatar.png new file mode 100644 index 0000000000..69ce9ba1b9 Binary files /dev/null and b/website/public/front/images/avatar/avatar.png differ diff --git a/website/public/front/images/avatar/avatarstatic.png b/website/public/front/images/avatar/avatarstatic.png new file mode 100644 index 0000000000..7f184e104a Binary files /dev/null and b/website/public/front/images/avatar/avatarstatic.png differ diff --git a/website/public/front/images/avatar/hair_bangs_1_brown.png b/website/public/front/images/avatar/hair_bangs_1_brown.png new file mode 100644 index 0000000000..2f1c964f44 Binary files /dev/null and b/website/public/front/images/avatar/hair_bangs_1_brown.png differ diff --git a/website/public/front/images/avatar/head_0.png b/website/public/front/images/avatar/head_0.png new file mode 100644 index 0000000000..5e8ff64c13 Binary files /dev/null and b/website/public/front/images/avatar/head_0.png differ diff --git a/website/public/front/images/avatar/head_warrior_3.png b/website/public/front/images/avatar/head_warrior_3.png new file mode 100644 index 0000000000..ba446c239e Binary files /dev/null and b/website/public/front/images/avatar/head_warrior_3.png differ diff --git a/website/public/front/images/avatar/head_warrior_5.png b/website/public/front/images/avatar/head_warrior_5.png new file mode 100644 index 0000000000..fab67bb74d Binary files /dev/null and b/website/public/front/images/avatar/head_warrior_5.png differ diff --git a/website/public/front/images/avatar/shield_warrior_3.png b/website/public/front/images/avatar/shield_warrior_3.png new file mode 100644 index 0000000000..fb89e66b02 Binary files /dev/null and b/website/public/front/images/avatar/shield_warrior_3.png differ diff --git a/website/public/front/images/avatar/shield_warrior_5.png b/website/public/front/images/avatar/shield_warrior_5.png new file mode 100644 index 0000000000..72bb8ba040 Binary files /dev/null and b/website/public/front/images/avatar/shield_warrior_5.png differ diff --git a/website/public/front/images/avatar/skin_f5a76e.png b/website/public/front/images/avatar/skin_f5a76e.png new file mode 100644 index 0000000000..670a4d68ca Binary files /dev/null and b/website/public/front/images/avatar/skin_f5a76e.png differ diff --git a/website/public/front/images/avatar/slim_armor_warrior_3.png b/website/public/front/images/avatar/slim_armor_warrior_3.png new file mode 100644 index 0000000000..37fa0ca8df Binary files /dev/null and b/website/public/front/images/avatar/slim_armor_warrior_3.png differ diff --git a/website/public/front/images/avatar/slim_armor_warrior_5.png b/website/public/front/images/avatar/slim_armor_warrior_5.png new file mode 100644 index 0000000000..464b22bbef Binary files /dev/null and b/website/public/front/images/avatar/slim_armor_warrior_5.png differ diff --git a/website/public/front/images/avatar/slim_shirt_black.png b/website/public/front/images/avatar/slim_shirt_black.png new file mode 100644 index 0000000000..3136ea2526 Binary files /dev/null and b/website/public/front/images/avatar/slim_shirt_black.png differ diff --git a/website/public/front/images/avatar/weapon_healer_6.png b/website/public/front/images/avatar/weapon_healer_6.png new file mode 100644 index 0000000000..c58cba7660 Binary files /dev/null and b/website/public/front/images/avatar/weapon_healer_6.png differ diff --git a/website/public/front/images/avatar/weapon_warrior_3.png b/website/public/front/images/avatar/weapon_warrior_3.png new file mode 100644 index 0000000000..3f309980ac Binary files /dev/null and b/website/public/front/images/avatar/weapon_warrior_3.png differ diff --git a/website/public/front/images/avatar/weapon_warrior_5.png b/website/public/front/images/avatar/weapon_warrior_5.png new file mode 100644 index 0000000000..efe0633ccc Binary files /dev/null and b/website/public/front/images/avatar/weapon_warrior_5.png differ diff --git a/website/public/front/images/blackish_fox_by_kellllly-d7pzd46.png b/website/public/front/images/blackish_fox_by_kellllly-d7pzd46.png new file mode 100644 index 0000000000..dc37dfa00f Binary files /dev/null and b/website/public/front/images/blackish_fox_by_kellllly-d7pzd46.png differ diff --git a/website/public/front/images/devices.png b/website/public/front/images/devices.png new file mode 100644 index 0000000000..8981ff8875 Binary files /dev/null and b/website/public/front/images/devices.png differ diff --git a/website/public/front/images/explosion.jpg b/website/public/front/images/explosion.jpg new file mode 100644 index 0000000000..ca42ec94f1 Binary files /dev/null and b/website/public/front/images/explosion.jpg differ diff --git a/website/public/front/images/explosion.png b/website/public/front/images/explosion.png new file mode 100644 index 0000000000..c5e23b1f8c Binary files /dev/null and b/website/public/front/images/explosion.png differ diff --git a/website/public/front/images/favicon-8b58f6a1.ico b/website/public/front/images/favicon-8b58f6a1.ico new file mode 100644 index 0000000000..0a6f815a75 Binary files /dev/null and b/website/public/front/images/favicon-8b58f6a1.ico differ diff --git a/website/public/front/images/habitrpg_pixel.png b/website/public/front/images/habitrpg_pixel.png new file mode 100644 index 0000000000..4bd1c43f3b Binary files /dev/null and b/website/public/front/images/habitrpg_pixel.png differ diff --git a/website/public/front/images/icon175x175.png b/website/public/front/images/icon175x175.png new file mode 100644 index 0000000000..ed7f90ff8f Binary files /dev/null and b/website/public/front/images/icon175x175.png differ diff --git a/website/public/front/images/intro.jpg b/website/public/front/images/intro.jpg new file mode 100644 index 0000000000..209bd92770 Binary files /dev/null and b/website/public/front/images/intro.jpg differ diff --git a/website/public/front/images/intro.psd b/website/public/front/images/intro.psd new file mode 100644 index 0000000000..d5bcba33be Binary files /dev/null and b/website/public/front/images/intro.psd differ diff --git a/website/public/front/images/misc/Pet_Food_Cake_Base.png b/website/public/front/images/misc/Pet_Food_Cake_Base.png new file mode 100644 index 0000000000..61dd797756 Binary files /dev/null and b/website/public/front/images/misc/Pet_Food_Cake_Base.png differ diff --git a/website/public/front/images/misc/inventory_quest_scroll_harpy.png b/website/public/front/images/misc/inventory_quest_scroll_harpy.png new file mode 100644 index 0000000000..ea24cd83ff Binary files /dev/null and b/website/public/front/images/misc/inventory_quest_scroll_harpy.png differ diff --git a/website/public/front/images/misc/rebirth_orb.png b/website/public/front/images/misc/rebirth_orb.png new file mode 100644 index 0000000000..488e5b3724 Binary files /dev/null and b/website/public/front/images/misc/rebirth_orb.png differ diff --git a/website/public/front/images/misc/shop_gold.png b/website/public/front/images/misc/shop_gold.png new file mode 100644 index 0000000000..87efead7aa Binary files /dev/null and b/website/public/front/images/misc/shop_gold.png differ diff --git a/website/public/front/images/misc/shop_potion.png b/website/public/front/images/misc/shop_potion.png new file mode 100644 index 0000000000..02fc6af334 Binary files /dev/null and b/website/public/front/images/misc/shop_potion.png differ diff --git a/website/public/front/images/mockup_for_habit_by_cosmic_caterpillar-d8mf5mb.png b/website/public/front/images/mockup_for_habit_by_cosmic_caterpillar-d8mf5mb.png new file mode 100644 index 0000000000..7e1af36666 Binary files /dev/null and b/website/public/front/images/mockup_for_habit_by_cosmic_caterpillar-d8mf5mb.png differ diff --git a/website/public/front/images/party/.DS_Store b/website/public/front/images/party/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/website/public/front/images/party/.DS_Store differ diff --git a/website/public/front/images/party/AnnaCosplay.png b/website/public/front/images/party/AnnaCosplay.png new file mode 100644 index 0000000000..adeb677778 Binary files /dev/null and b/website/public/front/images/party/AnnaCosplay.png differ diff --git a/website/public/front/images/party/Ariel_cosplay.png b/website/public/front/images/party/Ariel_cosplay.png new file mode 100644 index 0000000000..98f62954ff Binary files /dev/null and b/website/public/front/images/party/Ariel_cosplay.png differ diff --git a/website/public/front/images/party/Big_Daddy_(BioShock).png b/website/public/front/images/party/Big_Daddy_(BioShock).png new file mode 100644 index 0000000000..8d0ebecb47 Binary files /dev/null and b/website/public/front/images/party/Big_Daddy_(BioShock).png differ diff --git a/website/public/front/images/party/Cosplay_Daenerys_Targaryen.png b/website/public/front/images/party/Cosplay_Daenerys_Targaryen.png new file mode 100644 index 0000000000..5bd132cb7a Binary files /dev/null and b/website/public/front/images/party/Cosplay_Daenerys_Targaryen.png differ diff --git a/website/public/front/images/party/GrimReaper.png b/website/public/front/images/party/GrimReaper.png new file mode 100644 index 0000000000..38e882c706 Binary files /dev/null and b/website/public/front/images/party/GrimReaper.png differ diff --git a/website/public/front/images/party/HomeStuckLusus.png b/website/public/front/images/party/HomeStuckLusus.png new file mode 100644 index 0000000000..e6f3d44802 Binary files /dev/null and b/website/public/front/images/party/HomeStuckLusus.png differ diff --git a/website/public/front/images/presslogos/.DS_Store b/website/public/front/images/presslogos/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/website/public/front/images/presslogos/.DS_Store differ diff --git a/website/public/front/images/presslogos/Cnetlogo.png b/website/public/front/images/presslogos/Cnetlogo.png new file mode 100644 index 0000000000..502e2b3bfe Binary files /dev/null and b/website/public/front/images/presslogos/Cnetlogo.png differ diff --git a/website/public/front/images/presslogos/Fast-Company-logo.png b/website/public/front/images/presslogos/Fast-Company-logo.png new file mode 100644 index 0000000000..38c10a1c1f Binary files /dev/null and b/website/public/front/images/presslogos/Fast-Company-logo.png differ diff --git a/website/public/front/images/presslogos/Forbes_logo.png b/website/public/front/images/presslogos/Forbes_logo.png new file mode 100644 index 0000000000..86fc3d867e Binary files /dev/null and b/website/public/front/images/presslogos/Forbes_logo.png differ diff --git a/website/public/front/images/presslogos/GitHub_Logo.png b/website/public/front/images/presslogos/GitHub_Logo.png new file mode 100644 index 0000000000..04e81c3ecd Binary files /dev/null and b/website/public/front/images/presslogos/GitHub_Logo.png differ diff --git a/website/public/front/images/presslogos/ionic-logo-blog.png b/website/public/front/images/presslogos/ionic-logo-blog.png new file mode 100644 index 0000000000..a9b793ec2b Binary files /dev/null and b/website/public/front/images/presslogos/ionic-logo-blog.png differ diff --git a/website/public/front/images/presslogos/ionic-logo-horizontal-transparent.png b/website/public/front/images/presslogos/ionic-logo-horizontal-transparent.png new file mode 100644 index 0000000000..de788eedbc Binary files /dev/null and b/website/public/front/images/presslogos/ionic-logo-horizontal-transparent.png differ diff --git a/website/public/front/images/presslogos/kickstarter-logo.png b/website/public/front/images/presslogos/kickstarter-logo.png new file mode 100644 index 0000000000..6da64f639d Binary files /dev/null and b/website/public/front/images/presslogos/kickstarter-logo.png differ diff --git a/website/public/front/images/presslogos/landing_slack_hash_wordmark_logo.png b/website/public/front/images/presslogos/landing_slack_hash_wordmark_logo.png new file mode 100644 index 0000000000..488f500e16 Binary files /dev/null and b/website/public/front/images/presslogos/landing_slack_hash_wordmark_logo.png differ diff --git a/website/public/front/images/presslogos/lifehacker.png b/website/public/front/images/presslogos/lifehacker.png new file mode 100644 index 0000000000..c7488479c1 Binary files /dev/null and b/website/public/front/images/presslogos/lifehacker.png differ diff --git a/website/public/front/images/presslogos/logo_webstorm.png b/website/public/front/images/presslogos/logo_webstorm.png new file mode 100644 index 0000000000..1c8a7b8bd0 Binary files /dev/null and b/website/public/front/images/presslogos/logo_webstorm.png differ diff --git a/website/public/front/images/presslogos/makeuseof.png b/website/public/front/images/presslogos/makeuseof.png new file mode 100644 index 0000000000..31d5eac64c Binary files /dev/null and b/website/public/front/images/presslogos/makeuseof.png differ diff --git a/website/public/front/images/presslogos/nyt-logo.png b/website/public/front/images/presslogos/nyt-logo.png new file mode 100644 index 0000000000..bec83339af Binary files /dev/null and b/website/public/front/images/presslogos/nyt-logo.png differ diff --git a/website/public/front/images/presslogos/slack.png b/website/public/front/images/presslogos/slack.png new file mode 100644 index 0000000000..0134660e2b Binary files /dev/null and b/website/public/front/images/presslogos/slack.png differ diff --git a/website/public/front/images/presslogos/trello-logo-blue.png b/website/public/front/images/presslogos/trello-logo-blue.png new file mode 100644 index 0000000000..2674b1d599 Binary files /dev/null and b/website/public/front/images/presslogos/trello-logo-blue.png differ diff --git a/website/public/front/images/quest_vice3.png b/website/public/front/images/quest_vice3.png new file mode 100644 index 0000000000..afc5020526 Binary files /dev/null and b/website/public/front/images/quest_vice3.png differ diff --git a/website/public/front/images/screenshot.png b/website/public/front/images/screenshot.png new file mode 100644 index 0000000000..eb3ba9a385 Binary files /dev/null and b/website/public/front/images/screenshot.png differ diff --git a/website/public/front/images/t_bone_fight_2_by_mortquitue-d8dtxbl.png b/website/public/front/images/t_bone_fight_2_by_mortquitue-d8dtxbl.png new file mode 100644 index 0000000000..f82ef8ef35 Binary files /dev/null and b/website/public/front/images/t_bone_fight_2_by_mortquitue-d8dtxbl.png differ diff --git a/website/public/front/images/testimonial_by_Streak.png b/website/public/front/images/testimonial_by_Streak.png new file mode 100644 index 0000000000..d095baf0cf Binary files /dev/null and b/website/public/front/images/testimonial_by_Streak.png differ diff --git a/website/public/front/images/testimonials/.DS_Store b/website/public/front/images/testimonials/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/website/public/front/images/testimonials/.DS_Store differ diff --git a/website/public/front/images/testimonials/16bitFil.png b/website/public/front/images/testimonials/16bitFil.png new file mode 100644 index 0000000000..7615bd770f Binary files /dev/null and b/website/public/front/images/testimonials/16bitFil.png differ diff --git a/website/public/front/images/testimonials/AlexandraSo.png b/website/public/front/images/testimonials/AlexandraSo.png new file mode 100644 index 0000000000..45a5410b6a Binary files /dev/null and b/website/public/front/images/testimonials/AlexandraSo.png differ diff --git a/website/public/front/images/testimonials/Althaire.png b/website/public/front/images/testimonials/Althaire.png new file mode 100644 index 0000000000..034ff50e9e Binary files /dev/null and b/website/public/front/images/testimonials/Althaire.png differ diff --git a/website/public/front/images/testimonials/AndeeLiao.png b/website/public/front/images/testimonials/AndeeLiao.png new file mode 100644 index 0000000000..66a9fd023a Binary files /dev/null and b/website/public/front/images/testimonials/AndeeLiao.png differ diff --git a/website/public/front/images/testimonials/Brenna.png b/website/public/front/images/testimonials/Brenna.png new file mode 100644 index 0000000000..9edb96108a Binary files /dev/null and b/website/public/front/images/testimonials/Brenna.png differ diff --git a/website/public/front/images/testimonials/Drag0nsilver.png b/website/public/front/images/testimonials/Drag0nsilver.png new file mode 100644 index 0000000000..8f704b73ef Binary files /dev/null and b/website/public/front/images/testimonials/Drag0nsilver.png differ diff --git a/website/public/front/images/testimonials/Drei-M.png b/website/public/front/images/testimonials/Drei-M.png new file mode 100644 index 0000000000..26f02a73ec Binary files /dev/null and b/website/public/front/images/testimonials/Drei-M.png differ diff --git a/website/public/front/images/testimonials/Elmi.png b/website/public/front/images/testimonials/Elmi.png new file mode 100644 index 0000000000..21d6fe90dd Binary files /dev/null and b/website/public/front/images/testimonials/Elmi.png differ diff --git a/website/public/front/images/testimonials/EvaGantz.png b/website/public/front/images/testimonials/EvaGantz.png new file mode 100644 index 0000000000..57de3b7409 Binary files /dev/null and b/website/public/front/images/testimonials/EvaGantz.png differ diff --git a/website/public/front/images/testimonials/Helcura.png b/website/public/front/images/testimonials/Helcura.png new file mode 100644 index 0000000000..2e673b7351 Binary files /dev/null and b/website/public/front/images/testimonials/Helcura.png differ diff --git a/website/public/front/images/testimonials/InfH.png b/website/public/front/images/testimonials/InfH.png new file mode 100644 index 0000000000..62469cd980 Binary files /dev/null and b/website/public/front/images/testimonials/InfH.png differ diff --git a/website/public/front/images/testimonials/Kai.png b/website/public/front/images/testimonials/Kai.png new file mode 100644 index 0000000000..090b7e7a2f Binary files /dev/null and b/website/public/front/images/testimonials/Kai.png differ diff --git a/website/public/front/images/testimonials/Kazui.png b/website/public/front/images/testimonials/Kazui.png new file mode 100644 index 0000000000..aec92c6337 Binary files /dev/null and b/website/public/front/images/testimonials/Kazui.png differ diff --git a/website/public/front/images/testimonials/Zelah_Meyer.png b/website/public/front/images/testimonials/Zelah_Meyer.png new file mode 100644 index 0000000000..2fd88aa549 Binary files /dev/null and b/website/public/front/images/testimonials/Zelah_Meyer.png differ diff --git a/website/public/front/images/testimonials/autumnesquirrel.png b/website/public/front/images/testimonials/autumnesquirrel.png new file mode 100644 index 0000000000..6fbe9e7f0b Binary files /dev/null and b/website/public/front/images/testimonials/autumnesquirrel.png differ diff --git a/website/public/front/images/testimonials/frabjabulous.png b/website/public/front/images/testimonials/frabjabulous.png new file mode 100644 index 0000000000..9fcfb7736f Binary files /dev/null and b/website/public/front/images/testimonials/frabjabulous.png differ diff --git a/website/public/front/images/testimonials/galarix.png b/website/public/front/images/testimonials/galarix.png new file mode 100644 index 0000000000..24fa1bdd1f Binary files /dev/null and b/website/public/front/images/testimonials/galarix.png differ diff --git a/website/public/front/images/testimonials/gwyn.blath.png b/website/public/front/images/testimonials/gwyn.blath.png new file mode 100644 index 0000000000..b58ca3252d Binary files /dev/null and b/website/public/front/images/testimonials/gwyn.blath.png differ diff --git a/website/public/front/images/testimonials/irishfeet123.png b/website/public/front/images/testimonials/irishfeet123.png new file mode 100644 index 0000000000..1d2218bf0d Binary files /dev/null and b/website/public/front/images/testimonials/irishfeet123.png differ diff --git a/website/public/front/images/testimonials/skysailor.png b/website/public/front/images/testimonials/skysailor.png new file mode 100644 index 0000000000..2c585f75b4 Binary files /dev/null and b/website/public/front/images/testimonials/skysailor.png differ diff --git a/website/public/front/images/testimonials/supermouse35.png b/website/public/front/images/testimonials/supermouse35.png new file mode 100644 index 0000000000..3bf9a84ae8 Binary files /dev/null and b/website/public/front/images/testimonials/supermouse35.png differ diff --git a/website/public/front/images/testimonials/tonitonirocca.png b/website/public/front/images/testimonials/tonitonirocca.png new file mode 100644 index 0000000000..373c3cf600 Binary files /dev/null and b/website/public/front/images/testimonials/tonitonirocca.png differ diff --git a/website/public/front/images/uses/.DS_Store b/website/public/front/images/uses/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/website/public/front/images/uses/.DS_Store differ diff --git a/website/public/front/images/uses/achievement-bkgd.png b/website/public/front/images/uses/achievement-bkgd.png new file mode 100644 index 0000000000..c3561ca561 Binary files /dev/null and b/website/public/front/images/uses/achievement-bkgd.png differ diff --git a/website/public/front/images/uses/clipart-rosemonkeyct-meditation.png b/website/public/front/images/uses/clipart-rosemonkeyct-meditation.png new file mode 100644 index 0000000000..85f99e9d35 Binary files /dev/null and b/website/public/front/images/uses/clipart-rosemonkeyct-meditation.png differ diff --git a/website/public/front/images/uses/clipart-rosemonkeyct-meditation.psd b/website/public/front/images/uses/clipart-rosemonkeyct-meditation.psd new file mode 100644 index 0000000000..d532e5d5ac Binary files /dev/null and b/website/public/front/images/uses/clipart-rosemonkeyct-meditation.psd differ diff --git a/website/public/front/images/uses/clipart-rosemonkeyct-reading.png b/website/public/front/images/uses/clipart-rosemonkeyct-reading.png new file mode 100644 index 0000000000..b8c330419f Binary files /dev/null and b/website/public/front/images/uses/clipart-rosemonkeyct-reading.png differ diff --git a/website/public/front/images/uses/coding.png b/website/public/front/images/uses/coding.png new file mode 100644 index 0000000000..1e093e902f Binary files /dev/null and b/website/public/front/images/uses/coding.png differ diff --git a/website/public/front/images/uses/coding_3_by_phoneix_faerie-d7idtti.png b/website/public/front/images/uses/coding_3_by_phoneix_faerie-d7idtti.png new file mode 100644 index 0000000000..4973d66f3b Binary files /dev/null and b/website/public/front/images/uses/coding_3_by_phoneix_faerie-d7idtti.png differ diff --git a/website/public/front/images/uses/consequences.png b/website/public/front/images/uses/consequences.png new file mode 100644 index 0000000000..211607a511 Binary files /dev/null and b/website/public/front/images/uses/consequences.png differ diff --git a/website/public/front/images/uses/dusting-bkgd.png b/website/public/front/images/uses/dusting-bkgd.png new file mode 100644 index 0000000000..55c1a5e3c8 Binary files /dev/null and b/website/public/front/images/uses/dusting-bkgd.png differ diff --git a/website/public/front/images/uses/dusting_by_leephon.png b/website/public/front/images/uses/dusting_by_leephon.png new file mode 100644 index 0000000000..0dba0d71bd Binary files /dev/null and b/website/public/front/images/uses/dusting_by_leephon.png differ diff --git a/website/public/front/images/uses/gaining_an_achievement_by_cosmic_caterpillar-d7uyv5z.png b/website/public/front/images/uses/gaining_an_achievement_by_cosmic_caterpillar-d7uyv5z.png new file mode 100644 index 0000000000..b5a3b6349e Binary files /dev/null and b/website/public/front/images/uses/gaining_an_achievement_by_cosmic_caterpillar-d7uyv5z.png differ diff --git a/website/public/front/images/uses/meditation-bkgd.png b/website/public/front/images/uses/meditation-bkgd.png new file mode 100644 index 0000000000..6b9ed074dd Binary files /dev/null and b/website/public/front/images/uses/meditation-bkgd.png differ diff --git a/website/public/front/images/uses/publicSpaces.png b/website/public/front/images/uses/publicSpaces.png new file mode 100644 index 0000000000..7341fbe6a3 Binary files /dev/null and b/website/public/front/images/uses/publicSpaces.png differ diff --git a/website/public/front/images/uses/reading.png b/website/public/front/images/uses/reading.png new file mode 100644 index 0000000000..2e727e8f29 Binary files /dev/null and b/website/public/front/images/uses/reading.png differ diff --git a/website/public/front/js/.DS_Store b/website/public/front/js/.DS_Store new file mode 100644 index 0000000000..5008ddfcf5 Binary files /dev/null and b/website/public/front/js/.DS_Store differ diff --git a/website/public/front/js/blockScroll.js b/website/public/front/js/blockScroll.js new file mode 100755 index 0000000000..193cbf1def --- /dev/null +++ b/website/public/front/js/blockScroll.js @@ -0,0 +1,215 @@ +(function( $ ) { + + $.fn.blockScroll = function(options) { + var settings = $.extend({ + // These are the defaults. + startDiv : 1, + fadeDuration : "slow", + paddingRatio : 0.05, + triggerRatio : 0.005, + scrollDuration: "fast", + fadeBlocks: true + }, options ); + + if(settings.triggerRatio > settings.paddingRatio*.95) { settings.triggerRatio = settings.paddingRatio*.95 } + + var theDivs = this.children().filter("div"); + var activeDiv = settings.startDiv-1; //Active did is 0-index, settings is 1-index + var windowHeight; + var paddingHeight; + var triggerHeight; + var currentDownTrigger; + var currentUpTrigger; + var totalDivs = theDivs.length; + var lastScrollPos; + var activelyScrolling = false; + var activeBackground= 0; + + // Ensure that all of the elements are hidden just in case the css is not setup properly + if(settings.fadeBlocks) + { + this.children().each(function() { + $(this).css('opacity','0'); + }); + } + + arrange(); + // Fade in the first div + $(theDivs[activeDiv]).animate({opacity: 1},settings.fadeDuration,'linear', function() { + $(window).scrollTop(0); + calcTriggers(); + bindEvents(); + lastScrollPos = $(window).scrollTop(); + }); + + function bindEvents() + { + $(window).on('scroll', function(e) { + var scrollPosition = $(window).scrollTop(); + var scrollDistance = $(window).height(); + var indexOfClosest = 0; + + theDivs.each(function(index, element) { + var $this = $(this); + var topPosition = $this.offset().top; + var newScrollDistance = Math.abs(scrollPosition - topPosition); + if(newScrollDistance < scrollDistance) + { + indexOfClosest = index; + scrollDistance = newScrollDistance; + } + }); + gotoDiv(indexOfClosest); + }, 250); + + $(window).resize(function() { + arrange(); + }); + + $("#block-up-arrow").click(function() { + goUp(); + }); + + $("#block-down-arrow").click(function() { + goDown(); + }); + + $(document).keydown(function(e){ + if (e.keyCode == 37 || e.keyCode == 38) { + goUp(); + return false; + } + + if (e.keyCode == 39 || e.keyCode == 40) { + goDown(); + return false; + } + }); + $(window).bind('mousewheel', function(e){ + if(e.originalEvent.wheelDelta > 119) { + goUp(); + } + else if (e.originalEvent.wheelDelta < -119) { + goDown(); + } + }); + } + + function goUp() + { + if(activeDiv > 0 && !activelyScrolling) + { + gotoDiv(activeDiv-1); + } + } + + function goDown() + { + if(activeDiv < totalDivs - 1 && !activelyScrolling) + { + gotoDiv(activeDiv+1); + } + } + + function gotoDiv(number) + { + if(number == 0) + $("#block-up-arrow").hide(); + else + $("#block-up-arrow").show(); + if(number == totalDivs-1) + $("#block-down-arrow").hide(); + else + $("#block-down-arrow").show(); + activeDiv = number; + activelyScrolling = true; + $('html, body').animate({scrollTop: $(theDivs[activeDiv]).offset().top}, settings.scrollDuration, 'linear', function() { + $(theDivs[activeDiv]).animate({opacity: 1}, settings.fadeDuration,'linear', function() { + setTimeout(function(){ + activelyScrolling = false; lastScrollPos = $(window).scrollTop(); + },50); + }); + }); + calcTriggers(); + } + + function calcTriggers() + { + if (activeDiv < totalDivs -1) + { + currentDownTrigger = $(theDivs[activeDiv+1]).offset().top; + } else { + currentDownTrigger = -1; + } + + if (activeDiv > 0) { + currentUpTrigger = $(theDivs[activeDiv-1]).offset().top; + } else { + currentUpTrigger = -1; + } + } + + function calcDims() + { + windowHeight = $(window).height(); + paddingHeight = windowHeight * settings.paddingRatio; + triggerHeight = windowHeight * settings.triggerRatio; + } + + + function arrange() + { + calcDims(); + theDivs.each(function(index, element) { + var $this = $(this); + $this.height('auto'); + if($this.height() < windowHeight) + { + var margin = windowHeight/2 - $this.height()/2; + $this.height(windowHeight-margin); + $this.css('padding-top', margin + "px"); + var $innerDiv = $($this.children().filter('div')[0]); + // $innerDiv.css('padding-top', margin + "px"); + } + if(index != totalDivs - 1) + { + //$this.css('padding-bottom',paddingHeight + 'px'); + } + }); + gotoDiv(activeDiv); + } + + var gotoView = function(number) + { + gotoDiv(number-1); + } + + return { + goto: gotoView + }; + } + +}( jQuery )); + +;(function ($) { + var on = $.fn.on, timer; + $.fn.on = function () { + var args = Array.apply(null, arguments); + var last = args[args.length - 1]; + + if (isNaN(last) || (last === 1 && args.pop())) return on.apply(this, args); + + var delay = args.pop(); + var fn = args.pop(); + + args.push(function () { + var self = this, params = arguments; + clearTimeout(timer); + timer = setTimeout(function () { + fn.apply(self, params); + }, delay); + }); + + return on.apply(this, args); + }; +}(this.jQuery || this.Zepto)); diff --git a/website/public/front/js/bootstrap.min.js b/website/public/front/js/bootstrap.min.js new file mode 100644 index 0000000000..c8f82e592a --- /dev/null +++ b/website/public/front/js/bootstrap.min.js @@ -0,0 +1,7 @@ +/*! + * Bootstrap v3.3.4 (http://getbootstrap.com) + * Copyright 2011-2015 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ +if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.4",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.4",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active"));a&&this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.4",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.4",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){b&&3===b.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=c(d),f={relatedTarget:this};e.hasClass("open")&&(e.trigger(b=a.Event("hide.bs.dropdown",f)),b.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger("hidden.bs.dropdown",f)))}))}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.4",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a('',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(this.options.viewport.selector||this.options.viewport),this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c&&c.$tip&&c.$tip.is(":visible")?void(c.hoverState="in"):(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.options.container?a(this.options.container):this.$element.parent(),p=this.getPosition(o);h="bottom"==h&&k.bottom+m>p.bottom?"top":"top"==h&&k.top-mp.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.width&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){return this.$tip=this.$tip||a(this.options.template)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type)})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.4",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.4",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.4",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=a(document.body).height();"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); \ No newline at end of file diff --git a/website/public/front/js/skrollr.min.js b/website/public/front/js/skrollr.min.js new file mode 100644 index 0000000000..75f08b4f82 --- /dev/null +++ b/website/public/front/js/skrollr.min.js @@ -0,0 +1,2 @@ +/*! skrollr 0.6.29 (2014-11-17) | Alexander Prinzhorn - https://github.com/Prinzhorn/skrollr | Free to use under terms of MIT license */ +(function(e,t,r){"use strict";function n(r){if(o=t.documentElement,a=t.body,Y(),lt=this,r=r||{},mt=r.constants||{},r.easing)for(var n in r.easing)X[n]=r.easing[n];Tt=r.edgeStrategy||"set",ft={beforerender:r.beforerender,render:r.render,keyframe:r.keyframe},ut=r.forceHeight!==!1,ut&&(zt=r.scale||1),pt=r.mobileDeceleration||x,gt=r.smoothScrolling!==!1,vt=r.smoothScrollingDuration||A,ht={targetTop:lt.getScrollTop()},Kt=(r.mobileCheck||function(){return/Android|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent||navigator.vendor||e.opera)})(),Kt?(ct=t.getElementById(r.skrollrBody||E),ct&&it(),j(),Dt(o,[y,S],[T])):Dt(o,[y,b],[T]),lt.refresh(),kt(e,"resize orientationchange",function(){var e=o.clientWidth,t=o.clientHeight;(t!==Bt||e!==$t)&&(Bt=t,$t=e,_t=!0)});var i=R();return function l(){J(),St=i(l)}(),lt}var o,a,i={get:function(){return lt},init:function(e){return lt||new n(e)},VERSION:"0.6.29"},l=Object.prototype.hasOwnProperty,s=e.Math,c=e.getComputedStyle,f="touchstart",u="touchmove",m="touchcancel",p="touchend",d="skrollable",g=d+"-before",v=d+"-between",h=d+"-after",y="skrollr",T="no-"+y,b=y+"-desktop",S=y+"-mobile",k="linear",w=1e3,x=.004,E="skrollr-body",A=200,F="start",C="end",H="center",D="bottom",I="___skrollable_id",P=/^(?:input|textarea|button|select)$/i,N=/^\s+|\s+$/g,O=/^data(?:-(_\w+))?(?:-?(-?\d*\.?\d+p?))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/,V=/\s*(@?[\w\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,z=/^(@?[a-z\-]+)\[(\w+)\]$/,q=/-([a-z0-9_])/g,L=function(e,t){return t.toUpperCase()},M=/[\-+]?[\d]*\.?[\d]+/g,$=/\{\?\}/g,B=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,_=/[a-z\-]+-gradient/g,G="",K="",Y=function(){var e=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;if(c){var t=c(a,null);for(var n in t)if(G=n.match(e)||+n==n&&t[n].match(e))break;if(!G)return G=K="",r;G=G[0],"-"===G.slice(0,1)?(K=G,G={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[G]):K="-"+G.toLowerCase()+"-"}},R=function(){var t=e.requestAnimationFrame||e[G.toLowerCase()+"RequestAnimationFrame"],r=Nt();return(Kt||!t)&&(t=function(t){var n=Nt()-r,o=s.max(0,1e3/60-n);return e.setTimeout(function(){r=Nt(),t()},o)}),t},U=function(){var t=e.cancelAnimationFrame||e[G.toLowerCase()+"CancelAnimationFrame"];return(Kt||!t)&&(t=function(t){return e.clearTimeout(t)}),t},X={begin:function(){return 0},end:function(){return 1},linear:function(e){return e},quadratic:function(e){return e*e},cubic:function(e){return e*e*e},swing:function(e){return-s.cos(e*s.PI)/2+.5},sqrt:function(e){return s.sqrt(e)},outCubic:function(e){return s.pow(e-1,3)+1},bounce:function(e){var t;if(.5083>=e)t=3;else if(.8489>=e)t=9;else if(.96208>=e)t=27;else{if(!(.99981>=e))return 1;t=91}return 1-s.abs(3*s.cos(1.028*e*t)/t)}};n.prototype.refresh=function(e){var n,o,a=!1;for(e===r?(a=!0,st=[],Gt=0,e=t.getElementsByTagName("*")):e.length===r&&(e=[e]),n=0,o=e.length;o>n;n++){var i=e[n],l=i,s=[],c=gt,f=Tt,u=!1;if(a&&I in i&&delete i[I],i.attributes){for(var m=0,p=i.attributes.length;p>m;m++){var g=i.attributes[m];if("data-anchor-target"!==g.name)if("data-smooth-scrolling"!==g.name)if("data-edge-strategy"!==g.name)if("data-emit-events"!==g.name){var v=g.name.match(O);if(null!==v){var h={props:g.value,element:i,eventType:g.name.replace(q,L)};s.push(h);var y=v[1];y&&(h.constant=y.substr(1));var T=v[2];/p$/.test(T)?(h.isPercentage=!0,h.offset=(0|T.slice(0,-1))/100):h.offset=0|T;var b=v[3],S=v[4]||b;b&&b!==F&&b!==C?(h.mode="relative",h.anchors=[b,S]):(h.mode="absolute",b===C?h.isEnd=!0:h.isPercentage||(h.offset=h.offset*zt))}}else u=!0;else f=g.value;else c="off"!==g.value;else if(l=t.querySelector(g.value),null===l)throw'Unable to find anchor target "'+g.value+'"'}if(s.length){var k,w,x;!a&&I in i?(x=i[I],k=st[x].styleAttr,w=st[x].classAttr):(x=i[I]=Gt++,k=i.style.cssText,w=Ht(i)),st[x]={element:i,styleAttr:k,classAttr:w,anchorTarget:l,keyFrames:s,smoothScrolling:c,edgeStrategy:f,emitEvents:u,lastFrameIndex:-1},Dt(i,[d],[])}}}for(At(),n=0,o=e.length;o>n;n++){var E=st[e[n][I]];E!==r&&(Q(E),tt(E))}return lt},n.prototype.relativeToAbsolute=function(e,t,r){var n=o.clientHeight,a=e.getBoundingClientRect(),i=a.top,l=a.bottom-a.top;return t===D?i-=n:t===H&&(i-=n/2),r===D?i+=l:r===H&&(i+=l/2),i+=lt.getScrollTop(),0|i+.5},n.prototype.animateTo=function(e,t){t=t||{};var n=Nt(),o=lt.getScrollTop();return dt={startTop:o,topDiff:e-o,targetTop:e,duration:t.duration||w,startTime:n,endTime:n+(t.duration||w),easing:X[t.easing||k],done:t.done},dt.topDiff||(dt.done&&dt.done.call(lt,!1),dt=r),lt},n.prototype.stopAnimateTo=function(){dt&&dt.done&&dt.done.call(lt,!0),dt=r},n.prototype.isAnimatingTo=function(){return!!dt},n.prototype.isMobile=function(){return Kt},n.prototype.setScrollTop=function(t,r){return yt=r===!0,Kt?Yt=s.min(s.max(t,0),Vt):e.scrollTo(0,t),lt},n.prototype.getScrollTop=function(){return Kt?Yt:e.pageYOffset||o.scrollTop||a.scrollTop||0},n.prototype.getMaxScrollTop=function(){return Vt},n.prototype.on=function(e,t){return ft[e]=t,lt},n.prototype.off=function(e){return delete ft[e],lt},n.prototype.destroy=function(){var e=U();e(St),xt(),Dt(o,[T],[y,b,S]);for(var t=0,n=st.length;n>t;t++)at(st[t].element);o.style.overflow=a.style.overflow="",o.style.height=a.style.height="",ct&&i.setStyle(ct,"transform","none"),lt=r,ct=r,ft=r,ut=r,Vt=0,zt=1,mt=r,pt=r,qt="down",Lt=-1,$t=0,Bt=0,_t=!1,dt=r,gt=r,vt=r,ht=r,yt=r,Gt=0,Tt=r,Kt=!1,Yt=0,bt=r};var j=function(){var n,i,l,c,d,g,v,h,y,T,b,S;kt(o,[f,u,m,p].join(" "),function(e){var o=e.changedTouches[0];for(c=e.target;3===c.nodeType;)c=c.parentNode;switch(d=o.clientY,g=o.clientX,T=e.timeStamp,P.test(c.tagName)||e.preventDefault(),e.type){case f:n&&n.blur(),lt.stopAnimateTo(),n=c,i=v=d,l=g,y=T;break;case u:P.test(c.tagName)&&t.activeElement!==c&&e.preventDefault(),h=d-v,S=T-b,lt.setScrollTop(Yt-h,!0),v=d,b=T;break;default:case m:case p:var a=i-d,k=l-g,w=k*k+a*a;if(49>w){if(!P.test(n.tagName)){n.focus();var x=t.createEvent("MouseEvents");x.initMouseEvent("click",!0,!0,e.view,1,o.screenX,o.screenY,o.clientX,o.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null),n.dispatchEvent(x)}return}n=r;var E=h/S;E=s.max(s.min(E,3),-3);var A=s.abs(E/pt),F=E*A+.5*pt*A*A,C=lt.getScrollTop()-F,H=0;C>Vt?(H=(Vt-C)/F,C=Vt):0>C&&(H=-C/F,C=0),A*=1-H,lt.animateTo(0|C+.5,{easing:"outCubic",duration:A})}}),e.scrollTo(0,0),o.style.overflow=a.style.overflow="hidden"},W=function(){var e,t,r,n,a,i,l,c,f,u,m,p=o.clientHeight,d=Ft();for(c=0,f=st.length;f>c;c++)for(e=st[c],t=e.element,r=e.anchorTarget,n=e.keyFrames,a=0,i=n.length;i>a;a++)l=n[a],u=l.offset,m=d[l.constant]||0,l.frame=u,l.isPercentage&&(u*=p,l.frame=u),"relative"===l.mode&&(at(t),l.frame=lt.relativeToAbsolute(r,l.anchors[0],l.anchors[1])-u,at(t,!0)),l.frame+=m,ut&&!l.isEnd&&l.frame>Vt&&(Vt=l.frame);for(Vt=s.max(Vt,Ct()),c=0,f=st.length;f>c;c++){for(e=st[c],n=e.keyFrames,a=0,i=n.length;i>a;a++)l=n[a],m=d[l.constant]||0,l.isEnd&&(l.frame=Vt-l.offset+m);e.keyFrames.sort(Ot)}},Z=function(e,t){for(var r=0,n=st.length;n>r;r++){var o,a,s=st[r],c=s.element,f=s.smoothScrolling?e:t,u=s.keyFrames,m=u.length,p=u[0],y=u[u.length-1],T=p.frame>f,b=f>y.frame,S=T?p:y,k=s.emitEvents,w=s.lastFrameIndex;if(T||b){if(T&&-1===s.edge||b&&1===s.edge)continue;switch(T?(Dt(c,[g],[h,v]),k&&w>-1&&(Et(c,p.eventType,qt),s.lastFrameIndex=-1)):(Dt(c,[h],[g,v]),k&&m>w&&(Et(c,y.eventType,qt),s.lastFrameIndex=m)),s.edge=T?-1:1,s.edgeStrategy){case"reset":at(c);continue;case"ease":f=S.frame;break;default:case"set":var x=S.props;for(o in x)l.call(x,o)&&(a=ot(x[o].value),0===o.indexOf("@")?c.setAttribute(o.substr(1),a):i.setStyle(c,o,a));continue}}else 0!==s.edge&&(Dt(c,[d,v],[g,h]),s.edge=0);for(var E=0;m-1>E;E++)if(f>=u[E].frame&&u[E+1].frame>=f){var A=u[E],F=u[E+1];for(o in A.props)if(l.call(A.props,o)){var C=(f-A.frame)/(F.frame-A.frame);C=A.props[o].easing(C),a=nt(A.props[o].value,F.props[o].value,C),a=ot(a),0===o.indexOf("@")?c.setAttribute(o.substr(1),a):i.setStyle(c,o,a)}k&&w!==E&&("down"===qt?Et(c,A.eventType,qt):Et(c,F.eventType,qt),s.lastFrameIndex=E);break}}},J=function(){_t&&(_t=!1,At());var e,t,n=lt.getScrollTop(),o=Nt();if(dt)o>=dt.endTime?(n=dt.targetTop,e=dt.done,dt=r):(t=dt.easing((o-dt.startTime)/dt.duration),n=0|dt.startTop+t*dt.topDiff),lt.setScrollTop(n,!0);else if(!yt){var a=ht.targetTop-n;a&&(ht={startTop:Lt,topDiff:n-Lt,targetTop:n,startTime:Mt,endTime:Mt+vt}),ht.endTime>=o&&(t=X.sqrt((o-ht.startTime)/vt),n=0|ht.startTop+t*ht.topDiff)}if(Kt&&ct&&i.setStyle(ct,"transform","translate(0, "+-Yt+"px) "+bt),yt||Lt!==n){qt=n>Lt?"down":Lt>n?"up":qt,yt=!1;var l={curTop:n,lastTop:Lt,maxTop:Vt,direction:qt},s=ft.beforerender&&ft.beforerender.call(lt,l);s!==!1&&(Z(n,lt.getScrollTop()),Lt=n,ft.render&&ft.render.call(lt,l)),e&&e.call(lt,!1)}Mt=o},Q=function(e){for(var t=0,r=e.keyFrames.length;r>t;t++){for(var n,o,a,i,l=e.keyFrames[t],s={};null!==(i=V.exec(l.props));)a=i[1],o=i[2],n=a.match(z),null!==n?(a=n[1],n=n[2]):n=k,o=o.indexOf("!")?et(o):[o.slice(1)],s[a]={value:o,easing:X[n]};l.props=s}},et=function(e){var t=[];return B.lastIndex=0,e=e.replace(B,function(e){return e.replace(M,function(e){return 100*(e/255)+"%"})}),K&&(_.lastIndex=0,e=e.replace(_,function(e){return K+e})),e=e.replace(M,function(e){return t.push(+e),"{?}"}),t.unshift(e),t},tt=function(e){var t,r,n={};for(t=0,r=e.keyFrames.length;r>t;t++)rt(e.keyFrames[t],n);for(n={},t=e.keyFrames.length-1;t>=0;t--)rt(e.keyFrames[t],n)},rt=function(e,t){var r;for(r in t)l.call(e.props,r)||(e.props[r]=t[r]);for(r in e.props)t[r]=e.props[r]},nt=function(e,t,r){var n,o=e.length;if(o!==t.length)throw"Can't interpolate between \""+e[0]+'" and "'+t[0]+'"';var a=[e[0]];for(n=1;o>n;n++)a[n]=e[n]+(t[n]-e[n])*r;return a},ot=function(e){var t=1;return $.lastIndex=0,e[0].replace($,function(){return e[t++]})},at=function(e,t){e=[].concat(e);for(var r,n,o=0,a=e.length;a>o;o++)n=e[o],r=st[n[I]],r&&(t?(n.style.cssText=r.dirtyStyleAttr,Dt(n,r.dirtyClassAttr)):(r.dirtyStyleAttr=n.style.cssText,r.dirtyClassAttr=Ht(n),n.style.cssText=r.styleAttr,Dt(n,r.classAttr)))},it=function(){bt="translateZ(0)",i.setStyle(ct,"transform",bt);var e=c(ct),t=e.getPropertyValue("transform"),r=e.getPropertyValue(K+"transform"),n=t&&"none"!==t||r&&"none"!==r;n||(bt="")};i.setStyle=function(e,t,r){var n=e.style;if(t=t.replace(q,L).replace("-",""),"zIndex"===t)n[t]=isNaN(r)?r:""+(0|r);else if("float"===t)n.styleFloat=n.cssFloat=r;else try{G&&(n[G+t.slice(0,1).toUpperCase()+t.slice(1)]=r),n[t]=r}catch(o){}};var lt,st,ct,ft,ut,mt,pt,dt,gt,vt,ht,yt,Tt,bt,St,kt=i.addEvent=function(t,r,n){var o=function(t){return t=t||e.event,t.target||(t.target=t.srcElement),t.preventDefault||(t.preventDefault=function(){t.returnValue=!1,t.defaultPrevented=!0}),n.call(this,t)};r=r.split(" ");for(var a,i=0,l=r.length;l>i;i++)a=r[i],t.addEventListener?t.addEventListener(a,n,!1):t.attachEvent("on"+a,o),Rt.push({element:t,name:a,listener:n})},wt=i.removeEvent=function(e,t,r){t=t.split(" ");for(var n=0,o=t.length;o>n;n++)e.removeEventListener?e.removeEventListener(t[n],r,!1):e.detachEvent("on"+t[n],r)},xt=function(){for(var e,t=0,r=Rt.length;r>t;t++)e=Rt[t],wt(e.element,e.name,e.listener);Rt=[]},Et=function(e,t,r){ft.keyframe&&ft.keyframe.call(lt,e,t,r)},At=function(){var e=lt.getScrollTop();Vt=0,ut&&!Kt&&(a.style.height=""),W(),ut&&!Kt&&(a.style.height=Vt+o.clientHeight+"px"),Kt?lt.setScrollTop(s.min(lt.getScrollTop(),Vt)):lt.setScrollTop(e,!0),yt=!0},Ft=function(){var e,t,r=o.clientHeight,n={};for(e in mt)t=mt[e],"function"==typeof t?t=t.call(lt):/p$/.test(t)&&(t=t.slice(0,-1)/100*r),n[e]=t;return n},Ct=function(){var e,t=0;return ct&&(t=s.max(ct.offsetHeight,ct.scrollHeight)),e=s.max(t,a.scrollHeight,a.offsetHeight,o.scrollHeight,o.offsetHeight,o.clientHeight),e-o.clientHeight},Ht=function(t){var r="className";return e.SVGElement&&t instanceof e.SVGElement&&(t=t[r],r="baseVal"),t[r]},Dt=function(t,n,o){var a="className";if(e.SVGElement&&t instanceof e.SVGElement&&(t=t[a],a="baseVal"),o===r)return t[a]=n,r;for(var i=t[a],l=0,s=o.length;s>l;l++)i=Pt(i).replace(Pt(o[l])," ");i=It(i);for(var c=0,f=n.length;f>c;c++)-1===Pt(i).indexOf(Pt(n[c]))&&(i+=" "+n[c]);t[a]=It(i)},It=function(e){return e.replace(N,"")},Pt=function(e){return" "+e+" "},Nt=Date.now||function(){return+new Date},Ot=function(e,t){return e.frame-t.frame},Vt=0,zt=1,qt="down",Lt=-1,Mt=Nt(),$t=0,Bt=0,_t=!1,Gt=0,Kt=!1,Yt=0,Rt=[];"function"==typeof define&&define.amd?define([],function(){return i}):"undefined"!=typeof module&&module.exports?module.exports=i:e.skrollr=i})(window,document); \ No newline at end of file diff --git a/website/public/front/landingv1Wireframe.jpg b/website/public/front/landingv1Wireframe.jpg new file mode 100644 index 0000000000..0db2f61d9c Binary files /dev/null and b/website/public/front/landingv1Wireframe.jpg differ diff --git a/website/public/front/more-info.html b/website/public/front/more-info.html new file mode 100644 index 0000000000..5189db93c1 --- /dev/null +++ b/website/public/front/more-info.html @@ -0,0 +1,28 @@ +HabitRPG | Gamify Your Life + + + + + + + + + + + + + +
HabitRPG logo

A free habit building app that treats your life like a game.



The problem with most productivity apps on the market is that they provide no incentive to continue using them. HabitRPG fixes this by making habit building fun! By rewarding you for your successes and penalizing you for slip-ups, HabitRPG provides external motivation for completing your day-to-day activities.

Instant Gratification

Whenever you reinforce a positive habit, complete a daily task, or take care of an old to-do, HabitRPG immediately rewards you with experience points and gold. As you gain experience, you can level up, increasing your stats and unlocking more features, like classes and pets. Gold can be spent on in-game items that change your experience or personalized rewards you've created for motivation. When even the smallest successes provide you with an immediate reward, you're less likely to procrastinate. 

Consequences

Whenever you indulge in a bad habit or fail to complete one of your daily tasks, you lose health. If your health drops too low, you die and lose some of the progress you've made. By providing immediate consequences, HabitRPG can help break bad habits and procrastination cycles before they cause real-world problems. 

Accountability

With an active community, HabitRPG provides the accountability you need to stay on task. With the party system, you can bring in a group of your closest friends to cheer you on. The guild system allows you to find people with similar interests or obstacles, so you can share your goals and swap tips on how to tackle your problems. On HabitRPG, the community means that you have both the support and the accountability you need to succeed.

\ No newline at end of file diff --git a/website/public/front/statichome.html b/website/public/front/statichome.html new file mode 100644 index 0000000000..3bf04f348f --- /dev/null +++ b/website/public/front/statichome.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website/public/front/staticstyle.css b/website/public/front/staticstyle.css new file mode 100644 index 0000000000..d3d6b679d5 --- /dev/null +++ b/website/public/front/staticstyle.css @@ -0,0 +1,502 @@ +body { + width:100%; + overflow-x:hidden; +} + +.navbar-brand img { + height:40px; + float:left; + vertical-align: middle; + margin:-10px 10px 10px; +} + +.navbar-right { + margin-right:0px!important; +} + +section { + height:100%; + position:relative; + padding:5% 0 5% 0; +} + +section .well { + margin-top:-4rem; +} + + +#intro { + text-align:center; + padding-bottom:5rem; +} + +#intro h1 { + font-size:30px; + margin:3rem 0 4rem 0; +} + +#intro-text { + margin-bottom:3rem; + padding-top:4rem; + border-top:1px solid #ccc; +} + +h1, h2, h3, h4, p.sectioninfo { + text-align: center; +} + +.featuretext h4, .footer h4 { + text-align:left; +} + +.footer { + background-color:#fff!important; +} + +.footer .shoutout { + padding:4rem 0 6rem 0; + background-color:#ebebeb; +} + +.footer .shoutout h4 { + text-align:center; + padding-bottom:2rem; +} + +.footer .shoutout img { + max-height:40px; + display:block; + margin:0 auto; + } + +.footer .footer-content { + padding-top:2rem; +} + +#quest-intro { + background:#fff url("images/Habitica_banner_by_uncommoncriminal.png") no-repeat center bottom; +} + + +p.sectioninfo { + display:block; + margin:100px auto 0 auto; + font-size:16px; +} + +#uses .btn-toolbar { + text-align: center; +} + +.presslogos { + padding:10px 0; +} + +.presslogos img { + max-height:30px; + max-width:120px; + vertical-align: middle; + margin:20px 30px; + filter: url("data:image/svg+xml;utf8,#grayscale"); /* Firefox 10+, Firefox on Android */ + filter: grayscale(100%); + -moz-filter: grayscale(100%); + -ms-filter: grayscale(100%); + -o-filter: grayscale(100%); + filter: gray; /* IE6-9 */ + -webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */ +} + + +img#myAvatar { + z-index:1; +} + + +.scroll-armor { + z-index:2; +} +.scroll-armor img { + position:absolute; + top:0%; + right:10%; +} + + +.quest-pet img { + width:100px; +} + + +button.gamifybutton { + margin: 20px; +} + +#rewards { + margin-top:200px; +} + +.tweet.popover { + position:relative; + display:block; + max-width:76%!important; +} + +.scrolltweet { + margin:80px 0; +} + +.scrolltweet-image { + width:100px; + text-align:right; +} + +.headline { + display:block; +} + +.avatarscroll { + display:block; + text-align: center; +} + +.avatarscroll img { + display:inline-block; + margin-top:20px; +} + + + +#myCarousel { + margin-top:2rem; +} + +#myCarousel .nav a small +{ + display: block; +} + +#myCarousel .nav a { + border-radius:10px; + margin:10px; +} +#myCarousel .nav-justified > li > a +{ + border-radius: 10px; + background-color:#eee; +} + +#myCarousel .nav-justified > li > a:hover +{ + background-color:#ccc; +} + +#myCarousel .nav-pills >li.active a { background-color: #16a085; } + +.carousel-content { + width:100%; + height:450px; + min-width:100%; + min-height:450px; + max-width:100%; + max-height:450px; + overflow:hidden; + display:block; +} + +.carousel-content .sampletasks .task-btn { + font-size:1.41em; +} + +.carousel-content .sampletasks .task-desc { + font-size:1em; +} + +.carousel-content img { + width:300px; +} + + +.sampletasks { + display:block; + float:left; + background-color: #eee; + padding:20px; +} + +#myCarousel img.sample-img { + display:inline-block; + margin-left:10px; +} + +.usetweet-groups { + display:block; + float:right; +} + +.usetweet-group { + clear:both; + width:100%; + padding:50px 0; +} + +.usetweet-group img { + float:left; + width:80px; +} + +#features h2 { + margin-top:0; +} + +.featuretext h4 { + text-align: center; +} + +#features .row { + margin:4rem auto; +} + +.feature-img { + display:block; + height:80px; + text-align: center; + line-height:100px; +} + +.feature-img img { + max-height:100px; +} + +.carousel-content .usetweet { + float:right; + max-width:300px; +} + +#footercall { + padding:5rem 0 3rem; +} + +#footercall button { + margin-top:6rem; +} + +.footer { + background-color:#eee; +} + +/*Quote carousel for Testimonials*/ +/* Carousel */ + +#testimonial-carousel img.img-say{ + margin-top:7rem; +} + +#quote-carousel { + padding-bottom:30px; + margin-top: 15rem; + /* Control buttons */ + /* Previous button */ + /* Next button */ + /* Changes the position of the indicators */ + /* Changes the color of the indicators */ +} +#quote-carousel .carousel-control { + background: none; + color: #CACACA; + font-size: 2.3em; + text-shadow: none; + margin-top: 30px; +} + +#quote-carousel .carousel-indicators { + right: 50%; + top: auto; + bottom: 0px; + margin-right: -19px; +} +#quote-carousel .carousel-indicators li { + width: 50px; + height: 50px; + margin: 5px; + cursor: pointer; + border: 4px solid #CCC; + opacity: 0.4; + overflow: hidden; + transition: all 0.4s; +} +#quote-carousel .carousel-indicators .active { + background: #333333; + width: 128px; + height: 128px; + border-color: #004080; + opacity: 1; + overflow: hidden; +} +#quote-carousel .carousel-inner { + min-height: 300px; +} +#quote-carousel .item blockquote { + border-left: none; + margin: 0; + padding:0; +} +#quote-carousel .item blockquote p:before { + content: "\201C"; + float: left; + font-size:100px; + margin: -30px 10px 0 0; +} + +/* Health bar CSS*/ +.health-progress { + display:block; +} + +.meter-label { + float:left; + background-color:#b0c3c7; + width:30px; + height:28px; + text-align: center; + padding:2px 5px; + border:1px solid #fff; + outline:#999 solid 1px; + color:#fff; + text-shadow:-1px -1px 1px #2f3f42,1px -1px 1px #2f3f42,-1px 1px 1px #2f3f42,1px 1px 1px #2f3f42; +} +.health .bar { + margin-left:40px; + height:28px; + border:1px solid #fff; + background-color:#fff; + outline:#999 solid 1px; +} +.health .bar div { + background:#da5353; + height:100%; +} + +#quest .quest-friend { + position:absolute; + width:45%; + display:block; + top:20%; +} + + +#quest .quest-friend-img{ + position:relative; + display:block; + float:left; + margin-top:10px; + width:150px; +} + +#quest .quest-friend-health { + position:relative; + top:-10%; + left:45%; + width:200px; +} + +#features { + padding-top:3rem; +} + +#features h4 { + padding-top:3rem; +} + + +/*Fixed CTA*/ +.fixedcta { + position: absolute; + bottom: 15px; + right: 15px; + cursor: pointer; + z-index: 300; +} + + + +@media only screen and (max-width: 992px) { + p.sectioninfo, .scrolltweet { + margin:10px auto; + } + + section { + height:auto; + position:relative; + padding:2% 0; + } + + section .well { + margin-top:2rem; + clear:both; + } + + button.gamifybutton { + margin: 40px auto 20px auto; + width:80%; + position: static; + display:block; + cursor: pointer; + z-index: 300; + } + + #features .row { + margin:4rem auto 8rem auto; + } + + .footer .shoutout img { + margin:20px auto; + } + +} + +@media only screen and (max-width: 767px) { + .mobile-container { + max-width:100%; + overflow-x:hidden; +} + + #myCarousel .nav > li { + width:30%; + display:inline-block; + } + + .introcall { + padding-top:10px; + margin-top:10px; + } + + #quote-carousel { + padding-bottom:1rem; + margin-top: 5rem; + } + + #quote-carousel .carousel-indicators { + padding-bottom:5rem; + } + + #quote-carousel .carousel-indicators li { + width: 20px; + height: 20px; +} +#quote-carousel .carousel-indicators .active { + background: #333333; + width: 50px; + height: 50px; +} +#quote-carousel .carousel-inner { + min-height: 350px; + width::90%; +} + + .carousel-content .sampletasks .task-desc { + font-size:0.8em; + } +} + + + diff --git a/website/public/front/style.css b/website/public/front/style.css new file mode 100644 index 0000000000..2860c4680f --- /dev/null +++ b/website/public/front/style.css @@ -0,0 +1,440 @@ +body { + width:100%; + overflow-x:hidden; +} + +.navbar-brand img { + height:40px; + float:left; + vertical-align: middle; + margin:-10px 10px 10px; +} + +.navbar-right { + margin-right:0px!important; +} + +section { + height:100vh; + position:relative; + padding-top:5%; +} + + + +#intro { + text-align:center; + padding-bottom:5rem; +} + +#intro h1 { + font-size:30px; + margin:3rem 0 4rem 0; +} + +#intro-text { + margin-bottom:3rem; + padding-top:4rem; + border-top:1px solid #ccc; +} + +h1, h2, h3, h4, p.sectioninfo { + text-align: center; +} + +.featuretext h4, .footer h4 { + text-align:left; +} + +.footer { + background-color:#fff!important; +} + +.footer .shoutout { + padding:2rem 0 4rem 0; + background-color:#ebebeb; +} + +.footer .shoutout h4 { + text-align:center; + padding-bottom:2rem; +} + +.footer .shoutout img { + height:40px; + display:block; + margin:0 auto; + } + +.footer .footer-content { + padding-top:2rem; +} + +#quest-intro { + background:#fff url("images/Habitica_banner_by_uncommoncriminal.png") no-repeat center bottom; +} + + +p.sectioninfo { + display:block; + width:500px; + margin:0 auto; + font-size:16px; +} + +#uses .btn-toolbar { + text-align: center; +} + +.presslogos { + padding:10px 0; +} + +.presslogos img { + max-height:30px; + max-width:120px; + vertical-align: middle; + margin:20px 30px; + filter: url("data:image/svg+xml;utf8,#grayscale"); /* Firefox 10+, Firefox on Android */ + filter: grayscale(100%); + -moz-filter: grayscale(100%); + -ms-filter: grayscale(100%); + -o-filter: grayscale(100%); + filter: gray; /* IE6-9 */ + -webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */ +} + + +img#myAvatar { + z-index:1; +} + + +.scroll-armor { + z-index:2; +} +.scroll-armor img { + position:absolute; + top:0%; + right:10%; +} + + +.quest-pet img { + width:100px; +} + + +button.gamifybutton { + margin: 20px; + width:20%; +} + +#rewards { + margin-top:200px; +} + +.tweet.popover { + position:relative; + display:block; +} + +.scrolltweet { + margin-top:-250px; + cursor:pointer; +} + +.scrolltweet-right { + position:absolute; + right:20%; +} + +.scrolltweet img { + opacity:0.8; +} + +.scrolltweet .scrolltweet-image { + width:80px; +} + +.headline { + display:block; + margin-bottom:400px; +} + +.avatarscroll { + position:absolute; + display:block; + width:300px; + left:50%; + margin-left:-150px; + margin-top:-400px; + text-align: center; +} + +.avatarscroll img { + display:inline-block; + margin-top:20px; +} +.quest-classes img { + display:block; + position:absolute!important; +} + + +#myCarousel { + margin-top:2rem; +} + +#myCarousel .nav a small +{ + display: block; +} + +#myCarousel .nav a { + border-radius:10px; + margin:10px; +} +#myCarousel .nav-justified > li > a +{ + border-radius: 10px; + background-color:#eee; +} + +#myCarousel .nav-justified > li > a:hover +{ + background-color:#ccc; +} + +#myCarousel .nav-pills>li.active a { background-color: #16a085; } + +.carousel-content { + width:100%; + height:450px; + min-width:100%; + min-height:450px; + max-width:100%; + max-height:450px; + overflow:hidden; + display:block; +} + +.carousel-content img { + width:300px; +} + + +.sampletasks { + display:block; + float:left; + background-color: #eee; + padding:20px; +} + +#myCarousel img.sample-img { + display:inline-block; + margin-left:10px; +} + +.usetweet-groups { + display:block; + float:right; + width:35%; +} + +.usetweet-group { + clear:both; + width:100%; + padding:50px 0; +} + +.usetweet-group img { + float:left; + width:80px; +} + +.carousel-content .usetweet { + float:right; + max-width:300px; +} + +.featuretext { + margin:30px 0; +} + +#footercall { + padding:5rem 0 3rem; +} + +#footercall button { + margin-top:10rem; +} + +.footer { + background-color:#eee; +} + +/*Quote carousel for Testimonials*/ +/* Carousel */ + +#testimonial-carousel img.img-say{ + margin-top:7rem; +} + +#quote-carousel { + padding-bottom:30px; + margin-top: 15rem; + /* Control buttons */ + /* Previous button */ + /* Next button */ + /* Changes the position of the indicators */ + /* Changes the color of the indicators */ +} +#quote-carousel .carousel-control { + background: none; + color: #CACACA; + font-size: 2.3em; + text-shadow: none; + margin-top: 30px; +} + +#quote-carousel .carousel-indicators { + right: 50%; + top: auto; + bottom: 0px; + margin-right: -19px; +} +#quote-carousel .carousel-indicators li { + width: 50px; + height: 50px; + margin: 5px; + cursor: pointer; + border: 4px solid #CCC; + opacity: 0.4; + overflow: hidden; + transition: all 0.4s; +} +#quote-carousel .carousel-indicators .active { + background: #333333; + width: 128px; + height: 128px; + border-color: #004080; + opacity: 1; + overflow: hidden; +} +#quote-carousel .carousel-inner { + min-height: 300px; +} +#quote-carousel .item blockquote { + border-left: none; + margin: 0; + padding:0; +} +#quote-carousel .item blockquote p:before { + content: "\201C"; + float: left; + font-size:100px; + margin: -30px 10px 0 0; +} + +/* Health bar CSS*/ +.health-progress { + display:block; + position:absolute; + top:200px; + left:37%; + width:350px; +} + +.meter-label { + float:left; + background-color:#b0c3c7; + width:30px; + height:28px; + text-align: center; + padding:2px 5px; + border:1px solid #fff; + outline:#999 solid 1px; + color:#fff; + text-shadow:-1px -1px 1px #2f3f42,1px -1px 1px #2f3f42,-1px 1px 1px #2f3f42,1px 1px 1px #2f3f42; +} +.health .bar { + margin-left:40px; + height:28px; + border:1px solid #fff; + background-color:#fff; + outline:#999 solid 1px; +} +.health .bar div { + background:#da5353; + height:100%; +} + +section#quest { + background: #ffffff url("images/Quest_dilatory_drag'on.png") no-repeat center top; +} + +#quest .quest-friend { + position:absolute; + width:45%; + display:block; + top:20%; +} + +#quest .quest-friend.quest-right { + left:50%; +} + +#quest .quest-friend.quest-left { + right:50%; +} + +#quest .quest-friend .quest-friend-img{ + position:relative; + display:block; + width:150px; + height:150px; + left:30%; +} + +#quest .quest-friend-health { + position:relative; + top:-10%; + left:45%; + width:200px; +} + +#features { + padding-top:3rem; +} + +#features h4 { + padding-top:3rem; +} + +#features .quest-mount img.mount { + position:absolute; + left:45%; + width:170px; +} + +#features .quest-mount img.mount-head{ + z-index:10; +} + +#features .quest-warrior img.warrior-5 { + position:absolute; + left:43%; + width:170px; + z-index:9; +} + + +/*Fixed CTA*/ +.fixedcta { + position: fixed; + bottom: 15px; + right: 15px; + cursor: pointer; + z-index: 300; +} \ No newline at end of file diff --git a/website/public/js/app.js b/website/public/js/app.js index 742f31cfcc..fae2f42e42 100644 --- a/website/public/js/app.js +++ b/website/public/js/app.js @@ -1,5 +1,21 @@ "use strict"; +/* Refresh page if idle > 6h */ +var REFRESH_FREQUENCY = 21600000; +var refresh; +var refresher = function() { + window.location.reload(true); +}; + +var awaitIdle = function() { + if(refresh) clearTimeout(refresh); + refresh = setTimeout(refresher, REFRESH_FREQUENCY); +}; + +awaitIdle(); +$(document).on('mousemove keydown mousedown touchstart', awaitIdle); +/* Refresh page if idle > 6h */ + window.habitrpg = angular.module('habitrpg', ['ui.bootstrap', 'ui.keypress', 'ui.router', 'chieffancypants.loadingBar', 'At', 'infinite-scroll', 'ui.select2', 'angular.filter', 'ngResource', 'ngSanitize']) @@ -140,11 +156,22 @@ window.habitrpg = angular.module('habitrpg', templateUrl: 'partials/options.social.challenges.detail.html', controller: ['$scope', 'Challenges', '$stateParams', function($scope, Challenges, $stateParams){ + $scope.obj = $scope.challenge = Challenges.Challenge.get({cid:$stateParams.cid}, function(){ $scope.challenge._locked = true; }); }] }) + .state('options.social.challenges.edit', { + url: '/:cid/edit', + templateUrl: 'partials/options.social.challenges.detail.html', + controller: ['$scope', 'Challenges', '$stateParams', + function($scope, Challenges, $stateParams){ + $scope.obj = $scope.challenge = Challenges.Challenge.get({cid:$stateParams.cid}, function(){ + $scope.challenge._locked = false; + }); + }] + }) .state('options.social.challenges.detail.member', { url: '/:uid', templateUrl: 'partials/options.social.challenges.detail.member.html', @@ -205,9 +232,9 @@ window.habitrpg = angular.module('habitrpg', url: "/export", templateUrl: "partials/options.settings.export.html" }) - .state('options.settings.coupon', { - url: "/coupon", - templateUrl: "partials/options.settings.coupon.html" + .state('options.settings.promo', { + url: "/promo", + templateUrl: "partials/options.settings.promo.html" }) .state('options.settings.subscription', { url: "/subscription", diff --git a/website/public/js/controllers/authCtrl.js b/website/public/js/controllers/authCtrl.js index 6bdd4c0b83..48cf71cbe7 100644 --- a/website/public/js/controllers/authCtrl.js +++ b/website/public/js/controllers/authCtrl.js @@ -15,11 +15,13 @@ angular.module('habitrpg') var runAuth = function(id, token) { User.authenticate(id, token, function(err) { + if(!err) $scope.registrationInProgress = false; $window.location.href = ('/' + window.location.hash); }); }; function errorAlert(data, status, headers, config) { + $scope.registrationInProgress = false; if (status === 0) { $window.alert(window.env.t('noReachServer')); } else if (!!data && !!data.err) { @@ -29,17 +31,31 @@ angular.module('habitrpg') } }; + $scope.registrationInProgress = false; + $scope.register = function() { /*TODO highlight invalid inputs we have this as a workaround for https://github.com/HabitRPG/habitrpg-mobile/issues/64 */ - if ($scope.registrationForm.$invalid) { - return; - } + var scope = angular.element(document.getElementById('registrationForm')).scope(); + if (scope.registrationForm.$invalid) return; + + $scope.registrationInProgress = true; + var url = ApiUrl.get() + "/api/v2/register"; if($rootScope.selectedLanguage) url = url + '?lang=' + $rootScope.selectedLanguage.code; - $http.post(url, $scope.registerVals).success(function(data, status, headers, config) { + $http.post(url, scope.registerVals).success(function(data, status, headers, config) { runAuth(data.id, data.apiToken); + if (status == 200) { + mixpanel.alias(data._id); + if (data.auth.facebook) { + mixpanel.register({'authType':'facebook','email':data.auth.facebook._json.email}) + } else { + mixpanel.register({'authType':'email','email':data.auth.local.email}) + } + mixpanel.register({'UUID':data._id,'language':data.preferences.language}); + mixpanel.track('Registration'); + } }).error(errorAlert); }; @@ -51,6 +67,11 @@ angular.module('habitrpg') $http.post(ApiUrl.get() + "/api/v2/user/auth/local", data) .success(function(data, status, headers, config) { runAuth(data.id, data.token); + if (status == 200) { + mixpanel.identify(data.id); + mixpanel.register({'UUID':data._id}); + mixpanel.track('Login'); + } }).error(errorAlert); }; @@ -115,13 +136,18 @@ angular.module('habitrpg') // ------ Social ---------- hello.init({ - facebook : window.env.FACEBOOK_KEY, + facebook : window.env.FACEBOOK_KEY }); $scope.socialLogin = function(network){ hello(network).login({scope:'email'}).then(function(auth){ $http.post(ApiUrl.get() + "/api/v2/user/auth/social", auth) .success(function(data, status, headers, config) { + if (status == 200) { + mixpanel.identify(data.id); + mixpanel.register({'UUID':data._id}); + mixpanel.track('Login'); + } runAuth(data.id, data.token); }).error(errorAlert); }, function( e ){ diff --git a/website/public/js/controllers/challengesCtrl.js b/website/public/js/controllers/challengesCtrl.js index dd397f6a45..24985e85ac 100644 --- a/website/public/js/controllers/challengesCtrl.js +++ b/website/public/js/controllers/challengesCtrl.js @@ -1,17 +1,36 @@ "use strict"; -habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state', - function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state) { +habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state', '$stateParams', + function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state, $stateParams) { + + // Use presence of cid to determine whether to show a list or a single + // challenge + $scope.cid = $state.params.cid; + + // Fetch single challenge if a cid is present; fetch multiple challenges + // otherwise + var getChallenges = function() { + if ($scope.cid) { + Challenges.Challenge.get({cid: $scope.cid}, function(challenge) { + $scope.challenges = [challenge]; + }); + } else { + Challenges.Challenge.query(function(challenges){ + $scope.challenges = challenges; + $scope.groupsFilter = _.uniq(_.pluck(challenges, 'group'), function(g){return g._id}); + $scope.search = { + group: _.transform($scope.groups, function(m,g){m[g._id]=true;}) + }; + }); + } + }; + + getChallenges(); // FIXME $scope.challenges needs to be resolved first (see app.js) $scope.groups = Groups.Group.query({type:'party,guilds,tavern'}); - Challenges.Challenge.query(function(challenges){ - $scope.challenges = challenges; - $scope.groupsFilter = _.uniq(_.pluck(challenges, 'group'), function(g){return g._id}); - $scope.search = { - group: _.transform($scope.groups, function(m,g){m[g._id]=true;}) - }; - }); + + // we should fix this, that's pretty brittle // override score() for tasks listed in challenges-editing pages, so that nothing happens @@ -21,10 +40,36 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', // Challenge //------------------------------------------------------------ + // Use this to force the top view to change, not just the nested view. + $scope.edit = function(challenge) { + $state.transitionTo('options.social.challenges.edit', {cid: challenge._id}, { + reload: true, inherit: false, notify: true + }); + }; + /** * Create */ $scope.create = function() { + + //If the user has one filter selected, assume that the user wants to default to that group + var defaultGroup; + //Our filters contain all groups, but we only want groups that have atleast one challenge + var groupsWithChallenges = _.uniq(_.pluck($scope.groupsFilter, '_id')); + var len = groupsWithChallenges.length; + var filterCount = 0; + + for ( var i = 0; i < len; i += 1 ) { + if ( $scope.search.group[groupsWithChallenges[i]] == true ) { + filterCount += 1; + defaultGroup = groupsWithChallenges[i]; + } + if (filterCount > 1) { + defaultGroup = $scope.groups[0]._id + break; + } + } + $scope.obj = $scope.newChallenge = new Challenges.Challenge({ name: '', description: '', @@ -33,7 +78,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', todos: [], rewards: [], leader: User.user._id, - group: $scope.groups[0]._id, + group: defaultGroup, timestamp: +(new Date), members: [], official: false @@ -49,14 +94,14 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', challenge.$save(function(_challenge){ if (isNew) { Notification.text(window.env.t('challengeCreated')); - $state.go('options.social.challenges.detail', {cid: _challenge._id}); - $scope.discard(); - $scope.challenges = Challenges.Challenge.query(); + $state.transitionTo('options.social.challenges.detail', {cid: challenge._id}, { + reload: true, inherit: false, notify: true + }); User.sync(); } else { - // TODO figure out a more elegant way about this - //challenge._editing = false; - challenge._locked = true; + $state.transitionTo('options.social.challenges.detail', {cid: challenge._id}, { + reload: true, inherit: false, notify: true + }); } }); }; @@ -75,23 +120,32 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', */ function backToChallenges(){ $scope.popoverEl.popover('destroy'); + $scope.cid = null; $state.go('options.social.challenges'); $scope.challenges = Challenges.Challenge.query(); User.log({}); } - $scope.cancelClosing = function() { + $scope.cancelClosing = function(challenge) { $scope.popoverEl.popover('destroy'); $scope.popoverEl = undefined; $scope.closingChal = undefined; + challenge.winner = undefined; } $scope["delete"] = function(challenge) { - if (!confirm(window.env.t('sureDelCha'))) return; + var warningMsg; + if(challenge.group._id == 'habitrpg') { + warningMsg = window.env.t('sureDelChaTavern'); + } else { + warningMsg = window.env.t('sureDelCha'); + } + if (!confirm(warningMsg)) return; challenge.$delete(function(){ $scope.popoverEl.popover('destroy'); backToChallenges(); }); }; $scope.selectWinner = function(challenge) { + if (!challenge.winner) return; if (!confirm(window.env.t('youSure'))) return; challenge.$close({uid:challenge.winner}, function(){ $scope.popoverEl.popover('destroy'); @@ -139,11 +193,11 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', delete listDef.newTask; }; - $scope.removeTask = function(list, $index) { + $scope.removeTask = function(task, list) { if (!confirm(window.env.t('sureDelete'))) return; //TODO persist // User.log({op: "delTask", data: task}); - list.splice($index, 1); + _.remove(list, task); }; $scope.saveTask = function(task){ @@ -159,7 +213,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', $scope.join = function(challenge){ challenge.$join(function(){ - $scope.challenges = Challenges.Challenge.query(); + getChallenges() User.log({}); }); @@ -170,7 +224,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', $scope.selectedChal = undefined; } else { $scope.selectedChal.$leave({keep:keep}, function(){ - $scope.challenges = Challenges.Challenge.query(); + getChallenges() User.log({}); }); } diff --git a/website/public/js/controllers/filtersCtrl.js b/website/public/js/controllers/filtersCtrl.js index 201c206977..b1204b86d3 100644 --- a/website/public/js/controllers/filtersCtrl.js +++ b/website/public/js/controllers/filtersCtrl.js @@ -4,6 +4,7 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared', function($scope, $rootScope, User, Shared) { var user = User.user; $scope._editing = false; + $scope._newTag = {name:''}; var tagsSnap; // used to compare which tags need updating @@ -29,8 +30,8 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared', // User.save(); }; - $scope.createTag = function(name) { - User.user.ops.addTag({body:{name:name, id:Shared.uuid()}}); - $scope._newTag = ''; + $scope.createTag = function() { + User.user.ops.addTag({body:{name:$scope._newTag.name, id:Shared.uuid()}}); + $scope._newTag.name = ''; }; }]); diff --git a/website/public/js/controllers/footerCtrl.js b/website/public/js/controllers/footerCtrl.js index d250e72b6e..f7fda11580 100644 --- a/website/public/js/controllers/footerCtrl.js +++ b/website/public/js/controllers/footerCtrl.js @@ -27,13 +27,19 @@ function($scope, $rootScope, User, $http, Notification, ApiUrl) { // Google Analytics, only in production if (window.env.NODE_ENV === 'production') { - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - ga('create', window.env.GA_ID, {userId:User.user._id}); - ga('require', 'displayfeatures'); - ga('send', 'pageview'); + // Get experiments API + $.getScript('//www.google-analytics.com/cx/api.js?experiment=t-AFggRWQnuJ6Teck_x1-Q', function(){ + $rootScope.variant = cxApi.chooseVariation(); + $rootScope.$apply(); + + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); + ga('create', window.env.GA_ID, {userId:User.user._id}); + ga('require', 'displayfeatures'); + ga('send', 'pageview'); + }) } // Scripts only for desktop @@ -71,11 +77,11 @@ function($scope, $rootScope, User, $http, Notification, ApiUrl) { 'stats.hp': 1 }); } - $scope.addMissedDay = function(){ - if (!confirm("Are you sure you want to reset the day?")) return; - var dayBefore = moment(User.user.lastCron).subtract(1, 'days').toDate(); + $scope.addMissedDay = function(numberOfDays){ + if (!confirm("Are you sure you want to reset the day by " + numberOfDays + " day(s)?")) return; + var dayBefore = moment(User.user.lastCron).subtract(numberOfDays, 'days').toDate(); User.set({'lastCron': dayBefore}); - Notification.text('-1 day, remember to refresh'); + Notification.text('-' + numberOfDays + ' day(s), remember to refresh'); } $scope.addTenGems = function(){ $http.post(ApiUrl.get() + '/api/v2/user/addTenGems').success(function(){ @@ -87,6 +93,11 @@ function($scope, $rootScope, User, $http, Notification, ApiUrl) { 'stats.gp': User.user.stats.gp + 500, }); } + $scope.addMana = function(){ + User.set({ + 'stats.mp': User.user.stats.mp + 500, + }); + } $scope.addLevelsAndGold = function(){ User.set({ 'stats.exp': User.user.stats.exp + 10000, diff --git a/website/public/js/controllers/groupsCtrl.js b/website/public/js/controllers/groupsCtrl.js index 3f27ecd82e..eaf23df4d3 100644 --- a/website/public/js/controllers/groupsCtrl.js +++ b/website/public/js/controllers/groupsCtrl.js @@ -16,88 +16,125 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } $scope.isMemberOfGroup = function(userid, group){ + + // If the group is a guild, just check for an intersection with the + // current user's guilds, rather than checking the members of the group. + if(group.type === 'guild') { + return _.detect(Groups.myGuilds(), function(g) { return g._id === group._id }); + } + + // Similarly, if we're dealing with the user's current party, return true. + if(group.type === 'party') { + var currentParty = Groups.party(); + if(currentParty._id && currentParty._id === group._id) return true; + } + if (!group.members) return false; var memberIds = _.map(group.members, function(x){return x._id}); return ~(memberIds.indexOf(userid)); } - $scope.isMember = function(user, group){ - return ~(group.members.indexOf(user._id)); + $scope.isMember = function(user, group){ + return ~(group.members.indexOf(user._id)); + } + + $scope.Members = Members; + $scope._editing = {group:false}; + + $scope.save = function(group){ + if(group._newLeader && group._newLeader._id) group.leader = group._newLeader._id; + group.$save(); + group._editing = false; + } + + $scope.deleteAllMessages = function() { + if (confirm(window.env.t('confirmDeleteAllMessages'))) { + User.user.ops.clearPMs({}); } + } - $scope.Members = Members; - $scope._editing = {group:false}; + // ------ Modals ------ - $scope.save = function(group){ - if(group._newLeader && group._newLeader._id) group.leader = group._newLeader._id; - group.$save(); - group._editing = false; - } - - // ------ Modals ------ - - $scope.clickMember = function(uid, forceShow) { - if (User.user._id == uid && !forceShow) { - if ($state.is('tasks')) { - $state.go('options.profile.avatar'); - } else { - $state.go('tasks'); - } + $scope.clickMember = function(uid, forceShow) { + if (User.user._id == uid && !forceShow) { + if ($state.is('tasks')) { + $state.go('options.profile.avatar'); } else { - // We need the member information up top here, but then we pass it down to the modal controller - // down below. Better way of handling this? - Members.selectMember(uid, function(){ - $rootScope.openModal('member', {controller:'MemberModalCtrl', windowClass:'profile-modal', size:'lg'}); - }); + $state.go('tasks'); } - } - - $scope.removeMember = function(group, member, isMember){ - var yes = confirm(window.env.t('sureKick')) - if(yes){ - Groups.Group.removeMember({gid: group._id, uuid: member._id }, undefined, function(){ - if(isMember){ - _.pull(group.members, member); - }else{ - _.pull(group.invites, member); - } - }); - } - } - - $scope.openInviteModal = function(group){ - $rootScope.openModal('invite-friends', {controller:'InviteToGroupCtrl', resolve: - {injectedGroup: function(){ - return group; - }}}); - }; - - //var serializeQs = function(obj, prefix){ - // var str = []; - // for(var p in obj) { - // if (obj.hasOwnProperty(p)) { - // var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p]; - // str.push(typeof v == "object" ? - // serializeQs(v, k) : - // encodeURIComponent(k) + "=" + encodeURIComponent(v)); - // } - // } - // return str.join("&"); - //} - // - //$scope.inviteLink = function(obj){ - // return window.env.BASE_URL + '?' + serializeQs({partyInvite: obj}); - //} - - $scope.quickReply = function(uid) { + } else { + // We need the member information up top here, but then we pass it down to the modal controller + // down below. Better way of handling this? Members.selectMember(uid, function(){ - $rootScope.openModal('private-message',{controller:'MemberModalCtrl'}); + $rootScope.openModal('member', {controller:'MemberModalCtrl', windowClass:'profile-modal', size:'lg'}); }); } } - ]) - .controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedGroup', '$http', 'Notification', function($scope, User, Groups, injectedGroup, $http, Notification){ + + $scope.removeMember = function(group, member, isMember){ + // TODO find a better way to do this (share data with remove member modal) + $scope.removeMemberData = { + group: group, + member: member, + isMember: isMember + }; + $rootScope.openModal('remove-member', {scope: $scope}); + } + + $scope.confirmRemoveMember = function(confirm){ + if(confirm){ + Groups.Group.removeMember({ + gid: $scope.removeMemberData.group._id, + uuid: $scope.removeMemberData.member._id, + message: $scope.removeMemberData.message, + }, undefined, function(){ + if($scope.removeMemberData.isMember){ + _.pull($scope.removeMemberData.group.members, $scope.removeMemberData.member); + }else{ + _.pull($scope.removeMemberData.group.invites, $scope.removeMemberData.member); + } + + $scope.removeMemberData = undefined; + }); + }else{ + $scope.removeMemberData = undefined; + } + } + + $scope.openInviteModal = function(group){ + $rootScope.openModal('invite-friends', {controller:'InviteToGroupCtrl', resolve: + {injectedGroup: function(){ + return group; + }}}); + }; + + //var serializeQs = function(obj, prefix){ + // var str = []; + // for(var p in obj) { + // if (obj.hasOwnProperty(p)) { + // var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p]; + // str.push(typeof v == "object" ? + // serializeQs(v, k) : + // encodeURIComponent(k) + "=" + encodeURIComponent(v)); + // } + // } + // return str.join("&"); + //} + // + //$scope.inviteLink = function(obj){ + // return window.env.BASE_URL + '?' + serializeQs({partyInvite: obj}); + //} + + $scope.quickReply = function(uid) { + Members.selectMember(uid, function(){ + $rootScope.openModal('private-message',{controller:'MemberModalCtrl'}); + }); + } + + }]) + + .controller('InviteToGroupCtrl', ['$scope', 'User', 'Groups', 'injectedGroup', '$http', 'Notification', function($scope, User, Groups, injectedGroup, $http, Notification){ $scope.group = injectedGroup; $scope.inviter = User.user.profile.name; @@ -122,8 +159,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' }; }]) - .controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', - function($scope, $rootScope, Members, Shared, $http, Notification, Groups) { + .controller("MemberModalCtrl", ['$scope', '$rootScope', 'Members', 'Shared', '$http', 'Notification', 'Groups', '$controller', + function($scope, $rootScope, Members, Shared, $http, Notification, Groups, $controller) { + + $controller('RootCtrl', {$scope: $scope}); + $scope.timestamp = function(timestamp){ return moment(timestamp).format($rootScope.User.user.preferences.dateFormat.toUpperCase()); } @@ -135,6 +175,9 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.profile = member; }); $scope.sendPrivateMessage = function(uuid, message){ + // Don't do anything if the user somehow gets here without a message. + if (!message) return; + $http.post('/api/v2/members/'+uuid+'/message',{message:message}).success(function(){ Notification.text(window.env.t('messageSentAlert')); $rootScope.User.sync(); @@ -159,14 +202,14 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' Groups.Group.flagChatMessage({gid: groupId, messageId: message.id}, undefined, function(data){ Notification.text(window.env.t('abuseReported')); $scope.$close(); - }); + }); } $scope.clearFlagCount = function(message, groupId) { Groups.Group.clearFlagCount({gid: groupId, messageId: message.id}, undefined, function(data){ message.flagCount = 0; Notification.text("Flags cleared"); $scope.$close(); - }); + }); } } ]) @@ -176,7 +219,24 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.response = []; $scope.usernames = []; } - + + $scope.filterUser = function(msg) { + if (!$scope.query || !msg.user) { + return false; + } + + // Ignore casing when checking for username + var user = msg.user.toLowerCase(); + var text = $scope.query.text.toLowerCase(); + + return user.indexOf(text) == 0; + } + + $scope.performCompletion = function(msg) { + $scope.autoComplete(msg); + $scope.query = null; + } + $scope.addNewUser = function(user) { if($.inArray(user.user,$scope.usernames) == -1) { user.username = user.user; @@ -184,9 +244,9 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.response.push(user); } } - + $scope.clearUserlist(); - + $scope.chatChanged = function(newvalue,oldvalue){ if($scope.group.chat && $scope.group.chat.length > 0){ for(var i = 0; i < $scope.group.chat.length; i++) { @@ -194,9 +254,9 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } } } - + $scope.$watch('group.chat',$scope.chatChanged); - + $scope.caretChanged = function(newCaretPos) { var relativeelement = $('.chat-form div:first'); var textarea = $('.chat-form textarea'); @@ -213,23 +273,23 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' }); } } - + $scope.updateTimer = false; - + $scope.$watch(function () { return $scope.caretPos; },function(newCaretPos) { if($scope.updateTimer){ $timeout.cancel($scope.updateTimer) - } + } $scope.updateTimer = $timeout(function(){ $scope.caretChanged(newCaretPos); },$scope.watchDelay) }); }]) - + .controller('ChatCtrl', ['$scope', 'Groups', 'User', '$http', 'ApiUrl', 'Notification', 'Members', '$rootScope', function($scope, Groups, User, $http, ApiUrl, Notification, Members, $rootScope){ $scope.message = {content:''}; $scope._sending = false; - + $scope.isUserMentioned = function(user, message) { if(message.hasOwnProperty("highlight")) return message.highlight; @@ -260,6 +320,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } $scope.message.content = ''; $scope._sending = false; + if (group.privacy == 'public'){ + mixpanel.track('Group Chat',{'groupType':group.type,'privacy':group.privacy,'groupName':group.name,'message':message}) + } else { + mixpanel.track('Group Chat',{'groupType':group.type,'privacy':group.privacy}) + } }, function(err){ $scope._sending = false; }); @@ -273,7 +338,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' if(data.chat) group.chat = data.chat; var i = _.findIndex(group.chat, {id: message.id}); - if(i !== -1) group.chat.splice(i, 1); + if(i !== -1) group.chat.splice(i, 1); }); } } @@ -295,7 +360,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.flagChatMessage = function(groupId,message) { if(!message.flags) message.flags = {}; - if(message.flags[User.user._id]) + if(message.flags[User.user._id]) Notification.text(window.env.t('abuseAlreadyReported')); else { $scope.abuseObject = message; @@ -307,10 +372,30 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' }); }); } - } + }; + + $scope.copyToDo = function(message) { + var taskNotes = env.t("messageWroteIn", { + user: message.uuid == 'system' + ? 'system' + : '[' + message.user + '](' + env.BASE_URL + '/static/front/#?memberId=' + message.uuid + ')', + group: '[' + $scope.group.name + '](' + window.location.href + ')' + }); + + var newScope = $scope.$new(); + newScope.text = message.text; + newScope.notes = taskNotes; + + $rootScope.openModal('copyChatToDo',{ + controller:'CopyMessageModalCtrl', + scope: newScope + }); + }; $scope.sync = function(group){ group.$get(); + //When the user clicks fetch recent messages we need to update that the user has seen the new messages + Groups.seenMessage(group._id); } // List of Ordering options for the party members list @@ -351,6 +436,8 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' if (confirm(window.env.t('confirmGuild'))) { group.$save(function(saved){ + if (saved.privacy == 'public') {mixpanel.track('Join Group',{'owner':true,'groupType':'guild','privacy':saved.privacy,'groupName':saved.name})} + else {mixpanel.track('Join Group',{'owner':true,'groupType':'guild','privacy':saved.privacy})} $rootScope.hardRedirect('/#/options/groups/guilds/' + saved._id); }); } @@ -365,6 +452,8 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } group.$join(function(joined){ + if (joined.privacy == 'public') {mixpanel.track('Join Group',{'owner':false,'groupType':'guild','privacy':joined.privacy,'groupName':joined.name})} + else {mixpanel.track('Join Group',{'owner':false,'groupType':'guild','privacy':joined.privacy})} $rootScope.hardRedirect('/#/options/groups/guilds/' + joined._id); }) } @@ -430,6 +519,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.create = function(group){ group.$save(function(){ + mixpanel.track('Join Group',{'owner':true,'groupType':'party','privacy':'private'}); $rootScope.hardRedirect('/#/options/groups/party'); }); } @@ -437,6 +527,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' $scope.join = function(party){ var group = new Groups.Group({_id: party.id, name: party.name}); group.$join(function(){ + mixpanel.track('Join Group',{'owner':false,'groupType':'party','privacy':'private'}); $rootScope.hardRedirect('/#/options/groups/party'); }); } @@ -510,3 +601,20 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', ' } } ]) + + .controller("CopyMessageModalCtrl", ['$scope', 'User', 'Notification', + function($scope, User, Notification){ + $scope.saveTodo = function() { + var newTask = { + text: $scope.text, + type: 'todo', + notes: $scope.notes + }; + + User.user.ops.addTask({body:newTask}); + Notification.text(window.env.t('messageAddedAsToDo')); + + $scope.$close(); + } + } + ]); diff --git a/website/public/js/controllers/hallCtrl.js b/website/public/js/controllers/hallCtrl.js index 6956bfedd5..fe385a316c 100644 --- a/website/public/js/controllers/hallCtrl.js +++ b/website/public/js/controllers/hallCtrl.js @@ -17,6 +17,12 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica }) } $scope.heroes = Hero.query(); + + $scope.populateContributorInput = function(id) { + $scope._heroID = id; + window.scrollTo(0,200); + $scope.loadHero(id); + }; }]); habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource', diff --git a/website/public/js/controllers/headerCtrl.js b/website/public/js/controllers/headerCtrl.js index ada83f24c2..89db3dc18c 100644 --- a/website/public/js/controllers/headerCtrl.js +++ b/website/public/js/controllers/headerCtrl.js @@ -1,12 +1,36 @@ "use strict"; -habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User', - function($scope, Groups, User) { +habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User', '$location', '$rootScope', + function($scope, Groups, User, $location, $rootScope) { $scope.Math = window.Math; + $scope.user = User.user; $scope.party = Groups.party(function(){ - $scope.partyMinusSelf = _.sortBy( + var triggerResort = function() { + $scope.partyMinusSelf = resortParty(); + }; + + triggerResort(); + $scope.$watch('user.party.order', triggerResort); + $scope.$watch('user.party.orderAscending', triggerResort); + }); + + $scope.inviteOrStartParty = function(group) { + if (group.type === "party") { + $rootScope.openModal('invite-friends', { + controller:'InviteToGroupCtrl', + resolve: { + injectedGroup: function(){ return group; } + } + }); + } else { + $location.path("/options/groups/party"); + } + } + + function resortParty() { + var result = _.sortBy( _.filter($scope.party.members, function(member){ return member._id !== User.user._id; }), @@ -41,8 +65,10 @@ habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User', } ) if (User.user.party.orderAscending == "descending") { - $scope.partyMinusSelf = $scope.partyMinusSelf.reverse() + result = result.reverse() } - }); + + return result; + } } ]); diff --git a/website/public/js/controllers/inventoryCtrl.js b/website/public/js/controllers/inventoryCtrl.js index 219c8618e0..deae46e618 100644 --- a/website/public/js/controllers/inventoryCtrl.js +++ b/website/public/js/controllers/inventoryCtrl.js @@ -1,4 +1,4 @@ -habitrpg.controller("InventoryCtrl", +habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', 'Shared', '$window', 'User', 'Content', function($rootScope, $scope, Shared, $window, User, Content) { @@ -88,7 +88,7 @@ habitrpg.controller("InventoryCtrl", $rootScope.petCount = Shared.countPets($rootScope.countExists(User.user.items.pets), User.user.items.pets); // Checks if beastmaster has been reached for the first time - if(!User.user.achievements.beastMaster + if(!User.user.achievements.beastMaster && $rootScope.petCount >= 90) { User.user.achievements.beastMaster = true; $rootScope.openModal('achievements/beastMaster'); @@ -103,26 +103,6 @@ habitrpg.controller("InventoryCtrl", } } - $scope.purchase = function(type, item){ - if (type == 'special') return User.user.ops.buySpecialSpell({params:{key:item.key}}); - - var gems = User.user.balance * 4; - - var string = (type == 'weapon') ? window.env.t('weapon') : (type == 'armor') ? window.env.t('armor') : (type == 'head') ? window.env.t('headgear') : (type == 'shield') ? window.env.t('offhand') : (type == 'hatchingPotions') ? window.env.t('hatchingPotion') : (type == 'eggs') ? window.env.t('eggSingular') : (type == 'quests') ? window.env.t('quest') : (item.key == 'Saddle') ? window.env.t('foodSaddleText').toLowerCase() : type; // this is ugly but temporary, once the purchase modal is done this will be removed - if (type == 'weapon' || type == 'armor' || type == 'head' || type == 'shield') { - if (gems < ((item.specialClass == "wizard") && (item.type == "weapon")) + 1) return $rootScope.openModal('buyGems'); - var message = window.env.t('buyThis', {text: string, price: ((item.specialClass == "wizard") && (item.type == "weapon")) + 1, gems: gems}) - if($window.confirm(message)) - User.user.ops.purchase({params:{type:"gear",key:item.key}}); - } else { - if(gems < item.value) return $rootScope.openModal('buyGems'); - var message = window.env.t('buyThis', {text: string, price: item.value, gems: gems}) - if($window.confirm(message)) - User.user.ops.purchase({params:{type:type,key:item.key}}); - } - - } - $scope.choosePet = function(egg, potion){ var petDisplayName = env.t('petName', { potion: Content.hatchingPotions[potion] ? Content.hatchingPotions[potion].text() : potion, @@ -143,7 +123,7 @@ habitrpg.controller("InventoryCtrl", $rootScope.mountCount = Shared.countMounts($rootScope.countExists(User.user.items.mounts), User.user.items.mounts); // Checks if mountmaster has been reached for the first time - if(!User.user.achievements.mountMaster + if(!User.user.achievements.mountMaster && $rootScope.mountCount >= 90) { User.user.achievements.mountMaster = true; $rootScope.openModal('achievements/mountMaster'); @@ -200,6 +180,7 @@ habitrpg.controller("InventoryCtrl", $rootScope.selectedQuest = undefined; } $scope.questInit = function(){ + mixpanel.track("Quest",{"owner":true,"response":"accept","questName":$scope.selectedQuest.key}); $rootScope.party.$questAccept({key:$scope.selectedQuest.key}, function(){ $rootScope.party.$get(); }); @@ -215,23 +196,63 @@ habitrpg.controller("InventoryCtrl", $rootScope.selectedQuest = item; $rootScope.openModal('buyQuest', {controller:'InventoryCtrl'}); } - + $scope.getSeasonalShopArray = function(set){ var flatGearArray = _.toArray(Content.gear.flat); - + var filteredArray = _.where(flatGearArray, {index: set}); return filteredArray; }; - + $scope.getSeasonalShopQuests = function(set){ var questArray = _.toArray(Content.quests); - + var filteredArray = _.filter(questArray, function(q){ - return q.key == "evilsanta" || q.key == "evilsanta2"; + return q.key == "egg"; }); return filteredArray; }; + + $scope.dequip = function(itemSet){ + switch (itemSet) { + case "battleGear": + for (item in user.items.gear.equipped){ + var itemKey = user.items.gear.equipped[item]; + if (user.items.gear.owned[itemKey]) { + user.ops.equip({params: {key: itemKey}}); + } + } + break; + + case "costume": + for (item in user.items.gear.costume){ + var itemKey = user.items.gear.costume[item]; + if (user.items.gear.owned[itemKey]) { + user.ops.equip({params: {type:"costume", key: itemKey}}); + } + } + break; + + case "petMountBackground": + var pet = user.items.currentPet; + if (pet) { + user.ops.equip({params:{type: 'pet', key: pet}}); + } + + var mount = user.items.currentMount; + if (mount) { + user.ops.equip({params:{type: 'mount', key: mount}}); + } + + var background = user.preferences.background; + if (background) { + User.user.ops.unlock({query:{path:"background."+background}}); + } + + break; + } + }; } ]); diff --git a/website/public/js/controllers/notificationCtrl.js b/website/public/js/controllers/notificationCtrl.js index 6c30b511c2..578654afb0 100644 --- a/website/public/js/controllers/notificationCtrl.js +++ b/website/public/js/controllers/notificationCtrl.js @@ -73,20 +73,21 @@ habitrpg.controller('NotificationCtrl', if(after.type === 'HatchingPotion'){ var text = Content.hatchingPotions[after.key].text(); var notes = Content.hatchingPotions[after.key].notes(); - Notification.drop(env.t('messageDropPotion', {dropText: text, dropNotes: notes})); + Notification.drop(env.t('messageDropPotion', {dropText: text, dropNotes: notes}), after); }else if(after.type === 'Egg'){ var text = Content.eggs[after.key].text(); var notes = Content.eggs[after.key].notes(); - Notification.drop(env.t('messageDropEgg', {dropText: text, dropNotes: notes})); + Notification.drop(env.t('messageDropEgg', {dropText: text, dropNotes: notes}), after); }else if(after.type === 'Food'){ var text = Content.food[after.key].text(); var notes = Content.food[after.key].notes(); - Notification.drop(env.t('messageDropFood', {dropArticle: after.article, dropText: text, dropNotes: notes})); + Notification.drop(env.t('messageDropFood', {dropArticle: after.article, dropText: text, dropNotes: notes}), after); }else{ // Keep support for another type of drops that might be added Notification.drop(User.user._tmp.drop.dialog); } $rootScope.playSound('Item_Drop'); + mixpanel.track("Acquire Item",{'itemName':after.key,'acquireMethod':'Drop'}) }); $rootScope.$watch('user.achievements.streak', function(after, before){ @@ -100,9 +101,14 @@ habitrpg.controller('NotificationCtrl', } }); - $rootScope.$watch('user.achievements.ultimateGear', function(after, before){ - if (after === before || after !== true) return; + $rootScope.$watch('user.achievements.ultimateGearSets', function(after, before){ + if (_.isEqual(after,before) || !_.contains(User.user.achievements.ultimateGearSets, true)) return; $rootScope.openModal('achievements/ultimateGear'); + }, true); + + $rootScope.$watch('user.flags.armoireEmpty', function(after,before){ + if (before == undefined || after == before || after == false) return; + $rootScope.openModal('armoireEmpty'); }); $rootScope.$watch('user.achievements.rebirths', function(after, before){ diff --git a/website/public/js/controllers/rootCtrl.js b/website/public/js/controllers/rootCtrl.js index ebf38b9515..53e802a0b7 100644 --- a/website/public/js/controllers/rootCtrl.js +++ b/website/public/js/controllers/rootCtrl.js @@ -3,8 +3,8 @@ /* Make user and settings available for everyone through root scope. */ -habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments', - function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments) { +habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$http', '$state', '$stateParams', 'Notification', 'Groups', 'Shared', 'Content', '$modal', '$timeout', 'ApiUrl', 'Payments','$sce','$window', + function($scope, $rootScope, $location, User, $http, $state, $stateParams, Notification, Groups, Shared, Content, $modal, $timeout, ApiUrl, Payments, $sce, $window) { var user = User.user; var initSticky = _.once(function(){ @@ -105,11 +105,29 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ $rootScope.set = User.set; $rootScope.authenticated = User.authenticated; + var forceLoadBailey = function(template, options) { + $http.get('/new-stuff.html') + .success(function(data) { + $rootScope.latestBaileyMessage = $sce.trustAsHtml(data); + $modal.open({ + templateUrl: 'modals/' + template + '.html', + controller: options.controller, // optional + scope: options.scope, // optional + resolve: options.resolve, // optional + keyboard: (options.keyboard === undefined ? true : options.keyboard), // optional + backdrop: (options.backdrop === undefined ? true : options.backdrop), // optional + size: options.size, // optional, 'sm' or 'lg' + windowClass: options.windowClass // optional + }); + }); + }; + // Open a modal from a template expression (like ng-click,...) // Otherwise use the proper $modal.open $rootScope.openModal = function(template, options){//controller, scope, keyboard, backdrop){ if (!options) options = {}; if (options.track) window.ga && ga('send', 'event', 'button', 'click', options.track); + if(template === 'newStuff') return forceLoadBailey(template, options); return $modal.open({ templateUrl: 'modals/' + template + '.html', controller: options.controller, // optional @@ -183,7 +201,40 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ chart.draw(data, options); }; + $rootScope.getGearArray = function(set){ + var flatGearArray = _.toArray(Content.gear.flat); + var filteredArray = _.where(flatGearArray, {gearSet: set}); + + return filteredArray; + } + + $rootScope.purchase = function(type, item){ + if (type == 'special') return User.user.ops.buySpecialSpell({params:{key:item.key}}); + + var gems = User.user.balance * 4; + + var string = (type == 'weapon') ? window.env.t('weapon') : (type == 'armor') ? window.env.t('armor') : (type == 'head') ? window.env.t('headgear') : (type == 'shield') ? window.env.t('offhand') : (type == 'headAccessory') ? window.env.t('headAccessory') : (type == 'hatchingPotions') ? window.env.t('hatchingPotion') : (type == 'eggs') ? window.env.t('eggSingular') : (type == 'quests') ? window.env.t('quest') : (item.key == 'Saddle') ? window.env.t('foodSaddleText').toLowerCase() : type; // FIXME this is ugly but temporary, once the purchase modal is done this will be removed + var price = ((((item.specialClass == "wizard") && (item.type == "weapon")) || item.gearSet == "animal") + 1); + if (type == 'weapon' || type == 'armor' || type == 'head' || type == 'shield' || type == 'headAccessory') { + if (User.user.items.gear.owned[item.key]) { + if (User.user.preferences.costume) return User.user.ops.equip({params:{type: 'costume', key: item.key}}); + else { + return User.user.ops.equip({params:{type: 'equipped', key: item.key}}) + } + } + if (gems < price) return $rootScope.openModal('buyGems'); + var message = window.env.t('buyThis', {text: string, price: price, gems: gems}) + if($window.confirm(message)) + User.user.ops.purchase({params:{type:"gear",key:item.key}}); + } else { + if(gems < item.value) return $rootScope.openModal('buyGems'); + var message = window.env.t('buyThis', {text: string, price: item.value, gems: gems}) + if($window.confirm(message)) + User.user.ops.purchase({params:{type:type,key:item.key}}); + } + + } /* ------------------------ @@ -208,7 +259,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ } $scope.castEnd = function(target, type, $event){ - if (!$rootScope.applyingAction) return; + if (!$rootScope.applyingAction) return 'No applying action'; $event && ($event.stopPropagation(),$event.preventDefault()); if ($scope.spell.target != type) return Notification.text(window.env.t('invalidTarget')); $scope.spell.cast(User.user, target); @@ -220,16 +271,16 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ $rootScope.applyingAction = false; $http.post(ApiUrl.get() + '/api/v2/user/class/cast/'+spell.key+'?targetType='+type+'&targetId='+targetId) - .success(function(){ - var msg = window.env.t('youCast', {spell: spell.text()}); - switch (type) { - case 'task': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.text});break; - case 'user': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.profile.name});break; - case 'party': msg = window.env.t('youCastParty', {spell: spell.text()});break; - } - Notification.text(msg); - }); - + .success(function(){ + var msg = window.env.t('youCast', {spell: spell.text()}); + switch (type) { + case 'task': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.text});break; + case 'user': msg = window.env.t('youCastTarget', {spell: spell.text(), target: target.profile.name});break; + case 'party': msg = window.env.t('youCastParty', {spell: spell.text()});break; + } + Notification.markdown(msg); + User.sync(); + }); } $rootScope.castCancel = function(){ @@ -241,7 +292,9 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ // reload the page. Perform manually. $rootScope.hardRedirect = function(url){ window.location.href = url; - window.location.reload(false); + setTimeout(function() { + window.location.reload(false); + }); } // Universal method for sending HTTP methods diff --git a/website/public/js/controllers/settingsCtrl.js b/website/public/js/controllers/settingsCtrl.js index df960db39c..5c83b5756c 100644 --- a/website/public/js/controllers/settingsCtrl.js +++ b/website/public/js/controllers/settingsCtrl.js @@ -20,7 +20,7 @@ habitrpg.controller('SettingsCtrl', var mapPrefToEmailString = { 'importantAnnouncements': 'inactivityEmails' }; - + // If ?unsubFrom param is passed with valid email type, // automatically unsubscribe users from that email and // show an alert @@ -34,7 +34,7 @@ habitrpg.controller('SettingsCtrl', Notification.text(env.t('correctlyUnsubscribedEmailType', {emailType: emailTypeString})); $location.search({}); } - }, 500); + }, 1000); $scope.hideHeader = function(){ User.set({"preferences.hideHeader":!User.user.preferences.hideHeader}) @@ -42,7 +42,7 @@ habitrpg.controller('SettingsCtrl', User.set({"preferences.stickyHeader":false}); $rootScope.$on('userSynced', function(){ window.location.reload(); - }); + }); } } @@ -55,12 +55,11 @@ habitrpg.controller('SettingsCtrl', $scope.showTour = function(){ User.set({'flags.showTour':true}); - $location.path('/tasks'); - $timeout(Guide.initTour); + Guide.goto('intro', 0, true); } $scope.showClassesTour = function(){ - Guide.classesTour(); + Guide.goto('classes', 0, true); } $scope.showBailey = function(){ @@ -145,7 +144,7 @@ habitrpg.controller('SettingsCtrl', $http.post(ApiUrl.get() + '/api/v2/user/coupon/' + code).success(function(res,code){ if (code!==200) return; User.sync(); - Notification.text('Coupon applied! Check your inventory'); + Notification.text(env.t('promoCodeApplied')); }); } $scope.generateCodes = function(codes){ diff --git a/website/public/js/controllers/tasksCtrl.js b/website/public/js/controllers/tasksCtrl.js index 7294d5c2f7..3bb0df8c31 100644 --- a/website/public/js/controllers/tasksCtrl.js +++ b/website/public/js/controllers/tasksCtrl.js @@ -1,9 +1,12 @@ "use strict"; -habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','Notification', '$http', 'ApiUrl', '$timeout', 'Shared', - function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Shared) { +habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','Notification', '$http', 'ApiUrl', '$timeout', 'Shared', 'Guide', + function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Shared, Guide) { $scope.obj = User.user; // used for task-lists $scope.user = User.user; + $scope.armoireCount = function(gear) { + return Shared.countArmoire(gear); + }; $scope.score = function(task, direction) { switch (task.type) { @@ -20,7 +23,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N if (direction === 'down') $rootScope.playSound('Minus_Habit'); else if (direction === 'up') $rootScope.playSound('Plus_Habit'); } - User.user.ops.score({params:{id: task.id, direction:direction}}) + User.user.ops.score({params:{id: task.id, direction:direction}}); + mixpanel.register({'Gold':Math.floor(User.user.stats.gp),'Health':Math.ceil(User.user.stats.hp),'Experience':Math.floor(User.user.stats.exp),'Level':User.user.stats.lvl,'Mana':Math.floor(User.user.stats.mp),'Class':User.user.stats.class,'subscription':User.user.purchased.plan.planId,'contributorLevel':User.user.contributor.level,'UUID':User.user._id}); + mixpanel.track('Score Task',{'taskType':task.type,'direction':direction}); }; function addTask(addTo, listDef, task) { @@ -37,6 +42,8 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N $scope.addTask = function(addTo, listDef) { if (listDef.bulk) { var tasks = listDef.newTask.split(/[\n\r]+/); + //Reverse the order of tasks so the tasks will appear in the order the user entered them + tasks.reverse(); _.each(tasks, function(t) { addTask(addTo, listDef, t); }); @@ -46,6 +53,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N } delete listDef.newTask; delete listDef.focus; + if (listDef.type=='daily') Guide.goto('intro', 2); }; $scope.toggleBulk = function(list) { @@ -80,9 +88,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N } }; - $scope.removeTask = function(list, $index) { + $scope.removeTask = function(task) { if (!confirm(window.env.t('sureDelete'))) return; - User.user.ops.deleteTask({params:{id:list[$index].id}}) + User.user.ops.deleteTask({params:{id:task.id}}) }; $scope.saveTask = function(task, stayOpen, isSaveAndClose) { @@ -92,6 +100,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N if (!stayOpen) task._editing = false; if (isSaveAndClose) $("#task-" + task.id).parent().children('.popover').removeClass('in'); + if (task.type == 'habit') Guide.goto('intro', 3); }; /** @@ -163,7 +172,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N focusChecklist(task,$index-1); // Don't allow the backspace key to navigate back now that the field is gone $event.preventDefault(); - } + } } $scope.swapChecklistItems = function(task, oldIndex, newIndex) { var toSwap = task.checklist.splice(oldIndex, 1)[0]; @@ -183,37 +192,21 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N /* ------------------------ - Items + Items ------------------------ */ - $scope.$watch('user.items.gear.equipped', function(){ + $scope.$watchGroup(['user.items.gear.owned', 'user.flags.armoireEnabled'], function(){ $scope.itemStore = Shared.updateStore(User.user); },true); $scope.buy = function(item) { User.user.ops.buy({params:{key:item.key}}); $rootScope.playSound('Reward'); + Guide.goto('intro', 4); }; - /* - ------------------------ - Ads - ------------------------ - */ - - /** - * See conversation on http://productforums.google.com/forum/#!topic/adsense/WYkC_VzKwbA, - * Adsense is very sensitive. It must be called once-and-only-once for every , else things break. - * Additionally, angular won't run javascript embedded into a script template, so we can't copy/paste - * the html provided by adsense - we need to run this function post-link - */ - $scope.initAds = function(){ - $.getScript('//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'); - (window.adsbygoogle = window.adsbygoogle || []).push({}); - } - /* ------------------------ Hiding Tasks diff --git a/website/public/js/controllers/userCtrl.js b/website/public/js/controllers/userCtrl.js index cf5336f4c7..81c1958953 100644 --- a/website/public/js/controllers/userCtrl.js +++ b/website/public/js/controllers/userCtrl.js @@ -27,8 +27,7 @@ habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$ User.user.ops.changeClass({query:{class:klass}}); $scope.selectedClass = undefined; Shared.updateStore(User.user); - $state.go('options.profile.stats'); - window.setTimeout(Guide.classesTour, 10); + Guide.goto('classes', 0,true); } $scope.save = function(){ diff --git a/website/public/js/directives/directives.js b/website/public/js/directives/directives.js deleted file mode 100644 index d1543e348f..0000000000 --- a/website/public/js/directives/directives.js +++ /dev/null @@ -1,195 +0,0 @@ -'use strict'; - -/** - * Directive that places focus on the element it is applied to when the expression it binds to evaluates to true. - */ -habitrpg.directive('taskFocus', - ['$timeout', - function($timeout) { - return function(scope, elem, attrs) { - scope.$watch(attrs.taskFocus, function(newval) { - if ( newval ) { - $timeout(function() { - elem[0].focus(); - }, 0, false); - } - }); - }; - } -]); - -habitrpg.directive('habitrpgAdsense', function() { - return { - restrict: 'A', - transclude: true, - replace: true, - template: '
', - link: function ($scope, element, attrs) {} - } -}); - -habitrpg.directive('whenScrolled', function() { - return function(scope, elm, attr) { - var raw = elm[0]; - - elm.bind('scroll', function() { - if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) { - scope.$apply(attr.whenScrolled); - } - }); - }; -}); - -habitrpg - .directive('habitrpgTasks', ['$rootScope', 'User', function($rootScope, User) { - return { - restrict: 'EA', - templateUrl: 'templates/habitrpg-tasks.html', - //transclude: true, - //scope: { - // main: '@', // true if it's the user's main list - // obj: '=' - //}, - controller: ['$scope', '$rootScope', function($scope, $rootScope){ - $scope.editTask = function(task){ - task._editing = !task._editing; - task._tags = User.user.preferences.tagsCollapsed; - task._advanced = User.user.preferences.advancedCollapsed; - if($rootScope.charts[task.id]) $rootScope.charts[task.id] = false; - }; - }], - link: function(scope, element, attrs) { - // $scope.obj needs to come from controllers, so we can pass by ref - scope.main = attrs.main; - scope.modal = attrs.modal; - var dailiesView; - if(User.user.preferences.dailyDueDefaultView) { - dailiesView = "remaining"; - } else { - dailiesView = "all"; - } - $rootScope.lists = [ - { - header: window.env.t('habits'), - type: 'habit', - placeHolder: window.env.t('newHabit'), - placeHolderBulk: window.env.t('newHabitBulk'), - view: "all" - }, { - header: window.env.t('dailies'), - type: 'daily', - placeHolder: window.env.t('newDaily'), - placeHolderBulk: window.env.t('newDailyBulk'), - view: dailiesView - }, { - header: window.env.t('todos'), - type: 'todo', - placeHolder: window.env.t('newTodo'), - placeHolderBulk: window.env.t('newTodoBulk'), - view: "remaining" - }, { - header: window.env.t('rewards'), - type: 'reward', - placeHolder: window.env.t('newReward'), - placeHolderBulk: window.env.t('newRewardBulk'), - view: "all" - } - ]; - - } - } - }]); - -habitrpg.directive('fromNow', ['$interval', function($interval){ - return function(scope, element, attr){ - var updateText = function(){ element.text(moment(scope.message.timestamp).fromNow()) }; - updateText(); - // Update the counter every 60secs if was sent less than one hour ago otherwise every hour - // OPTIMIZATION, every time the interval is run, update the interval time - var intervalTime = moment().diff(scope.message.timestamp, 'minute') < 60 ? 60000 : 3600000; - var interval = $interval(function(){ updateText() }, intervalTime, false); - scope.$on('$destroy', function() { - $interval.cancel(interval); - }); - } -}]); - -habitrpg.directive('hrpgSortTasks', ['User', function(User) { - return function($scope, element, attrs, ngModel) { - $(element).sortable({ - axis: "y", - distance: 5, - start: function (event, ui) { - ui.item.data('startIndex', ui.item.index()); - }, - stop: function (event, ui) { - var task = angular.element(ui.item[0]).scope().task, - startIndex = ui.item.data('startIndex'); - User.user.ops.sortTask({ params: {id: task.id}, query: {from: startIndex, to: ui.item.index()} }); - } - }); - } -}]); - -habitrpg.directive('hrpgSortChecklist', ['User', function(User) { - return function($scope, element, attrs, ngModel) { - $(element).sortable({ - axis: "y", - distance: 5, - start: function (event, ui) { - ui.item.data('startIndex', ui.item.index()); - }, - stop: function (event, ui) { - var task = angular.element(ui.item[0]).scope().task, - startIndex = ui.item.data('startIndex'); - //$scope.saveTask(task, true); - $scope.swapChecklistItems(task, startIndex, ui.item.index()); - } - }); - } -}]); - -habitrpg.directive('hrpgSortTags', ['User', function(User) { - return function($scope, element, attrs, ngModel) { - $(element).sortable({ - axis: "x", - start: function (event, ui) { - ui.item.data('startIndex', ui.item.index()); - }, - stop: function (event, ui) { - User.user.ops.sortTag({query:{ from: ui.item.data('startIndex'), to:ui.item.index() }}); - } - }); - } -}]); - -habitrpg - .directive( 'popoverHtmlPopup', ['$sce', function($sce) { - return { - restrict: 'EA', - replace: true, - scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' }, - link: function(scope, element, attrs) { - scope.$watch('content', function(value, oldValue) { - scope.unsafeContent = $sce.trustAsHtml(scope.content); - }); - }, - templateUrl: 'template/popover/popover-html.html' - }; - }]) - .directive( 'popoverHtml', [ '$compile', '$timeout', '$parse', '$window', '$tooltip', - function ( $compile, $timeout, $parse, $window, $tooltip ) { - return $tooltip( 'popoverHtml', 'popover', 'click' ); - } - ]) - .run(["$templateCache", function($templateCache) { - $templateCache.put("template/popover/popover-html.html", - "
\n" + - "
\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - "
\n" + - "
\n"); - }]); diff --git a/website/public/js/directives/focus-me.directive.js b/website/public/js/directives/focus-me.directive.js new file mode 100644 index 0000000000..e2fd96657c --- /dev/null +++ b/website/public/js/directives/focus-me.directive.js @@ -0,0 +1,23 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('focusMe', focusMe); + +focusMe.$inject = [ + '$timeout', + '$parse' +]; + +function focusMe($timeout, $parse) { + return { + link: function(scope, element, attrs) { + var model = $parse(attrs.focusMe); + scope.$watch(model, function(value) { + $timeout(function() { + element[0].focus(); + }); + }); + } + } +} diff --git a/website/public/js/directives/from-now.directive.js b/website/public/js/directives/from-now.directive.js new file mode 100644 index 0000000000..37b61a2b90 --- /dev/null +++ b/website/public/js/directives/from-now.directive.js @@ -0,0 +1,44 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('fromNow', fromNow); + +fromNow.$inject = [ + '$interval', + '$timeout' +]; + +function fromNow($interval, $timeout) { + return function(scope, element, attr){ + var interval, timeout; + + var updateText = function(){ + element.text(moment(scope.message.timestamp).fromNow()); + }; + + var setupInterval = function() { + if(interval) $interval.cancel(interval); + if(timeout) $timeout.cancel(timeout); + + var diff = moment().diff(scope.message.timestamp, 'minute'); + + if(diff < 60) { + // Update every minute + interval = $interval(updateText, 60000, false); + timeout = $timeout(setupInterval, diff * 60000); + } else { + // Update every hour + interval = $interval(updateText, 3600000, false); + } + }; + + updateText(); + setupInterval(); + + scope.$on('$destroy', function() { + if(interval) $interval.cancel(interval); + if(timeout) $timeout.cancel(timeout); + }); + } +} diff --git a/website/public/js/directives/habitrpg-tasks.directive.js b/website/public/js/directives/habitrpg-tasks.directive.js new file mode 100644 index 0000000000..1ec1a5b93a --- /dev/null +++ b/website/public/js/directives/habitrpg-tasks.directive.js @@ -0,0 +1,69 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('habitrpgTasks', habitrpgTasks); + +habitrpgTasks.$inject = [ + '$rootScope', + 'User' +]; + +function habitrpgTasks($rootScope, User) { + return { + restrict: 'EA', + templateUrl: 'templates/habitrpg-tasks.html', + //transclude: true, + //scope: { + // main: '@', // true if it's the user's main list + // obj: '=' + //}, + controller: ['$scope', '$rootScope', function($scope, $rootScope){ + $scope.editTask = function(task){ + task._editing = !task._editing; + task._tags = User.user.preferences.tagsCollapsed; + task._advanced = User.user.preferences.advancedCollapsed; + if($rootScope.charts[task.id]) $rootScope.charts[task.id] = false; + }; + }], + link: function(scope, element, attrs) { + // $scope.obj needs to come from controllers, so we can pass by ref + scope.main = attrs.main; + scope.modal = attrs.modal; + var dailiesView; + if(User.user.preferences.dailyDueDefaultView) { + dailiesView = "remaining"; + } else { + dailiesView = "all"; + } + $rootScope.lists = [ + { + header: window.env.t('habits'), + type: 'habit', + placeHolder: window.env.t('newHabit'), + placeHolderBulk: window.env.t('newHabitBulk'), + view: "all" + }, { + header: window.env.t('dailies'), + type: 'daily', + placeHolder: window.env.t('newDaily'), + placeHolderBulk: window.env.t('newDailyBulk'), + view: dailiesView + }, { + header: window.env.t('todos'), + type: 'todo', + placeHolder: window.env.t('newTodo'), + placeHolderBulk: window.env.t('newTodoBulk'), + view: "remaining" + }, { + header: window.env.t('rewards'), + type: 'reward', + placeHolder: window.env.t('newReward'), + placeHolderBulk: window.env.t('newRewardBulk'), + view: "all" + } + ]; + + } + } +} diff --git a/website/public/js/directives/hrpg-sort-checklist.directive.js b/website/public/js/directives/hrpg-sort-checklist.directive.js new file mode 100644 index 0000000000..52211e8cd4 --- /dev/null +++ b/website/public/js/directives/hrpg-sort-checklist.directive.js @@ -0,0 +1,30 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('hrpgSortChecklist', hrpgSortChecklist); + +hrpgSortChecklist.$inject = [ + 'User' +]; + +function hrpgSortChecklist(User) { + return function($scope, element, attrs, ngModel) { + $(element).sortable({ + axis: "y", + distance: 5, + start: function (event, ui) { + ui.item.data('startIndex', ui.item.index()); + }, + stop: function (event, ui) { + var task = angular.element(ui.item[0]).scope().task; + var startIndex = ui.item.data('startIndex'); + $scope.swapChecklistItems( + task, + startIndex, + ui.item.index() + ); + } + }); + } +} diff --git a/website/public/js/directives/hrpg-sort-tags.directive.js b/website/public/js/directives/hrpg-sort-tags.directive.js new file mode 100644 index 0000000000..3eac5fe0a6 --- /dev/null +++ b/website/public/js/directives/hrpg-sort-tags.directive.js @@ -0,0 +1,27 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('hrpgSortTags', hrpgSortTags); + +hrpgSortTags.$inject = [ + 'User' +]; + +function hrpgSortTags(User) { + return function($scope, element, attrs, ngModel) { + $(element).sortable({ + start: function (event, ui) { + ui.item.data('startIndex', ui.item.index()); + }, + stop: function (event, ui) { + User.user.ops.sortTag({ + query: { + from: ui.item.data('startIndex'), + to:ui.item.index() + } + }); + } + }); + } +} diff --git a/website/public/js/directives/hrpg-sort-tasks.directive.js b/website/public/js/directives/hrpg-sort-tasks.directive.js new file mode 100644 index 0000000000..0e18091cf2 --- /dev/null +++ b/website/public/js/directives/hrpg-sort-tasks.directive.js @@ -0,0 +1,32 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('hrpgSortTasks', hrpgSortTasks); + +hrpgSortTasks.$inject = [ + 'User' +]; + +function hrpgSortTasks(User) { + return function($scope, element, attrs, ngModel) { + $(element).sortable({ + axis: "y", + distance: 5, + start: function (event, ui) { + ui.item.data('startIndex', ui.item.index()); + }, + stop: function (event, ui) { + var task = angular.element(ui.item[0]).scope().task; + var startIndex = ui.item.data('startIndex'); + User.user.ops.sortTask({ + params: { id: task.id }, + query: { + from: startIndex, + to: ui.item.index() + } + }); + } + }); + } +} diff --git a/website/public/js/directives/popover-html-popup.directive.js b/website/public/js/directives/popover-html-popup.directive.js new file mode 100644 index 0000000000..555a7019d1 --- /dev/null +++ b/website/public/js/directives/popover-html-popup.directive.js @@ -0,0 +1,45 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('popoverHtmlPopup', popoverHtmlPopup) + .run(loadPopupTemplate); + +popoverHtmlPopup.$inject = [ + '$sce' +]; + +function popoverHtmlPopup($sce) { + return { + restrict: 'EA', + replace: true, + scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' }, + link: function(scope, element, attrs) { + scope.$watch('content', function(value, oldValue) { + scope.unsafeContent = $sce.trustAsHtml(scope.content); + }); + }, + templateUrl: 'template/popover/popover-html.html' + }; +} + +/* + * TODO: Review whether it's appropriate to be seeding this into the + * templateCache like this. Feel like this might be an antipattern? + */ + +loadPopupTemplate.$inject = [ + '$templateCache' +]; + +function loadPopupTemplate($templateCache) { + $templateCache.put("template/popover/popover-html.html", + "
\n" + + "
\n" + + "\n" + + "
\n" + + "

\n" + + "
\n" + + "
\n" + + "
\n"); +} diff --git a/website/public/js/directives/popover-html.directive.js b/website/public/js/directives/popover-html.directive.js new file mode 100644 index 0000000000..0462d99a31 --- /dev/null +++ b/website/public/js/directives/popover-html.directive.js @@ -0,0 +1,17 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('popoverHtml', popoverHtml); + +popoverHtml.$inject = [ + '$compile', + '$timeout', + '$parse', + '$window', + '$tooltip' +]; + +function popoverHtml($compile, $timeout, $parse, $window, $tooltip) { + return $tooltip('popoverHtml', 'popover', 'click'); +} diff --git a/website/public/js/directives/task-focus.directive.js b/website/public/js/directives/task-focus.directive.js new file mode 100644 index 0000000000..391e42b7fe --- /dev/null +++ b/website/public/js/directives/task-focus.directive.js @@ -0,0 +1,24 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('taskFocus', taskFocus); + +taskFocus.$inject = ['$timeout']; + +/** + * Directive that places focus on the element it is applied to when the + * expression it binds to evaluates to true. + */ + +function taskFocus($timeout) { + return function(scope, elem, attrs) { + scope.$watch(attrs.taskFocus, function(newVal) { + if (newVal) { + $timeout(function() { + elem[0].focus(); + }, 0, false); + } + }); + } +} diff --git a/website/public/js/directives/when-scrolled.directive.js b/website/public/js/directives/when-scrolled.directive.js new file mode 100644 index 0000000000..3a063ca439 --- /dev/null +++ b/website/public/js/directives/when-scrolled.directive.js @@ -0,0 +1,17 @@ +'use strict'; + +angular + .module('habitrpg') + .directive('whenScrolled', whenScrolled); + +function whenScrolled() { + return function(scope, elm, attr) { + var raw = elm[0]; + + elm.bind('scroll', function() { + if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) { + scope.$apply(attr.whenScrolled); + } + }); + }; +} diff --git a/website/public/js/filters/filters.js b/website/public/js/filters/filters.js index 5064566b1e..4578c1a5db 100644 --- a/website/public/js/filters/filters.js +++ b/website/public/js/filters/filters.js @@ -21,3 +21,11 @@ angular.module('habitrpg') (gp > 999) ? (gp / Math.pow(10, 3)).toFixed(1) + "k" : gp; } }) + .filter('conditionalOrderBy', ['$filter', function($filter) { + return function (array, predicate, sortPredicate, reverseOrder) { + if (predicate) { + return $filter('orderBy')(array, sortPredicate, reverseOrder); + } + return array; + }; + }]); diff --git a/website/public/js/services/guideServices.js b/website/public/js/services/guideServices.js index 45f02161e0..5ba95de2e0 100644 --- a/website/public/js/services/guideServices.js +++ b/website/public/js/services/guideServices.js @@ -7,214 +7,293 @@ angular.module('habitrpg').factory('Guide', ['$rootScope', 'User', '$timeout', '$state', function($rootScope, User, $timeout, $state) { - /** - * Init and show the welcome tour. Note we do it listening to a $rootScope broadcasted 'userLoaded' message, - * this because we need to determine whether to show the tour *after* the user has been pulled from the server, - * otherwise it's always start off as true, and then get set to false later - */ - var tourRunning = false; - $rootScope.$on('userUpdated', initTour); - function initTour(){ - if (User.user.flags.showTour === false || tourRunning) return; - tourRunning = true; - var tourSteps = [ + + var chapters = { + intro: [ + [ + { + state: 'options.profile.avatar', + element: '.tab-content.ng-scope', + content: window.env.t('tourAvatar'), + placement: "top", + proceed: window.env.t('tourAvatarProceed'), + backdrop: false, + orphan: true + }, + { + state: 'tasks', + element: ".task-column.todos", + content: window.env.t('tourToDosBrief'), + placement: "top", + proceed: window.env.t('tourOkay') + }, + { + state: 'tasks', + element: ".task-column.dailys", + content: window.env.t('tourDailiesBrief'), + placement: "top", + proceed: window.env.t('tourDailiesProceed') + }, + { + state: 'tasks', + element: ".task-column.habits", + content: window.env.t('tourHabitsBrief'), + placement: "right", + proceed: window.env.t('tourHabitsProceed') + }, + { + state: 'tasks', + element: ".task-column.rewards", + content: window.env.t('tourRewardsBrief'), + placement: "top", + proceed: window.env.t('tourRewardsProceed'), + final: true + } + ] + ], + classes: [ + [ + { + state: 'options.inventory.equipment', + element: '.equipment-tab', + title: window.env.t('classGear'), + content: window.env.t('classGearText', {klass: User.user.stats.class}) + }, { + state: 'options.profile.stats', + element: ".allocate-stats", + title: window.env.t('stats'), + content: window.env.t('classStats') + }, { + state: 'options.profile.stats', + element: ".auto-allocate", + title: window.env.t('autoAllocate'), + placement: 'left', + content: window.env.t('autoAllocateText') + }, { + element: ".meter.mana", + title: window.env.t('spells'), + content: window.env.t('spellsText') + " " + window.env.t('toDo') + "." + }, { + orphan: true, + title: window.env.t('readMore'), + content: window.env.t('moreClass') + " Wikia.", + final: true + } + ] + ], + stats: [[ { - orphan:true, - title: window.env.t('welcomeHabit'), - content: window.env.t('welcomeHabitT1') + " Justin, " + window.env.t('welcomeHabitT2'), - }, { - element: ".main-herobox", - title: window.env.t('yourAvatar'), - content: window.env.t('yourAvatarText'), - }, { - element: ".main-herobox", - title: window.env.t('avatarCustom'), - content: window.env.t('avatarCustomText'), - }, { - element: ".hero-stats", - title: window.env.t('hitPoints'), - content: window.env.t('hitPointsText'), - }, { - element: ".hero-stats", - title: window.env.t('expPoints'), - content: window.env.t('expPointsText'), - }, { - element: "ul.habits", - title: window.env.t('typeGoals'), - content: window.env.t('typeGoalsText'), - placement: "top" - }, { - element: "ul.habits", - title: window.env.t('habits'), - content: window.env.t('tourHabits'), - placement: "top" - }, { - element: "ul.dailys", - title: window.env.t('dailies'), - content: window.env.t('tourDailies'), - placement: "top" - }, { - element: "ul.todos", - title: window.env.t('todos'), - content: window.env.t('tourTodos'), - placement: "top", - }, { - element: "ul.main-list.rewards", - title: window.env.t('rewards'), - content: window.env.t('tourRewards'), - placement: "top" - }, { - element: "ul.habits li:first-child", - title: window.env.t('hoverOver'), - content: window.env.t('hoverOverText'), - placement: "right" - }, { - orphan:true, - title: window.env.t('unlockFeatures'), - content: window.env.t('unlockFeaturesT1') + " " + window.env.t('habitWiki') + " " + window.env.t('unlockFeaturesT2'), - placement: "right" + orphan: true, + content: window.env.t('tourStatsPage'), + final: true, + proceed: window.env.t('tourOkay'), + hideNavigation: true } - ]; - $('.main-herobox').popover('destroy'); - var tour = new Tour({ - backdrop: true, - //orphan: true, - //keyboard: false, - template: '', - onEnd: function(){ - User.set({'flags.showTour': false}); + ]], + tavern: [[ + { + orphan: true, + content: window.env.t('tourTavernPage'), + final: true, + proceed: window.env.t('tourAwesome'), + hideNavigation: true } - }); - _.each(tourSteps, function(step) { + ]], + party: [[ + { + orphan: true, + content: window.env.t('tourPartyPage'), + final: true, + proceed: window.env.t('tourSplendid'), + hideNavigation: true + } + ]], + guilds: [[ + { + orphan: true, + content: window.env.t('tourGuildsPage'), + final: true, + proceed: window.env.t('tourNifty'), + hideNavigation: true + } + ]], + challenges: [[ + { + orphan: true, + content: window.env.t('tourChallengesPage'), + final: true, + proceed: window.env.t('tourOkay'), + hideNavigation: true + } + ]], + market: [[ + { + orphan: true, + content: window.env.t('tourMarketPage'), + final: true, + proceed: window.env.t('tourAwesome'), + hideNavigation: true + } + ]], + hall: [[ + { + orphan: true, + content: window.env.t('tourHallPage'), + final: true, + proceed: window.env.t('tourSplendid'), + hideNavigation: true + } + ]], + pets: [[ + { + orphan: true, + content: window.env.t('tourPetsPage'), + final: true, + proceed: window.env.t('tourNifty'), + hideNavigation: true + } + ]], + mounts: [[ + { + orphan: true, + content: window.env.t('tourMountsPage'), + final: true, + proceed: window.env.t('tourOkay'), + hideNavigation: true + } + ]], + equipment: [[ + { + orphan: true, + content: window.env.t('tourEquipmentPage'), + final: true, + proceed: window.env.t('tourAwesome'), + hideNavigation: true + } + ]] + } + + _.each(chapters, function(chapter, k){ + _(chapter).flatten().each(function(step, i) { step.content = "
" + step.content + "
"; + $(step.element).popover('destroy'); // destroy existing hover popovers so we can add our own step.onShow = function(){ - // Since all the steps are currently on the tasks page, ensure we go back there for each step in case they - // clicked elsewhere during the tour. FIXME: $state.go() returns a promise, necessary for async tour steps; - // however, that's not working here - have to use timeout instead :/ - if (!$state.is('tasks')) return $timeout(function(){$state.go('tasks');}, 0) + // step.path doesn't work in Angular do to async ui-router. Our custom solution: + if (step.state && !$state.is(step.state)) { + // $state.go() returns a promise, necessary for async tour steps; however, that's not working here - have to use timeout instead :/ + $state.go(step.state); + return $timeout(function(){}); + } + window.ga && ga('send', 'event', 'behavior', 'tour', k, i+1); + mixpanel.track('Tutorial',{'tour':k+'-web','step':i+1,'complete':false}); } - step.html = true; - tour.addStep(step); + step.onHide = function(){ + if (step.final) { // -2 indicates complete + var ups={};ups['flags.tour.'+k] = -2; + User.set(ups); + mixpanel.track('Tutorial',{'tour':k+'-web','step':i+1,'complete':true}); + } + } + }) + }) + + var tour = {}; + _.each(chapters, function(v,k){ + tour[k] = new Tour({ + name: k, + backdrop: true, + template: function(i,step){ + var showFinish = step.final || k == 'classes'; + var showCounter = k=='intro' && !step.final; + + return ''; + }, + storage: false + //onEnd: function(){ + // User.set({'flags.showTour': false}); + //} }); - tour.restart(); // Tour doesn't quite mesh with our handling of flags.showTour, just restart it on page load - //tour.start(true); - }; + }); - var alreadyShown = function(before, after) { - return !(!before && after === true); - }; - - var showPopover = function(selector, title, html, placement) { - if (!placement) placement = 'bottom'; - $(selector).popover('destroy'); - var button = ""; - if (env.worldDmg.guide) { - html = "
" + html + '
' + button + '
'; + var goto = function(chapter, page, force) { + //return; // TODO temporarily remove old tutorial system while experimenting with leslie's new gettup + if (chapter == 'intro') User.set({'flags.welcomed': true}); + var curr = User.user.flags.tour[chapter]; + if (page != curr+1 && !force) return; + var updates = {};updates['flags.tour.'+chapter] = page; + User.set(updates); + var chap = tour[chapter], opts = chap._options; + opts.steps = []; + _.times(page, function(p){ + opts.steps = opts.steps.concat(chapters[chapter][p]); + }) + var end = opts.steps.length; + opts.steps = opts.steps.concat(chapters[chapter][page]); + chap._removeState('end'); + if (chap._inited) { + chap.goTo(end); } else { - html = "
" + html + '
' + button + '
'; + chap.setCurrentStep(end); + chap.start(); } - $(selector).popover({ - title: title, - placement: placement, - trigger: 'manual', - html: true, - content: html - }).popover('show'); - }; + } - $rootScope.$watch('user.flags.customizationsNotification', function(after, before) { - if (alreadyShown(before, after)) return; - showPopover('.main-herobox', window.env.t('customAvatar'), window.env.t('customAvatarText'), 'bottom'); - }); - - $rootScope.$watch('user.flags.itemsEnabled', function(after, before) { - if (alreadyShown(before, after)) return; - var html = window.env.t('storeUnlockedText'); - showPopover('div.rewards', window.env.t('storeUnlocked'), html, 'left'); - }); - - $rootScope.$watch('user.flags.partyEnabled', function(after, before) { - if (alreadyShown(before, after)) return; - var html = window.env.t('partySysText'); - showPopover('.user-menu', window.env.t('partySys'), html, 'bottom'); - }); - - $rootScope.$watch('user.flags.dropsEnabled', function(after, before) { - if (alreadyShown(before, after)) return; - var eggs = User.user.items.eggs || {}; - if (!eggs) { - eggs['Wolf'] = 1; // This is also set on the server + //Init and show the welcome tour (only after user is pulled from server & wrapped). + var watcher = $rootScope.$watch('User.user.ops.update', function(updateFn){ + if (!updateFn) return; // only run after user has been wrapped + watcher(); // deregister watcher + if (window.env.IS_MOBILE) return; // Don't show tour immediately on mobile devices + if (User.user.flags.welcomed == false) { + $rootScope.openModal('welcome', {size: 'lg', backdrop: 'static', keyboard: false}); } - $rootScope.openModal('dropsEnabled'); - }); - $rootScope.$watch('user.flags.rebirthEnabled', function(after, before) { + var alreadyShown = function(before, after) { return !(!before && after === true) }; + //$rootScope.$watch('user.flags.dropsEnabled', _.flow(alreadyShown, function(already) { //FIXME requires lodash@~3.2.0 + $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){ + switch (toState.name) { + // case 'options.profile.avatar': return goto('intro', 5); + case 'options.profile.stats': return goto('stats', 0); + case 'options.social.tavern': return goto('tavern', 0); + case 'options.social.party': return goto('party', 0); + case 'options.social.guilds.public': return goto('guilds', 0); + case 'options.social.challenges': return goto('challenges', 0); + case 'options.social.hall.heroes': return goto('hall', 0); + case 'options.inventory.drops': return goto('market', 0); + case 'options.inventory.pets': return goto('pets', 0); + case 'options.inventory.mounts': return goto('mounts', 0); + case 'options.inventory.equipment': return goto('equipment', 0); + } + }); + $rootScope.$watch('user.flags.dropsEnabled', function(after, before) { + if (alreadyShown(before,after)) return; + var eggs = User.user.items.eggs || {}; + if (!eggs) eggs['Wolf'] = 1; // This is also set on the server + $rootScope.openModal('dropsEnabled'); + }); + $rootScope.$watch('user.flags.rebirthEnabled', function(after, before) { if (alreadyShown(before, after)) return; $rootScope.openModal('rebirthEnabled'); + }); }); - - /** - * Classes Tour - */ - function classesTour(){ - - // TODO notice my hack-job `onShow: _.once()` functions. Without these, the syncronous path redirects won't properly handle showing tour - var tourSteps = [ - { - path: '/#/options/inventory/equipment', - onShow: _.once(function(tour){ - $timeout(function(){tour.goTo(0)}); - }), - element: '.equipment-tab', - title: window.env.t('classGear'), - content: window.env.t('classGearText', {klass: User.user.stats.class}) - }, - { - path: '/#/options/profile/stats', - onShow: _.once(function(tour){ - $timeout(function(){tour.goTo(1)}); - }), - element: ".allocate-stats", - title: window.env.t('stats'), - content: window.env.t('classStats'), - }, { - element: ".auto-allocate", - title: window.env.t('autoAllocate'), - placement: 'left', - content: window.env.t('autoAllocateText'), - }, { - element: ".meter.mana", - title: window.env.t('spells'), - content: window.env.t('spellsText') + " " + window.env.t('toDo') + "." - }, { - orphan: true, - title: window.env.t('readMore'), - content: window.env.t('moreClass') + " Wikia." - } - ]; - _.each(tourSteps, function(step){ - if (env.worldDmg.guide) { - step.content = "
" + step.content + "
"; - } else { - step.content = "
" + step.content + "
"; - } - }); - $('.allocate-stats').popover('destroy'); - var tour = new Tour({ -// onEnd: function(){ -// User.set({'flags.showTour': false}); -// } - }); - tourSteps.forEach(function(step) { - tour.addStep(_.defaults(step, {html: true})); - }); - tour.restart(); // Tour doesn't quite mesh with our handling of flags.showTour, just restart it on page load - //tour.start(true); + var Guide = { + goto: goto }; + $rootScope.Guide = Guide; + return Guide; - return { - initTour: initTour, - classesTour: classesTour - }; }]); diff --git a/website/public/js/services/notificationServices.js b/website/public/js/services/notificationServices.js index a0dde36fbb..d08c077e6d 100644 --- a/website/public/js/services/notificationServices.js +++ b/website/public/js/services/notificationServices.js @@ -1,23 +1,9 @@ +'use strict' /** Set up "+1 Exp", "Level Up", etc notifications */ angular.module("habitrpg").factory("Notification", -[function() { - var stack_topright = {"dir1": "down", "dir2": "left", "spacing1": 15, "spacing2": 15, "firstpos1": 60}; - function notify(html, type, icon) { - var notice = $.pnotify({ - type: type || 'warning', //('info', 'text', 'warning', 'success', 'gp', 'xp', 'hp', 'lvl', 'death', 'mp', 'crit') - text: html, - opacity: 1, - addclass: 'alert-' + type, - delay: 7000, - hide: (type == 'error') ? false : true, - mouse_reset: false, - width: "250px", - stack: stack_topright, - icon: icon || false - }).click(function() { notice.pnotify_remove() }); - }; +['$filter', function($filter) { /** Show "+ 5 {gold_coin} 3 {silver_coin}" @@ -34,51 +20,117 @@ angular.module("habitrpg").factory("Notification", } else if (silver > 0) { return "" + silver + " "; } - }; + } - var sign = function(number){ + function crit(val) { + _notify(window.env.t('critBonus') + Math.round(val) + "%", 'crit', 'glyphicon glyphicon-certificate'); + } + + function drop(val, item) { + var dropClass = ""; + if ( item !== undefined ) { + switch ( item.type ) { + case "Egg": + dropClass = 'Pet_Egg_' + item.key; + break; + case "HatchingPotion": + dropClass = 'Pet_HatchingPotion_' + item.key; + break; + case "Food": + dropClass = 'Pet_Food_' + item.key; + break; + default: + dropClass = 'glyphicon glyphicon-gift'; + } + } + _notify(val, 'drop', dropClass); + } + + function exp(val) { + if (val < -50) return; // don't show when they level up (resetting their exp) + _notify(_sign(val) + " " + _round(val) + " " + window.env.t('xp'), 'xp', 'glyphicon glyphicon-star'); + } + + function error(error){ + _notify(error, "danger", 'glyphicon glyphicon-exclamation-sign'); + } + + function gp(val, bonus) { + _notify(_sign(val) + " " + coins(val - bonus), 'gp'); + } + + function hp(val) { + // don't show notifications if user dead + _notify(_sign(val) + " " + _round(val) + " " + window.env.t('hp'), 'hp', 'glyphicon glyphicon-heart'); + } + + function lvl(){ + _notify(window.env.t('levelUp'), 'lvl', 'glyphicon glyphicon-chevron-up'); + } + + function markdown(val){ + if (val) { + var parsed_markdown = $filter("markdown")(val); + _notify(parsed_markdown, 'info'); + } + } + + function mp(val) { + _notify(_sign(val) + " " + _round(val) + " " + window.env.t('mp'), 'mp', 'glyphicon glyphicon-fire'); + } + + function streak(val) { + _notify(window.env.t('streakName') + ': ' + val, 'streak', 'glyphicon glyphicon-repeat'); + } + + function text(val){ + if (val) { + _notify(val, 'info'); + } + } + + //-------------------------------------------------- + // Private Methods + //-------------------------------------------------- + + function _sign(number){ return number?number<0?'-':'+':'+'; } - var round = function(number){ + function _round(number){ return Math.abs(number.toFixed(1)); } + // Used to stack notifications, must be outside of _notify + var stack_topright = {"dir1": "down", "dir2": "left", "spacing1": 15, "spacing2": 15, "firstpos1": 60}; + + function _notify(html, type, icon) { + var notice = $.pnotify({ + type: type || 'warning', //('info', 'text', 'warning', 'success', 'gp', 'xp', 'hp', 'lvl', 'death', 'mp', 'crit') + text: html, + opacity: 1, + addclass: 'alert-' + type, + delay: 7000, + hide: (type == 'error') ? false : true, + mouse_reset: false, + width: "250px", + stack: stack_topright, + icon: icon || false + }).click(function() { notice.pnotify_remove() }); + } + return { coins: coins, - hp: function(val) { - // don't show notifications if user dead - notify(sign(val) + " " + round(val) + " " + window.env.t('hp'), 'hp', 'glyphicon glyphicon-heart'); - }, - exp: function(val) { - if (val < -50) return; // don't show when they level up (resetting their exp) - notify(sign(val) + " " + round(val) + " " + window.env.t('xp'), 'xp', 'glyphicon glyphicon-star'); - }, - gp: function(val, bonus) { - notify(sign(val) + " " + coins(val - bonus), 'gp'); - }, - text: function(val){ - if (val) { - notify(val, 'info'); - } - }, - lvl: function(){ - notify(window.env.t('levelUp'), 'lvl', 'glyphicon glyphicon-chevron-up'); - }, - error: function(error){ - notify(error, "danger", 'glyphicon glyphicon-exclamation-sign'); - }, - mp: function(val) { - notify(sign(val) + " " + round(val) + " " + window.env.t('mp'), 'mp', 'glyphicon glyphicon-fire'); - }, - crit: function(val) { - notify(window.env.t('critBonus') + Math.round(val) + "%", 'crit', 'glyphicon glyphicon-certificate'); - }, - streak: function(val) { - notify(window.env.t('streakName') + ': ' + val, 'streak', 'glyphicon glyphicon-repeat'); - }, - drop: function(val) { - notify(val, 'drop', 'glyphicon glyphicon-gift'); - } + crit: crit, + drop: drop, + exp: exp, + error: error, + gp: gp, + hp: hp, + lvl: lvl, + markdown: markdown, + mp: mp, + streak: streak, + text: text }; }]); diff --git a/website/public/js/static.js b/website/public/js/static.js index 3fdd1e6f2d..ae355a4b17 100644 --- a/website/public/js/static.js +++ b/website/public/js/static.js @@ -18,6 +18,8 @@ window.habitrpg = angular.module('habitrpg', ['chieffancypants.loadingBar', 'ui. }); }) } + + $scope.Math = window.Math; }]) .controller("PlansCtrl", ['$rootScope', diff --git a/website/public/manifest.json b/website/public/manifest.json index 92bdbd9373..7436040c57 100644 --- a/website/public/manifest.json +++ b/website/public/manifest.json @@ -50,7 +50,16 @@ "js/filters/filters.js", - "js/directives/directives.js", + "js/directives/focus-me.directive.js", + "js/directives/from-now.directive.js", + "js/directives/habitrpg-tasks.directive.js", + "js/directives/hrpg-sort-checklist.directive.js", + "js/directives/hrpg-sort-tags.directive.js", + "js/directives/hrpg-sort-tasks.directive.js", + "js/directives/popover-html-popup.directive.js", + "js/directives/popover-html.directive.js", + "js/directives/task-focus.directive.js", + "js/directives/when-scrolled.directive.js", "js/controllers/authCtrl.js", "js/controllers/notificationCtrl.js", @@ -105,5 +114,29 @@ "common/dist/sprites/habitrpg-shared.css", "static.css" ] + }, + "tmp_static_front": { + "js": [ + "bower_components/jquery/dist/jquery.min.js", + "common/dist/scripts/habitrpg-shared.js", + "bower_components/angular/angular.js", + "bower_components/angular-ui/build/angular-ui.js", + "bower_components/jquery-colorbox/jquery.colorbox-min.js", + "bower_components/hello/dist/hello.all.min.js", + + "bower_components/angular-loading-bar/build/loading-bar.js", + "js/env.js", + "js/static.js", + "js/services/notificationServices.js", + "common/script/public/userServices.js", + "js/controllers/authCtrl.js", + "js/controllers/footerCtrl.js" + ], + "css": [ + "bower_components/css-social-buttons/css/zocial.css", + "front/staticstyle.css", + "common/dist/sprites/habitrpg-shared.css", + "app.css" + ] } } diff --git a/website/src/controllers/auth.js b/website/src/controllers/auth.js index 64dc988a0d..e861daab19 100644 --- a/website/src/controllers/auth.js +++ b/website/src/controllers/auth.js @@ -7,6 +7,7 @@ var utils = require('../utils'); var nconf = require('nconf'); var request = require('request'); var User = require('../models/user').model; +var EmailUnsubscription = require('../models/emailUnsubscription').model; var ga = require('./../utils').ga; var i18n = require('./../i18n'); @@ -61,7 +62,7 @@ api.authWithUrl = function(req, res, next) { if (_.isEmpty(user)) return res.json(401, NO_USER_FOUND); res.locals.user = user; next(); - }) + }); } api.registerUser = function(req, res, next) { @@ -109,9 +110,14 @@ api.registerUser = function(req, res, next) { newUser.preferences = newUser.preferences || {}; newUser.preferences.language = req.language; // User language detected from browser, not saved var user = new User(newUser); - utils.txnEmail(user, 'welcome'); - ga.event('register', 'Local').send(); - user.save(cb); + ga.event('acquisition', 'register', 'local').send(); + user.save(function(err, savedUser){ + // Clean previous email preferences + EmailUnsubscription.remove({email: savedUser.auth.local.email}, function(){ + utils.txnEmail(savedUser, 'welcome'); + }); + cb.apply(cb, arguments); + }); } }] }, function(err, data) { @@ -132,7 +138,7 @@ api.loginLocal = function(req, res, next) { var login = validator.isEmail(username) ? {'auth.local.email':username} : {'auth.local.username':username}; User.findOne(login, {auth:1}, function(err, user){ if (err) return next(err); - if (!user) return res.json(401, {err:"Username or password incorrect. Click 'Forgot Password' for help with either. (Note: usernames are case-sensitive)"}); + if (!user) return res.json(401, {err:"Uh-oh - your username or password is incorrect.\n- Make sure your username or email is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login.\n- If you forgot your password, click \"Forgot Password\"."}); if (user.auth.blocked) return res.json(401, accountSuspended(user._id)); // We needed the whole user object first so we can get his salt to encrypt password comparison User.findOne( @@ -140,7 +146,7 @@ api.loginLocal = function(req, res, next) { , {_id:1, apiToken:1} , function(err, user){ if (err) return next(err); - if (!user) return res.json(401,{err:"Username or password incorrect. Click 'Forgot Password' for help with either. (Note: usernames are case-sensitive)"}); + if (!user) return res.json(401,{err:"Uh-oh - your username or password is incorrect.\n- Make sure your username or email is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login.\n- If you forgot your password, click \"Forgot Password\"."}); res.json({id: user._id,token: user.apiToken}); password = null; }); @@ -178,10 +184,17 @@ api.loginSocial = function(req, res, next) { }; user.auth[network] = prof; user = new User(user); - user.save(cb); + user.save(function(err, savedUser){ + // Clean previous email preferences + if(savedUser.auth.facebook.emails && savedUser.auth.facebook.emails[0] && savedUser.auth.facebook.emails[0].value){ + EmailUnsubscription.remove({email: savedUser.auth.facebook.emails[0].value}, function(){ + utils.txnEmail(savedUser, 'welcome'); + }); + } + cb.apply(cb, arguments); + }); - utils.txnEmail(user, 'welcome'); - ga.event('register', network).send(); + ga.event('acquisition', 'register', network).send(); }] }, function(err, results){ if (err) return res.json(401, {err: err.toString ? err.toString() : err}); @@ -214,13 +227,16 @@ api.resetPassword = function(req, res, next){ User.findOne({'auth.local.email': RegexEscape(email)}, function(err, user){ if (err) return next(err); - if (!user) return res.send(500, {err:"Couldn't find a user registered for email " + email}); + if (!user) return res.send(401, {err:"Sorry, we can't find a user registered with email " + email + "\n- Make sure your email address is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login."}); user.auth.local.salt = salt; user.auth.local.hashed_password = hashed_password; - utils.txnEmail(user, 'reset-password', [ - {name: "NEW_PASSWORD", content: newPassword}, - {name: "USERNAME", content: user.auth.local.username} - ]); + utils.sendEmail({ + from: "HabitRPG ", + to: email, + subject: "Password Reset for HabitRPG", + text: "Password for " + user.auth.local.username + " has been reset to " + newPassword + ". Log in at " + nconf.get('BASE_URL') + ". After you've logged in, head to "+nconf.get('BASE_URL')+"/#/options/settings/settings and change your password.", + html: "Password for " + user.auth.local.username + " has been reset to " + newPassword + ". Log in at " + nconf.get('BASE_URL') + ". After you've logged in, head to "+nconf.get('BASE_URL')+"/#/options/settings/settings and change your password." + }); user.save(function(err){ if(err) return next(err); res.send('New password sent to '+ email); diff --git a/website/src/controllers/challenges.js b/website/src/controllers/challenges.js index 5fabd0fb1c..8dea70cd1d 100644 --- a/website/src/controllers/challenges.js +++ b/website/src/controllers/challenges.js @@ -11,7 +11,7 @@ var logging = require('./../logging'); var csv = require('express-csv'); var utils = require('../utils'); var api = module.exports; - +var pushNotify = require('./pushNotifications'); /* ------------------------------------------------------------------------ @@ -40,7 +40,7 @@ api.list = function(req, res, next) { .select('name leader description group memberCount prize official') .select({members:{$elemMatch:{$in:[user._id]}}}) .sort('-official -timestamp') - .populate('group', '_id name') + .populate('group', '_id name type') .populate('leader', 'profile.name') .exec(cb); } @@ -56,17 +56,23 @@ api.list = function(req, res, next) { // GET api.get = function(req, res, next) { + var user = res.locals.user; // TODO use mapReduce() or aggregate() here to // 1) Find the sum of users.tasks.values within the challnege (eg, {'profile.name':'tyler', 'sum': 100}) // 2) Sort by the sum // 3) Limit 30 (only show the 30 users currently in the lead) Challenge.findById(req.params.cid) .populate('members', 'profile.name _id') + .populate('group', '_id name type') + .populate('leader', 'profile.name') .exec(function(err, challenge){ if(err) return next(err); if (!challenge) return res.json(404, {err: 'Challenge ' + req.params.cid + ' not found'}); + challenge._isMember = !!(_.find(challenge.members, function(member) { + return member._id === user._id; + })); res.json(challenge); - }) + }); } api.csv = function(req, res, next) { @@ -294,6 +300,7 @@ function closeChal(cid, broken, cb) { api['delete'] = function(req, res, next){ var user = res.locals.user; var cid = req.params.cid; + async.waterfall([ function(cb){ Challenge.findById(cid, cb); @@ -301,6 +308,10 @@ api['delete'] = function(req, res, next){ function(chal, cb){ if (!chal) return cb('Challenge ' + cid + ' not found'); if (chal.leader != user._id) return cb("You don't have permissions to edit this challenge"); + if (chal.group != 'habitrpg') user.balance += chal.prize/4; // Refund gems to user if a non-tavern challenge + user.save(cb); + }, + function(save, num, cb){ closeChal(req.params.cid, {broken: 'CHALLENGE_DELETED'}, cb); } ], function(err){ @@ -341,6 +352,9 @@ api.selectWinner = function(req, res, next) { {name: 'CHALLENGE_NAME', content: chal.name} ]); } + + pushNotify.sendNotify(saved, shared.i18n.t('wonChallenge'), chal.name); + closeChal(cid, {broken: 'CHALLENGE_CLOSED', winner: saved.profile.name}, cb); } ], function(err){ diff --git a/website/src/controllers/groups.js b/website/src/controllers/groups.js index 6883aebef0..acb893b1ec 100644 --- a/website/src/controllers/groups.js +++ b/website/src/controllers/groups.js @@ -12,8 +12,10 @@ var shared = require('../../../common'); var User = require('./../models/user').model; var Group = require('./../models/group').model; var Challenge = require('./../models/challenge').model; +var EmailUnsubscription = require('./../models/emailUnsubscription').model; var isProd = nconf.get('NODE_ENV') === 'production'; var api = module.exports; +var pushNotify = require('./pushNotifications'); /* ------------------------------------------------------------------------ @@ -30,7 +32,7 @@ var guildPopulate = {path: 'members', select: nameFields, options: {limit: 15} } * limited fields - and only a sampling of the members, beacuse they can be in the thousands * @param type: 'party' or otherwise * @param q: the Mongoose query we're building up - * @param additionalFields: if we want to populate some additional field not fetched normally + * @param additionalFields: if we want to populate some additional field not fetched normally * pass it as a string, parties only */ var populateQuery = function(type, q, additionalFields){ @@ -38,6 +40,7 @@ var populateQuery = function(type, q, additionalFields){ q.populate('members', partyFields + (additionalFields ? (' ' + additionalFields) : '')); else q.populate(guildPopulate); + q.populate('leader', nameFields); q.populate('invites', nameFields); q.populate({ path: 'challenges', @@ -135,8 +138,36 @@ api.get = function(req, res, next) { populateQuery(gid, q); q.exec(function(err, group){ if (err) return next(err); - if (!group && gid!=='party') return res.json(404,{err: "Group not found or you don't have access."}); - res.json(group); + if(!group){ + if(gid !== 'party') return res.json(404,{err: "Group not found or you don't have access."}); + + // Don't send a 404 when querying for a party even if it doesn't exist + // so that users with no party don't get a 404 on every access to the site + return res.json(group); + } + //Since we have a limit on how many members are populate to the group, we want to make sure the user is always in the group + var userInGroup = _.find(group.members, function(member){ return member._id == user._id; }); + //If the group is private or the group is a party, then the user must be a member of the group based on access restrictions above + if (group.privacy === 'private' || gid === 'party') { + //If the user is not in the group query, remove a user and add the current user + if (!userInGroup) { + group.members.splice(0,1); + group.members.push(user); + } + res.json(group); + } else if ( group.privacy === "public" ) { //The group is public, we must do an extra check to see if the user is already in the group query + //We must see how to check if a user is a member of a public group, so we requery + var q2 = Group.findOne({ _id: group._id, privacy:'public', members: {$in:[user._id]} }); + q2.exec(function(err, group2){ + if (err) return next(err); + if (group2 && !userInGroup) { + group.members.splice(0,1); + group.members.push(user); + } + res.json(group); + }); + } + gid = null; }); }; @@ -236,24 +267,28 @@ api.getChat = function(req, res, next) { * TODO make this it's own ngResource so we don't have to send down group data with each chat post */ api.postChat = function(req, res, next) { - var user = res.locals.user - var group = res.locals.group; - if (group.type!='party' && user.flags.chatRevoked) return res.json(401,{err:'Your chat privileges have been revoked.'}); - var lastClientMsg = req.query.previousMsg; - var chatUpdated = (lastClientMsg && group.chat && group.chat[0] && group.chat[0].id !== lastClientMsg) ? true : false; + if(!req.query.message) { + return res.json(400,{err:'You cannot send a blank message'}); + } else { + var user = res.locals.user + var group = res.locals.group; + if (group.type!='party' && user.flags.chatRevoked) return res.json(401,{err:'Your chat privileges have been revoked.'}); + var lastClientMsg = req.query.previousMsg; + var chatUpdated = (lastClientMsg && group.chat && group.chat[0] && group.chat[0].id !== lastClientMsg) ? true : false; - group.sendChat(req.query.message, user); // FIXME this should be body, but ngResource is funky + group.sendChat(req.query.message, user); // FIXME this should be body, but ngResource is funky - if (group.type === 'party') { - user.party.lastMessageSeen = group.chat[0].id; - user.save(); + if (group.type === 'party') { + user.party.lastMessageSeen = group.chat[0].id; + user.save(); + } + + group.save(function(err, saved){ + if (err) return next(err); + return chatUpdated ? res.json({chat: group.chat}) : res.json({message: saved.chat[0]}); + group = chatUpdated = null; + }); } - - group.save(function(err, saved){ - if (err) return next(err); - return chatUpdated ? res.json({chat: group.chat}) : res.json({message: saved.chat[0]}); - group = chatUpdated = null; - }); } api.deleteChatMessage = function(req, res, next){ @@ -304,8 +339,9 @@ api.flagChatMessage = function(req, res, next){ group.markModified('chat'); group.save(function(err,_saved){ if(err) return next(err); - var addressesToSendTo = JSON.parse(nconf.get('FLAG_REPORT_EMAIL')); - + var addressesToSendTo = nconf.get('FLAG_REPORT_EMAIL'); + addressesToSendTo = (typeof addressesToSendTo == 'string') ? JSON.parse(addressesToSendTo) : addressesToSendTo; + if(Array.isArray(addressesToSendTo)){ addressesToSendTo = addressesToSendTo.map(function(email){ return {email: email, canSend: true} @@ -321,17 +357,17 @@ api.flagChatMessage = function(req, res, next){ {name: "REPORTER_USERNAME", content: user.profile.name}, {name: "REPORTER_UUID", content: user._id}, {name: "REPORTER_EMAIL", content: user.auth.local ? user.auth.local.email : ((user.auth.facebook && user.auth.facebook.emails && user.auth.facebook.emails[0]) ? user.auth.facebook.emails[0].value : null)}, - {name: "REPORTER_MODAL_URL", content: "https://habitrpg.com/static/front/#?memberId=" + user._id}, + {name: "REPORTER_MODAL_URL", content: "/static/front/#?memberId=" + user._id}, {name: "AUTHOR_USERNAME", content: message.user}, {name: "AUTHOR_UUID", content: message.uuid}, {name: "AUTHOR_EMAIL", content: author.auth.local ? author.auth.local.email : ((author.auth.facebook && author.auth.facebook.emails && author.auth.facebook.emails[0]) ? author.auth.facebook.emails[0].value : null)}, - {name: "AUTHOR_MODAL_URL", content: "https://habitrpg.com/static/front/#?memberId=" + message.uuid}, + {name: "AUTHOR_MODAL_URL", content: "/static/front/#?memberId=" + message.uuid}, {name: "GROUP_NAME", content: group.name}, {name: "GROUP_TYPE", content: group.type}, {name: "GROUP_ID", content: group._id}, - {name: "GROUP_URL", content: group._id == 'habitrpg' ? (nconf.get('BASE_URL') + '/#/options/groups/tavern') : (group.type === 'guild' ? (nconf.get('BASE_URL')+ '/#/options/groups/guilds/' + group._id) : 'party')}, + {name: "GROUP_URL", content: group._id == 'habitrpg' ? '/#/options/groups/tavern' : (group.type === 'guild' ? ('/#/options/groups/guilds/' + group._id) : 'party')}, ]); return res.send(204); @@ -358,7 +394,7 @@ api.clearFlagCount = function(req, res, next){ }else{ return res.json(401, {err: "Only an admin can clear the flag count!"}) } - + } api.seenMessage = function(req,res,next){ @@ -393,7 +429,8 @@ api.likeChatMessage = function(req, res, next) { api.join = function(req, res, next) { var user = res.locals.user, - group = res.locals.group; + group = res.locals.group, + isUserInvited = false; if (group.type == 'party' && group._id == (user.invitations && user.invitations.party && user.invitations.party.id)) { User.update({_id:user.invitations.party.inviter}, {$inc:{'items.quests.basilist':1}}).exec(); // Reward inviter @@ -404,16 +441,25 @@ api.join = function(req, res, next) { group.quest.members[user._id] = undefined; group.markModified('quest.members'); } - } - else if (group.type == 'guild' && user.invitations && user.invitations.guilds) { + isUserInvited = true; + } else if (group.type == 'guild' && user.invitations && user.invitations.guilds) { var i = _.findIndex(user.invitations.guilds, {id:group._id}); - if (~i) user.invitations.guilds.splice(i,1); - user.save(); + if (~i){ + isUserInvited = true; + user.invitations.guilds.splice(i,1); + user.save(); + }else{ + isUserInvited = group.privacy === 'private' ? false : true; + } } + if(!isUserInvited) return res.json(401, {err: "Can't join a group you're not invited to."}); + if (!_.contains(group.members, user._id)){ group.members.push(user._id); - group.invites.splice(_.indexOf(group.invites, user._id), 1); + if (group.invites.length > 0) { + group.invites.splice(_.indexOf(group.invites, user._id), 1); + } } async.series([ @@ -425,7 +471,6 @@ api.join = function(req, res, next) { } ], function(err, results){ if (err) return next(err); - // Return the group? Or not? res.json(results[1]); group = null; @@ -535,9 +580,13 @@ var inviteByUUIDs = function(uuids, group, req, res, next){ function sendInvite (){ if(group.type === 'guild'){ invite.invitations.guilds.push({id: group._id, name: group.name, inviter:res.locals.user._id}); + + pushNotify.sendNotify(invite, shared.i18n.t('invitedGuild'), group.name); }else{ //req.body.type in 'guild', 'party' invite.invitations.party = {id: group._id, name: group.name, inviter:res.locals.user._id}; + + pushNotify.sendNotify(invite, shared.i18n.t('invitedParty'), group.name); } group.invites.push(invite._id); @@ -562,12 +611,12 @@ var inviteByUUIDs = function(uuids, group, req, res, next){ if(group.type == 'guild'){ emailVars.push( {name: 'GUILD_NAME', content: group.name}, - {name: 'GUILD_URL', content: nconf.get('BASE_URL') + '/#/options/groups/guilds/public'} + {name: 'GUILD_URL', content: '/#/options/groups/guilds/public'} ); }else{ emailVars.push( {name: 'PARTY_NAME', content: group.name}, - {name: 'PARTY_URL', content: nconf.get('BASE_URL') + '/#/options/groups/party'} + {name: 'PARTY_URL', content: '/#/options/groups/party'} ) } @@ -577,7 +626,7 @@ var inviteByUUIDs = function(uuids, group, req, res, next){ cb(); }); } - }); + }); }, function(err){ if(err) return err.code ? res.json(err.code, {err: err.err}) : next(err); @@ -609,7 +658,7 @@ var inviteByEmails = function(invites, group, req, res, next){ } // yeah, it supports guild too but for backward compatibility we'll use partyInvite as query - var link = nconf.get('BASE_URL')+'?partyInvite='+ utils.encrypt(JSON.stringify({id:group._id, inviter:res.locals.user._id, name:group.name})); + var link = '?partyInvite='+ utils.encrypt(JSON.stringify({id:group._id, inviter:res.locals.user._id, name:group.name})); var inviterVars = utils.getUserInfo(res.locals.user, ['name', 'email']); var variables = [ @@ -623,10 +672,15 @@ var inviteByEmails = function(invites, group, req, res, next){ } // TODO implement "users can only be invited once" - invite.canSend = true; // Requested by utils.txnEmail - utils.txnEmail(invite, ('invite-friend' + (group.type == 'guild' ? '-guild' : '')), variables); + // Check for the email address not to be unsubscribed + EmailUnsubscription.findOne({email: invite.email}, function(err, unsubscribed){ + if(err) return cb(err); + if(unsubscribed) return cb(); - cb(); + utils.txnEmail(invite, ('invite-friend' + (group.type == 'guild' ? '-guild' : '')), variables); + + cb(); + }); }); }else{ cb(); @@ -638,7 +692,7 @@ var inviteByEmails = function(invites, group, req, res, next){ inviteByUUIDs(usersAlreadyRegistered, group, req, res, next); }else{ - // Send only status code down the line because it doesn't need + // Send only status code down the line because it doesn't need // info on invited users since they are not yet registered res.send(200); } @@ -660,8 +714,21 @@ api.invite = function(req, res, next){ api.removeMember = function(req, res, next){ var group = res.locals.group; var uuid = req.query.uuid; + var message = req.query.message; var user = res.locals.user; + // Send an email to the removed user with an optional message from the leader + var sendMessage = function(removedUser){ + if(removedUser.preferences.emailNotifications.kickedGroup !== false){ + utils.txnEmail(removedUser, ('kicked-from-' + group.type), [ + {name: 'GROUP_NAME', content: group.name}, + {name: 'MESSAGE', content: message}, + {name: 'GUILDS_LINK', content: '/#/options/groups/guilds/public'}, + {name: 'PARTY_WANTED_GUILD', content: '/#/options/groups/guilds/f2db2a7f-13c5-454d-b3ee-ea1f5089e601'} + ]); + } + } + if(group.leader !== user._id){ return res.json(401, {err: "Only group leader can remove a member!"}); } @@ -678,12 +745,21 @@ api.removeMember = function(req, res, next){ Group.update({_id:group._id},update, function(err, saved){ if (err) return next(err); - // Sending an empty 204 because Group.update doesn't return the group - // see http://mongoosejs.com/docs/api.html#model_Model.update - return res.send(204); + User.findById(uuid, function(err, removedUser){ + if(err) return next(err); + + sendMessage(removedUser); + + // Sending an empty 204 because Group.update doesn't return the group + // see http://mongoosejs.com/docs/api.html#model_Model.update + group = uuid = null; + return res.send(204); + }); }); }else if(_.contains(group.invites, uuid)){ User.findById(uuid, function(err,invited){ + if(err) return next(err); + var invitations = invited.invitations; if(group.type === 'guild'){ invitations.guilds.splice(_.indexOf(invitations.guilds, group._id), 1); @@ -703,8 +779,9 @@ api.removeMember = function(req, res, next){ // Sending an empty 204 because Group.update doesn't return the group // see http://mongoosejs.com/docs/api.html#model_Model.update - return res.send(204); + sendMessage(invited); group = uuid = null; + return res.send(204); }); }); @@ -755,13 +832,18 @@ questStart = function(req, res, next) { updates['$set']['party.quest.progress.collect'] = collected; updates['$set']['party.quest.completed'] = null; questMembers[m] = true; + + User.findOne({_id: m}, {pushDevices: 1}, function(err, user){ + pushNotify.sendNotify(user, "HabitRPG", shared.i18n.t('questStarted') + ": "+ quest.text() ); + }); } else { updates['$set']['party.quest'] = Group.cleanQuestProgress(); } + parallel.push(function(cb2){ User.update({_id:m},updates,cb2); }); - }) + }); group.quest.active = true; if (quest.boss) { @@ -787,19 +869,22 @@ questStart = function(req, res, next) { groupClone.members = results[lastIndex].members; - // Send quest started email and remove auth information + // Send quest started email + var usersToEmail = groupClone.members.filter(function(user){ + return ( + user.preferences.emailNotifications.questStarted !== false && + user._id !== res.locals.user._id && + group.quest.members[user._id] == true + ) + }); + + utils.txnEmail(usersToEmail, 'quest-started', [ + {name: 'PARTY_URL', content: '/#/options/groups/party'} + ]); + _.each(groupClone.members, function(user){ - - if(user.preferences.emailNotifications.questStarted !== false && - user._id !== res.locals.user._id && - group.quest.members[user._id] == true - ){ - utils.txnEmail(user, 'quest-started', [ - {name: 'PARTY_URL', content: nconf.get('BASE_URL') + '/#/options/groups/party'} - ]); - } - // Remove sensitive data from what is sent to the public + // but after having sent emails as they are needed user.auth.facebook = undefined; user.auth.local = undefined; }); @@ -841,20 +926,24 @@ api.questAccept = function(req, res, next) { _id: { $in: _.without(group.members, user._id) } - }, {auth: 1, preferences: 1, profile: 1}, function(err, members){ + }, {auth: 1, preferences: 1, profile: 1, pushDevices: 1}, function(err, members){ if(err) return next(err); var inviterVars = utils.getUserInfo(user, ['name', 'email']); - _.each(members, function(member){ - if(member.preferences.emailNotifications.invitedQuest !== false){ - utils.txnEmail(member, ('invite-' + (quest.boss ? 'boss' : 'collection') + '-quest'), [ - {name: 'QUEST_NAME', content: quest.text()}, - {name: 'INVITER', content: inviterVars.name}, - {name: 'REPLY_TO_ADDRESS', content: inviterVars.email}, - {name: 'PARTY_URL', content: nconf.get('BASE_URL') + '/#/options/groups/party'} - ]); - } + var membersToEmail = members.filter(function(member){ + return member.preferences.emailNotifications.invitedQuest !== false; + }); + + utils.txnEmail(membersToEmail, ('invite-' + (quest.boss ? 'boss' : 'collection') + '-quest'), [ + {name: 'QUEST_NAME', content: quest.text()}, + {name: 'INVITER', content: inviterVars.name}, + {name: 'REPLY_TO_ADDRESS', content: inviterVars.email}, + {name: 'PARTY_URL', content: '/#/options/groups/party'} + ]); + + _.each(members, function(groupMember){ + pushNotify.sendNotify(groupMember, shared.i18n.t('questInvitationTitle'), shared.i18n.t('questInvitationInfo', { quest: quest.text() })); }); questStart(req,res,next); diff --git a/website/src/controllers/members.js b/website/src/controllers/members.js index 9102df985a..c7fe341d3d 100644 --- a/website/src/controllers/members.js +++ b/website/src/controllers/members.js @@ -7,6 +7,7 @@ var _ = require('lodash'); var shared = require('../../../common'); var utils = require('../utils'); var nconf = require('nconf'); +var pushNotify = require('./pushNotifications'); var fetchMember = function(uuid, restrict){ return function(cb){ @@ -72,7 +73,7 @@ api.sendPrivateMessage = function(req, res, next){ if(fetchedMember.preferences.emailNotifications.newPM !== false){ utils.txnEmail(fetchedMember, 'new-pm', [ {name: 'SENDER', content: utils.getUserInfo(res.locals.user, ['name']).name}, - {name: 'PMS_INBOX_URL', content: nconf.get('BASE_URL') + '/#/options/groups/inbox'} + {name: 'PMS_INBOX_URL', content: '/#/options/groups/inbox'} ]); } @@ -96,12 +97,18 @@ api.sendGift = function(req, res, next){ member.balance += amt; user.balance -= amt; api.sendMessage(user, member, req.body); + + var byUsername = utils.getUserInfo(user, ['name']).name; + if(member.preferences.emailNotifications.giftedGems !== false){ utils.txnEmail(member, 'gifted-gems', [ - {name: 'GIFTER', content: utils.getUserInfo(user, ['name']).name}, + {name: 'GIFTER', content: byUsername}, {name: 'X_GEMS_GIFTED', content: req.body.gems.amount} ]); } + + pushNotify.sendNotify(member, shared.i18n.t('giftedGems'), shared.i18n.t('giftedGemsInfo', { amount: req.body.gems.amount, name: byUsername })); + return async.parallel([ function (cb2) { member.save(cb2) }, function (cb2) { user.save(cb2) } diff --git a/website/src/controllers/payments/index.js b/website/src/controllers/payments/index.js index 639fe18ebf..3a86a101d9 100644 --- a/website/src/controllers/payments/index.js +++ b/website/src/controllers/payments/index.js @@ -12,6 +12,7 @@ var async = require('async'); var iap = require('./iap'); var mongoose= require('mongoose'); var cc = require('coupon-code'); +var pushNotify = require('./../pushNotifications'); function revealMysteryItems(user) { _.each(shared.content.gear.flat, function(item) { @@ -69,18 +70,26 @@ exports.createSubscription = function(data, cb) { revealMysteryItems(recipient); if(isProduction) { if (!data.gift) utils.txnEmail(data.user, 'subscription-begins'); - utils.ga.event('subscribe', data.paymentMethod).send(); + utils.ga.event('commerce', 'subscribe', data.paymentMethod, block.price).send(); utils.ga.transaction(data.user._id, block.price).item(block.price, 1, data.paymentMethod.toLowerCase() + '-subscription', data.paymentMethod).send(); + utils.mixpanel.track('purchase',{'distinct_id':data.user._id,'itemPurchased':block.key,'purchaseValue':block.price}) } data.user.purchased.txnCount++; if (data.gift){ members.sendMessage(data.user, data.gift.member, data.gift); + + var byUserName = utils.getUserInfo(data.user, ['name']).name; + if(data.gift.member.preferences.emailNotifications.giftedSubscription !== false){ utils.txnEmail(data.gift.member, 'gifted-subscription', [ - {name: 'GIFTER', content: utils.getUserInfo(data.user, ['name']).name}, + {name: 'GIFTER', content: byUserName}, {name: 'X_MONTHS_SUBSCRIPTION', content: months} ]); - } + } + + if (data.gift.member._id != data.user._id) { // Only send push notifications if sending to a user other than yourself + pushNotify.sendNotify(data.gift.member, shared.i18n.t('giftedSubscription'), months + " months - by "+ byUserName); + } } async.parallel([ function(cb2){data.user.save(cb2)}, @@ -105,7 +114,7 @@ exports.cancelSubscription = function(data, cb) { data.user.save(cb); utils.txnEmail(data.user, 'cancel-subscription'); - utils.ga.event('unsubscribe', data.paymentMethod).send(); + utils.ga.event('commerce', 'unsubscribe', data.paymentMethod).send(); } exports.buyGems = function(data, cb) { @@ -114,18 +123,26 @@ exports.buyGems = function(data, cb) { data.user.purchased.txnCount++; if(isProduction) { if (!data.gift) utils.txnEmail(data.user, 'donation'); - utils.ga.event('checkout', data.paymentMethod).send(); + utils.ga.event('commerce', 'checkout', data.paymentMethod, amt).send(); + utils.mixpanel.track('purchase',{'distinct_id':data.user._id,'itemPurchased':'Gems','purchaseValue':amt}) //TODO ga.transaction to reflect whether this is gift or self-purchase utils.ga.transaction(data.user._id, amt).item(amt, 1, data.paymentMethod.toLowerCase() + "-checkout", "Gems > " + data.paymentMethod).send(); } if (data.gift){ + var byUsername = utils.getUserInfo(data.user, ['name']).name; + var gemAmount = data.gift.gems.amount || 20; + members.sendMessage(data.user, data.gift.member, data.gift); if(data.gift.member.preferences.emailNotifications.giftedGems !== false){ utils.txnEmail(data.gift.member, 'gifted-gems', [ - {name: 'GIFTER', content: utils.getUserInfo(data.user, ['name']).name}, - {name: 'X_GEMS_GIFTED', content: data.gift.gems.amount || 20} + {name: 'GIFTER', content: byUsername}, + {name: 'X_GEMS_GIFTED', content: gemAmount} ]); } + + if (data.gift.member._id != data.user._id) { // Only send push notifications if sending to a user other than yourself + pushNotify.sendNotify(data.gift.member, shared.i18n.t('giftedGems'), gemAmount + ' Gems - by '+byUsername); + } } async.parallel([ function(cb2){data.user.save(cb2)}, @@ -153,4 +170,4 @@ exports.paypalCheckoutSuccess = paypal.executePayment; exports.paypalIPN = paypal.ipn; exports.iapAndroidVerify = iap.androidVerify; -exports.iapIosVerify = iap.iosVerify; \ No newline at end of file +exports.iapIosVerify = iap.iosVerify; diff --git a/website/src/controllers/pushNotifications.js b/website/src/controllers/pushNotifications.js new file mode 100644 index 0000000000..d0d98b5218 --- /dev/null +++ b/website/src/controllers/pushNotifications.js @@ -0,0 +1,57 @@ +var api = module.exports; +var _ = require('lodash'); +var nconf = require('nconf'); + +var pushNotify = require('push-notify'); + +var gcmApiKey = nconf.get("PUSH_CONFIGS:GCM_SERVER_API_KEY"); + +var gcm = gcmApiKey ? pushNotify.gcm({ + apiKey: gcmApiKey, + retries: 3 +}) : undefined; + +if(gcm){ + gcm.on('transmitted', function (result, message, registrationId) { + console.info("transmitted", result, message, registrationId); + }); + + gcm.on('transmissionError', function (error, message, registrationId) { + console.info("transmissionError", error, message, registrationId); + }); + gcm.on('updated', function (result, registrationId) { + console.info("updated", result, registrationId); + }); +} + +api.sendNotify = function(user, title, msg, timeToLive){ + timeToLive = timeToLive || 15; + + // need investigation: + // https://github.com/HabitRPG/habitrpg/issues/5252 + if(!user) + return; + + _.forEach(user.pushDevices, function(pushDevice){ + switch(pushDevice.type){ + case "android": + if(gcm){ + gcm.send({ + registrationId: pushDevice.regId, + //collapseKey: 'COLLAPSE_KEY', + delayWhileIdle: true, + timeToLive: timeToLive, + data: { + title: title, + message: msg + } + }); + } + + break; + + case "ios": + break; + } + }); +}; diff --git a/website/src/controllers/unsubscription.js b/website/src/controllers/unsubscription.js new file mode 100644 index 0000000000..d0ef89f920 --- /dev/null +++ b/website/src/controllers/unsubscription.js @@ -0,0 +1,36 @@ +var User = require('../models/user').model; +var EmailUnsubscription = require('../models/emailUnsubscription').model; +var utils = require('../utils'); +var i18n = require('../../../common').i18n; + +var api = module.exports = {}; + +api.unsubscribe = function(req, res, next){ + if(!req.query.code) return res.json(500, {err: 'Missing unsubscription code.'}); + + var data = JSON.parse(utils.decrypt(req.query.code)); + + if(data._id){ + User.update({_id: data._id}, { + $set: {'preferences.emailNotifications.unsubscribeFromAll': true} + }, {multi: false}, function(err, nAffected){ + if(err) return next(err); + if(nAffected !== 1) return res.json(404, {err: 'User not found'}); + + res.send('

' + i18n.t('unsubscribedSuccessfully', null, req.language) + '

' + i18n.t('unsubscribedTextUsers', null, req.language)); + }); + }else{ + EmailUnsubscription.findOne({email: data.email}, function(err, doc){ + if(err) return next(err); + var okRes = '

' + i18n.t('unsubscribedSuccessfully', null, req.language) + '

' + i18n.t('unsubscribedTextOthers', null, req.language); + + if(doc) return res.send(okRes); + + EmailUnsubscription.create({email: data.email}, function(err, doc){ + if(err) return next(err); + + res.send(okRes); + }) + }); + } +}; \ No newline at end of file diff --git a/website/src/controllers/user.js b/website/src/controllers/user.js index 5660e67d08..0fb27aef1b 100644 --- a/website/src/controllers/user.js +++ b/website/src/controllers/user.js @@ -215,6 +215,78 @@ api.getUser = function(req, res, next) { return res.json(200, user); }; +/** + * Get anonymized User + */ +api.getUserAnonymized = function(req, res, next) { + var user = res.locals.user.toJSON(); + user.stats.toNextLevel = shared.tnl(user.stats.lvl); + user.stats.maxHealth = 50; + user.stats.maxMP = res.locals.user._statsComputed.maxMP; + + delete user.apiToken; + + if (user.auth) { + delete user.auth.local; + delete user.auth.facebook; + } + + delete user.newMessages; + + delete user.profile; + delete user.purchased.plan; + delete user.contributor; + delete user.invitations; + + delete user.items.special.nyeReceived; + delete user.items.special.valentineReceived; + + delete user.webhooks; + delete user.achievements.challenges; + + _.forEach(user.inbox.messages, function(msg){ + msg.text = "inbox message text"; + }); + + _.forEach(user.tags, function(tag){ + tag.name = "tag"; + tag.challenge = "challenge"; + }); + + function cleanChecklist(task){ + var checklistIndex = 0; + + _.forEach(task.checklist, function(c){ + c.text = "item" + checklistIndex++; + }); + } + + _.forEach(user.habits, function(task){ + task.text = "task text"; + task.notes = "task notes"; + }); + + _.forEach(user.rewards, function(task){ + task.text = "task text"; + task.notes = "task notes"; + }); + + _.forEach(user.dailys, function(task){ + task.text = "task text"; + task.notes = "task notes"; + + cleanChecklist(task); + }); + + _.forEach(user.todos, function(task){ + task.text = "task text"; + task.notes = "task notes"; + + cleanChecklist(task); + }); + + return res.json(200, user); +}; /** * This tells us for which paths users can call `PUT /user` (or batch-update equiv, which use `User.set()` on our client). @@ -262,7 +334,7 @@ api.update = function(req, res, next) { api.cron = function(req, res, next) { var user = res.locals.user, - progress = user.fns.cron(), + progress = user.fns.cron({ga:ga, mixpanel:utils.mixpanel}), ranCron = user.isModified(), quest = shared.content.quests[user.party.quest.key]; diff --git a/website/src/i18n.js b/website/src/i18n.js index 271036754a..82967213b9 100644 --- a/website/src/i18n.js +++ b/website/src/i18n.js @@ -63,15 +63,28 @@ _.each(langCodes, function(code){ // used in place of plain original 'en' var defaultLangCodes = _.without(langCodes, 'en_GB'); +// A list of languages that have different versions +var multipleVersionsLanguages = ['es', 'zh']; + +var latinAmericanSpanishes = ['es-419', 'es-mx', 'es-gt', 'es-cr', 'es-pa', 'es-do', 'es-ve', 'es-co', 'es-pe', + 'es-ar', 'es-ec', 'es-cl', 'es-uy', 'es-py', 'es-bo', 'es-sv', 'es-hn', + 'es-ni', 'es-pr']; + +var chineseVersions = ['zh-tw']; + var getUserLanguage = function(req, res, next){ var getFromBrowser = function(){ var acceptable = _(req.acceptedLanguages).map(function(lang){ return lang.slice(0, 2); }).uniq().value(); + var matches = _.intersection(acceptable, defaultLangCodes); - if(matches.length > 0 && matches[0].toLowerCase() === 'es'){ + + var iAcceptedCompleteLang = (matches.length > 0) ? multipleVersionsLanguages.indexOf(matches[0].toLowerCase()) : -1; + + if(iAcceptedCompleteLang !== -1){ var acceptedCompleteLang = _.find(req.acceptedLanguages, function(accepted){ - return accepted.slice(0, 2) == 'es'; + return accepted.slice(0, 2) == multipleVersionsLanguages[iAcceptedCompleteLang]; }); if(acceptedCompleteLang){ @@ -80,11 +93,15 @@ var getUserLanguage = function(req, res, next){ return 'en'; } - var latinAmericanSpanishes = ['es-419', 'es-mx', 'es-gt', 'es-cr', 'es-pa', 'es-do', 'es-ve', 'es-co', 'es-pe', - 'es-ar', 'es-ec', 'es-cl', 'es-uy', 'es-py', 'es-bo', 'es-sv', 'es-hn', - 'es-ni', 'es-pr']; + if(matches[0] === 'es'){ + return (latinAmericanSpanishes.indexOf(acceptedCompleteLang) !== -1) ? 'es_419' : 'es'; + }else if(matches[0] === 'zh'){ + var iChinese = chineseVersions.indexOf(acceptedCompleteLang.toLowerCase()); + return (iChinese !== -1) ? chineseVersions[iChinese] : 'zh'; + }else{ + return en; + } - return (latinAmericanSpanishes.indexOf(acceptedCompleteLang) !== -1) ? 'es_419' : 'es'; }else if(matches.length > 0){ return matches[0].toLowerCase(); }else{ @@ -110,7 +127,7 @@ var getUserLanguage = function(req, res, next){ }else if(req.locals && req.locals.user){ getFromUser(req.locals.user); }else if(req.session && req.session.userId){ - User.findOne({_id: req.session.userId}, function(err, user){ + User.findOne({_id: req.session.userId}, 'preferences.language', function(err, user){ if(err) return next(err); getFromUser(user); }); diff --git a/website/src/middleware.js b/website/src/middleware.js index 34e1446be8..abd98ea048 100644 --- a/website/src/middleware.js +++ b/website/src/middleware.js @@ -198,7 +198,9 @@ module.exports.locals = function(req, res, next) { Content: shared.content, mods: require('./models/user').mods, tavern: tavern, // for world boss - worldDmg: (tavern && tavern.quest && tavern.quest.extra && tavern.quest.extra.worldDmg) || {} + worldDmg: (tavern && tavern.quest && tavern.quest.extra && tavern.quest.extra.worldDmg) || {}, + _: _, + MP_ID: nconf.get('MP_ID') }); // Put query-string party (& guild but use partyInvite for backward compatibility) diff --git a/website/src/models/emailUnsubscription.js b/website/src/models/emailUnsubscription.js new file mode 100644 index 0000000000..144417f3fc --- /dev/null +++ b/website/src/models/emailUnsubscription.js @@ -0,0 +1,14 @@ +var mongoose = require("mongoose"); +var shared = require('../../../common'); + +// A collection used to store mailing list unsubscription for non registered email addresses +var EmailUnsubscriptionSchema = new mongoose.Schema({ + _id: { + type: String, + 'default': shared.uuid + }, + email: String +}); + +module.exports.schema = EmailUnsubscriptionSchema; +module.exports.model = mongoose.model('EmailUnsubscription', EmailUnsubscriptionSchema); \ No newline at end of file diff --git a/website/src/models/user.js b/website/src/models/user.js index 5329fe0c16..634bb61f07 100644 --- a/website/src/models/user.js +++ b/website/src/models/user.js @@ -32,8 +32,10 @@ var UserSchema = new Schema({ _v: { type: Number, 'default': 0 }, achievements: { originalUser: Boolean, - helpedHabit: Boolean, - ultimateGear: Boolean, + helpedHabit: Boolean, //TODO: Deprecate this. Superseded by habitSurveys + habitSurveys: Number, + ultimateGear: Boolean, //TODO: Deprecate this. Superseded by ultimateGearSets + ultimateGearSets: Schema.Types.Mixed, beastMaster: Boolean, beastMasterCount: Number, mountMaster: Boolean, @@ -43,6 +45,7 @@ var UserSchema = new Schema({ veteran: Boolean, snowball: Number, spookDust: Number, + shinySeed: Number, streak: Number, challenges: Array, quests: Schema.Types.Mixed, @@ -118,6 +121,21 @@ var UserSchema = new Schema({ flags: { customizationsNotification: {type: Boolean, 'default': false}, showTour: {type: Boolean, 'default': true}, + tour: { + // -1 indicates "uninitiated", -2 means "complete", any other number is the current tour step (0-index) + intro: {type: Number, 'default': -1}, + classes: {type: Number, 'default': -1}, + stats: {type: Number, 'default': -1}, + tavern: {type: Number, 'default': -1}, + party: {type: Number, 'default': -1}, + guilds: {type: Number, 'default': -1}, + challenges: {type: Number, 'default': -1}, + market: {type: Number, 'default': -1}, + pets: {type: Number, 'default': -1}, + mounts: {type: Number, 'default': -1}, + hall: {type: Number, 'default': -1}, + equipment: {type: Number, 'default': -1} + }, dropsEnabled: {type: Boolean, 'default': false}, itemsEnabled: {type: Boolean, 'default': false}, newStuff: {type: Boolean, 'default': false}, @@ -133,7 +151,16 @@ var UserSchema = new Schema({ // Used to track the status of recapture emails sent to each user, // can be 0 - no email sent - 1, 2, 3 or 4 - 4 means no more email will be sent to the user recaptureEmailsPhase: {type: Number, 'default': 0}, - communityGuidelinesAccepted: {type: Boolean, 'default': false} + // Needed to track the tip to send inside the email + weeklyRecapEmailsPhase: {type: Number, 'default': 0}, + // Used to track when the next weekly recap should be sent + lastWeeklyRecap: {type: Date, 'default': Date.now}, + communityGuidelinesAccepted: {type: Boolean, 'default': false}, + cronCount: {type:Number, 'default':0}, + welcomed: {type: Boolean, 'default': false}, + armoireEnabled: {type: Boolean, 'default': false}, + armoireOpened: {type: Boolean, 'default': false}, + armoireEmpty: {type: Boolean, 'default': false} }, history: { exp: Array, // [{date: Date, value: Number}], // big peformance issues if these are defined @@ -149,12 +176,12 @@ var UserSchema = new Schema({ gear: { owned: _.transform(shared.content.gear.flat, function(m,v,k){ m[v.key] = {type: Boolean}; - if (v.key.match(/[weapon|armor|head|shield]_warrior_0/)) + if (v.key.match(/[armor|head|shield]_warrior_0/)) m[v.key]['default'] = true; }), equipped: { - weapon: {type: String, 'default': 'weapon_warrior_0'}, + weapon: String, armor: {type: String, 'default': 'armor_base_0'}, head: {type: String, 'default': 'head_base_0'}, shield: {type: String, 'default': 'shield_base_0'}, @@ -164,7 +191,7 @@ var UserSchema = new Schema({ body: String }, costume: { - weapon: {type: String, 'default': 'weapon_base_0'}, + weapon: String, armor: {type: String, 'default': 'armor_base_0'}, head: {type: String, 'default': 'head_base_0'}, shield: {type: String, 'default': 'shield_base_0'}, @@ -172,12 +199,13 @@ var UserSchema = new Schema({ headAccessory: String, eyewear: String, body: String - }, + } }, special:{ snowball: {type: Number, 'default': 0}, spookDust: {type: Number, 'default': 0}, + shinySeed: {type: Number, 'default': 0}, valentine: Number, valentineReceived: Array, // array of strings, by sender name nye: Number, @@ -297,12 +325,14 @@ var UserSchema = new Schema({ advancedCollapsed: {type: Boolean, 'default': false}, toolbarCollapsed: {type:Boolean, 'default':false}, background: String, + displayInviteToPartyWhenPartyIs1: { type:Boolean, 'default':true}, webhooks: {type: Schema.Types.Mixed, 'default': {}}, // For this fields make sure to use strict comparison when searching for falsey values (=== false) // As users who didn't login after these were introduced may have them undefined/null emailNotifications: { unsubscribeFromAll: {type: Boolean, 'default': false}, newPM: {type: Boolean, 'default': true}, + kickedGroup: {type: Boolean, 'default': true}, wonChallenge: {type: Boolean, 'default': true}, giftedGems: {type: Boolean, 'default': true}, giftedSubscription: {type: Boolean, 'default': true}, @@ -312,7 +342,8 @@ var UserSchema = new Schema({ invitedQuest: {type: Boolean, 'default': true}, //remindersToLogin: {type: Boolean, 'default': true}, // Those importantAnnouncements are in fact the recapture emails - importantAnnouncements: {type: Boolean, 'default': true} + importantAnnouncements: {type: Boolean, 'default': true}, + weeklyRecaps: {type: Boolean, 'default': true} } }, profile: { @@ -342,7 +373,8 @@ var UserSchema = new Schema({ stealth: {type: Number, 'default': 0}, streaks: {type: Boolean, 'default': false}, snowball: {type: Boolean, 'default': false}, - spookDust: {type: Boolean, 'default': false} + spookDust: {type: Boolean, 'default': false}, + shinySeed: {type: Boolean, 'default': false} }, training: { int: {type: Number, 'default': 0}, @@ -373,7 +405,12 @@ var UserSchema = new Schema({ todos: {type:[TaskSchemas.TodoSchema]}, rewards: {type:[TaskSchemas.RewardSchema]}, - extra: Schema.Types.Mixed + extra: Schema.Types.Mixed, + + pushDevices: {type: [{ + regId: {type: String}, + type: {type: String} + }],'default': []} }, { strict: true, @@ -422,7 +459,9 @@ UserSchema.pre('save', function(next) { newTask.name = newTask.name(self.preferences.language); }else{ newTask.text = newTask.text(self.preferences.language); - newTask.notes = newTask.notes(self.preferences.language); + if(newTask.notes) { + newTask.notes = newTask.notes(self.preferences.language); + } if(newTask.checklist){ newTask.checklist = _.map(newTask.checklist, function(checklistItem){ diff --git a/website/src/routes/apiv2.coffee b/website/src/routes/apiv2.coffee index 479521d054..947979c8c2 100644 --- a/website/src/routes/apiv2.coffee +++ b/website/src/routes/apiv2.coffee @@ -35,13 +35,13 @@ module.exports = (swagger, v2) -> '/status': spec: - description: "Returns the status of the server (up or down)" + description: "Returns the status of the server (up or down). Does not require authentication." action: (req, res) -> res.json status: "up" '/content': spec: - description: "Get all available content objects. This is essential, since Habit often depends on item keys (eg, when purchasing a weapon)." + description: "Get all available content objects. This is essential, since Habit often depends on item keys (eg, when purchasing a weapon). Does not require authentication." parameters: [ query("language","Optional language to use for content's strings. Default is english.","string") ] @@ -49,7 +49,7 @@ module.exports = (swagger, v2) -> '/content/paths': spec: - description: "Show user model tree" + description: "Show user model tree. Does not require authentication." action: user.getModelPaths "/export/history": @@ -68,7 +68,7 @@ module.exports = (swagger, v2) -> "/user/tasks/{id}/{direction}": spec: #notes: "Simple scoring of a task." - description: "Simple scoring of a task. This is most-likely the only API route you'll be using as a 3rd-party developer. The most common operation is for the user to gain or lose points based on some action (browsing Reddit, running a mile, 1 Pomodor, etc). Call this route, if the task you're trying to score doesn't exist, it will be created for you. When random events occur, the user._tmp variable will be filled. Critical hits can be accessed through user._tmp.crit. The Streakbonus can be accessed through user._tmp.streakBonus. Both will contain the multiplier value. When random drops occur, the following values are available: user._tmp.drop = {text,type,dialog,value,key,notes}" + description: "Simple scoring of a task (Habit, Daily, To-Do, or Reward). This is most-likely the only API route you'll be using as a 3rd-party developer. The most common operation is for the user to gain or lose points based on some action (browsing Reddit, running a mile, 1 Pomodor, etc). Call this route, if the task you're trying to score doesn't exist, it will be created for you. When random events occur, the user._tmp variable will be filled. Critical hits can be accessed through user._tmp.crit. The Streakbonus can be accessed through user._tmp.streakBonus. Both will contain the multiplier value. When random drops occur, the following values are available: user._tmp.drop = {text,type,dialog,value,key,notes}" parameters: [ path("id", "ID of the task to score. If this task doesn't exist, a task will be created automatically", "string") path("direction", "Either 'up' or 'down'", "string") @@ -227,6 +227,11 @@ module.exports = (swagger, v2) -> description: "Get the full user object" action: user.getUser + "/user/anonymized": + spec: + description: "Get the user object without any personal data" + action: user.getUserAnonymized + "/user:PUT": spec: path: '/user' @@ -396,6 +401,16 @@ module.exports = (swagger, v2) -> ] action: user.deleteWebhook + # Push Notifications + "/user/pushDevice": + spec: + method: 'POST' + description: 'Add a new push devices registration ID' + parameters: [ + body '','New push registration { regId: "123123", type: "android"}','object' + ] + action: user.addPushDevice + # --------------------------------- # Groups # --------------------------------- @@ -688,6 +703,7 @@ module.exports = (swagger, v2) -> path: '/challenges/{cid}' description: 'Get a challenge' parameters: [path('cid','Challenge id','string')] + middleware: [auth.auth, i18n.getUserLanguage] action: challenges.get "/challenges/{cid}/csv": diff --git a/website/src/routes/unsubscription.js b/website/src/routes/unsubscription.js new file mode 100644 index 0000000000..efd06f9197 --- /dev/null +++ b/website/src/routes/unsubscription.js @@ -0,0 +1,8 @@ +var express = require('express'); +var router = new express.Router(); +var i18n = require('../i18n'); +var unsubscription = require('../controllers/unsubscription'); + +router.get('/unsubscribe', i18n.getUserLanguage, unsubscription.unsubscribe); + +module.exports = router; \ No newline at end of file diff --git a/website/src/server.js b/website/src/server.js index 1c3484d776..1447823a4d 100644 --- a/website/src/server.js +++ b/website/src/server.js @@ -127,6 +127,7 @@ if (cores!==0 && cluster.isMaster && (isDev || isProd)) { app.use(require('./routes/payments').middleware); app.use(require('./routes/auth').middleware); app.use(require('./routes/coupon').middleware); + app.use(require('./routes/unsubscription').middleware); var v2 = express(); app.use('/api/v2', v2); app.use('/api/v1', require('./routes/apiv1').middleware); diff --git a/website/src/utils.js b/website/src/utils.js index 81ffca3f29..beb093e28e 100644 --- a/website/src/utils.js +++ b/website/src/utils.js @@ -37,13 +37,17 @@ function getUserInfo(user, fields) { } if(fields.indexOf('email') != -1){ - if(user.auth.local){ + if(user.auth.local && user.auth.local.email){ info.email = user.auth.local.email; }else if(user.auth.facebook && user.auth.facebook.emails && user.auth.facebook.emails[0] && user.auth.facebook.emails[0].value){ info.email = user.auth.facebook.emails[0].value; } } + if(fields.indexOf('_id') != -1){ + info._id = user._id; + } + if(fields.indexOf('canSend') != -1){ info.canSend = user.preferences.emailNotifications.unsubscribeFromAll !== true; } @@ -53,23 +57,70 @@ function getUserInfo(user, fields) { module.exports.getUserInfo = getUserInfo; -module.exports.txnEmail = function(mailingInfoArray, emailType, variables){ +module.exports.txnEmail = function(mailingInfoArray, emailType, variables, personalVariables){ var mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray]; + var variables = [ {name: 'BASE_URL', content: baseUrl} ].concat(variables || []); // It's important to pass at least a user with its `preferences` as we need to check if he unsubscribed mailingInfoArray = mailingInfoArray.map(function(mailingInfo){ - return mailingInfo._id ? getUserInfo(mailingInfo, ['email', 'name', 'canSend']) : mailingInfo; + return mailingInfo._id ? getUserInfo(mailingInfo, ['_id', 'email', 'name', 'canSend']) : mailingInfo; }).filter(function(mailingInfo){ - return (mailingInfo.email && mailingInfo.canSend); + // Always send reset-password emails + // Don't check canSend for non registered users as already checked before + return (mailingInfo.email && ((!mailingInfo._id || mailingInfo.canSend) || emailType === 'reset-password')); }); - // When only one recipient send his info as variables - if(mailingInfoArray.length === 1 && mailingInfoArray[0].name){ - variables.push({name: 'RECIPIENT_NAME', content: mailingInfoArray[0].name}); - } + // Personal variables are personal to each email recipient, if they are missing + // we manually create a structure for them with RECIPIENT_NAME and RECIPIENT_UNSUB_URL + // otherwise we just add RECIPIENT_NAME and RECIPIENT_UNSUB_URL to the existing personal variables + if(!personalVariables || personalVariables.length === 0){ + personalVariables = mailingInfoArray.map(function(mailingInfo){ + return { + rcpt: mailingInfo.email, + vars: [ + { + name: 'RECIPIENT_NAME', + content: mailingInfo.name + }, + { + name: 'RECIPIENT_UNSUB_URL', + content: '/unsubscribe?code=' + module.exports.encrypt(JSON.stringify({ + _id: mailingInfo._id, + email: mailingInfo.email + })) + } + ] + } + }); + }else{ + var temporaryPersonalVariables = {}; + + mailingInfoArray.forEach(function(mailingInfo){ + temporaryPersonalVariables[mailingInfo.email] = { + name: mailingInfo.name, + _id: mailingInfo._id + } + }); + + personalVariables.forEach(function(singlePersonalVariables){ + singlePersonalVariables.vars.push( + { + name: 'RECIPIENT_NAME', + content: temporaryPersonalVariables[singlePersonalVariables.rcpt].name + }, + { + name: 'RECIPIENT_UNSUB_URL', + content: '/unsubscribe?code=' + module.exports.encrypt(JSON.stringify({ + _id: temporaryPersonalVariables[singlePersonalVariables.rcpt]._id, + email: singlePersonalVariables.rcpt + })) + } + ) + }); + } if(isProd && mailingInfoArray.length > 0){ request({ @@ -84,9 +135,11 @@ module.exports.txnEmail = function(mailingInfoArray, emailType, variables){ data: { emailType: emailType, to: mailingInfoArray, - variables: variables + variables: variables, + personalVariables: personalVariables }, options: { + priority: 'high', attempts: 5, backoff: {delay: 10*60*1000, type: 'fixed'} } @@ -126,6 +179,11 @@ module.exports.setupConfig = function(){ baseUrl = nconf.get('BASE_URL'); module.exports.ga = require('universal-analytics')(nconf.get('GA_ID')); + + var mixpanel = isProd && require('mixpanel'); + module.exports.mixpanel = mixpanel + ? mixpanel.init(nconf.get('MP_ID')) + : { track: function() {} }; }; var algorithm = 'aes-256-ctr'; diff --git a/website/views/index.jade b/website/views/index.jade index 8c93d28e04..cf70ebccdf 100644 --- a/website/views/index.jade +++ b/website/views/index.jade @@ -21,6 +21,11 @@ html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":a script(type='text/javascript'). window.env = !{JSON.stringify(env)}; + script(type='text/javascript'). + (function(f,b){if(!b.__SV){var a,e,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); + for(g=0;g", linkEnd: ""}) .popover-content p!=env.t('seasonalShopClosedText', {linkStart:"", linkEnd: ""}) - // br - .well(ng-if='User.user.achievements.rebirths > 0')=env.t('seasonalShopRebirth') - li.customize-menu.inventory-gear - menu.pets-menu(label='{{::label}}', ng-repeat='(set,label) in ::{candycane:env.t("candycaneSet"), ski:env.t("skiSet"), snowflake:env.t("snowflakeSet"), yeti:env.t("yetiSet")}') + // .well(ng-if='User.user.achievements.rebirths > 0')=env.t('seasonalShopRebirth') + // li.customize-menu.inventory-gear + menu.pets-menu(label='{{::label}}', ng-repeat='(set,label) in ::{springWarrior:env.t("mightyBunnySet"), springMage:env.t("magicMouseSet"), springHealer:env.t("lovingPupSet"), springRogue:env.t("stealthyKittySet")}') // The `if true || false` conditional for applying the transparent class is necessary because - // when a user activates the orb of rebirth, the seasonal items are still in their inventory, but + // when a user activates the orb of rebirth, the seasonal items are still in their inventory, but // they have each have a value of false. The item can be purchased for gold in the rewards column, // not the seasonal shop. This makes that more clear. div(ng-repeat='item in ::getSeasonalShopArray(set)' ng-class="{transparent: user.items.gear.owned[item.key] === true ||user.items.gear.owned[item.key] === false}") button.customize-option(popover='{{::item.notes()}}', popover-title='{{::item.text()}}', popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', ng-click='purchase(item.type,item)', class='shop_{{::item.key}}') - .text-center + .text-left | {{((item.specialClass == "wizard") && (item.type == "weapon")) + 1}}  span.Pet_Currency_Gem1x.inline-gems menu.pets-menu(label=env.t('quests')) @@ -51,6 +55,11 @@ script(type='text/ng-template', id='partials/options.inventory.seasonalshop.html span.Pet_Currency_Gem1x.inline-gems menu.pets-menu(label=env.t('seasonalItems')) div + button.customize-option(popover='{{::Content.spells.special.shinySeed.notes()}}', popover-title='{{::Content.spells.special.shinySeed.text()}}', popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', ng-click='purchase("special", Content.spells.special.shinySeed)', class='inventory_special_shinySeed') + p + | {{::Content.spells.special.shinySeed.value}} + span(class='shop_gold') + // div button.customize-option(popover='{{::Content.spells.special.snowball.notes()}}', popover-title='{{::Content.spells.special.snowball.text()}}', popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', ng-click='purchase("special", Content.spells.special.snowball)', class='inventory_special_snowball') p | {{::Content.spells.special.snowball.value}} @@ -139,13 +148,14 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html') .badge.badge-info.stack-count {{user.items.special.#{k}}} +specialItem('snowball') +specialItem('spookDust') + +specialItem('shinySeed') div(ng-if='user.items.special.valentineReceived[0]') button.customize-option(popover="Valentine's Day Card from {{User.user.items.special.valentineReceived[0]}}", popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', ng-click='openModal("valentine")', class='inventory_special_valentine') .badge.badge-info.stack-count {{user.items.special.valentineReceived.length}} div(ng-if='user.purchased.plan.customerId || user.purchased.plan.mysteryItems.length') - button.customize-option(popover=env.t('subscriberItemText'), popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', class='inventory_present', ng-click="user.ops.openMysteryItem({})") + button.customize-option(popover=env.t('subscriberItemText'), popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', class='inventory_present inventory_present_{{moment().format("MM")}}', ng-click="user.ops.openMysteryItem({})") .badge.badge-info.stack-count {{user.purchased.plan.mysteryItems.length}} div(ng-if='user.purchased.plan.consecutive.trinkets') @@ -177,13 +187,14 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html') menu.inventory-list(type='list') li.customize-menu menu.pets-menu(label=env.t('eggs')) + p.muted!=env.t('dropsExplanation') div(ng-repeat='egg in Content.eggs', ng-if='egg.canBuy') button.customize-option(popover='{{::egg.notes()}}', popover-title!=env.t("egg", {eggType: "{{::egg.text()}}"}), popover-trigger='mouseenter', popover-placement='top', popover-append-to-body='true', ng-click='purchase("eggs", egg)', class='Pet_Egg_{{::egg.key}}') p | {{::egg.value}}  span.Pet_Currency_Gem1x.inline-gems - //- buyable quest eggs - each egg,quest in {gryphon:'Gryphon',hedgehog:'Hedgehog',ghost_stag:'Deer',rat:'Rat',octopus:'Octopus',dilatory_derby:'Seahorse',harpy:'Parrot',rooster:'Rooster',spider:'Spider',owl:'Owl',penguin:'Penguin',rock:'Rock'} + //- buyable quest eggs. TODO: Get this from a collection so we don't have to maintain this ridiculous comma-delimited list + each egg,quest in {gryphon:'Gryphon',hedgehog:'Hedgehog',ghost_stag:'Deer',rat:'Rat',octopus:'Octopus',dilatory_derby:'Seahorse',harpy:'Parrot',rooster:'Rooster',spider:'Spider',owl:'Owl',penguin:'Penguin',rock:'Rock',bunny:'Bunny',slime:'Slime',sheep:'Sheep'} div(ng-show='user.achievements.quests.#{quest} > 0') button.customize-option(popover='{{::Content.eggs.#{egg}.notes()}}', popover-title!=env.t("egg", {eggType: "{{::Content.eggs.#{egg}.text()}}"}), popover-trigger='mouseenter', popover-placement='top', popover-append-to-body='true', ng-click='purchase("eggs", Content.eggs.#{egg})', class='Pet_Egg_#{egg}') p @@ -197,6 +208,7 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html') li.customize-menu menu.pets-menu(label=env.t('hatchingPotions')) + p.muted!=env.t('dropsExplanation') div(ng-repeat='pot in Content.hatchingPotions') button.customize-option(popover='{{::pot.notes()}}', popover-title!=env.t("potion", {potionType: "{{::pot.text()}}"}), popover-trigger='mouseenter', popover-placement='top', popover-append-to-body='true', ng-click='purchase("hatchingPotions", pot)', class='Pet_HatchingPotion_{{::pot.key}}') p @@ -205,6 +217,7 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html') li.customize-menu menu.pets-menu(label=env.t('food')) + p.muted!=env.t('dropsExplanation') div(ng-repeat='food in Content.food', ng-if='food.canBuy') button.customize-option(popover='{{::food.notes()}}', popover-title='{{::food.text()}}', popover-trigger='mouseenter', popover-placement='top', popover-append-to-body='true', ng-click='purchase("food", food)', class='Pet_Food_{{::food.key}}') p @@ -234,7 +247,7 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html') span.Pet_Currency_Gem1x.inline-gems div(ng-show='petCount >= 90 || mountCount >= 90') button.customize-option(popover=env.t('petKeyPop'), popover-title=env.t('petKeyName'), popover-trigger='mouseenter', popover-placement='top', popover-append-to-body='true', ng-click='openModal("pet-key", {size:"lg"})', class='pet_key') - p + p(ng-show='petCount < 90 || mountCount < 90 || !user.achievements.triadBingo') | 4  span.Pet_Currency_Gem1x.inline-gems div(ng-if='user.purchased.plan.customerId', ng-class='::{transparent:(Shared.planGemLimits.convCap + User.user.purchased.plan.consecutive.gemCapExtra - User.user.purchased.plan.gemsBought) < 1}') @@ -248,4 +261,4 @@ script(type='text/ng-template', id='partials/options.inventory.drops.html') button.customize-option(popover='{{::Content.spells.special.valentine.notes()}}', popover-title='{{::Content.spells.special.valentine.text()}}', popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', ng-click='castStart(Content.spells.special.valentine)', class='inventory_special_valentine') p | {{Content.spells.special.valentine.value}} - span(class='shop_gold') \ No newline at end of file + span(class='shop_gold') diff --git a/website/views/options/inventory/stable.jade b/website/views/options/inventory/stable.jade index 27bc3f8ef0..83c448d4f1 100644 --- a/website/views/options/inventory/stable.jade +++ b/website/views/options/inventory/stable.jade @@ -7,7 +7,7 @@ mixin petList(source) - pet = egg.key+"-"+potion.key div(popover-trigger='mouseenter', popover=env.t('petName', {potion: potion.text(env.language.code), egg: egg.text(env.language.code)}), popover-placement='bottom') button(class="pet-button Pet-#{pet}", ng-if='user.items.pets["#{pet}"]>0', ng-class='{active: user.items.currentPet == "#{pet}", selectableInventory: #{!egg.noMount} && selectedFood && !user.items.mounts["#{pet}"]}', ng-click='choosePet("#{egg.key}", "#{potion.key}")') - .progress(ng-show='!user.items.mounts["#{pet}"] && "#{egg.key}"!="Egg"') + .progress(ng-show='!user.items.mounts["#{pet}"]') .progress-bar.progress-bar-success(style='width:{{user.items.pets["#{pet}"]/.5}}%') button(class="pet-button pet-not-owned", ng-if='!user.items.pets["#{pet}"]') .PixelPaw @@ -24,7 +24,7 @@ mixin mountList(source) div(popover-trigger='mouseenter', popover=env.t('mountName', {potion: potion.text(env.language.code), mount: egg.mountText(env.language.code)}), popover-placement='bottom') button(class="pet-button Mount_Head_#{mount}", ng-show='user.items.mounts["#{mount}"]', ng-class='{active: user.items.currentMount == "#{mount}"}', ng-click='chooseMount("#{egg.key}", "#{potion.key}")') //div(class='Mount_Head_{{mount}}') - button(class="pet-button pet-not-owned", ng-hide='user.items.mounts["#{mount}"]') + button(class="pet-button mount-not-owned", ng-hide='user.items.mounts["#{mount}"]') .PixelPaw -} diff --git a/website/views/options/profile.jade b/website/views/options/profile.jade index 1ab07efe1b..d7d9731502 100644 --- a/website/views/options/profile.jade +++ b/website/views/options/profile.jade @@ -4,6 +4,7 @@ mixin gemCost(cost) = ' ' + env.t('locked') block +-var gearGroup = function(grouping) { return env._(env.Content.gear.flat).where({gearSet:grouping}).pluck('key') } -var showPath = function(path, items, joiner) { return path+'["'+items.join('"] '+joiner+' '+path+'["')+'"]'; } -var unlockPath = function(path, items) { return 'unlock("'+path+'.'+items.join(','+path+'.')+'")'; } @@ -19,7 +20,7 @@ mixin customizeProfile(mobile) +gemCost(2) button.btn.btn-xs(ng-click='#{unlockPath(path, colors)}')!= env.t('unlockSet',{cost:5}) + ' ' each color in colors - button.customize-option(type='button', class='#{path=="skin" ? "skin_"+color : "customize-option hair hair_bangs_1_"+color}', ng-class='{locked: !user.purchased.#{path}["#{color}"]}', ng-if='#{status!="disabled"} || user.purchased.#{path}["#{color}"]', ng-click='unlock("#{path}.#{color}")') + button.customize-option(type='button', class='#{path=="skin" ? "skin_"+color : "customize-option hair hair_bangs_1_"+color}', ng-class='{locked: !user.purchased.#{path}["#{color}"], selectableInventory: user.preferences.#{path} == "#{color}"}', ng-if='#{status!="disabled"} || user.purchased.#{path}["#{color}"]', ng-click='unlock("#{path}.#{color}")') div(class=mobile ? 'padding' : 'container-fluid row') .col-md-4 @@ -35,7 +36,7 @@ mixin customizeProfile(mobile) li.customize-menu menu(label=env.t('shirts')) each shirt in ['black', 'blue', 'green', 'pink', 'white', 'yellow'] - button.customize-option(class='{{user.preferences.size}}_shirt_'+shirt, type='button', ng-click='set({"preferences.shirt":"'+shirt+'"})') + button.customize-option(class='{{user.preferences.size}}_shirt_'+shirt, type='button', ng-click='set({"preferences.shirt":"'+shirt+'"})', ng-class='{selectableInventory: user.preferences.shirt == "#{shirt}"}') menu(label=env.t('specialShirts')) - var specialShirts = ['convict', 'cross', 'fire', 'horizon', 'ocean', 'purple', 'rainbow', 'redblue', 'thunder', 'tropical', 'zombie'] @@ -43,25 +44,42 @@ mixin customizeProfile(mobile) +gemCost(2) button.btn.btn-xs(ng-click='#{unlockPath("shirt",specialShirts)}')!= env.t('unlockSet',{cost:5}) + ' ' each shirt in specialShirts - button.customize-option(type='button', class='{{user.preferences.size}}_shirt_'+shirt, ng-class='{locked: !user.purchased.shirt.'+shirt+'}', ng-click='unlock("shirt.'+shirt+'")') + button.customize-option(type='button', class='{{user.preferences.size}}_shirt_'+shirt, ng-class='{locked: !user.purchased.shirt.'+shirt+', selectableInventory: user.preferences.shirt == "#{shirt}"}', ng-click='unlock("shirt.'+shirt+'")') + h3(class=mobile?'item item-divider':'')=env.t('accessories') + + menu(type='list') + // Flower + li.customize-menu + menu(label=env.t('flower')) + button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.flower":0})', ng-class='{selectableInventory: user.preferences.hair.flower == 0}') + each num in [1,2,3,4,5,6] + button(class='hair_flower_#{num} customize-option', type='button', ng-click='set({"preferences.hair.flower":#{num}})', ng-class='{selectableInventory: user.preferences.hair.flower == "#{num}"}') + + // Animal Ears + li.customize-menu + menu(label=env.t('animalEars')) + span(ng-hide='#{showPath("user.items.gear.owned", gearGroup("animal"), "&&")}') + +gemCost(2) + button.btn.btn-xs(ng-click='#{unlockPath("items.gear.owned", gearGroup("animal"))}')!= env.t('unlockSet', {cost: 5}) + ' ' + button.customize-option(ng-repeat='item in ::getGearArray("animal")' ng-class="{locked: user.items.gear.owned[item.key] == undefined, selectableInventory: user.preferences.costume ? user.items.gear.costume.headAccessory == item.key : user.items.gear.equipped.headAccessory == item.key}", popover='{{::item.notes()}}', popover-title='{{::item.text()}}', popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true', ng-click='purchase(item.type,item)', class='{{::item.key}}') .col-md-4 h3(class=mobile?'item item-divider':'')=env.t('bodyHead') menu(type='list') // For special events code, see commit dfa27b3 - // Color li.customize-menu menu(label=env.t('color')) each color in ['white','brown','blond','red','black'] - button(type='button', class='#{path=="skin" ? "skin_"+color : "customize-option hair hair_bangs_1_"+color}', ng-click='set({"preferences.hair.color": "#{color}"})') + button(type='button', class='#{path=="skin" ? "skin_"+color : "customize-option hair hair_bangs_1_"+color}', ng-click='set({"preferences.hair.color": "#{color}"})', ng-class='{selectableInventory: user.preferences.hair.color == "#{color}"}') each color in ['candycane','frost','winternight','holly'] - button(type='button', ng-if='user.purchased.hair.color.#{color}', class='customize-option hair hair_bangs_1_#{color}', ng-click='unlock("hair.color.#{color}")') + button(type='button', ng-if='user.purchased.hair.color.#{color}', class='customize-option hair hair_bangs_1_#{color}', ng-click='unlock("hair.color.#{color}")', ng-class='{selectableInventory: user.preferences.hair.color == "#{color}"}') each color in ['pblue','pgreen','porange','ppink','ppurple','pyellow'] - button(type='button', ng-if='user.purchased.hair.color.#{color}', class='customize-option hair hair_bangs_1_#{color}', ng-click='unlock("hair.color.#{color}")') + button(type='button', ng-if='user.purchased.hair.color.#{color}', class='customize-option hair hair_bangs_1_#{color}', ng-click='unlock("hair.color.#{color}")', ng-class='{selectableInventory: user.preferences.hair.color == "#{color}"}') +buyPref('hair.color', ['rainbow','yellow','green','purple','blue','TRUred'], 'rainbowColors') + +buyPref('hair.color', ['pblue2','pgreen2','porange2','ppink2','ppurple2','pyellow2'], 'shimmerColors', 'disabled') +buyPref('hair.color', ['candycorn','ghostwhite','halloween','midnight','pumpkin','zombie'], 'hauntedColors', 'disabled') +buyPref('hair.color', ['aurora','festive','hollygreen','peppermint','snowy','winterstar'], 'winteryColors', 'disabled') @@ -70,15 +88,15 @@ mixin customizeProfile(mobile) // Bangs menu(label=env.t('hairBangs')) - button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.bangs":0})') + button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.bangs":0})', ng-class='{selectableInventory: user.preferences.hair.bangs == 0}') each num in [1,2,3] - button(class='hair_bangs_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-click='set({"preferences.hair.bangs":#{num}})') + button(class='hair_bangs_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-click='set({"preferences.hair.bangs":#{num}})', ng-class='{selectableInventory: user.preferences.hair.bangs == "#{num}"}') // Base hairstyles (free) menu(label=env.t('hairBase')) - button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.base":0})') + button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.base":0})', ng-class='{selectableInventory: user.preferences.hair.base == 0}') each num in [1,3] - button(class='hair_base_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-click='set({"preferences.hair.base":#{num}})') + button(class='hair_base_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-click='set({"preferences.hair.base":#{num}})', ng-class='{selectableInventory: user.preferences.hair.base == "#{num}"}') // Purchasable hairstyles menu(label=env.t('hairSet1')) @@ -87,22 +105,14 @@ mixin customizeProfile(mobile) +gemCost(2) button.btn.btn-xs(ng-click='#{unlockPath("hair.base",styles)}')!= env.t('unlockSet',{cost:5}) + ' ' each num in styles - button(class='hair_base_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.base["#{num}"]}', ng-click='unlock("hair.base.#{num}")') + button(class='hair_base_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.base["#{num}"], selectableInventory: user.preferences.hair.base == "#{num}"}', ng-click='unlock("hair.base.#{num}")') menu(label=env.t('hairSet2')) - var styles = [9,10,11,12,13,14] span(ng-hide='#{showPath("user.purchased.hair.base", styles, "&&")}') +gemCost(2) button.btn.btn-xs(ng-click='#{unlockPath("hair.base", styles)}')!= env.t('unlockSet', {cost: 5}) + ' ' each num in styles - button(class='hair_base_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.base["#{num}"]}', ng-click='unlock("hair.base.#{num}")') - - - // Flower - li.customize-menu - menu(label=env.t('flower')) - button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.flower":0})') - each num in [1,2,3,4,5,6] - button(class='hair_flower_#{num} customize-option', type='button', ng-click='set({"preferences.hair.flower":#{num}})') + button(class='hair_base_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.base["#{num}"], selectableInventory: user.preferences.hair.base == "#{num}"}', ng-click='unlock("hair.base.#{num}")') li.customize-menu menu(label=env.t('bodyFacialHair')) @@ -112,15 +122,15 @@ mixin customizeProfile(mobile) // Beard menu(label=env.t('beard')) - button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.beard":0})') + button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.beard":0})', ng-class='{selectableInventory: user.preferences.hair.beard == 0}') each num in [1,2,3] - button(class='hair_beard_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.beard["#{num}"]}', ng-click='unlock("hair.beard.#{num}")') + button(class='hair_beard_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.beard["#{num}"], selectableInventory: user.preferences.hair.beard == "#{num}"}', ng-click='unlock("hair.beard.#{num}")') // Mustache menu(label=env.t('mustache')) - button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.mustache":0})') + button(class='head_0 customize-option', type='button', ng-click='set({"preferences.hair.mustache":0})', ng-class='{selectableInventory: user.preferences.hair.mustache == 0}') each num in [1,2] - button(class='hair_mustache_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.mustache["#{num}"]}', ng-click='unlock("hair.mustache.#{num}")') + button(class='hair_mustache_#{num}_{{user.preferences.hair.color}} customize-option', type='button', ng-class='{locked: !user.purchased.hair.mustache["#{num}"], selectableInventory: user.preferences.hair.mustache == "#{num}"}', ng-click='unlock("hair.mustache.#{num}")') .col-md-4 h3(class=mobile?'item item-divider':'')=env.t('bodySkin') @@ -129,12 +139,14 @@ mixin customizeProfile(mobile) li.customize-menu menu(label=env.t('basicSkins')) each color in ['ddc994','f5a76e','ea8349','c06534','98461a','915533','c3e1dc','6bd049'] - button.customize-option(type='button', class='skin_#{color}', ng-click='set({"preferences.skin":"#{color}"})') + button.customize-option(type='button', class='skin_#{color}', ng-click='set({"preferences.skin":"#{color}"})', ng-class='{selectableInventory: user.preferences.skin == "#{color}"}') - // Rainbow Skin + // Always-available premium skins +buyPref('skin', ['eb052b','f69922','f5d70f','0ff591','2b43f6','d7a9f7','800ed0','rainbow'], 'rainbowSkins') + +buyPref('skin', ['bear','cactus','fox','lion','panda','pig','tiger','wolf'], 'animalSkins') - // Special Events + // Seasonal event skins. Note that Spooky Skins are a legacy set and should always be disabled for purchase + +buyPref('skin', ['pastelPink','pastelOrange','pastelYellow','pastelGreen','pastelBlue','pastelPurple','pastelRainbowChevron','pastelRainbowDiagonal'], 'pastelSkins', 'disabled') +buyPref('skin', ['monster','pumpkin','skeleton','zombie','ghost','shadow'], 'spookySkins', 'disabled') +buyPref('skin', ['candycorn','ogre','pumpkin2','reptile','shadow2','skeleton2','transparent','zombie2'], 'supernaturalSkins', 'disabled') @@ -159,9 +171,11 @@ mixin profileStats table.table.table-striped tr td - strong.inline - |{{user.stats.points}}  - strong.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('levelPopover'))=env.t('unallocated') + p(ng-if='::user.stats.lvl >= 100')!=env.t('noMoreAllocate') + p(ng-if='user.stats.points || user.stats.lvl < 100') + strong.inline + |{{user.stats.points}}  + strong.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('levelPopover'))=env.t('unallocated') td tr td(colspan=2) @@ -256,7 +270,7 @@ script(id='partials/options.profile.profile.html', type='text/ng-template') input.form-control(type='url', ng-model='editingProfile.imageUrl', placeholder=env.t('imageUrl')) .form-group label=env.t('displayBlurb') - textarea.form-control(rows=5, placeholder=env.t('displayBlurb'), ng-model='editingProfile.blurb') + textarea.form-control(rows=5, placeholder=env.t('displayBlurbPlaceholder'), ng-model='editingProfile.blurb') include ../shared/formatting-help mixin backgrounds(mobile) diff --git a/website/views/options/settings.jade b/website/views/options/settings.jade index 92eeaadce9..053efa17da 100644 --- a/website/views/options/settings.jade +++ b/website/views/options/settings.jade @@ -2,16 +2,16 @@ script(id='partials/options.settings.html', type="text/ng-template") ul.options-menu li(ng-class="{ active: $state.includes('options.settings.settings') }") a(ui-sref='options.settings.settings') - =env.t('settings') + =env.t('site') li(ng-class="{ active: $state.includes('options.settings.api') }") a(ui-sref='options.settings.api') =env.t('API') li(ng-class="{ active: $state.includes('options.settings.export') }") a(ui-sref='options.settings.export') =env.t('dataExport') - li(ng-class="{ active: $state.includes('options.settings.coupon') }") - a(ui-sref='options.settings.coupon') - =env.t('coupon') + li(ng-class="{ active: $state.includes('options.settings.promo') }") + a(ui-sref='options.settings.promo') + =env.t('promoCode') li(ng-class="{ active: $state.includes('options.settings.subscription') }") a(ui-sref='options.settings.subscription')=env.t('subscription') li(ng-class="{ active: $state.includes('options.settings.notifications') }") @@ -66,25 +66,25 @@ script(type='text/ng-template', id='partials/options.settings.settings.html') label input(type='checkbox', ng-model='user.preferences.dailyDueDefaultView', ng-change='set({"preferences.dailyDueDefaultView": user.preferences.dailyDueDefaultView?true: false})') span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('dailyDueDefaultViewPop'))=env.t('dailyDueDefaultView') - button.btn.btn-default(ng-click='showTour()', popover-placement='right', popover-trigger='mouseenter', popover=env.t('restartTour'))= env.t('showTour') + .checkbox(ng-if='party.memberCount === 1') + label + input(type='checkbox', ng-model='user.preferences.displayInviteToPartyWhenPartyIs1', ng-change='set({"preferences.displayInviteToPartyWhenPartyIs1": user.preferences.displayInviteToPartyWhenPartyIs1 ? true : false})') + span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('displayInviteToPartyWhenPartyIs1'))=env.t('displayInviteToPartyWhenPartyIs1') + // button.btn.btn-default(ng-click='showTour()', popover-placement='right', popover-trigger='mouseenter', popover=env.t('restartTour'))= env.t('showTour') button.btn.btn-default(ng-click='showBailey()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('showBaileyPop'))= env.t('showBailey') button.btn.btn-default(ng-click='openRestoreModal()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('fixValPop'))= env.t('fixVal') - button.btn.btn-default(ng-click="openModal('invite-friends', {controller:'GroupsCtrl'})") Invite Friends button.btn.btn-default(ng-if='user.preferences.disableClasses==true', ng-click='user.ops.changeClass({})', popover-trigger='mouseenter', popover-placement='right', popover=env.t('enableClassPop'))= env.t('enableClass') button.btn.btn-default(ng-if='!user.preferences.disableClasses && user.flags.classSelected', ng-click='showClassesTour()', popover-trigger='mouseenter', popover-placement='right', popover=env.t('classTourPop'))= env.t('showClass') div.alert.alert-warning(style='padding:2px;margin-top:7px') - h5.hint(popover=env.t('clockInfo'), popover-trigger='mouseenter')=env.t('customDayStart') + h5=env.t('customDayStart') + h5=env.t('customDayStartInfo1') + a(ng-click='showCustomDayStartInfo = !showCustomDayStartInfo') {{!showCustomDayStartInfo ? env.t('customDayStartInfo2') : env.t('customDayStartInfo3')}} + h5(ng-if='showCustomDayStartInfo')!=env.t('customDayStartInfo4') .form-group .input-group input.form-control(type='number', min='0', max='23', ng-model='user.preferences.dayStart', ng-blur='saveDayStart()') span.input-group-addon= ':00 (' + env.t('24HrClock') + ')' - small - =env.t('subWarning1') - |  - a(href='https://github.com/HabitRPG/habitrpg/issues/1057' target='_blank')=env.t('subWarning2') - |  - =env.t('subWarning3') .personal-options.col-md-6 .panel.panel-default @@ -158,14 +158,14 @@ script(type='text/ng-template', id='partials/options.settings.settings.html') a.btn.btn-danger(ng-click='openModal("reset", {controller:"SettingsCtrl"})', popover-trigger='mouseenter', popover-placement='right', popover=env.t('resetAccPop'))= env.t('resetAccount') a.btn.btn-danger(ng-click='openModal("delete", {controller:"SettingsCtrl"})', popover-trigger='mouseenter', popover=env.t('deleteAccPop'))= env.t('deleteAccount') -script(type='text/ng-template', id='partials/options.settings.coupon.html') +script(type='text/ng-template', id='partials/options.settings.promo.html') .container-fluid .row .col-md-6 - h2= env.t('coupon') + h2=env.t('promoCode') form.form-inline(role='form',ng-submit='enterCoupon(_couponCode)') - input.form-control(type='text', ng-model='_couponCode', placeholder=env.t('couponPlaceholder')) - button.btn.btn-primary(type='submit') Submit + input.form-control(type='text', ng-model='_couponCode', placeholder=env.t('promoPlaceholder')) + button.btn.btn-primary(type='submit')= env.t('submit') div small= env.t('couponText') div(ng-if='user.contributor.sudo') @@ -238,9 +238,6 @@ script(id='partials/options.settings.export.html', type="text/ng-template") mixin subPerks() table.table.table-striped - tr - td - span.hint(popover=env.t('disableAdsText'),popover-trigger='mouseenter',popover-placement='right')=env.t('disableAds') tr td span.hint(popover=env.t('buyGemsGoldText', {gemCost: "{{Shared.planGemLimits.convRate}}", gemLimit: "{{Shared.planGemLimits.convCap}}"}),popover-trigger='mouseenter',popover-placement='right') #{env.t('buyGemsGold')}  @@ -305,6 +302,11 @@ script(id='partials/options.settings.notifications.html', type="text/ng-template input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.invitedGuild', ng-change='set({"preferences.emailNotifications.invitedGuild": user.preferences.emailNotifications.invitedGuild ? true: false})') span=env.t('invitedGuild') + .checkbox + label + input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.kickedGroup', ng-change='set({"preferences.emailNotifications.kickedGroup": user.preferences.emailNotifications.kickedGroup ? true: false})') + span=env.t('kickedGroup') + .checkbox label input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.questStarted', ng-change='set({"preferences.emailNotifications.questStarted": user.preferences.emailNotifications.questStarted ? true: false})') @@ -326,6 +328,11 @@ script(id='partials/options.settings.notifications.html', type="text/ng-template input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.importantAnnouncements', ng-change='set({"preferences.emailNotifications.importantAnnouncements": user.preferences.emailNotifications.importantAnnouncements ? true: false})') span=env.t('inactivityEmails') + .checkbox + label + input(type='checkbox', ng-disabled='user.preferences.emailNotifications.unsubscribeFromAll === true', ng-model='user.preferences.emailNotifications.weeklyRecaps', ng-change='set({"preferences.emailNotifications.weeklyRecaps": user.preferences.emailNotifications.weeklyRecaps ? true: false})') + span=env.t('weeklyRecaps') + hr .checkbox @@ -375,12 +382,12 @@ script(id='partials/options.settings.subscription.html',type='text/ng-template') .form-inline .form-group - input.form-control(type='text', ng-model='_subscription.coupon', placeholder='Promo Code') + input.form-control(type='text', ng-model='_subscription.coupon', placeholder= env.t('couponPlaceholder')) .form-group - button.btn.btn-small(type='button',ng-click='applyCoupon(_subscription.coupon)') Apply + button.btn.btn-small(type='button',ng-click='applyCoupon(_subscription.coupon)')= env.t("apply") - h3(ng-if='(user.purchased.plan.customerId && user.purchased.plan.dateTerminated)') Resubscribe - a.btn.btn-primary(ng-click='Payments.showStripe({subscription:_subscription.key, coupon:_subscription.coupon})', ng-disabled='!_subscription.key') Card + h3(ng-if='(user.purchased.plan.customerId && user.purchased.plan.dateTerminated)')= env.t("resubscribe") + a.btn.btn-primary(ng-click='Payments.showStripe({subscription:_subscription.key, coupon:_subscription.coupon})', ng-disabled='!_subscription.key')= env.t('card') a.btn.btn-warning(href='/paypal/subscribe?_id={{user._id}}&apiToken={{user.apiToken}}&sub={{_subscription.key}}{{_subscription.coupon ? "&coupon="+_subscription.coupon : ""}}', ng-disabled='!_subscription.key') PayPal div(ng-if='user.purchased.plan.customerId') .btn.btn-primary(ng-if='!user.purchased.plan.dateTerminated && user.purchased.plan.paymentMethod=="Stripe"', ng-click='Payments.showStripeEdit()')=env.t('subUpdateCard') diff --git a/website/views/options/social/boss.jade b/website/views/options/social/boss.jade index 87194da9a1..1574f648e8 100644 --- a/website/views/options/social/boss.jade +++ b/website/views/options/social/boss.jade @@ -73,7 +73,7 @@ mixin boss(tavern, mobile) div(ng-bind-html='::Content.quests[group.quest.key].notes()') unless tavern hr - h5=env.t('participants') + h5=env.t('questParticipants') table.table.table-striped tr(ng-repeat='(k,v) in group.members', ng-if='::group.quest.members[v._id]') td diff --git a/website/views/options/social/challenge-box.jade b/website/views/options/social/challenge-box.jade index 57085c820b..f3013b5e46 100644 --- a/website/views/options/social/challenge-box.jade +++ b/website/views/options/social/challenge-box.jade @@ -3,7 +3,7 @@ .panel-heading h3.panel-title=env.t('challenges') |  - a.pull-right(target='_blank', href='https://trello.com/card/challenges-individual-party-guild-public/50e5d3684fe3a7266b0036d6/58') + a.pull-right(target='_blank', href='http://habitrpg.wikia.com/wiki/Challenges') small=env.t('moreInfo') .panel-body.modal-fixed-height(bindonce='group.challenges') div(ng-if='group.challenges.length > 0') diff --git a/website/views/options/social/challenges.jade b/website/views/options/social/challenges.jade index 3707c4f0d8..b2e0d2c1a4 100644 --- a/website/views/options/social/challenges.jade +++ b/website/views/options/social/challenges.jade @@ -1,12 +1,12 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.close.html') a.btn.btn-sm.btn-danger(ng-click="delete(closingChal)")=env.t('delete') h5= '- ' + env.t('or') + ' -' - select(ui-select2, ng-required=true, ng-model='closingChal.winner', data-placeholder=env.t('selectWinner'), ng-change='selectWinner(closingChal)', ) + select(ui-select2, ng-required=true, ng-model='closingChal.winner', data-placeholder=env.t('selectWinner'), ng-change='selectWinner(closingChal)', style='display:block') option(value='') option(ng-repeat='u in closingChal.members', value='{{u._id}}') {{u.profile.name}} - small.pull-right - a(ng-click='cancelClosing(closingChal)')=env.t('cancel') + .text-right + small.btn-link(ng-click='cancelClosing(closingChal)')=env.t('cancel') script(type='text/ng-template', id='partials/options.social.challenges.detail.member.html') .modal.bs-modal-lg(style='display: block') @@ -22,9 +22,9 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.me script(type='text/ng-template', id='partials/options.social.challenges.detail.html') // Edit button - div(bindonce='challenge', ng-if='challenge.leader==user._id') + div(bindonce='challenge', ng-if='challenge.leader._id==user._id') div(ng-hide='challenge._locked==false') - button.btn.btn-sm.btn-default(ng-click='challenge._locked = false')=env.t('edit') + button.btn.btn-sm.btn-default(ng-click='edit(challenge)')=env.t('edit') button.btn.btn-sm.btn-warning(ng-click='close(challenge, $event)', tooltip=env.t('deleteOrSelect'))=env.t('endChallenge') form(ng-show='challenge._locked==false') @@ -67,7 +67,7 @@ script(type='text/ng-template', id='partials/options.social.challenges.html') .container-fluid .row .col-md-2 - .well#challenges-filters + .well#challenges-filters(ng-hide="cid") h3=env.t('filter') + ':' h4=env.t('groups') ul.list-unstyled @@ -92,13 +92,14 @@ script(type='text/ng-template', id='partials/options.social.challenges.html') input(type='radio', name='search-participation-radio', ng-click='search._isMember = undefined', checked='checked') =env.t('either') .col-md-10 + a.btn.btn-info#back-to-challenges(ng-show="cid", ui-sref='options.social.challenges', ui-sref-opts='{reload: true}') + | Back to all challenges // Creation form button.btn.btn-success#create-challenge-btn(ng-click='create()', ng-hide='newChallenge')=env.t('createChallenge') .create-challenge-from.well(ng-if='newChallenge') form(ng-submit='save(newChallenge)') div input.btn.btn-success(type='submit', value=env.t('save')) - input.btn.btn-default(type='button', ng-click='openModal()', value='Invite to challenge') input.btn.btn-danger(type='button', ng-click='discard()', value=env.t('discard')) select(ng-model='newChallenge.group', ng-required='required', name='Group', ng-options='g._id as g.name for g in groups') .challenge-options @@ -114,17 +115,14 @@ script(type='text/ng-template', id='partials/options.social.challenges.html') .form-group textarea.form-control(cols='3', placeholder=env.t('challengeDescr'), ng-model='newChallenge.description') - //- what's going on here? - br - br - .form-group - input.form-control(type='number', min="{{newChallenge.group=='habitrpg' ? 1 : 0}}", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder=env.t('prize')) - span.input-suffix.Pet_Currency_Gem1x.inline-gems - |  - span.hint.vertical-20(popover=env.t('prizePop'), popover-trigger='mouseenter', popover-placement='right') + .input-group + span.input-group-addon + .Pet_Currency_Gem1x + input.form-control(type='number', min="{{newChallenge.group=='habitrpg' ? 1 : 0}}", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder=env.t('prize')) + a.hint(popover="{{newChallenge.group=='habitrpg' ? env.t('prizePopTavern') : env.t('prizePop')}}", popover-trigger='mouseenter', popover-placement='right') =env.t('moreInfo') - span(ng-show='newChallenge.group=="habitrpg"') + .pull-right(ng-show='newChallenge.group=="habitrpg"') !=env.t('publicChallenges') .form-group(ng-if='user.contributor.admin') @@ -142,13 +140,16 @@ script(type='text/ng-template', id='partials/options.social.challenges.html') ul.pull-right.challenge-accordion-header-specs li.bg-transparent(ng-if='challenge.official') span.label.label-success=env.t('officialChallenge') - li {{challenge.group.name}} + li + a(ui-sref="options.social.guilds.detail({gid:challenge.group._id})" ng-if="challenge.group.type=='guild'") + | {{challenge.group.name}} + a(ui-sref="options.social.party" ng-if="challenge.group.type=='party'") + | {{challenge.group.name}} li =env.t('by') + ' ' - strong {{challenge.leader.profile.name}} + a(ng-click='clickMember(challenge.leader._id, true)') {{challenge.leader.profile.name}} li - | {{challenge.memberCount}} - = ' ' + env.t('participants') + =env.t('participants', {membercount: "{{challenge.memberCount}}"}) li(ng-show='challenge.prize') p // prize @@ -164,7 +165,7 @@ script(type='text/ng-template', id='partials/options.social.challenges.html') a.btn.btn-sm.btn-success(ng-hide='challenge._isMember', ng-click='join(challenge)') span.glyphicon.glyphicon-ok =env.t('join') - a.accordion-toggle(ng-click='toggle(challenge._id)') {{challenge.name}} + a.accordion-toggle(id="{{challenge._id}}" ng-click='toggle(challenge._id)') {{challenge.name}} .panel-body(ng-class='{collapse: !$stateParams.cid == challenge._id}') .accordion-inner(ng-if='$stateParams.cid == challenge._id') div(ui-view) diff --git a/website/views/options/social/chat-box.jade b/website/views/options/social/chat-box.jade index c30dc9184e..bb0c8a5c25 100644 --- a/website/views/options/social/chat-box.jade +++ b/website/views/options/social/chat-box.jade @@ -7,19 +7,17 @@ div.chat-form.guidelines-not-accepted(ng-if='!user.flags.communityGuidelinesAcce div button.btn.btn-warning(ng-click='acceptCommunityGuidelines()')=env.t('iAcceptCommunityGuidelines') .chat-buttons - button(type="button", ng-click='sync(group)', tooltip=env.t('toolTipMsg')) - span.glyphicon.glyphicon-refresh + button(type="button", ng-click='sync(group)')=env.t('toolTipMsg') form.chat-form(ng-if='user.flags.communityGuidelinesAccepted' ng-submit='postChat(group,message.content)') div(ng-controller='AutocompleteCtrl') - textarea.form-control(rows=4, ui-keydown='{"meta-enter":"postChat(group,message.content)"}', ui-keypress='{13:"postChat(group,message.content)"}', ng-model='message.content', updateinterval='250', flag='@', at-user, auto-complete placeholder="{{group._id == 'habitrpg' ? env.t('tavernCommunityGuidelinesPlaceholder') : ''}}") - span.user-list(ng-show='!isAtListHidden') - ul.list-at-user - li(ng-repeat='user in response | filter:query.text | limitTo: 5', ng-click='autoComplete(user)') - span.username.label.label-default(ng-class=':: userLevelStyle(user)') {{::user.user}} - .chat-controls - .chat-formatting - include ../../shared/formatting-help + textarea.form-control(rows=4, ui-keydown='{"meta-enter":"postChat(group,message.content)"}', ui-keypress='{13:"postChat(group,message.content)"}', ng-model='message.content', updateinterval='250', flag='@', at-user, auto-complete placeholder="{{group._id == 'habitrpg' ? env.t('tavernCommunityGuidelinesPlaceholder') : ''}}", ng-disabled='_sending == true') + span.user-list + ul.list-at-user(ng-show="query") + li(ng-repeat='msg in response | filter:filterUser | limitTo: 5', ng-click='performCompletion(msg)') + span.username.label.label-default(ng-class=':: userLevelStyle(msg)') {{::msg.user}} + .chat-controls.clearfix .chat-buttons - input(type='submit', value=env.t('sendChat'), ng-class='{disabled: _sending == true}') - button(type="button", ng-click='sync(group)')=env.t('toolTipMsg') + input.btn(type='submit', value=env.t('sendChat'), ng-disabled='_sending') + button.btn(type="button", ng-click='sync(group)', ng-disabled='_sending')=env.t('toolTipMsg') + include ../../shared/formatting-help diff --git a/website/views/options/social/chat-message.jade b/website/views/options/social/chat-message.jade index 48c6d85e7f..944088faa4 100644 --- a/website/views/options/social/chat-message.jade +++ b/website/views/options/social/chat-message.jade @@ -31,6 +31,9 @@ mixin chatMessages(inbox) |     a(ng-click="flagChatMessage(group._id, message)", ng-if=':: user.contributor.admin || (!message.sent && user.flags.communityGuidelinesAccepted && message.uuid != user.id && message.uuid != "system")') span.glyphicon.glyphicon-flag(tooltip="{{message.flags[user._id] ? env.t('abuseAlreadyReported') : env.t('abuseFlag')}}" ng-class='message.flags[user._id] ? "text-danger" : ""') + |     + a(ng-click="copyToDo(message)") + span.glyphicon.glyphicon-share(tooltip=env.t('copyMessageAsToDo')) span.float-label(ng-class='::contribText(message.contributor, message.backer).length > 30 ? "long-title" : ""') a.label.label-default.chat-message(ng-if=':: message.user', ng-class='::userLevelStyleFromLevel(message.contributor.level, message.backer.npc, style)', ng-click='clickMember(message.uuid, true)') span.glyphicon.glyphicon-arrow-right(ng-if='::message.sent') diff --git a/website/views/options/social/create-group.jade b/website/views/options/social/create-group.jade index 6c0c4c20e8..846bd99837 100644 --- a/website/views/options/social/create-group.jade +++ b/website/views/options/social/create-group.jade @@ -23,6 +23,6 @@ form.col-md-12.form-horizontal(ng-submit='create(newGroup)') .checkbox label input(type='checkbox', ng-model='newGroup.leaderOnly.challenges') - | Only group leader can create challenges + =env.t('leaderOnlyChallenges') .form-group(ng-show='type=="party"') input.btn.btn-default.form-control(type='submit', value=env.t('create')) diff --git a/website/views/options/social/group.jade b/website/views/options/social/group.jade index 8c27edfa80..0765bcd7d7 100644 --- a/website/views/options/social/group.jade +++ b/website/views/options/social/group.jade @@ -17,11 +17,14 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter .panel-heading(bindonce='group') h3.panel-title | {{group.name}} - span(ng-if='group') + span.group-leave-join(ng-if='group') + a.btn.btn-sm.btn-danger.pull-right(ng-if=":: isMemberOfGroup(User.user._id, group)", ng-click='clickLeave(group, $event)') + span.glyphicon.glyphicon-ban-circle + =env.t('leave') a.btn.btn-success.pull-right(ng-if=':: !isMemberOfGroup(User.user._id, group)', ng-click='join(group)')=env.t('join') - span(ng-if='group.leader == user.id') - button.btn.btn-primary.pull-right(ng-click='save(group)', ng-show='group._editing')=env.t('save') - button.btn.btn-default.pull-right(ng-click='group._editing = true', ng-hide='group._editing')=env.t('editGroup') + span(ng-if='group.leader._id == user.id') + button.btn.btn-sm.btn-primary.pull-right(ng-click='save(group)', ng-show='group._editing')=env.t('save') + button.btn.btn-sm.btn-default.pull-right(ng-click='group._editing = true', ng-hide='group._editing')=env.t('editGroup') .panel-body form(ng-show='group._editing') @@ -39,7 +42,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter .checkbox label input(type='checkbox', ng-model='group.leaderOnly.challenges') - | Only group leader can create challenges + =env.t('leaderOnlyChallenges') h4=env.t('assignLeader') select#group-leader-selection(ng-model='group._newLeader', ng-options='member.profile.name for member in group.members') @@ -48,7 +51,13 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter img.pull-right(ng-show='group.logo', ng-src='{{group.logo}}') markdown(text='group.description') hr - small.muted Group ID: {{group._id}} + p=env.t('groupLeader') + |: + a(class='badge badge-info', ng-click='clickMember(group.leader._id, true)') + | {{group.leader.profile.name}} + .slight-vertical-padding + small.muted=env.t('groupID') + |: {{group._id}} include ./challenge-box @@ -57,7 +66,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter .panel-heading h3.panel-title =env.t('members') - button.pull-right.btn.btn-primary(ng-click="openInviteModal(group)") Invite Friends + button.pull-right.btn.btn-primary(ng-click="openInviteModal(group)")=env.t("inviteFriends") .panel-body.modal-fixed-height div.form-group(ng-if='::group.type=="party"') p=env.t('partyList') @@ -75,14 +84,14 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter ng-change='set({"party.orderAscending": user.party.orderAscending})' ) table.table.table-striped(bindonce='group') - tr(ng-repeat='member in group.members track by member._id') + tr(ng-repeat='member in group.members track by member._id' ng-if='member._id != group.leader._id') td.media // allow leaders to ban members - div.pull-left(ng-show='group.leader == user.id && user.id!=member._id') + div.pull-left(ng-show='group.leader._id == user.id') a.media-object(ng-click='removeMember(group, member, true)') span.glyphicon.glyphicon-ban-circle(tooltip=env.t('banTip')) a.media-body - span(ng-class='{"badge badge-info": group.leader==member._id}', ng-click='clickMember(member._id, true)') + span(ng-click='clickMember(member._id, true)') | {{member.profile.name}} tr(ng-if='group.memberCount > group.members.length') td @@ -95,7 +104,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter tr(ng-repeat='invite in group.invites') td.media // allow leaders to ban members - div.pull-left(ng-show='group.leader == user.id') + div.pull-left(ng-show='group.leader._id == user.id') a.media-object(ng-click='removeMember(group, invite, false)') span.glyphicon.glyphicon-ban-circle(tooltip=env.t('banTip')) a.media-body @@ -114,7 +123,7 @@ a.pull-right.gem-wallet(ng-if='group.type!="party"', popover-trigger='mouseenter td .popover.static-popover.fade.right.in.wide-popover .arrow - h3.popover-title {{Members.members[group.leader].profile.name}} + h3.popover-title {{group.leader.profile.name}} .popover-content markdown(text='group.leaderMessage') div(ng-controller='ChatCtrl') diff --git a/website/views/options/social/hall.jade b/website/views/options/social/hall.jade index 26d95ed179..cb7489a8f7 100644 --- a/website/views/options/social/hall.jade +++ b/website/views/options/social/hall.jade @@ -41,11 +41,6 @@ script(type='text/ng-template', id='partials/options.social.hall.heroes.html') label=env.t('balance') input.form-control(type='number', step="any", ng-model='hero.balance') small!= '`user.balance`' + env.t('notGems') - .form-group - .checkbox - label - input(type='checkbox', ng-model='hero.purchased.ads') - =env.t('hideAds') accordion accordion-group(heading='Items') h4 Update Item @@ -89,7 +84,7 @@ script(type='text/ng-template', id='partials/options.social.hall.heroes.html') span(ng-class='userAdminGlyphiconStyle(hero)') span(ng-if='!hero.contributor.admin') a.label.label-default(ng-class='userLevelStyle(hero)', ng-click='clickMember(hero._id, true)') {{hero.profile.name}} - td(ng-if='user.contributor.admin') {{hero._id}} + td(ng-if='user.contributor.admin', ng-click='populateContributorInput(hero._id)').btn-link {{hero._id}} td {{hero.contributor.level}} td {{hero.contributor.text}} td diff --git a/website/views/options/social/index.jade b/website/views/options/social/index.jade index ead6e5965b..a965b5d1d3 100644 --- a/website/views/options/social/index.jade +++ b/website/views/options/social/index.jade @@ -10,14 +10,15 @@ script(type='text/ng-template', id='partials/options.social.inbox.html') .container-fluid .row .col-md-12 - +chatMessages('inbox') .form-inline - a.btn.btn-xs.btn-danger(popover=env.t('clearAllPopover'), popover-trigger='mouseenter', ng-click='user.ops.clearPMs({})', popover-placement='right')=env.t('clearAll') + a.btn.btn-xs.btn-danger(ng-click='deleteAllMessages()')=env.t('clearAll') + |       .checkbox label input(type='checkbox', ng-model='user.inbox.optOut', ng-change='set({"inbox.optOut": user.inbox.optOut?true: false})') |   span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('optOutPopover'))=env.t('optOut') + +chatMessages('inbox') script(type='text/ng-template', id='partials/options.social.tavern.html') include ./tavern @@ -90,9 +91,9 @@ script(type='text/ng-template', id='partials/options.social.html') ul.options-menu li(ng-class="{ active: $state.includes('options.social.inbox') }") a(ui-sref='options.social.inbox') - =env.t("inbox") - |   span.badge.badge-danger(ng-if='user.inbox.newMessages') {{user.inbox.newMessages}} + |   + =env.t("inbox") li(ng-class="{ active: $state.includes('options.social.tavern') }") a(ui-sref='options.social.tavern') =env.t('tavern') @@ -103,7 +104,7 @@ script(type='text/ng-template', id='partials/options.social.html') a(ui-sref='options.social.guilds.public') =env.t('guilds') li(ng-class="{ active: $state.includes('options.social.challenges') }") - a(ui-sref='options.social.challenges') + a(ui-sref='options.social.challenges', ui-sref-opts='{reload: true}') =env.t('challenges') li(ng-class="{ active: $state.includes('options.social.hall') }") a(ui-sref='options.social.hall.heroes') @@ -112,3 +113,33 @@ script(type='text/ng-template', id='partials/options.social.html') .tab-content .tab-pane.active div(ui-view) + +script(type='text/ng-template', id='modals/copyChatToDo.html') + .modal-header + h4=env.t('copyMessageAsToDo') + .modal-body + .form-group + input.form-control(type='text',ng-model='text', ng-model-options="{debounce: 1000}") + .form-group + textarea.form-control(rows='5',ng-model='notes', ng-model-options="{debounce: 1000}", focus-me) + + hr + + div.task-column.preview + div(ng-init='popoverOpen = false', class='task todo uncompleted color-neutral', popover-trigger='mouseenter', data-popover-html="{{popoverOpen ? '' : notes | markdown}}", popover-placement="top") + // right-hand side control buttons + .task-meta-controls + // Icons only available if you own the tasks (aka, hidden from challenge stats) + span(ng-if='!obj._locked') + // notes + span.task-notes(ng-show='notes', ng-click='popoverOpen = !popoverOpen', popover-trigger='click', data-popover-html="{{notes | markdown}}", popover-placement="top") + span.glyphicon.glyphicon-comment + |   + + // main content + div.task-text + markdown(text='text',target='_blank') + + .modal-footer + button.btn.btn-default(ng-click='$close()')=env.t('close') + button.btn.btn-primary(ng-click='saveTodo()')=env.t('submit') \ No newline at end of file diff --git a/website/views/options/social/tavern.jade b/website/views/options/social/tavern.jade index b77e66d060..bfe065697a 100644 --- a/website/views/options/social/tavern.jade +++ b/website/views/options/social/tavern.jade @@ -14,14 +14,11 @@ h3.popover-title a(target='_blank', href='http://www.kickstarter.com/profile/2014640723')=env.t('daniel') .popover-content - =env.t('danielText') - div - button.btn.btn-lg.btn-success(ng-class='{active: user.preferences.sleep}', ng-click='User.user.ops.sleep({})') - span(ng-show='user.preferences.sleep')=env.t('innCheckOut') - span(ng-hide='user.preferences.sleep')=env.t('innCheckIn') - =env.t('danielText2') - .alert.alert-info(ng-show='user.preferences.sleep') - =env.t('innText',{name:"{{user.profile.name}}"}) + | {{user.preferences.sleep ? env.t('innText',{name: user.profile.name}) : env.t('danielText')}} + button.btn-block.btn.btn-lg.btn-success(ng-click='User.user.ops.sleep({})') + | {{user.preferences.sleep ? env.t('innCheckOut') : env.t('innCheckIn')}} + span(ng-if='!user.preferences.sleep')=env.t('danielText2') + // Resources .panel.panel-default @@ -116,7 +113,7 @@ a.label.label-contributor-6(ng-click='toggleUserTier($event)')=env.t('tier') + ' 6 (' + env.t('champion') + ')' div p - div(class='Pet-Dragon-Hydra pull-left') + span.shop-sprite.item-img(class='Pet-Dragon-Hydra') !=env.t('championSixth') tr td diff --git a/website/views/shared/footer.jade b/website/views/shared/footer.jade index 746d4d1958..caacfd09f4 100644 --- a/website/views/shared/footer.jade +++ b/website/views/shared/footer.jade @@ -77,9 +77,11 @@ footer.footer(ng-controller='FooterCtrl') h4 Debug .btn-group-vertical a.btn.btn-default(ng-click='setHealthLow()') Health = 1 - a.btn.btn-default(ng-click='addMissedDay()') +1 Missed Day + a.btn.btn-default(ng-click='addMissedDay(1)') +1 Missed Day + a.btn.btn-default(ng-click='addMissedDay(2)') +2 Missed Days a.btn.btn-default(ng-click='addTenGems()') +10 Gems a.btn.btn-default(ng-click='addGold()') +GP + a.btn.btn-default(ng-click='addMana()') +MP a.btn.btn-default(ng-click='addLevelsAndGold()') +Exp +GP +MP a.btn.btn-default(ng-click='addOneLevel()') +1 Level a.btn.btn-default(ng-click='addBossQuestProgressUp()') +1000 Boss Quest Progress Up diff --git a/website/views/shared/formatting-help.jade b/website/views/shared/formatting-help.jade index 80ef0633df..9ad945093e 100644 --- a/website/views/shared/formatting-help.jade +++ b/website/views/shared/formatting-help.jade @@ -1,2 +1,36 @@ -small - a(target='_blank', href='http://habitrpg.wikia.com/wiki/Markdown_Cheat_Sheet')=env.t('formattingMarkdown') \ No newline at end of file +small.btn-link(ng-init='showHelp = false', ng-click='showHelp = !showHelp') + | {{showHelp ? env.t('hideFormattingHelp') : env.t('showFormattingHelp')}} + +.slight-vertical-padding(ng-if='showHelp') + table.table.table-striped + tr.info + td.col-xs-6 #[b=env.t('youType')] + td.col-xs-6 #[b=env.t('youSee')] + tr + td=env.t('italics') + td #[markdown(text="env.t('italics')")] + tr + td=env.t('bold') + td #[markdown(text="env.t('bold')")] + tr + td=env.t('strikethrough') + td #[markdown(text="env.t('strikethrough')")] + tr + td=env.t('emojiExample') + td #[markdown(text="env.t('emojiExample')")] + tr + td=env.t('markdownLinkEx') + td #[markdown(text="env.t('markdownLinkEx')")] + tr + td=env.t('markdownImageEx') + td #[markdown(text="env.t('markdownImageEx')")] + tr + td!=env.t('unorderedListHTML') + td #[markdown(text="env.t('unorderedListMarkdown')")] + tr + td=env.t('code') + td #[markdown(text="env.t('code')")] + + hr + p.text-center.muted!=env.t('markdownBlurb') + hr diff --git a/website/views/shared/header/avatar.jade b/website/views/shared/header/avatar.jade index 75692866ff..5c770b06f2 100644 --- a/website/views/shared/header/avatar.jade +++ b/website/views/shared/header/avatar.jade @@ -17,7 +17,10 @@ mixin avatar(opts) span.snowman span(ng-if='profile.stats.buffs.spookDust') span.spookman - span(ng-if='!profile.stats.buffs.snowball && !profile.stats.buffs.spookDust') + span(ng-if='profile.stats.buffs.shinySeed') + span(class='avatar_floral_{{profile.stats.class}}') + span(ng-if='!profile.stats.buffs.snowball && !profile.stats.buffs.spookDust && !profile.stats.buffs.shinySeed') + // Back Accessory span(class='{{profile.items.gear.equipped.back}}', ng-if='!profile.preferences.costume') span(class='{{profile.items.gear.costume.back}}', ng-if='profile.preferences.costume') @@ -34,8 +37,8 @@ mixin avatar(opts) span(class='{{profile.preferences.size}}_{{profile.items.gear.costume.armor}}', ng-if='profile.preferences.costume') //- Cape collar - span(class='{{profile.items.gear.equipped.back}}_collar', ng-if='!profile.preferences.costume') - span(class='{{profile.items.gear.costume.back}}_collar', ng-if='profile.preferences.costume') + span(class='{{profile.items.gear.equipped.back}}_collar', ng-if='!profile.preferences.costume') + span(class='{{profile.items.gear.costume.back}}_collar', ng-if='profile.preferences.costume') // Body span(class='{{profile.items.gear.equipped.body}}', ng-if='!profile.preferences.costume') diff --git a/website/views/shared/header/header.jade b/website/views/shared/header/header.jade index 001081b729..3fe3006e56 100644 --- a/website/views/shared/header/header.jade +++ b/website/views/shared/header/header.jade @@ -10,27 +10,30 @@ .meter-label(tooltip=env.t('health')) span.glyphicon.glyphicon-heart .meter.health(tooltip='{{Math.round(user.stats.hp * 100) / 100}}') - .bar(style='width: {{Shared.percent(user.stats.hp, 50)}}%;') + .bar(ng-style='{"width": Shared.percent(user.stats.hp, 50)+"%"}') span.meter-text.value | {{Math.ceil(user.stats.hp)}} / 50 .meter-label(tooltip=env.t('experience')) span.glyphicon.glyphicon-star .meter.experience(tooltip='{{Math.round(user.stats.exp * 100) / 100}}') - .bar(style='width: {{Shared.percent(user.stats.exp,Shared.tnl(user.stats.lvl))}}%;') + .bar(ng-style='{"width": Shared.percent(user.stats.exp,Shared.tnl(user.stats.lvl))+"%"}') span.meter-text.value span(ng-show='user.history.exp', tooltip=env.t('progress')) - a(ng-click='toggleChart("exp")').glyphicon.glyphicon-signal + a(ng-click='toggleChart("exp")').glyphicon.glyphicon-signal span | {{Math.floor(user.stats.exp) | number:0}} / {{Shared.tnl(user.stats.lvl) | number:0}} .meter-label(tooltip='Mana', ng-if='user.flags.classSelected && !user.preferences.disableClasses') span.glyphicon.glyphicon-fire .meter.mana(ng-if='user.flags.classSelected && !user.preferences.disableClasses', tooltip='{{Math.round(user.stats.mp * 100) / 100}}') - .bar(style='width: {{user.stats.mp / user._statsComputed.maxMP * 100}}%;') + .bar(ng-style='{"width": (user.stats.mp / user._statsComputed.maxMP * 100) + "%"}') span.meter-text.value span | {{Math.floor(user.stats.mp)}} / {{user._statsComputed.maxMP}} // party span(ng-controller='PartyCtrl') + button.party-invite.pull-right.btn.btn-primary(ng-click="inviteOrStartParty(group)", + ng-if="(!party.members || party.memberCount === 1) && user.preferences.displayInviteToPartyWhenPartyIs1", + popover="{{!party.members ? env.t('startAParty') : env.t('addToParty')}}", popover-placement="left", popover-trigger="mouseenter")=env.t("inviteFriends") .herobox-wrap(ng-repeat='profile in partyMinusSelf') +herobox() diff --git a/website/views/shared/header/menu.jade b/website/views/shared/header/menu.jade index cd7a08b00f..ebfdd6a6ff 100644 --- a/website/views/shared/header/menu.jade +++ b/website/views/shared/header/menu.jade @@ -7,7 +7,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') ul.toolbar-mobile-nav li.toolbar-mobile a(ng-click='expandMenu("mobile")', ng-class='{active: _expandedMenu=="mobile"}') - span ☰ + span.glyphicon.glyphicon-align-justify div(ng-if='_expandedMenu=="mobile"', ng-click='expandMenu(null)') h4=env.t('menu') div @@ -26,9 +26,8 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') ul.toolbar-submenu li a(ui-sref='options.social.inbox') + span.badge.badge-danger(ng-if='user.inbox.newMessages') {{user.inbox.newMessages}}   =env.t("inbox") - |   - span.badge.badge-danger(ng-if='user.inbox.newMessages') {{user.inbox.newMessages}} li a(ui-sref='options.social.tavern')=env.t('tavern') li @@ -59,7 +58,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') a(ui-sref='options.settings.export')=env.t('exportData') ul.toolbar-submenu li - a(target="_blank" href='http://habitrpg.wikia.com/wiki/FAQ')=env.t('FAQ') + a(target="_blank" href='http://habitrpg.wikia.com/wiki/')=env.t('overview') li a(target="_blank" href='https://github.com/HabitRPG/habitrpg/issues/2760')=env.t('reportBug') li @@ -69,7 +68,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') li a(target="_blank" href='http://habitrpg.wikia.com/wiki/Contributing_to_HabitRPG')=env.t('contributeToHRPG') li - a(target="_blank" href='http://habitrpg.wikia.com/wiki/')=env.t('overview') + a(target="_blank" href='http://habitrpg.wikia.com/wiki/FAQ')=env.t('FAQ') ul.toolbar-controls li.toolbar-subscribe-button button(ng-if='!user.purchased.plan.customerId',ui-sref='options.settings.subscription',popover-trigger='mouseenter',popover-placement='bottom',popover-title=env.t('subscriptions'),popover=env.t('subDescription'),popover-append-to-body='true')=env.t('subscribe') @@ -95,18 +94,18 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') li a(ui-sref='options.profile.profile')=env.t('profile') li.toolbar-button-dropdown + a(ui-sref='options.social.inbox', ng-if='user.inbox.newMessages') + span.badge.badge-danger {{user.inbox.newMessages}} a(ui-sref='options.social.tavern') span=env.t('social') - span.badge.badge-danger(ng-if='user.inbox.newMessages') {{user.inbox.newMessages}} a(ng-click='expandMenu("social")', ng-class='{active: _expandedMenu == "social"}') span ☰ div(ng-if='_expandedMenu == "social"') ul.toolbar-submenu(ng-click='expandMenu(null)') li a(ui-sref='options.social.inbox') + span.badge.badge-danger(ng-if='user.inbox.newMessages') {{user.inbox.newMessages}}   =env.t("inbox") - |   - span.badge.badge-danger(ng-if='user.inbox.newMessages') {{user.inbox.newMessages}} li a(ui-sref='options.social.tavern')=env.t('tavern') li @@ -155,7 +154,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') div(ng-if='_expandedMenu == "help"') ul.toolbar-submenu(ng-click='expandMenu(null)') li - a(target="_blank" href='http://habitrpg.wikia.com/wiki/FAQ')=env.t('FAQ') + a(target="_blank" href='http://habitrpg.wikia.com/wiki/')=env.t('overview') li a(target="_blank" href='https://github.com/HabitRPG/habitrpg/issues/2760')=env.t('reportBug') li @@ -165,8 +164,8 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') li a(target="_blank" href='http://habitrpg.wikia.com/wiki/Contributing_to_HabitRPG')=env.t('contributeToHRPG') li - a(target="_blank" href='http://habitrpg.wikia.com/wiki/')=env.t('overview') - li(ng-controller='SettingsCtrl') + a(target="_blank" href='http://habitrpg.wikia.com/wiki/FAQ')=env.t('FAQ') + //-li(ng-controller='SettingsCtrl') a(ng-click='showTour()', popover-placement='right', popover-trigger='mouseenter', popover=env.t('restartTour'))= env.t('showTour') ul.toolbar-subscribe(ng-if='!user.purchased.plan.customerId') li.toolbar-subscribe-button @@ -189,7 +188,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') span.glyphicon.glyphicon-user span=env.t('invitedTo', {name: '{{user.invitations.party.name}}'}) li(ng-repeat='guild in user.invitations.guilds') - a(ui-sref='options.social.guilds', ng-click='expandMenu(null)') + a(ui-sref='options.social.guilds.public', ng-click='expandMenu(null)') span.glyphicon.glyphicon-user span=env.t('invitedTo', {name: '{{guild.name}}'}) li(ng-if='user.flags.classSelected && !user.preferences.disableClasses && user.stats.points') @@ -244,7 +243,7 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') li a(ui-sref='options.settings.export')=env.t('export') li - a(ui-sref='options.settings.coupon') Coupon + a(ui-sref='options.settings.promo')=env.t('promoCode') li a(ui-sref='options.settings.subscription')=env.t('subscription') li @@ -258,8 +257,8 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') li.toolbar-controls-button a(ng-click='expandMenu(null)')=env.t('close') ul.toolbar-wallet - li.toolbar-gems - a.gem-wallet(ng-click='openModal("buyGems",{track:"Gems > Toolbar"})', popover-trigger='mouseenter', popover-title=env.t('gems'), popover=env.t('gemsWhatFor'), popover-placement='bottom',popover-append-to-body='true') + li.toolbar-gems(popover-trigger='mouseenter', popover-title=env.t('gemsPopoverTitle'), popover=env.t('gemsWhatFor'), popover-placement='bottom',popover-append-to-body='true') + a.gem-wallet(ng-click='openModal("buyGems",{track:"Gems > Toolbar"})') //-span.task-action-btn.tile.flush.bright.add-gems-btn + span.Pet_Currency_Gem2x.Gems span.gem-text {{user.balance * 4 | number:0}} @@ -269,6 +268,11 @@ nav.toolbar(ng-controller='AuthCtrl', ng-class='{active: isToolbarHidden}') li.toolbar-currency.silver(popover=env.t('silver'), popover-placement='bottom',popover-trigger='mouseenter') span.shop_silver span {{Shared.silver(user.stats.gp)}} + + ul.toolbar-bailey(ng-class='{inactive: !_expandedMenu}') + li.toolbar-bailey-container(ng-if='user.flags.tour.intro!=-2') + .npc_justin_head.npc_bailey_head(popover="Continue Tour", popover-trigger='mouseenter', popover-placement='bottom', ng-click='Guide.goto("intro", user.flags.tour.intro, true)') + ul.toolbar-bailey(ng-class='{inactive: !_expandedMenu}') li.toolbar-bailey-container(ng-if='user.flags.newStuff') .npc_bailey.npc_bailey_head(popover=env.t('psst'), popover-trigger='mouseenter', popover-placement='right', ng-click='openModal("newStuff",{size:"lg"})') diff --git a/website/views/shared/mixins.jade b/website/views/shared/mixins.jade index 3db108f4d0..c4dde11e38 100644 --- a/website/views/shared/mixins.jade +++ b/website/views/shared/mixins.jade @@ -1,5 +1,5 @@ mixin gemButton(isGemsModal) - a.pull-right.gem-wallet(ng-click=( isGemsModal ? '' : 'openModal("buyGems",{track:"Gems > Wallet"})'), popover-trigger='mouseenter', popover-title=env.t('gems'), popover=env.t('gemsWhatFor'), popover-placement='bottom') + a.pull-right.gem-wallet(ng-click=( isGemsModal ? '' : 'openModal("buyGems",{track:"Gems > Wallet"})'), popover-trigger='mouseenter', popover-title=env.t('gemsPopoverTitle'), popover=env.t('gemsWhatFor'), popover-placement='bottom') if !isGemsModal span.task-action-btn.tile.flush.bright.add-gems-btn + span.task-action-btn.tile.flush.neutral @@ -10,4 +10,10 @@ mixin aLink(url, label) if mobile a(href="", ng-click="externalLink('#{url}')")= label else - a(href='#{url}', target='_blank')= label \ No newline at end of file + a(href='#{url}', target='_blank')= label + +mixin previewMarkdown(text) + .panel.panel-warning + .panel-heading=env.t('msgPreviewHeading') + .panel-body.markdown-preview + markdown(text='#{text}') \ No newline at end of file diff --git a/website/views/shared/modals/achievements.jade b/website/views/shared/modals/achievements.jade index 9d1decd66c..3b0470abe2 100644 --- a/website/views/shared/modals/achievements.jade +++ b/website/views/shared/modals/achievements.jade @@ -14,7 +14,27 @@ script(id='modals/achievements/ultimateGear.html', type='text/ng-template') h4=env.t('modalAchievement') .modal-body .achievement.achievement-armor - =env.t('gearAchievement') + p=env.t('gearAchievement') + br + table.multi-achievement + tr + td(ng-if='::user.achievements.ultimateGearSets.healer').multi-achievement + .achievement-ultimate-healer.multi-achievement + =env.t('healer') + td(ng-if='::user.achievements.ultimateGearSets.wizard').multi-achievement + .achievement-ultimate-mage.multi-achievement + =env.t('mage') + td(ng-if='::user.achievements.ultimateGearSets.rogue').multi-achievement + .achievement-ultimate-rogue.multi-achievement + =env.t('rogue') + td(ng-if='::user.achievements.ultimateGearSets.warrior').multi-achievement + .achievement-ultimate-warrior.multi-achievement + =env.t('warrior') + br + p(ng-if='!(user.achievements.ultimateGearSets.healer && user.achievements.ultimateGearSets.wizard && user.achievements.ultimateGearSets.rogue && user.achievements.ultimateGearSets.warrior)')!=env.t('moreGearAchievements') + br + .shop_armoire.pull-right + p!=env.t("armoireUnlocked") .modal-footer button.btn.btn-default(ng-click='$close()')=env.t('ok') diff --git a/website/views/shared/modals/classes.jade b/website/views/shared/modals/classes.jade index 5eac56aeea..d9fdaa054d 100644 --- a/website/views/shared/modals/classes.jade +++ b/website/views/shared/modals/classes.jade @@ -1,18 +1,11 @@ script(type='text/ng-template', id='modals/chooseClass.html') .modal-header - h4 - |  - =env.t('chooseClass1') - | - a(href='http://habitrpg.wikia.com/wiki/Class_System' target='_blank')=env.t('chooseClass2') - |  - =env.t('chooseClass3') + h4=env.t('chooseClassHeading') .modal-body.select-class .container-fluid .row .col-md-3(ng-click='selectedClass = "warrior"') - h5 - a(href='http://habitrpg.wikia.com/wiki/Warrior' target='_blank')=env.t('warrior') + h5!=env.t('warriorWiki') figure.herobox(ng-class='{"selected-class": selectedClass=="warrior"}') .character-sprites span(class='skin_{{user.preferences.skin}}') @@ -26,8 +19,7 @@ script(type='text/ng-template', id='modals/chooseClass.html') span(class='shield_warrior_5') span(class='weapon_warrior_6') .col-md-3(ng-click='selectedClass = "wizard"') - h5 - a(href='http://habitrpg.wikia.com/wiki/Mage' target='_blank')=env.t('mage') + h5!=env.t('mageWiki') figure.herobox(ng-class='{"selected-class": selectedClass=="wizard"}') .character-sprites span(class='skin_{{user.preferences.skin}}') @@ -41,8 +33,7 @@ script(type='text/ng-template', id='modals/chooseClass.html') span(class='shield_wizard_5') span(class='weapon_wizard_6') .col-md-3(ng-click='selectedClass = "rogue"') - h5 - a(href='http://habitrpg.wikia.com/wiki/Rogue' target='_blank')=env.t('rogue') + h5!=env.t('rogueWiki') figure.herobox(ng-class='{"selected-class": selectedClass=="rogue"}') .character-sprites span(class='skin_{{user.preferences.skin}}') @@ -56,8 +47,7 @@ script(type='text/ng-template', id='modals/chooseClass.html') span(class='shield_rogue_6') span(class='weapon_rogue_6') .col-md-3(ng-click='selectedClass = "healer"') - h5 - a(href='http://habitrpg.wikia.com/wiki/Healer' target='_blank')=env.t('healer') + h5!=env.t('healerWiki') figure.herobox(ng-class='{"selected-class": selectedClass=="healer"}') .character-sprites span(class='skin_{{user.preferences.skin}}') @@ -77,5 +67,7 @@ script(type='text/ng-template', id='modals/chooseClass.html') .well(ng-show='selectedClass=="healer"')=env.t('healerText') .modal-footer - button.btn.btn-sm.btn-danger(ng-click='user.ops.disableClasses({}); $close()', popover-placement='top', popover-trigger='mouseenter', popover=env.t('optOutText'))=env.t('optOut') + span(popover-placement='left', popover-trigger='mouseenter', popover=env.t('optOutText')) + button.btn.btn-danger(ng-click='user.ops.disableClasses({}); $close()')=env.t('optOut') button.btn.btn-primary(ng-disabled='!selectedClass' ng-click='changeClass(selectedClass); $close()')=env.t('select') + .pull-left!=env.t('chooseClassLearn') diff --git a/website/views/shared/modals/drops.jade b/website/views/shared/modals/drops.jade index ffba52e088..f47315128f 100644 --- a/website/views/shared/modals/drops.jade +++ b/website/views/shared/modals/drops.jade @@ -1,4 +1,4 @@ -script(type='text/ng-template', id='modals/dropsEnabled.html') +script(type='text/ng-template', id='modals/dropsEnabled.html') .modal-header h4=env.t('dropsEnabled') .modal-body @@ -16,7 +16,7 @@ script(type='text/ng-template', id='modals/dropsEnabled.html') script(type='text/ng-template', id='modals/pet-key.html') .modal-header - // Checks if user has 90 pets and 90 mounts. If so, displays "Beast Master/Mount Master". + // Checks if user has 90 pets and 90 mounts. If so, displays "Beast Master/Mount Master". // Else if user has 90 pets, displays "Beast Master". Else, displays "Mount Master" - var masterTitle='{{petCount >= 90 && mountCount >= 90 ? env.t("beastMountMasterName") : petCount >= 90 ? env.t("beastMasterName") : env.t("mountMasterName")}}' h4=env.t('petKeyBegin', {title: masterTitle}) @@ -28,7 +28,8 @@ script(type='text/ng-template', id='modals/pet-key.html') br p=env.t('petKeyInfo2') br - p=env.t('petKeyInfo3') + p(ng-if='user.achievements.triadBingo')=env.t('petKeyInfo4') + p(ng-if='!user.achievements.triadBingo')=env.t('petKeyInfo3') .modal-footer button.btn.btn-default(ng-click='$close()')=env.t('petKeyNeverMind') span(ng-if='user.balance < 1') @@ -44,8 +45,20 @@ script(type='text/ng-template', id='modals/pet-key.html') =env.t('petKeyMounts') | : 4  span.Pet_Currency_Gem1x.inline-gems - span(ng-if='user.balance >= 1.5 && petCount >= 90 && mountCount >= 90', ng-controller='SettingsCtrl') + span(ng-if='(user.balance >= 1.5 || user.achievements.triadBingo) && petCount >= 90 && mountCount >= 90', ng-controller='SettingsCtrl') a.btn.btn-danger(ng-click='$close(); releaseBoth()') =env.t('petKeyBoth') - | : 6  - span.Pet_Currency_Gem1x.inline-gems + span(ng-if='!user.achievements.triadBingo') + | : 6  + span.Pet_Currency_Gem1x.inline-gems + +script(type='text/ng-template', id='modals/armoireEmpty.html') + .modal-header + .shop_armoire.pull-right + h4=env.t('armoireText') + .modal-body + p=env.t('armoireLastItem') + br + p=env.t('armoireNotesEmpty') + .modal-footer + button.btn.btn-default(ng-click='$close()')=env.t('close') \ No newline at end of file diff --git a/website/views/shared/modals/index.jade b/website/views/shared/modals/index.jade index f8f5433996..a64701f60c 100644 --- a/website/views/shared/modals/index.jade +++ b/website/views/shared/modals/index.jade @@ -11,3 +11,4 @@ include ./quests include ./rebirth include ./limited include ./invite-friends +include ./welcome.jade diff --git a/website/views/shared/modals/invite-friends.jade b/website/views/shared/modals/invite-friends.jade index 13f954167f..36b1c21596 100644 --- a/website/views/shared/modals/invite-friends.jade +++ b/website/views/shared/modals/invite-friends.jade @@ -1,26 +1,26 @@ script(type='text/ng-template', id='modals/invite-friends.html') .modal-header - h4 Invite Friends + h4=env.t('inviteFriends') .modal-body - p.alert.alert-info Invite friends by User ID here. + p.alert.alert-info!=env.t('inviteAlertInfo') form.form-inline(ng-submit='invite()') //-.alert.alert-danger(ng-show='_groupError') {{_groupError}} .form-group input.form-control(type='text', placeholder=env.t('userId'), ng-model='invitee') |  - button.btn.btn-primary(type='submit') Invite Existing User + button.btn.btn-primary(type='submit')=env.t('inviteExistUser') hr - p.alert.alert-info Invite friends by email. If they join via your email, they'll automatically be invited to your party. + p.alert.alert-info=env.t('inviteByEmail') form.form-horizontal(ng-submit='inviteEmails()') table.table.table-striped thead tr - th Name - th Email + th=env.t('name') + th=env.t('email') tbody tr(ng-repeat='email in emails') td @@ -33,16 +33,16 @@ script(type='text/ng-template', id='modals/invite-friends.html') i.glyphicon.glyphicon-plus tr td.form-group(colspan=2) - label.col-sm-1.control-label By: + label.col-sm-1.control-label=env.t('byColon') .col-sm-7 input.form-control(type='text', ng-model='inviter') .col-sm-4 - button.btn.btn-primary(type='submit') Invite New User(s) + button.btn.btn-primary(type='submit')=env.t('inviteNewUsers') //- hr - p.alert.alert-info Or share this link (copy/paste): + p.alert.alert-info=env.t('inviteAlertInfo2') input.form-control(type='text', ng-value='inviteLink({id: party._id, inviter: user._id, name: party.name})') .modal-footer - button.btn.btn-default(ng-click='$close()') Close + button.btn.btn-default(ng-click='$close()')=env.t('close') diff --git a/website/views/shared/modals/members.jade b/website/views/shared/modals/members.jade index bafe6c62f5..626db557a4 100644 --- a/website/views/shared/modals/members.jade +++ b/website/views/shared/modals/members.jade @@ -2,7 +2,7 @@ script(type='text/ng-template', id='modals/member.html') .modal-header h4 span {{::profile.profile.name}} - span(ng-if='profile.contributor.level') - {{::contribText(profile.contributor, profile.backer)}} + span(ng-if='::contribText && profile.contributor.level') - {{::contribText(profile.contributor, profile.backer)}} .modal-body .container-fluid .row @@ -22,6 +22,7 @@ script(type='text/ng-template', id='modals/member.html') |  | {{::profile.auth.timestamps.loggedin | date:user.preferences.dateFormat}} - h3=env.t('stats') + // @TODO: Figure out why this isn't showing up in front page .label.label-info {{:: {warrior:env.t("warrior"), wizard:env.t("mage"), rogue:env.t("rogue"), healer:env.t("healer")}[profile.stats.class] }} include ../profiles/stats .col-md-6 @@ -38,7 +39,7 @@ script(type='text/ng-template', id='modals/member.html') span.glyphicon.glyphicon-ban-circle button.btn.btn-md.btn-default(tooltip=env.t('sendPM'), ng-click="openModal('private-message',{controller:'MemberModalCtrl'})", tooltip-placement='right') span.glyphicon.glyphicon-envelope - button.btn.btn-md.btn-default(tooltip="Send Gift", ng-click="openModal('send-gift',{controller:'MemberModalCtrl'})", tooltip-placement='right') + button.btn.btn-md.btn-default(tooltip=env.t('sendGift'), ng-click="openModal('send-gift',{controller:'MemberModalCtrl'})", tooltip-placement='right') span.glyphicon.glyphicon-gift button.btn.btn-default(ng-click='$close()')=env.t('close') @@ -46,21 +47,29 @@ script(type='text/ng-template', id='modals/private-message.html') .modal-header h4=env.t('pmHeading', {name: "{{profile.profile.name}}"}) .modal-body - textarea.form-control(type='text',rows='5',ui-keydown='{"meta-enter":"sendPrivateMessage(profile._id, _message)"}',ng-model='_message') + textarea.form-control(type='text',rows='5',ui-keydown='{"meta-enter":"sendPrivateMessage(profile._id, _message)"}',placeholder=env.t('needsTextPlaceholder'),ng-model='_message', focus-me) + include ../formatting-help .modal-footer - button.btn.btn-primary(ng-click='sendPrivateMessage(profile._id, _message)')=env.t("send") + //- Due to a quirk in Bootstrap UI, we need to wrap this so the tooltip can + //- appear when the button is disabled. + // + //- Source: http://getbootstrap.com/javascript/#tooltips + // "Tooltips on disabled elements require wrapper elements" + // + .disabled-tooltip-wrapper(tooltip="{{_message ? '' : env.t('needsText')}}") + button.btn.btn-primary(ng-disabled='!_message',ng-click='sendPrivateMessage(profile._id, _message)')=env.t("send") button.btn.btn-default(ng-click='$close()')=env.t('cancel') script(type='text/ng-template', id='modals/send-gift.html') .modal-header - h4 Send Gift to {{::profile.profile.name}} + h4=env.t('sendGiftHeading', {name: "{{::profile.profile.name}}"}) .modal-body .panel.panel-default(class="{{gift.type=='gems' ? 'panel-primary' : 'transparent'}}", ng-click='gift.type="gems"') .panel-heading .pull-right - span(ng-show='gift.gems.fromBalance') From {{user.balance*4}} Gems - span(ng-hide='gift.gems.fromBalance') Total: ${{gift.gems.amount/4}} USD - | Gems + span(ng-show='gift.gems.fromBalance')=env.t('sendGiftGemsBalance', {number: "{{::user.balance*4}}"}) + span(ng-hide='gift.gems.fromBalance')=env.t('sendGiftCost', {cost: "{{gift.gems.amount/4}}"}) + =env.t('gemsPopoverTitle') .panel-body .row .col-md-6 @@ -68,19 +77,20 @@ script(type='text/ng-template', id='modals/send-gift.html') input.form-control(type='number', placeholder='Number of Gems', min='0', max='{{gift.gems.fromBalance ? user.balance*4 : ""}}', ng-model='gift.gems.amount') .col-md-6 .btn-group - a.btn.btn-default(ng-class="{active:gift.gems.fromBalance}", ng-click="gift.gems.fromBalance=true") From Balance - a.btn.btn-default(ng-class="{active:!gift.gems.fromBalance}", ng-click="gift.gems.fromBalance=false") Purchase + a.btn.btn-default(ng-class="{active:gift.gems.fromBalance}", ng-click="gift.gems.fromBalance=true")=env.t('sendGiftFromBalance') + a.btn.btn-default(ng-class="{active:!gift.gems.fromBalance}", ng-click="gift.gems.fromBalance=false")=env.t('sendGiftPurchase') .panel.panel-default(class="{{gift.type=='subscription' ? 'panel-primary' : 'transparent'}}", ng-click='gift.type="subscription"') - .panel-heading Subscription + .panel-heading=env.t('subscription') .panel-body .form-group .radio(ng-repeat='block in Content.subscriptionBlocks | toArray | omit:"discount==true" | orderBy:"months"') label input(type="radio", name="subRadio", ng-value="block.key", ng-model='gift.subscription.key') - | {{block.months}} Month(s): ${{block.price}} + =env.t('sendGiftSubscription', {price: '{{::block.price}}', months: '{{::block.months}}'}) - textarea.form-control(rows='3', ng-model='gift.message', placeholder='Personal message (optional)') + textarea.form-control(rows='3', ng-model='gift.message', placeholder=env.t('sendGiftMessagePlaceholder')) + include ../formatting-help .modal-footer - var fromBal = "gift.type=='gems' && gift.gems.fromBalance" @@ -101,3 +111,12 @@ script(type='text/ng-template', id='modals/abuse-flag.html') | Reset Flag Count button.btn.btn-primary(ng-click='$close()')=env.t('cancel') button.btn.btn-default(ng-click='reportAbuse(user, abuseObject, groupId)')=env.t("abuseFlagModalButton") + +script(type='text/ng-template', id='modals/remove-member.html') + .modal-header + h4=env.t('sureKick') + .modal-body + textarea.form-control(type='text',rows='5',placeholder=env.t('optionalMessage'),ng-model='removeMemberData.message') + .modal-footer + button.pull-left.btn.btn-danger(ng-click='confirmRemoveMember(true); $close()')=env.t('yesRemove') + button.btn.btn-default(ng-click='confirmRemoveMember(false); $close()')=env.t('cancel') diff --git a/website/views/shared/modals/new-stuff.jade b/website/views/shared/modals/new-stuff.jade index e27ecc0e7f..3649ffc375 100644 --- a/website/views/shared/modals/new-stuff.jade +++ b/website/views/shared/modals/new-stuff.jade @@ -6,7 +6,7 @@ script(type='text/ng-template', id='modals/newStuff.html') div(class="#{env.worldDmg.bailey ? 'npc_bailey_broken' : 'npc_bailey'}") br br - include ../new-stuff + div(ng-bind-html='latestBaileyMessage') .modal-footer - button.btn.btn-default(ng-click='$close()')=env.t('cool') + button.btn.btn-default(ng-click='$close()')=env.t('cool') button.btn.btn-warning(ng-click='dismissAlert(); $close()')=env.t('dismissAlert') diff --git a/website/views/shared/modals/quest-rewards.jade b/website/views/shared/modals/quest-rewards.jade index f5dc816501..4035951fca 100644 --- a/website/views/shared/modals/quest-rewards.jade +++ b/website/views/shared/modals/quest-rewards.jade @@ -10,3 +10,5 @@ script(id='partials/options.social.party.quest-rewards.html', type='text/ng-temp tr td {{quest.drop.gp}} =env.t('gold') + tr + td {{quest.drop.unlock()}} diff --git a/website/views/shared/modals/settings.jade b/website/views/shared/modals/settings.jade index b5728fb551..8a263f2df0 100644 --- a/website/views/shared/modals/settings.jade +++ b/website/views/shared/modals/settings.jade @@ -46,7 +46,7 @@ script(type='text/ng-template', id='modals/restore.html') label.control-label=env.t('fix21Streaks') //- This is causing too many problems for users h3=env.t('other') - a.btn.btn-sm.btn-warning(ng-controller='FooterCtrl', ng-click='addMissedDay()')=env.t('triggerDay') + a.btn.btn-sm.btn-warning(ng-controller='FooterCtrl', ng-click='addMissedDay(1)')=env.t('triggerDay') .modal-footer button.btn.btn-default(ng-click='$close()')=env.t('discardChanges') button.btn.btn-primary(ng-click='restore(); $close();')=env.t('saveAndClose') diff --git a/website/views/shared/modals/welcome.jade b/website/views/shared/modals/welcome.jade new file mode 100644 index 0000000000..bf8fe48dd1 --- /dev/null +++ b/website/views/shared/modals/welcome.jade @@ -0,0 +1,18 @@ +// Created by sabrecat on 5/18/15. + +script(type='text/ng-template', id='modals/welcome.html') + .modal-header + h4=env.t('welcomeToHabit') + .modal-body.text-center + h4=env.t('welcome1') + .welcome_to_Habit_1.center-block + h4=env.t('welcome2') + .welcome_to_Habit_2.center-block + h4=env.t('welcome3') + .welcome_to_Habit_3.center-block + h4=env.t('welcome4') + .welcome_to_Habit_4.center-block + .modal-footer + span.h4=env.t('welcome5') + |  + span.button.btn.btn-primary(ng-click='$close(); Guide.goto("intro",0)')=env.t('imReady') \ No newline at end of file diff --git a/website/views/shared/new-stuff.jade b/website/views/shared/new-stuff.jade index 4fa59a4f80..ec2703ca20 100644 --- a/website/views/shared/new-stuff.jade +++ b/website/views/shared/new-stuff.jade @@ -1,26 +1,352 @@ -h5 3/3/2015 - MARCH BACKGROUNDS, ANDROID APP NOTIFICATIONS, AND MARCH MYSTERY BOX +h5 6/1/2015 - NEW EQUIPMENT: THE ENCHANTED ARMOIRE, JUNE BACKGROUNDS, AND NEW MOUNT POSITIONING! hr tr td - h5 March Backgrounds Revealed - p There are three new avatar backgrounds in the Background Shop! Now your avatar can dance in the Spring Rain, admire some Stained Glass, or frolic through the Rolling Hills! - p.small.muted by (in order) Sunstroke, Kiwibot, and Uncommon Criminal + .promo_enchanted_armoire.pull-right + h5 New Equipment: The Enchanted Armoire! + p Now after you achieve Ultimate Gear, you'll unlock a new Reward: THE ENCHANTED ARMOIRE! + br + p Click on the Enchanted Armoire, a 100 GP Reward in the Rewards Column, for a random chance at special Equipment! It may also give you random XP or food items. We'll be adding new equipment to it every month, but even when you've exhausted the current supply, you can keep clicking for a chance at food and XP. + br + p Now go spend all that accumulated Gold! May the Random Number Generator smile upon you... + p.small.muted by Lemoness and SabreCat + p.small.muted Art by Kiwibot, Starsystemic, UncommonCriminal, Zoebeagle, and Andrews38 tr td - h5 Android App Notifications - p The Android app can now remind you to log in! Simply go to Settings and select the time that you want the reminder. - p.small.muted by Negue + .background_island_waterfalls.pull-right + h5 June Backgrounds Revealed + p There are three new avatar backgrounds in the Background Shop! Now your avatar can paddle a Drifting Raft, float through a sea of Shimmery Bubbles, or picnic near Island Waterfalls! + p.small.muted by (in order): Teto is Great, beffymaroo, and UncommonCriminal tr td - .inventory_present.pull-right - h5 March Mystery Box - p Wow! What could it be? All Habiticans who are subscribed during the month of March will receive the March Mystery Item Set! It will be revealed on the 25th, so keep your eyes peeled. Thanks for supporting the site <3 - p.small.muted by Lemoness + h5 New Mount Positioning! + p The mount positioning has been fixed for all the base mounts where it looked like the avatar was riding extreme sidesaddle. Now avatars sit properly, no longer clinging to the sides of their mounts for dear life. + p.small.muted by Kiwibot, Lemoness, and SabreCat hr a(href='/static/old-news', target='_blank') Read older news mixin oldNews + + h5 6/1/2015 - JUNE MYSTERY ITEM! + tr + td + .inventory_present_06.pull-right + h5 June Mystery Item! + p Ooh, how mysterious! All Habiticans who are subscribed during the month of June will receive the June Mystery Item Set, as well as the ability to buy Gems with Gold! The June Item Set will be revealed on the 25th, so keep your eyes peeled. Thanks for supporting the site <3 + h5 5/31/2015 - PUSH NOTIFICATIONS FOR ANDROID, AND LAST CHANCE FOR GREEN KNIGHT SUBSCRIBER ITEMS! + tr + td + .promo_mystery_201505.pull-right + h5 Last Chance for Green Knight Item Set + p Reminder: this is the final day to subscribe and receive the Green Knight Item Set! If you want the Green Knight Helm or the Green Knight Lance, now's the time! Thanks so much for your support <3 + p.small.muted by Lemoness + tr + td + h5 Push Notifications for Android + p We've released an update to the Android app that includes new types of push notification! Now it's easier than ever to remember to stay productive. Get the Android update here! + p.small.muted by Negue + h5 5/25/2015 - MAY SUBSCRIBER ITEM SET: GREEN KNIGHT! + tr + td + .promo_mystery_201505.pull-right + h5 May Subscriber Item Set Revealed: Green Knight! + p The May Subscriber Item has been revealed: the Green Knight Item Set! All May subscribers will receive the Green Knight Helm and the Green Knight Lance. You still have six days to subscribe and receive the item set, along with the ability to buy Gems with Gold! Thank you so much for your support - we really do rely on you to keep HabitRPG free to use and running smoothly. + p.small.muted by Lemoness + h5 5/20/2015 - NEW PET QUEST: SHEEP! + tr + td + .quest_sheep.pull-right + h5 New Pet Quest: Sheep! + p It looks like there's some ba-a-a-ad weather in the Taskan countryside! Can you and your party be diligent enough to defeat the Thunder Ram? If so, you may find yourself with some wooly sheep pets... + p.small.muted art by Starsystemic and Misceo + p.small.muted writing by Salambander, Leephon, and Lemoness + h5 5/13/2015 - NEW ANIMAL SKINS AND ACCESSORIES, INN IMPROVEMENTS, COPY CHAT TO TO-DO, AND EXTRA INFO + tr + td + .promo_pet_skins.pull-right + h5 New Animal Skins and Accessories Available! + p They say that owners resemble their pets, and now that's truer than ever for Habiticans! The Animal Skin Set and Animal Accessory Set are now available in the Customization shop. Time to let your avatar walk on the wild side. + p.small.muted by Painter de Cluster and SabreCat + tr + td + h5 Inn Improvements + p Now even when you Rest in the Inn, your Dailies will refresh each day. Important note: your Dailies still do NOT hurt you while you're in the Inn. We wouldn't do that to you! + br + p It used to be that the Resting in the Inn froze all your Dailies so that they wouldn't refresh the next day - even for important Dailies like "take medicine" or "feed pets." This was very frustrating to a lot of users who relied on these features, even during periods of time when they needed to rest in the Inn for finals, illness, vacation, etc. + br + p Now if you're in a situation, for example finals period, where you don't have the time or energy to do most of your Dailies, you can still complete some of them every day while Resting in the Inn. It's much more flexible and convenient! + br + p If you're in a quest, you still won't deal damage/collect items until you check out of the Inn, and your Dailies will not damage your party members, but you can still be injured by a Boss if your Party mates skip their own Dailies. You also still do not gain Mana overnight until you check out of the Inn. If you have any questions about how Resting in the Inn works, be sure to ask in the Newbies Guild! + p.small.muted by hairlessbear and Blade + tr + td + h5 Copy Chat to To-Do + p Now you can copy any chat message into your To-Do list! If your roommate posted in party chat and asked you to grab groceries, or your friend reminded you about the history quiz tomorrow, you can save it right into your To-Do list. Awesome!  + p.small.muted by Negue and Redphoenix + tr + td + h5 Extra Info + p We know that HabitRPG can be confusing, so now you can easily double-check what each task type does by clicking the question mark next to its name. + p.small.muted by Lemoness, lefnire, and SabreCat + h5 5/06/2015 - MAY BACKGROUNDS REVEALED + tr + td + .background_mountain_lake.pull-right + h5 May Backgrounds Revealed + p There are three new avatar backgrounds in the Background Shop! Now your avatar can climb to the top of Pagodas, pose in front of a Marble Temple, or dip toes in a Mountain Lake! + p.small.muted by (in order) Teto is Great, Painter de Cluster, and Hazel40 + + h5 5/01/2015 - Skills Rebalancing + tr + td + p After over a year's worth of complaints on Trello and countless bug reports on Github, and after almost five months of dedicated debating, coding, and testing, we have finally rolled out an overhaul of the skills and mana system. Thank you so much to everyone who contributed opinions, time, and effort! Here's what happened: + tr + td + h5 HABITS DAMAGE BOSSES + p Now it's even easier to damage a Boss without skills! It was definitely high time that HabitRPG counted Habits towards battles. We were not living up to our name. + tr + td + h5 MANA DIRECTLY LINKED TO PROGRESS + p Mana was pretty broken: you gained it overnight no matter what you'd done the day before, and it was only linked to To-Dos. This meant that using skills was pretty detached from how well you were doing in your real life, which defeated the purpose of the game! + p Now you can gain Mana from Dailies and positive Habits as well as To-Dos! You still gain Mana overnight, but how much you gain depends on how many of your Dailies you did. + p You can also lose Mana by hitting negative Habits. Yikes! Better not indulge... + tr + td + h5 SKILLS STRENGTHENED AND WEAKENED + p Some notoriously overpowered skills have been weakened, like Backstab (which often granted over 1000GP per cast), Burst of Flames (which allowed you to 1-hit KO most bosses regardless of how much or how little you'd done that day), and Valorous Presence (which caused the notorious "I checked off one Daily and gained 997 levels" bug reports). + p Some painfully UNDERpowered skills have been strengthened, such as Tools of the Trade and Searing Brightness. We think you'll like these much better now! + p For a full description of what changed, check out this blog post. + tr + td + h5 GIVING FEEDBACK + p We understand that these changes may be disruptive to some of you. We're sorry! We hope that with time, you will find them to be a drastic improvement. We will be waiting two weeks (so that everyone can get used to the new system), and then on May 15th will open up a new Trello card for comments and feedback. + p For those of you who want to reallocate stats now that you have the new system, please post your User ID in this Github ticket. (Your UUID is found under Settings > API; do NOT post your API Token.) That ticket is also being used to debate a possibility to make it so that reallocating stats does not cost gems. If that's a feature you would like (or would hate), definitely drop by that ticket and let us know! + p.small.muted by Alys, Verabird, brandonjreid, ShilohT, betaveros, SabreCat, chimericdream, and everyone who commented with feedback on Trello and Github. You all are great! + + h5 4/30/2015 - LAST CHANCE FOR BUSY BEE AND SPRING FLING ITEMS, AND SOON-TO-APPEAR NEW EQUIPMENT! + tr + td + .promo_shimmer_hair.pull-right + h5 Last Chance for Spring Fling Outfits, Hair Colors, and Shiny Seeds! + p Tomorrow everything will be back to normal in Habitica, so if you still have any remaining Spring Fling Items that you want to buy, you'd better do it now! The Seasonal Edition items and Hair Colors won't be back until next March, and if the Limited Edition items return they will have increased prices or changed art, so strike while the iron is hot! + tr + td + .promo_mystery_201504.pull-right + h5 Last Chance for Busy Bee Item Set + p Reminder: this is the final day to subscribe and receive the Busy Bee Item Set! If you want the Busy Bee Robe or the Busy Bee Robes, now's the time! Thanks so much for your support <3 + tr + td + h5 New Equipment Soon + p If you're sad to see the extra gold-purchasable equipment disappear, don't worry! We have something fun in the works... + + h5 4/24/2015 - APRIL SUBSCRIBER ITEM SET AND NEW LANGUAGES + tr + td + .promo_mystery_201504.pull-right + h5 April Subscriber Item Set: Busy Bee! + p The April Subscriber Item has been revealed: the Busy Bee Item Set! All April subscribers will receive the Busy Bee Robe and the Busy Bee Wings. You still have six days to subscribe and receive the item set! Thank you so much for your support - we really do rely on you to keep HabitRPG free to use and running smoothly. + p.small.muted by Lemoness + tr + td + h5 New Languages + p We've added three new languages to the site: Japanese, Serbian and Chinese (Traditional)! + p.small.muted by Paglias, the Japanese Translation Team, the Serbian Translation Team, and the Chinese (Traditional) Translation Team + + h5 4/15/2015 - MARSHMALLOW SLIMES, KEY TO THE KENNELS CHANGE, AND CHALLENGE IMPROVEMENTS + tr + td + .Pet-Slime-Base.pull-right + h5 Marshmallow Slime Pet Quest! + p There is a new Pet Quest available in the Market: The Jelly Regent! Gooey slime is gumming up the works, and Habiticans are having a tough time finishing their tasks. Can you mop the floor with the Jelly Regent? If so, you'll get some adorable Marshmallow Slime pets! + p.small.muted art by Starsystemic, Leephon, LordDarkly, Overomega, and Shaner + p.small.muted writing by Bethany Woll and Theothermeme + tr + td + h5 Key to the Kennels Free with Triad Bingo + .pet_key.pull-right + p The Key to the Kennels is now free if you have the Triad Bingo achievement and if you choose to release your pets and mounts together! Rejoice, collectors! Note that the Key will not be free if you release only pets or only mounts. + p.small.muted by gisikw + tr + td + h5 Challenge Improvements + p Now Challenge links take you directly to that Challenge, instead of the top of the list, and when you edit a Challenge, the name is automatically updated! + p.small.muted by gisikw, chrisdotcode, and TheHollidayInn + h5 4/7/2015 - APRIL BACKGROUNDS REVEALED + tr + td + .background_cherry_trees.pull-right + h5 April Backgrounds + p There are three new avatar backgrounds in the Background Shop! Now your avatar can picnic in a Flowering Meadow, nibble the scenery of Gumdrop Land, or admire the Cherry Trees! + p.small.muted by Rattify, Painter de Cluster, and kmcallah + h5 4/2/2015 - MARCH AND APRIL ITEM SETS; SHINY SEEDS; MESSAGE CHALLENGE CREATORS; ITEM DROP ICONS + tr + td + h5 Last Chance for March Item Set + p Reminder: this is the final day to subscribe and receive the Aquamarine Item Set! If you want the Aquamarine Eyewear or the Aquamarine Armor, now's the time! Thanks so much for your support <3 + tr + td + h5 April Mystery Box + .inventory_present.pull-right + p Cool! What could it be? All Habiticans who are subscribed during the month of April will receive the April Mystery Item Set! It will be revealed on the 25th, so keep your eyes peeled. Thanks for supporting the site <3 + p.small.muted by Lemoness + tr + td + h5 Shiny Seeds + .inventory_special_shinySeed.pull-right + p Phew! It was tough, but we overthrew the flowers that had taken over the site. However, they've left behind some of their Shiny Seeds! + br + p Throw a Shiny Seed at your friends and they will turn into a cheerful flower until their next cron! You can buy the Seeds in the Seasonal Shop for gold. Don't want to be a flower? Just buy some Petal-Free Potion from the Rewards Store to reverse it. + br + p Shiny Seeds will be available in the Seasonal Shop until April 30th! + p.small.muted by Lemoness and SabreCat + tr + td + h5 Message Challenge Creators + p Now on the Challenges page, you can to click on the challenge creator's name to view their profile, message them, or to see how long ago they last logged in if you are curious about whether the challenge might still be active. + p.small.muted by TheHollidayInn + tr + td + .promo_item_notif.pull-right + h5 Icons in Notifications + p Now, when you find an item from scoring a task, an image of the item appears in the drop notification. Instant gratification when that egg or potion you've been hunting for finally appears! + p.small.muted by TheHollidayInn + h5 4/1/2015 - HOSTILE FLOWER TAKEOVER OF JOY AND DOOM + tr + td + h5 Joy and Doom to All! + p THE SPRING FLING HAS FLUNG TOO FAR! Run while you can, Habiticans! The floral theme has come to life and is taking over Habitica with horrifying cheer, repeat, the flowers are taking over HMMMPH MMPH MMMHPPPH.... + .avatar_floral_wizard + p CELEBRATE FLOWER POWER. + br + p RESISTANCE IS SILLY. + p.small.muted by Lemoness and Baconsaur + h5 3/29/2015 - PASTEL SKIN, SHIMMER HAIR COLORS, SURVEY BADGES AWARDED, AND PARTY SORT ORDER + tr + td + .promo_pastel_skin.pull-right + h5 Pastel Skin + p The Seasonal Edition Pastel Skin Set is now available for purchase in the avatar customizations page! This skin set will only be available until April 30th, and then it will disappear until next Spring Fling. + p.small.muted by McCoyly + tr + td + .promo_shimmer_hair.pull-right + h5 Shimmer Hair Colors + p The Seasonal Edition Shimmer Hair Colors are now available for purchase in the avatar customizations page! Now you can dye your avatar's hair Shimmer Pink, Shimmer Purple, Shimmer Blue, Shimmer Green, Shimmer Orange, or Shimmer Yellow. + br + p Seasonal Edition items recur unchanged every year, but they are only available to purchase during a short period of time. This is different from Limited Edition Items, which only recur if something is changed, such as the art or the price. These hair colors may remind some of you of the Pastel Hair Colors that were available last spring. The Pastel Hair Colors have been retired in favor of the similar Seasonal Edition Shimmer Hair Colors. Read more about the difference between Seasonal and Limited Edition items here! + p.small.muted by Lemoness, crystalphoenix, and mariahm + tr + td + h5 Survey Badges Awarded + p The Survey badges have been awarded to everyone who took the survey and provided their user ID! Unfortunately, some people did not include their User ID with the survey. As a result, we have no way of linking the survey with their accounts, and could not give them the "Helped Habit Grow" badge. If you have any questions, please email Leslie. + p.small.muted by Sugarfiend and Alys + tr + td + h5 Party Sort Order + p Now when you change the sort order for your party, it takes effect immediately. You can change the sort order under Social > Party. + p.small.muted by ChokesMcGee + h5 3/25/2015 - MARCH SUBSCRIBER ITEM, FREE EGG HUNT QUEST, EGG MOUNTS, AND NEW MODERATOR! + tr + td + .promo_mystery_201503.pull-right + h5 March Subscriber Item + p The March Subscriber Item has been revealed: the Aquamarine Item Set! All March subscribers will receive the Aquamarine Eyewear and the Aquamarine Armor. You still have six days to subscribe and receive the item set! Thank you so much for your support - we really do rely on you to keep HabitRPG free to use and running smoothly. + p.small.muted by Lemoness + tr + td + .Pet-Egg-CottonCandyPink.pull-right + h5 Egg Hunt Quest and Egg Mounts + p In celebration of the season, everyone has received a free Egg Hunt collection quest scroll! You can find it in the Inventory. Collect eggs by completing your tasks, and you'll be rewarded with some egg pets. + br + p Furthermore, the Egg Pets can now be fed... and grow into some glorious Egg Mounts! + br + p The Seasonal Sorceress will also be stocking the Egg Quest scrolls until April 30th. Once they're gone, they won't return until next Spring, so get them while they're hot! + p.small.muted by Beffymaroo and Megan + tr + td + h5 New Moderator + p Finally, we have a new moderator on the site: @Beffymaroo! Hooray! Be sure to say hello to her in the Tavern. + h5 3/20/2015 - SPRING FLING EVENT! LIMITED EDITION OUTFITS, SEASONAL SHOP OPENS, AND SPRING NPCS + tr + td + h5 Spring Fling! + p The Spring Fling is here! From today until April 30th, join Habitica in its sweet celebration. + tr + td + .promo_springclasses2015.pull-right + h5 Limited Edition Class Outfits + p From now until April 30th, limited edition outfits are available in the Rewards column. Depending on your class, you can be a Beware Dog, Magician's Bunny, Sneaky Squeaker, or Comforting Kitty! You'd better get productive to earn enough gold before they disappear. Good luck! + p.small.muted by Lemoness + tr + td + .promo_springclasses2014.pull-right + h5 Seasonal Shop Opens + p The Seasonal Shop has opened! It's stocking springtime Seasonal Edition goodies at the moment, including last year's spring outfits. Everything there will be available to purchase during the Spring Fling event each year, but it's only open until April 30th, so be sure to stock up now, or you'll have to wait a year to buy these items again. + p.small.muted by Lemoness + tr + td + .seasonalshop_spring2015.pull-left + h5 Spring NPCs + p Looks like the NPCs are really getting in to the springtime fun around the site. Who wouldn't? After all, there's plenty more to come! + p.small.muted by Lemoness and Shaner + h5 3/17/2015 - BUNNY PET QUEST, EGG PURCHASING CHANGE, LAST DAY FOR SURVEY AND ACHIEVEMENT, AND UNEQUIP BUTTONS + tr + td + h5 New Pet Quest: Killer Bunny + p There's a new quest scroll in the Market! Deep within Mount Procrastination lies a once-sweet beast grown horrifying with neglect. Can you rally your strength to defeat the Killer Bunny? If so, you'll get some bunny eggs! + p.small.muted by Draayder, Gully, and TetoIsGreat + tr + td + h5 Egg Purchasing Change + p You can now purchase quest eggs from the Market after defeating the corresponding boss at least once! Previously, you had to defeat the boss at least twice before being able to purchase the eggs. + p.small.muted by Blade + tr + td + h5 Last Day for Survey and Achievement + p March 18th is the final day to complete this survey to receive or stack the Helped Habit Grow survey! After it is closed, it will take us several days to award the badges. Thanks so much for sharing your feedback with us! + p.small.muted by sugarfiend and SabreCat + tr + td + h5 Unequip Buttons + p It’s now easier to switch your avatar’s costume! You can now unequip all your battle gear, costume pieces, and/or pets from the Equipment page using the new Unequip buttons. + p.small.muted by TheHolidayInn + h5 3/10/2015 - SURVEY, TESTIMONIALS GUILD, AND CHAT EXTENSION + hr + tr + td + h5 Survey and Achievement + .achievement.achievement-tree.pull-right + p We're giving out the rare Helped Habit Grow achievement to all users who help us out by completing this 10-question survey! If you already received this badge, taking this new survey will stack your achievement. Thanks for sparing a minute to let us know what you think about HabitRPG! + p.small.muted by sugarfiend and SabreCat + tr + td + h5 Testimonials Guild + p We're collecting testimonials from users to display on the front page along with pictures of their avatars. If HabitRPG has been helpful to you and you feel comfortable leaving a short testimonial for us, you can post it here. Thanks for all your help! <3 + tr + td + h5 Chat Extension + p Horacious Moreau has made a chat extension for HabitRPG! It creates a chat box for Tavern, parties, and Guilds. :) + br + p The Chat Client is also open-source! You can check out the project here. + p.small.muted by Horacious Moreau + h5 3/3/2015 - MARCH BACKGROUNDS, ANDROID APP NOTIFICATIONS, AND MARCH MYSTERY BOX + tr + td + h5 March Backgrounds Revealed + p There are three new avatar backgrounds in the Background Shop! Now your avatar can dance in the Spring Rain, admire some Stained Glass, or frolic through the Rolling Hills! + p.small.muted by (in order) Sunstroke, Kiwibot, and Uncommon Criminal + tr + td + h5 Android App Notifications + p The Android app can now remind you to log in! Simply go to Settings and select the time that you want the reminder. + p.small.muted by Negue + tr + td + .inventory_present.pull-right + h5 March Mystery Box + p Wow! What could it be? All Habiticans who are subscribed during the month of March will receive the March Mystery Item Set! It will be revealed on the 25th, so keep your eyes peeled. Thanks for supporting the site <3 + p.small.muted by Lemoness h5 2/24/2015 - FEBRUARY SUBSCRIBER ITEM AND ADD MULTIPLE TASKS! tr td diff --git a/website/views/shared/profiles/achievements.jade b/website/views/shared/profiles/achievements.jade index b83385032f..fe2ab02ccc 100644 --- a/website/views/shared/profiles/achievements.jade +++ b/website/views/shared/profiles/achievements.jade @@ -14,6 +14,16 @@ if mobile .item.item-divider=env.t('achievements') +div(ng-if='::profile.achievements.habitSurveys || user._id == profile._id') + .achievement.achievement-tree(ng-if='::profile.achievements.habitSurveys') + div(ng-class='::{muted: !profile.achievements.habitSurveys}') + h5=env.t('helped') + small(ng-if='::profile.achievements.habitSurveys > 1') + =env.t('surveysMultiple', {surveys: "{{::profile.achievements.habitSurveys}}"}) + small(ng-if='::!(profile.achievements.habitSurveys > 1)') + =env.t('surveysSingle') + hr + div(ng-if='::profile.backer.npc') .achievement.achievement-helm h5 @@ -42,149 +52,153 @@ div(ng-if='::profile.backer.tier') small=env.t('kickstartText') hr -div(ng-if='profile.achievements.streak || user._id == profile._id') - .achievement.achievement-thermometer(ng-show='profile.achievements.streak') - div(ng-class='{muted: !profile.achievements.streak}') - h5(ng-show='profile.achievements.streak > 1 || !profile.achievements.streak') +div(ng-if='::profile.achievements.streak || user._id == profile._id') + .achievement.achievement-thermometer(ng-if='::profile.achievements.streak') + div(ng-class='::{muted: !profile.achievements.streak}') + h5(ng-if='::profile.achievements.streak > 1 || !profile.achievements.streak') - | {{profile.achievements.streak || 0 }}  + | {{::profile.achievements.streak || 0 }}  =env.t('streakName') - small(ng-show='profile.achievements.streak > 1 || !profile.achievements.streak')=env.t('streakText', {streaks: "{{profile.achievements.streak || 0 }}"}) - h5(ng-show='profile.achievements.streak == 1') + small(ng-if='::profile.achievements.streak > 1 || !profile.achievements.streak')=env.t('streakText', {streaks: "{{::profile.achievements.streak || 0 }}"}) + h5(ng-if='::profile.achievements.streak == 1') =env.t('streakSingular') - small(ng-show='profile.achievements.streak == 1')=env.t('streakSingularText') + small(ng-if='::profile.achievements.streak == 1')=env.t('streakSingularText') hr -div(ng-if='profile.achievements.perfect || user._id == profile._id') - .achievement.achievement-perfect(ng-show='profile.achievements.perfect') - div(ng-class='{muted: !profile.achievements.perfect}') - h5(ng-show='profile.achievements.perfect > 1 || !profile.achievements.perfect') +div(ng-if='::profile.achievements.perfect || user._id == profile._id') + .achievement.achievement-perfect(ng-if='::profile.achievements.perfect') + div(ng-class='::{muted: !profile.achievements.perfect}') + h5(ng-if='::profile.achievements.perfect > 1 || !profile.achievements.perfect') - | {{profile.achievements.perfect || 0 }}  + | {{::profile.achievements.perfect || 0 }}  =env.t('perfectName') - small(ng-show='profile.achievements.perfect > 1 || !profile.achievements.perfect')=env.t('perfectText', {perfects: "{{profile.achievements.perfect || 0 }}"}) - h5(ng-show='profile.achievements.perfect == 1') + small(ng-if='::profile.achievements.perfect > 1 || !profile.achievements.perfect')=env.t('perfectText', {perfects: "{{::profile.achievements.perfect || 0 }}"}) + h5(ng-if='::profile.achievements.perfect == 1') =env.t('perfectSingular') - small(ng-show='profile.achievements.perfect == 1')=env.t('perfectSingularText') + small(ng-if='::profile.achievements.perfect == 1')=env.t('perfectSingularText') hr -//-div(ng-if='profile.achievements.ultimateGear || user._id == profile._id') - .achievement.achievement-armor(ng-show='profile.achievements.ultimateGear') - div(ng-class='{muted: !profile.achievements.ultimateGear}') +div(ng-if='::profile.achievements.ultimateGearSets || user._id == profile._id') + .achievement.achievement-armor(ng-if='::profile.achievements.ultimateGearSets') + div(ng-class='::{muted: !profile.achievements.ultimateGearSets}') h5=env.t('ultimGearName') small=env.t('ultimGearText') - hr -// Remove the following when ultimate gear is fixed (https://github.com/HabitRPG/habitrpg/issues/2232): -div(ng-if='::user._id == profile._id') - div.muted - h5=env.t('ultimGearName') - small - +aLink('https://github.com/HabitRPG/habitrpg/issues/2232', 'Returning soon') + table.multi-achievement + tr + td(ng-if='::profile.achievements.ultimateGearSets.healer').multi-achievement + .achievement-ultimate-healer.multi-achievement + =env.t('healer') + td(ng-if='::profile.achievements.ultimateGearSets.wizard').multi-achievement + .achievement-ultimate-mage.multi-achievement + =env.t('mage') + td(ng-if='::profile.achievements.ultimateGearSets.rogue').multi-achievement + .achievement-ultimate-rogue.multi-achievement + =env.t('rogue') + td(ng-if='::profile.achievements.ultimateGearSets.warrior').multi-achievement + .achievement-ultimate-warrior.multi-achievement + =env.t('warrior') hr -div(ng-if='profile.achievements.beastMaster || user._id == profile._id') - .achievement.achievement-rat(ng-show='profile.achievements.beastMaster') - div(ng-class='{muted: !profile.achievements.beastMaster}') +div(ng-if='::profile.achievements.beastMaster || user._id == profile._id') + .achievement.achievement-rat(ng-if='::profile.achievements.beastMaster') + div(ng-class='::{muted: !profile.achievements.beastMaster}') h5=env.t('beastMasterName') small=env.t('beastMasterText') - small(ng-if='profile.achievements.beastMasterCount') - =env.t('beastMasterText2', {count: "{{profile.achievements.beastMasterCount}}"}) + small(ng-if='::profile.achievements.beastMasterCount') + =env.t('beastMasterText2', {count: "{{::profile.achievements.beastMasterCount}}"}) hr -div(ng-if='profile.achievements.mountMaster || user._id == profile._id') - .achievement.achievement-wolf(ng-show='profile.achievements.mountMaster') - div(ng-class='{muted: !profile.achievements.mountMaster}') +div(ng-if='::profile.achievements.mountMaster || user._id == profile._id') + .achievement.achievement-wolf(ng-if='::profile.achievements.mountMaster') + div(ng-class='::{muted: !profile.achievements.mountMaster}') h5=env.t('mountMasterName') small=env.t('mountMasterText') - small(ng-if='profile.achievements.mountMasterCount') - =env.t('mountMasterText2', {count: "{{profile.achievements.mountMasterCount}}"}) + small(ng-if='::profile.achievements.mountMasterCount') + =env.t('mountMasterText2', {count: "{{::profile.achievements.mountMasterCount}}"}) hr -div(ng-if='profile.achievements.triadBingo || user._id == profile._id') - .achievement.achievement-triadbingo(ng-show='profile.achievements.triadBingo') - div(ng-class='{muted: !profile.achievements.triadBingo}') +div(ng-if='::profile.achievements.triadBingo || user._id == profile._id') + .achievement.achievement-triadbingo(ng-if='::profile.achievements.triadBingo') + div(ng-class='::{muted: !profile.achievements.triadBingo}') h5=env.t('triadBingoName') small=env.t('triadBingoText') - small(ng-if='profile.achievements.triadBingoCount') - =env.t('triadBingoText2', {count: "{{profile.achievements.triadBingoCount}}"}) + small(ng-if='::profile.achievements.triadBingoCount') + =env.t('triadBingoText2', {count: "{{::profile.achievements.triadBingoCount}}"}) hr -div(ng-if='profile.achievements.rebirths') +div(ng-if='::profile.achievements.rebirths') .achievement.achievement-sun - h5(ng-if='profile.achievements.rebirths == 1')=env.t('rebirthBegan') - h5(ng-if='profile.achievements.rebirths > 1') - =env.t('rebirthText', {rebirths: "{{profile.achievements.rebirths}}"}) + h5(ng-if='::profile.achievements.rebirths == 1')=env.t('rebirthBegan') + h5(ng-if='::profile.achievements.rebirths > 1') + =env.t('rebirthText', {rebirths: "{{::profile.achievements.rebirths}}"}) small =env.t('rebirthOrb') - | {{profile.achievements.rebirthLevel}}. + | {{::profile.achievements.rebirthLevel}}. hr -div(ng-if='::profile.achievements.helpedHabit') - .achievement.achievement-tree - h5=env.t('helped') - small - =env.t('helpedText1') - |  - +aLink('http://community.habitrpg.com/node/290', env.t('helpedText2')) - hr - -div(ng-if=':: profile.achievements.veteran') +div(ng-if='::profile.achievements.veteran') .achievement.achievement-cake div(ng-if='::profile.achievements.veteran') h5=env.t('veteran') small=env.t('veteranText') hr -div(ng-if=':: profile.achievements.originalUser') +div(ng-if='::profile.achievements.originalUser') .achievement.achievement-alpha div(ng-if='::profile.achievements.originalUser') h5=env.t('originalUser') small!=env.t('originalUserText') hr -div(ng-if='profile.achievements.challenges || user._id == profile._id') +div(ng-if='::profile.achievements.challenges.length || user._id == profile._id') // This is a very strange icon to use. revisit - .achievement.achievement-karaoke(ng-show='profile.achievements.challenges') - div(ng-class='{muted: !profile.achievements.challenges}') + .achievement.achievement-karaoke(ng-if='::profile.achievements.challenges.length') + div(ng-class='::{muted: !profile.achievements.challenges.length}') h5=env.t('challengeWinner') table.table.table-striped tr(ng-repeat='chal in profile.achievements.challenges track by $index') td {{::chal}} hr -div(ng-if='profile.achievements.quests || user._id == profile._id') - .achievement.achievement-alien(ng-show='profile.achievements.quests') - div(ng-class='{muted: !profile.achievements.quests}') +div(ng-if='::profile.achievements.quests || user._id == profile._id') + .achievement.achievement-alien(ng-if='::profile.achievements.quests') + div(ng-class='::{muted: !profile.achievements.quests}') h5=env.t('completedQuests') table.table.table-striped tr(ng-repeat='(k,v) in profile.achievements.quests') td {{::Content.quests[k].text()}} - td x{{v}} + td x{{::v}} hr -div(ng-if='profile.achievements.snowball') +div(ng-if='::profile.achievements.snowball') .achievement.achievement-snowball h5=env.t('annoyingFriends') small - =env.t('annoyingFriendsText', {snowballs: "{{profile.achievements.snowball}}"}) + =env.t('annoyingFriendsText', {snowballs: "{{::profile.achievements.snowball}}"}) hr -div(ng-if='profile.achievements.spookDust') +div(ng-if='::profile.achievements.spookDust') .achievement.achievement-spookDust h5=env.t('alarmingFriends') small - =env.t('alarmingFriendsText', {spookDust: "{{profile.achievements.spookDust}}"}) + =env.t('alarmingFriendsText', {spookDust: "{{::profile.achievements.spookDust}}"}) + hr + +div(ng-if='::profile.achievements.shinySeed') + .achievement.achievement-shinySeed + h5=env.t('agriculturalFriends') + small + =env.t('agriculturalFriendsText', {seeds: "{{::profile.achievements.shinySeed}}"}) hr div(ng-if='::profile.achievements.habitBirthdays') .achievement.achievement-habitBirthday h5=env.t('habitBirthday') small(ng-if='::profile.achievements.habitBirthdays == 1') - =env.t('habitBirthdayText') small(ng-if='::profile.achievements.habitBirthdays > 1') - =env.t('habitBirthdayPluralText', {number: "{{profile.achievements.habitBirthdays}}"}) + =env.t('habitBirthdayPluralText', {number: "{{::profile.achievements.habitBirthdays}}"}) hr div(ng-if='::profile.achievements.valentine') @@ -205,7 +219,7 @@ div(ng-if='::profile.achievements.costumeContest') .achievement.achievement-costumeContest h5=env.t('costumeContest') small - =env.t('costumeContestText') + =env.t('costumeContestText') hr div(ng-if='::profile.achievements.nye') diff --git a/website/views/shared/profiles/stats.jade b/website/views/shared/profiles/stats.jade index df1d72404f..476c114143 100644 --- a/website/views/shared/profiles/stats.jade +++ b/website/views/shared/profiles/stats.jade @@ -3,15 +3,15 @@ table.table.table-striped tr td strong=env.t('health') - | : {{profile.stats.hp | number:0}} / 50 + | : {{Math.ceil(profile.stats.hp)}} / 50 tr(ng-if='profile.stats.lvl >= 10 && !profile.preferences.disableClasses') td strong=env.t('mana') - | : {{profile.stats.mp | number:0}} / {{profile._statsComputed.maxMP}} + | : {{Math.floor(profile.stats.mp)}} / {{profile._statsComputed.maxMP}} tr td strong=env.t('gold') - | : {{profile.stats.gp | number:0}} + | : {{Math.floor(profile.stats.gp)}} tr td strong=env.t('level') @@ -19,7 +19,7 @@ table.table.table-striped tr td strong=env.t('experience') - | : {{profile.stats.exp | number:0}} / {{Shared.tnl(profile.stats.lvl)}} + | : {{Math.floor(profile.stats.exp)}} / {{Shared.tnl(profile.stats.lvl)}} // FIXME get translations working before can use this unless mobile @@ -43,13 +43,13 @@ table.table.table-striped ul.list-unstyled(ng-init='g=Content.gear.flat;e=profile.items.gear.equipped') li(ng-show='profile.stats.lvl > 1') span.hint(popover-title=env.t('levelBonus'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('levelBonusText'))=env.t('level') - |: {{(profile.stats.lvl - 1) / 2}}  + |: {{Math.ceil((Math.min(profile.stats.lvl - 1, 100)) / 2)}}  li(ng-show='g[e.weapon].#{k} + g[e.armor].#{k} + g[e.head].#{k} + g[e.shield].#{k} > 0') span.hint(popover-title=env.t('equipment'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('equipmentBonusText'))=env.t('equipment') |: {{g[e.weapon].#{k} + g[e.armor].#{k} + g[e.head].#{k} + g[e.shield].#{k} || 0}}  - li(ng-show='profile._statsComputed.#{k} - profile.stats.buffs.#{k} - ((profile.stats.lvl - 1) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k} > 0') + li(ng-show='profile._statsComputed.#{k} - profile.stats.buffs.#{k} - Math.ceil((Math.min(profile.stats.lvl - 1, 100)) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k} > 0') span.hint(popover-title=env.t('classBonus'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('classBonusText'))=env.t('classEquipBonus') - |: {{profile._statsComputed.#{k} - profile.stats.buffs.#{k} - ((profile.stats.lvl - 1) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k}}}  + |: {{profile._statsComputed.#{k} - profile.stats.buffs.#{k} - Math.ceil((Math.min(profile.stats.lvl - 1,100)) / 2) - g[e.weapon].#{k} - g[e.armor].#{k} - g[e.head].#{k} - g[e.shield].#{k} - profile.stats.#{k}}}  li(ng-show='profile.stats.#{k} > 0') span.hint(popover-title=env.t('allocatedPoints'), popover-trigger='mouseenter', popover-placement='top', popover=env.t('allocatedPointsText'))=env.t('allocated') |: {{profile.stats.#{k} || 0}}  diff --git a/website/views/shared/tasks/lists.jade b/website/views/shared/tasks/lists.jade index cd37d2962c..013f653bb8 100644 --- a/website/views/shared/tasks/lists.jade +++ b/website/views/shared/tasks/lists.jade @@ -8,30 +8,69 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template") .task-column(class='{{list.type}}s') // Todos export/graph options - span.option-box.pull-right(ng-if='::main && list.type=="todo"') - a.option-action(ng-show='obj.history.todos', ng-click='toggleChart("todos")', tooltip=env.t('progress')) + span.option-box.pull-right(ng-if='::main') + a.option-action(ng-if='list.type=="todo"', ng-show='obj.history.todos', ng-click='toggleChart("todos")', tooltip=env.t('progress'), style='margin-right:5px;') span.glyphicon.glyphicon-signal //a.option-action(ng-href='/v1/users/{{user.id}}/calendar.ics?apiToken={{user.apiToken}}', tooltip='iCal') - a.option-action(ng-click='notPorted()', tooltip='iCal', ng-show='false') + //-a.option-action(ng-if='list.type=="todo"', ng-click='notPorted()', tooltip='iCal', ng-show='false') span.glyphicon.glyphicon-calendar // + a.option-action(ng-click='list.help=!list.help', tooltip='Click for help') + span.glyphicon.glyphicon-question-sign(style={'zoom':1.5,'vertical-align':'-webkit-baseline-middle'}) // Header - h2.task-column_title {{list.header}} + h2.task-column_title + | {{list.header}} + + div(ng-if='list.help', ng-switch='::list.type') + div(ng-switch-when='habit') + ul + li!=env.t('habitHelp1', {plusIcon:""}) + li!=env.t('habitHelp2', {minusIcon:""}) + li!=env.t('habitHelp3') + li!=env.t('newbieGuild', {linkStart:"", linkEnd: ""}) + div(ng-switch-when='daily') + ul + li!=env.t('dailyHelp1', {emphasisStart:"", emphasisEnd:"", pencilIcon:""}) + li=env.t('dailyHelp2') + li!=env.t('dailyHelp3', {emphasisStart:"", emphasisEnd:""}) + li!=env.t('dailyHelp4', {linkStart:"", linkEnd:""}) + li!=env.t('dailyHelp5') + li!=env.t('newbieGuild', {linkStart:"", linkEnd: ""}) + div(ng-switch-when='todo') + ul + li=env.t('toDoHelp1') + li=env.t('toDoHelp2') + li=env.t('toDoHelp3') + li!=env.t('toDoHelp4') + li!=env.t('newbieGuild', {linkStart:"", linkEnd: ""}) + div(ng-switch-when='reward') + ul + li!=env.t('rewardHelp1', {linkStart:"", linkEnd: ""}) + li!=env.t('rewardHelp2', {linkStart:"", linkEnd: ""}) + li=env.t('rewardHelp3') + li!=env.t('rewardHelp4') + li!=env.t('newbieGuild', {linkStart:"", linkEnd: ""}) // Todo Chart .todos-chart(ng-if='::list.type == "todo"', ng-show='charts.todos') // Add New - form.task-add(name='new{{list.type}}form', ng-hide='obj._locked', ng-submit='addTask(obj[list.type+"s"],list)') + form.task-add(name='new{{list.type}}form', ng-hide='obj._locked', ng-submit='addTask(obj[list.type+"s"],list)' novalidate) textarea(rows='6', task-focus='list.bulk && list.focus', ng-model='list.newTask', placeholder='{{list.placeHolderBulk}}', ng-if='list.bulk', ui-keydown='{"meta-enter ctrl-enter":"addTask(obj[list.type+\'s\'],list)"}', required) input(type='text', task-focus='!list.bulk && list.focus', ng-model='list.newTask', placeholder='{{list.placeHolder}}', ng-if='!list.bulk', required) button(type='submit', ng-disabled='new{{list.type}}form.$invalid') - span.glyphicon.glyphicon-plus + div.empty-task-notification( ng-show='new{{list.type}}form.$invalid', tooltip=env.t("emptyTask") ) + span.glyphicon.glyphicon-plus + span.glyphicon.glyphicon-plus(ng-show='!new{{list.type}}form.$invalid') small.help-block.btn-link.pull-right(ng-click='toggleBulk(list)') span(ng-if='!list.bulk')=env.t('addmultiple') span(ng-if='list.bulk')=env.t('addsingle') + alert.alert-warning.dailiesRestingInInn(ng-if='::list.type == "daily" && user.preferences.sleep') + i.glyphicon.glyphicon-warning-sign   + =env.t('dailiesRestingInInn') + mixin taskColumnTabs(position) // Habits Tabs div(ng-if='::main && list.type=="habit"', class='tabbable tabs-below') @@ -64,7 +103,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template") ul.task-filter li(ng-class='{active: list.view == "remaining"}') a(ng-click='list.view = "remaining"')=env.t('remaining') - li(ng-class='{active: list.view == "dated"}', tooltip=env.t('datedNotSorted')) + li(ng-class='{active: list.view == "dated"}') a(ng-click='list.view = "dated"')=env.t('dated') li(ng-class='{active: list.view == "complete"}') a(ng-click='list.view = "complete"')=env.t('complete') @@ -79,12 +118,15 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template") +taskColumnTabs('top') // Actual List - ul(class='{{list.type}}s main-list', ng-show='obj[list.type + "s"].length > 0', hrpg-sort-tasks) + ul(class='{{list.type}}s main-list', ng-show='obj[list.type + "s"].length > 0', hrpg-sort-tasks, ng-if='!$state.includes("options.social.challenges")') + include ./task + //Loads the non-sortable lists for challenges + ul(class='{{list.type}}s main-list', ng-show='obj[list.type + "s"].length > 0', ng-if='$state.includes("options.social.challenges")') include ./task // Static Rewards - ul.items.rewards(ng-if='main && list.type=="reward" && user.flags.itemsEnabled') - li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.notes()}}') + ul.items.rewards(ng-if='main && list.type=="reward"') + li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.key == "armoire" && !user.flags.armoireEmpty ? env.t("armoireNotesFull") + armoireCount(user.items.gear.owned) : item.notes()}}') // right-hand side control buttons .task-meta-controls span.task-notes @@ -99,7 +141,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template") p.task-text {{item.text()}} // Events - ul.items.rewards(ng-if='main && list.type=="reward" && (user.items.special.snowball>0 || user.stats.buffs.snowball || user.items.special.spookDust>0 || user.stats.buffs.spookDust)') + ul.items.rewards(ng-if='main && list.type=="reward" && (user.items.special.snowball>0 || user.stats.buffs.snowball || user.items.special.spookDust>0 || user.stats.buffs.spookDust || user.items.special.shinySeed>0 || user.stats.buffs.shinySeed)') mixin specialSpell(k,canceler) li.task.reward-item(ng-if='#{canceler ? "user.stats.buffs."+canceler : "user.items.special."+k+">0"}',popover-trigger='mouseenter', popover-placement='top', popover='{{Content.spells.special.#{k}.notes()}}') @@ -120,9 +162,10 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template") +specialSpell('snowball') +specialSpell('spookDust') - + +specialSpell('shinySeed') +specialSpell('salt','snowball') +specialSpell('opaquePotion','spookDust') + +specialSpell('petalFreePotion','shinySeed') // Spells ul.items(ng-if='main && list.type=="reward" && user.stats.class && !user.preferences.disableClasses') @@ -142,12 +185,4 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template") br - // Ads - div(ng-if='::main && !user.purchased.ads && !user.purchased.plan.customerId && list.type!="reward"') - span.pull-right - a(ui-sref='options.settings.subscription', popover=env.t('removeAds'), popover-trigger='mouseenter') - span.glyphicon.glyphicon-remove - // Habit3 - ins.adsbygoogle(ng-init='initAds()', style='display: inline-block; width: 234px; height: 60px;', data-ad-client='ca-pub-3242350243827794', data-ad-slot='9529624576') - +taskColumnTabs('bottom') diff --git a/website/views/shared/tasks/task.jade b/website/views/shared/tasks/task.jade index 259066f098..9fa9a68bbe 100644 --- a/website/views/shared/tasks/task.jade +++ b/website/views/shared/tasks/task.jade @@ -1,11 +1,11 @@ -li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s"]', class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)', ng-class='{"cast-target":spell && (list.type != "reward")}', popover-trigger='mouseenter', data-popover-html="{{task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}', ng-show='shouldShow(task, list, user.preferences)') +li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s"] | conditionalOrderBy: list.view=="dated":"date"', class='task {{Shared.taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', ng-click='spell && (list.type != "reward") && castEnd(task, "task", $event)', ng-class='{"cast-target":spell && (list.type != "reward"), "locked-task":obj._locked === true}', popover-trigger='mouseenter', data-popover-html="{{task.popoverOpen ? '' : task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}', ng-show='shouldShow(task, list, user.preferences)') // right-hand side control buttons .task-meta-controls // Due Date span(ng-if='task.type=="todo" && task.date') span(ng-class='{"label label-danger":(moment(task.date).isBefore(_today, "days") && !task.completed)}') {{task.date | date:(user.preferences.dateFormat.indexOf('yyyy') == 0 ? user.preferences.dateFormat.substr(5) : user.preferences.dateFormat.substr(0,5))}} - + // Streak |   span(ng-show='task.streak') {{task.streak}}  @@ -44,18 +44,18 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s span.glyphicon.glyphicon-bullhorn(tooltip=env.t('challenge')) |   // delete - a(ng-if='!task.challenge.id', ng-click='removeTask(obj[list.type+"s"], $index)', tooltip=env.t('delete')) + a(ng-if='!task.challenge.id', ng-click='removeTask(task, obj[list.type+"s"])', tooltip=env.t('delete')) span.glyphicon.glyphicon-trash |   - // chart - a(ng-show='task.history', ng-click='toggleChart(obj._id+task.id, task)', tooltip=env.t('progress')) - span.glyphicon.glyphicon-signal - |   - // notes - span.task-notes(ng-show='task.notes && !task._editing') - span.glyphicon.glyphicon-comment - |   + // chart + a(ng-show='task.history', ng-click='toggleChart(obj._id+task.id, task)', tooltip=env.t('progress')) + span.glyphicon.glyphicon-signal + |   + // notes + span.task-notes(ng-show='task.notes && !task._editing', ng-click='task.popoverOpen = !task.popoverOpen', popover-trigger='click', data-popover-html="{{task.notes | markdown}}", popover-placement="top", popover-append-to-body='{{::modal ? "false":"true"}}') + span.glyphicon.glyphicon-comment + |   // left-hand side checkbox .task-controls.task-primary(ng-if='!task._editing') @@ -101,7 +101,7 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s p a(ng-click='unlink(task, "keep")')=env.t('keepIt') |    - a(ng-click="removeTask(obj[list.type+'s'], $index)")=env.t('removeIt') + a(ng-click="removeTask(task, obj[list.type+'s'])")=env.t('removeIt') div(ng-if='task.challenge.broken=="CHALLENGE_DELETED"') p |  @@ -146,7 +146,7 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s //input(type='checkbox',ng-model='item.completed',ng-change='saveTask(task,true)') //-,ng-blur='saveTask(task,true)') span.checklist-icon.glyphicon.glyphicon-resize-vertical() - input(type='text',ng-model='item.text',ui-keydown="{'8 46':'removeChecklistItem(task,$event,$index)'}",ui-keyup="{'13':'addChecklistItem(task,$event,$index)','38 40':'navigateChecklist(task,$index,$event)'}") + input(type='text',ng-model='item.text', ui-keyup="{'13':'addChecklistItem(task,$event,$index)','38 40':'navigateChecklist(task,$index,$event)'}") a(ng-click='removeChecklistItem(task,$event,$index,true)') span.glyphicon.glyphicon-trash(tooltip=env.t('delete')) @@ -210,7 +210,7 @@ li(bindonce='list', bo-id='"task-"+task.id', ng-repeat='task in obj[list.type+"s p.option-title.mega(ng-click='task._advanced = !task._advanced', tooltip=env.t('expandCollapse'))=env.t('advancedOptions') fieldset.option-group.advanced-option(ng-class="{visuallyhidden: task._advanced}") legend.option-title - a.hint.priority-multiplier-help(href='https://trello.com/card/priority-multiplier/50e5d3684fe3a7266b0036d6/17', target='_blank', popover-title=env.t('difficultyHelpTitle'), popover-trigger='mouseenter', popover=env.t('difficultyHelpContent'))=env.t('difficulty') + a.hint.priority-multiplier-help(href='http://habitrpg.wikia.com/wiki/Difficulty', target='_blank', popover-title=env.t('difficultyHelpTitle'), popover-trigger='mouseenter', popover=env.t('difficultyHelpContent'))=env.t('difficulty') ul.priority-multiplier li button(type='button', ng-class='{active: task.priority==1 || !task.priority}', ng-click='task.challenge.id || (task.priority=1)')=env.t('easy') diff --git a/website/views/static/api.jade b/website/views/static/api.jade index f4bbd576f3..1ed3be1079 100644 --- a/website/views/static/api.jade +++ b/website/views/static/api.jade @@ -86,8 +86,9 @@ html li POST to the URL /api/v2/user/tasks/{id}/{direction} ul li {direction} is 'up' or 'down' - li {id} is a unique identifier for a task, which you make up, consisting of lowercase letters. Try to make it something common, like 'productivity' or 'fitness' - because other services may piggy-back off your task. For example, the Chrome extension down-scores a productivity task when you visit vice websites (reddit, 9gag, etc). However, Pomodoro up-scores productivity when you complete a task. So the two services share a single task to score your overall productivity. If the task doesn't yet exist, it is created the first time you POST to this URL. + li {id} is a unique identifier for a Habit, which you make up, consisting of lowercase letters. Try to make it something common, like 'productivity' or 'fitness' - because other services may piggy-back off your Habit. For example, the Chrome extension down-scores a productivity Habit when you visit vice websites (reddit, 9gag, etc). However, Pomodoro up-scores productivity when you complete a Pomodoro task. So the two services share a single Habit to score your overall productivity. If the Habit doesn't yet exist, it is created the first time you POST to this URL. li apiToken (POST body) required + p A more advanced version that allows modification of other types of tasks is available in the /user/tasks/{id}/{direction} route in the full API below. h2 Full API p All API requests should be prefaced by https://habitrpg.com. Every authenticated request should include two headers. Your api key (x-api-key) and your user id (x-api-user). Do not include {} braces in your header (-H 'x-api-user: a94b6d9d-6b64-43ae-856c-2c3f211bd426') h2 Requirements: diff --git a/website/views/static/community-guidelines.jade b/website/views/static/community-guidelines.jade index 4af0c13a60..a31cf34781 100644 --- a/website/views/static/community-guidelines.jade +++ b/website/views/static/community-guidelines.jade @@ -26,28 +26,29 @@ block content .page-header h1=env.t('communityGuidelines') p.pagemeta - |Last updated  - =env.t('February') - | 9, 2015 - h2=env.t('commGuideHeadingWelcome') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/intro.png', alt='') + =env.t('lastUpdated') + |  + =env.t('May') + | 27, 2015 + h2#welcome=env.t('commGuideHeadingWelcome') + .clearfix + img.pull-left(src='/community-guidelines-images/intro.png', alt='') p=env.t('commGuidePara001') p=env.t('commGuidePara002') p=env.t('commGuidePara003') p=env.t('commGuidePara004') - h2=env.t('commGuideHeadingBeing') + h2#being-habitican=env.t('commGuideHeadingBeing') p=env.t('commGuidePara005') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/beingHabitican.png', alt='') + .clearfix + img.pull-right(src='/community-guidelines-images/beingHabitican.png', alt='') ul li!=env.t('commGuideList01A') li!=env.t('commGuideList01B') li!=env.t('commGuideList01C') li!=env.t('commGuideList01D') - h2=env.t('commGuideHeadingMeet') + h2#meet-the-mods=env.t('commGuideHeadingMeet') p=env.t('commGuidePara006') p strong=env.t('commGuidePara007') @@ -55,9 +56,9 @@ block content strong=env.t('commGuidePara008') p strong=env.t('commGuidePara009') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/staff.png', alt='') - ul(class='pull-left list-unstyled') + .clearfix + img.pull-left(src='/community-guidelines-images/staff.png', alt='') + ul.pull-left.list-unstyled li strong Lefnire (Tyler Renelle) li @@ -76,9 +77,11 @@ block content p=env.t('commGuidePara010') p strong=env.t('commGuidePara011') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/moderators.png', alt='') - ul(class='pull-left list-unstyled') + .clearfix + img.pull-left(src='/community-guidelines-images/moderators.png', alt='') + ul.pull-left.list-unstyled + li + strong beffymaroo li strong Bailey (It's Bailey  =env.t('commGuidePara011a') @@ -106,9 +109,9 @@ block content p=env.t('commGuidePara014') |  em Slappybag, litenull, Shaner, Bobbyroberts99, wc8 - h2=env.t('commGuideHeadingPublicSpaces') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/publicSpaces.png', alt='') + h2#public-spaces=env.t('commGuideHeadingPublicSpaces') + .clearfix + img.pull-right(src='/community-guidelines-images/publicSpaces.png', alt='') p=env.t('commGuidePara015') p=env.t('commGuidePara016') p!=env.t('commGuidePara017') @@ -127,18 +130,18 @@ block content p   p=env.t('commGuidePara021') - h3=env.t('commGuideHeadingTavern') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/tavern.png', alt='') + h3#tavern=env.t('commGuideHeadingTavern') + .clearfix + img.pull-left(src='/community-guidelines-images/tavern.png', alt='') p=env.t('commGuidePara022') p strong=env.t('commGuidePara023') p!=env.t('commGuidePara024') p!=env.t('commGuidePara027') - h3=env.t('commGuideHeadingPublicGuilds') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/publicGuilds.png', alt='') + h3#guilds=env.t('commGuideHeadingPublicGuilds') + .clearfix + img.pull-right(src='/community-guidelines-images/publicGuilds.png', alt='') p!=env.t('commGuidePara029') p!=env.t('commGuidePara031') p!=env.t('commGuidePara033') @@ -146,15 +149,15 @@ block content p strong=env.t('commGuidePara037') - h3=env.t('commGuideHeadingBackCorner') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/backCorner.png', alt='') + h3#back-corner=env.t('commGuideHeadingBackCorner') + .clearfix + img.pull-left(src='/community-guidelines-images/backCorner.png', alt='') p!=env.t('commGuidePara038') p!=env.t('commGuidePara039') - h3=env.t('commGuideHeadingTrello') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/trello.png', alt='') + h3#trello=env.t('commGuideHeadingTrello') + .clearfix + img.pull-right(src='/community-guidelines-images/trello.png', alt='') p!=env.t('commGuidePara040') p strong=env.t('commGuidePara041') @@ -166,13 +169,13 @@ block content li!=env.t('commGuideList03E') p!=env.t('commGuidePara042') - h3=env.t('commGuideHeadingGitHub') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/github.gif', alt='') + h3#github=env.t('commGuideHeadingGitHub') + .clearfix + img.pull-left(src='/community-guidelines-images/github.gif', alt='') p!=env.t('commGuidePara043') p strong=env.t('commGuidePara044') - ul(class='listColumns2 peopleList') + ul.listColumns2.peopleList li lefnire (Tyler) li Alys li benmanley (Pixel) @@ -195,9 +198,9 @@ block content li MagicMicky li viirus - h3=env.t('commGuideHeadingWiki') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/wiki.png', alt='') + h3#wiki=env.t('commGuideHeadingWiki') + .clearfix + img.pull-right(src='/community-guidelines-images/wiki.png', alt='') p!=env.t('commGuidePara045') p=env.t('commGuidePara046') p @@ -214,7 +217,7 @@ block content li=env.t('commGuideList04H') p strong=env.t('commGuidePara049') - ul(class='peopleList') + ul.peopleList li Breadstrings (bureaucrat) li JiggerD li LadyAlys @@ -224,10 +227,10 @@ block content |:  em Bobbyroberts99 (founder and bureaucrat), wc8 (bureaucrat) - h2=env.t('commGuideHeadingInfractionsEtc') - h3=env.t('commGuideHeadingInfractions') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/infractions.png', alt='') + h2#infractions-consequences-restoration=env.t('commGuideHeadingInfractionsEtc') + h3#infractions=env.t('commGuideHeadingInfractions') + .clearfix + img.pull-left(src='/community-guidelines-images/infractions.png', alt='') p=env.t('commGuidePara050') p!=env.t('commGuidePara051') h4=env.t('commGuideHeadingSevereInfractions') @@ -255,9 +258,9 @@ block content li=env.t('commGuideList07A') li=env.t('commGuideList07B') - h3=env.t('commGuideHeadingConsequences') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/consequences.png', alt='') + h3#consequences=env.t('commGuideHeadingConsequences') + .clearfix + img.pull-right(src='/community-guidelines-images/consequences.png', alt='') p=env.t('commGuidePara058') p!=env.t('commGuidePara059') p @@ -287,16 +290,16 @@ block content li=env.t('commGuideList11D') li=env.t('commGuideList11E') - h3=env.t('commGuideHeadingRestoration') - div(class='clearfix') - img(class='pull-left', src='/community-guidelines-images/restoration.png', alt='') + h3#restoration=env.t('commGuideHeadingRestoration') + .clearfix + img.pull-left(src='/community-guidelines-images/restoration.png', alt='') p!=env.t('commGuidePara061') p!=env.t('commGuidePara062') p!=env.t('commGuidePara063') - h2=env.t('commGuideHeadingContributing') - div(class='clearfix') - img(class='pull-right', src='/community-guidelines-images/contributing.png', alt='') + h2#contributing=env.t('commGuideHeadingContributing') + .clearfix + img.pull-right(src='/community-guidelines-images/contributing.png', alt='') p=env.t('commGuidePara064') ol li=env.t('commGuideList12A') @@ -314,11 +317,11 @@ block content li!=env.t('commGuideList13C') li!=env.t('commGuideList13D') - h2=env.t('commGuideHeadingFinal') + h2#final=env.t('commGuideHeadingFinal') p!=env.t('commGuidePara067') p=env.t('commGuidePara068') - h2=env.t('commGuideHeadingLinks') + h2#links=env.t('commGuideHeadingLinks') ul li a(href='https://habitrpg.com/#/options/groups/guilds/5481ccf3-5d2d-48a9-a871-70a7380cee5a' target='_blank')=env.t('commGuideLink01') @@ -355,7 +358,7 @@ block content p strong=env.t('commGuidePara069') - ul(class='listColumns2 peopleList') + ul.listColumns2.peopleList li Breadstrings li Draayder li Kiwibot diff --git a/website/views/static/contact.jade b/website/views/static/contact.jade index 48b9e0eee0..98bfaec23a 100644 --- a/website/views/static/contact.jade +++ b/website/views/static/contact.jade @@ -13,23 +13,30 @@ block content .page-header h1=env.t('contactUs') p - | Report Account Problems: + =env.t('reportAccountProblems') + | :  a(href='mailto:admin@habitrpg.com') admin@habitrpg.com br - | Report a Bug: + =env.t('reportBug') + | :  a(target='_blank', href='https://github.com/HabitRPG/habitrpg/issues?q=is%3Aopen') Github br - | Report Community Issues: + =env.t('reportCommunityIssues') + | :  a(href='mailto:leslie@habitrpg.com') leslie@habitrpg.com br - | General Questions about the Site: + =env.t('generalQuestionsSite') + | :  a(target='_blank', href='http://habitrpg.wikia.com/wiki/The_Keep:The_Newbies_Guild') Newbies Guild br - | Business Inquiries: + =env.t('businessInquiries') + | :  a(href='mailto:vicky@habitrpg.com') vicky@habitrpg.com br - | Merchandise Inquiries: + =env.t('merchandiseInquiries') + | :  a(href='mailto:store@habitrpg.com') store@habitrpg.com br - | Marketing/Social Media Inquiries: + =env.t('marketingInquiries') + | :  a(href='mailto:leslie@habitrpg.com') leslie@habitrpg.com diff --git a/website/views/static/features.jade b/website/views/static/features.jade index 542f76d00c..9fbb9b31fa 100644 --- a/website/views/static/features.jade +++ b/website/views/static/features.jade @@ -89,3 +89,27 @@ block content a.btn.btn-primary(href='/static/videos')=env.t('watchVideos') + hr + p.lead=env.t('landingp1') + h2=env.t('landingp2header') + //images in these parts could be useful, too + //if there's a language workaround, image headers? people like pictures! + p.lead + =env.t('landingp2') + |  + h2=env.t('landingp3header') + //I'm not sold on "Consquences as the title here. Anyone got a better idea? + p.lead + =env.t('landingp3') + |  + h2=env.t('landingp4header') + p.lead=env.t('landingp4') + //- TODO + h2=env.t('landingend') + p.lead + =env.t('landingend2') + a(href="FEATURESPAGEHERE")=env.t('landingfeatureslink') + =env.t('landingend3') + a(href="ENTERPRISEPAGEHERE")=env.t('landingadminlink') + |  + =env.t('landingend4') \ No newline at end of file diff --git a/website/views/static/front.jade b/website/views/static/front.jade index bbd25b9603..304abfce7e 100644 --- a/website/views/static/front.jade +++ b/website/views/static/front.jade @@ -1,52 +1,656 @@ -extends ./layout -//-Trick needed to pass 'env' to ./layout -block vars - - var layoutEnv = env - - var menuItem = 'home' +doctype html +html(ng-app='habitrpg', ng-controller='RootCtrl') + head + meta(charset='utf-8') + link(href='http://fonts.googleapis.com/css?family=Lato:400,700', rel='stylesheet', type='text/css') + title HabitRPG | Your Life the Role Playing Game + meta(name='description', content='') + meta(name='keywords', content='') + meta(name='author', content='') + meta(name='geo.placename', content='') + //if IE + meta(http-equiv='imagetoolbar', content='no') + meta(name='viewport', content='width=device-width, maximum-scale=1') + meta(property='og:title', content='') + meta(property='og:description', content='') + meta(property='og:url', content='') + meta(property='og:image', content='') + meta(property='og:site_name', content='') + link(rel='canonical', href='', type='text/html') + //-link(rel='sitemap', type='application/xml', title='Sitemap', href='/sitemap.xml') + link(rel='shortcut icon', href='/images/favicon-8b58f6a1.ico') + //if lt IE 9 + script(src='//html5shim.googlecode.com/svn/trunk/html5.js') -block title - title=env.t('titleFront') -block content - div(ng-controller='RootCtrl') + link(rel='stylesheet', type='text/css', href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css') + + script(type='text/javascript'). + window.env = !{JSON.stringify(env)}; + != env.getManifestFiles("tmp_static_front") + + script(type='text/javascript', src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js') + script(type='text/javascript', src='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap.min.js') + script(type='text/javascript', src='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js') + + script(type='text/javascript'). + (function (f, b) {if (!b.__SV) {var a, e, i, g;window.mixpanel = b;b._i = [];b.init = function (a, e, d) {function f(b, h) {var a = h.split(".");2 == a.length && (b = b[a[0]], h = a[1]);b[h] = function () {b.push([h].concat(Array.prototype.slice.call(arguments, 0)))}}var c = b;"undefined" !== typeof d ? c = b[d] = [] : d = "mixpanel";c.people = c.people || [];c.toString = function (b) {var a = "mixpanel";"mixpanel" !== d && (a += "." + d);b || (a += " (stub)");return a};c.people.toString = function () {return c.toString(1) + ".people (stub)"};i = "disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); + for (g = 0; g < i.length; g++)f(c, i[g]);b._i.push([a, e, d])};b.__SV = 1.2;a = f.createElement("script");a.type = "text/javascript";a.async = !0;a.src = "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";e = f.getElementsByTagName("script")[0];e.parentNode.insertBefore(a, e)}})(document, window.mixpanel || []); + mixpanel.init(window.env.MP_ID); + + script(type='text/javascript'). + mixpanel.track("Landing Page"); + + body(ng-controller='AuthCtrl') + include ./login-modal include ../shared/header/avatar + include ../shared/mixins include ../shared/modals/members + .mobile-container + header#header + nav.navbar.navbar-default.navbar-static-top + .container-fluid + // Brand and toggle get grouped for better mobile display + .navbar-header + button.navbar-toggle.collapsed(type='button', data-toggle='collapse', data-target='#bs-example-navbar-collapse-1') + span.sr-only Toggle navigation + span.icon-bar + span.icon-bar + span.icon-bar + a.navbar-brand(href='#') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/icon175x175.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/habitrpg_pixel.png') + // Collect the nav links, forms, and other content for toggling + #bs-example-navbar-collapse-1.collapse.navbar-collapse + ul.nav.navbar-nav.navbar-right + li + a(href='/static/features')=env.t('companyAbout') + li + a(href='/static/plans')=env.t('groupPlans') + li + a(href='http://blog.habitrpg.com/')=env.t('companyBlog') + li + a(href='/static/press-kit')=env.t('presskit') + li + a(href='/static/contact')=env.t('contactUs') + li + button#header-play-button.btn.btn-primary.navbar-btn.navbar-right(ng-click='playButtonClick()')= env.t('playButtonFull') + #intro + h1(ng-cloak) {{ variant==0 ? "#{env.t('motivate')}" : (variant==1 ? "#{env.t('motivate1')}" : "#{env.t('motivate2')}") }} + img.center-block.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/intro.png') + // insert intro images + .introcall.bg-success + h4= env.t('joinOthers') + small + button#play-btn.btn.btn-primary.btn-lg.gamifybutton(ng-click='playButtonClick()')= env.t('free') + .presslogos.text-center + = env.t('featuredIn') + br + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/lifehacker.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/nyt-logo.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/makeuseof.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/Forbes_logo.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/Cnetlogo.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/Fast-Company-logo.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/kickstarter-logo.png') + #intro-text + .container-fluid + .row + .col-md-8.col-md-offset-2 + p.lead.text-center + = env.t('leadText') + section#testimonial-carousel.bg-info + .container-fluid + .row + .col-md-3.col-md-offset-1 + h2= env.t('testimonialHeading') + img.img-say.img-responsive.visible-lg-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/publicSpaces.png') + // Testimonials + .col-md-8.col-sm-10.col-sx-10 + #quote-carousel.carousel.slide(data-interval='10000', data-ride='carousel') + // Bottom Carousel Indicators + ol.carousel-indicators + li.active(data-target='#quote-carousel', data-slide-to='0') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/Drag0nsilver.png', alt='') + li(data-target='#quote-carousel', data-slide-to='1') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/frabjabulous.png', alt='') + li(data-target='#quote-carousel', data-slide-to='2') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/AndeeLiao.png', alt='') + li(data-target='#quote-carousel', data-slide-to='3') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/AlexandraSo.png', alt='') + // Carousel Slides / Quotes + .carousel-inner.text-center + // Quote 1 + .item.active + blockquote + .row + .col-sm-8.col-sm-offset-2 + p + = env.t('dragonsilverQuote') + small Drag0nsilver + // Quote 2 + .item + blockquote + .row + .col-sm-8.col-sm-offset-2 + p + = env.t('frabjabulousQuote') + small frabjabulous + // Quote 3 + .item + blockquote + .row + .col-sm-8.col-sm-offset-2 + p + = env.t('andeeliaoQuote') + small AndeeLiao + .item + blockquote + .row + .col-sm-8.col-sm-offset-2 + p + = env.t('alexandraQuote') + small _AlexandraSo_ + // Carousel Buttons Next/Prev + a.left.carousel-control(data-slide='prev', href='#quote-carousel') + i.fa.fa-chevron-left + a.right.carousel-control(data-slide='next', href='#quote-carousel') + i.fa.fa-chevron-right + button.btn.btn-primary.btn-lg.gamifybutton.fixedcta(ng-click='playButtonClick()')= env.t('gamifyButton') + section#uses + h2= env.t('examplesHeading') + .container-fluid + #myCarousel.carousel.slide(data-interval='10000', data-ride='carousel') + ul.nav.nav-pills.nav-justified + li.active(data-target='#myCarousel', data-slide-to='0') + a(href='#')=env.t('work') + li(data-target='#myCarousel', data-slide-to='1') + a(href='#')=env.t('health') + li(data-target='#myCarousel', data-slide-to='2') + a(href='#')=env.t('teams') + li(data-target='#myCarousel', data-slide-to='3') + a(href='#')=env.t('school') + li(data-target='#myCarousel', data-slide-to='4') + a(href='#')=env.t('goals') + li(data-target='#myCarousel', data-slide-to='5') + a(href='#')=env.t('chores') + // Wrapper for slides + .carousel-inner(style='z-index:0;') + .item.active.work-use + h3 + = env.t('work') + br + small + a(href='/static/plans')= env.t('businessText') + .carousel-content.row + .sampletasks.col-lg-4.col-md-6.col-sm-12.col-xs-12 + h4= env.t('sampleHabits') + div(style='width:100%; background-color: rgb(252, 229, 205); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(219, 120, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('businessSample1') + br + div(style='width:100%; background-color: rgb(201, 218, 248); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(90, 98, 223); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('businessSample2') + br + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('businessSample3') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('businessSample4') + br + div(style='width:100%; background-color: rgb(244, 204, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(220, 93, 93); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(220, 93, 93); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('businessSample5') + img.sample-img.visible-lg-inline-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/coding.png') + .usetweet-groups.col-lg-5.col-md-6.visible-lg-inline-block.visible-md-inline-block + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='frabjabulous', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/frabjabulous.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('frabjabulousQuote') + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='_AlexandraSo_', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/AlexandraSo.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('alexandraQuote') + // End item + .item.health-use + h3= env.t('health') + .carousel-content.row + .sampletasks.col-lg-4.col-md-6.col-sm-12.col-xs-12 + h4= env.t('sampleHabits') + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(113, 176, 91); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('healthSample1') + br + div(style='width:100%; background-color: rgb(244, 204, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(220, 93, 93); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(220, 93, 93); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('healthSample2') + br + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(113, 176, 91); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('healthSample3') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(255, 207, 66); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('healthSample4') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('healthSample5') + img.sample-img.visible-lg-inline-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/clipart-rosemonkeyct-meditation.png') + .usetweet-groups.col-lg-5.col-md-6.visible-lg-inline-block.visible-md-inline-block + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='EvaGantz', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/EvaGantz.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('evagantzQuote') + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='supermouse35', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/supermouse35.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('supermouse35Quote') + // End Item + .item.team-use + h3= env.t('teams') + .carousel-content.row + .sampletasks.col-lg-4.col-md-6.col-sm-12.col-xs-12 + h4= env.t('sampleToDo') + div(style='width:100%; background-color: rgb(252, 229, 205); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(219, 120, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + span(style='padding: 0.5em 0px 0em 0em; color: #666;') ☐ + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('teamSample1') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + span(style='padding: 0.5em 0px 0em 0em; color: #666;') ☐ + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('teamSample2') + br + div(style='width:100%; background-color: rgb(244, 204, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(220, 93, 93); border-right: 1px solid rgba(0, 0, 0, 0.25);') + span(style='padding: 0.5em 0px 0em 0em; color: #666;') ☐ + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('teamSample3') + br + img.sample-img.visible-lg-inline-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/publicSpaces.png') + .usetweet-groups.col-lg-5.col-md-6.visible-lg-inline-block.visible-md-inline-block + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='Althaire', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/Althaire.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('althaireQuote') + // End Item + .item.school-use + h3= env.t('school') + .carousel-content.row + .sampletasks.col-lg-4.col-md-6.col-sm-12.col-xs-12 + h4= env.t('sampleHabits') + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('schoolSample1') + br + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('schoolSample2') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('schoolSample3') + br + div(style='width:100%; background-color: rgb(244, 204, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(220, 93, 93); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(220, 93, 93); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('schoolSample4') + br + div(style='width:100%; background-color: rgb(201, 218, 248); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(90, 98, 223); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(90, 98, 223); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('schoolSample5') + img.sample-img.visible-lg-inline-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/reading.png') + .usetweet-groups.col-lg-5.col-md-6.visible-lg-inline-block.visible-md-inline-block + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='InfH', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/InfH.png') + .usetweet.tweet.popover.right + .arrow + .popover-content= env.t('infhQuote') + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='Drei-M', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/Drei-M.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('dreimQuote') + // End Item + .item.improvement-use + h3= env.t('goals') + .carousel-content.row + .sampletasks.col-lg-4.col-md-6.col-sm-12.col-xs-12 + h4= env.t('sampleDailies') + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('goalSample1') + br + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(113, 176, 91); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('goalSample2') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('goalSample3') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('goalSample4') + br + div(style='width:100%; background-color: rgb(201, 218, 248); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(90, 98, 223); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('goalSample5') + img.sample-img.visible-lg-inline-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/gaining_an_achievement_by_cosmic_caterpillar-d7uyv5z.png') + .usetweet-groups.col-lg-5.col-md-6.visible-lg-inline-block.visible-md-inline-block + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='Kazui', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/Kazui.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('kazuiQuote') + // End Item + .item.housework-use + h3= env.t('chores') + .carousel-content.row + .sampletasks.col-lg-4.col-md-6.col-sm-12.col-xs-12 + h4= env.t('sampleDailies') + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('choreSample1') + br + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(113, 176, 91); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('choreSample2') + br + div(style='width:100%; background-color: #d9ead3; color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(113, 176, 91); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; background-color: rgb(113, 176, 91); border-right: 0px none;') - + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('choreSample3') + br + div(style='width:100%; background-color: rgb(255, 242, 204); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(255, 207, 66); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('choreSample4') + br + div(style='width:100%; background-color: rgb(201, 218, 248); color: rgb(51, 51, 51); text-align:center; padding: 0px; line-height: 1.62765; list-style: none outside none; padding: 0px; height: 2.3em; min-height: 1.62765em; margin-bottom:0.75em; margin:0px; box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5) inset;') + .task-btn(style='display: inline-block; width: 1.62765em; height: 1.62765em; padding: 0px; margin:0px; line-height: 1.62765; text-align: center; color: rgb(34, 34, 34); float:left; cursor: pointer; vertical-align: top; left:0px; position:relative; background-color: rgb(90, 98, 223); border-right: 1px solid rgba(0, 0, 0, 0.25);') + + |   + .task-desc(style='display: inline-block; font-family: Lato,sans-serif; padding: 0.6em 0px 0em 1em; letter-spacing: normal; float:left; word-wrap: break-word;')= env.t('choreSample5') + img.sample-img.visible-lg-inline-block(src='https://s3.amazonaws.com/habitrpg-assets/front/images/uses/dusting_by_leephon.png') + .usetweet-groups.col-lg-5.col-md-6.visible-lg-inline-block.visible-md-inline-block + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='autumnesquirrel', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/autumnesquirrel.png') + .usetweet.tweet.popover.right + .arrow + .popover-content= env.t('autumnesquirrelQuote') + .usetweet-group + img(data-toggle='tooltip', data-placement='top', title='irishfeet123', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/irishfeet123.png') + .usetweet.tweet.popover.right + .arrow + .popover-content + = env.t('irishfeet123Quote') + // End Item + // End Carousel + button.btn.btn-primary.btn-lg.gamifybutton.fixedcta(ng-click='playButtonClick()')= env.t('gamifyButton') + section#rewards.bg-warning.container-fluid + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + h2.headline= env.t('rewardHeading') + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12.col-xs-12 + p.sectioninfo + = env.t('rewardByline1') + br + br + = env.t('rewardByline2') + .scrolltweet.hidden-xs.hidden-sm + img.scrolltweet-image(data-toggle='tooltip', data-placement='top', title='Elmi', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/Elmi.png') + .tweet.popover.right.pull-right + .arrow + .popover-content= env.t('elmiQuote') + .col-lg-4.col-md-4.col-lg-offset-1.col-sm-8.well.col-xs-8.col-xs-offset-2.col-sm-offset-2.well-lg + .avatarscroll + h2 + span.glyphicon.glyphicon-check + h2 + span.glyphicon.glyphicon-arrow-down + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/misc/shop_gold.png') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/misc/shop_gold.png') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/misc/shop_gold.png') + h2 + span.glyphicon.glyphicon-arrow-down + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/TVreward.png') + button.btn.btn-primary.btn-lg.fixedcta.gamifybutton(ng-click='playButtonClick()')= env.t('gamifyButton') + section#levels.container-fluid + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + h2.headline= env.t('unlockHeadline') + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + p.sectioninfo + = env.t('unlockByline1') + br + br + = env.t('unlockByline2') + .scrolltweet.hidden-xs.hidden-sm + img.scrolltweet-image(data-toggle='tooltip', data-placement='top', title='16bitFil', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/16bitFil.png') + .tweet.popover.right.pull-right + .arrow + .popover-content + = env.t('sixteenBitFilQuote') + .col-lg-4.col-md-4.col-lg-offset-1.col-sm-8.well.col-xs-8.col-xs-offset-2.col-sm-offset-2 + .avatarscroll + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/avatar/avatarstatic.png') + h2 + span.glyphicon.glyphicon-arrow-down + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/SAMPLEadventurers.png') + button.btn.btn-primary.btn-lg.fixedcta.gamifybutton(ng-click='playButtonClick()')= env.t('gamifyButton') + section#health.bg-danger.container-fluid + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + h2.headline= env.t('punishHeading1') + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + h2= env.t('punishHeading2') + p.sectioninfo= env.t('punishByline') + .scrolltweet.hidden-xs.hidden-sm + img.scrolltweet-image(data-toggle='tooltip', data-placement='top', title='Zelah Meyer', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/Zelah_Meyer.png') + .tweet.popover.right.pull-right + .arrow + .popover-content + = env.t('zelahQuote') + .col-lg-4.col-md-4.col-lg-offset-1.col-sm-8.well.col-xs-8.col-xs-offset-2.col-sm-offset-2.well-lg + h2 + span.glyphicon.glyphicon-unchecked + .health-progress + .meter-label(tooltip='Health') + span.glyphicon.glyphicon-heart + .meter.health + .bar + div(style='width:100%;')   + h2 + span.glyphicon.glyphicon-arrow-down + .health-progress + .meter-label(tooltip='Health') + span.glyphicon.glyphicon-heart + .meter.health + .bar + div(style='width:50%;')   + button.btn.btn-primary.btn-lg.fixedcta.gamifybutton(ng-click='playButtonClick()')= env.t('gamifyButton') + section#quest.container-fluid + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + h2.headline= env.t('questHeading1') + .row + .col-lg-5.col-lg-offset-1.col-md-5.col-sm-12 + h2= env.t('questHeading2') + p.sectioninfo + = env.t('questByline1') + br + = env.t('questByline2') + .scrolltweet.hidden-xs.hidden-sm + img.scrolltweet-image(data-toggle='tooltip', data-placement='top', title='skysailor', src='https://s3.amazonaws.com/habitrpg-assets/front/images/testimonials/skysailor.png') + .tweet.popover.right.pull-right + .arrow + .popover-content + = env.t('skysailorQuote') + .col-lg-4.col-md-6.col-md-offset-1.col-lg-offset-1.col-sm-10.well.col-xs-10.col-xs-offset-1.col-sm-offset-1.well-lg + img.clearfix.img-responsive.center-block(style='padding-bottom:30px;', src="https://s3.amazonaws.com/habitrpg-assets/front/images/Quest_dilatory_drag'onSmall.png") + .row + .col-lg-5.col-md-5.col-sm-5.col-sm-offset-0.col-xs-5.col-xs-offset-0 + .health-progress + .meter-label(tooltip='Health') + span.glyphicon.glyphicon-heart + .meter.health + .bar + div(style='width:20%;')   + .quest-friend-img + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/party/AnnaCosplay.png') + .col-md-1.col-sm-1.col-xs-1 + h2 + span.glyphicon.glyphicon-arrow-right + .col-lg-5.col-md-offset-1.col-md-5.col-sm-5.col-sm-offset-0.col-xs-5.col-xs-offset-0 + .health-progress + .meter-label(tooltip='Health') + span.glyphicon.glyphicon-heart + .meter.health + .bar + div(style='width:0%;')   + .quest-friend-img + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/party/GrimReaper.png') + button.btn.btn-primary.btn-lg.fixedcta.gamifybutton(ng-click='playButtonClick()')= env.t('gamifyButton') + section#features.bg-info.container-fluid + .row + h2= env.t('featuresHeading') + .row + .col-md-4.col-md-offset-2.col-sm-6 + .feature-img + img.center-block.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/Mount.png') + .featuretext + h4= env.t('featurePetHeading') + p + = env.t('featurePetByline') + .col-md-4.col-sm-6 + .feature-img.center-block + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/achievement-triadbingo.png') + img(src='https://s3.amazonaws.com/habitrpg-assets/front/images/achievement-perfect.png') + .featuretext + h4= env.t('featureAchievementHeading') + p= env.t('featureAchievementByline') + .row + .col-md-4.col-md-offset-2.col-sm-6 + .feature-img + img.center-block.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/Promo_springclasses2015.png') + .featuretext + h4= env.t('featureEquipHeading') + p + = env.t('featureEquipByline') + .col-md-4.col-sm-6 + .feature-img + img.center-block.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/Party-Header.png') + .featuretext + h4= env.t('featureSocialHeading') + p + = env.t('featureSocialByline') + button.btn.btn-primary.btn-lg.fixedcta.gamifybutton(ng-click='playButtonClick()')= env.t('gamifyButton') + #footercall + .container-fluid + .row + .col-md-10 + h3= env.t('joinOthers') + .row + .col-md-4.col-md-offset-4 + button.btn.btn-primary.btn-lg.btn-block(ng-click='playButtonClick()')= env.t('free') + footer.footer + .container-fluid.shoutout + h4= env.t('contribUse') + .row + .col-lg-2.col-md-2.col-md-offset-1.col-sm-4.col-sm-offset-1.col-xs-6.col-xs-offset-1 + a(href='http://ionicframework.com/') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/ionic-logo-horizontal-transparent.png') + .col-lg-2.col-lg-offset-0.col-md-2.col-md-offset-0.col-sm-4.col-sm-offset-1.col-xs-6.col-xs-offset-1 + a(href='https://www.jetbrains.com/webstorm/') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/logo_webstorm.png') + .col-lg-2.col-lg-offset-0.col-md-2.col-md-offset-0.col-sm-4.col-sm-offset-1.col-xs-6.col-xs-offset-1 + a(href='http://github.com/') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/GitHub_Logo.png') + .col-lg-2.col-lg-offset-0.col-md-2.col-md-offset-0.col-sm-4.col-sm-offset-1.col-xs-6.col-xs-offset-1 + a(href='https://trello.com/') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/trello-logo-blue.png') + .col-lg-2.col-lg-offset-0.col-md-2.col-md-offset-0.col-sm-4.col-sm-offset-1.col-xs-6.col-xs-offset-1 + a(href='https://slack.com/') + img.img-responsive(src='https://s3.amazonaws.com/habitrpg-assets/front/images/presslogos/landing_slack_hash_wordmark_logo.png') + + .row.footer-content + include ../shared/footer + + // Footer scripts + // Use carousel initialize + script(type='text/javascript'). + $(document).ready( function() { + var clickEvent = false; + $('#myCarousel').on('click', '.nav a', function() { + clickEvent = true; + $('#myCarousel .nav li').removeClass('active'); + $(this).parent().addClass('active'); + }).on('slid.bs.carousel', function(e) { + if(!clickEvent) { + var count = $('#myCarousel .nav').children().length -1; + var current = $('#myCarousel .nav li.active'); + current.removeClass('active').next().addClass('active'); + var id = parseInt(current.data('slide-to')); + if(count == id) { + $('#myCarousel .nav li').first().addClass('active'); + } + } + clickEvent = false; + }); + }); + // Tooltips + script(type='text/javascript'). + $(function () { + $('[data-toggle="tooltip"]').tooltip() + $('[data-toggle="popover"]').popover() + }) + // Hack fix for carousel (http://stackoverflow.com/a/22182184/362790) + script. + angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition']) + .controller('CarouselController', ['$scope', '$timeout', '$transition', '$q', function ($scope, $timeout, $transition, $q) { + }]).directive('carousel', [function () { + return {} + }]); - .marketing - //we need to use something that's not jumbotron for this, but still keep it centered - //could someone write something else to make it pretty? - img(src='/common/img/logo/habitrpg_pixel.png', alt='HabitRPG logo') - //this image needs to be replaced by something more enticing, that shows off the features of hRPG - //while acting similarly to a logo - h1#tagline=env.t('tagline') - p.lead - button.btn.btn-primary.btn-lg#frontpage-play-button(ng-click='playButtonClick()')=env.t('playButton') - hr - img(src='/marketing/devices.png') - //we'd want the tagline centered, for sure, and a bit more pop, but without using jumbotron - //it could also be part of the image, as long as the alt text included it - //in fact, I think I really want it on the image, rather than as text, but language issues - br - p.lead=env.t('landingp1') - h2=env.t('landingp2header') - //images in these parts could be useful, too - //if there's a language workaround, image headers? people like pictures! - p.lead - =env.t('landingp2') - |  - h2=env.t('landingp3header') - //I'm not sold on "Consquences as the title here. Anyone got a better idea? - p.lead - =env.t('landingp3') - |  - h2=env.t('landingp4header') - p.lead=env.t('landingp4') - //- TODO - h2=env.t('landingend') - p.lead - =env.t('landingend2') - a(href="FEATURESPAGEHERE")=env.t('landingfeatureslink') - =env.t('landingend3') - a(href="ENTERPRISEPAGEHERE")=env.t('landingadminlink') - |  - =env.t('landingend4') diff --git a/website/views/static/layout.jade b/website/views/static/layout.jade index 2b712d49f4..1e2725b7c4 100644 --- a/website/views/static/layout.jade +++ b/website/views/static/layout.jade @@ -27,6 +27,11 @@ html(ng-app='habitrpg') //FIXME for some reason this won't load when in footerCtrl.js#deferredScripts() script(type="text/javascript", src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5016f6cc44ad68a4", async="async") + script(type='text/javascript'). + (function (f, b) {if (!b.__SV) {var a, e, i, g;window.mixpanel = b;b._i = [];b.init = function (a, e, d) {function f(b, h) {var a = h.split(".");2 == a.length && (b = b[a[0]], h = a[1]);b[h] = function () {b.push([h].concat(Array.prototype.slice.call(arguments, 0)))}}var c = b;"undefined" !== typeof d ? c = b[d] = [] : d = "mixpanel";c.people = c.people || [];c.toString = function (b) {var a = "mixpanel";"mixpanel" !== d && (a += "." + d);b || (a += " (stub)");return a};c.people.toString = function () {return c.toString(1) + ".people (stub)"};i = "disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); + for (g = 0; g < i.length; g++)f(c, i[g]);b._i.push([a, e, d])};b.__SV = 1.2;a = f.createElement("script");a.type = "text/javascript";a.async = !0;a.src = "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";e = f.getElementsByTagName("script")[0];e.parentNode.insertBefore(a, e)}})(document, window.mixpanel || []); + mixpanel.init(window.env.MP_ID); + != env.getManifestFiles("static") body @@ -44,14 +49,14 @@ html(ng-app='habitrpg') ul.nav.navbar-nav li(class='#{menuItem=="features" ? "active" : ""}') a(href='/static/features')=env.t('companyAbout') - li(class='#{menuItem=="videos" ? "active" : ""}') + //-li(class='#{menuItem=="videos" ? "active" : ""}') a(href='/static/videos')=env.t('companyVideos') - li - a(href='http://blog.habitrpg.com/')=env.t('companyBlog') li(class='#{menuItem=="plans" ? "active" : ""}') a(href='/static/plans')=env.t('groupPlans') + li + a(href='http://blog.habitrpg.com/')=env.t('companyBlog') li(class='#{menuItem=="pressKit" ? "active" : ""}') - a(href='/static/press-kit') Press Kit + a(href='/static/press-kit')=env.t('presskit') li(class='#{menuItem=="contact" ? "active" : ""}') a(href='/static/contact')=env.t('contactUs') diff --git a/website/views/static/login-modal.jade b/website/views/static/login-modal.jade index 27e82df49e..eed23662c3 100644 --- a/website/views/static/login-modal.jade +++ b/website/views/static/login-modal.jade @@ -12,15 +12,9 @@ script(id='modals/login.html', type='text/ng-template') li a.zocial.icon.twitter(alt="Twitter", ng-click='socialLogin("twitter")') Twitter hr - ul.nav.nav-tabs - li.active - a(data-toggle='tab',data-target='#login-tab')=env.t('login') - li - a(data-toggle='tab',data-target='#register-tab')=env.t('register') - - .tab-content - .tab-pane.active#login-tab - form(ng-submit='auth()', method='POST') + tabset(justified='true') + tab(heading=env.t('login')) + form#login-tab(ng-submit='auth()', method='POST') .form-group input.form-control(type='text', ng-model='loginUsername', placeholder=env.t('username')+' or Email', name='username') .form-group @@ -42,7 +36,7 @@ script(id='modals/login.html', type='text/ng-template') .panel-heading h3.panel-title a(data-toggle="collapse" data-parent="#forgot-password" href="#forgot-password-panel")=env.t('forgotPass') - + .panel-body.collapse#forgot-password-panel form(name='passwordResetForm', ng-submit='passwordReset(passwordResetEmail)', novalidate) //.alert.alert-success {.success.passwordReset} @@ -54,8 +48,8 @@ script(id='modals/login.html', type='text/ng-template') .form-group input.btn.btn-default(type='submit', value=env.t('submit')) - .tab-pane#register-tab - form(ng-submit='register()', name='registrationForm') + tab(heading=env.t('register')) + form#registrationForm(ng-submit='register()', name='registrationForm') .form-group input.form-control(type='text', ng-model='registerVals.username', placeholder=env.t('username'), required) .form-group @@ -75,4 +69,4 @@ script(id='modals/login.html', type='text/ng-template') a(href='/static/privacy' target='_blank')=env.t('privacy') | . .form-group - input.btn.btn-primary(type='submit', value=env.t('register')) + input.btn.btn-primary(type='submit', ng-disabled='registrationForm.$invalid || registrationInProgress', value=env.t('register')) diff --git a/website/views/static/plans.jade b/website/views/static/plans.jade index a7971fd3ab..ea320448c6 100644 --- a/website/views/static/plans.jade +++ b/website/views/static/plans.jade @@ -82,7 +82,6 @@ block content th h5=env.t('gameFeatures') + ':' ul - li=env.t('gameNoAds') li span.dashed-underline(popover=env.t('gold2GemText'),popover-trigger='mouseenter',popover-placement='right')=env.t('gold2Gem') li diff --git a/website/views/static/press-kit.jade b/website/views/static/press-kit.jade index 7439cff41c..427da56098 100644 --- a/website/views/static/press-kit.jade +++ b/website/views/static/press-kit.jade @@ -5,7 +5,7 @@ block vars - var menuItem = 'pressKit' block title - title Press Kit + title= env.t('presskit') block extraHead style.