[
  {
    "path": ".bowerrc",
    "content": "{\n\t\"directory\": \"public/vendors/\"\n}"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\npublic/vendors\nnpm-debug.log\ndata/database.sqlite"
  },
  {
    "path": ".rebooted",
    "content": "rebooted"
  },
  {
    "path": "Gruntfile.js",
    "content": "module.exports = function(grunt) {\n\n  grunt.initConfig({\n    concurrent: {\n      dev: {\n        tasks: ['nodemon', 'watch'],\n        options: {\n          logConcurrentOutput: true\n        }\n      }\n    },\n    nodemon: {\n      dev: {\n        script: 'index.js',\n        options: {\n          ext: 'js,css,html,tpl',\n          watch: ['**/*.js', '**/*.tpl', '**/*.css', 'public/index.html', '**/*.json'],\n          nodeArgs: ['--debug'],\n          env: {\n            PORT: '8080'\n          },\n          // omit this property if you aren't serving HTML files and \n          // don't want to open a browser tab on start\n          callback: function(nodemon) {\n            nodemon.on('log', function(event) {\n              console.log(event.colour);\n            });\n\n            // opens browser on initial server start\n            nodemon.on('config:update', function() {\n              // Delay before server listens on port\n              setTimeout(function() {\n                require('open')('http://localhost:8080');\n              }, 1000);\n            });\n\n            // refreshes browser when server reboots\n            nodemon.on('restart', function() {\n              // Delay before server listens on port\n              setTimeout(function() {\n                require('fs').writeFileSync('.rebooted', 'rebooted');\n              }, 3000);\n            });\n          }\n        }\n      }\n    },\n    watch: {\n      server: {\n        files: ['.rebooted'],\n        options: {\n          livereload: true,\n          debounceDelay: 500\n        }\n      },\n      javascript: {\n        files: ['includes/**/*.js'],\n        tasks: \"test\"\n      }\n    },\n    env: {\n      options: {},\n      test: {\n        NODE_ENV: 'test'\n      },\n      apiary: {\n        APIARY_API_KEY: process.env.DIMESHIFT_APIARY_API_KEY // https://login.apiary.io/tokens\n      }\n    },\n    concat: {\n      options: {\n        separator: '\\n \\n',\n      },\n      dist: {\n        src: [\"docs/api.md\", \"includes/routes/**/*.apib\"],\n        dest: 'data/cache/api.apib'\n      }\n    },\n    exec: {\n      publish: ['apiary', 'publish', ['--api-name', 'dimeshift'].join('='), ['--path', 'data/cache/api.apib'].join('=')].join(' ')\n    },\n    run: {\n      test_server: {\n        options: {\n          wait: false\n        },\n        args: [\n          'index.js'\n        ]\n      }\n    },\n    mochacli: {\n      options: {\n        require: [],\n        reporter: 'spec',\n        bail: true,\n        sort: true,\n        env: {\n          NODE_ENV: 'test'\n        }\n      },\n      all: ['includes/test/*.js']\n    }\n  });\n\n  grunt.loadNpmTasks('grunt-contrib-watch');\n  grunt.loadNpmTasks('grunt-nodemon');\n  grunt.loadNpmTasks('grunt-concurrent');\n  grunt.loadNpmTasks('grunt-mocha-cli');\n  grunt.loadNpmTasks('grunt-env');\n  grunt.loadNpmTasks('grunt-run');\n  grunt.loadNpmTasks('grunt-exec');\n  grunt.loadNpmTasks('grunt-contrib-concat');\n\n  grunt.registerTask('default', ['concurrent']);\n  grunt.registerTask('dev', ['concurrent']);\n  grunt.registerTask('test', ['env:test', 'run:test_server', 'mochacli', 'stop:test_server']);\n  grunt.registerTask('apiary', ['env:apiary', 'concat', 'exec:publish']);\n\n};"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<http://www.gnu.org/licenses/>.\n\n"
  },
  {
    "path": "Procfile",
    "content": "web: node index.js"
  },
  {
    "path": "README.md",
    "content": "# DimeShift - easiest way to track your expenses. Online. Open-source. Free\n* node.js\n* npm\n* Front-end: jQuery, Bootstrap, Backbone.js with JSmart template engine.\n* Back-end: Sequelize, SQLite database by default, easy to switch to MySQL or Postgree for production.\n\nDemo:\n----\n [DimeShift](https://dimeshift.com/)\n\nDesktop Application:\n----\n\n [DimeShift Desktop](https://github.com/jeka-kiselyov/dimeshift-desktop). Cross platform desktop app built on [Electron](http://electron.atom.io/)\n \n\nInstallation:\n----\n\n[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/jeka-kiselyov/dimeshift)\n\nor install from CLI:\n\n```bash\nmkdir dimeshift\ncd dimeshift\ngit clone https://github.com/jeka-kiselyov/dimeshift.git .\nnpm install\n```\n* [Install npm](https://docs.npmjs.com/getting-started/installing-node) if you don't have it.\n* [Install bower](http://bower.io/#install-bower) if you don't have it.\n\nRun:\n----\n\n```bash\nnpm start\n```\nOpen [localhost:8080](http://localhost:8080) in your browser.\n\nDocumentation:\n----\n\n[API](http://docs.dimeshift.apiary.io/)\n\n\nScreenshots:\n----\n![Dimeshift transactions](https://raw.githubusercontent.com/jeka-kiselyov/dimeshift/master/public/images/homepage/screenshots/transactions.jpg?1mar16)\n\n![Dimeshift wallets](https://raw.githubusercontent.com/jeka-kiselyov/dimeshift/master/public/images/homepage/screenshots/wallets.jpg?1mar16)\n\n![Dimeshift goals](https://raw.githubusercontent.com/jeka-kiselyov/dimeshift/master/public/images/homepage/screenshots/goal.jpg?1mar16)\n\n![Dimeshift i18n](https://raw.githubusercontent.com/jeka-kiselyov/dimeshift/master/public/images/homepage/screenshots/i18n.jpg?1mar16)\n\nLicense\n----\nGNU Affero GPL\n\n**Free Software, Hell Yeah!**\n\nFrom Slavyansk, Ukraine. With Love"
  },
  {
    "path": "app.json",
    "content": "{\n\t\"name\": \"dimeshift\",\n\t\"description\": \"Webapp to track and manage personal finances\",\n\t\"repository\": \"https://github.com/jeka-kiselyov/dimeshift\",\n\t\"logo\": \"https://raw.githubusercontent.com/jeka-kiselyov/dimeshift/master/public/images/homepage/screenshots/transactions.jpg\",\n\t\"keywords\": [\"node\", \"finances\", \"money\", \"HTML5\", \"Sequelize\", \"Backbone.js\", \"Restify\"],\n\t\"addons\": [\"heroku-postgresql:hobby-dev\", \"sparkpost:free\"],\n\t\"env\": {\n\t\t\"NODE_ENV\": \"heroku\"\n\t}\n}"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"DimeShift\",\n  \"version\": \"0.1.34\",\n  \"authors\": [\n    \"jeka911 <jeka911@gmail.com>\"\n  ],\n  \"description\": \"\",\n  \"main\": \"app/public/scripts/app.js\",\n  \"moduleType\": [\n    \"globals\"\n  ],\n  \"dependencies\": {\n    \"jquery\": \"1.10.2\",\n    \"jasmine\": \"https://github.com/pivotal/jasmine/releases/download/v2.0.2/jasmine-standalone-2.0.2.zip\",\n    \"jasmine-ajax\": \"https://raw.githubusercontent.com/pivotal/jasmine-ajax/master/lib/mock-ajax.js\",\n    \"jsmart\": \"2.13.1\",\n    \"backbone\": \"1.0.0\",\n    \"backbone.paginator\": \"https://github.com/backbone-paginator/backbone.paginator/archive/2.0.2.zip\",\n    \"underscore\": \"1.7.0\",\n    \"bootstrap\": \"3.3.4\",\n    \"magnific-popup\": \"*\",\n    \"bootstrap-clickonmouseover\": \"https://github.com/jeka-kiselyov/bootstrap-clickonmouseover/archive/master.zip\",\n    \"mprogress\": \"https://github.com/lightningtgc/MProgress.js/archive/master.zip\",\n    \"bootstrap-tour\": \"~0.10.2\",\n    \"js-xlsx\": \"~0.8.0\",\n    \"moment\": \"~2.10.6\",\n    \"eonasdan-bootstrap-datetimepicker\": \"^4.17.37\",\n    \"font-awesome\": \"fontawesome#^4.6.1\"\n  }\n}\n"
  },
  {
    "path": "config/config.json",
    "content": "{\n  \"development\": {\n    \"port\": 8080,\n    \"database\": {\n      \"dialect\": \"sqlite\",\n      \"username\": \"root\",\n      \"password\": \"root\",\n      \"database\": \"walletjs\",\n      \"host\": \"127.0.0.1\",\n      \"storage\": \"data/database.sqlite\"\n    },\n    \"smtp\": {\n      \"host\": \"mailtrap.io\",\n      \"username\": \"38298e68fa9771771\",\n      \"password\": \"ab75f0affdd61a\",\n      \"port\": \"465\"\n    },\n    \"openexchangerates\": {\n      \"use_env_variable\": false,\n      \"app_id\": \"OPENEXCHANGERATES_APP_ID\",\n      \"update_interval\": 86400\n    },\n    \"default_from_email\": \"noreply@dimeshift.com\",\n    \"site_path\": \"http://localhost:8080/\",\n    \"minify\": {\n      \"javascript\": true,\n      \"css\": true\n    }\n  },\n  \"electron\": {\n    \"port\": 0,\n    \"database\": {\n      \"dialectModulePath\": \"../../includes/sqlite3.js\",\n      \"dialect\": \"sqlite\",\n      \"storage\": \"data/database.sqlite\"\n    },\n    \"smtp\": null,\n    \"openexchangerates\": null,\n    \"default_from_email\": null,\n    \"site_path\": null,\n    \"minify\": {\n      \"javascript\": true,\n      \"css\": true\n    }\n  },\n  \"test\": {\n    \"port\": 8081,\n    \"database\": {\n      \"dialect\": \"sqlite\",\n      \"storage\": \"data/database.sqlite\"\n    },\n    \"smtp\": null,\n    \"openexchangerates\": {\n      \"app_id\": \"234234234234234234234\",\n      \"update_interval\": 86400\n    },\n    \"default_from_email\": \"noreply@dimeshift.com\",\n    \"site_path\": \"http://localhost:8080/\",\n    \"minify\": {\n      \"javascript\": false,\n      \"css\": false\n    }\n  },\n  \"heroku\": {\n    \"database\": {\n      \"use_env_variable\": \"DATABASE_URL\"\n    },\n    \"smtp\": {\n      \"use_env_variables\": true,\n      \"host\": \"SPARKPOST_SMTP_HOST\",\n      \"username\": \"SPARKPOST_SMTP_USERNAME\",\n      \"password\": \"SPARKPOST_SMTP_PASSWORD\",\n      \"port\": \"SPARKPOST_SMTP_PORT\"\n    },\n    \"openexchangerates\": {\n      \"use_env_variable\": true,\n      \"app_id\": \"OPENEXCHANGERATES_APP_ID\",\n      \"update_interval\": 86400\n    },\n    \"default_from_email\": \"noreply@dimeshift.com\",\n    \"site_path\": \"http://dimeshift.com/\",\n    \"minify\": {\n      \"javascript\": true,\n      \"css\": true\n    }\n  }\n}"
  },
  {
    "path": "config/currencies.json",
    "content": "{\n\t\"AED\": \"United Arab Emirates Dirham\",\n\t\"AFN\": \"Afghan Afghani\",\n\t\"ALL\": \"Albanian Lek\",\n\t\"AMD\": \"Armenian Dram\",\n\t\"ANG\": \"Netherlands Antillean Guilder\",\n\t\"AOA\": \"Angolan Kwanza\",\n\t\"ARS\": \"Argentine Peso\",\n\t\"AUD\": \"Australian Dollar\",\n\t\"AWG\": \"Aruban Florin\",\n\t\"AZN\": \"Azerbaijani Manat\",\n\t\"BAM\": \"Bosnia-Herzegovina Convertible Mark\",\n\t\"BBD\": \"Barbadian Dollar\",\n\t\"BDT\": \"Bangladeshi Taka\",\n\t\"BGN\": \"Bulgarian Lev\",\n\t\"BHD\": \"Bahraini Dinar\",\n\t\"BIF\": \"Burundian Franc\",\n\t\"BMD\": \"Bermudan Dollar\",\n\t\"BND\": \"Brunei Dollar\",\n\t\"BOB\": \"Bolivian Boliviano\",\n\t\"BRL\": \"Brazilian Real\",\n\t\"BSD\": \"Bahamian Dollar\",\n\t\"BTC\": \"Bitcoin\",\n\t\"BTN\": \"Bhutanese Ngultrum\",\n\t\"BWP\": \"Botswanan Pula\",\n\t\"BYR\": \"Belarusian Ruble\",\n\t\"BZD\": \"Belize Dollar\",\n\t\"CAD\": \"Canadian Dollar\",\n\t\"CDF\": \"Congolese Franc\",\n\t\"CHF\": \"Swiss Franc\",\n\t\"CLF\": \"Chilean Unit of Account (UF)\",\n\t\"CLP\": \"Chilean Peso\",\n\t\"CNY\": \"Chinese Yuan\",\n\t\"COP\": \"Colombian Peso\",\n\t\"CRC\": \"Costa Rican Colón\",\n\t\"CUP\": \"Cuban Peso\",\n\t\"CVE\": \"Cape Verdean Escudo\",\n\t\"CZK\": \"Czech Republic Koruna\",\n\t\"DJF\": \"Djiboutian Franc\",\n\t\"DKK\": \"Danish Krone\",\n\t\"DOP\": \"Dominican Peso\",\n\t\"DZD\": \"Algerian Dinar\",\n\t\"EEK\": \"Estonian Kroon\",\n\t\"EGP\": \"Egyptian Pound\",\n\t\"ERN\": \"Eritrean Nakfa\",\n\t\"ETB\": \"Ethiopian Birr\",\n\t\"EUR\": \"Euro\",\n\t\"FJD\": \"Fijian Dollar\",\n\t\"FKP\": \"Falkland Islands Pound\",\n\t\"GBP\": \"British Pound Sterling\",\n\t\"GEL\": \"Georgian Lari\",\n\t\"GGP\": \"Guernsey Pound\",\n\t\"GHS\": \"Ghanaian Cedi\",\n\t\"GIP\": \"Gibraltar Pound\",\n\t\"GMD\": \"Gambian Dalasi\",\n\t\"GNF\": \"Guinean Franc\",\n\t\"GTQ\": \"Guatemalan Quetzal\",\n\t\"GYD\": \"Guyanaese Dollar\",\n\t\"HKD\": \"Hong Kong Dollar\",\n\t\"HNL\": \"Honduran Lempira\",\n\t\"HRK\": \"Croatian Kuna\",\n\t\"HTG\": \"Haitian Gourde\",\n\t\"HUF\": \"Hungarian Forint\",\n\t\"IDR\": \"Indonesian Rupiah\",\n\t\"ILS\": \"Israeli New Sheqel\",\n\t\"IMP\": \"Manx pound\",\n\t\"INR\": \"Indian Rupee\",\n\t\"IQD\": \"Iraqi Dinar\",\n\t\"IRR\": \"Iranian Rial\",\n\t\"ISK\": \"Icelandic Króna\",\n\t\"JEP\": \"Jersey Pound\",\n\t\"JMD\": \"Jamaican Dollar\",\n\t\"JOD\": \"Jordanian Dinar\",\n\t\"JPY\": \"Japanese Yen\",\n\t\"KES\": \"Kenyan Shilling\",\n\t\"KGS\": \"Kyrgystani Som\",\n\t\"KHR\": \"Cambodian Riel\",\n\t\"KMF\": \"Comorian Franc\",\n\t\"KPW\": \"North Korean Won\",\n\t\"KRW\": \"South Korean Won\",\n\t\"KWD\": \"Kuwaiti Dinar\",\n\t\"KYD\": \"Cayman Islands Dollar\",\n\t\"KZT\": \"Kazakhstani Tenge\",\n\t\"LAK\": \"Laotian Kip\",\n\t\"LBP\": \"Lebanese Pound\",\n\t\"LKR\": \"Sri Lankan Rupee\",\n\t\"LRD\": \"Liberian Dollar\",\n\t\"LSL\": \"Lesotho Loti\",\n\t\"LTL\": \"Lithuanian Litas\",\n\t\"LVL\": \"Latvian Lats\",\n\t\"LYD\": \"Libyan Dinar\",\n\t\"MAD\": \"Moroccan Dirham\",\n\t\"MDL\": \"Moldovan Leu\",\n\t\"MGA\": \"Malagasy Ariary\",\n\t\"MKD\": \"Macedonian Denar\",\n\t\"MMK\": \"Myanma Kyat\",\n\t\"MNT\": \"Mongolian Tugrik\",\n\t\"MOP\": \"Macanese Pataca\",\n\t\"MRO\": \"Mauritanian Ouguiya\",\n\t\"MTL\": \"Maltese Lira\",\n\t\"MUR\": \"Mauritian Rupee\",\n\t\"MVR\": \"Maldivian Rufiyaa\",\n\t\"MWK\": \"Malawian Kwacha\",\n\t\"MXN\": \"Mexican Peso\",\n\t\"MYR\": \"Malaysian Ringgit\",\n\t\"MZN\": \"Mozambican Metical\",\n\t\"NAD\": \"Namibian Dollar\",\n\t\"NGN\": \"Nigerian Naira\",\n\t\"NIO\": \"Nicaraguan Córdoba\",\n\t\"NOK\": \"Norwegian Krone\",\n\t\"NPR\": \"Nepalese Rupee\",\n\t\"NZD\": \"New Zealand Dollar\",\n\t\"OMR\": \"Omani Rial\",\n\t\"PAB\": \"Panamanian Balboa\",\n\t\"PEN\": \"Peruvian Nuevo Sol\",\n\t\"PGK\": \"Papua New Guinean Kina\",\n\t\"PHP\": \"Philippine Peso\",\n\t\"PKR\": \"Pakistani Rupee\",\n\t\"PLN\": \"Polish Zloty\",\n\t\"PYG\": \"Paraguayan Guarani\",\n\t\"QAR\": \"Qatari Rial\",\n\t\"RON\": \"Romanian Leu\",\n\t\"RSD\": \"Serbian Dinar\",\n\t\"RUB\": \"Russian Ruble\",\n\t\"RWF\": \"Rwandan Franc\",\n\t\"SAR\": \"Saudi Riyal\",\n\t\"SBD\": \"Solomon Islands Dollar\",\n\t\"SCR\": \"Seychellois Rupee\",\n\t\"SDG\": \"Sudanese Pound\",\n\t\"SEK\": \"Swedish Krona\",\n\t\"SGD\": \"Singapore Dollar\",\n\t\"SHP\": \"Saint Helena Pound\",\n\t\"SLL\": \"Sierra Leonean Leone\",\n\t\"SOS\": \"Somali Shilling\",\n\t\"SRD\": \"Surinamese Dollar\",\n\t\"STD\": \"São Tomé and Príncipe Dobra\",\n\t\"SVC\": \"Salvadoran Colón\",\n\t\"SYP\": \"Syrian Pound\",\n\t\"SZL\": \"Swazi Lilangeni\",\n\t\"THB\": \"Thai Baht\",\n\t\"TJS\": \"Tajikistani Somoni\",\n\t\"TMT\": \"Turkmenistani Manat\",\n\t\"TND\": \"Tunisian Dinar\",\n\t\"TOP\": \"Tongan Paʻanga\",\n\t\"TRY\": \"Turkish Lira\",\n\t\"TTD\": \"Trinidad and Tobago Dollar\",\n\t\"TWD\": \"New Taiwan Dollar\",\n\t\"TZS\": \"Tanzanian Shilling\",\n\t\"UAH\": \"Ukrainian Hryvnia\",\n\t\"UGX\": \"Ugandan Shilling\",\n\t\"USD\": \"United States Dollar\",\n\t\"UYU\": \"Uruguayan Peso\",\n\t\"UZS\": \"Uzbekistan Som\",\n\t\"VEF\": \"Venezuelan Bolívar Fuerte\",\n\t\"VND\": \"Vietnamese Dong\",\n\t\"VUV\": \"Vanuatu Vatu\",\n\t\"WST\": \"Samoan Tala\",\n\t\"XAF\": \"CFA Franc BEAC\",\n\t\"XAG\": \"Silver (troy ounce)\",\n\t\"XAU\": \"Gold (troy ounce)\",\n\t\"XCD\": \"East Caribbean Dollar\",\n\t\"XDR\": \"Special Drawing Rights\",\n\t\"XOF\": \"CFA Franc BCEAO\",\n\t\"XPF\": \"CFP Franc\",\n\t\"YER\": \"Yemeni Rial\",\n\t\"ZAR\": \"South African Rand\",\n\t\"ZMK\": \"Zambian Kwacha (pre-2013)\",\n\t\"ZMW\": \"Zambian Kwacha\",\n\t\"ZWL\": \"Zimbabwean Dollar\"\n}"
  },
  {
    "path": "config/pages.json",
    "content": "{\n\t\"/*\": \"Index\",\n\t\"/wallets\": \"Wallets\",\n\t\"/profile\": \"Profile\",\n\t\"/plans\": \"Plans\",\n\t\"/plans/:id\": \"Plan\",\n\t\"/wallets/:id\": \"Wallet\",\n\t\"/wallets/:id/import\": \"ImportXLS\",\n\t\"/user/updatepassword/:code/:hash\": \"UpdatePassword\",\n\t\"/user/newpassword\": \"Index\"\n}"
  },
  {
    "path": "config/resources.json",
    "content": "{\n\t\"javascript\": [\n\t\t\"./public/vendors/jquery/jquery.min.js\",\n\t\t\"./public/vendors/bootstrap/js/modal.js\",\n\t\t\"./public/vendors/bootstrap/js/button.js\",\n\t\t\"./public/vendors/bootstrap/js/dropdown.js\",\n\t\t\"./public/vendors/bootstrap/js/collapse.js\",\n\t\t\"./public/vendors/bootstrap/js/tooltip.js\",\n\t\t\"./public/vendors/bootstrap/js/popover.js\",\n\t\t\"./public/vendors/bootstrap-tour/build/js/bootstrap-tour.js\",\n\t\t\"./public/vendors/underscore/underscore-min.js\",\n\t\t\"./public/vendors/backbone/backbone.js\",\n\t\t\"./public/vendors/backbone.paginator/lib/backbone.paginator.min.js\",\n\t\t\"./public/vendors/bootstrap-clickonmouseover/bootstrap.clickonmouseover.js\",\n\t\t\"./public/vendors/magnific-popup/dist/jquery.magnific-popup.min.js\",\n\t\t\"./public/vendors/mprogress/build/js/mprogress.min.js\",\n\t\t\"./public/vendors/jsmart/jsmart.js\",\n\t\t\"./public/scripts/functions.js\",\n\t\t\"./public/scripts/app.js\",\n\t\t\"./public/scripts/app/helper.js\",\n\t\t\"./public/scripts/app/view_stack.js\",\n\t\t\"./public/scripts/app/settings.js\",\n\t\t\"./public/scripts/app/local_storage.js\",\n\t\t\"./public/scripts/app/template_manager.js\",\n\t\t\"./public/scripts/app/i18n.js\",\n\t\t\"./public/scripts/app/exchange.js\",\n\n\t\t\"./public/scripts/app/abstract/\",\n\t\t\"./public/scripts/app/models/\",\n\t\t\"./public/scripts/app/collections/\",\n\n\t\t\"./public/scripts/app/views/dialogs/\",\n\t\t\"./public/scripts/app/views/widgets/\",\n\t\t\"./public/scripts/app/views/parts/\",\n\t\t\"./public/scripts/app/views/pages/\",\n\t\t\"./public/scripts/app/views/tours/\",\n\t\t\"./public/scripts/app/views/charts/\",\n\n\t\t\"./public/scripts/app/views/header.js\",\n\n\t\t\"./public/scripts/app/log.js\",\n\t\t\"./public/scripts/app/router.js\",\n\t\t\"./public/scripts/setup.js\"\n\t],\n\t\"css\": [\n\t\t\"./public/vendors/mprogress/build/css/mprogress.css\",\n\t\t\"./public/vendors/magnific-popup/dist/magnific-popup.css\",\n\t\t\"./public/vendors/bootstrap/dist/css/bootstrap.min.css\",\n\t\t\"./public/vendors/font-awesome/css/font-awesome.css\",\n\t\t\"./public/vendors/bootstrap-tour/build/css/bootstrap-tour.min.css\",\n\t\t\"./public/vendors/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css\",\n\t\t\"./public/css/main.css\",\n\t\t\"./public/css/parts/\",\n\t\t\"./public/css/parts/dialogs/\"\n\t]\n}"
  },
  {
    "path": "data/cache/.gitignore",
    "content": "exchangerates.json\napi.apib"
  },
  {
    "path": "data/i18n/en.json",
    "content": "{\n  \"Nothing is found\": \"\",\n  \"Add Income\": \"\",\n  \"Amount\": \"\",\n  \"Description\": \"\",\n  \"Desciption\": \"\",\n  \"Add\": \"\",\n  \"Saving...\": \"\",\n  \"Add Wallet\": \"\",\n  \"Name\": \"\",\n  \"Currency\": \"\",\n  \"Select Currency\": \"\",\n  \"Edit Wallet\": \"\",\n  \"Save\": \"\",\n  \"Fill Profile\": \"\",\n  \"Username\": \"\",\n  \"Email\": \"\",\n  \"Password\": \"\",\n  \"Invalid username or password\": \"\",\n  \"Thank you! From now, you can sign in to your account any time from any device.\": \"\",\n  \"Are you sure that you want to hide\": \"\",\n  \"this wallet\": \"\",\n  \"wallet\": \"\",\n  \"Are you sure that you want to remove\": \"\",\n  \"You will be able to restore it from Trash folder\": \"\",\n  \"All wallet data(transactions etc.) will be lost\": \"\",\n  \"Yes, Hide It\": \"\",\n  \"Yes, Remove\": \"\",\n  \"Removing...\": \"\",\n  \"Cancel\": \"\",\n  \"Canceling...\": \"\",\n  \"Registration\": \"\",\n  \"Sign Up\": \"\",\n  \"Registration...\": \"\",\n  \"Thank you! Please check your email inbox for confirmation link\": \"\",\n  \"Already a member?\": \"\",\n  \"Sign In\": \"\",\n  \"Are you sure that you want to remove access for email\": \"\",\n  \"from this wallet\": \"\",\n  \"from wallet\": \"\",\n  \"Are you sure that you want to remove this transaction?\": \"\",\n  \"Restore Password\": \"\",\n  \"Restore\": \"\",\n  \"Processing...\": \"\",\n  \"Instructions have been sent to your email address\": \"\",\n  \"Don't have an account?\": \"\",\n  \"Register\": \"\",\n  \"Set Total To\": \"\",\n  \"Total\": \"\",\n  \"Set\": \"\",\n  \"Username or Email\": \"\",\n  \"Signing in...\": \"\",\n  \"Restore your password\": \"\",\n  \"Transaction Details\": \"\",\n  \"Date\": \"\",\n  \"Time\": \"\",\n  \"Remove\": \"\",\n  \"Users with access\": \"\",\n  \"to this wallet\": \"\",\n  \"to wallet\": \"\",\n  \"Only you have access to this wallet\": \"\",\n  \"Not registered yet\": \"\",\n  \"Remove Access\": \"\",\n  \"Add access\": \"\",\n  \"Give Access\": \"\",\n  \"January\": \"\",\n  \"February\": \"\",\n  \"March\": \"\",\n  \"April\": \"\",\n  \"May\": \"\",\n  \"June\": \"\",\n  \"July\": \"\",\n  \"August\": \"\",\n  \"September\": \"\",\n  \"October\": \"\",\n  \"November\": \"\",\n  \"December\": \"\",\n  \"january\": \"\",\n  \"february\": \"\",\n  \"march\": \"\",\n  \"april\": \"\",\n  \"may\": \"\",\n  \"june\": \"\",\n  \"july\": \"\",\n  \"august\": \"\",\n  \"september\": \"\",\n  \"october\": \"\",\n  \"november\": \"\",\n  \"december\": \"\",\n  \"Home\": \"\",\n  \"Settings\": \"\",\n  \"Your password has been successfully changed\": \"\",\n  \"Invalid current password\": \"\",\n  \"Passwords missmatch\": \"\",\n  \"New password is too short\": \"\",\n  \"Current Password\": \"\",\n  \"New Password\": \"\",\n  \"Repeat Password\": \"\",\n  \"Change Password\": \"\",\n  \"Update Password\": \"\",\n  \"Invalid Restore Password Code\": \"\",\n  \"Restore Password Code\": \"\",\n  \"Restore Password Hash\": \"\",\n  \"Your Wallets\": \"\",\n  \"You have no wallets\": \"\",\n  \"You have no hidden wallets\": \"\",\n  \"Hide\": \"\",\n  \"Edit\": \"\",\n  \"Manage Accesses\": \"\",\n  \"This wallet is shared with you by another user\": \"\",\n  \"Filter\": \"\",\n  \"Active\": \"\",\n  \"Trash\": \"\",\n  \"Access\": \"\",\n  \"Both\": \"\",\n  \"Yours\": \"\",\n  \"Shared with you\": \"\",\n  \"Wallets\": \"\",\n  \"or\": \"\",\n  \"set total to\": \"\",\n  \"Transactions\": \"\",\n  \"Describe expense and press Enter to add\": \"\",\n  \"Transaction amount\": \"\",\n  \"Expenses per day trends\": \"\",\n  \"No transactions for\": \"\",\n  \"Contact\": \"\",\n  \"Log Out\": \"\",\n  \"View Source on GitHub\": \"\",\n  \"Copyright\": \"\",\n  \"GNU Affero GPL License\": \"\",\n  \"Change DimeShift language\": \"\",\n  \"the easiest way to track your expenses\": \"\",\n  \"To demonstrate how simple it is\": \"\",\n  \"we don't even ask you to register\": \"\",\n  \"Just move your mouse pointer over\": \"\",\n  \"here\": \"\",\n  \"and start using wallet right now!\": \"\",\n  \"Just click\": \"\",\n  \"Screenshots\": \"\",\n  \"Easiest way to manage your personal finances online\": \"\",\n  \"Simple as it is\": \"\",\n  \"Any currency\": \"\",\n  \"Create as many wallets as you need\": \"\",\n  \"Internalization\": \"\",\n  \"Just click on the globe icon in top right corner\": \"\",\n  \"Open Source!\": \"\",\n  \"GNU Affero GPL Licensed. Please feel free to check out the code and fork it!\": \"\",\n  \"Please don't forget to let us know your email address, so you can sign in to DimeShift on your next visit\": \"\",\n  \"Do it\": \"\",\n  \"Here is quick introdution to DimeShift.<br><br>Our demo robot has created few sample wallets for you to check out.\": \"\",\n  \"But you can add as many as you want.<br><br>Different name, different currencies\": \"\",\n  \"There're few options availiable when you move your mouse over your wallet.<br><br>\\n\\tBut lets jump directly to wallet page.<br><br>Click any row to jump to it.\\n\\t\": \"\",\n  \"Let's start by adding some money to your wallet.<br><br>Click \\\"Add Profit\\\" button and fill the form in modal window. It's simple.\": \"\",\n  \"You can also set current total with \\\"Set Total To\\\" dialog.<br><br>\\n\\t\\t\\t\\t\\tWe don't ask you to track every transaction you've done(though you can). \\n\\t\\t\\t\\t\\tFeel free to update your DimeShift wallet every evening, or even once in few days.<br><br>\\n\\t\\t\\t\\t\\tClick \\\"set total to\\\" action link and fill the form to check how it works.\": \"\",\n  \"It's time to add some expense.<br><br>\\n\\tYou can add transaction with one string, e.g. \\\"99.93, best expense ever\\\".<br><br>\\n\\tPress Enter when tranasction description is ready.\\n\\t\": \"\",\n  \"Check out updated transactions list\": \"\",\n  \"Check out expenses per day trends. Simple chart that gets updated every time you add another tranasction.\": \"\",\n  \"Don't forget to fill your profile, so you can sign in to DimeShift next time.\": \"\",\n  \"Select file\": \"\",\n  \"Uploading...\": \"\",\n  \"Do not import\": \"\",\n  \"Expense amount\": \"\",\n  \"Preview\": \"\",\n  \"Import\": \"\",\n  \"Back\": \"\",\n  \"Import .xls file\": \"\",\n  \"Step 1. Select .xls file to import\": \"\",\n  \"Invalid xls file. Please select another one and try again\": \"\",\n  \"Please select your local .xls file\": \"\",\n  \"Step 2. Select columns to import\": \"\",\n  \"more rows\": \"\",\n  \"Amount and Date fields are required\": \"\",\n  \"Few more rows\": \"\",\n  \"Do not import transaction, if it's already in database\": \"\",\n  \"Step 4. Import\": \"\",\n  \"Finished\": \"\",\n  \"Import operation is finished\": \"\",\n  \"Check out you updated wallet\": \"\",\n  \"Step 3. Preview and settings\": \"\",\n  \"You don't have access to other users' wallets\": \"\",\n  \"Goals\": \"\",\n  \"Are you sure that you want to remove this plan?\": \"\",\n  \"Plan name\": \"\",\n  \"Plan your expenses\": \"\",\n  \"Your plans\": \"\",\n  \"View Report\": \"\",\n  \"Create new\": \"\",\n  \"Basic settings\": \"\",\n  \"Wallets to use for planning\": \"\",\n  \"Next\": \"\",\n  \"Plan settings\": \"\",\n  \"Current balance is\": \"\",\n  \"Calculate in different currency\": \"\",\n  \"And on\": \"\",\n  \"Plan is to keep\": \"\",\n  \"Set to\": \"\",\n  \"So you\": \"\",\n  \"can spend up to\": \"\",\n  \"have to get\": \"\",\n  \"on the next day\": \"\",\n  \"in next\": \"\",\n  \"days\": \"\",\n  \"per day\": \"\",\n  \"Confirm and save\": \"\",\n  \"Goal Details\": \"\",\n  \"From:\": \"\",\n  \"To:\": \"\",\n  \"From\": \"\",\n  \"to\": \"\",\n  \"Day by day report\": \"\",\n  \"Total On Start\": \"\",\n  \"Spent\": \"\",\n  \"Profit\": \"\",\n  \"Plan\": \"\",\n  \"Remove account\": \"\",\n  \"Security code\": \"\",\n  \"Demo account will be removed as soon as you do log out from it.\": \"\",\n  \"Please think twice. All account data will be lost.\": \"\",\n  \"has been mailed to your email. Please fill this form to finish account removal.\": \"\",\n  \"Your account has been removed. We will miss you :(\": \"\",\n  \"Invalid\": \"\",\n  \"There're no goals defined for this wallet\": \"\",\n  \"Set Goal\": \"\",\n  \"You\": \"\",\n  \"today\": \"\"\n}"
  },
  {
    "path": "data/i18n/ptbr.json",
    "content": "{\n  \"Nothing is found\": \"Sem resultado\",\n  \"Add Income\": \"Adicionar Receita\",\n  \"Amount\": \"Valor\",\n  \"Description\": \"Descrição\",\n  \"Desciption\": \"\",\n  \"Add\": \"Adicionar\",\n  \"Saving...\": \"Salvando...\",\n  \"Add Wallet\": \"Adicionar Carteira\",\n  \"Name\": \"Nome\",\n  \"Currency\": \"Moeda\",\n  \"Select Currency\": \"Selecionar Moeda\",\n  \"Edit Wallet\": \"Editar Carteira\",\n  \"Save\": \"Salvar\",\n  \"Fill Profile\": \"Preencher Perfil\",\n  \"Username\": \"Usuário\",\n  \"Email\": \"Email\",\n  \"Password\": \"Senha\",\n  \"Invalid username or password\": \"Usuário ou senha inválidos\",\n  \"Thank you! From now, you can sign in to your account any time from any device.\": \"Obrigado! A partir de agora, você pode fazer login na sua conta a qualquer momento a partir de qualquer dispositivo.\",\n  \"Are you sure that you want to hide\": \"Tem certeza que você deseja ocultar\",\n  \"this wallet\": \"esta carteira\",\n  \"wallet\": \"carteira\",\n  \"Are you sure that you want to remove\": \"Tem certeza que você deseja ocultar\",\n  \"You will be able to restore it from Trash folder\": \"Você será capaz de restaurá-lo a partir da Lixeira\",\n  \"All wallet data(transactions etc.) will be lost\": \"Todos os dados da carteira (transações etc.) serão perdidos\",\n  \"Yes, Hide It\": \"Sim, oculte-o\",\n  \"Yes, Remove\": \"Sim, Remover\",\n  \"Removing...\": \"Removendo...\",\n  \"Cancel\": \"Cancelar\",\n  \"Canceling...\": \"Cancelando...\",\n  \"Registration\": \"Registro\",\n  \"Sign Up\": \"Inscrição\",\n  \"Registration...\": \"Registro...\",\n  \"Thank you! Please check your email inbox for confirmation link\": \"Obrigado! Por favor verifique sua caixa de entrada pelo link de confirmação\",\n  \"Already a member?\": \"Já é membro\",\n  \"Sign In\": \"Entrar\",\n  \"Are you sure that you want to remove access for email\": \"Tem certeza de que deseja remover o acesso de e-mail?\",\n  \"from this wallet\": \"desta carteira\",\n  \"from wallet\": \"da carteira\",\n  \"Are you sure that you want to remove this transaction?\": \"Tem certeza de que deseja remover esta transação?\",\n  \"Restore Password\": \"Restaurar Senha\",\n  \"Restore\": \"Restaurar\",\n  \"Processing...\": \"Processando\",\n  \"Instructions have been sent to your email address\": \"Instruções enviadas para seu email\",\n  \"Don't have an account?\": \"Sem uma conta?\",\n  \"Register\": \"Registrar\",\n  \"Set Total To\": \"Definir Total Para\",\n  \"Total\": \"Total\",\n  \"Set\": \"Definir\",\n  \"Username or Email\": \"Usuário ou Email\",\n  \"Signing in...\": \"Entrando\",\n  \"Restore your password\": \"Restaurar sua senha\",\n  \"Transaction Details\": \"Detalhes da Transação\",\n  \"Date\": \"Data\",\n  \"Time\": \"Hora\",\n  \"Remove\": \"Remover\",\n  \"Users with access\": \"Usuários com acesso\",\n  \"to this wallet\": \"para esta carteira\",\n  \"to wallet\": \"para carteira\",\n  \"Only you have access to this wallet\": \"Somente você tem acesso a esta carteira\",\n  \"Not registered yet\": \"Não registrado ainda\",\n  \"Remove Access\": \"Remover Acesso\",\n  \"Add access\": \"Adicionar acesso\",\n  \"Give Access\": \"Obter Acesso\",\n  \"January\": \"Janeiro\",\n  \"February\": \"Fevereiro\",\n  \"March\": \"Março\",\n  \"April\": \"Abril\",\n  \"May\": \"Maio\",\n  \"June\": \"Junho\",\n  \"July\": \"Julho\",\n  \"August\": \"Agosto\",\n  \"September\": \"Setembro\",\n  \"October\": \"Outubro\",\n  \"November\": \"Novembro\",\n  \"December\": \"Dezembro\",\n  \"january\": \"janeiro\",\n  \"february\": \"fevereiro\",\n  \"march\": \"março\",\n  \"april\": \"abril\",\n  \"may\": \"maio\",\n  \"june\": \"junho\",\n  \"july\": \"julho\",\n  \"august\": \"agosto\",\n  \"september\": \"setembro\",\n  \"october\": \"outubro\",\n  \"november\": \"novembro\",\n  \"december\": \"dezembro\",\n  \"Home\": \"Home\",\n  \"Settings\": \"Configurações\",\n  \"Your password has been successfully changed\": \"Sua senha foi atualizada com sucesso\",\n  \"Invalid current password\": \"Senha atual inválida\",\n  \"Passwords missmatch\": \"Senhas incompatíveis\",\n  \"New password is too short\": \"Nova senha é muito curta\",\n  \"Current Password\": \"Senha Atual\",\n  \"New Password\": \"NOva Senha\",\n  \"Repeat Password\": \"Repetir Senha\",\n  \"Change Password\": \"Alterar Senha\",\n  \"Update Password\": \"Atualizar Senha\",\n  \"Invalid Restore Password Code\": \"Código para restaurar senha inválido\",\n  \"Restore Password Code\": \"Código para restaurar senha\",\n  \"Restore Password Hash\": \"Hash para restaurar senha\",\n  \"Your Wallets\": \"Suas Carteiras\",\n  \"You have no wallets\": \"Você não possui carteiras\",\n  \"You have no hidden wallets\": \"Você não possui carteiras ocultas\",\n  \"Hide\": \"Ocultar\",\n  \"Edit\": \"Editar\",\n  \"Manage Accesses\": \"Gerenciar Acessos\",\n  \"This wallet is shared with you by another user\": \"Esta carteira é compartilhada com você por outro usuário\",\n  \"Filter\": \"Filtro\",\n  \"Active\": \"Ativo\",\n  \"Trash\": \"Lixo\",\n  \"Access\": \"Acesso\",\n  \"Both\": \"Ambos\",\n  \"Yours\": \"Seus\",\n  \"Shared with you\": \"Compartilhado com você\",\n  \"Wallets\": \"Carteiras\",\n  \"or\": \"ou\",\n  \"set total to\": \"definir total para\",\n  \"Transactions\": \"Transações\",\n  \"Describe expense and press Enter to add\": \"Descreva a despesa e pressione Enter para adicionar\",\n  \"Transaction amount\": \"Valor da transação\",\n  \"Expenses per day trends\": \"Tendencia de despesas por dia\",\n  \"No transactions for\": \"Sem transações para\",\n  \"Contact\": \"Contato\",\n  \"Log Out\": \"Encerrar\",\n  \"View Source on GitHub\": \"Ver origem no GitHub\",\n  \"Copyright\": \"Copyright\",\n  \"GNU Affero GPL License\": \"GNU Affero GPL License\",\n  \"Change DimeShift language\": \"Mudar linguagem DimeShift\",\n  \"the easiest way to track your expenses\": \"A maneira mais simples de gerenciar suas finanças\",\n  \"To demonstrate how simple it is\": \"Para demonstrar como é simples\",\n  \"we don't even ask you to register\": \"Não pediremos para registrar\",\n  \"Just move your mouse pointer over\": \"Basta mover o ponteiro do mouse sobre\",\n  \"here\": \"aqui\",\n  \"and start using wallet right now!\": \"e inicie usando a carteira agora mesmo!\",\n  \"Just click\": \"Basta clicar\",\n  \"Screenshots\": \"Screenshots\",\n  \"Easiest way to manage your personal finances online\": \"Maneira mais fácil de gerenciar suas finanças pessoais on-line\",\n  \"Simple as it is\": \"Simples como é\",\n  \"Any currency\": \"Qualquer moeda\",\n  \"Create as many wallets as you need\": \"Crie quantas carteiras precisar\",\n  \"Internalization\": \"Internacioanlização\",\n  \"Just click on the globe icon in top right corner\": \"\",\n  \"Please don't forget to let us know your email address, so you can sign in to DimeShift on your next visit\": \"Por favor, não se esqueça de nos informar seu endereço de e-mail, para entrar em sua próxima visita a DimeShift\",\n  \"Do it\": \"Faça\",\n  \"Here is quick introdution to DimeShift.<br><br>Our demo robot has created few sample wallets for you to check out.\": \"Rápida introdução a DimeShift.<br:<brNosso robô criou uma demonstração para que você vá para algumas carteiras de amostra.:\",\n  \"But you can add as many as you want.<br><br>Different name, different currencies\": \"Mas você pode adicionar quantos você quiser.<br><br>Diferentes nomes e moedas\",\n  \"There're few options availiable when you move your mouse over your wallet.<br><br>\\n\\tBut lets jump directly to wallet page.<br><br>Click any row to jump to it.\\n\\t\": \"Poucas opções são disponibilizadas quando você move o mouse sobre a sua carteira.<br><br>\\n\\tMas vamos pular diretamente para a página de carteira.<br><br>Clique em qualquer linha para saltar para ela.\\n\\t\",\n  \"Let's start by adding some money to your wallet.<br><br>Click \\\"Add Profit\\\" button and fill the form in modal window. It's simple.\": \"Vamos começar adicionando um pouco de dinheiro para a sua carteira.<br><br>Clique o botão \\\"Adicionar Beneficio\\\" e preencha o formulário na janela. É simples.\",\n  \"You can also set current total with \\\"Set Total To\\\" dialog.<br><br>\\n\\t\\t\\t\\t\\tWe don't ask you to track every transaction you've done(though you can). \\n\\t\\t\\t\\t\\tFeel free to update your DimeShift wallet every evening, or even once in few days.<br><br>\\n\\t\\t\\t\\t\\tClick \\\"set total to\\\" action link and fill the form to check how it works.\": \"Você pode definir o Total Atual com o diálogo \\\"Definir Total Para\\\".<br><br>\\n\\t\\t\\t\\t\\tNós não pedimos que você acompanhe todas as transações que você fez (embora você possa). \\n\\t\\t\\t\\tSinta-se livre para atualizar sua carteira DimeShift todas as noites, ou mesmo uma vez em poucos dias.<br><br>\\n\\t\\t\\t\\t\\tClique no link \\\"Definir Total Para\\\" e preencha o formulário para ver como funciona.\",\n  \"It's time to add some expense.<br><br>\\n\\tYou can add transaction with one string, e.g. \\\"99.93, best expense ever\\\".<br><br>\\n\\tPress Enter when tranasction description is ready.\\n\\t\": \"É hora de adicionar alguma despesa.<br><br>\\n\\tVocê pode adicionar transação com um simples texto,ex:\\\"99.93, melhor gasto\\\".<br><br>\\n\\tPressione Enter quando a descrição da transação estiver pronta.\\n\\t\",\n  \"Check out updated transactions list\": \"Confira lista de transações atualizadas\",\n  \"Check out expenses per day trends. Simple chart that gets updated every time you add another tranasction.\": \"Confira as tendências de despesas por dia. Gráfico simples que é atualizado cada vez que você adicionar uma outra transação.\",\n  \"Don't forget to fill your profile, so you can sign in to DimeShift next time.\": \"Não se esqueça de preencher o seu perfil, de modo que você possa entrar na DimeShift da próxima vez.\",\n  \"Select file\": \"Selecionar arquivo\",\n  \"Uploading...\": \"Carregando...\",\n  \"Do not import\": \"Não importar\",\n  \"Expense amount\": \"Valor da despesa\",\n  \"Preview\": \"Visualizar\",\n  \"Import\": \"Importar\",\n  \"Back\": \"Voltar\",\n  \"Import .xls file\": \"Importar arquivo .xls\",\n  \"Step 1. Select .xls file to import\": \"Passo 1. Selecionar arquivo .xls para importar\",\n  \"Invalid xls file. Please select another one and try again\": \"Arquivo xls inválido. Por favor selecionar outro e tentar novamente\",\n  \"Please select your local .xls file\": \"Selecionar o local do seu arquivo .xls\",\n  \"Step 2. Select columns to import\": \"Passo 2. Selecionar colunas para importar\",\n  \"more rows\": \"mais linhas\",\n  \"Amount and Date fields are required\": \"Os campos valor e data são obrigatórios\",\n  \"Few more rows\": \"Poucas linhas a mais\",\n  \"Do not import transaction, if it's already in database\": \"Não importar transação, se ela já está no banco de dados\",\n  \"Step 4. Import\": \"Passo 4. Importar\",\n  \"Finished\": \"Terminado\",\n  \"Import operation is finished\": \"Operação de importação concluída\",\n  \"Check out you updated wallet\": \"Confira atualização de sua carteira\",\n  \"Step 3. Preview and settings\": \"Passo 3. Configuração e Visualização\",\n  \"Goals\": \"\",\n  \"Are you sure that you want to remove this plan?\": \"\",\n  \"Plan name\": \"\",\n  \"Plan your expenses\": \"\",\n  \"Your plans\": \"\",\n  \"View Report\": \"\",\n  \"Create new\": \"\",\n  \"Basic settings\": \"\",\n  \"Wallets to use for planning\": \"\",\n  \"Next\": \"\",\n  \"Plan settings\": \"\",\n  \"Current balance is\": \"\",\n  \"Calculate in different currency\": \"\",\n  \"And on\": \"\",\n  \"Plan is to keep\": \"\",\n  \"Set to\": \"\",\n  \"So you\": \"\",\n  \"can spend up to\": \"\",\n  \"have to get\": \"\",\n  \"on the next day\": \"\",\n  \"in next\": \"\",\n  \"days\": \"\",\n  \"per day\": \"\",\n  \"Confirm and save\": \"\",\n  \"Goal Details\": \"\",\n  \"From:\": \"\",\n  \"To:\": \"\",\n  \"From\": \"\",\n  \"to\": \"\",\n  \"Day by day report\": \"\",\n  \"Total On Start\": \"\",\n  \"Spent\": \"\",\n  \"Profit\": \"\",\n  \"Plan\": \"\",\n  \"Remove account\": \"\",\n  \"Security code\": \"\",\n  \"Demo account will be removed as soon as you do log out from it.\": \"\",\n  \"Please think twice. All account data will be lost.\": \"\",\n  \"has been mailed to your email. Please fill this form to finish account removal.\": \"\",\n  \"Your account has been removed. We will miss you :(\": \"\",\n  \"Invalid\": \"\",\n  \"You don't have access to other users' wallets\": \"\",\n  \"There're no goals defined for this wallet\": \"\",\n  \"Set Goal\": \"\",\n  \"You\": \"\",\n  \"today\": \"\"\n}"
  },
  {
    "path": "data/i18n/ru.json",
    "content": "{\n  \"Nothing is found\": \"Ничего не найдено\",\n  \"Add Income\": \"Добавить доход\",\n  \"Amount\": \"Сумма\",\n  \"Description\": \"Описание\",\n  \"Add\": \"Добавить\",\n  \"Saving...\": \"Сохранение\",\n  \"Add Wallet\": \"Добавить кошелек\",\n  \"Name\": \"Название\",\n  \"Currency\": \"Валюта\",\n  \"Select Currency\": \"Выбрать валюту\",\n  \"Edit Wallet\": \"Редактировать кошелек\",\n  \"Save\": \"Сохранить\",\n  \"Fill Profile\": \"Заполнить профиль\",\n  \"Username\": \"Имя пользователя\",\n  \"Email\": \"\",\n  \"Password\": \"Пароль\",\n  \"Invalid username or password\": \"Неправильное имя пользователя или пароль\",\n  \"Thank you! From now, you can sign in to your account any time from any device.\": \"Спасибо! Теперь вы можете войти в ваш аккаунт с любого устройства.\",\n  \"Are you sure that you want to hide\": \"Вы уверены что хотите скрыть\",\n  \"this wallet\": \"этот кошелек\",\n  \"wallet\": \"кошелек\",\n  \"Are you sure that you want to remove\": \"Вы уверены что хотите удалить\",\n  \"You will be able to restore it from Trash folder\": \"Вы сможете восстановить его из Корзины\",\n  \"All wallet data(transactions etc.) will be lost\": \"Все данные, включая транзакции, будут утеряны\",\n  \"Yes, Hide It\": \"Да, спрятать\",\n  \"Yes, Remove\": \"Да, удалить\",\n  \"Removing...\": \"Удаление...\",\n  \"Cancel\": \"Отмена\",\n  \"Canceling...\": \"Отмена...\",\n  \"Registration\": \"Регистрация\",\n  \"Sign Up\": \"Зарегистрироваться\",\n  \"Registration...\": \"Регистрация...\",\n  \"Thank you! Please check your email inbox for confirmation link\": \"Спасибо. Мы отправили вам письмо с ссылкой для подтверждения вашей учетной записи\",\n  \"Already a member?\": \"Уже зарегистрированы?\",\n  \"Sign In\": \"Войти\",\n  \"Are you sure that you want to remove access for email\": \"Вы уверены что хотите удалить доступ для email\",\n  \"from this wallet\": \"для этого кошелька\",\n  \"from wallet\": \"для кошелька\",\n  \"Are you sure that you want to remove this transaction?\": \"Вы уверены что хотите удалить эту транзакцию?\",\n  \"Restore Password\": \"Восстановить пароль\",\n  \"Restore\": \"Восттановить\",\n  \"Processing...\": \"Обработка...\",\n  \"Instructions have been sent to your email address\": \"Инструкции отправлены на вашу электронную почту\",\n  \"Don't have an account?\": \"Еще нет учетной записи?\",\n  \"Register\": \"Зарегистрироваться\",\n  \"Set Total To\": \"Установить текущую сумму\",\n  \"Total\": \"Итого\",\n  \"Set\": \"Установить\",\n  \"Username or Email\": \"Имя пользователя или пароль\",\n  \"Signing in...\": \"Проверка...\",\n  \"Restore your password\": \"Восттановить ваш пароль\",\n  \"Transaction Details\": \"Детали транзакции\",\n  \"Date\": \"Дата\",\n  \"Time\": \"Время\",\n  \"Remove\": \"Удалить\",\n  \"Users with access\": \"Пользователи с доступом\",\n  \"to this wallet\": \"к этому кошельку\",\n  \"to wallet\": \"к кошельку\",\n  \"Only you have access to this wallet\": \"Только у вас есть доступ\",\n  \"Not registered yet\": \"Еще не зарегистрирован\",\n  \"Remove Access\": \"Лишить доступа\",\n  \"Add access\": \"Предоставить доступ\",\n  \"Give Access\": \"Предоставить доступ\",\n  \"January\": \"Январь\",\n  \"February\": \"Февраль\",\n  \"March\": \"Март\",\n  \"April\": \"Апрель\",\n  \"May\": \"Май\",\n  \"June\": \"Июнь\",\n  \"July\": \"Июль\",\n  \"August\": \"Август\",\n  \"September\": \"Сентябрь\",\n  \"October\": \"Октябрь\",\n  \"November\": \"Ноябрь\",\n  \"December\": \"Декабрь\",\n  \"january\": \"января\",\n  \"february\": \"февраля\",\n  \"march\": \"марта\",\n  \"april\": \"апреля\",\n  \"may\": \"мая\",\n  \"june\": \"июня\",\n  \"july\": \"июля\",\n  \"august\": \"августа\",\n  \"september\": \"сентября\",\n  \"october\": \"октября\",\n  \"november\": \"ноября\",\n  \"december\": \"декабря\",\n  \"Home\": \"Главная\",\n  \"Settings\": \"Настройки\",\n  \"Your password has been successfully changed\": \"Пароль успешно изменен\",\n  \"Invalid current password\": \"Неверный текущий пароль\",\n  \"Passwords missmatch\": \"Пароли не совпадают\",\n  \"New password is too short\": \"Новый пароль слишком короткий\",\n  \"Current Password\": \"Текущий пароль\",\n  \"New Password\": \"Новый пароль\",\n  \"Repeat Password\": \"Повторить новый пароль\",\n  \"Change Password\": \"Изменить пароль\",\n  \"Update Password\": \"Изменить пароль\",\n  \"Invalid Restore Password Code\": \"Неверный код восстановления пароля\",\n  \"Restore Password Code\": \"Код восстановления пароля\",\n  \"Restore Password Hash\": \"Хэш восстановления пароля\",\n  \"Your Wallets\": \"Ваши кошельки\",\n  \"You have no wallets\": \"У вас нет кошельков\",\n  \"You have no hidden wallets\": \"У вас нет скрытых кошельков\",\n  \"Hide\": \"Спрятать\",\n  \"Edit\": \"Редактировать\",\n  \"Manage Accesses\": \"Управление доступом\",\n  \"This wallet is shared with you by another user\": \"Доступ к этому кошельку предоставлен другим пользователем\",\n  \"Filter\": \"Фильтр\",\n  \"Active\": \"Активные\",\n  \"Trash\": \"Корзина\",\n  \"Access\": \"Доступ\",\n  \"Both\": \"Все\",\n  \"Yours\": \"Ваши\",\n  \"Shared with you\": \"Доступные вам\",\n  \"Wallets\": \"Кошельки\",\n  \"or\": \"или\",\n  \"set total to\": \"установить текущую сумму\",\n  \"Transactions\": \"Транзакции\",\n  \"Describe expense and press Enter to add\": \"Опишите транзакцию и нажмите Enter\",\n  \"Transaction amount\": \"Сумма операции\",\n  \"Expenses per day trends\": \"Тенденции дневных расходов\",\n  \"No transactions for\": \"Нет транзакций за\",\n  \"Contact\": \"Написать нам\",\n  \"Log Out\": \"Выйти\",\n  \"View Source on GitHub\": \"Исходный код на GitHub\",\n  \"Copyright\": \"Разработано в\",\n  \"GNU Affero GPL License\": \"под лицензией GNU Affero GPL\",\n  \"Change DimeShift language\": \"Выбрать язык интерфейса\",\n  \"the easiest way to track your expenses\": \"самый простой способ вести учет финансов\",\n  \"To demonstrate how simple it is\": \"Чтобы показать насколько\",\n  \"we don't even ask you to register\": \"мы даже не просим вас вводить данные в форму регистрации\",\n  \"Just move your mouse pointer over\": \"Просто наведите указатель мыши\",\n  \"here\": \"сюда\",\n  \"and start using wallet right now!\": \"и начните использовать DimeShift уже сейчас!\",\n  \"Just click\": \"Просто нажмите\",\n  \"Screenshots\": \"Скриншоты\",\n  \"Easiest way to manage your personal finances online\": \"Самый простой способ упорядочить ваши финансы\",\n  \"Simple as it is\": \"Проще не придумаешь\",\n  \"Any currency\": \"Любая валюта\",\n  \"Create as many wallets as you need\": \"Создавайте сколь угодно много кошельков\",\n  \"Internalization\": \"Локализации\",\n  \"Just click on the globe icon in top right corner\": \"Доступны несколько языков интерфейса\",\n  \"Please don't forget to let us know your email address, so you can sign in to DimeShift on your next visit\": \"Пожалуйста, заполните ваш профиль, чтобы вы смогли войти в вашу учетную запись в следующий раз\",\n  \"Do it\": \"Заполнить\",\n  \"Here is quick introdution to DimeShift.<br><br>Our demo robot has created few sample wallets for you to check out.\": \"Позвольте нам провести небольшой тур по основным функциям DimeShift<br><br>Наш робот создал пару тестовых кошельков для тестирования.\",\n  \"But you can add as many as you want.<br><br>Different name, different currencies\": \"Но вы можете создать их столько, сколько захотите.<br><br>В любой валюте, с любым названием.\",\n  \"There're few options availiable when you move your mouse over your wallet.<br><br>\\n\\tBut lets jump directly to wallet page.<br><br>Click any row to jump to it.\\n\\t\": \"Наведите указатель на строку с названием кошелька и появятся кнопки с дополнительными функциями.<br><br>Но давайте сразу перейдем на страницу кошелька. Нажмите на любой кошелек, чтобы продолжить.\",\n  \"Let's start by adding some money to your wallet.<br><br>Click \\\"Add Profit\\\" button and fill the form in modal window. It's simple.\": \"Давайте для начала добавим в кошелек немного денег :)<br><br>Нажмите на эту кнопку и заполните небольшую форму во всплывающем окне. Это просто.\",\n  \"You can also set current total with \\\"Set Total To\\\" dialog.<br><br>\\n\\t\\t\\t\\t\\tWe don't ask you to track every transaction you've done(though you can). \\n\\t\\t\\t\\t\\tFeel free to update your DimeShift wallet every evening, or even once in few days.<br><br>\\n\\t\\t\\t\\t\\tClick \\\"set total to\\\" action link and fill the form to check how it works.\": \"В отличии от других подобных систем, Dimeshift разрабатывали реалисты. Мы не просим вас вводить данные о каждой транзакции, иногда бывает проще в какой-то момент установить текущую сумму.<br><br>Это можно делать каждый вечер или даже раз в несколько дней.<br><br>Если вдруг вы забыли о своем решении вести учет, а через время вернулись к этой идее - не страшно, возвращайтесь к своим кошелькам в любое время.\",\n  \"It's time to add some expense.<br><br>\\n\\tYou can add transaction with one string, e.g. \\\"99.93, best expense ever\\\".<br><br>\\n\\tPress Enter when tranasction description is ready.\\n\\t\": \"Настало время указать расходы.<br><br>Можно описать транзакцию в одну строку, например '99.99, лучшая трата в моей жизни'<br><br>Нажмите Enter, когда будет готово\",\n  \"Check out updated transactions list\": \"Список транзакций обновился\",\n  \"Check out expenses per day trends. Simple chart that gets updated every time you add another tranasction.\": \"Каждая транзакция отображается на графике, наглядно показывая ваши траты\",\n  \"Don't forget to fill your profile, so you can sign in to DimeShift next time.\": \"Заполните ваш профиль, чтобы иметь возможность войти в него снова\",\n  \"Select file\": \"Выбрать файл\",\n  \"Uploading...\": \"Загрузка...\",\n  \"Do not import\": \"Не имортировать\",\n  \"Expense amount\": \"Сумма траты\",\n  \"Preview\": \"Предпросмотр\",\n  \"Import\": \"Импорт\",\n  \"Back\": \"Назад\",\n  \"Import .xls file\": \"Импорт файла Excel\",\n  \"Step 1. Select .xls file to import\": \"Шаг 1. Выберите файл для импорта\",\n  \"Invalid xls file. Please select another one and try again\": \"Неверный формат файла. Попробуйте загрузить другой файл\",\n  \"Please select your local .xls file\": \"Выберите .xls файл на вашем компьютере\",\n  \"Step 2. Select columns to import\": \"Шаг 2. Веберите столбцы для импорта\",\n  \"more rows\": \"дополнительных строк\",\n  \"Amount and Date fields are required\": \"Обязательные столбцы: сумма и дата\",\n  \"Few more rows\": \"Еще несколько строк\",\n  \"Do not import transaction, if it's already in database\": \"Не импортировать транзакцию, если она уже есть в базе данных\",\n  \"Step 4. Import\": \"Шаг 4. Импорт\",\n  \"Finished\": \"Завершено\",\n  \"Import operation is finished\": \"Импорт завершен\",\n  \"Check out you updated wallet\": \"Просмотрите ваш обновленный кошелек\",\n  \"Step 3. Preview and settings\": \"Шаг 3. Предпросмотр\",\n  \"You don't have access to other users' wallets\": \"У вас нет доступа к кошелькам других пользователей\",\n  \"Goals\": \"Цели\",\n  \"Are you sure that you want to remove this plan?\": \"Вы уверены, что хотите удалить эту цель?\",\n  \"Plan name\": \"Название цели\",\n  \"Plan your expenses\": \"Планирование расходов\",\n  \"Your plans\": \"Ваши цели\",\n  \"View Report\": \"Просмотреть отчет\",\n  \"Create new\": \"Создать новую\",\n  \"Basic settings\": \"Основные настройки\",\n  \"Wallets to use for planning\": \"Кошельки для планирования\",\n  \"Next\": \"Далее\",\n  \"Plan settings\": \"Настройки цели\",\n  \"Current balance is\": \"Текущий баланс\",\n  \"Calculate in different currency\": \"Пересчитать в другой валюте\",\n  \"And on\": \"И на дату\",\n  \"Plan is to keep\": \"Баланс должен быть\",\n  \"Set to\": \"Установить в\",\n  \"So you\": \"Итак, вы\",\n  \"can spend up to\": \"можете потратить до\",\n  \"have to get\": \"должны добавить\",\n  \"on the next day\": \"завтра\",\n  \"in next\": \"в следующие\",\n  \"days\": \"дней\",\n  \"per day\": \"в день\",\n  \"Confirm and save\": \"Подтвердить и сохранить\",\n  \"Goal Details\": \"Детали Цели\",\n  \"From:\": \"От:\",\n  \"To:\": \"До:\",\n  \"From\": \"От\",\n  \"to\": \"до\",\n  \"Day by day report\": \"Отчёт по дням\",\n  \"Total On Start\": \"Баланс в начале дня\",\n  \"Spent\": \"Траты\",\n  \"Profit\": \"Доход\",\n  \"Plan\": \"Цель\",\n  \"Remove account\": \"Удалить учетную запись\",\n  \"Security code\": \"Код безопасности\",\n  \"Demo account will be removed as soon as you do log out from it.\": \"Демострационный аккаунт будет удален после завершения текущей сессии\",\n  \"Please think twice. All account data will be lost.\": \"Уверены? Все данные будут удалены безвозвратно.\",\n  \"has been mailed to your email. Please fill this form to finish account removal.\": \"был отправлен на ваш email. Заполните эту форму и завершите процедуру удаления\",\n  \"Your account has been removed. We will miss you :(\": \"Аккаунт удалён. Печалька :( Мы будем скучать.\",\n  \"Invalid\": \"Неверный\",\n  \"There're no goals defined for this wallet\": \"Для этого кошелька не определены цели\",\n  \"Set Goal\": \"Установить цель\",\n  \"You\": \"Вы\",\n  \"today\": \"сегодня\"\n}"
  },
  {
    "path": "data/i18n/ua.json",
    "content": "{\n  \"Nothing is found\": \"Нічого не знайдено\",\n  \"Add Income\": \"Додати прибуток\",\n  \"Amount\": \"Сума\",\n  \"Description\": \"Опис\",\n  \"Add\": \"Додати\",\n  \"Saving...\": \"Збереження...\",\n  \"Add Wallet\": \"Додати гаманець\",\n  \"Name\": \"Ім’я\",\n  \"Currency\": \"Валюта\",\n  \"Select Currency\": \"Вибрати валюту\",\n  \"Edit Wallet\": \"Редагувати гаманець\",\n  \"Save\": \"Зберегти\",\n  \"Fill Profile\": \"Заповнити профіль\",\n  \"Username\": \"Ім’я користувача\",\n  \"Email\": \"\",\n  \"Password\": \"Пароль\",\n  \"Invalid username or password\": \"Невірне ім’я користувача або пароль\",\n  \"Thank you! From now, you can sign in to your account any time from any device.\": \"Дякуємо! Відтепер, ви можете увійти в свій обліковий запис в будь-який час з будь-якого пристрою.\",\n  \"Are you sure that you want to hide\": \"Ви впевнені, що ви хочете приховати\",\n  \"this wallet\": \"цей гаманець\",\n  \"wallet\": \"гаманець\",\n  \"Are you sure that you want to remove\": \"Ви впевнені, що ви хочете видалити\",\n  \"You will be able to restore it from Trash folder\": \"Ви зможете відновити його з папки Приховані\",\n  \"All wallet data(transactions etc.) will be lost\": \"Всі дані гаманця будуть втрачені\",\n  \"Yes, Hide It\": \"Так, приховати\",\n  \"Yes, Remove\": \"Так, видалити\",\n  \"Removing...\": \"Обробка...\",\n  \"Cancel\": \"Скасувати\",\n  \"Canceling...\": \"Скасування...\",\n  \"Registration\": \"Реєстрація\",\n  \"Sign Up\": \"Зареєструватися\",\n  \"Registration...\": \"Реєстрація...\",\n  \"Thank you! Please check your email inbox for confirmation link\": \"Дякуємо! Будь ласка, перевірте свою поштову скриньку. Ми відправили вам повідомлення з посиланням підтвердження вашого облікового запису\",\n  \"Already a member?\": \"Вже зареєстровані?\",\n  \"Sign In\": \"Увійти\",\n  \"Are you sure that you want to remove access for email\": \"Ви впевнені, що хочете видалити доступ для цієї електронної пошти\",\n  \"from this wallet\": \"для цього гаманця\",\n  \"from wallet\": \"для гаманця\",\n  \"Are you sure that you want to remove this transaction?\": \"Ви впевнені, що хочете видалити цю транзакцію?\",\n  \"Restore Password\": \"Відновити пароль\",\n  \"Restore\": \"Відновити\",\n  \"Processing...\": \"Обробка...\",\n  \"Instructions have been sent to your email address\": \"Інструкції були відправлені на вашу електронну пошту\",\n  \"Don't have an account?\": \"Не маєте облікового запису?\",\n  \"Register\": \"Зареєструватися\",\n  \"Set Total To\": \"Встановити загальну суму у\",\n  \"Total\": \"Загальна сума\",\n  \"Set\": \"Встановити\",\n  \"Username or Email\": \"Ім’я користувача або електронна пошта\",\n  \"Signing in...\": \"Обробка...\",\n  \"Restore your password\": \"Відновити пароль\",\n  \"Transaction Details\": \"Деталі транзакції\",\n  \"Date\": \"Дата\",\n  \"Time\": \"Час\",\n  \"Remove\": \"Видалити\",\n  \"Users with access\": \"Користувачі з доступом\",\n  \"to this wallet\": \"до цього гаманця\",\n  \"to wallet\": \"до гаманця\",\n  \"Only you have access to this wallet\": \"Тільки ви маєте доступ до цього гаманця\",\n  \"Not registered yet\": \"Поки що не зареєстрований\",\n  \"Remove Access\": \"Видалити доступ\",\n  \"Add access\": \"Дозволити доступ\",\n  \"Give Access\": \"Дозволити доступ\",\n  \"January\": \"Січень\",\n  \"February\": \"Лютий\",\n  \"March\": \"Березень\",\n  \"April\": \"Квітень\",\n  \"May\": \"Травень\",\n  \"June\": \"Червень\",\n  \"July\": \"Липень\",\n  \"August\": \"Серпень\",\n  \"September\": \"Вересень\",\n  \"October\": \"Жовтень\",\n  \"November\": \"Листопад\",\n  \"December\": \"Грудень\",\n  \"january\": \"січня\",\n  \"february\": \"лютого\",\n  \"march\": \"березня\",\n  \"april\": \"квітня\",\n  \"may\": \"травня\",\n  \"june\": \"червня\",\n  \"july\": \"липня\",\n  \"august\": \"серпня\",\n  \"september\": \"вересня\",\n  \"october\": \"жовтня\",\n  \"november\": \"листопада\",\n  \"december\": \"грудня\",\n  \"Home\": \"Головна\",\n  \"Settings\": \"Налаштування\",\n  \"Your password has been successfully changed\": \"Ваш пароль змінено\",\n  \"Invalid current password\": \"Невірний поточний пароль\",\n  \"Passwords missmatch\": \"Паролі не збігаються\",\n  \"New password is too short\": \"Новий пароль занадто короткий\",\n  \"Current Password\": \"Поточний пароль\",\n  \"New Password\": \"Новий пароль\",\n  \"Repeat Password\": \"Повторити новий пароль\",\n  \"Change Password\": \"Змінитити пароль\",\n  \"Update Password\": \"Змінитити пароль\",\n  \"Invalid Restore Password Code\": \"Невірний код відновлення\",\n  \"Restore Password Code\": \"Код відновлення\",\n  \"Restore Password Hash\": \"Хеш відновлення\",\n  \"Your Wallets\": \"Ваші гаманці\",\n  \"You have no wallets\": \"У вас немає гаманців\",\n  \"You have no hidden wallets\": \"У вас немає прихованих гаманців\",\n  \"Hide\": \"Приховати\",\n  \"Edit\": \"Редагувати\",\n  \"Manage Accesses\": \"Доступ\",\n  \"This wallet is shared with you by another user\": \"Доступ до цього гаманця надано іншим користувачем\",\n  \"Filter\": \"Фільтр\",\n  \"Active\": \"Активні\",\n  \"Trash\": \"Приховані\",\n  \"Access\": \"Доступ\",\n  \"Both\": \"Будь-які\",\n  \"Yours\": \"Ваші\",\n  \"Shared with you\": \"Інших користувачів\",\n  \"Wallets\": \"Гаманці\",\n  \"or\": \"чи\",\n  \"set total to\": \"встановити загальну суму у\",\n  \"Transactions\": \"Транзакції\",\n  \"Describe expense and press Enter to add\": \"Опишіть витрату і натисніть Enter\",\n  \"Transaction amount\": \"Сума транзакції\",\n  \"Expenses per day trends\": \"Тенденції витрат за день\",\n  \"No transactions for\": \"Немає транзакцій за\",\n  \"Contact\": \"Зв’язатися з нами\",\n  \"Log Out\": \"Вийти\",\n  \"View Source on GitHub\": \"Код на GitHub\",\n  \"Copyright\": \"Розроблено у\",\n  \"GNU Affero GPL License\": \"ліцензія GNU Affero GPL\",\n  \"Change DimeShift language\": \"Змінитити мову\",\n  \"the easiest way to track your expenses\": \"найпростіший спосіб ведення обліку фінансів\",\n  \"To demonstrate how simple it is\": \"Щоб продемонструвати як це просто\",\n  \"we don't even ask you to register\": \"ми навіть не просимо вас зареєструватися\",\n  \"Just move your mouse pointer over\": \"Просто наведіть курсор миші\",\n  \"here\": \"сюди\",\n  \"and start using wallet right now!\": \"і почніть використовувати DimeShift прямо зараз!\",\n  \"Just click\": \"Просто натисніть\",\n  \"Screenshots\": \"Скріншоти\",\n  \"Easiest way to manage your personal finances online\": \"\",\n  \"Simple as it is\": \"\",\n  \"Any currency\": \"\",\n  \"Create as many wallets as you need\": \"\",\n  \"Internalization\": \"\",\n  \"Just click on the globe icon in top right corner\": \"\",\n  \"Please don't forget to let us know your email address, so you can sign in to DimeShift on your next visit\": \"Будь ласка, заповніть ваш профіль, щоб ви змогли увійти в ваш обліковий запис наступного разу\",\n  \"Do it\": \"Заповнити\",\n  \"Here is quick introdution to DimeShift.<br><br>Our demo robot has created few sample wallets for you to check out.\": \"Дозвольте нам провести невеликий тур по основним функціям DimeShift.<br><br> Наш робот створив пару тестових гаманців для тестування.\",\n  \"But you can add as many as you want.<br><br>Different name, different currencies\": \"Але ви можете створити їх стільки, скільки забажаєте.<br><br>У будь-якій валюті, з будь-якою назвою.\",\n  \"There're few options availiable when you move your mouse over your wallet.<br><br>\\n\\tBut lets jump directly to wallet page.<br><br>Click any row to jump to it.\\n\\t\": \"Наведіть курсор на рядок з назвою гаманця і з'являться кнопки з додатковими функціями.<br><br>Але спочатку перейдімо на сторінку гаманця. Натисніть на будь-який гаманець, щоб продовжити.\",\n  \"Let's start by adding some money to your wallet.<br><br>Click \\\"Add Profit\\\" button and fill the form in modal window. It's simple.\": \"Для початку додамо в гаманець трохи грошей :)<br><br>Натисніть на цю кнопку і заповніть невелику форму у спливаючому віконці. Це просто.\",\n  \"You can also set current total with \\\"Set Total To\\\" dialog.<br><br>\\n\\t\\t\\t\\t\\tWe don't ask you to track every transaction you've done(though you can). \\n\\t\\t\\t\\t\\tFeel free to update your DimeShift wallet every evening, or even once in few days.<br><br>\\n\\t\\t\\t\\t\\tClick \\\"set total to\\\" action link and fill the form to check how it works.\": \"На відміну від інших подібних систем, DimeShift розробляли реалісти. Ми не просимо вас вводити дані про кожну транзакцію, іноді буває простіше в якийсь момент встановити поточну суму.<br><br>Це можна робити щовечора або навіть раз на кілька днів.<br><br>Якщо раптом ви забули про своє рішення вести облік, а через час повернулися до цієї ідеї - все окей, повертайтеся до своїх гаманців в будь-який час.\",\n  \"It's time to add some expense.<br><br>\\n\\tYou can add transaction with one string, e.g. \\\"99.93, best expense ever\\\".<br><br>\\n\\tPress Enter when tranasction description is ready.\\n\\t\": \"Настав час вказати витрати.<br><br>Можна описати транзакцію в один рядок, наприклад '99.99, краща трата в моєму житті'<br><br>Натисніть Enter, коли опис буде готовим\",\n  \"Check out updated transactions list\": \"Список транзакцій оновився\",\n  \"Check out expenses per day trends. Simple chart that gets updated every time you add another tranasction.\": \"Кожна транзакція відображається на графіку, наочно демонструючі ваші витрати\",\n  \"Don't forget to fill your profile, so you can sign in to DimeShift next time.\": \"Заповніть ваш профіль, щоб мати можливість увійти до нього наступного разу\",\n  \"Select file\": \"Вибрати файл\",\n  \"Uploading...\": \"Завантаження...\",\n  \"Do not import\": \"Не імпортувати\",\n  \"Expense amount\": \"Сума витрати\",\n  \"Preview\": \"Переглянути\",\n  \"Import\": \"Імпорт\",\n  \"Back\": \"Назад\",\n  \"Import .xls file\": \"Імпорт файла Excel\",\n  \"Step 1. Select .xls file to import\": \"Крок 1. Вибрати файл\",\n  \"Invalid xls file. Please select another one and try again\": \"Невірний формат файлу. Спробуйте інший файл\",\n  \"Please select your local .xls file\": \"Завантажте файл .xls з вашого комп’ютеру\",\n  \"Step 2. Select columns to import\": \"Крок 2. Вибрати сповпці для імпорту\",\n  \"more rows\": \"додаткових строк\",\n  \"Amount and Date fields are required\": \"Обов'язкові стовпці: сума і дата\",\n  \"Few more rows\": \"Ще кілька рядків\",\n  \"Do not import transaction, if it's already in database\": \"Не імпортувати транзакцію, якщо вона вже є в базі даних\",\n  \"Step 4. Import\": \"Крок 4. Імпорт\",\n  \"Finished\": \"Завершено\",\n  \"Import operation is finished\": \"Імпорт завершений\",\n  \"Check out you updated wallet\": \"Перегляньте ваш оновлений гаманець\",\n  \"Step 3. Preview and settings\": \"Крок 3. Перегляд\",\n  \"You don't have access to other users' wallets\": \"Інші користувачі не надавали вам доступ до своїх гаманців\",\n  \"Goals\": \"Цілі\",\n  \"Are you sure that you want to remove this plan?\": \"Ви впевнені, що хочете видалити цю ціль?\",\n  \"Plan name\": \"Назва цілі\",\n  \"Plan your expenses\": \"Планування витрат\",\n  \"Your plans\": \"Ваші цілі\",\n  \"View Report\": \"Звіт\",\n  \"Create new\": \"Додати нову\",\n  \"Basic settings\": \"Основні налаштування\",\n  \"Wallets to use for planning\": \"Гаманці для планування\",\n  \"Next\": \"Далі\",\n  \"Plan settings\": \"Налаштування цілі\",\n  \"Current balance is\": \"Поточний баланс\",\n  \"Calculate in different currency\": \"Перерахувати в іншій валюті\",\n  \"And on\": \"І на дату\",\n  \"Plan is to keep\": \"Баланс повинен становити\",\n  \"Set to\": \"Встановити у\",\n  \"So you\": \"Отже, ви\",\n  \"can spend up to\": \"можете витратити\",\n  \"have to get\": \"повинні додати\",\n  \"on the next day\": \"завтра\",\n  \"in next\": \"у наступні\",\n  \"days\": \"днів\",\n  \"per day\": \"у день\",\n  \"Confirm and save\": \"Підтвердити і зберегти\",\n  \"Goal Details\": \"Деталі цілі\",\n  \"From:\": \"Від:\",\n  \"To:\": \"До:\",\n  \"From\": \"Від\",\n  \"to\": \"до\",\n  \"Day by day report\": \"Звіт по днях\",\n  \"Total On Start\": \"Баланс на початку дня\",\n  \"Spent\": \"Витрати\",\n  \"Profit\": \"Дохід\",\n  \"Plan\": \"Ціль\",\n  \"Remove account\": \"Видалити аккаунт\",\n  \"Security code\": \"Код безпеки\",\n  \"Demo account will be removed as soon as you do log out from it.\": \"Демостраціонний аккаунт буде видалений після завершення поточної сесії\",\n  \"Please think twice. All account data will be lost.\": \"Впевнені? Усі дані будуть видалені безповоротно.\",\n  \"has been mailed to your email. Please fill this form to finish account removal.\": \"був відправлений на ваш email. Заповніть цю форму і завершіть процедуру видалення\",\n  \"Your account has been removed. We will miss you :(\": \"Аккаунт видалений :( Шкода, повертайтеся при першій нагоді, будемо чекати.\",\n  \"Invalid\": \"Невірній\",\n  \"There're no goals defined for this wallet\": \"Для цього гаманця не визначені цілі\",\n  \"Set Goal\": \"Встановити ціль\",\n  \"You\": \"Ви\",\n  \"today\": \"сьогодні\"\n}"
  },
  {
    "path": "data/mailtemplates/registration.template",
    "content": "Thank you for joining DimeShift\n\n<div style=\"background: #31b0d5; padding: 10px;\">\n\t<a href=\"%site_path%\" style=\"font-size: 20px; color: white; text-decoration: none;\">$ dimeshift</a>\n\t<div style=\"background: #ffffff; padding: 10px;\">\n\t\t\n\n\n\t\t<p>We appreciate your interest.</p>\n\t\t<p>- The DimeShift Team</p>\n\t</div>\n</div>"
  },
  {
    "path": "data/mailtemplates/remove_account.template",
    "content": "Remove your DimeShift account\n\n<div style=\"background: #31b0d5; padding: 10px;\">\n\t<a href=\"%site_path%\" style=\"font-size: 20px; color: white; text-decoration: none;\">$ dimeshift</a>\n\t<div style=\"background: #ffffff; padding: 10px;\">\n\t\t<p>Hi %login%,</p>\n\n\t\t<p>\n\t\t\tHere's your code to remove DimeShift account: %remove_account_code%\n\t\t</p>\n\n\t\t<p>&nbsp;</p>\n\t\t<p>- The DimeShift Team</p>\n\t</div>\n</div>"
  },
  {
    "path": "data/mailtemplates/restore_password.template",
    "content": "Restore your DimeShift password\n\n<div style=\"background: #31b0d5; padding: 10px;\">\n\t<a href=\"%site_path%\" style=\"font-size: 20px; color: white; text-decoration: none;\">$ dimeshift</a>\n\t<div style=\"background: #ffffff; padding: 10px;\">\n\t\t<p>Hi %login%,</p>\n\n\t\t<p>\n\t\t\tUse this link to restore your password: \n\t\t\t<a href=\"%site_path%user/updatepassword/%password_restore_code%/%password_restore_hash%\">%site_path%user/updatepassword/%password_restore_code%/%password_restore_hash%</a>\n\t\t</p>\n\n\t\t<p>&nbsp;</p>\n\t\t<p>- The DimeShift Team</p>\n\t</div>\n</div>"
  },
  {
    "path": "data/min/.gitignore",
    "content": "*\n!.gitignore"
  },
  {
    "path": "docs/api.md",
    "content": "FORMAT: 1A\nHOST: http://dimeshift.com/\n\n# DimeShift\n\n[DimeShift](http://dimeshift.com) ([github.com/jeka-kiselyov/dimeshift](https://github.com/jeka-kiselyov/dimeshift))\n\nDimeShift API is simple. You'll love it.\n\n# Authentication\n\nSet authCode HTTP header for authentication. Obtain authCode with Create a New User or Authenticate User methods.\n\n```\nrequest.setRequestHeader('authCode', '421a5bbd0624efebf12b2cbe5454b753');\n```\n"
  },
  {
    "path": "includes/api.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar fs = require('fs');\nvar path = require('path');\n\nvar getVisitorIp = function(req) {\n\tvar ipAddr = req.headers[\"x-forwarded-for\"];\n\tif (ipAddr) {\n\t\tvar list = ipAddr.split(\",\");\n\t\tipAddr = list[list.length - 1];\n\t} else {\n\t\tipAddr = req.connection.remoteAddress;\n\t}\n\n\treturn ipAddr;\n};\n\nexports.requireSignedIn = function(req, callback) {\n\tvar cookies = req.cookies;\n\tvar auth_code = cookies.logged_in_user || '';\n\n\tvar ip = getVisitorIp(req);\n\n\tif (auth_code === '')\n\t\tthrow new errors.HaveNoRightsError();\n\n\tdb.User.getByAuthCode({\n\t\tauth_code: auth_code,\n\t\tip: ip\n\t}).then(function(user) {\n\t\tif (typeof(callback) == 'function')\n\t\t\tcallback(user);\n\t}, function(err) {\n\t\tthrow new errors.HaveNoRightsError();\n\t});\n};\n\nexports.getVisitorIp = getVisitorIp;\n\nvar i18n_path = path.join(__dirname, '../data/i18n');\nvar i18n_cache = {};\nexports.geti18njson = function(code) {\n\tif (typeof(i18n_cache[code]) !== 'undefined')\n\t\treturn i18n_cache[code];\n\n\ti18n_cache[code] = fs.readFileSync(path.join(i18n_path, code + '.json'), 'utf8');\n\treturn i18n_cache[code];\n};\n\nvar getParam = function(req, name, def) {\n\tif (typeof(req.body) !== 'undefined' && typeof(req.body[name]) !== 'undefined')\n\t\treturn req.body[name];\n\telse if (typeof(req.params) !== 'undefined' && typeof(req.params[name]) !== 'undefined')\n\t\treturn req.params[name];\n\telse\n\t\treturn def;\n};\nexports.getParam = getParam;"
  },
  {
    "path": "includes/config.js",
    "content": "var rfr = require('rfr');\nvar env = process.env.NODE_ENV || 'development';\nvar config = rfr('config/config.json');\nvar net = require('net');\n\nif (typeof(config[env]) == 'undefined')\n\tconfig = config['development'];\nelse\n\tconfig = config[env];\n\nconfig['env'] = env;\nconfig['resources'] = rfr('config/resources.json');\nif (config['port'] === 0) {\n\tvar portrange = 45032\n\n\tfunction getPort(cb) {\n\t\tvar port = portrange\n\t\tportrange += 1\n\n\t\tvar server = net.createServer()\n\t\tserver.listen(port, function(err) {\n\t\t\tserver.once('close', function() {\n\t\t\t\tcb(port)\n\t\t\t})\n\t\t\tserver.close()\n\t\t})\n\t\tserver.on('error', function(err) {\n\t\t\tgetPort(cb)\n\t\t})\n\t}\n\n\tconfig['port'] = getPort;\n}\n\nmodule.exports = config;"
  },
  {
    "path": "includes/demo.js",
    "content": "var sequelize = require('sequelize');\n\nexports.fillDemoAccount = function(user, callback) {\n\treturn new sequelize.Promise(function(resolve, reject) {\n\t\tvar rand = function(min, max) {\n\t\t\treturn Math.floor(Math.random() * (max - min + 1) + min);\n\t\t}\n\n\t\tvar currency = 'USD';\n\n\t\tvar wallet_1_name = 'Sample Cash Wallet';\n\t\tvar wallet_2_name = 'Sample Bank Account Wallet';\n\n\t\tvar initial_1_description = 'Profit';\n\t\tvar initial_2_description = 'My freelance work';\n\n\t\tvar initial_1_amount = 4000 + rand(0, 50) * 100;\n\t\tvar initial_2_amount = 3000 + rand(0, 50) * 100;\n\n\t\tvar now = Date.now() / 1000 | 0;\n\n\t\tvar descriptions_1 = [\n\t\t\t'Vodka',\n\t\t\t'Beer',\n\t\t\t'Candies',\n\t\t\t'Date with Sammy',\n\t\t\t'Sausages',\n\t\t\t'Food',\n\t\t\t'Foods',\n\t\t\t'Eat out',\n\t\t\t'Mall',\n\t\t\t'Cinema',\n\t\t\t'Gas',\n\t\t\t'Wi-Fi access',\n\t\t\t'Wi-Fi',\n\t\t\t'Wine'\n\t\t];\n\n\t\tvar descriptions_2 = [\n\t\t\t'Hosting',\n\t\t\t'Custom Software',\n\t\t\t'Amazon S3',\n\t\t\t'Amazon AWS',\n\t\t\t'Wordpress template',\n\t\t\t'Translations',\n\t\t\t'Data Gathering',\n\t\t\t'CSS work',\n\t\t\t'Adwords',\n\t\t\t'PPC Campaign',\n\t\t\t'PPM Campaign',\n\t\t\t'Content writing',\n\t\t\t'iStock',\n\t\t\t'Shutterstock',\n\t\t\t'Gettyimages',\n\t\t\t'Photobank'\n\t\t];\n\n\t\tvar t_to_add_1 = [];\n\t\tvar total_1 = initial_1_amount;\n\n\t\tt_to_add_1.push({\n\t\t\tamount: initial_1_amount,\n\t\t\tdescription: initial_1_description,\n\t\t\tdatetime: now - 70 * 24 * 60 * 60\n\t\t});\n\t\tfor (var i = 29; i > 0; i--) {\n\t\t\tvar amount = rand(0, (initial_1_amount / 30)) + (rand(0, 100) * 0.01);\n\t\t\tvar description = descriptions_1[Math.floor(Math.random() * descriptions_1.length)];\n\t\t\tvar datetime = now - ((i - rand(0, 80) * 0.01) * 24 * 60 * 60);\n\n\t\t\ttotal_1 = total_1 - amount;\n\n\t\t\tt_to_add_1.push({\n\t\t\t\tamount: -amount,\n\t\t\t\tdescription: description,\n\t\t\t\tdatetime: datetime\n\t\t\t});\n\n\t\t\tif (total_1 < 300) {\n\t\t\t\tvar amount = rand(100, 1000);\n\t\t\t\tt_to_add_1.push({\n\t\t\t\t\tamount: amount,\n\t\t\t\t\tdescription: initial_1_description,\n\t\t\t\t\tdatetime: datetime + rand(10, 1000)\n\t\t\t\t});\n\t\t\t\ttotal_1 = total_1 + amount;\n\t\t\t}\n\t\t}\n\n\t\tvar t_to_add_2 = [];\n\t\tvar total_2 = initial_2_amount;\n\n\t\tt_to_add_2.push({\n\t\t\tamount: initial_2_amount,\n\t\t\tdescription: initial_2_description,\n\t\t\tdatetime: now - 50 * 24 * 60 * 60\n\t\t});\n\t\tfor (var i = 19; i > 0; i--) {\n\t\t\tvar amount = rand(10, 11 + (initial_2_amount / 20));\n\t\t\tvar description = descriptions_2[Math.floor(Math.random() * descriptions_2.length)];\n\t\t\tvar datetime = now - ((i - rand(0, 80) * 0.01) * 24 * 60 * 60);\n\n\t\t\tif (rand(0, 5) === 1)\n\t\t\t\tamount = amount - 0.01;\n\n\t\t\ttotal_2 = total_2 - amount;\n\n\t\t\tt_to_add_2.push({\n\t\t\t\tamount: -amount,\n\t\t\t\tdescription: description,\n\t\t\t\tdatetime: datetime\n\t\t\t});\n\n\t\t\tif (total_2 < 1000) {\n\t\t\t\tvar amount = rand(1, 10) * 100;\n\t\t\t\tt_to_add_2.push({\n\t\t\t\t\tamount: amount,\n\t\t\t\t\tdescription: initial_2_description,\n\t\t\t\t\tdatetime: datetime + rand(10, 1000)\n\t\t\t\t});\n\t\t\t\ttotal_2 = total_2 + amount;\n\t\t\t}\n\t\t}\n\n\t\tsequelize.Promise.map([wallet_1_name, wallet_2_name], function(name) {\n\t\t\treturn user.createWallet({\n\t\t\t\tname: name,\n\t\t\t\tcurrency: currency\n\t\t\t});\n\t\t}).spread(function(wallet_1, wallet_2) {\n\n\t\t\t/// @todo: do with raw query. Too slow now.\n\t\t\tsequelize.Promise.map(t_to_add_1, function(data) {\n\t\t\t\treturn wallet_1.insertTransaction({\n\t\t\t\t\tdescription: data.description,\n\t\t\t\t\tamount: data.amount,\n\t\t\t\t\tdatetime: data.datetime\n\t\t\t\t});\n\t\t\t}).then(function() {\n\t\t\t\tsequelize.Promise.map(t_to_add_2, function(data) {\n\t\t\t\t\treturn wallet_2.insertTransaction({\n\t\t\t\t\t\tdescription: data.description,\n\t\t\t\t\t\tamount: data.amount,\n\t\t\t\t\t\tdatetime: data.datetime\n\t\t\t\t\t});\n\t\t\t\t}).then(function() {\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t});\n\n\n}"
  },
  {
    "path": "includes/errors.js",
    "content": "var restify = require('restify');\nvar util = require('util');\nvar restifyErrors = require('restify-errors');\n\nfunction ValidationError(err) {\n  restifyErrors.RestError.call(this, {\n    restCode: 'ValidationError',\n    statusCode: 666,\n    message: [],\n    constructorOpt: ValidationError\n  });\n  this.name = 'ValidationError';\n  if (typeof(err.errors) !== 'undefined') {\n    for (var k in err.errors)\n      this.message.push(err.errors[k].message);\n  } else {\n    console.log(err);\n    this.message.push(\"\" + err);\n  }\n};\nutil.inherits(ValidationError, restifyErrors.RestError);\n\n\nfunction HaveNoRightsError() {\n  restifyErrors.RestError.call(this, {\n    restCode: 'HaveNoRightsError',\n    statusCode: 6969,\n    message: 'You have no rights to call this API method with this parameters. Try to check auth hash',\n    constructorOpt: HaveNoRightsError\n  });\n  this.name = 'HaveNoRightsError';\n};\nutil.inherits(HaveNoRightsError, restifyErrors.RestError);\n\nfunction NotFoundError() {\n  restifyErrors.RestError.call(this, {\n    restCode: 'NotFoundError',\n    statusCode: 404,\n    message: 'Nothing is found. Please check item id',\n    constructorOpt: NotFoundError\n  });\n  this.name = 'NotFoundError';\n};\nutil.inherits(NotFoundError, restifyErrors.RestError);\n\nexports.ValidationError = ValidationError;\nexports.HaveNoRightsError = HaveNoRightsError;\nexports.NotFoundError = NotFoundError;"
  },
  {
    "path": "includes/exchange.js",
    "content": "var path = require('path');\nvar oxr = require('open-exchange-rates');\nvar fx = require('money');\nvar fs = require('fs');\nvar rfr = require('rfr');\nvar config = rfr('includes/config.js');\n\nvar openExchangeRatesAppId = null;\nvar openExchangeRatesUpdateInterval = null;\n\nif (config.openexchangerates) {\n\topenExchangeRatesAppId = config.openexchangerates.app_id || '';\n\topenExchangeRatesUpdateInterval = config.openexchangerates.update_interval || 86400;\n\n\tif (config.openexchangerates.use_env_variable)\n\t\topenExchangeRatesAppId = process.env[openExchangeRatesAppId];\n}\n\nvar cache_filename = path.join(__dirname, '..', 'data/cache/exchangerates.json');\nvar cached = null;\n\nvar reloadRates = function(callback) {\n\tif (!openExchangeRatesAppId) {\n\t\tconsole.error(\"Please specify openexchangerates -> app_id in config.json to enable currency conversion\");\n\t\tif (typeof(callback) === 'function')\n\t\t\tcallback(cached);\n\t}\n\n\toxr.latest(function() {\n\t\tcached = {};\n\t\tcached.rates = oxr.rates;\n\t\tcached.base = oxr.base;\n\t\tfs.writeFile(cache_filename, JSON.stringify(cached, null, 2), function(){\n\t\t\tif (typeof(callback) === 'function')\n\t\t\t\tcallback(cached);\n\t\t});\n\t});\n};\n\n\nvar reloadIfNeeded = function(callback) {\n\tfs.stat(cache_filename, function(err, stats) {\n\t\tif (!stats || (stats.mtime.getTime() / 1000) < (Date.now() / 1000 | 0) - openExchangeRatesUpdateInterval) {\n\t\t\treloadRates(callback);\n\t\t}\n\t});\n};\n\nvar cached = {\n\trates: {},\n\tbase: 'USD'\n};\n\noxr.set({\n\tapp_id: openExchangeRatesAppId\n});\n\ntry {\n\tcached = JSON.parse(\"\" + fs.readFileSync(cache_filename, 'utf8'));\n} catch (e) {\n\tconsole.log(\"No cached exchange rates\\n\");\n}\n\nif (cached && typeof(cached.rates) !== 'undefined' && typeof(cached.base) !== 'undefined') {\n\tfx.rates = cached.rates;\n\tfx.base = cached.base;\n\n\treloadIfNeeded();\n} else {\n\treloadRates(function() {\n\t\tfx.rates = cached.rates;\n\t\tfx.base = cached.base;\n\t});\n}\n\nvar getRates = function() {\n\treloadIfNeeded();\n\treturn cached;\n};\n\nvar convert = function(value, from, to) {\n\tvar ret = value;\n\ttry {\n\t\tret = fx(value).from(from).to(to);\n\t} catch (e) {\n\t\tret = value;\n\t}\n\n\treturn ret;\n};\n\nexports.fx = fx;\nexports.convert = convert;\nexports.getRates = getRates;\n// fx(100).from('HKD').to('GBP'); // ~8.0424"
  },
  {
    "path": "includes/mailer.js",
    "content": "var nodemailer = require('nodemailer');\nvar rfr = require('rfr');\nvar fs = require('fs');\n\nvar config = rfr('includes/config.js');\n\nvar transporter = null;\nif (config && config.smtp) {\n\tif (config.smtp.use_env_variables) {\n\t\ttransporter = nodemailer.createTransport({\n\t\t\thost: process.env[config.smtp.host],\n\t\t\tport: process.env[config.smtp.port],\n\t\t\tauth: {\n\t\t\t\tuser: process.env[config.smtp.username],\n\t\t\t\tpass: process.env[config.smtp.password]\n\t\t\t}\n\t\t});\n\t} else {\n\t\ttransporter = nodemailer.createTransport({\n\t\t\thost: config.smtp.host,\n\t\t\tport: config.smtp.port,\n\t\t\tauth: {\n\t\t\t\tuser: config.smtp.username,\n\t\t\t\tpass: config.smtp.password\n\t\t\t}\n\t\t});\n\t}\n\n\tif (config.default_from_email)\n\t\ttransporter.default_from_email = config.default_from_email;\n}\n\nvar default_replaces = {};\nif (config.site_path)\n\tdefault_replaces.site_path = config.site_path;\n\nvar __mailtemplates_cache = {};\n\nvar sendMail = function(to, subject, html) {\n\tif (transporter !== null)\n\t\ttransporter.sendMail({\n\t\t\tfrom: transporter.default_from_email,\n\t\t\tto: to,\n\t\t\tsubject: subject,\n\t\t\thtml: html\n\t\t});\n}\n\nvar sendTemplate = function(templateName, to, replaces) {\n\tvar doSend = function() {\n\t\tvar subject = __mailtemplates_cache[templateName].subject;\n\t\tvar body = __mailtemplates_cache[templateName].body;\n\n\t\tfor (var k in replaces) {\n\t\t\tsubject = subject.split('%' + k + '%').join(replaces[k]);\n\t\t\tbody = body.split('%' + k + '%').join(replaces[k]);\n\t\t}\n\n\t\tfor (var k in default_replaces) {\n\t\t\tsubject = subject.split('%' + k + '%').join(default_replaces[k]);\n\t\t\tbody = body.split('%' + k + '%').join(default_replaces[k]);\n\t\t}\n\n\t\tsendMail(to, subject, body);\n\t};\n\n\tif (typeof(__mailtemplates_cache[templateName]) === 'undefined') {\n\t\tfs.readFile('./data/mailtemplates/' + templateName + '.template', function(err, data) {\n\t\t\tvar lines = (\"\" + data).split(\"\\n\");\n\t\t\tvar subject = lines.shift();\n\t\t\tvar body = lines.join(\"\\n\");\n\t\t\t__mailtemplates_cache[templateName] = {\n\t\t\t\tsubject: subject,\n\t\t\t\tbody: body\n\t\t\t};\n\n\t\t\tdoSend();\n\t\t});\n\t} else {\n\t\tdoSend();\n\t}\n}\n\n\nexports.transporter = transporter;\nexports.send = sendMail;\nexports.sendTemplate = sendTemplate;"
  },
  {
    "path": "includes/models/authentication.js",
    "content": "var crypto = require('crypto');\n\nmodule.exports = function(sequelize, DataTypes) {\n\tvar Authentication = sequelize.define('Authentication', {\n\t\tid: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tprimaryKey: true,\n\t\t\tautoIncrement: true\n\t\t},\n\t\tauth_code: DataTypes.STRING(100)\n\t}, {\n\t\ttimestamps: false,\n\t\tindexes: [{\n\t\t\tunique: true,\n\t\t\tfields: ['auth_code']\n\t\t}],\n\t\tfreezeTableName: true,\n\t\ttableName: 'authentications',\n\t\tclassMethods: {},\n\t\tinstanceMethods: {}\n\t});\n\n\treturn Authentication;\n};"
  },
  {
    "path": "includes/models/index.js",
    "content": "var fs = require('fs');\nvar path = require('path');\nvar Sequelize = require('sequelize');\nvar rfr = require('rfr');\nvar basename = path.basename(module.filename);\nvar config = rfr('includes/config.js');\nvar db = {};\n\nvar options = {\n  logging: false\n};\n\nif (config.database.use_env_variable) {\n  var sequelize = new Sequelize(process.env[config.database.use_env_variable], options);\n} else {\n  options.host = config.database.host || null;\n  options.dialect = config.database.dialect || null;\n  options.storage = config.database.storage || null;\n  if (options.storage)\n    options.storage = path.join(rfr.root, options.storage);\n\n  if (config.database.dialectModulePath)\n    options.dialectModulePath = path.join(rfr.root, config.database.dialectModulePath);\n\n  var sequelize = new Sequelize(config.database.database, config.database.username, config.database.password, options);\n}\n\nfs\n  .readdirSync(__dirname)\n  .filter(function(file) {\n    return (file.indexOf('.') !== 0) && (file !== basename);\n  })\n  .forEach(function(file) {\n    if (file.slice(-3) !== '.js') return;\n    var model = sequelize['import'](path.join(__dirname, file));\n    db[model.name] = model;\n  });\n\nObject.keys(db).forEach(function(modelName) {\n  if (db[modelName].associate) {\n    db[modelName].associate(db);\n  }\n});\n\nsequelize.db = db;\ndb.sequelize = sequelize;\ndb.Sequelize = Sequelize;\n\n//// Foreign keys\ndb['Authentication'].belongsTo(db['User'], {\n  foreignKey: 'user_id',\n  constraints: false\n});\ndb['User'].hasMany(db['Authentication'], {\n  foreignKey: 'user_id',\n  constraints: false,\n  onDelete: 'CASCADE'\n});\n\ndb['Wallet'].belongsTo(db['User'], {\n  foreignKey: 'user_id',\n  constraints: false\n});\ndb['User'].hasMany(db['Wallet'], {\n  foreignKey: 'user_id',\n  constraints: false,\n  onDelete: 'CASCADE'\n});\n\ndb['Transaction'].belongsTo(db['User'], {\n  foreignKey: 'user_id',\n  constraints: false\n});\ndb['Transaction'].belongsTo(db['Wallet'], {\n  foreignKey: 'wallet_id',\n  constraints: false\n});\n\ndb['User'].hasMany(db['Transaction'], {\n  foreignKey: 'user_id',\n  constraints: false\n});\ndb['Wallet'].hasMany(db['Transaction'], {\n  foreignKey: 'wallet_id',\n  constraints: false,\n  onDelete: 'CASCADE'\n});\n\ndb['WalletAccess'].belongsTo(db['Wallet'], {\n  foreignKey: 'wallet_id',\n  constraints: false\n});\ndb['WalletAccess'].belongsTo(db['User'], {\n  as: 'OriginalUser',\n  foreignKey: 'original_user_id'\n});\ndb['WalletAccess'].belongsTo(db['User'], {\n  as: 'ToUser',\n  foreignKey: 'to_user_id'\n});\n\ndb['Wallet'].hasMany(db['WalletAccess'], {\n  foreignKey: 'wallet_id',\n  constraints: false,\n  onDelete: 'CASCADE'\n});\ndb['User'].hasMany(db['WalletAccess'], {\n  foreignKey: 'to_user_id',\n  constraints: false,\n  onDelete: 'SET NULL'\n});\n\n\ndb['Plan'].belongsTo(db['User'], {\n  foreignKey: 'user_id',\n  constraints: false\n});\ndb['User'].hasMany(db['Plan'], {\n  foreignKey: 'user_id',\n  constraints: false,\n  onDelete: 'CASCADE'\n});\ndb['Plan'].belongsToMany(db['Wallet'], {\n  as: 'wallets',\n  through: 'plan_wallets',\n  foreignKey: 'plan_id',\n  otherKey: 'wallet_id'\n});\ndb['Wallet'].belongsToMany(db['Plan'], {\n  as: 'Plans',\n  through: 'plan_wallets',\n  foreignKey: 'wallet_id',\n  otherKey: 'plan_id'\n});\n\nmodule.exports = db;"
  },
  {
    "path": "includes/models/plan.js",
    "content": "var rfr = require('rfr');\nvar exchange = rfr('includes/exchange.js');\n\nmodule.exports = function(sequelize, DataTypes) {\n\tvar Plan = sequelize.define('Plan', {\n\t\tid: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tprimaryKey: true,\n\t\t\tautoIncrement: true\n\t\t},\n\t\tname: DataTypes.STRING(255),\n\t\tgoal_balance: {\n\t\t\ttype: DataTypes.FLOAT(),\n\t\t\tdefaultValue: 0\n\t\t},\n\t\tgoal_currency: {\n\t\t\ttype: DataTypes.STRING(10),\n\t\t\tdefaultValue: 'USD'\n\t\t},\n\t\tgoal_datetime: {\n\t\t\ttype: DataTypes.INTEGER\n\t\t},\n\t\tstart_balance: {\n\t\t\ttype: DataTypes.FLOAT(),\n\t\t\tdefaultValue: 0\n\t\t},\n\t\tstart_currency: {\n\t\t\ttype: DataTypes.STRING(10),\n\t\t\tdefaultValue: 'USD'\n\t\t},\n\t\tstart_datetime: {\n\t\t\ttype: DataTypes.INTEGER\n\t\t},\n\t\tend_balance: {\n\t\t\ttype: DataTypes.FLOAT(),\n\t\t\tdefaultValue: 0\n\t\t},\n\t\tstatus: {\n\t\t\ttype: DataTypes.ENUM('active', 'finished'),\n\t\t\tdefaultValue: 'active',\n\t\t\tfield: \"status\",\n\t\t\tvalidate: {\n\t\t\t\tisIn: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t['active', 'finished']\n\t\t\t\t\t],\n\t\t\t\t\tmsg: \"Invalid plan status\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, {\n\t\ttimestamps: false,\n\t\tindexes: [],\n\t\tfreezeTableName: true,\n\t\ttableName: 'plans',\n\t\tclassMethods: {},\n\t\tinstanceMethods: {\n\t\t\tcheckIfFinished: function() {\n\t\t\t\tvar plan = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tif (plan.status == 'finished') {\n\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tvar currentDateTime = (Date.now() / 1000 | 0);\n\t\t\t\t\tif (plan.goal_datetime <= currentDateTime) {\n\t\t\t\t\t\tplan.status = 'finished';\n\t\t\t\t\t\tplan.getCurrentTotal().then(function(total) {\n\t\t\t\t\t\t\tplan.end_balance = total;\n\t\t\t\t\t\t\treturn plan.save();\n\t\t\t\t\t\t}).then(function(plan) {\n\t\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tupdateWalletsIds: function(wallets_ids) {\n\t\t\t\tvar plan = this;\n\t\t\t\t/// remove duplicate elements\n\t\t\t\twallets_ids = wallets_ids.reduce(function(p, c) {\n\t\t\t\t\tif (p.indexOf(c) < 0) p.push(c);\n\t\t\t\t\treturn p;\n\t\t\t\t}, []);\n\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\t/// need to check if all wallets are user's wallets\n\t\t\t\t\tsequelize.db.Wallet.findAll({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t$in: wallets_ids\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(function(wallets) {\n\t\t\t\t\t\tvar goodWalletsCount = 0;\n\t\t\t\t\t\tfor (var k in wallets_ids) {\n\t\t\t\t\t\t\tfor (var j in wallets)\n\t\t\t\t\t\t\t\tif (wallets[j].id == wallets_ids[k] && wallets[j].user_id == plan.user_id)\n\t\t\t\t\t\t\t\t\tgoodWalletsCount++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (goodWalletsCount != wallets_ids.length)\n\t\t\t\t\t\t\tthrow \"Invalid wallets ids\";\n\n\t\t\t\t\t\tplan.setWallets(wallets_ids).then(function() {\n\t\t\t\t\t\t\tplan.save().then(function(plan) {\n\t\t\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetCurrentTotal: function() {\n\t\t\t\tvar plan = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tplan.getWallets().then(function(wallets) {\n\t\t\t\t\t\tvar balance = 0;\n\t\t\t\t\t\tvar walletTotal = 0;\n\n\t\t\t\t\t\tfor (var k in wallets) {\n\t\t\t\t\t\t\twalletTotal = exchange.convert(wallets[k].total, wallets[k].currency, plan.goal_currency);\n\t\t\t\t\t\t\tbalance += walletTotal;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve(balance);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsetDefaultValues: function() {\n\t\t\t\tvar plan = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tif (!plan.start_datetime)\n\t\t\t\t\t\tplan.start_datetime = Date.now() / 1000 | 0;\n\t\t\t\t\tif (!plan.status)\n\t\t\t\t\t\tplan.status = 'active';\n\t\t\t\t\tif (!plan.name)\n\t\t\t\t\t\tplan.name = 'Undefined';\n\t\t\t\t\tif (!plan.start_currency && plan.goal_currency)\n\t\t\t\t\t\tplan.start_currency = plan.goal_currency;\n\t\t\t\t\tif (!plan.goal_currency && plan.start_currency)\n\t\t\t\t\t\tplan.goal_currency = plan.start_currency;\n\t\t\t\t\tif (!plan.start_balance && !plan.isNewRecord) {\n\t\t\t\t\t\t/// get start_balance from wallets\n\t\t\t\t\t\tplan.getWallets().then(function(wallets) {\n\t\t\t\t\t\t\tvar start_balance = 0;\n\t\t\t\t\t\t\t// @todo: use exchange rates to recalculate\n\t\t\t\t\t\t\tfor (var k in wallets)\n\t\t\t\t\t\t\t\tstart_balance += wallets[k].total;\n\t\t\t\t\t\t\tplan.start_balance = start_balance;\n\n\t\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t}\n\t});\n\n\treturn Plan;\n};"
  },
  {
    "path": "includes/models/transaction.js",
    "content": "var crypto = require('crypto');\n\nmodule.exports = function(sequelize, DataTypes) {\n\tvar Transaction = sequelize.define('Transaction', {\n\t\tid: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tprimaryKey: true,\n\t\t\tautoIncrement: true\n\t\t},\n\t\tdescription: DataTypes.STRING(255),\n\t\ttype: {\n\t\t\ttype: DataTypes.ENUM('profit', 'expense'),\n\t\t\tdefaultValue: 'expense',\n\t\t\tvalidate: {\n\t\t\t\tisIn: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t['profit', 'expense']\n\t\t\t\t\t],\n\t\t\t\t\tmsg: \"Invalid transaction type\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tsubtype: {\n\t\t\ttype: DataTypes.ENUM('setup', 'confirmed', 'planned'),\n\t\t\tdefaultValue: 'confirmed',\n\t\t\tvalidate: {\n\t\t\t\tisIn: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t['setup', 'confirmed', 'planned']\n\t\t\t\t\t],\n\t\t\t\t\tmsg: \"Invalid transaction subtype\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tamount: {\n\t\t\ttype: DataTypes.FLOAT(),\n\t\t\tdefaultValue: 0\n\t\t},\n\t\tabs_amount: {\n\t\t\ttype: DataTypes.FLOAT(),\n\t\t\tdefaultValue: 0\n\t\t},\n\t\tdatetime: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tfield: \"datetime\"\n\t\t}\n\t}, {\n\t\ttimestamps: false,\n\t\tindexes: [\n\n\t\t],\n\t\tfreezeTableName: true,\n\t\ttableName: 'transactions',\n\t\tclassMethods: {},\n\t\tinstanceMethods: {\n\t\t\tdeleteAndCheckWallet: function() {\n\n\t\t\t\tvar setUpDiff = -this.amount;\n\t\t\t\tvar wallet_id = this.wallet_id;\n\t\t\t\tvar this_datetime = this.datetime;\n\t\t\t\tvar this_id = this.id;\n\n\t\t\t\tvar that = this;\n\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tvar setUpTransaction = null;\n\n\t\t\t\t\tsequelize.db.Transaction.findOne({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\twallet_id: wallet_id,\n\t\t\t\t\t\t\tsubtype: 'setup',\n\t\t\t\t\t\t\tdatetime: {\n\t\t\t\t\t\t\t\t$gte: this_datetime\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t$ne: this_id\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\torder: 'datetime ASC'\n\t\t\t\t\t}).then(function(setupTransaction) {\n\t\t\t\t\t\tif (setupTransaction) {\n\t\t\t\t\t\t\tsetupTransaction.amount -= setUpDiff;\n\t\t\t\t\t\t\tsetupTransaction.save().then(function(setupTransaction) {\n\t\t\t\t\t\t\t\tthat.destroy();\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsequelize.query(\"UPDATE wallets SET total = total + :diff WHERE id = :id\", {\n\t\t\t\t\t\t\t\treplacements: {\n\t\t\t\t\t\t\t\t\tdiff: setUpDiff,\n\t\t\t\t\t\t\t\t\tid: wallet_id\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}).then(function() {\n\t\t\t\t\t\t\t\tthat.destroy();\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}, function(err) {\n\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\treturn Transaction;\n};"
  },
  {
    "path": "includes/models/user.js",
    "content": "var crypto = require('crypto');\nvar rfr = require('rfr');\nvar demo = rfr('includes/demo.js');\nvar mailer = rfr('includes/mailer.js');\nvar moment = require('moment');\n\nmodule.exports = function(sequelize, DataTypes) {\n\tvar User = sequelize.define('User', {\n\t\tid: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tprimaryKey: true,\n\t\t\tautoIncrement: true\n\t\t},\n\t\temail: {\n\t\t\ttype: DataTypes.STRING(255),\n\t\t\tvalidate: {\n\t\t\t\tisEmail: {\n\t\t\t\t\tmsg: \"Invalid email\"\n\t\t\t\t},\n\t\t\t\tisUnique: function(value, next) {\n\t\t\t\t\tvar that = this;\n\t\t\t\t\tsequelize.db.User.findOne({\n\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\temail: value,\n\t\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t\t$ne: this.id\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattributes: ['id']\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(function(foundUser) {\n\t\t\t\t\t\t\tif (foundUser)\n\t\t\t\t\t\t\t\tthrow new Error('Email is already in use');\n\t\t\t\t\t\t\tnext();\n\t\t\t\t\t\t}).catch(function(err) {\n\t\t\t\t\t\t\tthrow new Error('Email is already in use');\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\ttype: {\n\t\t\ttype: DataTypes.STRING(20),\n\t\t\tdefaultValue: 'default',\n\t\t\tvalidate: {\n\t\t\t\tisIn: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t['default', 'facebook']\n\t\t\t\t\t],\n\t\t\t\t\tmsg: \"Invalid user type\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tpassword: DataTypes.STRING(50),\n\t\tlogin: {\n\t\t\ttype: DataTypes.STRING(255),\n\t\t\tvalidate: {\n\t\t\t\tisUnique: function(value, next) {\n\t\t\t\t\tvar that = this;\n\t\t\t\t\tsequelize.db.User.findOne({\n\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\tlogin: value,\n\t\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t\t$ne: this.id\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattributes: ['id']\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(function(foundUser) {\n\t\t\t\t\t\t\tif (foundUser)\n\t\t\t\t\t\t\t\tthrow new Error('This username is already in use');\n\t\t\t\t\t\t\tnext();\n\t\t\t\t\t\t}).catch(function(err) {\n\t\t\t\t\t\t\tthrow new Error('This username is already in use');\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tis_demo: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tdefaultValue: 0,\n\t\t\tallowNull: false\n\t\t},\n\t\tis_admin: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tdefaultValue: 0,\n\t\t\tallowNull: false\n\t\t},\n\t\tregistration_date: DataTypes.INTEGER,\n\t\tactivity_date: DataTypes.INTEGER,\n\t\tregistration_ip: DataTypes.STRING(20),\n\t\tactivity_ip: DataTypes.STRING(20),\n\t\tconfirmation_code: DataTypes.STRING(255),\n\t\tremove_account_code: DataTypes.STRING(255),\n\t\tpassword_restore_code: DataTypes.STRING(255),\n\t\tis_banned: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tdefaultValue: 0,\n\t\t\tallowNull: false\n\t\t}\n\t}, {\n\t\ttimestamps: false,\n\t\tfreezeTableName: true,\n\t\ttableName: 'users',\n\t\tclassMethods: {\n\t\t\thashPassword: function(password) {\n\t\t\t\treturn crypto.createHash('md5').update(password + 'password_salt').digest(\"hex\");\n\t\t\t},\n\t\t\tregister: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar type = params.type || 'default';\n\t\t\t\tvar login = params.login || '';\n\t\t\t\tvar password = params.password || '';\n\t\t\t\tvar email = params.email || '';\n\t\t\t\tvar ip = params.ip || null;\n\t\t\t\tvar is_demo = 0;\n\n\t\t\t\tif (email == 'demo@demo.com') {\n\t\t\t\t\temail = 'email' + Math.random() + '@example.com';\n\t\t\t\t\tlogin = 'login' + Math.random();\n\t\t\t\t\tpassword = 'password' + Math.random();\n\t\t\t\t\ttype = 'default';\n\t\t\t\t\tis_demo = 1;\n\t\t\t\t}\n\n\t\t\t\tpassword = this.hashPassword(password);\n\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tvar user = sequelize.db.User.build({\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\temail: email,\n\t\t\t\t\t\tlogin: login,\n\t\t\t\t\t\tpassword: password\n\t\t\t\t\t});\n\t\t\t\t\tuser.registration_date = Date.now() / 1000 | 0;\n\t\t\t\t\tuser.registration_ip = ip;\n\t\t\t\t\tuser.is_demo = is_demo;\n\n\t\t\t\t\tuser.save().then(function(user) {\n\t\t\t\t\t\tif (is_demo) {\n\t\t\t\t\t\t\tdemo.fillDemoAccount(user).then(function() {\n\t\t\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsequelize.db.WalletAccess.checkAccessForNewUser(user);\n\t\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, function(err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t},\n\t\t\tregisterDemo: function(params, callback) {\n\n\t\t\t},\n\t\t\tremoveOldDemoAccounts: function() {\n\t\t\t\tvar maxTimestamp = (Date.now() / 1000 | 0) - 2 * 24 * 60 * 60;\n\t\t\t\treturn sequelize.query(\"DELETE FROM users WHERE is_demo = 1 AND registration_date < :max_timestamp\", {\n\t\t\t\t\treplacements: {\n\t\t\t\t\t\tmax_timestamp: maxTimestamp\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t},\n\t\t\tupdatePassword: function(code, hash, password) {\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tif (password.length < 6)\n\t\t\t\t\t\treturn reject('Password is too short');\n\n\t\t\t\t\tsequelize.db.User.findOne({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\tpassword_restore_code: code\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(function(user) {\n\t\t\t\t\t\tif (!user)\n\t\t\t\t\t\t\treturn reject('Invalid reset password code');\n\t\t\t\t\t\tvar restore_password_hash = sequelize.db.User.hashPassword(user.id + user.password_restore_code);\n\t\t\t\t\t\tif (hash != restore_password_hash)\n\t\t\t\t\t\t\treturn reject('Invalid reset password code');\n\n\t\t\t\t\t\tpassword = sequelize.db.User.hashPassword(password);\n\t\t\t\t\t\tuser.password = password;\n\t\t\t\t\t\treturn user.save();\n\t\t\t\t\t}).then(function(user) {\n\t\t\t\t\t\tresolve(user);\n\t\t\t\t\t}, function(err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tresetPassword: function(email) {\n\t\t\t\tvar restore_password_hash = '';\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tsequelize.db.User.findOne({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\temail: email\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(function(user) {\n\t\t\t\t\t\tif (!user)\n\t\t\t\t\t\t\treturn reject('Can not find this email in our database');\n\t\t\t\t\t\tuser.password_restore_code = sequelize.db.User.hashPassword(\"\" + user.id + Math.random());\n\t\t\t\t\t\trestore_password_hash = sequelize.db.User.hashPassword(user.id + user.password_restore_code);\n\t\t\t\t\t\treturn user.save();\n\t\t\t\t\t}).then(function(user) {\n\t\t\t\t\t\tmailer.sendTemplate('restore_password', user.email, {\n\t\t\t\t\t\t\tlogin: user.login,\n\t\t\t\t\t\t\tpassword_restore_code: user.password_restore_code,\n\t\t\t\t\t\t\tpassword_restore_hash: restore_password_hash\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn resolve(user);\n\t\t\t\t\t}).catch(function(e) {\n\t\t\t\t\t\treturn reject('Can not find this email in our database');\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetByAuthCode: function(params, callback) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar ip = params.ip || null;\n\t\t\t\tvar auth_code = params.auth_code || null;\n\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tsequelize.db.Authentication.findOne({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\tauth_code: auth_code\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(function(authentication) {\n\t\t\t\t\t\tif (!authentication)\n\t\t\t\t\t\t\treturn reject('Invalid auth code');\n\t\t\t\t\t\treturn authentication.getUser();\n\t\t\t\t\t}).then(function(user) {\n\t\t\t\t\t\tuser.activity_ip = ip;\n\t\t\t\t\t\tuser.activity_date = Date.now() / 1000 | 0;\n\t\t\t\t\t\tuser.save();\n\t\t\t\t\t\treturn resolve(user);\n\t\t\t\t\t}).catch(function(e) {\n\t\t\t\t\t\treturn reject('Invalid auth code');\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsignIn: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar username = params.username || '';\n\t\t\t\tvar password = params.password || '';\n\n\t\t\t\tpassword = this.hashPassword(password);\n\n\t\t\t\treturn sequelize.db.User.findOne({\n\t\t\t\t\twhere: {\n\t\t\t\t\t\t$or: [{\n\t\t\t\t\t\t\tlogin: username\n\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\temail: username\n\t\t\t\t\t\t}],\n\t\t\t\t\t\tpassword: password\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tinstanceMethods: {\n\t\t\tauth: function(params) {\n\t\t\t\tvar md5sum = crypto.createHash('md5');\n\t\t\t\tvar hash = '' + md5sum.update('' + Math.random() + this.id).digest('hex');\n\t\t\t\treturn this.createAuthentication({\n\t\t\t\t\tauth_code: hash\n\t\t\t\t});\n\t\t\t},\n\t\t\tsignOut: function() {\n\t\t\t\treturn sequelize.query(\"SELECT * FROM `authentications` WHERE user_id = :user_id\", {\n\t\t\t\t\treplacements: {\n\t\t\t\t\t\tuser_id: this.id\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tremoveAccount: function() {\n\t\t\t\tvar user = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tuser.remove_account_code = sequelize.db.User.hashPassword(\"del\" + user.id + Math.random());\n\t\t\t\t\tuser.save().then(function(user) {\n\t\t\t\t\t\tmailer.sendTemplate('remove_account', user.email, {\n\t\t\t\t\t\t\tlogin: user.login,\n\t\t\t\t\t\t\tremove_account_code: user.remove_account_code\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn resolve(user);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tremoveAccountConfirm: function(code) {\n\t\t\t\tvar user = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tif (user.remove_account_code && user.remove_account_code == code)\n\t\t\t\t\t\treturn user.destroy().then(function() {\n\t\t\t\t\t\t\treturn resolve(true);\n\t\t\t\t\t\t});\n\t\t\t\t\telse\n\t\t\t\t\t\treturn resolve(false);\n\t\t\t\t});\n\t\t\t},\n\t\t\tfillProfile: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar login = params.login || '';\n\t\t\t\tvar email = params.email || '';\n\t\t\t\tvar password = params.password || '';\n\t\t\t\tvar ip = params.ip || null;\n\n\t\t\t\tpassword = sequelize.db.User.hashPassword(password);\n\n\t\t\t\tif (this.is_demo) {\n\t\t\t\t\tthis.login = login;\n\t\t\t\t\tthis.email = email;\n\t\t\t\t\tthis.password = password;\n\t\t\t\t\tthis.is_demo = 0;\n\t\t\t\t\tthis.registration_ip = ip;\n\n\t\t\t\t\tsequelize.db.WalletAccess.checkAccessForNewUser(this);\n\t\t\t\t} else\n\t\t\t\t\treturn false;\n\n\t\t\t\treturn this.save();\n\t\t\t},\n\t\t\tupdate: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar password = params.password || '';\n\t\t\t\tvar current_password = params.current_password || '';\n\n\t\t\t\tcurrent_password = sequelize.db.User.hashPassword(current_password);\n\t\t\t\tif (current_password == this.password) {\n\t\t\t\t\tpassword = sequelize.db.User.hashPassword(password);\n\t\t\t\t\tthis.password = password;\n\t\t\t\t} else {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn this.save();\n\t\t\t},\n\t\t\tinsertWallet: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar name = params.name || '';\n\t\t\t\tvar currency = params.currency || 'USD';\n\n\t\t\t\treturn this.createWallet({\n\t\t\t\t\tname: name,\n\t\t\t\t\tcurrency: currency\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetSharedWallets: function() {\n\t\t\t\treturn sequelize.query(\"SELECT wallets.* FROM wallets JOIN wallet_accesses ON wallet_accesses.wallet_id = wallets.id WHERE wallet_accesses.to_user_id = :user_id\", {\n\t\t\t\t\treplacements: {\n\t\t\t\t\t\tuser_id: this.id\n\t\t\t\t\t},\n\t\t\t\t\tmodel: sequelize.db.Wallet\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetUserPlans: function(id) {\n\t\t\t\tvar where = {\n\t\t\t\t\t'user_id': this.id\n\t\t\t\t};\n\t\t\t\tif (typeof(id) !== 'undefined')\n\t\t\t\t\twhere['id'] = id;\n\n\t\t\t\treturn sequelize.db.Plan.findAll({\n\t\t\t\t\tattributes: ['id', 'user_id', 'name', 'goal_balance', 'goal_currency', 'goal_datetime', 'start_balance', 'start_currency', 'start_datetime', 'end_balance', 'status'],\n\t\t\t\t\twhere: where,\n\t\t\t\t\tinclude: [{\n\t\t\t\t\t\tmodel: sequelize.db.Wallet,\n\t\t\t\t\t\tas: 'wallets',\n\t\t\t\t\t\tattributes: ['id', 'name', 'total'],\n\t\t\t\t\t\tthrough: {\n\t\t\t\t\t\t\tattributes: []\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetUserPlan: function(id) {\n\t\t\t\tvar user = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tuser.getUserPlans(id).then(function(plans) {\n\t\t\t\t\t\tif (plans.length > 0)\n\t\t\t\t\t\t\tresolve(plans[0]);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\taddUserPlan: function(data) {\n\t\t\t\tvar wallets_ids = data.wallets || [];\n\t\t\t\tvar user = this;\n\n\t\t\t\t/// remove duplicate elements\n\t\t\t\twallets_ids = wallets_ids.reduce(function(p, c) {\n\t\t\t\t\tif (p.indexOf(c) < 0) p.push(c);\n\t\t\t\t\treturn p;\n\t\t\t\t}, []);\n\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\t/// need to check if all wallets are user's wallets\n\t\t\t\t\tsequelize.db.Wallet.findAll({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t$in: wallets_ids\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(function(wallets) {\n\t\t\t\t\t\tvar goodWalletsCount = 0;\n\t\t\t\t\t\tfor (var k in wallets_ids) {\n\t\t\t\t\t\t\tfor (var j in wallets)\n\t\t\t\t\t\t\t\tif (wallets[j].id == wallets_ids[k] && wallets[j].user_id == user.id)\n\t\t\t\t\t\t\t\t\tgoodWalletsCount++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (goodWalletsCount != wallets_ids.length)\n\t\t\t\t\t\t\tthrow \"Invalid wallets ids\";\n\n\t\t\t\t\t\tuser.createPlan(data).then(function(plan) {\n\t\t\t\t\t\t\tplan.setWallets(wallets_ids).then(function() {\n\t\t\t\t\t\t\t\treturn plan.setDefaultValues();\n\t\t\t\t\t\t\t}).then(function() {\n\t\t\t\t\t\t\t\treturn plan.save();\n\t\t\t\t\t\t\t}).then(function(plan) {\n\t\t\t\t\t\t\t\tresolve(plan);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetWalletIfHasAccess: function(wallet_id) {\n\t\t\t\treturn sequelize.db.WalletAccess.getWalletIfHasAccess(this, wallet_id);\n\t\t\t},\n\t\t\tgetStats: function(params) {\n\t\t\t\tvar user = this;\n\t\t\t\tvar period = params.period || 'week';\n\t\t\t\tif (period != 'week' && period != 'month' && period != 'year')\n\t\t\t\t\tperiod = 'week';\n\t\t\t\tvar utcOffset = params.utcOffset || 0;\n\t\t\t\tvar wallet_id = params.wallet_id || null;\n\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tvar now = moment();\n\t\t\t\t\tnow.utcOffset(utcOffset);\n\n\t\t\t\t\tvar retPeriods = [];\n\t\t\t\t\tvar walletsCurrencies = {};\n\n\t\t\t\t\tvar lowestTimestamp = now.unix();\n\t\t\t\t\tvar highestTimestamp = now.unix();\n\n\t\t\t\t\tvar count = 7; \n\t\t\t\t\tif (period == 'month')\n\t\t\t\t\t\tcount = 31;\n\t\t\t\t\telse if (period == 'year')\n\t\t\t\t\t\tcount = 12;\n\n\t\t\t\t\tfor (var i = 0; i < count; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar newPeriod = {\n\t\t\t\t\t\t\tmonth: now.month() + 1, \n\t\t\t\t\t\t\tyear: now.year(),\n\t\t\t\t\t\t\tutcOffset: now.format('Z')\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (period == 'year')\n\t\t\t\t\t\t\tnow.startOf('month');\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tnewPeriod.day = now.date();\n\t\t\t\t\t\t\tnow.startOf('day');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewPeriod.fromTimestamp = now.unix(); // >=\n\t\t\t\t\t\tif (newPeriod.fromTimestamp < lowestTimestamp)\n\t\t\t\t\t\t\tlowestTimestamp = newPeriod.fromTimestamp;\n\t\t\t\t\t\tif (period == 'year')\n\t\t\t\t\t\t\tnow.endOf('month');\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnow.endOf('day');\n\t\t\t\t\t\tnewPeriod.toTimestamp = now.unix(); // <=\n\t\t\t\t\t\tif (newPeriod.toTimestamp > highestTimestamp)\n\t\t\t\t\t\t\thighestTimestamp = newPeriod.toTimestamp;\n\n\t\t\t\t\t\tif (period == 'year')\n\t\t\t\t\t\t\tnow.subtract(1, 'months');\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnow.subtract(1, 'days');\n\n\t\t\t\t\t\tretPeriods.push(newPeriod);\n\t\t\t\t\t}\n\n\n\t\t\t\t\tuser.getWallets().then(function(wallets){\n\t\t\t\t\t\tvar foundWallet = false;\n\t\t\t\t\t\tif (wallets) {\n\t\t\t\t\t\t\tfor (var k in wallets) {\n\t\t\t\t\t\t\t\tif ((wallet_id && wallets[k].id == wallet_id) || !wallet_id)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twalletsCurrencies[wallets[k].id] = wallets[k].currency;\n\t\t\t\t\t\t\t\t\tfoundWallet = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!foundWallet)\n\t\t\t\t\t\t\treturn resolve(null);\n\n\t\t\t\t\t\tvar allCurrencies = [];\n\t\t\t\t\t\tfor (k in walletsCurrencies)\n\t\t\t\t\t\t\tif (allCurrencies.indexOf(walletsCurrencies[k]) == -1)\n\t\t\t\t\t\t\t\tallCurrencies.push(walletsCurrencies[k]);\n\n\t\t\t\t\t\tfor (k in retPeriods) {\n\t\t\t\t\t\t\tretPeriods[k].stats = {};\n\t\t\t\t\t\t\tfor (var ak in allCurrencies)\n\t\t\t\t\t\t\t\tretPeriods[k].stats[allCurrencies[ak]] = {\n\t\t\t\t\t\t\t\t\texpense: 0,\n\t\t\t\t\t\t\t\t\tprofit: 0\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tvar where = {\n\t\t\t\t\t\t\t\tuser_id: user.id,\n\t\t\t\t\t\t\t\tdatetime: {\n\t\t\t\t\t\t\t\t\t$lte: highestTimestamp,\n\t\t\t\t\t\t\t\t\t$gte: lowestTimestamp\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\tif (wallet_id > 0)\n\t\t\t\t\t\t\twhere.wallet_id = wallet_id;\n\n\t\t\t\t\t\tsequelize.db.Transaction.findAll({\n\t\t\t\t\t\t\twhere: where\n\t\t\t\t\t\t}).then(function(transactions){\n\t\t\t\t\t\t\tif (transactions)\n\t\t\t\t\t\t\tfor (var kt in transactions)\n\t\t\t\t\t\t\tfor (var kp in retPeriods)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (transactions[kt].datetime >= retPeriods[kp].fromTimestamp && transactions[kt].datetime <= retPeriods[kp].toTimestamp)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tvar currency = walletsCurrencies[transactions[kt].wallet_id];\n\t\t\t\t\t\t\t\t\tif (transactions[kt].amount < 0)\n\t\t\t\t\t\t\t\t\t\tretPeriods[kp].stats[currency].expense += Math.abs(transactions[kt].amount);\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tretPeriods[kp].stats[currency].profit += Math.abs(transactions[kt].amount);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (var k in retPeriods)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdelete retPeriods[k].fromTimestamp;\n\t\t\t\t\t\t\t\tdelete retPeriods[k].toTimestamp;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tresolve(retPeriods);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\treturn User;\n};\n"
  },
  {
    "path": "includes/models/wallet.js",
    "content": "var crypto = require('crypto');\n\nmodule.exports = function(sequelize, DataTypes) {\n\tvar Wallet = sequelize.define('Wallet', {\n\t\tid: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tprimaryKey: true,\n\t\t\tautoIncrement: true\n\t\t},\n\t\tname: DataTypes.STRING(255),\n\t\ttype: {\n\t\t\ttype: DataTypes.ENUM('default', 'user'),\n\t\t\tdefaultValue: 'default',\n\t\t\tvalidate: {\n\t\t\t\tisIn: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t['default', 'user']\n\t\t\t\t\t],\n\t\t\t\t\tmsg: \"Invalid wallet type\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tstatus: {\n\t\t\ttype: DataTypes.ENUM('active', 'hidden'),\n\t\t\tdefaultValue: 'active',\n\t\t\tvalidate: {\n\t\t\t\tisIn: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t['active', 'hidden']\n\t\t\t\t\t],\n\t\t\t\t\tmsg: \"Invalid wallet status\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcurrency: {\n\t\t\ttype: DataTypes.STRING(10),\n\t\t\tdefaultValue: 'USD'\n\t\t},\n\t\ttotal: {\n\t\t\ttype: DataTypes.FLOAT(),\n\t\t\tdefaultValue: 0\n\t\t}\n\t}, {\n\t\ttimestamps: false,\n\t\tindexes: [\n\n\t\t],\n\t\tfreezeTableName: true,\n\t\ttableName: 'wallets',\n\t\tclassMethods: {},\n\t\tinstanceMethods: {\n\t\t\tgiveAccess: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar email = params.email || '';\n\t\t\t\tvar original_user_id = this.user_id;\n\n\t\t\t\tvar that = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tsequelize.db.User.findOne({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\temail: email\n\t\t\t\t\t\t}\n\t\t\t\t\t}).\n\t\t\t\t\tthen(function(user) {\n\t\t\t\t\t\t\tif (user)\n\t\t\t\t\t\t\t\treturn that.createWalletAccess({\n\t\t\t\t\t\t\t\t\tto_email: email,\n\t\t\t\t\t\t\t\t\tto_user_id: user.id,\n\t\t\t\t\t\t\t\t\toriginal_user_id: original_user_id\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treturn that.createWalletAccess({\n\t\t\t\t\t\t\t\t\tto_email: email,\n\t\t\t\t\t\t\t\t\toriginal_user_id: original_user_id\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(function(wallet_access) {\n\t\t\t\t\t\t\tresolve(wallet_access);\n\t\t\t\t\t\t}, function(err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tsetTotalTo: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar amount = parseFloat(params.amount, 10) || 0;\n\t\t\t\tvar diff = amount - this.total;\n\n\t\t\t\tparams.subtype = 'setup';\n\t\t\t\tparams.amount = diff;\n\n\t\t\t\treturn this.insertTransaction(params);\n\t\t\t},\n\t\t\tinsertTransaction: function(params) {\n\t\t\t\tvar params = params || {};\n\t\t\t\tvar description = params.description || '';\n\t\t\t\tvar amount = parseFloat(params.amount, 10) || 0;\n\t\t\t\tvar abs_amount = Math.abs(amount);\n\t\t\t\tvar subtype = params.subtype || 'confirmed';\n\n\t\t\t\tvar currentDateTime = (Date.now() / 1000 | 0);\n\t\t\t\tvar datetime = currentDateTime;\n\t\t\t\tvar inThePast = false;\n\t\t\t\tif (parseInt(params.datetime)) {\n\t\t\t\t\tdatetime = parseInt(params.datetime);\n\t\t\t\t\tif (datetime < currentDateTime)\n\t\t\t\t\t\tinThePast = true;\n\t\t\t\t}\n\n\t\t\t\tvar type = 'expense';\n\t\t\t\tif (amount >= 0)\n\t\t\t\t\ttype = 'profit';\n\n\t\t\t\tvar user_id = this.user_id;\n\n\t\t\t\tvar that = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\t\t\t\t\tthat.createTransaction({\n\t\t\t\t\t\tdescription: description,\n\t\t\t\t\t\tamount: amount,\n\t\t\t\t\t\tabs_amount: abs_amount,\n\t\t\t\t\t\tsubtype: subtype,\n\t\t\t\t\t\tdatetime: datetime,\n\t\t\t\t\t\ttype: type,\n\t\t\t\t\t\tuser_id: user_id\n\t\t\t\t\t}).then(function(transaction) {\n\t\t\t\t\t\t/// proccess successful calculation\n\t\t\t\t\t\tif (!inThePast) {\n\t\t\t\t\t\t\tthat.total = that.total + transaction.amount;\n\t\t\t\t\t\t\tthat.save().done(function(res) {\n\t\t\t\t\t\t\t\tresolve(transaction);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t/// need to recalculate\n\t\t\t\t\t\t\t/// find setup transaction after this current one we've added\n\t\t\t\t\t\t\tsequelize.db.Transaction.findOne({\n\t\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\t\twallet_id: that.id,\n\t\t\t\t\t\t\t\t\tsubtype: 'setup',\n\t\t\t\t\t\t\t\t\tdatetime: {\n\t\t\t\t\t\t\t\t\t\t$gt: datetime\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\torder: 'datetime ASC'\n\t\t\t\t\t\t\t}).then(function(setup_transaction) {\n\t\t\t\t\t\t\t\tif (setup_transaction) {\n\t\t\t\t\t\t\t\t\t/// there's setup transaction\n\t\t\t\t\t\t\t\t\tsetup_transaction.amount = setup_transaction.amount + transaction.amount;\n\t\t\t\t\t\t\t\t\tsetup_transaction.save().done(function(res) {\n\t\t\t\t\t\t\t\t\t\tresolve(transaction);\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t/// no setup transaction, update wallet\n\t\t\t\t\t\t\t\t\tthat.total = that.total + transaction.amount;\n\t\t\t\t\t\t\t\t\tthat.save().done(function(res) {\n\t\t\t\t\t\t\t\t\t\tresolve(transaction);\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}, function(err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tgetWalletPlans: function() {\n\t\t\t\tvar wallet = this;\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\n\t\t\t\t\tsequelize.db.Plan.findAll({\n\t\t\t\t\t\tattributes: ['id'],\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t'user_id': wallet.user_id\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinclude: [{\n\t\t\t\t\t\t\tmodel: sequelize.db.Wallet,\n\t\t\t\t\t\t\tas: 'wallets',\n\t\t\t\t\t\t\tattributes: ['id', 'name', 'total'],\n\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\tid: wallet.id\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tthrough: {\n\t\t\t\t\t\t\t\tattributes: []\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}]\n\t\t\t\t\t}).then(function(plans) {\n\t\t\t\t\t\tvar ids = [];\n\t\t\t\t\t\tfor (var k in plans)\n\t\t\t\t\t\t\tids.push(plans[k].id);\n\n\t\t\t\t\t\tsequelize.db.Plan.findAll({\n\t\t\t\t\t\t\tattributes: ['id', 'user_id', 'name', 'goal_balance', 'goal_currency', 'goal_datetime', 'start_balance', 'start_currency', 'start_datetime', 'end_balance', 'status'],\n\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\tid: {\n\t\t\t\t\t\t\t\t\t$in: ids\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinclude: [{\n\t\t\t\t\t\t\t\tmodel: sequelize.db.Wallet,\n\t\t\t\t\t\t\t\tas: 'wallets',\n\t\t\t\t\t\t\t\tattributes: ['id', 'name', 'total'],\n\t\t\t\t\t\t\t\tthrough: {\n\t\t\t\t\t\t\t\t\tattributes: []\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}]\n\t\t\t\t\t\t}).then(function(plans) {\n\t\t\t\t\t\t\tresolve(plans);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\treturn Wallet;\n};"
  },
  {
    "path": "includes/models/wallet_access.js",
    "content": "module.exports = function(sequelize, DataTypes) {\n\tvar Authentication = sequelize.define('WalletAccess', {\n\t\tid: {\n\t\t\ttype: DataTypes.INTEGER,\n\t\t\tprimaryKey: true,\n\t\t\tautoIncrement: true\n\t\t},\n\t\tto_email: {\n\t\t\ttype: DataTypes.STRING(255),\n\t\t\tvalidate: {\n\t\t\t\tisEmail: {\n\t\t\t\t\tmsg: \"Invalid email\"\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t}, {\n\t\ttimestamps: false,\n\t\tindexes: [{\n\t\t\tunique: true,\n\t\t\tfields: ['to_email']\n\t\t}],\n\t\tfreezeTableName: true,\n\t\ttableName: 'wallet_accesses',\n\t\tclassMethods: {\n\t\t\tcheckAccessForNewUser: function(user) {\n\t\t\t\tvar email = user.email;\n\t\t\t\tvar new_user_id = user.id;\n\n\t\t\t\tsequelize.db.WalletAccess.findAll({\n\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\tto_email: email,\n\t\t\t\t\t\t\tto_user_id: null\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.then(function(wallet_accesses) {\n\t\t\t\t\t\twallet_accesses.forEach(function(wallet_access) {\n\t\t\t\t\t\t\twallet_access.to_user_id = new_user_id;\n\t\t\t\t\t\t\twallet_access.save();\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t},\n\t\t\tgetWalletIfHasAccess: function(user, wallet_id) {\n\t\t\t\treturn new sequelize.Promise(function(resolve, reject) {\n\n\t\t\t\t\tsequelize.db.Wallet.findOne({\n\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\tid: wallet_id\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(function(wallet) {\n\t\t\t\t\t\t\tif (!wallet)\n\t\t\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\t\tif (wallet.user_id == user.id)\n\t\t\t\t\t\t\t\tresolve(wallet);\n\t\t\t\t\t\t\telse {\n\n\t\t\t\t\t\t\t\tsequelize.query(\"SELECT wallets.* FROM wallets JOIN wallet_accesses ON wallet_accesses.wallet_id = wallets.id WHERE wallets.id = :wallet_id AND wallet_accesses.to_user_id = :user_id\", {\n\t\t\t\t\t\t\t\t\t\treplacements: {\n\t\t\t\t\t\t\t\t\t\t\tuser_id: user.id,\n\t\t\t\t\t\t\t\t\t\t\twallet_id: wallet_id\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tmodel: sequelize.db.Wallet\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.then(function(wallets) {\n\t\t\t\t\t\t\t\t\t\tif (!wallets.length)\n\t\t\t\t\t\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\tresolve(wallets[0]);\n\t\t\t\t\t\t\t\t\t}, function(err) {\n\t\t\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tinstanceMethods: {}\n\t});\n\n\treturn Authentication;\n};"
  },
  {
    "path": "includes/routes/exchange/exchange.apib",
    "content": "# Group Exchange Rates\n\n### Get Exchange Rates [GET /api/exchange/rates]\n\nGet cached exchange rates from OpenExchangeRates (if API key is defined in config files) or from Yahoo FX.\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"base\":\"USD\",\n        \"rates\":    {\n                        \"AED\":3.673,\n                        \"AFN\":68.37,\n                        \"ZAR\":14.5653,\n                        \"ZMK\":5189.5,\n                        \"ZMW\":9.2,\n                        \"ZWL\":322.355\n                    }\n    }"
  },
  {
    "path": "includes/routes/exchange/rates.js",
    "content": "var rfr = require('rfr');\nvar api = rfr('includes/api.js');\nvar exchange = rfr('includes/exchange.js');\n\nexports.route = '/api/exchange/rates';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\tres.send(exchange.getRates());\n\tnext();\n};"
  },
  {
    "path": "includes/routes/i18n/get.js",
    "content": "var rfr = require('rfr');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/i18n/bycode/:code';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\tvar code = req.params.code || en;\n\tvar body = api.geti18njson(code);\n\n\tres.writeHead(200, {\n\t\t'Content-Length': Buffer.byteLength(body),\n\t\t'Content-Type': 'application/json'\n\t});\n\n\tres.write(body);\n\tres.end();\n\tnext();\n};"
  },
  {
    "path": "includes/routes/i18n/i18n.apib",
    "content": "# Group i18n\n\n### Get language strings [GET /api/i18n/bycode/{code}]\n\nGet i18n json file for selected locale.\n\n+ Parameters\n    + code: ua (string) - language code\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"Nothing is found\": \"Sem resultado\",\n        \"Add Income\": \"Adicionar Receita\",\n        \"Amount\": \"Valor\",\n        \"...\": \"...\"\n    }"
  },
  {
    "path": "includes/routes/index.js",
    "content": "var fs = require('fs');\nvar routes = [];\n\nvar done = false;\nvar callback;\n\nvar walk = function(dir, done) {\n  var results = [];\n  fs.readdir(dir, function(err, list) {\n    if (err) return done(err);\n    var i = 0;\n    (function next() {\n      var file = list[i++];\n      if (!file) return done(null, results);\n      file = dir + '/' + file;\n      fs.stat(file, function(err, stat) {\n        if (stat && stat.isDirectory()) {\n          walk(file, function(err, res) {\n            results = results.concat(res);\n            next();\n          });\n        } else {\n          results.push(file);\n          next();\n        }\n      });\n    })();\n  });\n};\n\nwalk(__dirname, function(err, results) {\n  if (err) throw err;\n  results.forEach(function(file) {\n    if (file.indexOf('index.js') == -1 && file.slice(-3) === '.js') {\n      var name = file.substr(file.lastIndexOf('/'), file.indexOf('.'));\n      var inc = require(file);\n      routes.push({\n        handler: inc.handler,\n        route: inc.route,\n        method: inc.method,\n        docs: inc.docs\n      });\n    }\n  });\n\n  done = true;\n  if (typeof callback == 'function')\n    callback(routes);\n});\n\nmodule.exports = function(cb) {\n  if (done)\n    cb(routes);\n  else\n    callback = cb;\n}"
  },
  {
    "path": "includes/routes/plans/del.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/plans/:plan_id';\nexports.method = 'del';\n\nexports.handler = function(req, res, next) {\n\n\tvar plan_id = req.params.plan_id || 0;\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Plan.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: plan_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(plan) {\n\t\t\t\tif (!plan) throw new errors.HaveNoRightsError();\n\t\t\t\treturn plan.destroy();\n\t\t\t}).then(function(plan) {\n\t\t\t\tres.send(true);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/plans/get.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/plans/:plan_id';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar plan_id = parseInt(req.params.plan_id || 0, 10);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getUserPlan(plan_id).then(function(resPlan) {\n\t\t\tresPlan.checkIfFinished().then(function(plan) {\n\t\t\t\tres.send(plan);\n\t\t\t\tnext();\n\t\t\t});\n\t\t});\n\t});\n};"
  },
  {
    "path": "includes/routes/plans/list.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/plans';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getUserPlans().then(function(plans) {\n\t\t\tvar resPlans = [];\n\t\t\tfor (var k in plans)\n\t\t\t\tresPlans.push(plans[k].checkIfFinished());\n\n\t\t\tdb.sequelize.Promise.all(resPlans).then(function() {\n\t\t\t\tres.send(plans);\n\t\t\t\tnext();\n\t\t\t});\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/plans/plans.apib",
    "content": "# Group Goals\n\n### List User Goals [GET /api/plans]\n\nGet list of user's goals\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":1,\n                \"name\":\"\",\n                \"goal_balance\":1000,\n                \"goal_currency\":\"USD\",\n                \"goal_datetime\":null,\n                \"start_balance\":2138.02,\n                \"start_currency\":\"USD\",\n                \"start_datetime\":null,\n                \"status\":\"active\",\n                \"wallets\":  [\n                                {\n                                    \"id\":1,\n                                    \"name\":\"Sample Bank Account Wallet\",\n                                    \"total\":2138.02\n                                }\n                            ]\n            }\n        ]\n\n### Add New Goal [POST /api/plans]\n\nCreate new goal for currently signed in user's account\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + name: Somegoalname (string, required) - Goal name.\n        + start_currency: USD (string, required) - currency identifier. USD, EUR, BTC etc\n        + goal_currency: USD (string, required) - currency identifier. USD, EUR, BTC etc\n        + start_balance: 2138.02 (number, required) - Current balance of wallets used in this plan\n        + goal_balance: 1000 (number, required) - Current balance of wallets used in this plan\n        + start_datetime: (number, required) - Current unix timestamp\n        + goal_datetime: (number, required) - Goal unix timestamp\n        + wallets: [12,13] (array, required) - Array of wallets ids for this goal\n\n+ Response 200 (application/json)\n\n    + Body\n\n        {\n            \"id\":1,\n            \"name\":\"\",\n            \"goal_balance\":30,\n            \"goal_currency\":\"USD\",\n            \"goal_datetime\":23423,\n            \"start_balance\":2138.02,\n            \"start_currency\":\"USD\",\n            \"start_datetime\":22333,\n            \"status\":\"active\",\n            \"wallets\":  [\n                            {\n                                \"id\":1,\n                                \"name\":\"Sample Bank Account Wallet\",\n                                \"total\":2138.02\n                            }\n                        ]\n        }\n\n### Update Goal [PUT /api/plans/{plan_id}]\n\nUpdate goal\n\n+ Parameters\n    + plan_id (number) - ID of the Plan in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + name: Somegoalname (string, required) - Goal name.\n        + goal_currency: USD (string, required) - currency identifier. USD, EUR, BTC etc\n        + goal_balance: 1000 (number, required) - Current balance of wallets used in this plan\n        + goal_datetime: (number, required) - Goal unix timestamp\n        + wallets: [12,13] (array, required) - Array of wallets ids for this goal\n\n+ Response 200 (application/json)\n\n    + Body\n\n        {\n            \"id\":1,\n            \"name\":\"\",\n            \"goal_balance\":30,\n            \"goal_currency\":\"USD\",\n            \"goal_datetime\":23423,\n            \"start_balance\":2138.02,\n            \"start_currency\":\"USD\",\n            \"start_datetime\":22333,\n            \"status\":\"active\",\n            \"wallets\":  [\n                            {\n                                \"id\":1,\n                                \"name\":\"Sample Bank Account Wallet\",\n                                \"total\":2138.02\n                            }\n                        ]\n        }\n\n### Remove Goal [DELETE /api/plans/{plan_id}]\n\nRemove goal from database\n\n+ Parameters\n    + plan_id (number) - ID of the Plan in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        true"
  },
  {
    "path": "includes/routes/plans/post.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/plans';\nexports.method = 'post';\n\n\nexports.handler = function(req, res, next) {\n\n\tvar data = {\n\t\tname: api.getParam(req, 'name', 'Undefined'),\n\t\tgoal_balance: api.getParam(req, 'goal_balance', 0),\n\t\tgoal_currency: api.getParam(req, 'goal_currency', ''),\n\t\tgoal_datetime: api.getParam(req, 'goal_datetime', 0),\n\t\tstart_balance: api.getParam(req, 'start_balance', 0),\n\t\tstart_currency: api.getParam(req, 'start_currency', ''),\n\t\tstart_datetime: api.getParam(req, 'start_datetime', 0),\n\t\tstatus: api.getParam(req, 'status', 'active'),\n\t\twallets: api.getParam(req, 'wallets', 0)\n\t};\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.addUserPlan(data).then(function(plan) {\n\t\t\t/// loads it from db, to be sure:\n\t\t\tuser.getUserPlan(plan.id).then(function(resPlan) {\n\t\t\t\tres.send(resPlan);\n\t\t\t\tnext();\n\t\t\t});\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/plans/put.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\n\nexports.route = '/api/plans/:plan_id';\nexports.method = 'put';\n\nexports.handler = function(req, res, next) {\n\n\tvar plan_id = req.params.plan_id || 0;\n\n\tvar data = {\n\t\tname: api.getParam(req, 'name', null),\n\t\tgoal_balance: api.getParam(req, 'goal_balance', null),\n\t\tgoal_currency: api.getParam(req, 'goal_currency', null),\n\t\tgoal_datetime: api.getParam(req, 'goal_datetime', null),\n\t\twallets: api.getParam(req, 'wallets', null)\n\t};\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Plan.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: plan_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(plan) {\n\t\t\t\tif (data.name !== null) plan.name = data.name;\n\t\t\t\tif (data.goal_balance !== null) plan.goal_balance = data.goal_balance;\n\t\t\t\tif (data.goal_currency !== null) plan.goal_currency = data.goal_currency;\n\t\t\t\tif (data.goal_datetime !== null) plan.goal_datetime = data.goal_datetime;\n\n\t\t\t\tif (data.wallets !== null)\n\t\t\t\t\treturn plan.updateWalletsIds(data.wallets);\n\t\t\t\telse\n\t\t\t\t\treturn plan.save();\n\t\t\t}).then(function(plan) {\n\t\t\t\t/// loads it from db, to be sure:\n\t\t\t\tuser.getUserPlan(plan.id).then(function(resPlan) {\n\t\t\t\t\tres.send(resPlan);\n\t\t\t\t\tnext();\n\t\t\t\t});\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/stats/month.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/stats/month';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar utcoffset = parseInt(req.params.utcoffset || 0, 10); // http://momentjs.com/docs/#/manipulating/utc-offset/\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getStats({period: 'month', utcOffset: utcoffset}).then(function(stats){\n\t\t\tres.send(stats);\n\t\t\tnext();\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/stats/stats.apib",
    "content": "# Group Statistics\n\n### Get Recent Week User Statistics [GET /api/stats/week]\n\nGet recent week user statistics\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + utcoffset: (number) - Timezone offset. In hours or minutes. http://momentjs.com/docs/#/manipulating/utc-offset/\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    [ \n        {\n            month: 4,\n            year: 2016,\n            day: 21,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 20,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 19,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 18,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 17,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 16,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 15,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        }\n    ]\n\n\n### Get Recent Month User Statistics [GET /api/stats/month]\n\nGet recent month user statistics\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + utcoffset: (number) - Timezone offset. In hours or minutes. http://momentjs.com/docs/#/manipulating/utc-offset/\n        \n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    [ \n        {\n            month: 4,\n            year: 2016,\n            day: 21,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 3,\n            year: 2016,\n            day: 22,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        }\n    ]\n\n\n\n### Get Recent Year User Statistics [GET /api/stats/year]\n\nGet recent year user statistics\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + utcoffset: (number) - Timezone offset. In hours or minutes. http://momentjs.com/docs/#/manipulating/utc-offset/\n        \n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    [ \n        {\n            month: 4,\n            year: 2016,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 2,\n            year: 2016,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                UAH: \n                { \n                    expense: 0, \n                    profit: 198 \n                },\n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        }\n    ]\n"
  },
  {
    "path": "includes/routes/stats/week.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/stats/week';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar utcoffset = parseInt(req.params.utcoffset || 0, 10); // http://momentjs.com/docs/#/manipulating/utc-offset/\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getStats({period: 'week', utcOffset: utcoffset}).then(function(stats){\n\t\t\tres.send(stats);\n\t\t\tnext();\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/stats/year.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/stats/year';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar utcoffset = parseInt(req.params.utcoffset || 0, 10); // http://momentjs.com/docs/#/manipulating/utc-offset/\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getStats({period: 'year', utcOffset: utcoffset}).then(function(stats){\n\t\t\tres.send(stats);\n\t\t\tnext();\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/users/get.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar api = rfr('includes/api.js');\nvar mailer = rfr('includes/mailer.js');\n\nexports.route = '/api/users';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\tapi.requireSignedIn(req, function(user) {\n\t\tres.send({\n\t\t\tlogin: user.login,\n\t\t\temail: user.email,\n\t\t\tid: user.id,\n\t\t\tis_demo: user.is_demo\n\t\t});\n\t\tnext();\n\t});\n};"
  },
  {
    "path": "includes/routes/users/newpassword.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar ValidationError = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/newpassword';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\n\tvar code = api.getParam(req, 'code', '');\n\tvar hash = api.getParam(req, 'hash', '');\n\tvar password =api.getParam(req, 'password', '');\n\n\tdb.User.updatePassword(code, hash, password).then(function(user) {\n\t\tres.send(true);\n\t\tnext();\n\t}, function(e) {\n\t\tthrow e;\n\t});\n\n};"
  },
  {
    "path": "includes/routes/users/post.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar ValidationError = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\n\tvar body = req.body || {};\n\n\tvar login = api.getParam(req, 'login', '');\n\tvar type = api.getParam(req, 'type', 'default');\n\tvar password = api.getParam(req, 'password', '');\n\tvar email = api.getParam(req, 'email', '');\n\n\tvar ip = api.getVisitorIp(req);\n\n\tvar gotUser = null;\n\n\tdb.User.removeOldDemoAccounts();\n\n\tdb.User.register({\n\t\tlogin: login,\n\t\ttype: type,\n\t\tpassword: password,\n\t\temail: email,\n\t\tip: ip\n\t}).then(function(user) {\n\t\tgotUser = user;\n\t\treturn user.auth();\n\t}).then(function(authentication) {\n\t\tres.setCookie('logged_in_user', authentication.auth_code, {\n\t\t\tpath: '/',\n\t\t\tmaxAge: 365 * 24 * 60 * 60\n\t\t});\n\t\tres.setCookie('is_logged_in_user', '1', {\n\t\t\tpath: '/',\n\t\t\tmaxAge: 365 * 24 * 60 * 60\n\t\t});\n\n\t\tres.send({\n\t\t\tid: gotUser.id,\n\t\t\temail: gotUser.email,\n\t\t\tlogin: gotUser.login,\n\t\t\tis_demo: gotUser.is_demo,\n\t\t\tauth_code: authentication.auth_code\n\t\t});\n\n\t\tnext();\n\t}).catch(function(e) {\n\t\tthrow e;\n\t});\n\n\treturn true;\n};"
  },
  {
    "path": "includes/routes/users/put.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/:user_id';\nexports.method = 'put';\n\nexports.handler = function(req, res, next) {\n\n\tvar user_id = req.params.user_id;\n\n\tvar password = api.getParam(req, 'login', null);\n\tvar email = api.getParam(req, 'email', null);\n\tvar login = api.getParam(req, 'login', null);\n\n\tvar current_password = api.getParam(req, 'current_password', null);\n\t\n\tvar ip = api.getVisitorIp(req);\n\n\tapi.requireSignedIn(req, function(user) {\n\n\t\tvar promise = false;\n\t\tif (user.is_demo)\n\t\t\tpromise = user.fillProfile({\n\t\t\t\temail: email,\n\t\t\t\tlogin: login,\n\t\t\t\tpassword: password,\n\t\t\t\tip: ip\n\t\t\t});\n\t\telse\n\t\t\tpromise = user.update({\n\t\t\t\tpassword: password,\n\t\t\t\tcurrent_password: current_password\n\t\t\t});\n\n\t\tif (promise === false)\n\t\t\tthrow new errors.HaveNoRightsError();\n\n\t\tpromise.then(function(user) {\n\t\t\tres.send({\n\t\t\t\tlogin: user.login,\n\t\t\t\temail: user.email,\n\t\t\t\tid: user.id,\n\t\t\t\tis_demo: user.is_demo\n\t\t\t});\n\t\t\tnext();\n\t\t});\n\n\t});\n\n};"
  },
  {
    "path": "includes/routes/users/removeaccount.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/:user_id/removeaccount';\nexports.method = 'post';\n\n\nexports.handler = function(req, res, next) {\n\n\tvar user_id = parseInt(req.params.user_id || 0, 10);\n\tvar code = api.getParam(req, 'code', null);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tif (user_id != user.id)\n\t\t\tthrow 'Invalid user id';\n\n\t\tif (code === null) /// first step, no code parameter\n\t\t{\n\t\t\tuser.removeAccount().then(function(user) {\n\t\t\t\tres.send(true);\n\t\t\t\tnext();\n\t\t\t});\n\t\t} else {\n\t\t\t/// second step, with code\n\t\t\tdb.User.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: user_id,\n\t\t\t\t\tremove_account_code: code\n\t\t\t\t}\n\t\t\t}).then(function(user) {\n\t\t\t\tif (!user) {\n\t\t\t\t\tres.send(false);\n\t\t\t\t\tnext();\n\t\t\t\t}\n\t\t\t\tuser.removeAccountConfirm(code).then(function(success) {\n\t\t\t\t\tres.send(success);\n\t\t\t\t\tnext();\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n};"
  },
  {
    "path": "includes/routes/users/restore.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/restore';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\n\tvar email = api.getParam(req, 'email', '');\n\n\tdb.User.resetPassword(email).then(function(user) {\n\t\tres.send(true);\n\t\tnext();\n\t}, function(e) {\n\t\tthrow e;\n\t});\n\n};"
  },
  {
    "path": "includes/routes/users/signin.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/signin';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\n\tres.setHeader('Access-Control-Allow-Origin', '*');\n\n\tvar username = api.getParam(req, 'username', '');\n\tvar password = api.getParam(req, 'password', '');\n\tconsole.log(username);\n\tconsole.log(password);\n\tvar gotUser = null;\n\n\tdb.User.signIn({\n\t\tusername: username,\n\t\tpassword: password\n\t}).then(function(user) {\n\t\tgotUser = user;\n\t\treturn user.auth();\n\t}).then(function(authentication) {\n\t\tres.setCookie('logged_in_user', authentication.auth_code, {\n\t\t\tpath: '/',\n\t\t\tmaxAge: 365 * 24 * 60 * 60\n\t\t});\n\t\tres.setCookie('is_logged_in_user', '1', {\n\t\t\tpath: '/',\n\t\t\tmaxAge: 365 * 24 * 60 * 60\n\t\t});\n\n\t\tres.send({\n\t\t\tid: gotUser.id,\n\t\t\temail: gotUser.email,\n\t\t\tlogin: gotUser.login,\n\t\t\tis_demo: gotUser.is_demo,\n\t\t\tauth_code: authentication.auth_code\n\t\t});\n\t\tnext();\n\t}).catch(function(e) {\n\t\tthrow e;\n\t});\n\n\treturn true;\n};"
  },
  {
    "path": "includes/routes/users/signout.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/signout';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\tvar cookies = req.cookies;\n\tvar auth_code = cookies.logged_in_user || '';\n\n\tres.setCookie('logged_in_user', null, {\n\t\tpath: '/',\n\t\tmaxAge: -1\n\t});\n\tres.setCookie('is_logged_in_user', null, {\n\t\tpath: '/',\n\t\tmaxAge: -1\n\t});\n\n\tres.send(true);\n\tnext();\n};"
  },
  {
    "path": "includes/routes/users/users.apib",
    "content": "# Group Users\n\n### User [GET /api/users]\n### Get Signed In User Details [GET /api/users]\n\nGet currently signed in user details.\n\n+ Request\n\n    + Headers\n\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"id\": 23, \n        \"email\": \"example@gmail.com\",\n        \"login\": \"userlogin\",\n        \"is_demo\": 0\n    }\n\n\n### List User Wallets [GET /api/users/:user_id/wallets]\n\nGet list of current user's wallets\n\n+ Parameters\n    + user_id (number) - ID of the User in the form of an integer\n    \n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":4,\n                \"name\":\"Cash\",\n                \"status\":\"active\",\n                \"currency\":\"EUR\",\n                \"total\":300,\n                \"origin\":\"mine\"\n            },\n            {\n                \"id\":32,\n                \"name\":\"Bitcoins\",\n                \"status\":\"active\",\n                \"currency\":\"BTC\",\n                \"total\":12.99,\n                \"origin\":\"shared\"\n            }\n        ]\n\n### Sign In [POST /api/users/signin]\n\nSign in user using username and password. Returns user record with auth_code property. Use this auth_code for signing next API calls.\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + username: userlogin (string) - username or email\n        + password: Hahahahahaha (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"id\": 23, \n        \"email\": \"example@gmail.com\",\n        \"login\": \"userlogin\",\n        \"is_demo\": 0,\n        \"auth_code\": \"017957d841c8f6927c612ea1d6602c3f\"\n    }\n\n### Register New User [POST /api/users]\n\nRegister new user. Returns user record with auth_code property. Use this auth_code for signing next API calls.\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + email: example@example.com (string, required)\n        + login: userlogin (string, required)\n        + type: default (string)\n        + password: lovesecurity (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"id\": 23, \n        \"email\": \"example@gmail.com\",\n        \"login\": \"userlogin\",\n        \"is_demo\": 0,\n        \"auth_code\": \"017957d841c8f6927c612ea1d6602c3f\"\n    }\n\n\n### Fill Demo Account [PUT /api/users/:user_id]\n\nFill demo account.\n\n+ Parameters\n    + user_id (number) - ID of the User in the form of an integer\n    \n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + email: example@example.com (string, required)\n        + login: userlogin (string, required)\n        + password: dolovesecurity (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"id\": 23, \n        \"email\": \"example@gmail.com\",\n        \"login\": \"userlogin\",\n        \"is_demo\": 0\n    }\n\n### Update User Password [PUT /api/users/:user_id]\n\nUpdate user password.\n\n+ Parameters\n    + user_id (number) - ID of the User in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + current_password: lovesecurity (string, required)\n        + password: dolovesecurity (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    {\n        \"id\": 23, \n        \"email\": \"example@gmail.com\",\n        \"login\": \"userlogin\",\n        \"is_demo\": 0\n    }\n\n### Reset User Password [POST /api/users/restore]\n\nStart reset password procedure. Generate restore code and hash and send message to user's email.\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + email: example@example.com (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    true\n\n### Set New User Password [POST /api/users/newpassword]\n\nUpdate user's password using code and hash generated with 'Reset User Password' API method.\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + code: 234234 (string, required)\n        + hash: 345345345 (string, required)\n        + password: dolovesecurity (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    true\n\n\n### Sign Out [POST /api/users/signout]\n\nSigns out current user. And invalidates auth_code.\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + username: userlogin (string) - username or email\n        + password: Hahahahahaha (string, required)\n\n+ Response 200 (application/json)\n\n    + Body\n\n    true\n\n\n### Remove User Account [POST /api/users/{user_id}/removeaccount]\n\nStart user account remove process. Sends email to user with confirmation code.\n\n+ Parameters\n    + user_id (number) - ID of the User in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    true\n\n\n### Confirm User Account Removal [POST /api/users/{user_id}/removeaccount]\n\nConfirm user account removal.\n\n+ Parameters\n    + user_id (number) - ID of the User in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n            \n    + Attributes (object)\n        + code: 223425234 (string, required) - confirmation code\n\n+ Response 200 (application/json)\n\n    + Body\n\n    true"
  },
  {
    "path": "includes/routes/users/wallets/list.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/users/:user_id/wallets';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\tapi.requireSignedIn(req, function(user) {\n\n\t\tdb.sequelize.Promise.join(\n\t\t\tuser.getWallets(),\n\t\t\tuser.getSharedWallets(),\n\t\t\tfunction(own, shared) {\n\t\t\t\tres.send(\n\t\t\t\t\tshared.map(\n\t\t\t\t\t\tfunction(wallet) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: wallet.id,\n\t\t\t\t\t\t\t\tname: wallet.name,\n\t\t\t\t\t\t\t\tstatus: wallet.status,\n\t\t\t\t\t\t\t\tcurrency: wallet.currency,\n\t\t\t\t\t\t\t\ttotal: wallet.total,\n\t\t\t\t\t\t\t\torigin: 'shared'\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t).concat(\n\t\t\t\t\t\town.map(\n\t\t\t\t\t\t\tfunction(wallet) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: wallet.id,\n\t\t\t\t\t\t\t\t\tname: wallet.name,\n\t\t\t\t\t\t\t\t\tstatus: wallet.status,\n\t\t\t\t\t\t\t\t\tcurrency: wallet.currency,\n\t\t\t\t\t\t\t\t\ttotal: wallet.total,\n\t\t\t\t\t\t\t\t\torigin: 'mine'\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tnext();\n\t\t\t}\n\t\t);\n\n\n\t});\n};"
  },
  {
    "path": "includes/routes/wallets/accesses/accesses.apib",
    "content": "# Group Wallet Access\n\n### List Wallet Accesses [GET /api/wallets/{wallet_id}/accesses]\n\nGet list of accesses to wallet\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":11,\n                \"to_email\":\"example@gmail.com\",\n                \"wallet_id\":4,\n                \"original_user_id\":1,\n                \"to_user_id\":null\n            },\n            {\n                \"id\":12,\n                \"to_email\":\"example2@gmail.com\",\n                \"wallet_id\":4,\n                \"original_user_id\":1,\n                \"to_user_id\":88\n            }\n        ]\n\n### Add new access to wallet [POST /api/wallets/{wallet_id}/accesses]\n\nAdd new access to wallet. User registered(already or later) with to_email will be able to view wallet.\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + wallet_id: 1 (number, required) - Wallet ID. Should be the same as in URL param\n        + to_email: example2@gmail.com (string, required) - Email\n\n+ Response 200 (application/json)\n\n    + Body\n\n        {\n            \"id\":12,\n            \"to_email\":\"example2@gmail.com\",\n            \"wallet_id\":4,\n            \"original_user_id\":1,\n            \"to_user_id\":88\n        }\n\n### Remove Wallet Access [DELETE /api/wallets/{wallet_id}/accesses/{wallet_access_id}]\n\nRemove access to wallet. Works only if called by original wallet owner.\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n    + wallet_access_id (number) - ID of the WalletAccess in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        true"
  },
  {
    "path": "includes/routes/wallets/accesses/del.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/accesses/:wallet_access_id';\nexports.method = 'del';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = req.params.wallet_id || 0;\n\tvar wallet_access_id = req.params.wallet_access_id || 0;\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.WalletAccess.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_access_id,\n\t\t\t\t\twallet_id: wallet_id,\n\t\t\t\t\toriginal_user_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet_access) {\n\t\t\t\tif (!wallet_access) throw new errors.HaveNoRightsError();\n\t\t\t\treturn wallet_access.destroy();\n\t\t\t}).then(function(wallet_access) {\n\t\t\t\tres.send(true);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/accesses/list.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/accesses';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet) throw new errors.HaveNoRightsError();\n\t\t\t\treturn db.WalletAccess.findAll({\n\t\t\t\t\twhere: {\n\t\t\t\t\t\twallet_id: wallet_id\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(function(wallet_accesses) {\n\t\t\t\tres.send(wallet_accesses);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/accesses/post.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/accesses';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\t\n\tvar wallet_id = parseInt(api.getParam(req, 'wallet_id', 0), 10);\n\tvar to_email = api.getParam(req, 'to_email', '');\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet) throw new errors.HaveNoRightsError();\n\t\t\t\treturn wallet.giveAccess({\n\t\t\t\t\temail: to_email\n\t\t\t\t});\n\t\t\t}).then(function(wallet_access) {\n\t\t\t\tres.send(wallet_access);\n\t\t\t\tnext();\n\t\t\t}, function(err) {\n\t\t\t\tthrow err;\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/delete.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id';\nexports.method = 'del';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id,\n\t\t\t\t\tstatus: 'hidden'\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\treturn wallet.destroy();\n\t\t\t}).then(function(wallet) {\n\t\t\t\tres.send(true);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n};"
  },
  {
    "path": "includes/routes/wallets/get.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getWalletIfHasAccess(wallet_id)\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet)\n\t\t\t\t\tthrow new errors.NotFoundError();\n\t\t\t\tres.send(wallet);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n};"
  },
  {
    "path": "includes/routes/wallets/list.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\tapi.requireSignedIn(req, function(user) {\n\n\t\tdb.sequelize.Promise.join(\n\t\t\tuser.getWallets(),\n\t\t\tuser.getSharedWallets(),\n\t\t\tfunction(own, shared) {\n\t\t\t\tres.send(\n\t\t\t\t\tshared.map(\n\t\t\t\t\t\tfunction(wallet) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tid: wallet.id,\n\t\t\t\t\t\t\t\tname: wallet.name,\n\t\t\t\t\t\t\t\tstatus: wallet.status,\n\t\t\t\t\t\t\t\tcurrency: wallet.currency,\n\t\t\t\t\t\t\t\ttotal: wallet.total,\n\t\t\t\t\t\t\t\torigin: 'shared'\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t).concat(\n\t\t\t\t\t\town.map(\n\t\t\t\t\t\t\tfunction(wallet) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: wallet.id,\n\t\t\t\t\t\t\t\t\tname: wallet.name,\n\t\t\t\t\t\t\t\t\tstatus: wallet.status,\n\t\t\t\t\t\t\t\t\tcurrency: wallet.currency,\n\t\t\t\t\t\t\t\t\ttotal: wallet.total,\n\t\t\t\t\t\t\t\t\torigin: 'mine'\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tnext();\n\t\t\t}\n\t\t);\n\n\t});\n};"
  },
  {
    "path": "includes/routes/wallets/plans/list.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/plans';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet) throw new errors.HaveNoRightsError();\n\t\t\t\treturn wallet.getWalletPlans();\n\t\t\t})\n\t\t\t.then(function(plans) {\n\t\t\t\tvar resPlans = [];\n\t\t\t\tfor (var k in plans)\n\t\t\t\t\tresPlans.push(plans[k].checkIfFinished());\n\n\t\t\t\tdb.sequelize.Promise.all(resPlans).then(function() {\n\t\t\t\t\tres.send(plans);\n\t\t\t\t\tnext();\n\t\t\t\t});\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/post.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\n\tvar name = api.getParam(req, 'name', '');\n\tvar currency = api.getParam(req, 'currency', 'USD');\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.insertWallet({\n\t\t\t\tname: name,\n\t\t\t\tcurrency: currency\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tres.send(wallet);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/put.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id';\nexports.method = 'put';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = req.params.wallet_id || 0;\n\t\n\tvar name = api.getParam(req, 'name', null);\n\tvar currency = api.getParam(req, 'currency', null);\n\tvar status = api.getParam(req, 'status', null);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (name !== null) wallet.name = name;\n\t\t\t\tif (currency !== null) wallet.currency = currency;\n\t\t\t\tif (status !== null) wallet.status = status;\n\n\t\t\t\treturn wallet.save();\n\t\t\t}).then(function(wallet) {\n\t\t\t\tres.send(wallet);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/stats/month.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/stats/month';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\tvar utcoffset = parseInt(req.params.utcoffset || 0, 10); // http://momentjs.com/docs/#/manipulating/utc-offset/\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getStats({period: 'month', utcOffset: utcoffset, wallet_id: wallet_id}).then(function(stats){\n\t\t\tres.send(stats);\n\t\t\tnext();\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/stats/wallet_stats.apib",
    "content": "# Group Wallet Statistics\n\n### Get Recent Week Wallet Statistics [GET /api/wallets/{wallet_id}/stats/week]\n\nGet recent week user statistics\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + utcoffset: (number) - Timezone offset. In hours or minutes. http://momentjs.com/docs/#/manipulating/utc-offset/\n        \n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    [ \n        {\n            month: 4,\n            year: 2016,\n            day: 21,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 20,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 19,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 18,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 17,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 16,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 4,\n            year: 2016,\n            day: 15,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        }\n    ]\n\n\n### Get Recent Month Wallet Statistics [GET /api/wallets/{wallet_id}/stats/month]\n\nGet recent month wallet statistics\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + utcoffset: (number) - Timezone offset. In hours or minutes. http://momentjs.com/docs/#/manipulating/utc-offset/\n        \n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    [ \n        {\n            month: 4,\n            year: 2016,\n            day: 21,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 3,\n            year: 2016,\n            day: 22,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        }\n    ]\n\n\n\n### Get Recent Year Wallet Statistics [GET /api/wallets/{wallet_id}/stats/year]\n\nGet recent year wallet statistics\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + utcoffset: (number) - Timezone offset. In hours or minutes. http://momentjs.com/docs/#/manipulating/utc-offset/\n        \n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n    [ \n        {\n            month: 4,\n            year: 2016,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        },\n        {\n            month: 2,\n            year: 2016,\n            utcOffset: '-03:00',\n            stats:  \n            { \n                USD: \n                { \n                    expense: 90, \n                    profit: 11.99 \n                }\n            } \n        }\n    ]\n"
  },
  {
    "path": "includes/routes/wallets/stats/week.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/stats/week';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\tvar utcoffset = parseInt(req.params.utcoffset || 0, 10); // http://momentjs.com/docs/#/manipulating/utc-offset/\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getStats({period: 'week', utcOffset: utcoffset, wallet_id: wallet_id}).then(function(stats){\n\t\t\tres.send(stats);\n\t\t\tnext();\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/stats/year.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/stats/year';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\tvar utcoffset = parseInt(req.params.utcoffset || 0, 10); // http://momentjs.com/docs/#/manipulating/utc-offset/\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getStats({period: 'year', utcOffset: utcoffset, wallet_id: wallet_id}).then(function(stats){\n\t\t\tres.send(stats);\n\t\t\tnext();\n\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/transactions/del.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/transactions/:transaction_id';\nexports.method = 'del';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\tvar transaction_id = parseInt(req.params.transaction_id || 0, 10);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet) throw new errors.NotFoundError();\n\t\t\t\treturn db.Transaction.findOne({\n\t\t\t\t\twhere: {\n\t\t\t\t\t\tid: transaction_id,\n\t\t\t\t\t\twallet_id: wallet.id\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}).then(function(transaction) {\n\t\t\t\tif (!transaction) throw new errors.NotFoundError();\n\t\t\t\treturn transaction.deleteAndCheckWallet();\n\t\t\t}).then(function() {\n\t\t\t\tres.send(true);\n\t\t\t\tnext();\n\t\t\t})\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/transactions/list.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/transactions';\nexports.method = 'get';\n\nexports.handler = function(req, res, next) {\n\n\tvar wallet_id = parseInt(req.params.wallet_id || 0, 10);\n\tvar to = parseInt(req.params.to || 0, 10);\n\tvar from = parseInt(req.params.from || 0, 10);\n\n\tif (to === 0 || from === 0) {\n\t\tto = Math.floor(Date.now() / 1000);\n\t\tfrom = to - 24 * 60 * 60 * 31;\n\t}\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tuser.getWalletIfHasAccess(wallet_id)\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet) throw new errors.HaveNoRightsError();\n\t\t\t\treturn db.Transaction.findAll({\n\t\t\t\t\twhere: {\n\t\t\t\t\t\twallet_id: wallet.id,\n\t\t\t\t\t\tdatetime: {\n\t\t\t\t\t\t\t$lte: to,\n\t\t\t\t\t\t\t$gt: from\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\torder: [['datetime', 'DESC']]\n\t\t\t\t});\n\t\t\t}).then(function(transactions) {\n\t\t\t\tres.send(transactions);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/transactions/post.js",
    "content": "var rfr = require('rfr');\nvar db = rfr('includes/models');\nvar errors = rfr('includes/errors.js');\nvar api = rfr('includes/api.js');\n\nexports.route = '/api/wallets/:wallet_id/transactions';\nexports.method = 'post';\n\nexports.handler = function(req, res, next) {\n\n\tvar body = req.body || {};\n\tvar wallet_id = api.getParam(req, 'wallet_id', 0);\n\tvar amount = api.getParam(req, 'amount', 0);\n\tvar description = api.getParam(req, 'description', '');\n\tvar subtype = api.getParam(req, 'subtype', 'confirmed');\n\n\tvar datetime = api.getParam(req, 'datetime', null);\n\n\tapi.requireSignedIn(req, function(user) {\n\t\tdb.Wallet.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: wallet_id,\n\t\t\t\t\tuser_id: user.id\n\t\t\t\t}\n\t\t\t})\n\t\t\t.then(function(wallet) {\n\t\t\t\tif (!wallet) throw new errors.HaveNoRightsError();\n\t\t\t\tif (subtype == 'setup')\n\t\t\t\t\treturn wallet.setTotalTo({\n\t\t\t\t\t\tdescription: description,\n\t\t\t\t\t\tamount: amount\n\t\t\t\t\t});\n\t\t\t\telse\n\t\t\t\t\treturn wallet.insertTransaction({\n\t\t\t\t\t\tdescription: description,\n\t\t\t\t\t\tamount: amount,\n\t\t\t\t\t\tdatetime: datetime\n\t\t\t\t\t});\n\t\t\t}).then(function(transaction) {\n\t\t\t\tres.send(transaction);\n\t\t\t\tnext();\n\t\t\t});\n\t});\n\n};"
  },
  {
    "path": "includes/routes/wallets/transactions/transactions.apib",
    "content": "# Group Transactions\n\n### List Wallet Transactions [GET /api/wallets/{wallet_id}/transactions]\n\nGet list of wallet's transactions\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Attributes (object)\n        + from: (number) - From unix timestamp. Default is now() - 1 month\n        + to: (string) - To unix timestamp. Default is now()\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":53402,\n                \"description\":\"Desc\",\n                \"amount\":-42.33,\n                \"abs_amount\":42.33,\n                \"subtype\":\"confirmed\",\n                \"datetime\":1449706027,\n                \"type\":\"expense\",\n                \"user_id\":1,\n                \"wallet_id\":2103\n            },\n            {\n                \"id\":53412,\n                \"description\":\"Text\",\n                \"amount\":0.99,\n                \"abs_amount\":0.99,\n                \"subtype\":\"confirmed\",\n                \"datetime\":1449736027,\n                \"type\":\"profit\",\n                \"user_id\":1,\n                \"wallet_id\":2103\n            }\n        ]\n\n### Add New Transaction [POST /api/wallets/{wallet_id}/transactions]\n\nAdd new transaction\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + wallet_id: 1 (number, required) - Wallet ID. Should be the same as in URL param\n        + amount: 9.99 (number, required) - Transaction amount\n        + description: Some description (string) - Transaction description\n        + subtype: confirmed (string) - Transaction subtype. Default is 'confirmed'. If subtype is 'setup', it sets wallet total to amount.\n        + datetime: (number) - Default is current unix timestamp\n\n+ Response 200 (application/json)\n\n    + Body\n\n        {\n            \"id\":53402,\n            \"description\":\"Desc\",\n            \"amount\":-42.33,\n            \"abs_amount\":42.33,\n            \"subtype\":\"confirmed\",\n            \"datetime\":1449706027,\n            \"type\":\"expense\",\n            \"user_id\":1,\n            \"wallet_id\":2103\n        }\n\n### Remove Transaction [DELETE /api/wallets/{wallet_id}/transactions/{transaction_id}]\n\nRemove transaction from database. Also recalculate wallet total.\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n    + transaction_id (number) - ID of the Transaction in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        true"
  },
  {
    "path": "includes/routes/wallets/wallets.apib",
    "content": "# Group Wallets\n\n### List User Wallets [GET /api/wallets]\n\nGet list of current user's wallets\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":4,\n                \"name\":\"Cash\",\n                \"status\":\"active\",\n                \"currency\":\"EUR\",\n                \"total\":300,\n                \"origin\":\"mine\"\n            },\n            {\n                \"id\":32,\n                \"name\":\"Bitcoins\",\n                \"status\":\"active\",\n                \"currency\":\"BTC\",\n                \"total\":12.99,\n                \"origin\":\"shared\"\n            }\n        ]\n\n\n### Create New Wallet [POST /api/wallets]\n\nCreate new wallet under currently signed in user's account\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + name: Somewalletname (string, required)\n        + currency: USD (string, required) - currency identifier. USD, EUR, BTC etc\n\n+ Response 200 (application/json)\n\n    + Body\n\n        {\n            \"type\":\"default\",\n            \"status\":\"active\",\n            \"total\":0,\n            \"id\":2100,\n            \"name\":\"Name\",\n            \"currency\":\"USD\",\n            \"user_id\":1\n        }\n\n### Get Wallet [GET /api/wallets/{wallet_id}]\n\nGet wallet information\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":4,\n                \"name\":\"Cash\",\n                \"status\":\"active\",\n                \"currency\":\"EUR\",\n                \"total\":300,\n                \"origin\":\"mine\"\n            },\n            {\n                \"id\":32,\n                \"name\":\"Bitcoins\",\n                \"status\":\"active\",\n                \"currency\":\"BTC\",\n                \"total\":12.99,\n                \"origin\":\"shared\"\n            }\n        ]\n\n### Update Wallet [PUT /api/wallets/{wallet_id}]\n\nUpdate wallet under currently signed in user's account.\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n    + Attributes (object)\n        + name: Somewalletname (string)\n        + currency: USD (string) - currency identifier. USD, EUR, BTC etc\n        + status: active (string) - 'active' or 'hidden'\n\n+ Response 200 (application/json)\n\n    + Body\n\n        {\n            \"type\":\"default\",\n            \"status\":\"active\",\n            \"total\":0,\n            \"id\":2100,\n            \"name\":\"Name\",\n            \"currency\":\"USD\",\n            \"user_id\":1\n        }\n\n\n### Remove Wallet [DELETE /api/wallets/{wallet_id}]\n\nRemove wallet from database. As additional protection, this method removes wallet only if its status == 'hidden'. So you have to call PUT method first and set wallet status to 'hidden' and call DELETE after this.\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n\n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        true\n        \n### List Wallet Goals [GET /api/wallets/{wallet_id}/plans]\n\nGet list of wallet's goals\n\n+ Parameters\n    + wallet_id (number) - ID of the Wallet in the form of an integer\n    \n+ Request (application/json)\n\n    + Headers\n            authCode: 421a5bbd0624efebf12b2cbe5454b753\n\n+ Response 200 (application/json)\n\n    + Body\n\n        [\n            {\n                \"id\":1,\n                \"name\":\"\",\n                \"goal_balance\":1000,\n                \"goal_currency\":\"USD\",\n                \"goal_datetime\":null,\n                \"start_balance\":2138.02,\n                \"start_currency\":\"USD\",\n                \"start_datetime\":null,\n                \"status\":\"active\",\n                \"wallets\":  [\n                                {\n                                    \"id\":1,\n                                    \"name\":\"Sample Bank Account Wallet\",\n                                    \"total\":2138.02\n                                }\n                            ]\n            }\n        ]\n"
  },
  {
    "path": "includes/servers/images_server.js",
    "content": "'use strict';\n\nvar rfr = require('rfr');\nvar fs = require('fs');\nvar path = require('path');\nvar mime = require('mime');\n\nfunction serveImage(opts) {\n\n    var __cache = {};\n\n    function serveFileFromStats(file, err, stats, isGzip, req, res, next) {\n        if (err || !stats.isFile()) {\n            res.writeHead(404, \"Not Found\");\n            res.end();\n            return next(false);\n        }\n\n        var vsize = stats.size;\n        var vmime = mime.getType(file);\n        var vmtime = stats.mtime;\n\n        __cache[file] = {\n            size: vsize,\n            mime: vmime,\n            mtime: vmtime\n        };\n\n        res.setHeader(\"Cache-Control\", \"public, max-age=2592000\");\n        res.setHeader(\"Expires\", new Date(Date.now() + 2592000000).toUTCString());\n\n        res.set('Content-Length', __cache[file]['size']);\n        res.set('Content-Type', __cache[file]['mime']);\n        res.setHeader('Content-Type', __cache[file]['mime']);\n        res.set('Last-Modified', __cache[file]['mtime']);\n\n        res.writeHead(200);\n        fs.readFile(file, function(err, data) {\n            __cache[file]['content'] = data;\n            res.end(data);\n            return next(false);\n        });\n    }\n\n    function serveNormal(file, req, res, next) {\n        if (typeof(__cache[file]) !== 'undefined') {\n\n            res.setHeader(\"Cache-Control\", \"public, max-age=2592000\");\n            res.setHeader(\"Expires\", new Date(Date.now() + 2592000000).toUTCString());\n\n            res.set('Content-Length', __cache[file]['size']);\n            res.set('Content-Type', __cache[file]['mime']);\n            res.setHeader('Content-Type', __cache[file]['mime']);\n            res.set('Last-Modified', __cache[file]['mtime']);\n\n            res.writeHead(200);\n            res.end(__cache[file]['content']);\n\n            next(false);\n        } else {\n            fs.stat(file, function(err, stats) {\n                serveFileFromStats(file,\n                    err,\n                    stats,\n                    false,\n                    req,\n                    res,\n                    next);\n            });\n        }\n    }\n\n    function serve(req, res, next) {\n        if (req.headers[\"if-modified-since\"]) {\n            res.writeHead(304, \"Not Modified\");\n            res.end();\n            return next(false);\n        }\n        var file;\n\n        file = decodeURIComponent(req.path()).split('images/').join('');\n        file = path.join(rfr.root, './public/images/', file);\n\n        if (req.method !== 'GET' && req.method !== 'HEAD') {\n            res.writeHead(404, \"Not Found\");\n            res.end();\n            return next(false);\n        }\n\n        serveNormal(file, req, res, next);\n    }\n\n    return (serve);\n}\n\nmodule.exports = serveImage;"
  },
  {
    "path": "includes/servers/index.js",
    "content": "var fs = require('fs');\nvar servers = {};\n\nfs.readdirSync(__dirname).forEach(function(file) {\n\tif (file == \"index.js\") return;\n\tvar name = file.substr(0, file.indexOf('.'));\n\tservers[name] = require('./' + name);\n});\n\nmodule.exports = servers;"
  },
  {
    "path": "includes/servers/index_server.js",
    "content": "var restify = require('restify');\n\n\nfunction serveIndex(opts) {\n\tvar indexFile = opts.indexFile || 'index.html';\n\tvar indexDirectory = opts.indexDirectory || './public';\n\n\tvar index = restify.plugins.serveStatic({\n\t\tdirectory: indexDirectory,\n\t\tfile: indexFile\n\t});\n\n\treturn index;\n}\n\nmodule.exports = serveIndex;"
  },
  {
    "path": "includes/servers/minify_server.js",
    "content": "'use strict';\n\nvar fs = require('fs');\nvar zlib = require('zlib');\nvar path = require('path');\n\nvar UglifyJS = require(\"uglify-js\");\nvar CleanCSS = require('clean-css');\n\nvar rfr = require('rfr');\nvar config = rfr('includes/config.js');\n\nfunction serve(name) {\n    var name = name || 'css';\n    var type = 'guess';\n\n    var cachePath = {\n        cache: path.join(rfr.root, 'data/min/' + name + '.min'),\n        gzip: path.join(rfr.root, 'data/min/' + name + '.min.gz'),\n        raw: path.join(rfr.root, 'data/min/' + name + '.raw')\n    };\n\n    var need_to_minify = config.minify[name] || false;\n    var items = config.resources[name] || [];\n\n    var files = [];\n\n    var __result = '';\n    var __raw = '';\n    var __gzip = '';\n\n\n    var mostRecentMTime = 0;\n    var cacheMTime = 0;\n\n    var initialized = false;\n\n    function serve(req, res, next) {\n\n        if (req.method !== 'GET' && req.method !== 'HEAD') {\n            res.writeHead(405);\n            res.end('Method not allowed');\n            return next();\n        }\n\n        var callback = function() {\n            doServe(req, res, next);\n        };\n\n        if (!initialized)\n            init(callback);\n        else\n            callback();\n    }\n\n    function echoContentType(res) {\n        if (type == 'javascript')\n            res.setHeader('Content-Type', 'application/javascript');\n        else\n        if (type == 'css')\n            res.setHeader('Content-Type', 'text/css');\n        else\n            res.setHeader('Content-Type', 'text/plain');\n\n        return res;\n    }\n\n    function doServe(req, res, next) {\n        if (req.acceptsEncoding('gzip') && need_to_minify) {\n            res = echoContentType(res);\n            res.setHeader('Content-Encoding', 'gzip');\n            res.writeHead(200);\n            res.end(__gzip);\n            console.log('Send ' + type + ' resources as gzip');\n        } else {\n            res = echoContentType(res);\n            res.writeHead(200);\n            if (need_to_minify)\n                res.end(__result);\n            else\n                res.end(__raw);\n            console.log('Send ' + type + ' resources as plain');\n        }\n\n        next();\n    }\n\n    function addFile(filename) {\n        if (type == 'guess') {\n            if (filename.slice(-3) == '.js')\n                type = 'javascript';\n            if (filename.slice(-4) == '.css')\n                type = 'css';\n        }\n        files.push(filename);\n    }\n\n    function addFolder(pathname) {\n        fs.readdirSync(pathname).forEach(function(file) {\n            if (file.slice(-3) !== '.js' && file.slice(-4) !== '.css')\n                return;\n            addFile(path.join(pathname, file));\n        });\n    }\n\n    function getMTimes(callback) {\n\n        var gotMTimeCount = 0;\n        var expectedMTimeCount = files.length + 3; /// cached + cached.gz + raw\n\n        var cbReady = function() {\n            gotMTimeCount++;\n            if (gotMTimeCount == expectedMTimeCount && typeof callback == 'function')\n                callback();\n        }\n\n        files.forEach(function(file) {\n            fs.stat(file, function(err, stats) {\n                if (err)\n                    return cbReady();\n                if (typeof(stats['mtime']) !== 'undefined' && stats['mtime'] > mostRecentMTime)\n                    mostRecentMTime = stats['mtime'];\n                cbReady();\n            });\n        });\n\n        var cbCached = function(err, stats) {\n            if (err)\n                return cbReady();\n            if (typeof(stats['mtime']) !== 'undefined')\n                if (cacheMTime === 0 || stats['mtime'] < cacheMTime)\n                    cacheMTime = stats['mtime'];\n            cbReady();\n        }\n\n        fs.stat(cachePath.cache, cbCached);\n        fs.stat(cachePath.gzip, cbCached);\n        fs.stat(cachePath.raw, cbCached);\n    }\n\n    function generateJSHTML(callback) {\n        __raw = '';\n        __raw += \"function inc_js_file(fname) { var js = document.createElement('script'); js.type = 'text/javascript';\";\n        __raw += \"js.src = fname; js.async = false; document.body.appendChild(js); }\\n\";\n\n        files.forEach(function(file) {\n            file = file.split(path.join(rfr.root, '/public/')).join('/').split('./public/').join('/').split('public/').join('/');\n            file = file.split(\"\\\\\").join(\"/\");\n            __raw += \"inc_js_file(\\\"\" + file + \"\\\");\\n\";\n        })\n    }\n\n    function minify(callback) {\n\n        if (type == 'javascript') {\n            console.log('Minify javascript files...');\n\n            var code = {};\n            for (var fName of files) {\n                code[fName] = fs.readFileSync(fName, \"utf8\");\n            }\n\n            var result = UglifyJS.minify(code, {\n                compress: false\n            });\n\n            // console.log(files);\n\n            __result = result.code;\n\n            generateJSHTML();\n\n            var buf = new Buffer(__result, 'utf-8');\n\n            zlib.gzip(buf, function(_, res) {\n                console.log('Minify javascript files. Done.');\n                __gzip = res;\n\n                fs.writeFileSync(cachePath.cache, __result);\n                fs.writeFileSync(cachePath.gzip, __gzip);\n                fs.writeFileSync(cachePath.raw, __raw);\n\n                if (typeof callback === 'function')\n                    callback();\n            });\n        } else\n        if (type == 'css') {\n\n\n            console.log('Minify css files...');\n            new CleanCSS({\n                rebaseTo: path.join(rfr.root, 'public/'),\n                // relativeTo: path.join(rfr.root, 'public')\n            }).minify(files, function(error, minified) {\n                __result = minified.styles;\n                __raw = __result;\n                var buf = new Buffer(__result, 'utf-8');\n\n                zlib.gzip(buf, function(_, res) {\n                    __gzip = res;\n\n                    fs.writeFileSync(cachePath.cache, __result);\n                    fs.writeFileSync(cachePath.raw, __raw);\n                    fs.writeFileSync(cachePath.gzip, __gzip);\n\n                    console.log('Minify css files. Done.');\n                    if (typeof callback === 'function')\n                        callback();\n                });\n            });\n        }\n    }\n\n    function loadFromCache(callback) {\n        var gotCount = 0;\n        var expectedCount = 3;\n        if (!cachePath.gzip) expectedCount--;\n        if (!cachePath.raw) expectedCount--;\n        if (!cachePath.cache) expectedCount--;\n\n        var cbReady = function() {\n            gotCount++;\n            if (gotCount == expectedCount && typeof callback == 'function') {\n                console.log(type + ' loaded');\n                callback();\n            }\n        };\n\n\n        fs.readFile(cachePath.cache, function read(err, data) {\n            if (err)\n                return cbReady();\n            __result = data;\n            cbReady();\n        });\n        fs.readFile(cachePath.gzip, function read(err, data) {\n            if (err)\n                return cbReady();\n            __gzip = data;\n            cbReady();\n        });\n        fs.readFile(cachePath.raw, function read(err, data) {\n            if (err)\n                return cbReady();\n            __raw = data;\n            cbReady();\n        });\n    }\n\n    function init(callback) {\n        items.forEach(function(item) {\n            if (item.slice(-3) === '.js' || item.slice(-4) === '.css')\n                addFile(path.join(rfr.root, item));\n            else\n                addFolder(path.join(rfr.root, item));\n        });\n\n\n        getMTimes(function() {\n            console.log('Most recent mtime(' + type + '): ' + mostRecentMTime);\n            console.log('Cached recent mtime(' + type + '): ' + cacheMTime);\n\n            if (mostRecentMTime > cacheMTime) {\n                console.log('Minify ' + type);\n                minify(callback);\n            } else {\n                console.log('Load ' + type + ' from cache');\n                loadFromCache(callback);\n            }\n        });\n        initialized = true;\n    }\n\n    return (serve);\n}\n\nmodule.exports = serve;"
  },
  {
    "path": "includes/servers/public_server.js",
    "content": "var restify = require('restify');\nvar rfr = require('rfr');\nvar path = require('path');\n\nvar server = restify.plugins.serveStatic({\n\tdirectory: path.join(rfr.root, '/public/')\n});\n\nmodule.exports = server;"
  },
  {
    "path": "includes/servers/static_file_server.js",
    "content": "'use strict';\n\nvar fs = require('fs');\nvar path = require('path');\nvar mime = require('mime');\nvar escapeRE = require('escape-regexp-component');\n\nfunction serveStatic(opts) {\n    opts = opts || {};\n\n    var p = path.normalize(opts.directory).replace(/\\\\/g, '/');\n    var re = new RegExp('^' + escapeRE(p) + '/?.*');\n\n    function serveFileFromStats(file, err, stats, isGzip, req, res, next) {\n        if (err) {\n            res.writeHead(404, \"Not Found\");\n            next();\n            return;\n        } else if (!stats.isFile()) {\n            res.writeHead(404, \"Not Found\");\n            next()\n            return;\n        }\n\n        if (res.handledGzip && isGzip) {\n            res.handledGzip();\n        }\n\n        var fstream = fs.createReadStream(file + (isGzip ? '.gz' : ''));\n        var maxAge = opts.maxAge === undefined ? 3600 : opts.maxAge;\n        fstream.once('open', function(fd) {\n            res.cache({\n                maxAge: maxAge\n            });\n            res.set('Content-Length', stats.size);\n\n            var mimeType = mime.getType(file);\n            if (mimeType == 'application/vnd.groove-tool-template')\n                mimeType = 'text/html';\n\n            res.set('Content-Type', mimeType);\n            res.set('Last-Modified', stats.mtime);\n            res.setHeader('Access-Control-Allow-Origin', '*');\n\n            if (opts.charSet) {\n                var type = res.getHeader('Content-Type') +\n                    '; charset=' + opts.charSet;\n                res.setHeader('Content-Type', type);\n            }\n\n            if (opts.etag) {\n                res.set('ETag', opts.etag(stats, opts));\n            }\n            res.writeHead(200);\n            fstream.pipe(res);\n            fstream.once('end', function() {\n                next(false);\n            });\n        });\n    }\n\n    function serveNormal(file, req, res, next) {\n        fs.stat(file, function(err, stats) {\n            if (!err && stats.isDirectory() && opts.default) {\n                // Serve an index.html page or similar\n                file = path.join(file, opts.default);\n                fs.stat(file, function(dirErr, dirStats) {\n                    serveFileFromStats(file,\n                        dirErr,\n                        dirStats,\n                        false,\n                        req,\n                        res,\n                        next);\n                });\n            } else {\n                serveFileFromStats(file,\n                    err,\n                    stats,\n                    false,\n                    req,\n                    res,\n                    next);\n            }\n        });\n    }\n\n    function serve(req, res, next) {\n        var file;\n\n        if (opts.file) {\n            //serves a direct file\n            file = path.join(opts.directory,\n                decodeURIComponent(opts.file));\n        } else {\n            file = path.join(opts.directory,\n                decodeURIComponent(req.path()));\n        }\n\n        if (opts.suffix)\n            file += opts.suffix;\n\n        if (req.method !== 'GET' && req.method !== 'HEAD') {\n            res.writeHead(404, \"Not Found\");\n            next();\n            return;\n        }\n\n        if (!re.test(file.replace(/\\\\/g, '/'))) {\n            res.writeHead(404, \"Not Found\");\n            next();\n            return;\n        }\n\n        if (opts.match && !opts.match.test(file)) {\n            res.writeHead(404, \"Not Found\");\n            next();\n            return;\n        }\n\n        if (opts.gzip && req.acceptsEncoding('gzip')) {\n            fs.stat(file + '.gz', function(err, stats) {\n                if (!err) {\n                    res.setHeader('Content-Encoding', 'gzip');\n                    serveFileFromStats(file,\n                        err,\n                        stats,\n                        true,\n                        req,\n                        res,\n                        next);\n                } else {\n                    serveNormal(file, req, res, next);\n                }\n            });\n        } else {\n            serveNormal(file, req, res, next);\n        }\n\n    }\n\n    return (serve);\n}\n\nmodule.exports = serveStatic;"
  },
  {
    "path": "includes/test/planning.test.js",
    "content": "var hippie = require('hippie');\nvar rfr = require('rfr');\nvar expect = require('chai').expect;\nvar assert = require('chai').assert;\nvar testHelper = rfr('includes/test.js');\nvar db = rfr('includes/models');\n\ndescribe('API server for planning', function() {\n\t/// Data for user registration\n\tvar email = 'email' + Math.random() + '@example.com';\n\tvar login = 'login' + Math.random();\n\tvar password = 'password' + Math.random();\n\tvar registeredUserId = null;\n\tvar auth_code = null;\n\n\tvar wallet_1_name = 'name ' + Math.random();\n\tvar wallet_1_currency = 'UAH';\n\tvar wallet_1_id = null;\n\tvar wallet_1_initial_amount = 200.99;\n\n\tvar wallet_2_name = 'name2 ' + Math.random();\n\tvar wallet_2_currency = 'USD';\n\tvar wallet_2_id = null;\n\tvar wallet_2_initial_amount = 100.99;\n\n\tvar plan_1_name = 'Test Name';\n\tvar plan_1_currency = 'UAH';\n\tvar plan_1_goal_balance = 1000;\n\tvar plan_1_goal_datetime = (Date.now() / 1000 | 0) + 60 * 24 * 60 * 60;\n\n\tvar plan_1_id = null;\n\tvar plan_1 = null;\n\n\tvar plan_2_name = 'Test 2 Name';\n\tvar plan_2_currency = 'USD';\n\tvar plan_2_goal_balance = 1000;\n\tvar plan_2_goal_datetime = (Date.now() / 1000 | 0) + 60 * 24 * 60 * 60;\n\n\tvar plan_2_id = null;\n\tvar plan_2 = null;\n\n\tit('registers user', function(done) {\n\t\ttestHelper.sendPost('/api/users', {\n\t\t\temail: email,\n\t\t\tlogin: login,\n\t\t\tpassword: password\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.id).to.be.a('number');\n\t\t\texpect(data.body.email).to.be.a('string');\n\t\t\texpect(data.body.email).to.equal(email);\n\t\t\texpect(data.body.login).to.be.a('string');\n\t\t\texpect(data.body.login).to.equal(login);\n\t\t\texpect(data.body.auth_code).to.be.a('string');\n\n\t\t\tassert.ok(data.cookies.is_logged_in_user);\n\t\t\texpect(data.cookies.logged_in_user).to.equal(data.body.auth_code);\n\n\t\t\tregisteredUserId = data.body.id;\n\t\t\tauth_code = data.body.auth_code;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('signs him in on registration', function(done) {\n\t\ttestHelper.sendGet('/api/users').then(function(data) {\n\t\t\texpect(data.body.id).to.be.a('number');\n\t\t\texpect(data.body.id).to.equal(registeredUserId);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns empty plans list for new user', function(done) {\n\t\ttestHelper.sendGet('/api/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(0);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('adds new wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets', {\n\t\t\tname: wallet_1_name,\n\t\t\tcurrency: wallet_1_currency\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.name).to.equal(wallet_1_name);\n\t\t\texpect(data.body.total).to.equal(0);\n\t\t\texpect(data.body.status).to.equal('active');\n\t\t\texpect(data.body.currency).to.equal(wallet_1_currency);\n\n\t\t\twallet_1_id = data.body.id;\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us add some income transaction to wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets/' + wallet_1_id + '/transactions/', {\n\t\t\twallet_id: wallet_1_id,\n\t\t\tamount: wallet_1_initial_amount,\n\t\t\tdescription: 'Initial'\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.amount).to.equal(wallet_1_initial_amount);\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allow to create new plan', function(done) {\n\t\tvar newData = {\n\t\t\tname: plan_1_name,\n\t\t\tgoal_currency: plan_1_currency,\n\t\t\tgoal_balance: plan_1_goal_balance,\n\t\t\tgoal_datetime: plan_1_goal_datetime,\n\t\t\twallets: [wallet_1_id]\n\t\t};\n\n\t\ttestHelper.sendPost('/api/plans', newData).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.name).to.equal(newData.name);\n\t\t\texpect(data.body.goal_currency).to.equal(newData.goal_currency);\n\t\t\texpect(data.body.start_currency).to.equal(newData.goal_currency);\n\t\t\texpect(data.body.goal_balance).to.equal(newData.goal_balance);\n\n\t\t\texpect(data.body.goal_datetime).to.equal(plan_1_goal_datetime);\n\n\t\t\texpect(data.body.wallets).to.be.a('array');\n\t\t\texpect(data.body.wallets).to.have.length(1);\n\n\t\t\texpect(data.body.wallets[0].id).to.equal(wallet_1_id);\n\n\t\t\t/// start_balance should be calculated from wallets\n\t\t\texpect(data.body.start_balance).to.equal(wallet_1_initial_amount);\n\n\t\t\tplan_1_id = data.body.id;\n\t\t\tplan_1 = data.body;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns plans list with 1 plan now', function(done) {\n\t\ttestHelper.sendGet('/api/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(1);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns plans list for wallet', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id + '/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(1);\n\t\t\texpect(data.body[0].id).to.equal(plan_1_id);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allow to edit plan', function(done) {\n\t\tplan_1_name = plan_1_name + 'updated';\n\t\tplan_1_currency = 'USD';\n\t\tplan_1_goal_balance = 2000;\n\t\tplan_1_goal_datetime = plan_1_goal_datetime + 60 * 24 * 60 * 60; // 120 days total\n\n\t\tvar newData = {\n\t\t\tname: plan_1_name,\n\t\t\tgoal_currency: plan_1_currency,\n\t\t\tgoal_balance: plan_1_goal_balance,\n\t\t\tgoal_datetime: plan_1_goal_datetime,\n\t\t\twallets: [wallet_1_id]\n\t\t};\n\n\t\ttestHelper.sendPut('/api/plans/' + plan_1_id, newData).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\n\t\t\t/// Updated fields\n\t\t\texpect(data.body.name).to.equal(newData.name);\n\t\t\texpect(data.body.goal_currency).to.equal(newData.goal_currency);\n\t\t\texpect(data.body.goal_balance).to.equal(newData.goal_balance);\n\t\t\texpect(data.body.goal_datetime).to.equal(plan_1_goal_datetime);\n\n\t\t\t// Kept fields\n\t\t\texpect(data.body.wallets).to.be.a('array');\n\t\t\texpect(data.body.wallets).to.have.length(1);\n\t\t\texpect(data.body.wallets[0].id).to.equal(wallet_1_id);\n\n\t\t\texpect(data.body.start_currency).to.equal(plan_1.start_currency);\n\t\t\texpect(data.body.start_balance).to.equal(plan_1.start_balance);\n\t\t\texpect(data.body.start_datetime).to.equal(plan_1.start_datetime);\n\n\t\t\tplan_1 = data.body;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('adds another new wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets', {\n\t\t\tname: wallet_2_name,\n\t\t\tcurrency: wallet_2_currency\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.name).to.equal(wallet_2_name);\n\t\t\texpect(data.body.total).to.equal(0);\n\t\t\texpect(data.body.status).to.equal('active');\n\t\t\texpect(data.body.currency).to.equal(wallet_2_currency);\n\n\t\t\twallet_2_id = data.body.id;\n\t\t\tdone();\n\t\t});\n\t});\n\n\n\tit('allow to edit plan, adding another wallets to it', function(done) {\n\n\t\tvar newData = {\n\t\t\twallets: [wallet_1_id, wallet_2_id]\n\t\t};\n\n\t\ttestHelper.sendPut('/api/plans/' + plan_1_id, newData).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\n\t\t\t/// Updated fields\n\t\t\texpect(data.body.wallets).to.be.a('array');\n\t\t\texpect(data.body.wallets).to.have.length(2);\n\n\t\t\tvar found_wallet_1 = false;\n\t\t\tvar found_wallet_2 = false;\n\t\t\tfor (var k in data.body.wallets) {\n\t\t\t\tif (data.body.wallets[k].id == wallet_1_id)\n\t\t\t\t\tfound_wallet_1 = true;\n\t\t\t\tif (data.body.wallets[k].id == wallet_2_id)\n\t\t\t\t\tfound_wallet_2 = true;\n\t\t\t}\n\n\t\t\tassert.ok(found_wallet_1);\n\t\t\tassert.ok(found_wallet_2);\n\n\t\t\t// Kept fields\n\t\t\texpect(data.body.name).to.equal(plan_1.name);\n\t\t\texpect(data.body.goal_currency).to.equal(plan_1.goal_currency);\n\t\t\texpect(data.body.goal_balance).to.equal(plan_1.goal_balance);\n\t\t\texpect(data.body.goal_datetime).to.equal(plan_1.goal_datetime);\n\t\t\texpect(data.body.start_currency).to.equal(plan_1.start_currency);\n\t\t\texpect(data.body.start_balance).to.equal(plan_1.start_balance);\n\t\t\texpect(data.body.start_datetime).to.equal(plan_1.start_datetime);\n\n\t\t\tplan_1 = data.body;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\n\tit('returns plans list for wallet with 2 wallets ids in plan', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id + '/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(1);\n\t\t\texpect(data.body[0].id).to.equal(plan_1_id);\n\n\t\t\tvar found_wallet_1 = false;\n\t\t\tvar found_wallet_2 = false;\n\t\t\tfor (var k in data.body[0].wallets) {\n\t\t\t\tif (data.body[0].wallets[k].id == wallet_1_id)\n\t\t\t\t\tfound_wallet_1 = true;\n\t\t\t\tif (data.body[0].wallets[k].id == wallet_2_id)\n\t\t\t\t\tfound_wallet_2 = true;\n\t\t\t}\n\n\t\t\tassert.ok(found_wallet_1);\n\t\t\tassert.ok(found_wallet_2);\n\t\t\tdone();\n\t\t});\n\t});\n\n\n\tit('allow to create another plan', function(done) {\n\t\tvar newData = {\n\t\t\tname: plan_2_name,\n\t\t\tgoal_currency: plan_2_currency,\n\t\t\tgoal_balance: plan_2_goal_balance,\n\t\t\tgoal_datetime: plan_2_goal_datetime,\n\t\t\twallets: [wallet_1_id, wallet_2_id]\n\t\t};\n\n\t\ttestHelper.sendPost('/api/plans', newData).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.name).to.equal(newData.name);\n\t\t\texpect(data.body.goal_currency).to.equal(newData.goal_currency);\n\t\t\texpect(data.body.start_currency).to.equal(newData.goal_currency);\n\t\t\texpect(data.body.goal_balance).to.equal(newData.goal_balance);\n\n\t\t\texpect(data.body.goal_datetime).to.equal(plan_2_goal_datetime);\n\n\t\t\texpect(data.body.wallets).to.be.a('array');\n\t\t\texpect(data.body.wallets).to.have.length(2);\n\n\t\t\tplan_2_id = data.body.id;\n\t\t\tplan_2 = data.body;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns plans list for wallet with 2 plans', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/' + wallet_2_id + '/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(2);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allow to edit plan setting goal_datetime to the past. For testing', function(done) {\n\n\t\tvar newData = {\n\t\t\tgoal_datetime: (Date.now() / 1000 | 0)\n\t\t};\n\n\t\ttestHelper.sendPut('/api/plans/' + plan_2_id, newData).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.goal_datetime).to.equal(newData.goal_datetime);\n\n\t\t\tplan_2 = data.body;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns plan with status == finished now', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/' + wallet_2_id + '/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(2);\n\n\t\t\tvar foundPlan = null;\n\t\t\tfor (var k in data.body)\n\t\t\t\tif (data.body[k].id == plan_2_id)\n\t\t\t\t\tfoundPlan = data.body[k];\n\n\t\t\texpect(foundPlan).to.not.equal(null);\n\t\t\texpect(foundPlan.status).to.equal('finished');\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns plan with status == finished now', function(done) {\n\t\ttestHelper.sendGet('/api/plans/' + plan_2_id).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.status).to.equal('finished');\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\n\tit('lets us remove plan', function(done) {\n\t\ttestHelper.sendDelete('/api/plans/' + plan_1_id, {}).then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns list without removed plan now', function(done) {\n\t\ttestHelper.sendGet('/api/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(1);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us remove second plan', function(done) {\n\t\ttestHelper.sendDelete('/api/plans/' + plan_2_id, {}).then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns empty plans list now', function(done) {\n\t\ttestHelper.sendGet('/api/plans').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(0);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tvar remove_account_code = null;\n\n\tit('allow to initialize remove account procedure for signed in user', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\tdb.User.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: registeredUserId\n\t\t\t\t}\n\t\t\t}).then(function(user) {\n\n\t\t\t\texpect(registeredUserId).to.equal(user.id);\n\t\t\t\tremove_account_code = user.remove_account_code;\n\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n\tit('allow to finish remove account procedure', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {\n\t\t\tcode: remove_account_code\n\t\t}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\t/// double check that user is removed\n\t\t\tdb.User.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: registeredUserId\n\t\t\t\t}\n\t\t\t}).then(function(user) {\n\t\t\t\texpect(user).to.equal(null);\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n});"
  },
  {
    "path": "includes/test/stats.test.js",
    "content": "var hippie = require('hippie');\nvar rfr = require('rfr');\nvar expect = require('chai').expect;\nvar assert = require('chai').assert;\nvar testHelper = rfr('includes/test.js');\nvar db = rfr('includes/models');\n\ndescribe('API server for statistics', function() {\n\n\tvar email = 'email' + Math.random() + '@example.com';\n\tvar login = 'login' + Math.random();\n\tvar password = 'password' + Math.random();\n\tvar registeredUserId = null;\n\tvar auth_code = null;\n\n\tvar wallet_1_name = 'name ' + Math.random();\n\tvar wallet_1_currency = 'USD';\n\tvar wallet_1_id = null;\n\n\tvar wallet_2_name = 'name ' + Math.random();\n\tvar wallet_2_currency = 'UAH';\n\tvar wallet_2_id = null;\n\n\tit('registers user', function(done) {\n\t\ttestHelper.sendPost('/api/users', {\n\t\t\temail: email,\n\t\t\tlogin: login,\n\t\t\tpassword: password\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.id).to.be.a('number');\n\n\t\t\tregisteredUserId = data.body.id;\n\t\t\tauth_code = data.body.auth_code;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('adds new wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets', {\n\t\t\tname: wallet_1_name,\n\t\t\tcurrency: wallet_1_currency\n\t\t}).then(function(data) {\n\t\t\twallet_1_id = data.body.id;\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('adds new wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets', {\n\t\t\tname: wallet_2_name,\n\t\t\tcurrency: wallet_2_currency\n\t\t}).then(function(data) {\n\t\t\twallet_2_id = data.body.id;\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us add some income transaction to wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets/' + wallet_1_id + '/transactions/', {\n\t\t\twallet_id: wallet_1_id,\n\t\t\tamount: 10,\n\t\t\tdescription: 'Initial'\n\t\t}).then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us add some expense transaction to wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets/' + wallet_1_id + '/transactions/', {\n\t\t\twallet_id: wallet_1_id,\n\t\t\tamount: -99,\n\t\t\tdescription: 'Initial'\n\t\t}).then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us add some income transaction to wallet 2', function(done) {\n\t\ttestHelper.sendPost('/api/wallets/' + wallet_2_id + '/transactions/', {\n\t\t\twallet_id: wallet_2_id,\n\t\t\tamount: 99,\n\t\t\tdescription: 'Initial'\n\t\t}).then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us add some income transaction to wallet 2', function(done) {\n\t\ttestHelper.sendPost('/api/wallets/' + wallet_2_id + '/transactions/', {\n\t\t\twallet_id: wallet_2_id,\n\t\t\tamount: 99,\n\t\t\tdescription: 'Initial'\n\t\t}).then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('gets week transactions', function(done) {\n\t\ttestHelper.sendGet('/api/stats/week?utcoffset=-3').then(function(data) {\n\n\n\t\t\texpect(data.body).to.have.length(7);\n\t\t\texpect(data.body[0].stats).to.be.an('object');\n\t\t\texpect(data.body[0].stats[wallet_1_currency]).to.be.an('object');\n\t\t\texpect(data.body[0].stats[wallet_2_currency]).to.be.an('object');\n\n\t\t\texpect(data.body[0].stats[wallet_1_currency].expense).to.equal(99);\n\t\t\texpect(data.body[0].stats[wallet_2_currency].expense).to.equal(0);\n\t\t\texpect(data.body[0].stats[wallet_1_currency].profit).to.equal(10);\n\t\t\texpect(data.body[0].stats[wallet_2_currency].profit).to.equal(198);\n\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('gets by wallet week transactions', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/'+wallet_1_id+'/stats/week?utcoffset=-3').then(function(data) {\n\n\n\t\t\texpect(data.body).to.have.length(7);\n\t\t\texpect(data.body[0].stats).to.be.an('object');\n\t\t\texpect(data.body[0].stats[wallet_1_currency]).to.be.an('object');\n\n\t\t\texpect(data.body[0].stats[wallet_1_currency].expense).to.equal(99);\n\t\t\texpect(data.body[0].stats[wallet_1_currency].profit).to.equal(10);\n\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('gets by wallet2 week transactions', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/'+wallet_2_id+'/stats/week?utcoffset=-3').then(function(data) {\n\t\t\texpect(data.body).to.have.length(7);\n\t\t\texpect(data.body[0].stats).to.be.an('object');\n\t\t\texpect(data.body[0].stats[wallet_2_currency]).to.be.an('object');\n\n\t\t\texpect(data.body[0].stats[wallet_2_currency].expense).to.equal(0);\n\t\t\texpect(data.body[0].stats[wallet_2_currency].profit).to.equal(198);\n\t\t\t\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('shoud not return others wallets stats', function(done) {\n\t\ttestHelper.sendGetAndExpectStatus('/api/wallets/1/stats/week?utcoffset=-3', \"!200\").then(function() {\n\t\t\tdone();\n\t\t});\n\t});\n\n\n\tit('gets year transactions', function(done) {\n\t\ttestHelper.sendGet('/api/stats/year?utcoffset=-3').then(function(data) {\n\n\n\t\t\texpect(data.body).to.have.length(12);\n\t\t\texpect(data.body[0].stats).to.be.an('object');\n\t\t\texpect(data.body[0].stats[wallet_1_currency]).to.be.an('object');\n\t\t\texpect(data.body[0].stats[wallet_2_currency]).to.be.an('object');\n\n\t\t\texpect(data.body[0].stats[wallet_1_currency].expense).to.equal(99);\n\t\t\texpect(data.body[0].stats[wallet_2_currency].expense).to.equal(0);\n\t\t\texpect(data.body[0].stats[wallet_1_currency].profit).to.equal(10);\n\t\t\texpect(data.body[0].stats[wallet_2_currency].profit).to.equal(198);\n\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\n\tvar remove_account_code = null;\n\n\tit('allow to initialize remove account procedure for signed in user', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\tdb.User.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: registeredUserId\n\t\t\t\t}\n\t\t\t}).then(function(user) {\n\t\t\t\tremove_account_code = user.remove_account_code;\n\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n\tit('allow to finish remove account procedure', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {\n\t\t\tcode: remove_account_code\n\t\t}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\t\t\tdone();\n\t\t});\n\t});\n\n});"
  },
  {
    "path": "includes/test/wallet.test.js",
    "content": "var hippie = require('hippie');\nvar rfr = require('rfr');\nvar expect = require('chai').expect;\nvar assert = require('chai').assert;\nvar testHelper = rfr('includes/test.js');\nvar db = rfr('includes/models');\n\ndescribe('API server', function() {\n\n\t/// Data for user registration\n\tvar email = 'email' + Math.random() + '@example.com';\n\tvar login = 'login' + Math.random();\n\tvar password = 'password' + Math.random();\n\tvar registeredUserId = null;\n\tvar auth_code = null;\n\n\tvar wallet_1_name = 'name ' + Math.random();\n\tvar wallet_1_currency = 'USD';\n\tvar wallet_1_id = null;\n\tvar wallet_1_initial_amount = 200.99;\n\n\tit('registers user', function(done) {\n\t\ttestHelper.sendPost('/api/users', {\n\t\t\temail: email,\n\t\t\tlogin: login,\n\t\t\tpassword: password\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.id).to.be.a('number');\n\t\t\texpect(data.body.email).to.be.a('string');\n\t\t\texpect(data.body.email).to.equal(email);\n\t\t\texpect(data.body.login).to.be.a('string');\n\t\t\texpect(data.body.login).to.equal(login);\n\t\t\texpect(data.body.auth_code).to.be.a('string');\n\n\t\t\texpect(data.cookies.is_logged_in_user).to.be.ok;\n\t\t\texpect(data.cookies.logged_in_user).to.equal(data.body.auth_code);\n\n\t\t\tregisteredUserId = data.body.id;\n\t\t\tauth_code = data.body.auth_code;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('signs him in on registration', function(done) {\n\t\ttestHelper.sendGet('/api/users').then(function(data) {\n\t\t\texpect(data.body.id).to.be.a('number');\n\t\t\texpect(data.body.id).to.equal(registeredUserId);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns empty wallets list for new (not demo) user', function(done) {\n\t\ttestHelper.sendGet('/api/wallets').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(0);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allows him to sign out', function(done) {\n\t\ttestHelper.sendPost('/api/users/signout', null).then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('does not allow to remove account for signed out user', function(done) {\n\t\ttestHelper.sendGetAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', \"!200\").then(function() {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('does not show signed out user info', function(done) {\n\t\ttestHelper.sendGetAndExpectStatus('/api/users', 500).then(function() {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allows him to sign in', function(done) {\n\t\ttestHelper.sendPost('/api/users/signin', {\n\t\t\tusername: login,\n\t\t\tpassword: password\n\t\t}).then(function(data) {\n\t\t\texpect(data.cookies.is_logged_in_user).to.be.ok;\n\t\t\texpect(data.cookies.logged_in_user).to.equal(data.body.auth_code);\n\t\t\texpect(data.body.id).to.equal(registeredUserId);\n\n\t\t\tauth_code = data.body.auth_code;\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allows to confirm that user is signed in', function(done) {\n\t\ttestHelper.sendGet('/api/users').then(function(data) {\n\t\t\texpect(data.body.id).to.be.a('number');\n\t\t\texpect(data.body.id).to.equal(registeredUserId);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('adds new wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets', {\n\t\t\tname: wallet_1_name,\n\t\t\tcurrency: wallet_1_currency\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.name).to.equal(wallet_1_name);\n\t\t\texpect(data.body.total).to.equal(0);\n\t\t\texpect(data.body.status).to.equal('active');\n\t\t\texpect(data.body.currency).to.equal(wallet_1_currency);\n\n\t\t\twallet_1_id = data.body.id;\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns updated wallets list', function(done) {\n\t\ttestHelper.sendGet('/api/wallets').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(1);\n\t\t\texpect(data.body[0].id).to.equal(wallet_1_id);\n\t\t\texpect(data.body[0].name).to.equal(wallet_1_name);\n\t\t\texpect(data.body[0].status).to.equal('active');\n\t\t\texpect(data.body[0].origin).to.equal('mine');\n\t\t\texpect(data.body[0].currency).to.equal(wallet_1_currency);\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us edit wallet name and currency', function(done) {\n\t\twallet_1_name = wallet_1_name + '_updated';\n\t\twallet_1_currency = 'EUR';\n\t\ttestHelper.sendPut('/api/wallets/' + wallet_1_id, {\n\t\t\tname: wallet_1_name,\n\t\t\tcurrency: wallet_1_currency\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.name).to.equal(wallet_1_name);\n\t\t\texpect(data.body.currency).to.equal(wallet_1_currency);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('lets us add some income transaction to wallet', function(done) {\n\t\ttestHelper.sendPost('/api/wallets/' + wallet_1_id + '/transactions/', {\n\t\t\twallet_id: wallet_1_id,\n\t\t\tamount: wallet_1_initial_amount,\n\t\t\tdescription: 'Initial'\n\t\t}).then(function(data) {\n\t\t\texpect(data.body).to.be.a('object');\n\t\t\texpect(data.body.amount).to.equal(wallet_1_initial_amount);\n\t\t\texpect(data.body.wallet_id).to.equal(wallet_1_id);\n\t\t\texpect(data.body.user_id).to.equal(registeredUserId);\n\t\t\texpect(data.body.description).to.equal('Initial');\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('updates wallet total with transactions', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id).then(function(data) {\n\t\t\texpect(data.body).to.be.a('object');\n\t\t\texpect(data.body.total).to.equal(wallet_1_initial_amount);\n\t\t\tdone();\n\t\t});\n\t});\n\n\t// wallet_1_initial_amount = 200.99\n\tvar testTransactions = [];\n\ttestTransactions.push({\n\t\tamount: -0.99,\n\t\tshouldSetTotalTo: wallet_1_initial_amount - 0.99, // 200\n\t\twhenRemovedShouldSetTotalTo: 900\n\t});\n\ttestTransactions.push({\n\t\tamount: -100,\n\t\tshouldSetTotalTo: wallet_1_initial_amount - 0.99 - 100, // 100\n\t\twhenRemovedShouldSetTotalTo: 900\n\t});\n\ttestTransactions.push({\n\t\tsubtype: 'setup',\n\t\tamount: 201, /// setup amount is +101.00\n\t\tshouldSetTotalTo: 201, //// setup transaction set wallet total to its amount,\n\t\twhenRemovedShouldSetTotalTo: 900\n\t});\n\ttestTransactions.push({\n\t\tamount: 99,\n\t\tshouldSetTotalTo: 300,\n\t\twhenRemovedShouldSetTotalTo: 900\n\t});\n\ttestTransactions.push({\n\t\tsubtype: 'setup',\n\t\tamount: 1000, /// setup amount is +700.00\n\t\tshouldSetTotalTo: 1000,\n\t\twhenRemovedShouldSetTotalTo: 100.99 //// initial - last\n\t});\n\ttestTransactions.push({\n\t\tamount: -100,\n\t\tshouldSetTotalTo: 900,\n\t\twhenRemovedShouldSetTotalTo: 200.99 /// initial\n\t});\n\n\ttestTransactions.forEach(function(testTransaction, index, array) {\n\t\tit('lets us add another sample transaction', function(done) {\n\t\t\tvar data = {\n\t\t\t\twallet_id: wallet_1_id,\n\t\t\t\tamount: testTransaction.amount,\n\t\t\t\tdescription: 'fasd'\n\t\t\t};\n\t\t\tif (typeof(testTransaction.subtype) !== 'undefined')\n\t\t\t\tdata.subtype = testTransaction.subtype;\n\n\t\t\ttestHelper.sendPost('/api/wallets/' + wallet_1_id + '/transactions/', data).then(function(data) {\n\t\t\t\texpect(data.body).to.be.a('object');\n\t\t\t\tif (data.body.subtype === 'confirmed')\n\t\t\t\t\texpect(data.body.amount).to.equal(testTransaction.amount);\n\n\t\t\t\tarray[index]['id'] = data.body.id;\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\n\t\tit('updates wallet total with sample transactions', function(done) {\n\t\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id).then(function(data) {\n\t\t\t\texpect(data.body).to.be.a('object');\n\t\t\t\texpect(data.body.total).to.equal(testTransaction.shouldSetTotalTo);\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n\tit('should allow to check that all transactions added', function(done) {\n\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id + '/transactions/').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\tvar somethingIsNotFound = false;\n\t\t\ttestTransactions.forEach(function(testTransaction) {\n\t\t\t\tvar found = false;\n\t\t\t\tfor (var k in data.body)\n\t\t\t\t\tif (data.body[k].id == testTransaction.id)\n\t\t\t\t\t\tfound = true;\n\n\t\t\t\tif (!found)\n\t\t\t\t\tsomethingIsNotFound = true;\n\t\t\t});\n\t\t\texpect(somethingIsNotFound).to.equal(false);\n\n\t\t\tdone();\n\t\t});\n\t});\n\n\ttestTransactions.forEach(function(testTransaction) {\n\t\tit('should let us remove transaction', function(done) {\n\t\t\ttestHelper.sendDelete('/api/wallets/' + wallet_1_id + '/transactions/' + testTransaction.id).then(function(data) {\n\t\t\t\texpect(data.body).to.equal(true);\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t\tit('should allow to double check that transaction is removed', function(done) {\n\t\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id + '/transactions').then(function(data) {\n\t\t\t\texpect(data.body).to.be.a('array');\n\t\t\t\tvar found = false;\n\t\t\t\tfor (var k in data.body)\n\t\t\t\t\tif (data.body[k].id == testTransaction.id)\n\t\t\t\t\t\tfound = true;\n\t\t\t\texpect(found).to.equal(false);\n\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t\tit('updates wallet total when transaction is removed', function(done) {\n\t\t\ttestHelper.sendGet('/api/wallets/' + wallet_1_id).then(function(data) {\n\t\t\t\texpect(data.body).to.be.a('object');\n\t\t\t\texpect(+parseFloat(data.body.total).toFixed(2)).to.equal(testTransaction.whenRemovedShouldSetTotalTo);\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n\tit('does not allow to remove wallet instantly', function(done) {\n\t\ttestHelper.sendDeleteAndExpectStatus('/api/wallets/' + wallet_1_id, '!200').then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('hides wallet with PUT method', function(done) {\n\t\ttestHelper.sendPut('/api/wallets/' + wallet_1_id, {\n\t\t\tstatus: 'hidden'\n\t\t}).then(function(data) {\n\t\t\texpect(data.body.status).to.equal('hidden');\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allow to remove hidden wallet', function(done) {\n\t\ttestHelper.sendDelete('/api/wallets/' + wallet_1_id).then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('returns empty wallets list now, as we have removed the only wallet', function(done) {\n\t\ttestHelper.sendGet('/api/wallets').then(function(data) {\n\t\t\texpect(data.body).to.be.a('array');\n\t\t\texpect(data.body).to.have.length(0);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tvar remove_account_code = null;\n\n\tit('allow to initialize remove account procedure for signed in user', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\tdb.User.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: registeredUserId\n\t\t\t\t}\n\t\t\t}).then(function(user) {\n\n\t\t\t\texpect(registeredUserId).to.equal(user.id);\n\t\t\t\tremove_account_code = user.remove_account_code;\n\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n\tit('does not allow to finish account remove procedure with wrong remove_account_code', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {\n\t\t\tcode: 'wrong'\n\t\t}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(false);\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('does not allow to finish account remove procedure with good remove_account_code, but wrong user_id parameter', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId - 2 + '/removeaccount', {\n\t\t\tcode: remove_account_code\n\t\t}, '!200').then(function(data) {\n\t\t\tdone();\n\t\t});\n\t});\n\n\tit('allow to finish remove account procedure', function(done) {\n\t\ttestHelper.sendPostAndExpectStatus('/api/users/' + registeredUserId + '/removeaccount', {\n\t\t\tcode: remove_account_code\n\t\t}, '200').then(function(data) {\n\t\t\texpect(data.body).to.equal(true);\n\n\t\t\t/// double check that user is removed\n\t\t\tdb.User.findOne({\n\t\t\t\twhere: {\n\t\t\t\t\tid: registeredUserId\n\t\t\t\t}\n\t\t\t}).then(function(user) {\n\t\t\t\texpect(user).to.equal(null);\n\t\t\t\tdone();\n\t\t\t});\n\t\t});\n\t});\n\n});"
  },
  {
    "path": "includes/test.js",
    "content": "var hippie = require('hippie');\nvar expect = require('chai').expect;\nvar Sequelize = require('sequelize');\nvar rfr = require('rfr');\nvar config = rfr('includes/config.js');\n\nvar base = 'http://localhost:' + config.port;\nvar timeout = 500;\n\nvar prepareResolve = function(err, res, body, resolve) {\n\tif (err) throw err;\n\tvar headers = res.headers;\n\tvar cookies = {};\n\n\tif (typeof(headers['set-cookie']) !== 'undefined' && headers['set-cookie']) {\n\t\theaders['set-cookie'].forEach(function(cookie) {\n\t\t\tvar parts = cookie.split('=');\n\t\t\tcookies[parts.shift().trim()] = decodeURI(parts.join('=').split('; ')[0]);\n\t\t});\n\t}\n\n\tvar bodyTypeIsGood = false;\n\tif (Array.isArray(body) || (typeof body === 'object' && Object.prototype.toString.call(body) === '[object Array]'))\n\t\tbodyTypeIsGood = true;\n\telse if (body !== null && typeof body === 'object')\n\t\tbodyTypeIsGood = true;\n\telse if (typeof body === 'boolean')\n\t\tbodyTypeIsGood = true;\n\n\texpect(bodyTypeIsGood).to.equal(true, \"Invalid response body. Should be one of(array, object, boolean)\");\n\tresolve({\n\t\tbody: body,\n\t\theaders: headers,\n\t\tcookies: cookies\n\t});\n};\n\nvar prepareResolveStatus = function(err, res, body, resolve, status) {\n\tvar resStatus = 0;\n\tif (typeof res !== 'undefined' && typeof res.statusCode !== 'undefined')\n\t\tresStatus = res.statusCode;\n\tif (typeof(status) === 'string' && status.substr(0, 1) === '!') {\n\t\tvar statusToNotExpect = parseInt(status.split('!').join(''), 10);\n\t\tif (statusToNotExpect == resStatus) {\n\t\t\tconsole.error(\"Body:\");\n\t\t\tconsole.error(body);\n\t\t}\n\t\texpect(resStatus).to.not.equal(statusToNotExpect, \"Invalid response status code\");\n\t} else {\n\t\tvar statusToExpect = parseInt(status, 10);\n\t\tif (statusToExpect != resStatus) {\n\t\t\tconsole.error(\"Body:\");\n\t\t\tconsole.error(body);\n\t\t}\n\t\texpect(resStatus).to.equal(statusToExpect, \"Invalid response status code\");\n\t}\n\tresolve({\n\t\tbody: body\n\t});\n};\n\nvar prepareHippie = function(method, endpoint, data) {\n\tvar hippieCall = hippie()\n\t\t.json()\n\t\t.base(base)\n\t\t.timeout(timeout)\n\t\t.use(persistCookies);\n\n\tif (method == 'post') {\n\t\treturn hippieCall.post(endpoint).send(data);\n\t} else if (method == 'delete' || method == 'del') {\n\t\treturn hippieCall.del(endpoint);\n\t} else if (method == 'put') {\n\t\treturn hippieCall.put(endpoint).send(data);\n\t} else\n\t\treturn hippieCall.get(endpoint);\n}\n\nvar sendPostAndExpectStatus = function(endpoint, data, status) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('post', endpoint, data)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolveStatus(err, res, body, resolve, status);\n\t\t\t});\n\t});\n};\n\nvar sendPost = function(endpoint, data) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('post', endpoint, data)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolve(err, res, body, resolve);\n\t\t\t});\n\t});\n};\n\nvar sendGetAndExpectStatus = function(endpoint, status) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('get', endpoint)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolveStatus(err, res, body, resolve, status);\n\t\t\t});\n\t});\n};\n\nvar sendGet = function(endpoint) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('get', endpoint)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolve(err, res, body, resolve);\n\t\t\t});\n\t});\n};\n\nvar sendDeleteAndExpectStatus = function(endpoint, status) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('del', endpoint)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolveStatus(err, res, body, resolve, status);\n\t\t\t});\n\t});\n};\n\nvar sendDelete = function(endpoint) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('del', endpoint)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolve(err, res, body, resolve);\n\t\t\t});\n\t});\n};\n\nvar sendPut = function(endpoint, data) {\n\treturn new Sequelize.Promise(function(resolve, reject) {\n\t\tprepareHippie('put', endpoint, data)\n\t\t\t.end(function(err, res, body) {\n\t\t\t\tprepareResolve(err, res, body, resolve);\n\t\t\t});\n\t});\n};\n\nvar persistCookies = function(opts, next) {\n\topts.jar = true;\n\tnext(opts);\n};\n\nexports.sendPost = sendPost;\nexports.sendGet = sendGet;\nexports.sendPut = sendPut;\nexports.sendDelete = sendDelete;\nexports.sendPostAndExpectStatus = sendPostAndExpectStatus;\nexports.sendGetAndExpectStatus = sendGetAndExpectStatus;\nexports.sendDeleteAndExpectStatus = sendDeleteAndExpectStatus;"
  },
  {
    "path": "index.js",
    "content": "var CookieParser = require('restify-cookies');\nvar restify = require('restify');\nvar rfr = require('rfr');\nvar db = rfr('includes/models');\nvar routes = rfr('includes/routes');\nvar servers = rfr('includes/servers');\nvar pages = rfr('config/pages.json');\nvar config = rfr('includes/config.js');\nvar path = require('path');\n\nvar startServer = function(options, callback) {\n\toptions = options || {};\n\n\tvar server = restify.createServer({\n\t\tname: 'DimeShift',\n\t\thandleUncaughtExceptions: true\n\t});\n\n\t// Server settings\n\tserver.pre(restify.pre.sanitizePath());\n\tserver.on('uncaughtException', function(req, res, route, err) {\n\t\ttry {\n\t\t\tres.json(500, err);\n\t\t} catch (e) {\n\t\t\tres.end();\n\t\t}\n\t\treturn true;\n\t});\n\tdb.Sequelize.Promise.onPossiblyUnhandledRejection(function(reason) {\n\t\tthrow reason;\n\t});\n\tserver.use(CookieParser.parse);\n\tserver.use(restify.plugins.queryParser());\n\tserver.use(restify.plugins.bodyParser());\n\n\t// API routes\n\troutes(function(routes) {\n\t\troutes.forEach(function(route) {\n\t\t\tserver[route.method](route.route, route.handler);\n\t\t});\n\t});\n\n\t// Templates\n\tvar templatesDirectory = path.join(rfr.root, './public');\n\tserver.get('/jstemplates/*', servers.static_file_server({\n\t\tdirectory: templatesDirectory,\n\t\tsuffix: '.tpl'\n\t}));\n\n\t// Static files and css/js minification\n\tserver.get('/images/*', servers.images_server());\n\tserver.get('/scripts/*', servers.public_server);\n\tserver.get('/vendors/*', servers.public_server);\n\tserver.get('/resources/js.js', servers.minify_server('javascript'));\n\tserver.get('/css.css', servers.minify_server('css'));\n\n\t// App index html file\n\tfor (var k in pages) {\n\t\tserver.get(k, servers.index_server({\n\t\t\tindexFile: options.indexFile,\n\t\t\tindexDirectory: options.indexDirectory\n\t\t}));\n\t}\n\n\t// Sync db and start server\n\tdb.sequelize.sync()\n\t\t.then(function(err) {\n\t\t\tvar port = config.port || process.env.PORT || 8080;\n\t\t\tvar doStart = function(selectedPort) {\n\t\t\t\tserver.listen(selectedPort);\n\t\t\t\tconsole.log(\"Server started: http://localhost:\" + selectedPort + \"/\");\n\t\t\t\tif (typeof(callback) === 'function')\n\t\t\t\t\tcallback(selectedPort);\n\t\t\t}\n\n\t\t\tif (typeof(port) === 'function')\n\t\t\t\tport(doStart);\n\t\t\telse\n\t\t\t\tdoStart(port);\n\t\t});\n};\n\nif (!module.parent) {\n\tstartServer();\n} else {\n\tmodule.exports = startServer;\n}"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"dimeshift\",\n  \"version\": \"0.1.42\",\n  \"description\": \"Webapp to track and manage personal finances\",\n  \"main\": \"index.js\",\n  \"engines\": {\n    \"node\": \"10.15.2\"\n  },\n  \"scripts\": {\n    \"start\": \"node index.js\",\n    \"test\": \"node_modules/.bin/mocha includes/test\",\n    \"postinstall\": \"bower install\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/jeka-kiselyov/dimeshift.git\"\n  },\n  \"author\": \"Jeka Kiselyov <jeka911@gmail.com> (https://github.com/jeka-kiselyov)\",\n  \"license\": \"AGPL-3.0\",\n  \"keywords\": [\n    \"finance\",\n    \"financial\",\n    \"single page\",\n    \"single page application\",\n    \"application\",\n    \"saas\",\n    \"api\",\n    \"currency\",\n    \"economy\",\n    \"ukrainian\",\n    \"russian\",\n    \"backbonejs\",\n    \"restify\"\n  ],\n  \"bundledDependencies\": [\n    \"rfr\"\n  ],\n  \"dependencies\": {\n    \"bower\": \"^1.6.3\",\n    \"clean-css\": \"^4.2.1\",\n    \"escape-regexp-component\": \"^1.0.2\",\n    \"grunt-contrib-concat\": \"^1.0.0\",\n    \"grunt-exec\": \"^3.0.0\",\n    \"mime\": \"^2.4.2\",\n    \"moment\": \"^2.13.0\",\n    \"money\": \"^0.2.0\",\n    \"mysql\": \"^2.17.1\",\n    \"mysql2\": \"^1.6.5\",\n    \"nodemailer\": \"^6.1.1\",\n    \"open-exchange-rates\": \"^0.3.0\",\n    \"pg\": \"^6.4.2\",\n    \"pg-hstore\": \"^2.3.2\",\n    \"request\": \"^2.88.0\",\n    \"restify\": \"^8.3.0\",\n    \"restify-cookies\": \"^0.2.5\",\n    \"restify-errors\": \"^7.0.0\",\n    \"rfr\": \"^1.2.2\",\n    \"sequelize\": \"^3.10.0\",\n    \"sqlite3\": \"^4.0.9\",\n    \"uglify-js\": \"^3.5.6\"\n  },\n  \"devDependencies\": {\n    \"chai\": \"^4.2.0\",\n    \"grunt\": \"^1.0.4\",\n    \"grunt-concurrent\": \"^2.0.3\",\n    \"grunt-contrib-watch\": \"^1.1.0\",\n    \"grunt-env\": \"^0.4.4\",\n    \"grunt-mocha-cli\": \"^4.0.0\",\n    \"grunt-nodemon\": \"^0.4.0\",\n    \"grunt-run\": \"^0.8.1\",\n    \"hippie\": \"^0.5.2\",\n    \"mocha\": \"^6.1.4\",\n    \"open\": \"^6.1.0\"\n  }\n}\n"
  },
  {
    "path": "public/css/.gitignore",
    "content": "dist/*\nfonts/*"
  },
  {
    "path": "public/css/main.css",
    "content": "\r\r\r\r\r"
  },
  {
    "path": "public/css/parts/dialogs/base.css",
    "content": ".modal-loading {\n\theight: 100px;\n\ttext-indent: -9999px;\n\tbackground: white url('/images/loading.gif') center center no-repeat;\t\n}"
  },
  {
    "path": "public/css/parts/dialogs/registration.css",
    "content": "\n.social_signin {\n\ttext-align: left;\n\tmargin-bottom: 20px;\n}\n\n.registration_dialog h3, .signin_dialog h3 {\n\tmargin: 0;\n\tpadding: 0 0 10px 0;\n\tcolor: #333;\n\tfont-size: 15px;\n\tfont-weight: normal;\n}\n\n.social_signin_divider {\n\tmargin: 15px 0 18px 0;\n}\n\n.social_signin_divider_h {\n\tfloat: left; \n\twidth: 45%; \n\toverflow: hidden; \n\theight: 11px; \n\tborder-bottom: 1px solid #333;\n}\n\n.social_signin_divider_or {\n\tfloat: left; \n\twidth: 10%; \n\toverflow: hidden; \n\theight: 20px; \n\tfont-size: 16px; \n\tvertical-align: middle; \n\tline-height: 20px; \n\ttext-align: center; \n\tcolor: #333\n}\n\n.social_signin_divider_cl {\n\tclear: both;\n}"
  },
  {
    "path": "public/css/parts/dialogs/signin.css",
    "content": "\n.dialog_signin {\n\t-webkit-touch-callout: none;\n\t-webkit-user-select: none;\n\t-khtml-user-select: none;\n\t-moz-user-select: none;\n\t-ms-user-select: none;\n\tuser-select: none;\n}\n\n.dialog_signin_container input[type=\"password\"],\n.dialog_signin_container input[type=\"text\"] {\n\twidth: 355px;\n\theight: 25px;\n}\n\n.dialog_signin_container h3, .dialog_signin_container h4 {\n\tcursor: default;\n}\n\n.dialog_signin_container .alert{\n\tposition: absolute;\n\tz-index: 9999999;\n\twidth: 318px;\n\tdisplay: none;\n\tmargin-top: -5px;\n}\n\n.dialog_signin_container .modal-social {\n\tbackground: white;\n}\n\n.dialog_signin_container .modal-forget-password {\n\tfloat: right;\n\tpadding: 5px 2px 3px 0;\n}\n\n.dialog_signin_container .modal-link-to-registration {\n}\n\n.modal-link-to-registration a {\n\tcolor: white;\n\tdisplay: block;\n\ttext-align: center;\n}\n\n.social_button_icon {\n\tfloat: left;\n\twidth: 30px; \n\ttext-align: center; \n\tfont-weight: bold;\n\tdisplay: block;\n\tborder-right: 1px solid #ccc;\n\theight: 24px;\n\tmargin-top: -3px;\n\tpadding-top: 3px;\n\toverflow: hidden;\n}\n"
  },
  {
    "path": "public/css/parts/head.css",
    "content": ".navbar-inverse {\n\tborder-radius: 0;\n\tbackground: white;\n\tborder-bottom: 1px solid #DDDDDD;\n\tmin-height: 45px;\n\toverflow: hidden;\n\tpadding-top: 0px;\n\tmargin-bottom: 0;\n}\n\n.btn-logo {\n\tborder-radius: 0;\n}\n\n.navbar-inverse *:focus {\n\toutline: 0;\n}\n\n@media (max-width: 767px) {\n\t.navbar-inverse {\n\t\tbackground: rgba(255,255,255,.9);\n\t}\n\t.navbar-toggle {\n\t\tmargin-top: 7px;\n\t\tborder-color: #31B0D5;\n\t\tmargin-bottom: 0;\n\t}\n}\n\n.navbar-inverse .navbar-toggle .icon-bar {\n\tbackground-color: #31B0D5;\n}\n\n.navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover {\n\tbackground-color: #EEEEEE;\n}\n\n.navbar-inverse .navbar-nav > li > a, .navbar-inverse .navbar-nav > .open ul > a {\n\tcolor: rgba(0, 0, 0, .7);\n\tpadding-bottom: 0;\n\tpadding-top: 0;\n\tline-height: 45px;\n}\n\n.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {\n\tcolor: rgba(0, 0, 0, 1);\n\tbackground: none;\n\tpadding-bottom: 0;\n}\n\n.navbar-inverse .navbar-nav > .open > a {\n\tbackground: none;\n\tcolor: rgba(0, 0, 0, 1);\n}\n\n.navbar-inverse .navbar-nav>li>a:hover, .navbar-inverse .navbar-nav>li>a:focus, .navbar-inverse .navbar-nav>.open>a:hover, .navbar-inverse .navbar-nav>.open>a:focus {\n\tbackground: none;\n\tcolor: rgba(0, 0, 0, 1);\n}\n\n.navbar-inverse .navbar-nav > .active > a {\n\tbackground: none;\n\tcolor: rgba(0, 0, 0, 1);\n}\n\n.navbar-inverse .navbar-brand img {\n\tmargin-top: -20px;\n\theight: 60px;\n}\n\n.navbar-nav .dropdown-menu {\n\tleft: -5px;\n\tfont-size:  13px;\n\tbackground-color: rgba(0, 0, 0, .7);\n\tborder: 0px none;\n\t-webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px;\n\t-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);\n}\n\n.navbar-nav .dropdown-menu > li > a {\n\tcolor: rgba(0, 0, 0, .7);\n\tpadding: 7px 20px;\n}\n\n.navbar-nav .dropdown-menu > li > a:hover, .navbar-nav .dropdown-menu > li > a:focus, .navbar-nav .dropdown-menu > .active > a:hover {\n\tbackground: rgba(0, 0, 0, .1);\n\tcolor: white;\n}\n\n.navbar-nav .dropdown-menu > .active > a, .navbar-nav .dropdown-menu > .active > a:focus {\n\tbackground: none;\n\tcolor: #fff;\n}\n\n.navbar-nav .btn {\n\tborder: 0;\n\tmargin: 10px 0 0 10px;\n\tborder-radius: 5px;\n\tpadding: 5px;\n\tbox-shadow: none;\n}\n\n\n.navbar-nav a.btn:focus, .navbar-nav a.btn:hover {\n\tborder: 0;\n\tbox-shadow: none;\n}\n\n.navbar-collapse {\n\tborder: 0 none;\n\tborder-top: 0 none;\n\tbox-shadow: none;\n}\n\n@media (max-width: 767px) {\n\t.navbar-collapse ul {\n\t\ttext-align: center;\n\t\twidth: 100%;\n\t\tpadding-bottom: 10px;\n\t}\n\n\t.navbar-collapse ul .btn{\n\t\tmax-width: 50%;\n\t\tmargin:0 auto;\n\t}\n}\n\n.navbar-static-top, .navbar-fixed-top, .navbar-fixed-bottom {\n\tborder-radius: 0;\n}\n\n.slideUp {\n\ttop: -45px;\n}\n\n.headroom {\n\t-webkit-transition: all 0.4s ease-out;\n\t-moz-transition: all 0.4s ease-out;\n\t-o-transition: all 0.4s ease-out;\n\ttransition: all 0.4s ease-out;\n}\n\n#container {\n\tpadding-top: 55px;\n}\n\n.navbar-nav a.icon_holder {\n\tpadding-top: 11px !important;\n\tline-height: 20px !important;\n\tfont-size: 20px;\n}"
  },
  {
    "path": "public/css/parts/home.css",
    "content": ".home_features {\n\n}\n\n.home_features img {\n\tmargin-top: 10px;\n\tmargin-right: 5px;\n}\n\n.home_features .media-heading {\n\tmargin-top: 30px;\n}\n\n.img-thumbnail {\n\tmargin-bottom: 10px;\n}\n\n.home_screenshots {\n\n}\n\n.home_screenshots .image-link {\n\tdisplay: block;\n\theight: 161px;\n\tbackground-size: cover;\n\tborder: 1px solid #31B0D5;\n\tbackground-position: left top;\n\tmargin-bottom: 15px;\n\tbackground-repeat: no-repeat;\n}\n\n.home_screenshots .image-link-contain {\n\tbackground-size: contain;\n\tbackground-position: center center;\n}\n\n.home_screenshots .image-link:hover {\n\tborder: 1px solid #337AB7;\n\n}"
  },
  {
    "path": "public/css/parts/icons.css",
    "content": ".btn-social{position:relative;padding-left:44px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.btn-social>:first-child{position:absolute;left:0;top:0;bottom:0;width:32px;line-height:34px;font-size:1.6em;text-align:center;border-right:1px solid rgba(0,0,0,0.2)}\n\n.btn-facebook{color:#fff;background-color:#3b5998;border-color:rgba(0,0,0,0.2)}.btn-facebook:focus,.btn-facebook.focus{color:#fff;background-color:#2d4373;border-color:rgba(0,0,0,0.2)}\n.btn-facebook:hover{color:#fff;background-color:#2d4373;border-color:rgba(0,0,0,0.2)}\n.btn-facebook:active,.btn-facebook.active,.open>.dropdown-toggle.btn-facebook{color:#fff;background-color:#2d4373;border-color:rgba(0,0,0,0.2)}.btn-facebook:active:hover,.btn-facebook.active:hover,.open>.dropdown-toggle.btn-facebook:hover,.btn-facebook:active:focus,.btn-facebook.active:focus,.open>.dropdown-toggle.btn-facebook:focus,.btn-facebook:active.focus,.btn-facebook.active.focus,.open>.dropdown-toggle.btn-facebook.focus{color:#fff;background-color:#23345a;border-color:rgba(0,0,0,0.2)}\n.btn-facebook:active,.btn-facebook.active,.open>.dropdown-toggle.btn-facebook{background-image:none}\n.btn-facebook.disabled,.btn-facebook[disabled],fieldset[disabled] .btn-facebook,.btn-facebook.disabled:hover,.btn-facebook[disabled]:hover,fieldset[disabled] .btn-facebook:hover,.btn-facebook.disabled:focus,.btn-facebook[disabled]:focus,fieldset[disabled] .btn-facebook:focus,.btn-facebook.disabled.focus,.btn-facebook[disabled].focus,fieldset[disabled] .btn-facebook.focus,.btn-facebook.disabled:active,.btn-facebook[disabled]:active,fieldset[disabled] .btn-facebook:active,.btn-facebook.disabled.active,.btn-facebook[disabled].active,fieldset[disabled] .btn-facebook.active{background-color:#3b5998;border-color:rgba(0,0,0,0.2)}\n.btn-facebook .badge{color:#3b5998;background-color:#fff}\n\n.btn-google{color:#fff;background-color:#dd4b39;border-color:rgba(0,0,0,0.2)}.btn-google:focus,.btn-google.focus{color:#fff;background-color:#c23321;border-color:rgba(0,0,0,0.2)}\n.btn-google:hover{color:#fff;background-color:#c23321;border-color:rgba(0,0,0,0.2)}\n.btn-google:active,.btn-google.active,.open>.dropdown-toggle.btn-google{color:#fff;background-color:#c23321;border-color:rgba(0,0,0,0.2)}.btn-google:active:hover,.btn-google.active:hover,.open>.dropdown-toggle.btn-google:hover,.btn-google:active:focus,.btn-google.active:focus,.open>.dropdown-toggle.btn-google:focus,.btn-google:active.focus,.btn-google.active.focus,.open>.dropdown-toggle.btn-google.focus{color:#fff;background-color:#a32b1c;border-color:rgba(0,0,0,0.2)}\n.btn-google:active,.btn-google.active,.open>.dropdown-toggle.btn-google{background-image:none}\n.btn-google.disabled,.btn-google[disabled],fieldset[disabled] .btn-google,.btn-google.disabled:hover,.btn-google[disabled]:hover,fieldset[disabled] .btn-google:hover,.btn-google.disabled:focus,.btn-google[disabled]:focus,fieldset[disabled] .btn-google:focus,.btn-google.disabled.focus,.btn-google[disabled].focus,fieldset[disabled] .btn-google.focus,.btn-google.disabled:active,.btn-google[disabled]:active,fieldset[disabled] .btn-google:active,.btn-google.disabled.active,.btn-google[disabled].active,fieldset[disabled] .btn-google.active{background-color:#dd4b39;border-color:rgba(0,0,0,0.2)}\n.btn-google .badge{color:#dd4b39;background-color:#fff}\n\n.btn-twitter{color:#fff;background-color:#55acee;border-color:rgba(0,0,0,0.2)}.btn-twitter:focus,.btn-twitter.focus{color:#fff;background-color:#2795e9;border-color:rgba(0,0,0,0.2)}\n.btn-twitter:hover{color:#fff;background-color:#2795e9;border-color:rgba(0,0,0,0.2)}\n.btn-twitter:active,.btn-twitter.active,.open>.dropdown-toggle.btn-twitter{color:#fff;background-color:#2795e9;border-color:rgba(0,0,0,0.2)}.btn-twitter:active:hover,.btn-twitter.active:hover,.open>.dropdown-toggle.btn-twitter:hover,.btn-twitter:active:focus,.btn-twitter.active:focus,.open>.dropdown-toggle.btn-twitter:focus,.btn-twitter:active.focus,.btn-twitter.active.focus,.open>.dropdown-toggle.btn-twitter.focus{color:#fff;background-color:#1583d7;border-color:rgba(0,0,0,0.2)}\n.btn-twitter:active,.btn-twitter.active,.open>.dropdown-toggle.btn-twitter{background-image:none}\n.btn-twitter.disabled,.btn-twitter[disabled],fieldset[disabled] .btn-twitter,.btn-twitter.disabled:hover,.btn-twitter[disabled]:hover,fieldset[disabled] .btn-twitter:hover,.btn-twitter.disabled:focus,.btn-twitter[disabled]:focus,fieldset[disabled] .btn-twitter:focus,.btn-twitter.disabled.focus,.btn-twitter[disabled].focus,fieldset[disabled] .btn-twitter.focus,.btn-twitter.disabled:active,.btn-twitter[disabled]:active,fieldset[disabled] .btn-twitter:active,.btn-twitter.disabled.active,.btn-twitter[disabled].active,fieldset[disabled] .btn-twitter.active{background-color:#55acee;border-color:rgba(0,0,0,0.2)}\n.btn-twitter .badge{color:#55acee;background-color:#fff}\n\n.btn-social-icon>:first-child{border:none;text-align:center;width:100% !important}\n\n"
  },
  {
    "path": "public/css/parts/import.css",
    "content": "\n.sample_cell {\n\tmax-height: 40px;\n\tmax-width: 190px;\n\tword-wrap: break-word;\n\toverflow: hidden;\n}\n\n.import_row_type {\n\twidth: 130px;\n}\n.import_row_date_format {\n\twidth: 130px;\n}\n.import_row_time_format {\n\twidth: 130px;\n}\n"
  },
  {
    "path": "public/css/parts/overload.css",
    "content": "#wrap {\n\tbackground-color: #F8F8F8;\n}\n\n.row.no-gutter {\n  margin-left: 0;\n  margin-right: 0;\n}\n\n.row.no-gutter [class*='col-']:not(:first-child),\n.row.no-gutter [class*='col-']:not(:last-child) {\n  padding-right: 0;\n  padding-left: 0;\n}\n\n.hideme {\n\tdisplay: none;\n}\n\n.disable-selection {\n\t-webkit-touch-callout: none;\n\t-webkit-user-select: none;\n\t-khtml-user-select: none;\n\t-moz-user-select: none;\n\t-ms-user-select: none;\n\tuser-select: none;\n}\n\n.disable-selection a:hover {\n\toutline: 0;\n}\n\n.navbar-default {\n\t  -webkit-box-shadow: none;\n\t  box-shadow: none;\n\t  background-image: none;\n}\n\n.btn-danger, .btn-default, .btn-info, .btn-primary, .btn-success, .btn-warning {\n\ttext-shadow: none;\n}\n\n.modal-footer {\n\tborder-top: 0;\n}\n\n@media (max-width: 480px) { \n        body {\n          font-size: 11px;\n        }\n        h4 {\n        \tfont-size: 12px;\n        }\n}"
  },
  {
    "path": "public/css/parts/page_transitions.css",
    "content": "\n.page_holder {\n}\n\n.page {\n}\n\n.page_loading {\n\tbackground: url('/images/loading.gif') center center no-repeat;\n\tmin-height: 200px;\n}\n\n#preloader {\n\tposition: fixed;\n\ttop: 0; left: 0; right: 0; bottom: 0;\n\tbackground: white url('/images/loading.gif') center center no-repeat;\t\n\tz-index: 999;\n}"
  },
  {
    "path": "public/css/parts/sticked_footer.css",
    "content": "html, body {\n\theight: 100%; /* The html and body elements cannot have any padding or margin. */\n\tmargin: 0;\n\tpadding: 0;\n}\n\n/* Wrapper for page content to push down footer */\n#wrap {\n\tmin-height: 100%;\n\theight: auto !important;\n\theight: 100%;\n\t/* Negative indent footer by it's height */\n\tmargin: 0 auto -50px;\n}\n\n/* Set the fixed height of the footer here */\n#push, #footer {\n\theight: 50px;\n}\n\n\n\n#footer {\n\tbackground-color: #DDD;\n\tborder-top: 1px solid #AAA;\n}\n\n#footer .credit a {\n}\n\n#footer .credit a:hover {\n}\n\n#footer .container, #footer .container-fluid {\n\tpadding-top: 14px;\n}\n\n\n"
  },
  {
    "path": "public/css/parts/text_format.css",
    "content": "\n\n.text_format {\n\n}\n\n.text_format img {\n\tmax-width: 100%;\n}\n\n.text_format img[style*=\"float: left\"] {\n\tmargin: 0 10px 5px 0;\n}\n\n.text_format img {\n\n}\n\n.text_format hr {\n\tmargin-top: 10px;\n\tmargin-bottom: 10px;\n\tborder-top: 1px solid #666;\n}\n\n.text_format table {\n\tmargin-bottom: 10px;\n}\n\n.text_format blockquote p {\n\tfont-size: 14px;\n}"
  },
  {
    "path": "public/css/parts/wallets.css",
    "content": ".wallet_total {\n\tfont-size: 24px;\n}\n\na.action {\n\tborder-bottom: 1px dashed #2a6496;\n\ttext-decoration: none;\n}\n\na.action:hover {\n\tborder-bottom: 1px dashed #2a6496;\n\ttext-decoration: none;\n}\n\n.transaction_amount {\n\ttext-align: right;\n}\n\n.transaction_description {\n\tmargin-left: 170px;\n}\n\n.transaction_time {\n\tfont-size: 12px;\n\twidth: 170px;\n\toverflow: hidden;\n}\n\n.transaction_time_date {\n\tfloat: left;\n\twidth: 100px;\n\toverflow: hidden;\n\tfont-weight: bold;\n\tmargin-bottom: 5px;\n\tline-height: 1.1;\n}\n\n.transaction_time_time {\n\tfloat: left;\n\twidth: 70px;\n\toverflow: hidden;\n\tfont-weight: bold;\n\tmargin-bottom: 5px;\n\tline-height: 1.1;\n}\n\n#add_transaction_amount {\n\tmargin-top: 3px;\n}\n\n.wallet_item {\n\n}\n\n.wallet_item .wallet_buttons {\n\tfloat: right;\n\tmargin-right: 10px;\n}\n\n\n@media (max-width: 480px) { \n        .transaction_time {\n        \tfont-size: 11px;\n        }\n        .transaction_description {\n        \tclear: both;\n        \tmargin-left: 100px;\n        \tmargin-bottom: 0;\n        }\n}"
  },
  {
    "path": "public/css/parts/widgets.css",
    "content": ".widget h1:first-child {\n\tmargin-top: 0;\n}\n.widget h2:first-child {\n\tmargin-top: 0;\n}\n.widget h3:first-child {\n\tmargin-top: 0;\n}\n.widget h4:first-child {\n\tmargin-top: 0;\n}\n.widget h5:first-child {\n\tmargin-top: 0;\n}\n"
  },
  {
    "path": "public/index.html",
    "content": "<!DOCTYPE HTML>\n<html>\n<head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\t<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->\n\t<!--[if lt IE 9]>\n\t  <script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"></script>\n\t<![endif]-->\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n\t<title>DimeShift</title>\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n\t<link rel='icon' href='/images/favicon.ico' type='image/x-icon' />\n\n\t<script type=\"text/javascript\">\n\t\tvar site_path = window.location.protocol + \"//\" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');\n\t</script>\n\n\t<script src=\"//localhost:35729/livereload.js\"></script>\n\n\t<link href=\"/css.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n\t<meta name=\"google-site-verification\" content=\"MyNePgPoKL2FkR070Lj1pIT8Or7gERZiobVzjG0PtOk\" />\n\t<script>\n\t\t(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n\t\t(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\t\tm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n\t\t})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n\t\tga('create', 'UA-400436-21', 'auto');\n\t\tga('send', 'pageview');\n\t</script>\n</head>\n<body>\n<div id=\"wrap\">\n\t\t<!-- Fixed navbar -->\n\t<div class=\"navbar navbar-inverse navbar-fixed-top headroom disable-selection\" id=\"header\">\n\t\t<div class=\"container\">\n\t\t\t<div class=\"navbar-header\">\n\t\t\t\t<!-- Button for smallest screens -->\n\t\t\t\t<button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\"><span class=\"icon-bar\"></span> <span class=\"icon-bar\"></span> <span class=\"icon-bar\"></span> </button>\n\t\t\t\t\n\n\t\t\t\t<a href=\"/\" class=\"btn btn-info btn-lg btn-logo\">$ dimeshift</a>\n\t\t\t</div>\n\t\t\t<div class=\"navbar-collapse collapse\">\n\t\t\t\t<ul class=\"nav navbar-nav pull-right\">\n\t\t\t\t\t<li class=\"active header_is_not_signed_in\">\n\t\t\t\t\t\t<a href=\"/\" class=\"menu_category menu_category_home\" data-i18n=\"Home\">Home</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class=\"header_is_signed_in\" style=\"display: none;\">\n\t\t\t\t\t\t<a href=\"/wallets\" class=\"menu_category menu_category_wallets\" data-i18n=\"Wallets\">Wallets</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class=\"header_is_signed_in\" style=\"display: none;\">\n\t\t\t\t\t\t<a href=\"/plans\" class=\"menu_category menu_category_wallets\" data-i18n=\"Goals\">Goals</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li><a href=\"mailto:jeka911@gmail.com?subject=Wallet\" class=\"menu_category\" data-i18n=\"Contact\">Contact</a></li>\n\t\t\t\t\t<li><a href=\"http://docs.dimeshift.apiary.io/\" class=\"menu_category\">API</a></li>\n\t\t\t\t\t<li class=\"header_is_not_signed_in\" >\n\t\t\t\t\t\t<a href=\"/user/registration\" data-i18n=\"Register\">Register</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class=\"header_is_not_signed_in\" >\n\t\t\t\t\t\t<a href=\"/user/signin\" class=\"signin_caller\" data-i18n=\"Sign In\">Sign In</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class=\"header_is_signed_in\" style=\"display: none;\">\n\t\t\t\t\t\t<a href=\"/profile\" data-i18n=\"Settings\">Settings</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li class=\"header_is_signed_in\" style=\"display: none;\">\n\t\t\t\t\t\t<a href=\"/user/logout\" class=\"signout_caller\" data-i18n=\"Log Out\">Log Out</a>\n\t\t\t\t\t</li>\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<a href=\"/user/change_language\" class=\"icon_holder\"><span class=\"glyphicon glyphicon-globe\" aria-hidden=\"true\"></span></a>\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t</div><!--/.nav-collapse -->\n\t\t</div>\n\t</div> \n\t<!-- /.navbar -->\n\n\n\n\t<div class=\"container\" id=\"container\">\n\n\t\t<div id=\"fill_profile_invitation\" style=\"display: none;\">\n\t\t\t<div class=\"alert alert-info\">\n\t\t\t<span data-i18n=\"Please don't forget to let us know your email address, so you can sign in to DimeShift on your next visit\">Please don't forget to let us know your email address, so you can sign in to DimeShift on your next visit</span>. <a href=\"/user/fillprofile\" class=\"btn btn-primary btn-xs\" data-i18n=\"Do it\">Do it</a>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class=\"page_holder\" id=\"page_holder_1\"></div>\n\t\t<div class=\"page_holder\" id=\"page_holder_2\"></div>\n\t</div>\n\n\t<div id=\"push\"></div>\n</div>\n\n\t<div id=\"preloader\"></div>\n\t<footer id=\"footer\" role=\"contentinfo\">\n\t\t<div class=\"container\">\n\t\t\t<div class=\"pull-right\">\n\t\t\t\t<a href=\"https://github.com/jeka-kiselyov/dimeshift\" data-i18n=\"View Source on GitHub\">View Source on GitHub</a>\n\t\t\t</div>\n\t\t\t<p class=\"muted credit\"><span data-i18n=\"Copyright\" class=\"hidden-xs hidden-sm\">Copyright</span><span class=\"visible-xs-inline visible-sm-inline\">&copy;</span> 2018 <a href=\"http://dimeshift.com\">DimeShift</a><span class=\"hidden-xs hidden-sm\">.</span> <span data-i18n=\"GNU Affero GPL License\" class=\"hidden-xs hidden-sm\">GNU Affero GPL License</span></a> </p>\n\t\t</div>\n\t</footer>\n\n    <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>\n\t<script src=\"/resources/js.js\" type=\"text/javascript\"></script>\n</body>\n</html>"
  },
  {
    "path": "public/jstemplates/404.tpl",
    "content": "<h1>{t}Nothing is found{/t}</h1>"
  },
  {
    "path": "public/jstemplates/dialogs/add_profit.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Add Income{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      <form method=\"post\" action=\"{$settings->site_path}/wallets/add_profit\" role=\"form\">\n      <fieldset>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_amount\">{t}Amount{/t}</label>\n          <input type=\"number\" min=\"0\" step=\"0.01\" name=\"amount\" class=\"form-control\" id=\"input_amount\" placeholder=\"{t}Amount{/t}\">\n        </div>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_description\">{t}Description{/t}</label>\n          <input type=\"text\" name=\"description\" class=\"form-control\" id=\"input_description\" placeholder=\"{t}Description{/t}\">\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Add{/t}\" data-loading-text=\"{t}Saving...{/t}\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/add_wallet.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Add Wallet{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      <form method=\"post\" action=\"{$settings->site_path}/wallets/add\" role=\"form\" id=\"add_wallet_modal_form\">\n      <fieldset>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_name\">{t}Name{/t}</label>\n          <input type=\"text\" name=\"name\" class=\"form-control\" id=\"input_name\" placeholder=\"Name\">\n        </div>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_name\">{t}Currency{/t}</label>\n          <select name=\"currency\" id=\"input_currency\" class=\"form-control\">\n            <option value=\"\">{t}Select Currency{/t}</option>\n            {foreach from=$settings.currencies item=c key=id}\n              <option value=\"{$id}\" {if $id == 'USD'}selected=\"selected\"{/if}>{$c}</option>\n            {/foreach}\n          </select>\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Add{/t}\" data-loading-text=\"{t}Saving...{/t}\" id=\"add_wallet_modal_form_submit\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/change_language.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">\n          {t}Change DimeShift language{/t}\n        </h4>\n      </div>\n      <form method=\"post\"  role=\"form\">\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n        <div class=\"process_button_container btn-group-vertical\" role=\"group\" style=\"display: block\">\n        {foreach from=$locales item=locale key=key}\n          {if $current_locale == $key}\n          <button type=\"button\" class=\"btn btn-default btn-block btn-primary process_button\" data-code=\"{$key}\">{$locale.name}</button>\n          {else}\n          <button type=\"button\" class=\"btn btn-default btn-block process_button\" data-code=\"{$key}\">{$locale.name}</button>\n          {/if}\n        {/foreach}\n        </div>\n\n      </div>\n      <div class=\"modal-footer\">\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Cancel{/t}\" data-loading-text=\"{t}Canceling...{/t}\">\n        </div>\n\n      </div>\n      </form>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/edit_wallet.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Edit Wallet{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      <form method=\"post\" action=\"{$settings->site_path}/wallets/edit\" role=\"form\">\n      <fieldset>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_name\">{t}Name{/t}</label>\n          <input type=\"text\" name=\"name\" class=\"form-control\" id=\"input_name\" placeholder=\"Name\" value=\"{$item->name|escape:'html'}\">\n        </div>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_name\">{t}Currency{/t}</label>\n          <select name=\"currency\" id=\"input_currency\" class=\"form-control\">\n            <option value=\"\">{t}Select Currency{/t}</option>\n            {foreach from=$settings.currencies item=c key=id}\n              <option value=\"{$id}\" {if $item->currency == $id}selected=\"selected\"{/if}>{$c}</option>\n            {/foreach}\n          </select>\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Save{/t}\" data-loading-text=\"{t}Saving...{/t}\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/fill_profile.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Fill Profile{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      <form method=\"post\" role=\"form\" id=\"fill_profile_modal_form\">\n      <fieldset>\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_login\">{t}Username{/t}</label>\n          <input type=\"text\" name=\"login\" class=\"form-control\" id=\"input_login\" placeholder=\"{t}Username{/t}\">\n        </div>\n        \n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_email\">{t}Email{/t}</label>\n          <input type=\"email\" name=\"email\" class=\"form-control\" id=\"input_email\" placeholder=\"{t}Email{/t}\">\n        </div>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_password\">{t}Password{/t}</label>\n          <input type=\"password\" name=\"password\" class=\"form-control\" id=\"input_password\" placeholder=\"{t}Password{/t}\">\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" id=\"registration_invalid_password_alert\" style=\"display: none;\">\n          {t}Invalid username or password{/t}\n        </div>\n        \n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Save{/t}\" data-loading-text=\"{t}Saving...{/t}\" id=\"fill_profile_modal_form_submit\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n        <div class=\"alert alert-info\" role=\"alert\">{t}Thank you! From now, you can sign in to your account any time from any device.{/t}.</div>\n      </div>\n      <div class=\"modal-footer\">\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/hide_wallet.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">\n        {if $item->status|default:'active' == 'active'}\n          {t}Are you sure that you want to hide{/t} {if $item->name|default:''==''}{t}this wallet{/t}{else}{t}wallet{/t} {$item->name|escape:'html'}{/if}?\n        {else}\n          {t}Are you sure that you want to remove{/t} {if $item->name|default:''==''}{t}this wallet{/t}{else}{t}wallet{/t} {$item->name|escape:'html'}{/if}?\n        {/if}\n        </h4>\n      </div>\n      <form method=\"post\" action=\"{$settings->site_path}/wallets/remove\" role=\"form\">\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n        {if $item->status|default:'active' == 'active'}\n          <p>{t}You will be able to restore it from Trash folder{/t}</p>\n        {else}\n          <p>{t}All wallet data(transactions etc.) will be lost{/t}</p>\n        {/if}\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n      </div>\n      <div class=\"modal-footer\">\n\n        <div class=\"form-group\">\n          <input type=\"button\" class=\"process_button btn btn-danger pull-left\" value=\"{if $item->status|default:'active' == 'active'}{t}Yes, Hide It{/t}{else}{t}Yes, Remove{/t}{/if}\" data-loading-text=\"{t}Removing...{/t}\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Cancel{/t}\" data-loading-text=\"{t}Canceling...{/t}\">\n        </div>\n\n      </div>\n      </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/registration.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Registration{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default registration_dialog\" style=\"padding-bottom: 0;\">\n<!-- \n      <h3>{t}Sign In With{/t}</h3>\n\n      <div class=\"social_signin\">\n        <a href=\"#\" class=\"btn btn-social btn-facebook\"><span class=\"fa fa-facebook\"></span> Facebook</a>\n        <a href=\"#\" class=\"btn btn-social btn-google\"><span class=\"fa fa-google\"></span> Google</a>\n        <a href=\"#\" class=\"btn btn-social btn-twitter\"><span class=\"fa fa-twitter\"></span> Twitter</a>\n      </div>\n -->\n<!--       <div class=\"social_signin_divider\">\n        <div class=\"social_signin_divider_h\"></div>\n        <div class=\"social_signin_divider_or\">or</div>\n        <div class=\"social_signin_divider_h\"></div>\n        <div class=\"social_signin_divider_cl\"></div>\n      </div> -->\n<!-- \n      <h3>{t}Or Create New Account{/t}</h3> -->\n\n      <form method=\"post\" action=\"{$settings->site_path}/user/signin\" role=\"form\" id=\"registration_modal_form\">\n      <fieldset>\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_login\">{t}Username{/t}</label>\n          <input type=\"text\" name=\"login\" class=\"form-control\" id=\"input_login\" placeholder=\"{t}Username{/t}\">\n        </div>\n        \n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_email\">{t}Email{/t}</label>\n          <input type=\"email\" name=\"email\" class=\"form-control\" id=\"input_email\" placeholder=\"{t}Email{/t}\">\n        </div>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_password\">{t}Password{/t}</label>\n          <input type=\"password\" name=\"password\" class=\"form-control\" id=\"input_password\" placeholder=\"{t}Password{/t}\">\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" id=\"registration_invalid_password_alert\" style=\"display: none;\">\n          {t}Invalid username or password{/t}\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Sign Up{/t}\" data-loading-text=\"{t}Registration...{/t}\" id=\"registration_modal_form_submit\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n        <div class=\"alert alert-info\" role=\"alert\">{t}Thank you! Please check your email inbox for confirmation link{/t}.</div>\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n        {t}Already a member?{/t} <a href=\"{$settings->site_path}/user/signin\" class=\"btn btn-default btn-sm\">{t}Sign In{/t}</a>\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/remove_access.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">\n          {t}Are you sure that you want to remove access for email{/t} {$access->to_email|escape} {if $item->name|default:''==''}{t}from this wallet{/t}{else}{t}from wallet{/t} \"{$item->name|escape:'html'}\"{/if}?\n        </h4>\n      </div>\n      <form method=\"post\"  role=\"form\">\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n      </div>\n      <div class=\"modal-footer\">\n\n        <div class=\"form-group\">\n          <input type=\"button\" class=\"process_button btn btn-danger pull-left\" value=\"{t}Yes, Remove{/t}\" data-loading-text=\"{t}Removing...{/t}\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Cancel{/t}\" data-loading-text=\"{t}Canceling...{/t}\">\n        </div>\n\n      </div>\n      </form>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/remove_plan.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">\n          {t}Are you sure that you want to remove this plan?{/t}\n        </h4>\n      </div>\n      <form method=\"post\"  role=\"form\">\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n      </div>\n      <div class=\"modal-footer\">\n\n        <div class=\"form-group\">\n          <input type=\"button\" class=\"process_button btn btn-danger pull-left\" value=\"{t}Yes, Remove{/t}\" data-loading-text=\"{t}Removing...{/t}\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Cancel{/t}\" data-loading-text=\"{t}Canceling...{/t}\">\n        </div>\n\n      </div>\n      </form>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/remove_transaction.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">\n          {t}Are you sure that you want to remove this transaction?{/t}\n        </h4>\n      </div>\n      <form method=\"post\"  role=\"form\">\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n      </div>\n      <div class=\"modal-footer\">\n\n        <div class=\"form-group\">\n          <input type=\"button\" class=\"process_button btn btn-danger pull-left\" value=\"{t}Yes, Remove{/t}\" data-loading-text=\"{t}Removing...{/t}\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Cancel{/t}\" data-loading-text=\"{t}Canceling...{/t}\">\n        </div>\n\n      </div>\n      </form>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/restore.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Restore Password{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      <form method=\"post\" action=\"{$settings->site_path}/user/restore\" role=\"form\" id=\"restore_modal_form\">\n      <fieldset>\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_email\">{t}Email{/t}</label>\n          <input type=\"email\" name=\"email\" class=\"form-control\" id=\"input_email\" placeholder=\"{t}Email{/t}\">\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" id=\"restore_invalid_password_alert\" style=\"display: none;\">\n          {t}Invalid username or password{/t}\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Restore{/t}\" data-loading-text=\"{t}Processing...{/t}\" id=\"restore_modal_form_submit\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n        <div class=\"alert alert-info\" role=\"alert\">{t}Instructions have been sent to your email address{/t}.</div>\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n        {t}Don't have an account?{/t} <a href=\"{$settings->site_path}/user/registration\" class=\"btn btn-default btn-sm\">{t}Register{/t}</a>\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/set_total_to.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Set Total To{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      <form method=\"post\" action=\"{$settings->site_path}/wallets/add_profit\" role=\"form\">\n      <fieldset>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_total\">{t}Total{/t}</label>\n          <input type=\"number\" step=\"0.01\" name=\"total\" class=\"form-control\" id=\"input_total\" placeholder=\"{t}Total{/t}\">\n        </div>\n\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Set{/t}\" data-loading-text=\"{t}Saving...{/t}\">\n        </div>\n\n      </fieldset>\n      </form>\n\n      </div>\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/signin.tpl",
    "content": "<div class=\"modal-dialog\">\r\n  <div class=\"modal-content\">\r\n      <div class=\"modal-header\">\r\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\r\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Sign In{/t}</h4>\r\n      </div>\r\n      <div class=\"modal-body signin_dialog\" style=\"padding-bottom: 0;\">\r\n<!-- \r\n      <h3>{t}Sign In With{/t}</h3>\r\n\r\n      <div class=\"social_signin\">\r\n        <a href=\"#\" class=\"btn btn-social btn-facebook\"><span class=\"fa fa-facebook\"></span> Facebook</a>\r\n        <a href=\"#\" class=\"btn btn-social btn-google\"><span class=\"fa fa-google\"></span> Google</a>\r\n        <a href=\"#\" class=\"btn btn-social btn-twitter\"><span class=\"fa fa-twitter\"></span> Twitter</a>\r\n      </div>\r\n\r\n      <h3>{t}Or Sign In With Your DimeShift Account{/t}</h3> -->\r\n\r\n      <form method=\"post\" action=\"{$settings->site_path}/user/signin\" role=\"form\" id=\"signin_modal_form\">\r\n      <fieldset>\r\n        <div class=\"form-group\">\r\n          <label class=\"sr-only\" for=\"input_username\">{t}Username or Email{/t}</label>\r\n          <input type=\"text\" name=\"username\" class=\"form-control\" id=\"input_username\" placeholder=\"{t}Username or Email{/t}\">\r\n        </div>\r\n        <div class=\"form-group\">\r\n          <label class=\"sr-only\" for=\"input_password\">{t}Password{/t}</label>\r\n          <input type=\"password\" name=\"password\" class=\"form-control\" id=\"input_password\" placeholder=\"{t}Password{/t}\">\r\n        </div>\r\n        <div class=\"alert alert-danger errors-container\" id=\"signin_invalid_password_alert\" style=\"display: none;\">\r\n          {t}Invalid username or password{/t}\r\n        </div>\r\n\r\n        <div class=\"form-group\">\r\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Sign In{/t}\" data-loading-text=\"{t}Signing in...{/t}\" id=\"signin_modal_form_submit\">\r\n        </div>\r\n      </fieldset>\r\n      </form>\r\n\r\n      </div>\r\n      <div class=\"modal-footer\">\r\n        <a href=\"{$settings->site_path}/user/registration\" class=\"btn btn-default btn-sm\">{t}Register{/t}</a>\r\n        <a href=\"{$settings->site_path}/user/restore\" class=\"btn btn-default btn-sm\">{t}Restore your password{/t}</a>\r\n      </div>\r\n  </div>\r\n</div>\r\n\r\n"
  },
  {
    "path": "public/jstemplates/dialogs/transaction_details.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Transaction Details{/t}</h4>\n      </div>\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n        <table class=\"table table-hover table-striped\">\n          <tr>\n            <td><strong>{t}Amount{/t}</strong></td>\n            <td><strong>{if $wallet->currency == 'USD'}${/if}{$item->amount|rational}.<sup>{$item->amount|decimal}</sup> {if $wallet->currency != 'USD'} {$wallet->currency}{/if}</strong></td>\n          </tr>\n          <tr>\n            <td><strong>{t}Date{/t}</strong></td>\n            <td>{$item->datetime|date_format}</td>\n          </tr>\n          <tr>\n            <td><strong>{t}Time{/t}</strong></td>\n            <td>{$item->datetime|date_format:'g:i a'}</td>\n          </tr>\n          <tr>\n            <td><strong>{t}Description{/t}</strong></td>\n            <td>{$item->description|escape:'html'|default:'&nbsp;'}</td>\n          </tr>\n        </table>\n\n\n<!--       <form method=\"post\" action=\"{$settings->site_path}/wallets/edit\" role=\"form\">\n      <fieldset>\n\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_name\">Name</label>\n          <input type=\"text\" name=\"name\" class=\"form-control\" id=\"input_name\" placeholder=\"Name\" value=\"{$item->name|escape:'html'}\">\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"Save\" data-loading-text=\"Saving...\">\n        </div>\n\n      </fieldset>\n      </form> -->\n\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"pull-right\">\n          <a href=\"#\" class=\"btn btn-default btn-sm\" id=\"remove_transaction_button\"><span class=\"glyphicon glyphicon-trash\"></span>  {t}Remove{/t}</a>\n        </div>\n      </div>\n    </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/dialogs/wallet_accesses.tpl",
    "content": "<div class=\"modal-dialog\">\n  <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n        <h4 class=\"modal-title\" id=\"dialog_label\">{t}Users with access{/t} {if $item->name|default:''==''}{t}to this wallet{/t}{else}{t}to wallet{/t} \"{$item->name|escape:'html'}\"{/if}</h4>\n      </div>\n\n      <form method=\"post\" role=\"form\">\n      <fieldset>\n\n      <div class=\"modal-body modal-body-default\" style=\"padding-bottom: 0;\">\n\n      {if $status == 'loading'}\n        <div class=\"page_loading\"></div>\n      {else}\n\n        {if $accesses|count == 0}\n          <div class=\"alert alert-warning\" role=\"alert\">{t}Only you have access to this wallet{/t}</div>  \n        {else}\n        <div class=\"table-responsive\" style=\"max-height: 300px; overflow-y: scroll;\">\n          <table class=\"table table-hover table-striped\">\n          {foreach from=$accesses item=a}\n            <tr>\n              <td style=\"width: 39px;\">\n                <img src=\"{$a->gravatar}\" class=\"img-circle\" style=\"max-width: 39px; height: auto;\">\n              </td>\n              <td style=\"max-width: 300px; overflow: hidden;\">\n                <strong title=\"{$a->to_email|escape}\" data-id=\"{$a->id}\" id=\"emails_with_access_{$a->id}\">{$a->to_email|escape}</strong>\n              </td>\n              <td style=\"text-align: center;\">{if !$a->to_user_id || $a->to_user_id == '0'}<span class=\"glyphicon glyphicon-user\" style=\"color: #ccc;\" title=\"{t}Not registered yet{/t}\"></span>{else}<span class=\"glyphicon glyphicon-user\"></span>{/if}</td>\n              <td><div class=\"pull-right\"><a href=\"#\" class=\"btn btn-default btn-xs item_button_remove_access\" data-id=\"{$a->id}\"><span class=\"glyphicon glyphicon-trash\"></span>  {t}Remove Access{/t}</a></div></td>\n            </tr>\n          {/foreach}\n          </table>\n        </div>\n        {/if}\n\n      {/if}\n\n        <h4>{t}Add access{/t}</h4>\n        <div class=\"form-group\">\n          <label class=\"sr-only\" for=\"input_email\">{t}Email{/t}</label>\n          <input type=\"email\" name=\"email\" class=\"form-control\" id=\"input_email\" placeholder=\"{t}Email{/t}\">\n        </div>\n\n        <div class=\"alert alert-danger errors-container\" style=\"display: none;\">\n        </div>\n\n\n\n      <div class=\"modal-body modal-body-success\" style=\"display: none;\">\n      </div>\n\n      </div>\n      <div class=\"modal-footer\">\n        <div class=\"form-group\">\n          <input type=\"submit\" class=\"btn btn-primary pull-left\" value=\"{t}Give Access{/t}\" data-loading-text=\"{t}Saving...{/t}\">\n        </div>\n      </div>\n      </fieldset>\n      </form>\n  </div>\n</div>\n\n"
  },
  {
    "path": "public/jstemplates/months.tpl",
    "content": "{t}January{/t}\n{t}February{/t}\n{t}March{/t}\n{t}April{/t}\n{t}May{/t}\n{t}June{/t}\n{t}July{/t}\n{t}August{/t}\n{t}September{/t}\n{t}October{/t}\n{t}November{/t}\n{t}December{/t}\nfor dmy:\n{t}january{/t}\n{t}february{/t}\n{t}march{/t}\n{t}april{/t}\n{t}may{/t}\n{t}june{/t}\n{t}july{/t}\n{t}august{/t}\n{t}september{/t}\n{t}october{/t}\n{t}november{/t}\n{t}december{/t}"
  },
  {
    "path": "public/jstemplates/pages/import/xls.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{tp}Home{/tp}</a></li>\n  <li><a href=\"{$settings->site_path}/wallets\">{tp}Wallets{/tp}</a></li>\n  <li class=\"active\">{tp}Import .xls file{/tp}</li>\n</ul>\n\n\n<div class=\"row\">\n<div class=\"col-xs-12 col-md-12\">\n\n\n\t{if $step == 1 && !$sample}\n\t<div class=\"panel panel-default\" id=\"step_1\">\n\t\t<div class=\"panel-heading\">{tp}Step 1. Select .xls file to import{/tp}</div>\n\t\t<div class=\"panel-body\">\n\n\t\t\t<div class=\"alert alert-danger\" role=\"alert\" style=\"display: none;\">\n\t\t\t\t{tp}Invalid xls file. Please select another one and try again{/tp}\n\t\t\t</div>\n\n\t\t\t<input type=\"file\" id=\"file_input\" style=\"display: none;\">\n\t\t\t<input type=\"button\" class=\"select_file_button btn btn-primary\" value=\"{t}Select file{/t}\" data-loading-text=\"{t}Uploading...{/t}\" data-i18nvalue=\"Select file\">\n\t\t\t<p>{tp}Please select your local .xls file{/tp}</p>\n\t\t\t<a href=\"{$settings->site_path}/wallets/{$wallet_id}\" class=\"btn btn-default\">{tp}Cancel{/tp}</a>\n\n\t\t</div>\n\t</div>\n\t{/if}\n\n\t{if $step == 1 && $sample}\n\t<div class=\"panel panel-default\" id=\"step_2\">\n\t\t<div class=\"panel-heading\">{tp}Step 2. Select columns to import{/tp}</div>\n\t\t<div class=\"panel-body\">\n\n\t\t\t<div style=\"overflow-x: scroll\">\n\t\t\t{if $sample}\n\t\t\t<table class=\"table table-striped  table-condensed table-bordered\">\n\t\t\t\t<tr>\n\t\t\t\t{for $var=1 to $sampleWidth}\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<select name=\"import_row_{$var}_type\" class=\"import_row_type\">\n\t\t\t\t\t\t\t<option value=''>{t}Do not import{/t}</option>\n\t\t\t\t\t\t\t<option value='description' {if $selectedFields.description==$var} selected=\"selected\"{/if}>{t}Description{/t}</option>\n\t\t\t\t\t\t\t<option value='date' {if $selectedFields.date==$var} selected=\"selected\"{/if}>{t}Date{/t}</option>\n\t\t\t\t\t\t\t<option value='time' {if $selectedFields.time==$var} selected=\"selected\"{/if}>{t}Time{/t}</option>\n\t\t\t\t\t\t\t<option value='amount' {if $selectedFields.amount==$var} selected=\"selected\"{/if}>{t}Amount{/t}</option>\n\t\t\t\t\t\t\t<option value='abs_amount' {if $selectedFields.abs_amount==$var} selected=\"selected\"{/if}>{t}Expense amount{/t}</option>\n\t\t\t\t\t\t</select>\n\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<select id=\"import_row_{$var}_date_format\" class=\"import_row_date_format \" style=\"display: none;\">\n\t\t\t\t\t\t\t{foreach from=$dateFormats item=f}\n\t\t\t\t\t\t\t\t<option value='{$f|escape}'>{$f|escape}</option>\n\t\t\t\t\t\t\t{/foreach}\n\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<select id=\"import_row_{$var}_time_format\" class=\"import_row_time_format \" style=\"display: none;\">\n\t\t\t\t\t\t\t{foreach from=$timeFormats item=f}\n\t\t\t\t\t\t\t\t<option value='{$f|escape}'>{$f|escape}</option>\n\t\t\t\t\t\t\t{/foreach}\n\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t</td>\n\t\t\t\t{/for}\n\t\t\t\t</tr>\n\t\t\t\t{foreach from=$sample item=row key=i}\n\t\t\t\t\t{if $row.items|count}\n\t\t\t\t\t<tr class=\"sample_import_row\" id=\"sample_import_row_{$row.y}\">\n\t\t\t\t\t\t{foreach from=$row.items item=c}\n\t\t\t\t\t\t\t<td><div class=\"sample_cell\">{$c}</div></td>\n\t\t\t\t\t\t{/foreach}\n\t\t\t\t\t</tr>\n\t\t\t\t\t{else}\n\t\t\t\t\t<tr class=\"active\">\n\t\t\t\t\t\t<td colspan=\"{$sampleWidth}\">... {$row.skiped} {tp}more rows{/tp}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t{/if}\n\t\t\t\t\t</tr>\n\t\t\t\t{/foreach}\n\t\t\t</table>\n\t\t\t{/if}\n\t\t\t</div>\n\n\t\t\t<div class=\"pull-right\">\n\t\t\t\t<p class=\"text-danger pull-left bg-warning\" id=\"proccess_step1_warning\" style=\"padding: 7px; display: block;\">\n\t\t\t\t\t{tp}Amount and Date fields are required{/tp}\n\t\t\t\t</p>\n\t\t\t\t<input type=\"button\" disabled=\"disabled\" id=\"proccess_step1_button\" class=\" btn btn-primary pull-right\" value=\"{t}Preview{/t}\" data-i18nvalue=\"Preview\">\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t{/if}\n\n\t{if $step == 2}\n\t<div class=\"panel panel-default\" id=\"step_2\">\n\t\t<div class=\"panel-heading\">{tp}Step 3. Preview and settings{/tp}</div>\n\t\t<div class=\"panel-body\">\n\n\t\t\t{if $importPreview}\n\t\t\t<table class=\"table table-striped  table-condensed table-bordered\">\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{tp}Date{/tp}</th>\n\t\t\t\t\t<th>{tp}Time{/tp}</th>\n\t\t\t\t\t<th>{tp}Description{/tp}</th>\n\t\t\t\t\t<th>{tp}Amount{/tp}</th>\n\t\t\t\t</tr>\n\t\t\t\t{foreach from=$importPreview item=i}\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$i.date|wallet_date}</td>\n\t\t\t\t\t<td>{$i.date|wallet_time}</td>\n\t\t\t\t\t<td class=\"sample_cell\">{if $i.description}{$i.description|escape}{else}&nbsp;{/if}</td>\n\t\t\t\t\t<td>{$i.amount|escape}</td>\n\t\t\t\t</tr>\n\t\t\t\t{/foreach}\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=\"4\">{tp}Few more rows{/tp}</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t\t{/if}\n\n\n\t\t\t<div class=\"checkbox\">\n\t\t\t\t<label>\n\t\t\t\t\t<input type=\"checkbox\" checked=\"checked\" id=\"do_not_import_duplicates\"> {tp}Do not import transaction, if it's already in database{/tp}\n\t\t\t\t</label>\n\t\t\t</div>\n\n\t\t\t<input type=\"button\" id=\"proccess_step2_button\" class=\"btn btn-primary pull-right\" data-i18nvalue=\"Import\" value=\"{t}Import{/t}\">\n\t\t\t<input type=\"button\" id=\"proccess_step2_cancel\" class=\"btn btn-default pull-right\" data-i18nvalue=\"Back\" value=\"{t}Back{/t}\">\n\t\t</div>\n\t</div>\n\t{/if}\n\n\t{if $step == 3}\n\n\t<div class=\"panel panel-default\" id=\"step_2\">\n\t\t<div class=\"panel-heading\">{tp}Step 4. Import{/tp}</div>\n\t\t<div class=\"panel-body\">\n\t\t\t<div class=\"progress\">\n\t\t\t\t<div class=\"progress-bar progress-bar-striped active\" id=\"import_progress_bar\" role=\"progressbar\" aria-valuenow=\"45\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 1%\">\n\t\t\t\t<span class=\"sr-only\">&nbsp;</span>\n\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\n\n\t{/if}\n\n\n\t{if $step == 4}\n\n\t<div class=\"panel panel-default\" id=\"step_2\">\n\t\t<div class=\"panel-heading\">{tp}Finished{/tp}</div>\n\t\t<div class=\"panel-body\">\n\t\t\t<p>{tp}Import operation is finished{/tp}. <a href=\"{$settings->site_path}/wallets/{$wallet_id}\">{tp}Check out you updated wallet{/tp}</a></p>\n\t\t</div>\n\t</div>\n\n\n\t{/if}\n\n</div>\n</div>"
  },
  {
    "path": "public/jstemplates/pages/index/index.tpl",
    "content": "<h1>DimeShift &ndash; {tp}the easiest way to track your expenses{/tp}</h1>\r\n\r\n<p>{tp}To demonstrate how simple it is{/tp} &ndash; {tp}we don't even ask you to register{/tp}.</p>\r\n\r\n<div style=\"height: 50px;\">\r\n<p class=\"register_with_mouse\" style=\"display: none;\">{tp}Just move your mouse pointer over{/tp} \r\n          <input type=\"submit\" class=\"btn btn-primary\" id=\"demo_signup\" data-i18nvalue=\"here\" value=\"{t}here{/t}\"> {tp}and start using wallet right now!{/tp}</p>\r\n<p class=\"register_without_mouse\" style=\"display: none;\">{tp}Just click{/tp}\r\n          <input type=\"submit\" class=\"btn btn-primary\" id=\"demo_without_mouse_signup\" data-i18nvalue=\"here\" value=\"{t}here{/t}\"> {tp}and start using wallet right now!{/tp}</p>\r\n</div>\r\n<span id=\"screenshots_header_ruler\"></span>\r\n\r\n<h4 id=\"screenshots_header\">{tp}Screenshots{/tp}</h4>\r\n<div class=\"row home_screenshots\">\r\n  <div class=\"col-md-3 col-sm-6 col-xs-12\">\r\n  \t<a href=\"{$settings->site_path}/images/homepage/screenshots/transactions.jpg\" class=\"image-link\" id=\"image-link-1\" style=\"background-image: url('{$settings->site_path}/images/homepage/screenshots/transactions.jpg');\"></a>\r\n<div class=\"hideme\" id=\"image-link-1-title\">{tp}Easiest way to manage your personal finances online{/tp}</div>\r\n<div class=\"hideme\" id=\"image-link-1-description\">{tp}Simple as it is{/tp}</div>\r\n  </div>\r\n  <div class=\"col-md-3 col-sm-6 col-xs-12\">\r\n  \t<a href=\"{$settings->site_path}/images/homepage/screenshots/wallets.jpg\" class=\"image-link\" id=\"image-link-wallets\" style=\"background-image: url('{$settings->site_path}/images/homepage/screenshots/wallets.jpg');\"></a>\r\n<div class=\"hideme\" id=\"image-link-wallets-title\">{tp}Any currency{/tp}</div>\r\n<div class=\"hideme\" id=\"image-link-wallets-description\">{tp}Create as many wallets as you need{/tp}</div>\r\n  </div>\r\n  <div class=\"col-md-3 col-sm-6 col-xs-12\">\r\n  \t<a href=\"{$settings->site_path}/images/homepage/screenshots/goal.jpg\" class=\"image-link\" id=\"image-link-agpl\" style=\"background-image: url('{$settings->site_path}/images/homepage/screenshots/goal.jpg');\"></a>\r\n<div class=\"hideme\" id=\"image-link-agpl-title\">{tp}Set Goals!{/tp}</div>\r\n<div class=\"hideme\" id=\"image-link-agpl-description\">{tp}Save money!{/tp}</div>\r\n  </div>\r\n  <div class=\"col-md-3 col-sm-6 col-xs-12\">\r\n    <a href=\"{$settings->site_path}/images/homepage/screenshots/i18n.jpg\" class=\"image-link\" id=\"image-link-2\" style=\"background-image: url('{$settings->site_path}/images/homepage/screenshots/i18n.jpg');\"></a>\r\n<div class=\"hideme\" id=\"image-link-2-title\">{tp}Internalization{/tp}</div>\r\n<div class=\"hideme\" id=\"image-link-2-description\">{tp}Just click on the globe icon in top right corner{/tp}</div>\r\n  </div>\r\n</div>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
  },
  {
    "path": "public/jstemplates/pages/plans/index.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{tp}Home{/tp}</a></li>\n  <li class=\"active\">{tp}Plan your expenses{/tp}</li>\n</ul>\n\n\n<div class=\"row\" {if $step != 0}style=\"display: none;\"{/if}>\n<div class=\"col-xs-12\">\n\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Your plans{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\n\t\t\t<ul class=\"list-group\">\n\t\t\t{if $plans|count == 0}\n\t\t\t{else}\n\t\t\t\t{foreach from=$plans item=p}\n\t\t\t\t<li class=\"list-group-item clearfix\">\n\t\t\t\t\t\n\t\t\t\t\t\t<span class=\"glyphicon glyphicon-{if $p->status == 'active'}play{else}stop{/if}\" aria-hidden=\"true\"></span>\n\t\t\t\t\t\n\t\t\t\t\t{$p->name|escape:'html'}&nbsp;\n\t\t\t\t\t<div class=\"pull-right clearfix\">\n\t\t\t\t\t\t<a href=\"{$settings->site_path}/plans/{$p->id}\" class=\"btn btn-default btn-xs\"><span class=\"glyphicon glyphicon-list-alt\"></span> <span class=\"hidden-xs hidden-sm\">{tp}View Report{/tp}</span></a>\n\t\t\t\t\t\t<button class=\"btn btn-default btn-xs edit_plan_button\" data-id=\"{$p->id}\"><span class=\"glyphicon glyphicon-pencil\"></span> <span class=\"hidden-xs hidden-sm\">{tp}Edit{/tp}</span></button>\n\t\t\t\t\t\t<button class=\"btn btn-default btn-xs remove_plan_button\" data-id=\"{$p->id}\"><span class=\"glyphicon glyphicon-remove\"></span> <span class=\"hidden-xs hidden-sm\">{tp}Remove{/tp}</span></button>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t\t{/foreach}\n\t\t\t{/if}\n\t\t\t</ul>\n\n\t\t\t<button class=\"btn btn-primary\" type=\"submit\" id=\"button_create_new\">{tp}Create new{/tp}</button>\n\n\t\t</div>\n\t</div>\n\n</div>\n</div>\n\n<div class=\"row\" {if $step != 1}style=\"display: none;\"{/if}>\n<div class=\"col-xs-12\">\n\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Basic settings{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\n\n\t\t<div class=\"row\">\n\t\t\t<div class=\"col-sm-6\">\n\t\t\t\t<p>{tp}Plan name{/tp}</p>\n\n\t\t        <div class=\"form-group\">\n\t\t\t\t\t<label class=\"sr-only\" for=\"input_name\">{t}Plan name{/t}</label>\n\t\t\t\t\t<input type=\"text\" name=\"input_name\" class=\"form-control\" id=\"input_name\" {if $preparedData->name|default:'Undefined' != 'Undefined'}value=\"{$preparedData->name|escape:'html'}\"{/if} placeholder=\"{t}Plan name{/t}\">\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-6\">\n\t\t\t\t<p>{tp}Wallets to use for planning{/tp}</p>\n\n\t\t\t\t{if $wallets|count == 0}\n\t\t\t\t{else}\n\t\t\t\t<div class=\"list-group\">\n\t\t\t\t\t{foreach from=$wallets item=w}\n\t\t\t\t\t\t{assign var=\"checked\" value=0}\n\t\t\t\t\t\t{if $preparedData->wallets|default:''}\n\t\t\t\t\t\t{foreach from=$preparedData->wallets item=pwid}\n\t\t\t\t\t\t\t{if $pwid == $w->id}\n\t\t\t\t\t\t\t\t{assign var=\"checked\" value=1}\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{/foreach}\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t<a href=\"#\" class=\"list-group-item {if $preparedData->id|default:0 == 0}step1_wallet_checkbox{else}disabled{/if} {if $checked}active{/if}\" data-id=\"{$w->id}\"><span class=\"glyphicon glyphicon-{if $checked}check{else}unchecked{/if}\"></span> {$w->name|escape:'html'}&nbsp;</a>\n\t\t\t\t\t{/foreach}\n\t\t\t\t</div>\n\t\t\t\t{/if}\n\t\t\t</div>\n\t\t</div>\n\n\t\t<button class=\"btn btn-default\" type=\"submit\" id=\"button_step1_back\">{tp}Back{/tp}</button>\n\t\t<button class=\"btn btn-primary\" type=\"submit\" id=\"button_step1_next\" {if !$preparedData->wallets|default:''}disabled=\"disabled\"{/if}>{tp}Next{/tp}</button>\n\n\t\t</div>\n\t</div>\n\n</div>\n</div>\n\n\n<div class=\"row\" {if $step != 2}style=\"display: none;\"{/if}>\n<div class=\"col-xs-12\">\n\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Plan settings{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\n\n\t\t<div class=\"row\">\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<p>{tp}Current balance is{/tp}</p>\n\n\t\t\t\t<p class=\"text-center {if $preparedData->start_balance >= 0}text-success{else}text-danger{/if} wallet_total\"><strong>\n\n\t\t\t\t\t<span id=\"cb_minus\">-</span><span id=\"cb_c_dollar\">$</span><span id=\"cb_rational\">0</span>.<sup><span id=\"cb_decimal\">00</span></sup> <span id=\"cb_c_other\">USD</span> \n\n\t\t\t\t</strong></p>\n\t\t\t\t<div id=\"cb_o\">\n\t\t\t\t\t<p class=\"text-center\">or</p>\n\t\t\t\t\t<p class=\"text-center {if $preparedData->start_balance >= 0}text-success{else}text-danger{/if} wallet_total\"><strong>\n\n\t\t\t\t\t\t<span id=\"cb_o_minus\">-</span><span id=\"cb_o_c_dollar\">$</span><span id=\"cb_o_rational\">0</span>.<sup><span id=\"cb_o_decimal\">00</span></sup> <span id=\"cb_o_c_other\">USD</span> \n\n\t\t\t\t\t</strong></p>\n\t\t\t\t</div>\n\n\n\t\t        <div class=\"form-group\">\n\t\t          <label for=\"input_name\">{tp}Calculate in different currency{/tp}</label>\n\t\t          <select name=\"input_start_currency\" id=\"input_start_currency\" class=\"form-control\">\n\t\t            <option value=\"\">{t}Select Currency{/t}</option>\n\t\t            {foreach from=$settings.currencies item=c key=id}\n\t\t              <option value=\"{$id}\" {if $id == $preparedData->start_currency|default:'USD'}selected=\"selected\"{/if}>{$c}</option>\n\t\t            {/foreach}\n\t\t          </select>\n\t\t        </div>\n\n\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<p>{tp}And on{/tp}</p>\n\n\t\t\t\t<div style=\"overflow:hidden;\">\n\t\t\t\t    <div class=\"form-group\">\n\t\t\t\t        <div class=\"row\">\n\t\t\t\t            <div class=\"col-md-12\">\n\t\t\t\t                <div class=\"datetimepicker\"></div>\n\t\t\t\t            </div>\n\t\t\t\t        </div>\n\t\t\t\t    </div>\n\t\t\t\t</div>\n\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<p>{tp}Plan is to keep{/tp}</p>\n\n\t\t        <div class=\"form-group\">\n\t\t          <label class=\"sr-only\" for=\"input_amount\">{tp}Amount{/tp}</label>\n\t\t          <input type=\"number\" step=\"0.01\" name=\"input_goal_balance\" class=\"form-control\" id=\"input_goal_balance\" value=\"{$preparedData->goal_balance|default:'0.00'}\" placeholder=\"{t}Amount{/t}\">\n\t\t        </div>\n\n\t\t        <div class=\"form-group\">\n\t\t          <label for=\"input_name\">{t}Select Currency{/t}</label>\n\t\t          <select name=\"input_goal_currency\" id=\"input_goal_currency\" class=\"form-control\">\n\t\t            <option value=\"\">{t}Select Currency{/t}</option>\n\t\t            {foreach from=$settings.currencies item=c key=id}\n\t\t              <option value=\"{$id}\" {if $id == $preparedData->goal_currency|default:'USD'}selected=\"selected\"{/if}>{$c}</option>\n\t\t            {/foreach}\n\t\t          </select>\n\t\t        </div>\n\n\t\t\t\t<button class=\"btn btn-default\" type=\"submit\" id=\"set_goal_to_start\">{tp}Set to{/tp} <span id=\"set_goal_to_start_c\">USD</span></button>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"row\">\n\t\t\t<div class=\"col-xs-12\">\n\t\t\t\t<p>{tp}So you{/tp}\n\t\t\t\t\t<span id=\"preview_spend\">{tp}can spend up to{/tp} </span>\n\t\t\t\t\t<span id=\"preview_get\">{tp}have to get{/tp} </span>\n\n\t\t\t\t\t<span id=\"preview_diff_c_dollar\">$</span><span id=\"preview_diff_rational\">100</span>.<span id=\"preview_diff_decimal\">00</span> <span id=\"preview_diff_c_other\">USD</span> \n\n\t\t\t\t\t<span id=\"preview_one_day\">{tp}on the next day{/tp}</span>\n\t\t\t\t\t<span id=\"preview_few_days\">\n\t\t\t\t\t{tp}in next{/tp} <span id=\"preview_days_count\">32</span> {tp}days{/tp}. \n\t\t\t\t\t</span>\n\n\t\t\t\t\t<span id=\"preview_d_diff_c_dollar\">$</span><span id=\"preview_d_diff_rational\">100</span>.<span id=\"preview_d_diff_decimal\">00</span> <span id=\"preview_d_diff_c_other\">USD</span>\n\t\t\t\t\t {tp}per day{/tp}. \n\t\t\t</div>\n\t\t</div>\n\n\t\t\t<button class=\"btn btn-default\" type=\"submit\" id=\"button_step2_back\">{tp}Back{/tp}</button>\n\t\t\t<button class=\"btn btn-primary\" type=\"submit\" id=\"button_step2_save\">{tp}Confirm and save{/tp}</button>\n\t\t</div>\n\t</div>\n\n\n</div>\n</div>"
  },
  {
    "path": "public/jstemplates/pages/plans/view.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{tp}Home{/tp}</a></li>\n  <li><a href=\"{$settings->site_path}/plans\">{tp}Plan your expenses{/tp}</a></li>\n  <li class=\"active\">{$plan->name|default:'Wallet'|escape:'html'}</li>\n</ul>\n\n<div class=\"row\">\n<div class=\"col-xs-12\">\n\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Goal Details{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\n\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-sm-6\">\n\t\t\t\t\t<p class=\"text-center {if $plan->start_balance >= 0}text-success{else}text-danger{/if} wallet_total\"><strong>{tp}From:{/tp} {if $plan->start_balance < 0}-{/if}{if $plan->start_currency == 'USD'}${/if}{$plan->start_balance|rational}.<sup>{$plan->start_balance|decimal}</sup>{if $plan->start_currency != 'USD'} {$plan->start_currency}{/if}</strong></p>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"col-sm-6\">\n\n\t\t\t\t\t<p class=\"text-center {if $plan->goal_balance >= 0}text-success{else}text-danger{/if} wallet_total\"><strong>{tp}To:{/tp} {if $plan->goal_balance < 0}-{/if}{if $plan->goal_currency == 'USD'}${/if}{$plan->goal_balance|rational}.<sup>{$plan->goal_balance|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if}</strong></p>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"col-xs-12\">\n\n\t\t\t\t\t<p class=\"text-center\">{if $stats|count > 1}{$stats|count} {tp}days{/tp}.{/if} {tp}From{/tp} {$plan->start_datetime|wallet_date} {tp}to{/tp} {$plan->goal_datetime|wallet_date}</p>\n\n\t\t\t\t\t<div class=\"text-center\">\n\t\t\t\t\t\t<a class=\"btn btn-default\" href=\"#\" role=\"button\" id=\"reload_stats_button\" data-loading-text=\"{t}Loading...{/t}\"><span class=\"glyphicon glyphicon-refresh\"></span> {tp}Refresh{/tp}</a>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<p class=\"text-center\" style=\"margin-top: 10px;\" id=\"advice_today\">\n\t\t\t\t\t\t{if $adviceData.hasToday}\n\t\t\t\t\t\t\t{if $adviceData.todaysPlan < 0}\n\t\t\t\t\t\t\t\t<span>Your goal for today is to spend at most {if $plan->goal_currency == 'USD'}${/if}{$adviceData.todaysPlan|rational}.<sup>{$adviceData.todaysPlan|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if}</span>\n\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t<span>Your goal for today is to earn at least {if $plan->goal_currency == 'USD'}${/if}{$adviceData.todaysPlan|rational}.<sup>{$adviceData.todaysPlan|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if}</span>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{if $adviceData.todaysAlreadyTotal != 0}\n\t\t\t\t\t\t\t\t{if $adviceData.todaysAlreadyTotal < 0}\n\t\t\t\t\t\t\t\t\t<span>At this point, you've spent {if $plan->goal_currency == 'USD'}${/if}{$adviceData.todaysAlreadyTotal|rational}.<sup>{$adviceData.todaysAlreadyTotal|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if} today already.</span>\n\t\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t\t<span>At this point, you've already earned {if $plan->goal_currency == 'USD'}${/if}{$adviceData.todaysAlreadyTotal|rational}.<sup>{$adviceData.todaysAlreadyTotal|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if} today.</span>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t{if $adviceData.todaysPlan < 0}\n\t\t\t\t\t\t\t\t\t<span>You have no spendings for today.</span>\n\t\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t\t<span>You've earned nothing today.</span>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{if $adviceData.hasTomorrow}\n\t\t\t\t\t\t\t\t{if $adviceData.tomorrowPlan < 0}\n\t\t\t\t\t\t\t\t\t<span>Which means you can spend up to {if $plan->goal_currency == 'USD'}${/if}{$adviceData.tomorrowPlan|rational}.<sup>{$adviceData.tomorrowPlan|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if} tomorrow.</span>\n\t\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t\t<span>Which means you have to earn at least {if $plan->goal_currency == 'USD'}${/if}{$adviceData.tomorrowPlan|rational}.<sup>{$adviceData.tomorrowPlan|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if} tomorrow.</span>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t{if $adviceData.todaysDif < 0}\n\t\t\t\t\t\t\t\t\t<span>Today is the last day of your plan, be sure to spend no more than {if $plan->goal_currency == 'USD'}${/if}{$adviceData.todaysDif|rational}.<sup>{$adviceData.todaysDif|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if} more to achieve success with this goal.</span>\n\t\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t\t<span>Today is the last day of your plan, be sure to earn {if $plan->goal_currency == 'USD'}${/if}{$adviceData.todaysDif|rational}.<sup>{$adviceData.todaysDif|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if} more to achieve success with this goal.</span>\n\t\t\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{if $adviceData.hasFuture}\n\t\t\t\t\t\t\t\t{if $adviceData.futureMaxPlan < 0}\n\t\t\t\t\t\t\t\t\t<span>Spend less than DimeShift suggests you each day and you will have more money available for spending each day. Up&nbsp;to&nbsp;{if $plan->goal_currency == 'USD'}${/if}{$adviceData.futureMaxPlan|rational}.<sup>{$adviceData.futureMaxPlan|decimal}</sup>{if $plan->goal_currency != 'USD'} {$plan->goal_currency}{/if}&nbsp;on&nbsp;{$adviceData.futureEndDate|wallet_date}!</span>\n\t\t\t\t\t\t\t\t{else}\n\t\t\t\t\t\t\t\t\t<span>Of course, feel free to earn more than DimeShift suggests you each day.</span>\n\t\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t{/if}\n\t\t\t\t\t</p>\n\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t</div>\n\t</div>\n</div>\n</div>\n\n<div class=\"row\">\n<div class=\"col-xs-12\">\n\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Day by day report{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\n<table class=\"table table-condensed\">\n\t<tr>\n\t\t<th>{tp}Date{/tp}</th>\n\t\t<th><span style=\"visibility: hidden;\" class=\"hidden-xs hidden-sm\">-</span>{tp}Total On Start{/tp}</th>\n\t\t<th><span class=\"text-danger\">{tp}Spent{/tp}</span></th>\n\t\t<th><span class=\"text-success\">{tp}Profit{/tp}</span></th>\n\t\t<th>{tp}Plan{/tp}</th>\n\t</tr>\n\t{if $stats|count == 0}\n\t{else}\n\t\t{assign var=\"possibleLowestSpending\" value=null}\n\t\t{foreach from=$stats item=s}\n\t\t<tr class=\"{if $s->date->unix_from > $currentTimestamp}active{else}{if $s->date->unix_from < $currentTimestamp && $s->date->unix_to > $currentTimestamp}info{else}{if ($s->allowedToSpend > 0 && $s->dayTotal >= $s->allowedToSpend) || ($s->allowedToSpend <= 0 && $s->dayTotal > $s->allowedToSpend)}success{else}danger{/if}{/if}{/if}\">\n\t\t\t<td>{$s->date->unix|wallet_date}</td>\n\t\t\t<td>\n\t\t\t\t{if $s->date->unix_from < $currentTimestamp && $s->date->unix_to > $currentTimestamp}\n\t\t\t\t<strong><span {if $s->currentTotalOnStart >= 0}style=\"visibility: hidden;\" class=\"hidden-xs hidden-sm\"{/if}>-</span>{$s->currentTotalOnStart|rational}.<sup>{$s->currentTotalOnStart|decimal}</sup></strong>\n\t\t\t\t{else}\n\t\t\t\t<span {if $s->currentTotalOnStart >= 0}style=\"visibility: hidden;\"{/if}>-</span>{$s->currentTotalOnStart|rational}.<sup>{$s->currentTotalOnStart|decimal}</sup>\n\t\t\t\t{/if}\n\t\t\t</td>\n\t\t\t{if $s->date->unix_from > $currentTimestamp}\n\t\t\t<td colspan=\"2\">&nbsp;</td>\n\t\t\t{else}\n\t\t\t<td>{$s->expensesTotal|rational}.<sup>{$s->expensesTotal|decimal}</sup></td>\n\t\t\t<td>{$s->profitsTotal|rational}.<sup>{$s->profitsTotal|decimal}</sup></td>\n\t\t\t{/if}\n\t\t\t<td><span class=\"{if $s->allowedToSpend >= 0}text-success{else}text-danger{/if}\">\n\t\t\t\t{if $s->date->unix_from > $currentTimestamp && $possibleLowestSpending !== null}\n\t\t\t\t\t{$possibleLowestSpending|rational}.<sup>{$possibleLowestSpending|decimal}</sup>\t&ndash;\t\t\t\t\n\t\t\t\t{/if}\n\t\t\t\t{$s->allowedToSpend|rational}.<sup>{$s->allowedToSpend|decimal}</sup>\n\t\t\t\t{if $s->date->unix_from > $currentTimestamp && $possibleLowestSpending == null}\n\t\t\t\t\t{assign var=\"possibleLowestSpending\" value=$s->allowedToSpend}\n\t\t\t\t{/if}\n\t\t\t</span></td>\n\t\t</tr>\n\t\t{/foreach}\n\t{/if}\n</table>\n\n\t\t</div>\n\t</div>\n\n</div>\n</div>"
  },
  {
    "path": "public/jstemplates/pages/profile/index.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{tp}Home{/tp}</a></li>\n  <li class=\"active\">{tp}Settings{/tp}</li>\n</ul>\n\n\n<div class=\"row\">\n\t<div class=\"col-xs-12 col-md-9\">\n\n\t<div id=\"profile_change_password_container\" class=\"profile_container\">\n\t\t<div class=\"alert alert-info\" role=\"alert\" style=\"display: none;\">\n\t\t\t{tp}Your password has been successfully changed{/tp}\n\t\t</div>\n\t\t<div class=\"alert alert-danger\" role=\"alert\" style=\"display: none;\">\n\t\t\t<span class=\"errorNo1\" data-input=\"current_password_input\">{tp}Invalid current password{/tp}</span>\n\t\t\t<span class=\"errorNo2\" data-input=\"new_password_repeat_input\">{tp}Passwords missmatch{/tp}</span>\n\t\t\t<span class=\"errorNo3\" data-input=\"new_password_input\">{tp}New password is too short{/tp}</span>\n\t\t</div>\n\t\t<form id=\"change_password_form\">\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"current_password_input\">{tp}Current Password{/tp}</label>\n\t\t\t\t<input type=\"password\" class=\"form-control\" \n\t\t\t\t\tid=\"current_password_input\" \n\t\t\t\t\tplaceholder=\"{t}Current Password{/t}\" data-i18nplaceholder=\"Current Password\">\n\t\t\t</div>\n\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"new_password_input\">{tp}New Password{/tp}</label>\n\t\t\t\t<input type=\"password\" class=\"form-control\" \n\t\t\t\t\tid=\"new_password_input\" \n\t\t\t\t\tplaceholder=\"{t}New Password{/t}\" data-i18nplaceholder=\"New Password\">\n\t\t\t</div>\n\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"new_password_repeat_input\">{tp}Repeat Password{/tp}</label>\n\t\t\t\t<input type=\"password\" class=\"form-control\" \n\t\t\t\t\tid=\"new_password_repeat_input\" \n\t\t\t\t\tplaceholder=\"{t}Repeat Password{/t}\" data-i18nplaceholder=\"Repeat Password\">\n\t\t\t</div>\n\n\t\t\t<input type=\"submit\" class=\"btn btn-primary\" data-i18nvalue=\"Change Password\" value=\"{t}Change Password{/t}\">\n\t\t</form>\n\t</div>\n\n\n\t<div id=\"profile_remove_account_container\" class=\"profile_container\" style=\"display: none;\">\n\n\t\t{if $user.isDemo()}\n\t\t<div class=\"alert alert-info\">\n\t\t\t{tp}Demo account will be removed as soon as you do log out from it.{/tp}\n\t\t</div>\n\n\t\t\t<a href=\"/user/logout\" class=\"btn btn-primary\">{tp}Log Out{/tp}</a>\n\t\t{else}\n\n\t\t<div id=\"profile_remove_account_step_1\">\n\t\t\t<div class=\"alert alert-danger\" role=\"alert\">\n\t\t\t\t{tp}Please think twice. All account data will be lost.{/tp}\n\t\t\t</div>\n\n\t\t\t<form id=\"remove_account_step_1_form\">\n\t\t\t\t<input type=\"submit\" class=\"btn btn-primary\" id=\"remove_account_step_1_submit\" data-i18nvalue=\"Remove account\" value=\"{t}Remove account{/t}\">\n\t\t\t</form>\n\t\t</div>\n\n\t\t<div id=\"profile_remove_account_step_2\" style=\"display: none;\">\n\n\t\t\t<div class=\"alert alert-danger\" role=\"alert\">\n\t\t\t\t{tp}Security code{/tp} {tp}has been mailed to your email. Please fill this form to finish account removal.{/tp}\n\t\t\t</div>\n\n\t\t\t<div class=\"alert alert-info\" id=\"profile_remove_account_done\" role=\"alert\" style=\"display: none;\">\n\t\t\t\t{tp}Your account has been removed. We will miss you :({/tp}\n\t\t\t</div>\n\n\t\t\t<div class=\"alert alert-info\" id=\"invalid_remove_account_code\" role=\"alert\" style=\"display: none;\">\n\t\t\t\t{tp}Invalid{/tp} {tp}Security code{/tp}\n\t\t\t</div>\n\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"remove_account_code\">{tp}Security code{/tp}</label>\n\t\t\t\t<input type=\"text\" class=\"form-control\" \n\t\t\t\t\tid=\"remove_account_code\" \n\t\t\t\t\tplaceholder=\"{t}Security code{/t}\" data-i18nplaceholder=\"Security code\">\n\t\t\t</div>\n\n\t\t\t<form id=\"remove_account_step_2_form\">\n\t\t\t\t<input type=\"submit\" class=\"btn btn-primary\" id=\"remove_account_step_2_submit\" data-i18nvalue=\"Remove account\" value=\"{t}Remove account{/t}\">\n\t\t\t</form>\n\t\t</div>\n\t\t{/if}\n\n\t</div>\n\n\t</div>\n\t<div class=\"col-xs-12 col-md-3\">\n\t\t<div class=\"panel panel-default\">\n\t\t\t<div class=\"panel-heading\">\n\t\t\t\t<h3 class=\"panel-title\">{tp}Settings{/tp}</h3>\n\t\t\t</div>\n\t\t\t<div class=\"panel-body\">\n\t\t\t\t<ul class=\"nav nav-pills nav-stacked\">\n\t\t\t\t\t<li class=\"active\"><a href=\"#\" data-target=\"change_password\" class=\"select_part\"><span class=\"glyphicon glyphicon-lock\" ></span> {tp}Change Password{/tp}</a></li>\n\t\t\t\t\t\n\t\t\t\t\t<li><a href=\"#\" data-target=\"remove_account\" class=\"select_part\"><span class=\"glyphicon glyphicon-trash\" ></span> {tp}Remove account{/tp}</a></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</div>\n"
  },
  {
    "path": "public/jstemplates/pages/user/confirm.tpl",
    "content": "<h4>Confirm your email address</h4>\r\n\r\n{if $confirmed}\r\n<div class=\"alert alert-success\">\r\n Your email has been confirmed. You can <a href=\"{$settings->site_path}/user/signin/\" class=\"signin_caller\">log in</a> now.\r\n</div>\r\n{else}\r\n<div class=\"alert alert-error\">\r\n Invalid confirmation code.\r\n</div>\r\n{/if}"
  },
  {
    "path": "public/jstemplates/pages/user/index.tpl",
    "content": "<h2>Dashboard</h2>\r\n"
  },
  {
    "path": "public/jstemplates/pages/user/registration.tpl",
    "content": "<script>\r\n  $(function(){\r\n    App.showDialog('Registration');\r\n  });\r\n</script>"
  },
  {
    "path": "public/jstemplates/pages/user/restore.tpl",
    "content": "<script>\r\n  $(function(){\r\n    App.showDialog('Restore');\r\n  });\r\n</script>"
  },
  {
    "path": "public/jstemplates/pages/user/signin.tpl",
    "content": "<script>\r\n  $(function(){\r\n    App.showDialog('Signin');\r\n  });\r\n</script>"
  },
  {
    "path": "public/jstemplates/pages/user/update_password.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{t}Home{/t}</a></li>\n  <li class=\"active\">{t}Update Password{/t}</li>\n</ul>\n\n\n<div class=\"row\">\n\t<div class=\"col-xs-12 col-md-9\">\n\n\t<div id=\"profile_change_password_container\">\n\t\t<div class=\"alert alert-info\" role=\"alert\" style=\"display: none;\">\n\t\t\t{t}Your password has been successfully changed. You can <a href=\"{$settings->site_path}/wallets\">sign in</a> with your new one.{/t}\n\t\t</div>\n\t\t<div class=\"alert alert-danger\" role=\"alert\" style=\"display: none;\">\n\t\t\t<span class=\"errorNo1\" data-input=\"password_restore_code\">{t}Invalid Restore Password Code{/t}</span>\n\t\t\t<span class=\"errorNo2\" data-input=\"new_password_repeat_input\">{t}Passwords missmatch{/t}</span>\n\t\t\t<span class=\"errorNo3\" data-input=\"new_password_input\">{t}New password is too short{/t}</span>\n\t\t</div>\n\t\t<form id=\"update_password_form\">\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"password_restore_code\">{t}Restore Password Code{/t}</label>\n\t\t\t\t<input type=\"text\" disabled=\"disabled\" class=\"form-control\" \n\t\t\t\t\tid=\"password_restore_code\" value=\"{$password_restore_code|escape:'html'}\">\n\t\t\t</div>\n\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"password_restore_hash\">{t}Restore Password Hash{/t}</label>\n\t\t\t\t<input type=\"text\" disabled=\"disabled\" class=\"form-control\" \n\t\t\t\t\tid=\"password_restore_hash\" value=\"{$password_restore_hash|escape:'html'}\">\n\t\t\t</div>\n\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"new_password_input\">{t}New Password{/t}</label>\n\t\t\t\t<input type=\"password\" class=\"form-control\" \n\t\t\t\t\tid=\"new_password_input\" \n\t\t\t\t\tplaceholder=\"{t}New Password{/t}\">\n\t\t\t</div>\n\n\t\t\t<div class=\"form-group\">\n\t\t\t\t<label for=\"new_password_repeat_input\">{t}Repeat Password{/t}</label>\n\t\t\t\t<input type=\"password\" class=\"form-control\" \n\t\t\t\t\tid=\"new_password_repeat_input\" \n\t\t\t\t\tplaceholder=\"{t}Repeat Password{/t}\">\n\t\t\t</div>\n\n\t\t\t<input type=\"submit\" class=\"btn btn-primary\" value=\"{t}Update Password{/t}\">\n\t\t</form>\n\t</div>\n\n\n\t</div>\n\t<div class=\"col-xs-12 col-md-3\">\n\t</div>\n</div>\n"
  },
  {
    "path": "public/jstemplates/pages/wallets/index.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{tp}Home{/tp}</a></li>\n  <li class=\"active\">{tp}Your Wallets{/tp}</li>\n</ul>\n\n\n<div class=\"row\">\n<div class=\"col-xs-12 col-md-9\">\n\n\t{if $items|count == 0}\n\t\t{if $status|default:'active' == 'active'}\n\t\t\t{if $origin|default:'mine' == 'shared'}\n\t\t\t<div class=\"alert alert-warning\" role=\"alert\">{tp}You don't have access to other users' wallets{/tp}</div>\t\n\t\t\t{else}\n\t\t\t<div class=\"alert alert-warning\" role=\"alert\">{tp}You have no wallets{/tp} <a href=\"{$settings->site_path}/wallets/add\" class=\"btn btn-primary btn-xs\" id=\"add_wallet_button\">{tp}Add{/tp}</a></div>\n\t\t\t{/if}\n\t\t{else}\n\t\t\t<div class=\"alert alert-warning\" role=\"alert\">{tp}You have no hidden wallets{/tp}</div>\t\t\t\n\t\t{/if}\n\t{else}\n\t\t<div class=\"list-group wallet_item\" id=\"wallet_items\">\n\t\t{foreach from=$items item=i}\n\t\t\t<a href=\"{$settings->site_path}/wallets/{$i->id}\" class=\"list-group-item item\" data-id=\"{$i->id}\" \n\t\t\t\t{if $i->origin|default:'mine' == 'shared'}style=\"background: #eee\"{/if}>\n\t\t\t    \n\t\t\t\t\n\t\t\t\t<div class=\"pull-right {if $i->total >= 0}text-success{else}text-danger{/if} \n\t\t\t\ttransaction_amount\"><strong>{if $i->total < 0}-{/if}{if $i->currency == 'USD'}${/if}{$i->total|rational}.<sup>{$i->total|decimal}</sup>{if $i->currency != 'USD'} {$i->currency}{/if}</strong></div>\n\n\t\t\t\t<div class=\"item_buttons hideme wallet_buttons\">\n\t\t\t\t{if $i->origin|default:'mine' == 'mine'}\n\t\t\t\t\t<button class=\"btn btn-default btn-xs item_button_remove\"><span class=\"glyphicon glyphicon-trash\"></span> {if $i->status|default:'active' == 'active'}{tp}Hide{/tp}{else}{tp}Remove{/tp}{/if}</button>\n\t\t\t\t\t{if $i->status|default:'active' == 'active'}\n\t\t\t\t\t<button class=\"btn btn-default btn-xs item_button_edit\"><span class=\"glyphicon glyphicon-pencil\"></span> {tp}Edit{/tp}</button>\n\t\t\t\t\t<button class=\"btn btn-default btn-xs item_button_accesses\"><span class=\"glyphicon glyphicon-user\"></span> {tp}Manage Accesses{/tp}</button>\n\t\t\t\t\t{/if}\n\t\t\t\t\t{if $i->status|default:'active' == 'hidden'}\n\t\t\t\t\t<button class=\"btn btn-default btn-xs item_button_restore\"><span class=\"glyphicon glyphicon-repeat\"></span> {tp}Restore{/tp}</button>\n\t\t\t\t\t{/if}\n\t\t\t\t{/if}\n\t\t\t\t</div>\n\t\t\t\t<h4 class=\"list-group-item-heading\">\n\t\t\t\t{if $i->origin|default:'mine' == 'shared'}<span class=\"glyphicon glyphicon-share-alt\" title=\"{tp}This wallet is shared with you by another user{/tp}\"></span> {/if}\n\t\t\t\t{$i->name|escape:'html'}</h4>\n\n\t\t\t</a>\n\t\t{/foreach}\n\n\t\t{if $status|default:'active' == 'active'}\n\t\t\t<div class=\"list-group-item list-group-item-info\"><a href=\"{$settings->site_path}/wallets/add\" class=\"btn btn-primary\" id=\"add_wallet_button\">{tp}Add{/tp}</a></div>\n\t\t{/if}\n\t\t</div>\t\n\t{/if}\n\n</div>\n<div class=\"col-xs-12 col-md-3\">\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Filter{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\t\t\t<ul class=\"nav nav-pills nav-stacked\">\n\t\t\t\t<li {if $status|default:'active' == 'active'}class=\"active\"{/if}><a href=\"#\" class=\"filter_menu\" data-status=\"active\"><span class=\"glyphicon glyphicon-ok\"></span> {tp}Active{/tp}</a></li>\n\t\t\t\t<li {if $status|default:'active' == 'hidden'}class=\"active\"{/if}><a href=\"#\" class=\"filter_menu\" data-status=\"hidden\"><span class=\"glyphicon glyphicon-trash\"></span> {tp}Trash{/tp}</a></li>\n\t\t\t</ul>\n\t\t</div>\n\t</div>\n\n\n\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">\n\t\t\t<h3 class=\"panel-title\">{tp}Access{/tp}</h3>\n\t\t</div>\n\t\t<div class=\"panel-body\">\n\t\t\t<ul class=\"nav nav-pills nav-stacked\">\n\t\t\t\t<li {if $origin|default:'both' == 'both'}class=\"active\"{/if}><a href=\"#\" class=\"origin_menu\" data-origin=\"both\"><span class=\"glyphicon glyphicon-ok\"></span> {tp}Both{/tp}</a></li>\n\t\t\t\t<li {if $origin|default:'both' == 'mine'}class=\"active\"{/if}><a href=\"#\" class=\"origin_menu\" data-origin=\"mine\"><span class=\"glyphicon glyphicon-user\"></span> {tp}Yours{/tp}</a></li>\n\t\t\t\t<li {if $origin|default:'both' == 'shared'}class=\"active\"{/if}><a href=\"#\" class=\"origin_menu\" data-origin=\"shared\"><span class=\"glyphicon glyphicon-share-alt\"></span> {tp}Shared with you{/tp}</a></li>\n\t\t\t</ul>\n\t\t</div>\n\t</div>\n\n\n</div>\n</div>\n\n\n<div class=\"hidden\">\n\t<span id=\"tour_step_0\">{t}Here is quick introdution to DimeShift.<br><br>Our demo robot has created few sample wallets for you to check out.{/t}</span>\n\t<span id=\"tour_step_1\">{t}But you can add as many as you want.<br><br>Different name, different currencies{/t}</span>\n\t<span id=\"tour_step_2\">{t}There're few options availiable when you move your mouse over your wallet.<br><br>\n\tBut lets jump directly to wallet page.<br><br>Click any row to jump to it.\n\t{/t}</span>\n</div>"
  },
  {
    "path": "public/jstemplates/pages/wallets/view.tpl",
    "content": "<ul class=\"breadcrumb\">\n  <li><a href=\"{$settings->site_path}\">{tp}Home{/tp}</a></li>\n  <li><a href=\"{$settings->site_path}/wallets\">{tp}Wallets{/tp}</a></li>\n  <li class=\"active\">{$item->name|default:'Wallet'|escape:'html'}</li>\n</ul>\n\n\n<div class=\"row\">\n\n\t<div class=\"col-xs-12 col-sm-12 col-md-4 pull-right\">\n\t\t<div class=\"panel panel-default\">\n\t\t\t<div class=\"panel-heading\">\n\t\t\t\t<h3 class=\"panel-title\">{$item->name|escape:'html'}</h3>\n\t\t\t</div>\n\t\t\t<div class=\"panel-body\">\n\t\t\t\n\t\t\t\t<p class=\"text-center {if $item->total >= 0}text-success{else}text-danger{/if} wallet_total\"><strong>{if $item->total < 0}-{/if}{if $item->currency == 'USD'}${/if}{$item->total|rational}.<sup>{$item->total|decimal}</sup>{if $item->currency != 'USD'} {$item->currency}{/if}</strong></p>\n\t\t\t\t\n\t\t\t\t<button type=\"button\" id=\"add_profit_button\" class=\"btn btn-success btn-block\">{tp}Add Income{/tp}</button>\n\t\t\t\t<div class=\"pull-right\">{tp}or{/tp} <a href=\"#\" class=\"action\" id=\"set_total_to_button\">{tp}set total to{/tp}</a></div>\n\t\t\t</div>\n\t\t</div>\n\n\n\t</div>\n\n\t<div class=\"col-xs-12 col-sm-12 col-md-8 pull-left\">\n\n\t\t<div class=\"list-group\">\n\t\t\t<div class=\"list-group-item \">\n\t\t\t\t<h3 class=\"panel-title\">{tp}Transactions{/tp}\n\t\t\t\t\t<span class=\"pull-right\"><a href=\"{$settings->site_path}/wallets/{$item->id}/import/\" class=\"btn btn-default btn-xs\"><span class=\"glyphicon glyphicon-import\" aria-hidden=\"true\"></span> {tp}Import{/tp}</a></span>\n\t\t\t\t</h3>\n\n\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t<form method=\"post\" id=\"add_transaction_form\">\n\t\t\t\t\t\t<input type=\"text\" class=\"form-control\" id=\"add_transaction_text\" placeholder=\"{t}Describe expense and press Enter to add{/t}\" data-i18nplaceholder=\"Describe expense and press Enter to add\">\n\t\t\t\t\t\t<input type=\"number\" min=\"0\" step=\"0.01\" class=\"form-control hideme\" id=\"add_transaction_amount\" placeholder=\"{t}Transaction amount{/t}\" data-i18nplaceholder=\"Transaction amount\">\n\t\t\t\t\t\t<button type=\"submit\" class=\"hideme\">\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div id=\"transactions_container\">\n\n\t\t\t</div>\n\n\t\t</div>\t\n\n\n\t</div>\n\n\t<div class=\"col-xs-12 col-sm-12 col-md-4 pull-right\">\n\n\t\t<div id=\"plans_container\">\n\n\t\t</div>\n\n\t\t<div class=\"panel panel-default\" id=\"balance_canvas_container\">\n\t\t\t<div class=\"panel-heading\">\n\t\t\t\t<h3 class=\"panel-title\">{tp}Expenses per day trends{/tp}</h3>\n\t\t\t</div>\n\t\t\t<div class=\"panel-body\">\n\t\t\t\t<div id=\"balance_canvas\" class=\"ct-chart\" ></div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\n\n</div>\n\n\n<div class=\"hidden\">\n\t<span id=\"tour_step_0\">{t}Let's start by adding some money to your wallet.<br><br>Click \"Add Profit\" button and fill the form in modal window. It's simple.{/t}</span>\n\t<span id=\"tour_step_1\">{t}You can also set current total with \"Set Total To\" dialog.<br><br>\n\t\t\t\t\tWe don't ask you to track every transaction you've done(though you can). \n\t\t\t\t\tFeel free to update your DimeShift wallet every evening, or even once in few days.<br><br>\n\t\t\t\t\tClick \"set total to\" action link and fill the form to check how it works.{/t}</span>\n\t<span id=\"tour_step_2\">{t}It's time to add some expense.<br><br>\n\tYou can add transaction with one string, e.g. \"99.93, best expense ever\".<br><br>\n\tPress Enter when tranasction description is ready.\n\t{/t}</span>\n\t<span id=\"tour_step_3\">{t}Check out updated transactions list{/t}</span>\n\t<span id=\"tour_step_4\">{t}Check out expenses per day trends. Simple chart that gets updated every time you add another tranasction.{/t}</span>\n\t<span id=\"tour_step_5\">{t}Don't forget to fill your profile, so you can sign in to DimeShift next time.{/t}</span>\n</div>"
  },
  {
    "path": "public/jstemplates/parts/transactions.tpl",
    "content": "{if $state == 'loading'}\n\t<div class=\"list-group-item\">\n\t\t<div class=\"page_loading\"></div>\n\t</div>\n{else}\n<div id=\"transactions_container\">\n\t{if $collection|default:false && $collection.hasNextPeriod()}\n\t\t{if $collection.diffToCurrentPeriod() < 2}\n\t\t\t<div class=\"list-group-item\">\n\t\t\t\t<button type=\"button\" class=\"btn btn-default btn-sm  btn-info btn-block\" id=\"goto_next\">\n\t\t\t\t<span class=\"glyphicon glyphicon-chevron-up\" aria-hidden=\"true\"></span> {$collection.nextPeriodToReadableFormat()}</button>\n\t\t\t</div>\n\t\t{else}\n\t\t\t<div class=\"list-group-item\">\n\t\t\t\t<div class=\"btn-group btn-group-justified\" role=\"group\">\n\t\t\t\t\t<div class=\"btn-group\" role=\"group\">\n\t\t\t\t\t\t<button type=\"button\" class=\"btn btn-default btn-sm btn-info\" id=\"goto_current\">\n\t\t\t\t\t\t<span class=\"glyphicon glyphicon-chevron-left\" aria-hidden=\"true\"></span> {$collection.currentPeriodToReadableFormat()}</button>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"btn-group\" role=\"group\">\n\t\t\t\t\t\t<button type=\"button\" class=\"btn btn-default btn-sm btn-info\" id=\"goto_next\">\n\t\t\t\t\t\t<span class=\"glyphicon glyphicon-chevron-up\" aria-hidden=\"true\"></span> {$collection.nextPeriodToReadableFormat()}</button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t{/if}\n\t{/if}\n\n\n\n\n\t{if $transactions|count > 0}\n\t\t{foreach from=$transactions item=t}\n\t\t<div class=\"list-group-item item\" data-id=\"{$t->id}\">\n\t\t\t<div class=\"pull-left transaction_time\">\n\t\t\t\t{assign var=\"current_transaction_time_date\" value=$t->datetime|wallet_date}\n\t\t\t\t<div class=\"transaction_time_date\">{if $last_time_date|default:'' != $current_transaction_time_date}{$current_transaction_time_date}{else}&nbsp;{/if}</div>\n\t\t\t\t<div class=\"transaction_time_time\">{$t->datetime|wallet_time}</div>\n\t\t\t\t{assign var=\"last_time_date\" value=$current_transaction_time_date}\n\t\t\t</div>\n\n\t\t\t<div class=\"pull-right {if $t->amount >= 0}text-success{else}text-danger{/if} transaction_amount\">&nbsp; <strong>{if $item->currency == 'USD'}${/if}{$t->amount|rational}.<sup>{$t->amount|decimal}</sup>{if $item->currency != 'USD'} {$item->currency}{/if}</strong></div>\n\t\t\t\n\t\t\t<h6 class=\"list-group-item-heading transaction_description\">{$t->description|escape:'html'|default:'&nbsp;'}</h6>\n\t\t</div>\n\t\t{/foreach}\n\t{else}\n\t<div class=\"list-group-item\">\n\t\t{tp}No transactions for{/tp} {$collection.periodToReadableFormat()}\n\t</div>\t\n\t{/if}\n\n\t{if $collection|default:false && $collection.hasPrevPeriod()}\n\t<div class=\"list-group-item\">\n\t\t<button type=\"button\" class=\"btn btn-default btn-sm btn-info btn-block\" id=\"goto_prev\">\n\t\t<span class=\"glyphicon glyphicon-chevron-down\" aria-hidden=\"true\"></span> {$collection.prevPeriodToReadableFormat()}</button>\n\t</div>\n\t{/if}\n\n\n\n</div>\n{/if}"
  },
  {
    "path": "public/jstemplates/parts/wallet_plans.tpl",
    "content": "\n\n\n<div class=\"panel panel-default\">\n\t<div class=\"panel-heading\">\n\t\t<h3 class=\"panel-title\">{tp}Goals{/tp}</h3>\n\t</div>\n\t{if $plans|count > 0}\n\t\t<div class=\"list-group\">\n\t\t\t{foreach from=$plans item=p}\n\t\t\t\t{if $p->plan->status != 'finished'}\n\t\t\t\t{assign var=\"hasActivePlans\" value=true}\n\t\t\t\t<a href=\"{$settings->site_path}/plans/{$p->plan->id}\" class=\"list-group-item\">\n\t\t\t\t\t<h4 class=\"list-group-item-heading\">{$p->plan->name|escape:'html'}</h4>\n\t\t\t\t\t{if $areStatsReady}\n\t\t\t\t\t\t{assign var=\"allowedToSpend\" value=$p->allowedToSpendInWalletCurrency}\n\t\t\t\t\t\t<p class=\"list-group-item-text\">\n\t\t\t\t\t\t{tp}You{/tp}\n\n\t\t\t\t\t\t{if $allowedToSpend < 0}\n\t\t\t\t\t\t<span id=\"preview_spend\">{tp}can spend up to{/tp} </span>\n\t\t\t\t\t\t{else}\n\t\t\t\t\t\t<span id=\"preview_get\">{tp}have to get{/tp} </span>\n\t\t\t\t\t\t{/if}\n\n\t\t\t\t\t\t<span \n\t\t\t\t\t\t\t{if $wallet->currency != $p->plan->goal_currency} \n\t\t\t\t\t\t\t\t{assign var=\"pas\" value=$p->allowedToSpend}\n\t\t\t\t\t\t\t\tdata-toggle=\"tooltip\" data-placement=\"top\" \n\t\t\t\t\t\t\t\ttitle=\"{if $p->plan->goal_currency == 'USD'}${/if}{$pas|rational}.{$pas|decimal}{if $p->plan->goal_currency != 'USD'} {$wallet->currency}{/if}\"\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t>\n\n\t\t\t\t\t\t\t{if $wallet->currency == 'USD'}${/if}{$allowedToSpend|rational}.<sup>{$allowedToSpend|decimal}</sup>{if $wallet->currency != 'USD'} {$wallet->currency}{/if}\n\n\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t{tp}today{/tp}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t{else}\n\t\t\t\t\t\t<p class=\"list-group-item-text\">\n\t\t\t\t\t\t\tLoading\n\t\t\t\t\t\t</p>\n\t\t\t\t\t{/if}\n\t\t\t\t</a>\n\t\t\t\t{/if}\n\t\t\t{/foreach}\n\t\t</div>\n\t{/if}\n\n\t{if !$hasActivePlans}\n\t\t<div class=\"panel-body\">\n\t\t\t{tp}There're no goals defined for this wallet{/tp}\n\t\t\t<a href=\"{$settings->site_path}/plans\" class=\"btn btn-default btn-block\">{tp}Set Goal{/tp}</a>\n\t\t</div>\n\t{/if}\n</div>"
  },
  {
    "path": "public/scripts/.gitignore",
    "content": "dist/*"
  },
  {
    "path": "public/scripts/app/abstract/dialog.js",
    "content": "// dialog.js\nApp.Views.Abstract.Dialog = Backbone.View.extend({\n\n\tel: $(\"#dialog_wrapper\"),\n\tisVisible: false,\n\tfocusOnInit: false,\n\tinitialFocus: function() {\n\t\tif ('ontouchstart' in window || navigator.maxTouchPoints)\n\t\t\treturn false; /// do not focus on touch devices\n\t\tif (!this.focusOnInit)\n\t\t\treturn false;\n\n\t\tthis.$(this.focusOnInit).focus();\n\t\treturn true;\n\t},\n\tshow: function(data) {\n\t\tif (!$(\"#dialog_wrapper\").length)\n\t\t\t$('body').append(\"<div id='dialog_wrapper'></div>\");\n\n\t\tthis.setElement($(\"#dialog_wrapper\"));\n\n\t\tif (typeof(data) === 'undefined')\n\t\t\tdata = {};\n\n\t\tthis.renderLoading();\n\n\t\tvar that = this;\n\t\tvar rendered = new $.Deferred();\n\t\tvar shown = new $.Deferred();\n\n\t\t$.when(rendered, shown).done(function() {\n\t\t\tthat.initialFocus();\n\t\t\tthat.trigger('ready');\n\t\t});\n\t\tthis.$el.children().on('shown.bs.modal', function(e) {\n\t\t\tthat.isVisible = true;\n\t\t\tconsole.log(\"Dialog \" + that.dialogName + \" is shown. Firing shown event.\");\n\t\t\tthat.trigger('shown');\n\t\t\tshown.resolve();\n\t\t});\n\t\tthis.$el.children().on('hidden.bs.modal', function(e) {\n\t\t\tthat.isVisible = false;\n\t\t\tthat.undelegateEvents();\n\t\t\t$(\"#dialog_wrapper\").html('');\n\t\t\tconsole.log(\"Dialog \" + that.dialogName + \" is hidden. Firing hidden event.\");\n\t\t\tthat.trigger('hidden');\n\t\t});\n\t\tthis.once('rendered', function() {\n\t\t\trendered.resolve();\n\t\t});\n\n\t\tthis.isVisible = true;\n\t\tthis.$el.children().modal();\n\t\tthis.renderHTML(data);\n\t},\n\trenderLoading: function() {\n\t\tconsole.log('Dialog ' + this.dialogName + ' rendered loading');\n\t\tthis.$el.html('<div id=\"dialog_' + this.dialogName + '\" class=\"modal dialog_' + this.dialogName + '\" role=\"dialog\" aria-labelledby=\"dialog_label\">' +\n\t\t\t'<div class=\"modal-dialog\"><div class=\"modal-content modal-loading\">Loading</div></div></div>');\n\t},\n\trenderHTML: function(data) {\n\t\tvar that = this;\n\t\tApp.templateManager.fetch('dialogs/' + this.dialogName, data, function(html) {\n\t\t\tconsole.log('Dialog ' + that.dialogName + ' rendering');\n\t\t\tthat.$(\".modal\").html(html);\n\t\t\tthat.trigger('rendered');\n\t\t\tconsole.log('Dialog ' + that.dialogName + ' rendered');\n\t\t});\n\t},\n\thide: function() {\n\t\tconsole.log(\"Hide dialog\");\n\t\tthis.$el.children().modal('hide');\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/abstract/page.js",
    "content": "// page.js\nApp.Views.Abstract.Page = Backbone.View.extend({\n\n\tisReady: false,\n\trequiresSignedIn: false,\n\twidgets: [],\n\tparts: [],\n\tpartsInitialized: false,\n\trequireSingedIn: function(callback) {\n\t\tthis.requiresSignedIn = true;\n\n\t\tthis.listenToOnce(App.currentUser, 'signedout', function() {\n\t\t\tconsole.log('abstract/page.js | Clearing stack and redirect user back to the root');\n\t\t\tApp.viewStack.clear();\n\t\t\tApp.router.redirect('/');\n\t\t});\n\n\t\tif (typeof(App.currentUser) !== 'undefined' && App.currentUser.isSignedIn()) {\n\t\t\tif (typeof(callback) === 'function')\n\t\t\t\tcallback(App.currentUser);\n\t\t\treturn App.currentUser;\n\t\t} else {\n\t\t\tthis.listenToOnce(App.currentUser, 'signedin', function() {\n\t\t\t\tcallback(App.currentUser);\n\t\t\t});\n\t\t\tApp.showDialog('Signin');\n\t\t\tApp.dialog.on('hidden', function() {\n\t\t\t\tif (!App.currentUser.isSignedIn()) {\n\t\t\t\t\tApp.viewStack.clear();\n\t\t\t\t\tApp.router.navigate('/', {\n\t\t\t\t\t\ttrigger: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t},\n\tsetURL: function(url) {\n\t\tif (typeof(url) === 'undefined') {\n\t\t\turl = '';\n\t\t\tif (typeof(this.url) === 'function')\n\t\t\t\turl = this.url();\n\t\t\telse if (typeof(this.url) === 'string')\n\t\t\t\turl = this.url;\n\t\t}\n\n\t\tif (url) {\n\t\t\tApp.router.setUrl(url);\n\t\t\tApp.log.setURL(url);\n\t\t} else {\n\t\t\tApp.log.setURL('');\n\t\t}\n\n\t\tApp.log.pageView();\n\t},\n\tsetTitle: function(title) {\n\t\tif (typeof(title) === 'undefined') {\n\t\t\ttitle = '';\n\t\t\tif (typeof(this.title) === 'function')\n\t\t\t\ttitle = this.title();\n\t\t\telse if (typeof(this.title) === 'string')\n\t\t\t\ttitle = this.title;\n\t\t}\n\n\t\tif (typeof(App.settings.title) == 'function')\n\t\t\ttitle = App.settings.title(title);\n\n\t\tif (title) {\n\t\t\tconsole.log(\"Document title changed to '\" + title + \"'\");\n\t\t\t$(document).attr('title', title);\n\t\t\tApp.log.setTitle(title);\n\t\t}\n\t},\n\twakeUp: function() {\n\t\tApp.setProgress(false);\n\t\tthis.holderReady = false;\n\t\tthis.render();\n\t},\n\tsleep: function() {\n\n\t\tfor (var k in this.parts) {\n\t\t\tthis.parts[k].undelegateEvents();\n\t\t\tthis.parts[k].stopListening();\n\t\t}\n\n\t\tthis.undelegateEvents();\n\t\tthis.stopListening();\n\t},\n\tproccessWidgets: function() {\n\t\tthis.widgets = [];\n\t\tvar that = this;\n\t\tthis.$('.client-side-widget').each(function() {\n\t\t\tvar data = $(this).data();\n\t\t\tif (typeof(data.widgetName) === 'undefined' || !data.widgetName)\n\t\t\t\treturn false;\n\n\t\t\tif (typeof(App.Views.Widgets[data.widgetName]) === 'undefined') {\n\t\t\t\tconsole.error('Widget class for ' + data.widgetName + ' is not defined');\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tvar widgetView = new App.Views.Widgets[data.widgetName]({\n\t\t\t\tel: $(this)\n\t\t\t});\n\n\t\t\tthat.widgets.push(widgetView);\n\t\t});\n\t},\n\trenderHTML: function(data) {\n\n\t\tif (typeof(this.templateName) === 'undefined' || !this.templateName)\n\t\t\tthrow 'templateName is undefined';\n\n\t\tif (typeof(data) === 'undefined')\n\t\t\tdata = {};\n\n\t\tthis.switchBuffers();\n\n\t\tvar that = this;\n\t\tApp.templateManager.fetch(this.templateName, data, function(html) {\n\t\t\tthat.$el.html('<div class=\"page\">' + html + '</div>');\n\t\t\t$('.page', \"#page_holder_\" + App.currentHolder).removeClass('page_loading');\n\t\t\tthat.proccessWidgets();\n\t\t\tthat.trigger('render');\n\t\t\tthat.trigger('loaded');\n\n\t\t\tApp.setProgress(true);\n\t\t});\n\t\tthis.setTitle();\n\t\tthis.setURL();\n\t\tthis.isReady = true;\n\n\t\treturn this;\n\t},\n\tswitchBuffers: function() {\n\t\tif (typeof(this.holderReady) !== 'undefined' && this.holderReady === true)\n\t\t\treturn true;\n\t\tconsole.log('Switching buffers');\n\t\tvar holderToRenderTo = 2;\n\t\tif (typeof(App.currentHolder) !== 'undefined' && App.currentHolder == 2)\n\t\t\tholderToRenderTo = 1;\n\n\t\tvar holderToFadeOut = (holderToRenderTo == 1) ? 2 : 1;\n\n\t\t$(\"#page_holder_\" + holderToFadeOut).hide();\n\t\t$(\"#page_holder_\" + holderToFadeOut).html('');\n\t\t$(\"#page_holder_\" + holderToRenderTo).show();\n\n\t\tthis.setElement($(\"#page_holder_\" + holderToRenderTo));\n\n\t\tApp.currentHolder = holderToRenderTo;\n\n\t\tthis.holderReady = true;\n\t},\n\trenderLoading: function() {\n\t\t/// ask templateManager to prepare template\n\t\tApp.setProgress(false);\n\t\tApp.templateManager.fetch(this.templateName, {});\n\n\t\tthis.switchBuffers();\n\n\t\tthis.$el.html('<div class=\"page page_loading\"></div>');\n\n\t\tthis.setTitle();\n\t\tthis.setURL();\n\n\t\tconsole.log('Displaying loading');\n\t\tthis.trigger('loading');\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/collections/plans.js",
    "content": "//plans.js\nApp.Collections.Plans = Backbone.Collection.extend({\n\tmodel: App.Models.Plan,\n\tuser_id: false,\n\twallet_id: false,\n\turl: function() {\n\t\tif (this.wallet_id)\n\t\t\treturn App.settings.apiEntryPoint + 'wallets/' + this.wallet_id + '/plans';\n\t\telse\n\t\t\treturn App.settings.apiEntryPoint + 'plans';\n\t},\n\tsetUserId: function(user_id) {\n\t\tthis.user_id = user_id;\n\t},\n\tsetWalletId: function(wallet_id) {\n\t\tthis.wallet_id = wallet_id;\n\t},\n});"
  },
  {
    "path": "public/scripts/app/collections/transactions.js",
    "content": "//transactions.js\nApp.Collections.Transactions = Backbone.Collection.extend({\n\n    model: App.Models.Transaction,\n    wallet_id: false,\n    state: 'loading',\n    periodMonth: false,\n    periodYear: false,\n    comparator: function(item) {\n        return -item.get('datetime'); // Note the minus!\n    },\n    url: function() {\n        if (this.wallet_id)\n            return App.settings.apiEntryPoint + 'wallets/' + this.wallet_id + '/transactions/' + this.periodToGETParams();\n        else\n            return App.settings.apiEntryPoint + 'transactions/' + this.periodToGETParams();\n    },\n    periodToReadableFormat: function(month, year) {\n        var monthNames = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n            \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"\n        ];\n\n        if (typeof(month) == 'undefined' || typeof(year) == 'undefined') {\n            if (!this.periodMonth || !this.periodYear)\n                this.setPeriod();\n\n            return App.i18n.translate(monthNames[this.periodMonth - 1]) + ' ' + this.periodYear;\n        } else {\n            return App.i18n.translate(monthNames[month - 1]) + ' ' + year;\n        }\n    },\n    nextPeriodToReadableFormat: function() {\n        if (!this.periodMonth || !this.periodYear)\n            this.setPeriod();\n        var month = this.periodMonth + 1;\n        var year = this.periodYear;\n        if (month == 13) {\n            year++;\n            month = 1;\n        }\n\n        return this.periodToReadableFormat(month, year);\n    },\n    prevPeriodToReadableFormat: function() {\n        if (!this.periodMonth || !this.periodYear)\n            this.setPeriod();\n        var month = this.periodMonth - 1;\n        var year = this.periodYear;\n        if (month === 0) {\n            year--;\n            month = 12;\n        }\n\n        return this.periodToReadableFormat(month, year);\n    },\n    currentPeriodToReadableFormat: function() {\n        var d = new Date();\n        return this.periodToReadableFormat(d.getMonth() + 1, d.getFullYear());\n    },\n    diffToCurrentPeriod: function() {\n        if (!this.periodMonth || !this.periodYear)\n            this.setPeriod();\n\n        var d = new Date();\n        var curMonth = d.getMonth() + 1;\n        var curYear = d.getFullYear();\n\n        return (curMonth - this.periodMonth) + (curYear - this.periodYear) * 12;\n    },\n    periodToGETParams: function() {\n        if (!this.periodMonth || !this.periodYear)\n            this.setPeriod();\n\n        var to = 0;\n\n        if (this.periodMonth < 12) /// don't forget that the month is 0 based for new Date, but 1 based in periodMonth\n            to = (new Date(this.periodYear, this.periodMonth, 1, 0, 0, 0, 0)).getTime() / 1000 - 1;\n        else\n            to = (new Date(this.periodYear + 1, 0, 1, 0, 0, 0, 0)).getTime() / 1000 - 1;\n\n        var from = (new Date(this.periodYear, this.periodMonth - 1, 1, 0, 0, 0, 0)).getTime() / 1000;\n\n        return '?to=' + to + '&from=' + from;\n    },\n    setWalletId: function(wallet_id) {\n        this.wallet_id = wallet_id;\n    },\n    hasNextPeriod: function() {\n        if (this.periodMonth === false || this.periodYear === false)\n            return false;\n        var d = new Date(); /// don't forget that the month is 0 based for new Date, but 1 based in periodMonth\n        if (this.periodYear < d.getFullYear() || (this.periodYear == d.getFullYear() && this.periodMonth < d.getMonth() + 1))\n            return true;\n        return false;\n    },\n    hasPrevPeriod: function() {\n        if (this.periodMonth === false || this.periodYear === false)\n            return true;\n        var d = new Date();\n        if (this.periodYear <= 1970)\n            return false;\n        return true;\n    },\n    nextPeriod: function() {\n        if (!this.periodMonth || !this.periodYear)\n            this.setPeriod();\n        if (!this.hasNextPeriod())\n            return false;\n\n        this.periodMonth++;\n        if (this.periodMonth > 12) {\n            this.periodMonth = 1;\n            this.periodYear++;\n        }\n\n        return true;\n    },\n    currentPeriod: function() {\n        if (!this.periodMonth || !this.periodYear) {\n            this.setPeriod();\n            return true;\n        }\n\n        if (!this.hasNextPeriod())\n            return false;\n\n        var d = new Date();\n        var curMonth = d.getMonth() + 1;\n        var curYear = d.getFullYear();\n        this.periodMonth = curMonth;\n        this.periodYear = curYear;\n\n        return true;\n    },\n    prevPeriod: function() {\n        if (!this.periodMonth || !this.periodYear)\n            this.setPeriod();\n        if (!this.hasPrevPeriod())\n            return false;\n\n        this.periodMonth--;\n        if (this.periodMonth < 1) {\n            this.periodMonth = 12;\n            this.periodYear--;\n        }\n\n        return true;\n    },\n    setPeriod: function(month, year) {\n\n        var d = new Date();\n\n        if (typeof(month) == 'undefined') {\n            this.periodMonth = d.getMonth() + 1;\n        } else {\n            if (month >= 1 && month <= 12)\n                this.periodMonth = month;\n            else\n                console.error('Invalid month parameter');\n        }\n\n        if (typeof(year) == 'undefined') {\n            this.periodYear = d.getFullYear();\n        } else {\n            if (year >= 1970)\n                this.periodYear = year;\n            else\n                console.error('Invalid year parameter');\n        }\n    },\n    gotoNext: function() {\n        if (this.nextPeriod()) {\n            this.fetch();\n            this.trigger('changedperiod');\n            return true;\n        }\n        return false;\n    },\n    gotoPrev: function() {\n        if (this.prevPeriod()) {\n            this.fetch();\n            this.trigger('changedperiod');\n            return true;\n        }\n        return false;\n    },\n    gotoCurrent: function() {\n        if (this.currentPeriod()) {\n            this.fetch();\n            this.trigger('changedperiod');\n            return true;\n        }\n        return false;\n    },\n    initialize: function() {\n        this.state = 'loading';\n        this.on('request', function() {\n            this.state = 'loading';\n        }, this);\n        this.on('sync', function() {\n            this.state = 'ready';\n        }, this);\n    }\n});"
  },
  {
    "path": "public/scripts/app/collections/users.js",
    "content": "//users.js\nApp.Collections.Users = Backbone.Collection.extend({\n\tmodel: App.Models.User,\n\turl: function() {\n\t\treturn App.settings.apiEntryPoint + 'users';\n\t},\n});"
  },
  {
    "path": "public/scripts/app/collections/wallets.js",
    "content": "//wallets.js\nApp.Collections.Wallets = Backbone.Collection.extend({\n    model: App.Models.Wallet,\n    user_id: false,\n    url: function() {\n        if (this.user_id)\n            return App.settings.apiEntryPoint + 'users/' + this.user_id + '/wallets';\n        else\n            return App.settings.apiEntryPoint + 'wallets';\n    },\n    search: function(opts) {\n        var result = this.where(opts);\n        var resultCollection = new App.Collections.Wallets(result);\n\n        return resultCollection;\n    },\n    setUserId: function(user_id) {\n        this.user_id = user_id;\n    },\n});"
  },
  {
    "path": "public/scripts/app/collections/wallets_accesses.js",
    "content": "//wallets_accesses.js\nApp.Collections.WalletsAccesses = Backbone.Collection.extend({\n\n\tmodel: App.Models.WalletsAccess,\n\twallet_id: false,\n\turl: function() {\n\t\tif (this.wallet_id)\n\t\t\treturn App.settings.apiEntryPoint + 'wallets/' + this.wallet_id + '/accesses';\n\t\telse\n\t\t\treturn App.settings.apiEntryPoint + 'wallets_accesses';\n\t},\n\tsetWalletId: function(wallet_id) {\n\t\tthis.wallet_id = wallet_id;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/exchange.js",
    "content": "// exchange.js\nApp.exchange = {\n\trates: {},\n\tbase: 'USD',\n\tloaded: false,\n\tloadRates: function(callback) {\n\t\t// @todo: reload exchange rates once per hour\n\t\tif (this.loaded) {\n\t\t\tif (typeof(callback) == 'function')\n\t\t\t\tcallback();\n\t\t\treturn;\n\t\t}\n\t\tvar that = this;\n\n\t\tvar process = function(data) {\n\n\t\t\tif (typeof(data.rates) === 'undefined' || typeof(data.base) === 'undefined') {\n\t\t\t\tconsole.error('Invalid api/exchange/rates rasponse. Maybe you need to check openexchangerates api_key in server settings');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthat.rates = data.rates;\n\t\t\tthat.base = data.base;\n\n\t\t\tthat.loaded = true;\n\t\t\tif (typeof(callback) == 'function')\n\t\t\t\tcallback();\n\t\t};\n\n\t\t$.ajax({\n\t\t\turl: App.settings.apiEntryPoint + 'exchange/rates',\n\t\t\tdata: {},\n\t\t\tsuccess: process,\n\t\t\tdataType: 'json',\n\t\t\tmimeType: 'application/json',\n\t\t\tcache: false\n\t\t});\n\t},\n\tconvert: function(value, from, to) {\n\t\treturn value * this.getRate(to, from);\n\t},\n\tgetRate: function(to, from) {\n\t\tthis.rates[this.base] = 1;\n\n\t\tif (!this.rates[to] || !this.rates[from]) {\n\t\t\tconsole.error('No exchange rates FROM:' + from + ' TO:' + to + '. Converting by 1:1');\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (from === this.base) {\n\t\t\treturn this.rates[to];\n\t\t}\n\t\tif (to === this.base) {\n\t\t\treturn 1 / this.rates[from];\n\t\t}\n\n\t\treturn this.rates[to] * (1 / this.rates[from]);\n\t}\n\n};"
  },
  {
    "path": "public/scripts/app/helper.js",
    "content": "// helper.js\nApp.helper = {\n\n\tloadedAdditionalScripts: {},\n\tloadAdditionalScripts: function(scripts, callback) {\n\t\tvar that = this;\n\t\tvar expectedScripts = {};\n\n\t\tvar addLoadHandler = function(scriptObj, scriptURL) {\n\t\t\tscriptObj.onload = function() {\n\t\t\t\tthat.loadAdditionalScripts[scriptURL] = true;\n\t\t\t\texpectedScripts[scriptURL] = false;\n\n\t\t\t\tfor (var k in expectedScripts)\n\t\t\t\t\tif (expectedScripts[k]) {\n\t\t\t\t\t\tloadScript(k);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\tif (typeof(callback) === 'function')\n\t\t\t\t\tcallback();\n\t\t\t};\n\t\t};\n\n\t\tvar loadScript = function(src) {\n\t\t\tvar head = document.getElementsByTagName('head')[0];\n\t\t\tvar script = document.createElement('script');\n\t\t\tscript.type = 'text/javascript';\n\t\t\tscript.src = src;\n\t\t\taddLoadHandler(script, src);\n\t\t\thead.appendChild(script);\n\t\t};\n\n\t\tfor (var k in scripts)\n\t\t\texpectedScripts[scripts[k]] = true;\n\n\t\tif (scripts.length > 0)\n\t\t\tloadScript(scripts[0]);\n\t}\n\n};"
  },
  {
    "path": "public/scripts/app/i18n.js",
    "content": "// i18n.js\nApp.i18n = {\n\n\tstrings: {},\n\tloaded: false,\n\tsetLanguage: function(languageCode, callback) {\n\t\tthis.languageCode = languageCode;\n\t\tApp.localStorage.set('selected_interface_locale', languageCode);\n\t\tthis.loadStrings(callback);\n\t},\n\tgetLanguage: function(languageCode) {\n\t\treturn this.languageCode;\n\t},\n\ttranslate: function(string, stringId) {\n\t\tif (typeof(stringId) == 'undefined')\n\t\t\tstringId = string;\n\t\tif (typeof(this.strings[stringId]) === 'undefined' || this.strings[stringId] === false || this.strings[stringId] === '')\n\t\t\treturn string;\n\t\telse\n\t\t\treturn this.strings[stringId];\n\t},\n\ttranslateDOM: function() {\n\t\tvar that = this;\n\t\t$(\"[data-i18n]\").each(function() {\n\t\t\tvar string = $(this).data('i18n');\n\t\t\tstring = that.translate(string);\n\t\t\t$(this).text(string);\n\t\t});\n\t\t$(\"[data-i18nvalue]\").each(function() {\n\t\t\tvar string = $(this).data('i18nvalue');\n\t\t\tstring = that.translate(string);\n\t\t\t$(this).val(string);\n\t\t});\n\t\t$(\"[data-i18nplaceholder]\").each(function() {\n\t\t\tvar string = $(this).data('i18nplaceholder');\n\t\t\tstring = that.translate(string);\n\t\t\t$(this).attr('placeholder', string);\n\t\t});\n\t},\n\tloadStrings: function(callback) {\n\n\t\tvar that = this;\n\t\tvar process = function(data) {\n\t\t\tthat.strings = data;\n\t\t\tthat.loaded = true;\n\t\t\tthat.translateDOM();\n\n\t\t\tif (typeof(callback) == 'function')\n\t\t\t\tcallback();\n\t\t};\n\n\t\tthis.loaded = false;\n\n\t\tif (this.languageCode == 'default')\n\t\t\tprocess({});\n\t\telse\n\t\t\t$.ajax({\n\t\t\t\turl: App.settings.apiEntryPoint + 'i18n/bycode/' + this.languageCode.split('-').join(''),\n\t\t\t\tdata: {},\n\t\t\t\tsuccess: process,\n\t\t\t\tdataType: 'json',\n\t\t\t\tmimeType: 'application/json',\n\t\t\t\tcache: true\n\t\t\t});\n\t}\n\n\n};"
  },
  {
    "path": "public/scripts/app/local_storage.js",
    "content": "// local_storage.js\nApp.localStorage = {\n\n\tinvalidate: function(currentVersion) {\n\t\tvar prev = this.get('current_app_version');\n\t\tif (prev && currentVersion != prev)\n\t\t\tthis.clear();\n\t\tthis.set('current_app_version', currentVersion);\n\t},\n\tset: function(name, data) {\n\t\tif (typeof(data) === 'undefined')\n\t\t\treturn this.remove(name);\n\n\t\twindow.localStorage.setItem(name, this._serialize(data));\n\t\treturn data;\n\t},\n\tget: function(name) {\n\t\treturn this._deserialize(window.localStorage.getItem(name));\n\t},\n\tremove: function(name) {\n\t\twindow.localStorage.removeItem(name);\n\t\treturn true;\n\t},\n\tclear: function() {\n\t\twindow.localStorage.clear();\n\t\treturn true;\n\t},\n\tisSupported: function() {\n\t\tif (typeof(window) === 'undefined')\n\t\t\treturn false;\n\t\ttry {\n\t\t\treturn ('localStorage' in window && window.localStorage);\n\t\t} catch (err) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\t_serialize: function(data) {\n\t\treturn JSON.stringify(data);\n\t},\n\t_deserialize: function(data) {\n\t\tif (typeof data != 'string')\n\t\t\treturn undefined;\n\t\ttry {\n\t\t\treturn JSON.parse(data);\n\t\t} catch (e) {\n\t\t\treturn data || undefined;\n\t\t}\n\t}\n\n};"
  },
  {
    "path": "public/scripts/app/log.js",
    "content": "// log.js\nApp.log = {\n\n\tcurrentURL: null,\n\tcurrentTitle: null,\n\tcurrentVisitTime: null,\n\thasToForce: false,\n\tsetURL: function(url) {\n\t\tif (url != this.currentURL) {\n\t\t\tthis.setUserId();\n\t\t\tthis.hasToForce = true;\n\t\t\tthis.currentURL = url;\n\t\t\tif (typeof(ga) === 'function') {\n\t\t\t\tga('set', 'page', '/' + url);\n\t\t\t}\n\t\t}\n\t},\n\tsetTitle: function(title) {\n\t\tif (title != this.currentTitle) {\n\t\t\tthis.setUserId();\n\t\t\tthis.currentTitle = title;\n\t\t\tthis.hasToForce = true;\n\t\t\tif (typeof(ga) === 'function') {\n\t\t\t\tga('set', 'title', title);\n\t\t\t}\n\t\t}\n\t},\n\tsetUserId: function() {\n\t\tif (App && App.currentUser && App.currentUser.id && typeof(ga) === 'function')\n\t\t\tga('set', '&uid', '' + App.currentUser.id);\n\t},\n\tpageView: function() {\n\t\tvar time = Date.now();\n\n\t\tif (this.currentVisitTime === null || (time - this.currentVisitTime) > 1000 || this.hasToForce) /// 100 microseconds\n\t\t{\n\t\t\tthis.setUserId();\n\t\t\tif (typeof(ga) === 'function') {\n\t\t\t\tga('send', 'pageview');\n\t\t\t}\n\n\t\t\tthis.hasToForce = false;\n\t\t}\n\n\t\tthis.currentVisitTime = time;\n\t},\n\tevent: function(category, action, label, count) {\n\t\tthis.setUserId();\n\t\tif (typeof(label) === 'undefined')\n\t\t\tlabel = '';\n\n\t\tif (typeof(ga) === 'function') {\n\t\t\tif (typeof(count) !== 'undefined')\n\t\t\t\tga('send', 'event', category, action, label, count);\n\t\t\telse\n\t\t\t\tga('send', 'event', category, action, label);\n\t\t}\n\t}\n};"
  },
  {
    "path": "public/scripts/app/models/plan.js",
    "content": "// plan.js\nApp.Models.Plan = Backbone.Model.extend({\n\n\tdefaults: {\n\t\tname: null,\n\t},\n\tloadedWallets: [],\n\ttransactions: {},\n\tstats: [],\n\twalletsCurrencies: {},\n\tareStatsReady: false,\n\turl: function() {\n\t\treturn App.settings.apiEntryPoint + 'plans/' + (typeof(this.id) === 'undefined' ? '' : this.id);\n\t},\n\tgetPlanForToday: function() {\n\t\tvar today = new Date();\n\t\treturn this.getPlanForTheDay(today.getDate(), today.getMonth() + 1, today.getFullYear());\n\t},\n\tgetPlanForTheDay: function(day, month, year) {\n\t\tif (!this.areStatsReady)\n\t\t\tthrow 'call getPlanForTheDay only when stats are ready';\n\n\t\t// @todo: cache index\n\t\tfor (var di = 0; di < this.stats.length; di++) {\n\t\t\tif (this.stats[di].date.day == day && this.stats[di].date.month == month && this.stats[di].date.year == year) {\n\t\t\t\treturn this.stats[di].allowedToSpend;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t},\n\treloadStats: function() {\n\t\tApp.localStorage.remove('plan_' + this.id + '_data');\n\t\tthis.areStatsReady = false;\n\t\treturn this.getStats();\n\t},\n\tgetStats: function() {\n\t\tvar deferred = jQuery.Deferred();\n\n\t\tif (this.areStatsReady) {\n\t\t\tthis.trigger('statsready');\n\t\t\tdeferred.resolve(this.stats);\n\t\t\treturn deferred;\n\t\t}\n\n\t\tvar cached = App.localStorage.get('plan_' + this.id + '_data');\n\t\tif (cached !== null && cached !== undefined) {\n\t\t\tvar cachedDate = new Date(1000 * cached.saved);\n\t\t\tvar curDate = new Date();\n\n\t\t\tif (cachedDate.getMonth() == curDate.getMonth() && cachedDate.getDate() == curDate.getDate() && cachedDate.getFullYear() == curDate.getFullYear()) {\n\t\t\t\tconsole.log('plan.js | restore stats from cache');\n\t\t\t\tthis.stats = cached.stats;\n\t\t\t\tthis.areStatsReady = true;\n\t\t\t\tthis.trigger('statsready');\n\t\t\t\tdeferred.resolve(this.stats);\n\t\t\t\treturn deferred;\n\t\t\t} else {\n\t\t\t\tconsole.log('plan.js | cache is too old');\n\t\t\t}\n\t\t}\n\n\t\tvar plan = this;\n\t\tvar daysCount = Math.ceil((this.get('goal_datetime') - this.get('start_datetime')) / (24 * 60 * 60));\n\t\tthis.stats = [];\n\n\t\tvar lastDayDate = new Date(1000 * this.get('goal_datetime'));\n\n\t\tfor (var i = 0; i < daysCount; i++) {\n\t\t\tvar dayStat = {};\n\t\t\tdayStat.date = {};\n\t\t\tdayStat.date.unix = (this.get('start_datetime') + 24 * 60 * 60 * i);\n\t\t\tdayStat.date.date = new Date(1000 * dayStat.date.unix);\n\t\t\tdayStat.date.month = dayStat.date.date.getMonth() + 1;\n\t\t\tdayStat.date.year = dayStat.date.date.getFullYear();\n\t\t\tdayStat.date.day = dayStat.date.date.getDate();\n\t\t\tdayStat.date.unix_from = (new Date(dayStat.date.year, dayStat.date.month - 1, dayStat.date.day, 0, 0, 0, 0)).getTime() / 1000;\n\t\t\tdayStat.date.unix_to = dayStat.date.unix_from + 24 * 60 * 60;\n\t\t\tdayStat.expenses = {};\n\t\t\tdayStat.expensesTotal = 0;\n\t\t\tdayStat.profits = {};\n\t\t\tdayStat.profitsTotal = 0;\n\t\t\tdayStat.dayTotal = 0;\n\n\t\t\tif (dayStat.date.day != lastDayDate.getDate() || dayStat.date.month != lastDayDate.getMonth() + 1 || dayStat.date.year != lastDayDate.getFullYear()) {\n\t\t\t\t// push stats othen than for the last day to stats array\n\t\t\t\tthis.stats.push(dayStat);\t\t\t\t\n\t\t\t}\n\t\t}\n\n\t\tthis.once('walletsloadded', function() {\n\n\t\t\tfor (var wk in plan.loadedWallets)\n\t\t\t\tplan.walletsCurrencies[plan.loadedWallets[wk].id] = plan.loadedWallets[wk].get('currency');\n\n\t\t\tfor (var di = 0; di < plan.stats.length; di++) {\n\t\t\t\tfor (var tk in plan.transactions) {\n\t\t\t\t\tplan.stats[di].expenses[tk] = 0;\n\t\t\t\t\tplan.stats[di].profits[tk] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t/// get spending per day\n\t\t\tfor (var di = 0; di < plan.stats.length; di++) {\n\t\t\t\tfor (var tk in plan.transactions) {\n\t\t\t\t\tfor (var wti = 0; wti < plan.transactions[tk].length; wti++) {\n\t\t\t\t\t\tif (plan.transactions[tk][wti].get('datetime') >= plan.stats[di].date.unix_from && plan.transactions[tk][wti].get('datetime') < plan.stats[di].date.unix_to) {\n\n\t\t\t\t\t\t\tvar absInWalletCurrency = Math.abs(plan.transactions[tk][wti].get('amount'));\n\t\t\t\t\t\t\tvar absInGoalCurrency = App.exchange.convert(absInWalletCurrency, plan.walletsCurrencies[tk], plan.get('goal_currency'));\n\t\t\t\t\t\t\tif (plan.transactions[tk][wti].get('amount') < 0) {\n\t\t\t\t\t\t\t\t// expense\n\t\t\t\t\t\t\t\tplan.stats[di].expenses[tk] += absInGoalCurrency;\n\t\t\t\t\t\t\t\tplan.stats[di].expensesTotal += absInGoalCurrency;\n\t\t\t\t\t\t\t\tplan.stats[di].dayTotal -= absInGoalCurrency;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// profit\n\t\t\t\t\t\t\t\tplan.stats[di].profits[tk] += absInGoalCurrency;\n\t\t\t\t\t\t\t\tplan.stats[di].profitsTotal += absInGoalCurrency;\n\t\t\t\t\t\t\t\tplan.stats[di].dayTotal += absInGoalCurrency;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/// average spendings by empty days\n\t\t\tvar emptyFrom = null;\n\t\t\tvar groupExpenses = 0;\n\t\t\tvar groupProfits = 0;\n\t\t\tvar groupCount = 0;\n\t\t\tfor (var di = 0; di < plan.stats.length; di++) {\n\t\t\t\tif (plan.stats[di].expensesTotal == 0 && plan.stats[di].profitsTotal == 0) {\n\t\t\t\t\tif (emptyFrom === null)\n\t\t\t\t\t\temptyFrom = di;\n\t\t\t\t\tgroupCount++;\n\t\t\t\t} else {\n\n\t\t\t\t\tgroupCount++;\n\t\t\t\t\tgroupExpenses = plan.stats[di].expensesTotal;\n\t\t\t\t\tgroupProfits = plan.stats[di].profitsTotal;\n\n\t\t\t\t\tif (emptyFrom !== null) {\n\t\t\t\t\t\tgroupExpenses = groupExpenses / groupCount;\n\t\t\t\t\t\tgroupProfits = groupProfits / groupCount;\n\t\t\t\t\t\tfor (var dgi = emptyFrom; dgi <= di; dgi++) {\n\t\t\t\t\t\t\tplan.stats[dgi].expensesTotal = groupExpenses;\n\t\t\t\t\t\t\tplan.stats[dgi].profitsTotal = groupProfits;\n\t\t\t\t\t\t\tplan.stats[dgi].dayTotal = groupProfits - groupExpenses;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\temptyFrom = null;\n\t\t\t\t\tgroupCount = 0;\n\t\t\t\t\tgroupExpenses = 0;\n\t\t\t\t\tgroupProfits = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar currentTotal = App.exchange.convert(plan.get('start_balance'), plan.get('start_currency'), plan.get('goal_currency'));\n\t\t\tvar goalTotal = plan.get('goal_balance');\n\t\t\tfor (var di = 0; di < plan.stats.length; di++) {\n\t\t\t\tplan.stats[di].currentTotalOnStart = currentTotal;\n\t\t\t\tplan.stats[di].allowedToSpend = (goalTotal - currentTotal) / (plan.stats.length - di);\n\t\t\t\tcurrentTotal += plan.stats[di].dayTotal;\n\t\t\t\tplan.stats[di].currentTotalOnEnd = currentTotal;\n\t\t\t}\n\n\t\t\tplan.areStatsReady = true;\n\n\t\t\tApp.localStorage.set('plan_' + plan.id + '_data', {\n\t\t\t\tstats: plan.stats,\n\t\t\t\tsaved: (new Date().getTime() / 1000)\n\t\t\t});\n\n\t\t\tplan.trigger('statsready');\n\t\t\tdeferred.resolve(plan.stats);\n\t\t});\n\n\t\tthis.loadWallets();\n\t\treturn deferred;\n\t},\n\tloadWallets: function() {\n\t\tvar plan = this;\n\t\tvar wallets = this.get('wallets');\n\t\tfor (var k in wallets) {\n\t\t\tvar wallet = new App.Models.Wallet();\n\t\t\twallet.id = wallets[k].id;\n\t\t\tthis.loadedWallets.push(wallet);\n\t\t}\n\n\t\tvar complete = _.invoke(this.loadedWallets, 'fetch');\n\n\t\t$.when.apply($, complete).done(function() {\n\t\t\tvar completeTransactions = _.invoke(plan.loadedWallets, 'getTransactionsForPeriod', plan.get('start_datetime'), plan.get('goal_datetime'));\n\t\t\t$.when.apply($, completeTransactions).done(function() {\n\t\t\t\tvar allTransactions = Array.prototype.slice.call(arguments);\n\t\t\t\tfor (var k in allTransactions) {\n\t\t\t\t\tvar wallet_id = plan.loadedWallets[k].id;\n\t\t\t\t\tplan.transactions[wallet_id] = allTransactions[k];\n\t\t\t\t}\n\n\t\t\t\tplan.trigger('walletsloadded');\n\t\t\t});\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/models/transaction.js",
    "content": "// transaction.js\nApp.Models.Transaction = Backbone.Model.extend({\n\n    defaults: function() {\n        return {\n            user_id: null,\n            wallet_id: null,\n            description: null,\n            type: null,\n            subtype: null,\n            amount: null,\n            abs_amount: null,\n            datetime: Math.floor((new Date().getTime()) / 1000)\n        }\n    },\n    url: function() {\n        if (!this.get('wallet_id'))\n            return App.settings.apiEntryPoint + 'transactions/' + (typeof(this.id) === 'undefined' ? '' : this.id);\n        else\n            return App.settings.apiEntryPoint + 'wallets/' + this.get('wallet_id') + '/transactions/' + (typeof(this.id) === 'undefined' ? '' : this.id);\n    }\n\n});"
  },
  {
    "path": "public/scripts/app/models/user.js",
    "content": "// user.js\nApp.Models.User = Backbone.Model.extend({\n\n\tvalidate: function(attrs, options) {\n\t\tvar errors = [];\n\n\t\tif (typeof(this.get('email')) !== 'string' || !isEmail(this.get('email')))\n\t\t\terrors.push({\n\t\t\t\tmsg: 'Invalid email',\n\t\t\t\tattr: 'email'\n\t\t\t});\n\t\telse if (this.get('email').length > 255)\n\t\t\terrors.push({\n\t\t\t\tmsg: 'Email is too long',\n\t\t\t\tattr: 'email'\n\t\t\t});\n\n\t\tif (typeof(this.get('login')) !== 'string' || this.get('login').length < 2)\n\t\t\terrors.push({\n\t\t\t\tmsg: 'Username is too short',\n\t\t\t\tattr: 'login'\n\t\t\t});\n\t\telse if (this.get('login').length > 255)\n\t\t\terrors.push({\n\t\t\t\tmsg: 'Username is too long',\n\t\t\t\tattr: 'login'\n\t\t\t});\n\n\t\tif (typeof(this.get('password')) !== 'string' || this.get('password').length < 6)\n\t\t\terrors.push({\n\t\t\t\tmsg: 'Password is too short',\n\t\t\t\tattr: 'password'\n\t\t\t});\n\n\t\tif (errors.length)\n\t\t\treturn errors;\n\t},\n\tdefaults: {\n\t\tauth_code: null,\n\t\temail: null,\n\t\tpassword: null,\n\t\tis_demo: null,\n\t\tlogin: null,\n\t},\n\tsignedIn: false,\n\tsignInError: null,\n\turl: function() {\n\t\treturn App.settings.apiEntryPoint + 'users' + (typeof(this.id) === 'undefined' ? '' : '/' + this.id);\n\t},\n\tgetWallets: function() {\n\t\tif (typeof(this.wallets) === 'undefined') {\n\t\t\tthis.wallets = new App.Collections.Wallets();\n\t\t\tthis.wallets.setUserId(this.id);\n\t\t}\n\t\treturn this.wallets;\n\t},\n\tgetPlans: function() {\n\t\tif (typeof(this.plans) === 'undefined') {\n\t\t\tthis.plans = new App.Collections.Plans();\n\t\t\tthis.plans.setUserId(this.id);\n\t\t}\n\t\treturn this.plans;\n\t},\n\tisSignedIn: function() {\n\t\treturn this.signedIn;\n\t},\n\tisAdmin: function() {\n\t\treturn false;\n\t},\n\n\tisDemo: function() {\n\t\treturn (this.get('is_demo') == true); // yep, ==\n\t},\n\n\tsignInWithData: function(data) {\n\t\tif (typeof(data) !== 'undefined') {\n\t\t\tthis.set(data);\n\t\t\tif (this.signedIn === false) {\n\t\t\t\tthis.signedIn = true;\n\t\t\t\tthis.trigger('signedInStatusChanged');\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.signedIn === true) {\n\t\t\t\tthis.signedIn = false;\n\t\t\t\tthis.trigger('signedInStatusChanged');\n\t\t\t}\n\t\t}\n\t},\n\tdemoRegister: function() {\n\t\tthis.register('demo', 'demo@demo.com', 'demonstration');\n\t},\n\tchangePassword: function(currentPassword, newPassword) {\n\t\tvar that = this;\n\n\t\tthis.set('current_password', currentPassword);\n\t\tthis.set('password', newPassword);\n\n\t\treturn this.save(null, {\n\t\t\tsuccess: function(model, data) {\n\t\t\t\tif (typeof(data.id) !== 'undefined') {\n\t\t\t\t\tconsole.log(\"Server side change password success\");\n\t\t\t\t\tthat.set('password', '');\n\t\t\t\t\tthat.trigger('changed');\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function(model, response) {\n\t\t\t\tconsole.log(\"Server side change password error\");\n\t\t\t\tif (typeof(response.responseJSON) !== 'undefined' && typeof(response.responseJSON.message) !== 'undefined') {\n\t\t\t\t\tif (!(that.validationError instanceof Array))\n\t\t\t\t\t\tthat.validationError = [];\n\t\t\t\t\tfor (var k in response.responseJSON.message)\n\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\tmsg: response.responseJSON.message[k]\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthat.trigger('invalid');\n\t\t\t}\n\t\t});\n\t},\n\tfillProfile: function(login, email, password) {\n\t\tvar that = this;\n\n\t\tthis.set('login', login);\n\t\tthis.set('email', email);\n\t\tthis.set('password', password);\n\t\tthis.set('is_demo', false);\n\n\t\treturn this.save(null, {\n\t\t\tsuccess: function(model, data) {\n\t\t\t\tif (typeof(data.id) !== 'undefined') {\n\t\t\t\t\tconsole.log(\"Server side fill profile success\");\n\t\t\t\t\tthat.set('password', '');\n\t\t\t\t\tthat.trigger('filled');\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function(model, response) {\n\t\t\t\tconsole.log(\"Server side fill profile error\");\n\t\t\t\tif (typeof(response.responseJSON) !== 'undefined' && typeof(response.responseJSON.message) !== 'undefined') {\n\t\t\t\t\tif (!(that.validationError instanceof Array))\n\t\t\t\t\t\tthat.validationError = [];\n\t\t\t\t\tif (typeof(response.responseJSON.message) === 'string') {\n\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\tmsg: response.responseJSON.message\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (var k in response.responseJSON.message)\n\t\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\t\tmsg: response.responseJSON.message[k]\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthat.trigger('invalid');\n\t\t\t}\n\t\t});\n\t},\n\tregister: function(login, email, password) {\n\t\tvar that = this;\n\n\t\tthis.set('login', login);\n\t\tthis.set('email', email);\n\t\tthis.set('password', password);\n\n\t\treturn this.save(null, {\n\t\t\tsuccess: function(model, data) {\n\t\t\t\tif (typeof(data.id) !== 'undefined') {\n\t\t\t\t\tconsole.log(\"Server side registration success\");\n\t\t\t\t\tthat.set('password', '');\n\t\t\t\t\tthat.trigger('registered');\n\t\t\t\t\tif (typeof(data.auth_code) !== 'undefined') {\n\t\t\t\t\t\t// And signed in\n\t\t\t\t\t\tthat.signedIn = true;\n\t\t\t\t\t\tthat.trigger('signedInStatusChanged');\n\t\t\t\t\t\tconsole.log(\"Server side registration - signed in\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function(model, response) {\n\t\t\t\tconsole.log(\"Server side registration error\");\n\t\t\t\tif (typeof(response.responseJSON) !== 'undefined' && typeof(response.responseJSON.message) !== 'undefined') {\n\t\t\t\t\tif (!(that.validationError instanceof Array))\n\t\t\t\t\t\tthat.validationError = [];\n\t\t\t\t\tif (typeof(response.responseJSON.message) === 'string') {\n\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\tmsg: response.responseJSON.message\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (var k in response.responseJSON.message)\n\t\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\t\tmsg: response.responseJSON.message[k]\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthat.trigger('invalid');\n\t\t\t}\n\t\t});\n\t},\n\tnewPassword: function(code, hash, password) {\n\t\tvar that = this;\n\n\t\tvar url = App.settings.apiEntryPoint + 'users/newpassword';\n\n\t\tthis.clear();\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\ttype: 'POST',\n\t\t\tdataType: \"json\",\n\t\t\tdata: {\n\t\t\t\tcode: code,\n\t\t\t\thash: hash,\n\t\t\t\tpassword: password\n\t\t\t},\n\t\t\tsuccess: function(data) {\n\t\t\t\tconsole.log('Success setting new password');\n\t\t\t\tthat.trigger('newpassword:success');\n\t\t\t},\n\t\t\terror: function(data) {\n\t\t\t\tconsole.log('Error setting new password');\n\n\t\t\t\tthat.validationError = [];\n\t\t\t\tif (typeof(data.responseJSON) != 'undefined' && typeof(data.responseJSON.code) != 'undefined' && typeof(data.responseJSON.message) != 'undefined')\n\t\t\t\t\tif (data.responseJSON.message instanceof Array) {\n\t\t\t\t\t\tfor (var k in data.responseJSON.message)\n\t\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\t\tmsg: data.responseJSON.message[k]\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\tmsg: data.responseJSON.message\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\tthat.trigger('newpassword:error');\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t},\n\trestorePassword: function(email) {\n\t\tvar that = this;\n\n\t\tvar url = App.settings.apiEntryPoint + 'users/restore';\n\n\t\tthis.clear();\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\ttype: 'POST',\n\t\t\tdataType: \"json\",\n\t\t\tdata: {\n\t\t\t\temail: email\n\t\t\t},\n\t\t\tsuccess: function(data) {\n\t\t\t\tconsole.log('Success restoring password');\n\t\t\t\tthat.trigger('restore:success');\n\t\t\t},\n\t\t\terror: function(data) {\n\t\t\t\tconsole.log('Error restoring password');\n\n\t\t\t\tthat.validationError = [];\n\t\t\t\tif (typeof(data.responseJSON) != 'undefined' && typeof(data.responseJSON.message) != 'undefined')\n\t\t\t\t\tif (data.responseJSON.message instanceof Array) {\n\t\t\t\t\t\tfor (var k in data.responseJSON.message)\n\t\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\t\tmsg: data.responseJSON.message[k]\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\tmsg: data.responseJSON.message\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\tthat.trigger('restore:error');\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t},\n\tsignIn: function(username, password) {\n\n\t\tvar that = this;\n\n\t\tvar url = App.settings.apiEntryPoint + 'users/signin';\n\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\ttype: 'POST',\n\t\t\tdataType: \"json\",\n\t\t\tdata: {\n\t\t\t\tusername: username,\n\t\t\t\tpassword: password\n\t\t\t},\n\t\t\tsuccess: function(data) {\n\t\t\t\tif (typeof(data.auth_code) != 'undefined' && data.auth_code) {\n\t\t\t\t\tconsole.log('Logged in successfully');\n\t\t\t\t\tthat.trigger('signedin');\n\t\t\t\t\tthat.signInWithData(data);\n\t\t\t\t}\n\t\t\t},\n\t\t\terror: function(data) {\n\t\t\t\tconsole.log('Cannot log in');\n\t\t\t\tthat.signInWithData();\n\t\t\t\tif (!(that.validationError instanceof Array))\n\t\t\t\t\tthat.validationError = [];\n\t\t\t\tif (typeof(data.responseJSON) != 'undefined' && typeof(data.responseJSON.code) != 'undefined' && typeof(data.responseJSON.message) != 'undefined')\n\t\t\t\t\tfor (var k in data.responseJSON.message)\n\t\t\t\t\t\tthat.validationError.push({\n\t\t\t\t\t\t\tmsg: data.responseJSON.message[k]\n\t\t\t\t\t\t});\n\t\t\t\tthat.trigger('invalid');\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t},\n\tsignOut: function() {\n\t\tvar that = this;\n\t\tvar url = App.settings.apiEntryPoint + 'users/signout';\n\n\t\tif (!this.isSignedIn()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.signedIn = false;\n\t\tthis.clear().set(this.defaults);\n\t\tdelete this.wallets;\n\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\ttype: 'POST',\n\t\t\tdataType: \"json\",\n\t\t\tsuccess: function(data) {\n\t\t\t\tconsole.log('Signed out');\n\t\t\t\tthat.trigger('signedout');\n\t\t\t\tthat.signInWithData();\n\t\t\t},\n\t\t\terror: function(data) {\n\t\t\t\tconsole.error('Error signing out');\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t},\n\tremoveAccount: function() {\n\t\tvar that = this;\n\t\tvar url = App.settings.apiEntryPoint + 'users/' + this.id + '/removeaccount';\n\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\ttype: 'POST',\n\t\t\tdataType: \"json\",\n\t\t\tsuccess: function(data) {\n\t\t\t\tconsole.log('Asked server to start user account removal');\n\t\t\t\tthat.trigger('removeaccountstart');\n\t\t\t},\n\t\t\terror: function(data) {}\n\t\t});\n\n\t\treturn true;\n\t},\n\tremoveAccountConfirm: function(code) {\n\t\tvar that = this;\n\t\tvar url = App.settings.apiEntryPoint + 'users/' + this.id + '/removeaccount';\n\t\tvar data = {\n\t\t\tcode: code\n\t\t};\n\t\t$.ajax({\n\t\t\turl: url,\n\t\t\tdata: data,\n\t\t\ttype: 'POST',\n\t\t\tdataType: \"json\",\n\t\t\tsuccess: function(data) {\n\t\t\t\tconsole.log('Asked server to finish user account removal');\n\t\t\t\tif (data) {\n\t\t\t\t\tthat.trigger('removeaccountdone');\n\t\t\t\t} else\n\t\t\t\t\tthat.trigger('removeaccountwrongcode');\n\n\t\t\t},\n\t\t\terror: function(data) {\n\t\t\t\tthat.trigger('removeaccountwrongcode');\n\t\t\t}\n\t\t});\n\n\t\treturn true;\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/models/wallet.js",
    "content": "// wallet.js\nApp.Models.Wallet = Backbone.Model.extend({\n\n    defaults: {\n        name: null,\n        type: null,\n        status: 'active',\n        total: null,\n        currency: 'USD'\n    },\n    getTotal: function() {\n        return parseFloat(this.get('total'), 10);\n    },\n    url: function() {\n        return App.settings.apiEntryPoint + 'wallets/' + (typeof(this.id) === 'undefined' ? '' : this.id);\n    },\n    hide: function() {\n        if (this.get('status') == 'active') {\n            this.set('status', 'hidden');\n            this.save();\n        } else if (this.get('status') == 'hidden') {\n            this.destroy();\n        }\n    },\n    getTransactions: function() {\n        if (typeof(this.transactions) === 'undefined') {\n            this.transactions = new App.Collections.Transactions();\n            this.transactions.setWalletId(this.id);\n\n            var that = this;\n            this.transactions.fetch().done(function() {});\n        }\n        this.transactions.setWalletId(this.id);\n        return this.transactions;\n    },\n    getPlans: function() {\n        if (typeof(this.plans) === 'undefined') {\n            this.plans = new App.Collections.Plans();\n            this.plans.setWalletId(this.id);\n\n            var that = this;\n            this.plans.fetch().done(function() {\n                that.trigger('plansloaded');\n            });\n        }\n        this.plans.setWalletId(this.id);\n        return this.plans;\n    },\n    getTransactionsForPeriod: function(from, to, callback) {\n        var deferred = jQuery.Deferred();\n\n        var transactions = new App.Collections.Transactions();\n        var aTransactions = [];\n        transactions.setWalletId(this.id);\n\n        var fromDate = new Date(from * 1000);\n        var fromMonth = fromDate.getMonth() + 1;\n        var fromYear = fromDate.getFullYear();\n\n        var toDate = new Date(to * 1000);\n        var toMonth = toDate.getMonth() + 1;\n        var toYear = toDate.getFullYear();\n\n        var curMonth = fromMonth;\n        var curYear = fromYear;\n\n        var fetched = function() {\n            transactions.forEach(function(t) {\n                if (t.get('datetime') >= from && t.get('datetime') <= to)\n                    aTransactions.push(t);\n            });\n\n            fetchNext();\n        };\n\n        var fetch = function() {\n            transactions.setPeriod(curMonth, curYear);\n            transactions.fetch().done(fetched);\n        };\n\n        var fetchNext = function() {\n            if (curMonth >= toMonth && curYear >= toYear) {\n                if (typeof(callback) === 'function')\n                    callback(aTransactions);\n                deferred.resolve(aTransactions);\n                return false;\n            }\n\n            curMonth++;\n            if (curMonth > 12) {\n                curMonth = 1;\n                curYear++;\n            }\n\n            fetch();\n\n            return true;\n        };\n\n        fetch();\n\n        return deferred;\n    },\n    addProfit: function(amount, description) {\n\n        var profit = new App.Models.Transaction();\n        var amountValue = Math.abs(parseFloat(amount, 10));\n        amountValue = Math.round(amountValue * 100) / 100;\n\n        profit.set('description', description);\n        profit.set('amount', amountValue);\n        profit.set('wallet_id', this.id);\n\n        profit.save();\n\n        this.getTransactions().add(profit);\n        this.set('total', this.getTotal() + amountValue);\n        this.trigger('addTransaction', profit);\n        //this.trigger('change');\n    },\n    setTotalTo: function(total) {\n        var transaction = new App.Models.Transaction();\n        var totalValue = parseFloat(total, 10);\n        totalValue = Math.round(totalValue * 100) / 100;\n\n        transaction.set('amount', totalValue);\n        transaction.set('subtype', 'setup');\n        transaction.set('wallet_id', this.id);\n\n        transaction.save();\n        this.getTransactions().add(transaction);\n        this.set('total', totalValue);\n        this.trigger('addTransaction', transaction);\n        //this.trigger('change');\n    },\n    addExpense: function(amount, description) {\n\n        var expense = new App.Models.Transaction();\n        var amountValue = -Math.abs(parseFloat(amount, 10));\n        amountValue = Math.round(amountValue * 100) / 100;\n\n        expense.set('description', description);\n        expense.set('amount', amountValue);\n        expense.set('wallet_id', this.id);\n\n        expense.save();\n\n        this.getTransactions().add(expense);\n        this.set('total', this.getTotal() + amountValue);\n        this.trigger('addTransaction', expense);\n        this.trigger('addExpense');\n        //this.trigger('change');\n    },\n    removeTransaction: function(transaction) {\n        var newTotal = this.get('total') - transaction.get('amount');\n        var transactionId = transaction.id;\n\n        this.getTransactions().remove(transaction);\n        transaction.destroy();\n        this.set('total', newTotal);\n        this.trigger('removeTransaction', transactionId);\n    }\n\n});"
  },
  {
    "path": "public/scripts/app/models/wallets_access.js",
    "content": "// wallets_access.js\nApp.Models.WalletsAccess = Backbone.Model.extend({\n\n    defaults: {\n        wallet_id: null,\n        to_user_id: null,\n        original_user_id: null,\n        to_email: null\n    },\n    url: function() {\n        if (!this.get('wallet_id'))\n            return App.settings.apiEntryPoint + 'wallets_accesses/' + (typeof(this.id) === 'undefined' ? '' : this.id);\n        else\n            return App.settings.apiEntryPoint + 'wallets/' + this.get('wallet_id') + '/accesses/' + (typeof(this.id) === 'undefined' ? '' : this.id);\n    },\n    getGravatarURL: function() {\n        return \"http://www.gravatar.com/avatar/\" + md5(this.get('to_email').replace(/^\\s+|\\s+$/g, '').toLowerCase());\n    }\n});"
  },
  {
    "path": "public/scripts/app/router.js",
    "content": "// router.js\nApp.router = new(Backbone.Router.extend({\n\n  setUrl: function(path) {\n    this.navigate(path);\n  },\n  redirect: function(path) {\n    if (typeof(App.page) !== 'undefined' && App.page && typeof(App.page.isReady) !== 'undefined' && !App.page.isReady)\n      App.loadingStatus(false);\n    this.navigate(path, {\n      trigger: true\n    });\n  },\n\n  routes: {\n    \"(/)\": \"index\", // #help\n    \"profile(/)\": \"profile\",\n    \"plans(/)\": \"plans\",\n    \"plans/:id\": \"plan\",\n    \"wallets(/)\": \"wallets\",\n    \"wallets/:id\": \"wallet\",\n    \"wallets/:id/import(/)\": \"importXLS\",\n    \"user/updatepassword/:code/:hash\": \"updatePassword\"\n  },\n\n  dialogs: {\n    \"user/signin\": \"Signin\",\n    \"user/registration\": \"Registration\",\n    \"user/restore\": \"Restore\",\n    \"user/logout\": \"Logout\",\n    \"user/fillprofile\": \"FillProfile\",\n    \"wallets/add\": \"AddWallet\",\n    \"user/change_language\": \"ChangeLanguage\"\n  },\n\n  index: function() {\n    App.showPage('Index');\n  },\n\n  plans: function() {\n    App.showPage('Plans');\n  },\n\n  plan: function(id) {\n    App.showPage('Plan', {\n      id: id\n    });\n  },\n\n  profile: function() {\n    App.showPage('Profile');\n  },\n\n  updatePassword: function(code, hash) {\n    App.showPage('UpdatePassword', {\n      password_restore_code: code,\n      password_restore_hash: hash\n    });\n  },\n\n  wallet: function(id) {\n    App.showPage('Wallet', {\n      id: id\n    });\n  },\n\n  importXLS: function(wallet_id) {\n    App.showPage('ImportXLS', {\n      wallet_id: wallet_id\n    });\n  },\n\n  wallets: function() {\n    App.showPage('Wallets');\n  },\n\n  init: function() {\n    Backbone.history.start({\n      pushState: App.settings.history.pushState,\n      silent: App.settings.history.startSilent\n    });\n    Backbone.history.isRoutingURL = function(fragment) {\n      for (var k in this.handlers)\n        if (this.handlers[k].route.test(fragment))\n          return true;\n      return false;\n    };\n\n    var that = this;\n\n    if (Backbone.history && Backbone.history._hasPushState) {\n      $(document).on(\"click\", \"a\", function(evt) {\n        if (typeof(evt.ctrlKey) !== 'undefined' && evt.ctrlKey)\n          return true;\n        var href = $(this).attr(\"href\");\n        var protocol = this.protocol + \"//\";\n        href = href.split(App.settings.sitePath).join('');\n        href = href.slice(-1) == '/' ? href.slice(0, -1) : href;\n        href = href.slice(0, 1) == '/' ? href.slice(1) : href;\n\n        /// trying to find dialog\n        for (var k in that.dialogs)\n          if (k == href) {\n            console.log('Showing \"' + that.dialogs[k] + '\" dialog from document click event');\n            App.showDialog(that.dialogs[k]);\n\n            return false;\n          }\n\n          // Ensure the protocol is not part of URL, meaning its relative.\n        if (href.slice(protocol.length) !== protocol && Backbone.history.isRoutingURL(href)) {\n          console.log('Navigating to \"' + href + '\" from document click event');\n          evt.preventDefault();\n          App.router.navigate(href, {\n            trigger: true\n          });\n\n          return false;\n        }\n\n        return true;\n      });\n    }\n  }\n\n}))();"
  },
  {
    "path": "public/scripts/app/settings.js",
    "content": "// settings.js\nApp.settings = {\n\n\tsitePath: site_path,\n\tapiEntryPoint: site_path + '/api/',\n\ttemplatePath: site_path + '/jstemplates/',\n\tversion: (typeof(app_version) !== 'undefined') ? app_version : '',\n\ttitle: function(title) {\n\t\treturn title + ' | ' + 'DimeShift';\n\t},\n\n\tavailiableLocales: {\n\t\t'default': {\n\t\t\tcode: 'en',\n\t\t\tname: 'English',\n\t\t\ttimeFormat: '12',\n\t\t\tdateFormat: 'mdy'\n\t\t},\n\t\t'ua': {\n\t\t\tname: 'Українська',\n\t\t\ttimeFormat: '24',\n\t\t\tdateFormat: 'dmy'\n\t\t},\n\t\t'ru': {\n\t\t\tname: 'Русский',\n\t\t\ttimeFormat: '24',\n\t\t\tdateFormat: 'dmy'\n\t\t},\n\t\t'pt-br': {\n\t\t\tname: 'Português Brasileiro',\n\t\t\ttimeFormat: '24',\n\t\t\tdateFormat: 'dmy'\n\t\t}\n\t},\n\tdetectLanguage: function() {\n\n\t\tvar language = 'default';\n\t\tif (App.localStorage.get('selected_interface_locale'))\n\t\t\tlanguage = App.localStorage.get('selected_interface_locale');\n\t\telse {\n\t\t\tlanguage = window.navigator.userLanguage || window.navigator.language;\n\t\t\tif (language && typeof(this.availiableLocales[language]) == 'undefined' && language.indexOf('-') != -1) {\n\t\t\t\tlanguage = language.split('-')[0];\n\t\t\t}\n\t\t}\n\n\t\tif (typeof(this.availiableLocales[language]) == 'undefined')\n\t\t\tlanguage = 'default';\n\n\t\tthis.timeFormat = this.availiableLocales[language][0];\n\t\tthis.dateFormat = this.availiableLocales[language][1];\n\t\tthis.language = language;\n\n\t\treturn language;\n\t},\n\tlanguage: 'en',\n\ttimeFormat: '24', // 12 or 24\n\tdateFormat: 'dmy', // mdy or dmy\n\n\tallowRealTimeTranslation: true,\n\n\tenableTemplatesCache: false,\n\tenablePagesStack: true,\n\tpagesStackMaxLength: 25,\n\n\thistory: {\n\t\tpushState: true,\n\t\tstartSilent: false\n\t},\n\n\tinviteMode: true,\n\n\n\tsite_path: site_path,\n\tinvite_mode: this.inviteMode,\n\tclient_side: true,\n\n\tcurrencies: {\n\t\t\"AED\": \"United Arab Emirates Dirham\",\n\t\t\"AFN\": \"Afghan Afghani\",\n\t\t\"ALL\": \"Albanian Lek\",\n\t\t\"AMD\": \"Armenian Dram\",\n\t\t\"ANG\": \"Netherlands Antillean Guilder\",\n\t\t\"AOA\": \"Angolan Kwanza\",\n\t\t\"ARS\": \"Argentine Peso\",\n\t\t\"AUD\": \"Australian Dollar\",\n\t\t\"AWG\": \"Aruban Florin\",\n\t\t\"AZN\": \"Azerbaijani Manat\",\n\t\t\"BAM\": \"Bosnia-Herzegovina Convertible Mark\",\n\t\t\"BBD\": \"Barbadian Dollar\",\n\t\t\"BDT\": \"Bangladeshi Taka\",\n\t\t\"BGN\": \"Bulgarian Lev\",\n\t\t\"BHD\": \"Bahraini Dinar\",\n\t\t\"BIF\": \"Burundian Franc\",\n\t\t\"BMD\": \"Bermudan Dollar\",\n\t\t\"BND\": \"Brunei Dollar\",\n\t\t\"BOB\": \"Bolivian Boliviano\",\n\t\t\"BRL\": \"Brazilian Real\",\n\t\t\"BSD\": \"Bahamian Dollar\",\n\t\t\"BTC\": \"Bitcoin\",\n\t\t\"BTN\": \"Bhutanese Ngultrum\",\n\t\t\"BWP\": \"Botswanan Pula\",\n\t\t\"BYR\": \"Belarusian Ruble\",\n\t\t\"BZD\": \"Belize Dollar\",\n\t\t\"CAD\": \"Canadian Dollar\",\n\t\t\"CDF\": \"Congolese Franc\",\n\t\t\"CHF\": \"Swiss Franc\",\n\t\t\"CLF\": \"Chilean Unit of Account (UF)\",\n\t\t\"CLP\": \"Chilean Peso\",\n\t\t\"CNY\": \"Chinese Yuan\",\n\t\t\"COP\": \"Colombian Peso\",\n\t\t\"CRC\": \"Costa Rican Colón\",\n\t\t\"CUP\": \"Cuban Peso\",\n\t\t\"CVE\": \"Cape Verdean Escudo\",\n\t\t\"CZK\": \"Czech Republic Koruna\",\n\t\t\"DJF\": \"Djiboutian Franc\",\n\t\t\"DKK\": \"Danish Krone\",\n\t\t\"DOP\": \"Dominican Peso\",\n\t\t\"DZD\": \"Algerian Dinar\",\n\t\t\"EEK\": \"Estonian Kroon\",\n\t\t\"EGP\": \"Egyptian Pound\",\n\t\t\"ERN\": \"Eritrean Nakfa\",\n\t\t\"ETB\": \"Ethiopian Birr\",\n\t\t\"EUR\": \"Euro\",\n\t\t\"FJD\": \"Fijian Dollar\",\n\t\t\"FKP\": \"Falkland Islands Pound\",\n\t\t\"GBP\": \"British Pound Sterling\",\n\t\t\"GEL\": \"Georgian Lari\",\n\t\t\"GGP\": \"Guernsey Pound\",\n\t\t\"GHS\": \"Ghanaian Cedi\",\n\t\t\"GIP\": \"Gibraltar Pound\",\n\t\t\"GMD\": \"Gambian Dalasi\",\n\t\t\"GNF\": \"Guinean Franc\",\n\t\t\"GTQ\": \"Guatemalan Quetzal\",\n\t\t\"GYD\": \"Guyanaese Dollar\",\n\t\t\"HKD\": \"Hong Kong Dollar\",\n\t\t\"HNL\": \"Honduran Lempira\",\n\t\t\"HRK\": \"Croatian Kuna\",\n\t\t\"HTG\": \"Haitian Gourde\",\n\t\t\"HUF\": \"Hungarian Forint\",\n\t\t\"IDR\": \"Indonesian Rupiah\",\n\t\t\"ILS\": \"Israeli New Sheqel\",\n\t\t\"IMP\": \"Manx pound\",\n\t\t\"INR\": \"Indian Rupee\",\n\t\t\"IQD\": \"Iraqi Dinar\",\n\t\t\"IRR\": \"Iranian Rial\",\n\t\t\"ISK\": \"Icelandic Króna\",\n\t\t\"JEP\": \"Jersey Pound\",\n\t\t\"JMD\": \"Jamaican Dollar\",\n\t\t\"JOD\": \"Jordanian Dinar\",\n\t\t\"JPY\": \"Japanese Yen\",\n\t\t\"KES\": \"Kenyan Shilling\",\n\t\t\"KGS\": \"Kyrgystani Som\",\n\t\t\"KHR\": \"Cambodian Riel\",\n\t\t\"KMF\": \"Comorian Franc\",\n\t\t\"KPW\": \"North Korean Won\",\n\t\t\"KRW\": \"South Korean Won\",\n\t\t\"KWD\": \"Kuwaiti Dinar\",\n\t\t\"KYD\": \"Cayman Islands Dollar\",\n\t\t\"KZT\": \"Kazakhstani Tenge\",\n\t\t\"LAK\": \"Laotian Kip\",\n\t\t\"LBP\": \"Lebanese Pound\",\n\t\t\"LKR\": \"Sri Lankan Rupee\",\n\t\t\"LRD\": \"Liberian Dollar\",\n\t\t\"LSL\": \"Lesotho Loti\",\n\t\t\"LTL\": \"Lithuanian Litas\",\n\t\t\"LVL\": \"Latvian Lats\",\n\t\t\"LYD\": \"Libyan Dinar\",\n\t\t\"MAD\": \"Moroccan Dirham\",\n\t\t\"MDL\": \"Moldovan Leu\",\n\t\t\"MGA\": \"Malagasy Ariary\",\n\t\t\"MKD\": \"Macedonian Denar\",\n\t\t\"MMK\": \"Myanma Kyat\",\n\t\t\"MNT\": \"Mongolian Tugrik\",\n\t\t\"MOP\": \"Macanese Pataca\",\n\t\t\"MRO\": \"Mauritanian Ouguiya\",\n\t\t\"MTL\": \"Maltese Lira\",\n\t\t\"MUR\": \"Mauritian Rupee\",\n\t\t\"MVR\": \"Maldivian Rufiyaa\",\n\t\t\"MWK\": \"Malawian Kwacha\",\n\t\t\"MXN\": \"Mexican Peso\",\n\t\t\"MYR\": \"Malaysian Ringgit\",\n\t\t\"MZN\": \"Mozambican Metical\",\n\t\t\"NAD\": \"Namibian Dollar\",\n\t\t\"NGN\": \"Nigerian Naira\",\n\t\t\"NIO\": \"Nicaraguan Córdoba\",\n\t\t\"NOK\": \"Norwegian Krone\",\n\t\t\"NPR\": \"Nepalese Rupee\",\n\t\t\"NZD\": \"New Zealand Dollar\",\n\t\t\"OMR\": \"Omani Rial\",\n\t\t\"PAB\": \"Panamanian Balboa\",\n\t\t\"PEN\": \"Peruvian Nuevo Sol\",\n\t\t\"PGK\": \"Papua New Guinean Kina\",\n\t\t\"PHP\": \"Philippine Peso\",\n\t\t\"PKR\": \"Pakistani Rupee\",\n\t\t\"PLN\": \"Polish Zloty\",\n\t\t\"PYG\": \"Paraguayan Guarani\",\n\t\t\"QAR\": \"Qatari Rial\",\n\t\t\"RON\": \"Romanian Leu\",\n\t\t\"RSD\": \"Serbian Dinar\",\n\t\t\"RUB\": \"Russian Ruble\",\n\t\t\"RWF\": \"Rwandan Franc\",\n\t\t\"SAR\": \"Saudi Riyal\",\n\t\t\"SBD\": \"Solomon Islands Dollar\",\n\t\t\"SCR\": \"Seychellois Rupee\",\n\t\t\"SDG\": \"Sudanese Pound\",\n\t\t\"SEK\": \"Swedish Krona\",\n\t\t\"SGD\": \"Singapore Dollar\",\n\t\t\"SHP\": \"Saint Helena Pound\",\n\t\t\"SLL\": \"Sierra Leonean Leone\",\n\t\t\"SOS\": \"Somali Shilling\",\n\t\t\"SRD\": \"Surinamese Dollar\",\n\t\t\"STD\": \"São Tomé and Príncipe Dobra\",\n\t\t\"SVC\": \"Salvadoran Colón\",\n\t\t\"SYP\": \"Syrian Pound\",\n\t\t\"SZL\": \"Swazi Lilangeni\",\n\t\t\"THB\": \"Thai Baht\",\n\t\t\"TJS\": \"Tajikistani Somoni\",\n\t\t\"TMT\": \"Turkmenistani Manat\",\n\t\t\"TND\": \"Tunisian Dinar\",\n\t\t\"TOP\": \"Tongan Paʻanga\",\n\t\t\"TRY\": \"Turkish Lira\",\n\t\t\"TTD\": \"Trinidad and Tobago Dollar\",\n\t\t\"TWD\": \"New Taiwan Dollar\",\n\t\t\"TZS\": \"Tanzanian Shilling\",\n\t\t\"UAH\": \"Ukrainian Hryvnia\",\n\t\t\"UGX\": \"Ugandan Shilling\",\n\t\t\"USD\": \"United States Dollar\",\n\t\t\"UYU\": \"Uruguayan Peso\",\n\t\t\"UZS\": \"Uzbekistan Som\",\n\t\t\"VEF\": \"Venezuelan Bolívar Fuerte\",\n\t\t\"VND\": \"Vietnamese Dong\",\n\t\t\"VUV\": \"Vanuatu Vatu\",\n\t\t\"WST\": \"Samoan Tala\",\n\t\t\"XAF\": \"CFA Franc BEAC\",\n\t\t\"XAG\": \"Silver (troy ounce)\",\n\t\t\"XAU\": \"Gold (troy ounce)\",\n\t\t\"XCD\": \"East Caribbean Dollar\",\n\t\t\"XDR\": \"Special Drawing Rights\",\n\t\t\"XOF\": \"CFA Franc BCEAO\",\n\t\t\"XPF\": \"CFP Franc\",\n\t\t\"YER\": \"Yemeni Rial\",\n\t\t\"ZAR\": \"South African Rand\",\n\t\t\"ZMK\": \"Zambian Kwacha (pre-2013)\",\n\t\t\"ZMW\": \"Zambian Kwacha\",\n\t\t\"ZWL\": \"Zimbabwean Dollar\"\n\t}\n\n};"
  },
  {
    "path": "public/scripts/app/template_manager.js",
    "content": "// template_manager.js\nApp.templateManager = {\n\n\t_cache: {},\n\t_templates: {},\n\t_loadingStates: {},\n\t_loadingCallbacks: {},\n\t_initialized: false,\n\n\tmodifiers: {\n\t\tdecimal: function(s) {\n\t\t\tvar decimal = Math.round((Math.abs(+s) % 1).toFixed(2) * 100);\n\n\t\t\tif (decimal === 0)\n\t\t\t\treturn '00';\n\t\t\tif (decimal < 10)\n\t\t\t\treturn '0' + decimal;\n\t\t\tif (decimal === 100)\n\t\t\t\treturn '99';\n\n\t\t\treturn decimal;\n\t\t},\n\t\trational: function(s) {\n\t\t\tvar rational = Math.floor(Math.abs(+s));\n\t\t\treturn rational;\n\t\t}\n\t},\n\tinitialize: function() {\n\t\tjSmart.prototype.getTemplate = function(name) {\n\t\t\tif (name.indexOf('shared/widgets/') === 0) {\n\t\t\t\t/// It's a widget!\n\t\t\t\tvar widgetName = name.split('shared/widgets/').join('').split('.tpl').join('');\n\t\t\t\tconsole.log('template_manager.js | Including widget \"' + widgetName + '\"');\n\n\t\t\t\treturn '<div class=\"widget client-side-widget client-side-widget-' + widgetName + '\" id=\"widget_' + (Math.random() + '').split('0.').join('') + '\" data-widget-name=\"' + widgetName + '\"></div>';\n\t\t\t}\n\n\t\t\tif (typeof(App.templateManager._templates[name]) !== 'undefined') {\n\t\t\t\treturn App.templateManager._cache[name];\n\t\t\t} else {\n\t\t\t\tthrow new Error('Template ' + name + ' is not yet loaded');\n\t\t\t}\n\t\t};\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'modifier',\n\t\t\t'decimal',\n\t\t\tthis.modifiers.decimal\n\t\t);\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'modifier',\n\t\t\t'rational',\n\t\t\tthis.modifiers.rational\n\t\t);\n\n\t\tDate.prototype.format = function(e) {\n\t\t\tvar t = \"\";\n\t\t\tvar n = Date.replaceChars;\n\t\t\tfor (var r = 0; r < e.length; r++) {\n\t\t\t\tvar i = e.charAt(r);\n\t\t\t\tif (r - 1 >= 0 && e.charAt(r - 1) == \"\\\\\") {\n\t\t\t\t\tt += i\n\t\t\t\t} else if (n[i]) {\n\t\t\t\t\tt += n[i].call(this)\n\t\t\t\t} else if (i != \"\\\\\") {\n\t\t\t\t\tt += i\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn t\n\t\t};\n\t\tDate.replaceChars = {\n\t\t\tshortMonths: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"],\n\t\t\tlongMonths: [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n\t\t\tshortDays: [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"],\n\t\t\tlongDays: [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n\t\t\td: function() {\n\t\t\t\treturn (this.getDate() < 10 ? \"0\" : \"\") + this.getDate()\n\t\t\t},\n\t\t\tD: function() {\n\t\t\t\treturn Date.replaceChars.shortDays[this.getDay()]\n\t\t\t},\n\t\t\tj: function() {\n\t\t\t\treturn this.getDate()\n\t\t\t},\n\t\t\tl: function() {\n\t\t\t\treturn Date.replaceChars.longDays[this.getDay()]\n\t\t\t},\n\t\t\tN: function() {\n\t\t\t\treturn this.getDay() + 1\n\t\t\t},\n\t\t\tS: function() {\n\t\t\t\treturn this.getDate() % 10 == 1 && this.getDate() != 11 ? \"st\" : this.getDate() % 10 == 2 && this.getDate() != 12 ? \"nd\" : this.getDate() % 10 == 3 && this.getDate() != 13 ? \"rd\" : \"th\"\n\t\t\t},\n\t\t\tw: function() {\n\t\t\t\treturn this.getDay()\n\t\t\t},\n\t\t\tz: function() {\n\t\t\t\tvar e = new Date(this.getFullYear(), 0, 1);\n\t\t\t\treturn Math.ceil((this - e) / 864e5)\n\t\t\t},\n\t\t\tW: function() {\n\t\t\t\tvar e = new Date(this.getFullYear(), 0, 1);\n\t\t\t\treturn Math.ceil(((this - e) / 864e5 + e.getDay() + 1) / 7)\n\t\t\t},\n\t\t\tF: function() {\n\t\t\t\treturn Date.replaceChars.longMonths[this.getMonth()]\n\t\t\t},\n\t\t\tm: function() {\n\t\t\t\treturn (this.getMonth() < 9 ? \"0\" : \"\") + (this.getMonth() + 1)\n\t\t\t},\n\t\t\tM: function() {\n\t\t\t\treturn Date.replaceChars.shortMonths[this.getMonth()]\n\t\t\t},\n\t\t\tn: function() {\n\t\t\t\treturn this.getMonth() + 1\n\t\t\t},\n\t\t\tt: function() {\n\t\t\t\tvar e = new Date;\n\t\t\t\treturn (new Date(e.getFullYear(), e.getMonth(), 0)).getDate()\n\t\t\t},\n\t\t\tL: function() {\n\t\t\t\tvar e = this.getFullYear();\n\t\t\t\treturn e % 400 == 0 || e % 100 != 0 && e % 4 == 0\n\t\t\t},\n\t\t\to: function() {\n\t\t\t\tvar e = new Date(this.valueOf());\n\t\t\t\te.setDate(e.getDate() - (this.getDay() + 6) % 7 + 3);\n\t\t\t\treturn e.getFullYear()\n\t\t\t},\n\t\t\tY: function() {\n\t\t\t\treturn this.getFullYear()\n\t\t\t},\n\t\t\ty: function() {\n\t\t\t\treturn (\"\" + this.getFullYear()).substr(2)\n\t\t\t},\n\t\t\ta: function() {\n\t\t\t\treturn this.getHours() < 12 ? \"am\" : \"pm\"\n\t\t\t},\n\t\t\tA: function() {\n\t\t\t\treturn this.getHours() < 12 ? \"AM\" : \"PM\"\n\t\t\t},\n\t\t\tB: function() {\n\t\t\t\treturn Math.floor(((this.getUTCHours() + 1) % 24 + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1e3 / 24)\n\t\t\t},\n\t\t\tg: function() {\n\t\t\t\treturn this.getHours() % 12 || 12\n\t\t\t},\n\t\t\tG: function() {\n\t\t\t\treturn this.getHours()\n\t\t\t},\n\t\t\th: function() {\n\t\t\t\treturn ((this.getHours() % 12 || 12) < 10 ? \"0\" : \"\") + (this.getHours() % 12 || 12)\n\t\t\t},\n\t\t\tH: function() {\n\t\t\t\treturn (this.getHours() < 10 ? \"0\" : \"\") + this.getHours()\n\t\t\t},\n\t\t\ti: function() {\n\t\t\t\treturn (this.getMinutes() < 10 ? \"0\" : \"\") + this.getMinutes()\n\t\t\t},\n\t\t\ts: function() {\n\t\t\t\treturn (this.getSeconds() < 10 ? \"0\" : \"\") + this.getSeconds()\n\t\t\t},\n\t\t\tu: function() {\n\t\t\t\tvar e = this.getMilliseconds();\n\t\t\t\treturn (e < 10 ? \"00\" : e < 100 ? \"0\" : \"\") + e\n\t\t\t},\n\t\t\te: function() {\n\t\t\t\treturn \"Not Yet Supported\"\n\t\t\t},\n\t\t\tI: function() {\n\t\t\t\tvar e = null;\n\t\t\t\tfor (var t = 0; t < 12; ++t) {\n\t\t\t\t\tvar n = new Date(this.getFullYear(), t, 1);\n\t\t\t\t\tvar r = n.getTimezoneOffset();\n\t\t\t\t\tif (e === null) e = r;\n\t\t\t\t\telse if (r < e) {\n\t\t\t\t\t\te = r;\n\t\t\t\t\t\tbreak\n\t\t\t\t\t} else if (r > e) break\n\t\t\t\t}\n\t\t\t\treturn this.getTimezoneOffset() == e | 0\n\t\t\t},\n\t\t\tO: function() {\n\t\t\t\treturn (-this.getTimezoneOffset() < 0 ? \"-\" : \"+\") + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? \"0\" : \"\") + Math.abs(this.getTimezoneOffset() / 60) + \"00\"\n\t\t\t},\n\t\t\tP: function() {\n\t\t\t\treturn (-this.getTimezoneOffset() < 0 ? \"-\" : \"+\") + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? \"0\" : \"\") + Math.abs(this.getTimezoneOffset() / 60) + \":00\"\n\t\t\t},\n\t\t\tT: function() {\n\t\t\t\tvar e = this.getMonth();\n\t\t\t\tthis.setMonth(0);\n\t\t\t\tvar t = this.toTimeString().replace(/^.+ \\(?([^\\)]+)\\)?$/, \"$1\");\n\t\t\t\tthis.setMonth(e);\n\t\t\t\treturn t\n\t\t\t},\n\t\t\tZ: function() {\n\t\t\t\treturn -this.getTimezoneOffset() * 60\n\t\t\t},\n\t\t\tc: function() {\n\t\t\t\treturn this.format(\"Y-m-d\\\\TH:i:sP\")\n\t\t\t},\n\t\t\tr: function() {\n\t\t\t\treturn this.toString()\n\t\t\t},\n\t\t\tU: function() {\n\t\t\t\treturn this.getTime() / 1e3\n\t\t\t}\n\t\t};\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'modifier',\n\t\t\t'date_format',\n\t\t\tfunction(s, fmt, defaultDate) {\n\t\t\t\tvar date = new Date(s * 1000);\n\t\t\t\treturn date.format(fmt ? fmt : 'M j, Y', s ? s : defaultDate);\n\t\t\t}\n\t\t);\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'modifier',\n\t\t\t'wallet_time',\n\t\t\tfunction(s) {\n\t\t\t\tvar date = new Date(s * 1000);\n\n\t\t\t\tif (App.settings.timeFormat == '12')\n\t\t\t\t\treturn date.format('g:i a', s);\n\t\t\t\telse\n\t\t\t\t\treturn date.format('H:i', s);\n\t\t\t}\n\t\t);\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'modifier',\n\t\t\t'wallet_date',\n\t\t\tfunction(s) {\n\t\t\t\tvar date = new Date(s * 1000);\n\n\t\t\t\tif (App.settings.dateFormat == 'mdy')\n\t\t\t\t\treturn date.format('M j, Y', s);\n\t\t\t\telse {\n\t\t\t\t\tvar monthName = date.format('F', s).toLowerCase();\n\t\t\t\t\treturn date.format('j', s) + ' ' + App.i18n.translate(monthName) + ' ' + date.format('Y', s);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'block',\n\t\t\t't',\n\t\t\tfunction(params, content, data, repeat) {\n\t\t\t\tif (typeof(App) === 'undefined' || typeof(App.i18n) === 'undefined')\n\t\t\t\t\treturn content;\n\t\t\t\telse\n\t\t\t\t\treturn App.i18n.translate(content);\n\t\t\t}\n\t\t);\n\n\t\tjSmart.prototype.registerPlugin(\n\t\t\t'block',\n\t\t\t'tp',\n\t\t\tfunction(params, content, data, repeat) {\n\t\t\t\tif (typeof(App) === 'undefined' || typeof(App.i18n) === 'undefined')\n\t\t\t\t\treturn '<span data-i18n=\"' + content + '\">' + content + \"</span>\";\n\t\t\t\telse\n\t\t\t\t\treturn '<span data-i18n=\"' + content + '\">' + App.i18n.translate(content) + \"</span>\";\n\t\t\t}\n\t\t);\n\n\t\tthis._initialized = true;\n\t},\n\tcommonData: function() {\n\t\treturn {\n\t\t\tsettings: _.extend(App.settings, {\n\t\t\t\tsite_path: App.settings.sitePath,\n\t\t\t\tclient_side: true,\n\t\t\t\tinvite_mode: App.settings.inviteMode\n\t\t\t})\n\t\t};\n\t},\n\tfetch: function(name, data, success) {\n\n\t\tif (!this._initialized)\n\t\t\tthis.initialize();\n\n\t\tdata = _.extend(data, this.commonData());\n\n\t\tif (typeof(this._templates[name]) !== 'undefined' || this.tryToLoadFromStorage(name)) {\n\t\t\tvar res = this._templates[name].fetch(data);\n\t\t\tif (typeof(success) === 'function')\n\t\t\t\tsuccess(res);\n\t\t\treturn res;\n\t\t}\n\n\t\tvar that = this;\n\n\t\tif (typeof(success) === 'function') {\n\t\t\tif (typeof(this._loadingStates[name]) !== 'undefined' && this._loadingStates[name] === 'loading') {\n\t\t\t\t// already fetched\n\t\t\t\tif (typeof(this._loadingCallbacks[name]) === 'undefined') {\n\t\t\t\t\tthis._loadingCallbacks[name] = [];\n\t\t\t\t}\n\n\t\t\t\tthis._loadingCallbacks[name].push(function(tpl) {\n\t\t\t\t\tsuccess(tpl.fetch(data));\n\t\t\t\t});\n\n\t\t\t} else {\n\t\t\t\t// fetch template\n\t\t\t\tthis.loadFromServer(name, function(tpl) {\n\t\t\t\t\tsuccess(tpl.fetch(data));\n\t\t\t\t});\n\t\t\t}\n\n\t\t} else {\n\t\t\tthis.loadFromServer(name);\n\t\t}\n\n\t\treturn false;\n\t},\n\ttryToLoadFromStorage: function(name) {\n\t\tif (!App.settings.enableTemplatesCache) {\n\t\t\tconsole.log('Templates cache is disabled');\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!App.localStorage.isSupported()) {\n\t\t\tconsole.log('Local storage is disabled');\n\t\t\treturn false;\n\t\t}\n\n\t\tvar data = App.localStorage.get('app_temapltes_' + name);\n\t\tif (data) {\n\t\t\tthis._cache[name] = data;\n\t\t\tthis._templates[name] = new jSmart(data);\n\t\t\tthis._loadingStates[name] = 'ready';\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t},\n\tloadFromServer: function(name, callback) {\n\n\t\tthis._loadingStates[name] = 'loading';\n\t\tvar that = this;\n\t\tvar templateName = name;\n\t\tvar callbackFunc = callback;\n\n\t\tconsole.time(\"template_manager.js | Fetch \" + templateName + \" from server\");\n\n\t\tvar process = function(data) {\n\t\t\tconsole.timeEnd(\"template_manager.js | Fetch \" + templateName + \" from server\");\n\t\t\tconsole.group(\"Template name: \" + templateName);\n\t\t\tconsole.log(\"Callback function present: \" + typeof(callbackFunc));\n\t\t\tif (typeof(that._loadingCallbacks[templateName]) === 'undefined')\n\t\t\t\tconsole.log(\"No additional callbacks\");\n\t\t\telse\n\t\t\t\tconsole.log(\"Additional callbacks: \" + that._loadingCallbacks[templateName].length);\n\t\t\tconsole.groupEnd();\n\n\t\t\tif (data) {\n\t\t\t\tApp.localStorage.set('app_temapltes_' + templateName, data);\n\t\t\t\tthat._cache[templateName] = data;\n\t\t\t\tthat._templates[templateName] = new jSmart(data);\n\t\t\t\tthat._loadingStates[templateName] = 'ready';\n\n\t\t\t\tif (typeof(callbackFunc) === 'function')\n\t\t\t\t\tcallbackFunc(that._templates[templateName]);\n\n\t\t\t\tif (typeof(that._loadingCallbacks[templateName]) !== 'undefined') {\n\t\t\t\t\tfor (var k in that._loadingCallbacks[templateName])\n\t\t\t\t\t\tthat._loadingCallbacks[templateName][k](that._templates[templateName]);\n\n\t\t\t\t\tthat._loadingCallbacks[templateName] = [];\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tvar use_cache = true;\n\t\tif (!App.settings.enableTemplatesCache)\n\t\t\tuse_cache = false;\n\n\t\t$.ajax({\n\t\t\turl: App.settings.templatePath + name,\n\t\t\tdata: {},\n\t\t\tsuccess: process,\n\t\t\tdataType: 'html',\n\t\t\tmimeType: 'text/plain',\n\t\t\tcache: use_cache\n\t\t});\n\t}\n\n\n};"
  },
  {
    "path": "public/scripts/app/view_stack.js",
    "content": "// view_stack.js\nApp.viewStack = {\n\n\tstack: {},\n\tinStackCount: 0,\n\taddView: function(name, params, view) {\n\t\tif (!App.settings.enablePagesStack)\n\t\t\treturn false;\n\n\t\tvar hash = name;\n\t\tif (typeof(params) !== 'undefined')\n\t\t\tfor (var k in params) {\n\t\t\t\tif (typeof(params[k].id) !== 'undefined')\n\t\t\t\t\thash += '-' + k + '_id' + params[k].id;\n\t\t\t\telse\n\t\t\t\t\thash += '-' + k + '_' + params[k];\n\t\t\t}\n\n\t\tthis.stack[hash] = {\n\t\t\tview: view,\n\t\t\thash: hash,\n\t\t\tadded: new Date()\n\t\t};\n\t\tthis.inStackCount++;\n\t\tthis.removeOldestIfNeeded();\n\t\treturn true;\n\t},\n\tgetView: function(name, params) {\n\t\tif (!App.settings.enablePagesStack)\n\t\t\treturn false;\n\n\t\tvar hash = name;\n\t\tif (typeof(params) !== 'undefined')\n\t\t\tfor (var k in params) {\n\t\t\t\tif (typeof(params[k].id) !== 'undefined')\n\t\t\t\t\thash += '-' + k + '_id' + params[k].id;\n\t\t\t\telse\n\t\t\t\t\thash += '-' + k + '_' + params[k];\n\t\t\t}\n\n\t\tif (typeof(this.stack[hash]) !== 'undefined')\n\t\t\treturn this.stack[hash].view;\n\t\telse\n\t\t\treturn false;\n\t},\n\tclear: function() {\n\t\tthis.stack = {};\n\t\tthis.inStackCount = 0;\n\t},\n\tremoveOldestIfNeeded: function() {\n\t\tvar maxElements = App.settings.pagesStackMaxLength;\n\n\t\tif (this.inStackCount <= maxElements)\n\t\t\treturn;\n\n\t\tvar sort = [];\n\t\tfor (var k in this.stack)\n\t\t\tsort.push({\n\t\t\t\thash: this.stack[k].hash,\n\t\t\t\tadded: this.stack[k].added\n\t\t\t});\n\n\t\tsort.sort(function(a, b) {\n\t\t\treturn a.added - b.added;\n\t\t});\n\t\tconsole.log(\"Removing \" + sort[0].hash + \" from pages stack\");\n\t\tdelete this.stack[sort[0].hash];\n\t\tthis.inStackCount--;\n\t}\n};"
  },
  {
    "path": "public/scripts/app/views/charts/balance.js",
    "content": "// balance.js\nApp.Views.Charts.Balance = Backbone.View.extend({\n\n\tevents: {},\n\tchart: false,\n\taTransactions: [],\n\t_data: {},\n\tdataReady: false,\n\tdataFetched: false,\n\tlibReady: false,\n\n\tdrawChart: function() {\n\t\tvar that = this;\n\t\t$('#' + that.id).fadeOut(20, function() {\n\t\t\t$('#balance_canvas_container').show();\n\t\t\tvar options = {\n\t\t\t\ttitle: 'Expenses',\n\t\t\t\tcurveType: 'function',\n\t\t\t\tlegend: {\n\t\t\t\t\tposition: 'none'\n\t\t\t\t},\n\t\t\t\twidth: that.containerWidth,\n\t\t\t\theight: that.containerHeight,\n\t\t\t\tchartArea: {\n\t\t\t\t\tleft: 0,\n\t\t\t\t\ttop: 0,\n\t\t\t\t\twidth: that.containerWidth,\n\t\t\t\t\theight: '85%'\n\t\t\t\t},\n\t\t\t\tcolors: ['#a94442'],\n\t\t\t\tvAxis: {\n\t\t\t\t\ttextPosition: 'in',\n\t\t\t\t\tviewWindow: {\n\t\t\t\t\t\tmin: 0\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thAxis: {\n\t\t\t\t\tminValue: 0,\n\t\t\t\t\tbaseline: 0,\n\t\t\t\t\ttextStyle: {\n\t\t\t\t\t\tfontSize: 8\n\t\t\t\t\t},\n\t\t\t\t\t// ticks: [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30],\n\t\t\t\t\tslantedTextAngle: 30,\n\t\t\t\t\tmaxAlternation: 1,\n\t\t\t\t\tslantedText: true\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (that._data.length > 1) {\n\t\t\t\tvar chart = new google.visualization.LineChart(document.getElementById(that.id));\n\t\t\t\tchart.draw(google.visualization.arrayToDataTable(that._data), options);\n\t\t\t} else {\n\t\t\t\t$('#balance_canvas_container').hide();\n\t\t\t}\n\t\t\t$('#' + that.id).fadeIn(400);\n\t\t});\n\t},\n\tinitialize: function() {\n\t\tif (!this.model || !this.id)\n\t\t\tconsole.error('views/charts/balance.js | model(wallet) and id of canvas should be provided for this view');\n\n\t\tvar that = this;\n\n\t\tgoogle.load('visualization', '1.0', {\n\t\t\t'packages': ['corechart'],\n\t\t\t'callback': function() {\n\t\t\t\t/// visualization library loaded\n\t\t\t\tthat.trigger('libReady');\n\t\t\t\tthat.libReady = true;\n\t\t\t}\n\t\t});\n\n\t\tthis.model.on('addTransaction', this.appendTransaction, this);\n\t\tthis.model.on('removeTransaction', this.removeTransaction, this);\n\n\t\tthis.on('dataReady', function() {\n\t\t\tconsole.log('views/charts/balance.js | dataReady');\n\n\t\t\tif (that.libReady)\n\t\t\t\tthat.drawChart();\n\t\t\telse\n\t\t\t\tthat.once('libReady', that.drawChart);\n\t\t});\n\t},\n\tresize: function() {\n\t\tif (typeof(this.__resizeThrottled) === 'undefined') {\n\t\t\tvar that = this;\n\t\t\tthis.__resizeThrottled = _.throttle(function() {\n\t\t\t\tif (that.libReady && that.dataReady)\n\t\t\t\t\tthat.drawChart();\n\t\t\t}, 100);\n\t\t}\n\n\t\tthis.containerWidth = $('#balance_canvas').width();\n\t\tthis.containerHeight = $('#balance_canvas').height();\n\t\tthis.__resizeThrottled();\n\t},\n\tappendTransaction: function(transaction) {\n\t\tthis.aTransactions.push(transaction);\n\t\tthis.trigger('transactionsReady');\n\t},\n\tremoveTransaction: function(transactionId) {\n\t\tthis.aTransactions = _.filter(this.aTransactions, function(t) {\n\t\t\treturn t.id != transactionId;\n\t\t});\n\t\tthis.trigger('transactionsReady');\n\t},\n\tgetMissedTransactionsFromPage: function() {\n\t\tvar isUpdated = false;\n\t},\n\tfetchTransactions: function() {\n\t\tif (this.aTransactions.length) {\n\t\t\tthis.trigger('transactionsReady');\n\t\t\treturn this.aTransactions;\n\t\t}\n\n\t\tvar transactions = new App.Collections.Transactions();\n\t\tthis.aTransactions = [];\n\t\ttransactions.setWalletId(this.model.id);\n\n\t\tvar that = this;\n\t\ttransactions.once('sync', function() {\n\t\t\tconsole.log('Synced current month');\n\t\t\ttransactions.forEach(function(t) {\n\t\t\t\tthat.aTransactions.push(t);\n\t\t\t});\n\n\t\t\ttransactions.once('sync', function() {\n\t\t\t\tconsole.log('Synced prev month');\n\t\t\t\ttransactions.forEach(function(t) {\n\t\t\t\t\tthat.aTransactions.push(t);\n\t\t\t\t});\n\n\t\t\t\tthat.trigger('transactionsReady');\n\t\t\t});\n\t\t\ttransactions.gotoPrev();\n\t\t});\n\n\t\ttransactions.fetch();\n\t},\n\tfetchData: function() {\n\t\tif (this.dataFetched)\n\t\t\treturn false;\n\t\tif (this.dataReady) {\n\t\t\tthis.trigger('dataReady');\n\t\t\treturn this._data;\n\t\t}\n\n\t\tthis.dataFetched = true;\n\n\t\tvar that = this;\n\t\tthis.on('transactionsReady', function() {\n\t\t\tconsole.log('views/charts/balance.js | transactionsReady');\n\t\t\t//// first step. Filter expenses\n\t\t\tvar a = _.filter(this.aTransactions, function(t) {\n\t\t\t\treturn t.get('amount') < 0;\n\t\t\t});\n\t\t\t//// second step. For each day\n\t\t\tvar days = {};\n\t\t\tvar curTime = new Date();\n\t\t\tvar curDay = curTime.getDate();\n\t\t\tvar curMonth = curTime.getMonth();\n\t\t\tvar curYear = curTime.getYear();\n\n\t\t\tcurTime = curTime.getTime();\n\t\t\tvar eachDayFunc = function(t) {\n\t\t\t\tvar tDate = new Date(t.get('datetime') * 1000);\n\t\t\t\tif (tDate.getDate() === day && tDate.getMonth() === month)\n\t\t\t\t\tdayTotal += Math.abs(t.get('amount'));\n\t\t\t};\n\n\t\t\tfor (var i = 60; i >= 0; i--) {\n\t\t\t\tvar d = new Date(curTime - 24 * 60 * 60 * 1000 * i);\n\t\t\t\tvar day = d.getDate();\n\t\t\t\tvar month = d.getMonth();\n\t\t\t\tvar year = d.getYear();\n\n\t\t\t\tvar dayTotal = 0;\n\t\t\t\t_.each(a, eachDayFunc);\n\t\t\t\tdays[day + '-' + month] = {\n\t\t\t\t\tday: day,\n\t\t\t\t\tmonth: month,\n\t\t\t\t\tyear: year,\n\t\t\t\t\ttotal: Math.abs(dayTotal)\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t/// third step. Find first day from a set at which transaction occurs.\n\t\t\tvar firstDay = 0;\n\t\t\tvar firstMonth = 0;\n\t\t\tvar firstYear = 0;\n\t\t\t_.each(days, function(day) {\n\t\t\t\tif (day.total > 0) {\n\t\t\t\t\tif (firstDay === 0 && firstMonth === 0) {\n\t\t\t\t\t\tfirstDay = day.day;\n\t\t\t\t\t\tfirstMonth = day.month;\n\t\t\t\t\t\tfirstYear = day.year;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((day.month < firstMonth && day.year == firstYear) || (day.day < firstDay && day.month == firstMonth)) {\n\t\t\t\t\t\tfirstDay = day.day;\n\t\t\t\t\t\tfirstMonth = day.month;\n\t\t\t\t\t\tfirstYear = day.year;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t/// forth step. Fill days without transactions by values from next days started from firstDay\n\t\t\tif (firstDay)\n\t\t\t\t_.each(days, function(d) {\n\t\t\t\t\tif (firstYear < d.year || (firstMonth < d.month && firstYear <= d.year) || (firstDay < d.day && firstMonth == d.month)) {\n\t\t\t\t\t\tif (d.total === 0 && typeof(d.filledMissed) === 'undefined') {\n\t\t\t\t\t\t\tvar foundTotal = 0;\n\t\t\t\t\t\t\tvar foundEmpty = [];\n\t\t\t\t\t\t\tvar iDay = d.day + 1;\n\t\t\t\t\t\t\tvar iMonth = d.month;\n\t\t\t\t\t\t\tvar iYear = d.year;\n\t\t\t\t\t\t\tfoundEmpty.push(d.day + '-' + d.month);\n\n\t\t\t\t\t\t\twhile ((foundTotal === 0) && ((curMonth == iMonth && curDay >= iDay) || (curYear == iYear && curMonth > iMonth) || curYear > iYear))\n\t\t\t\t\t\t\t\tif (typeof(days[iDay + '-' + iMonth]) !== 'undefined') {\n\n\t\t\t\t\t\t\t\t\tif (days[iDay + '-' + iMonth].total === 0) {\n\t\t\t\t\t\t\t\t\t\t/// another empty day\n\t\t\t\t\t\t\t\t\t\tfoundEmpty.push(iDay + '-' + iMonth);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t/// day with total set\n\t\t\t\t\t\t\t\t\t\tfoundEmpty.push(iDay + '-' + iMonth);\n\t\t\t\t\t\t\t\t\t\tfoundTotal = days[iDay + '-' + iMonth].total;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tiDay++;\n\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t/// next month\n\t\t\t\t\t\t\t\t\tiMonth++;\n\t\t\t\t\t\t\t\t\tiDay = 1;\n\n\t\t\t\t\t\t\t\t\tif (iMonth == 12) {\n\t\t\t\t\t\t\t\t\t\tiMonth = 0;\n\t\t\t\t\t\t\t\t\t\tiYear++;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t//// fill missed sum\n\t\t\t\t\t\t\tfoundEmpty = _.uniq(foundEmpty);\n\t\t\t\t\t\t\tif (foundEmpty.length > 0) {\n\t\t\t\t\t\t\t\tvar total = foundTotal / foundEmpty.length;\n\t\t\t\t\t\t\t\t_.each(foundEmpty, function(found) {\n\t\t\t\t\t\t\t\t\tdays[found].total = total;\n\t\t\t\t\t\t\t\t\tdays[found].filledMissed = true;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t/// fifth step. Filter days with total set and truncate to 30 max\n\t\t\t//days = _.filter(days, function(d){ return d.total > 0; });\n\t\t\t//days = _.last(days, 30);\n\n\t\t\t/// generate labels\n\t\t\t//days.reverse();\n\t\t\tvar values = [];\n\t\t\t_.each(days, function(day, key) {\n\t\t\t\tvalues.push({\n\t\t\t\t\tlabel: day.day + '/' + (day.month + 1),\n\t\t\t\t\tvalue: day.total\n\t\t\t\t});\n\t\t\t});\n\t\t\t//values.reverse();\n\t\t\tvalues = _.last(values, 31);\n\t\t\t/// remove empty from the start\n\t\t\tvar alreadyStarted = false;\n\t\t\tvalues = _.filter(values, function(item) {\n\t\t\t\tif (item.value > 0 || alreadyStarted) {\n\t\t\t\t\talreadyStarted = true;\n\t\t\t\t\treturn true;\n\t\t\t\t} else return false;\n\t\t\t});\n\n\t\t\t/// group by \n\t\t\t// if (values.length > 10) {\n\t\t\t// \tvar rvalues = [];\n\t\t\t// \tvar i = 0;\n\t\t\t// \tif (values.length > 20) {\n\t\t\t// \t\t/// by 3\n\t\t\t// \t\twhile (typeof(values[i]) !== 'undefined') {\n\t\t\t// \t\t\tvar rvalue = values[i].value;\n\t\t\t// \t\t\tif (typeof(values[i + 1]) !== 'undefined') rvalue += values[i + 1].value;\n\t\t\t// \t\t\tif (typeof(values[i + 2]) !== 'undefined') rvalue += values[i + 2].value;\n\n\t\t\t// \t\t\tif (typeof(values[i + 1]) !== 'undefined' && typeof(values[i + 2]) !== 'undefined')\n\t\t\t// \t\t\t\trvalue = rvalue / 3;\n\t\t\t// \t\t\telse if (typeof(values[i + 1]) !== 'undefined')\n\t\t\t// \t\t\t\trvalue = rvalue / 2;\n\n\t\t\t// \t\t\tvar rlabel = values[i].label;\n\t\t\t// \t\t\tif (typeof(values[i + 2]) !== 'undefined') rlabel += ' - <br>' + values[i + 2].label;\n\t\t\t// \t\t\telse\n\t\t\t// \t\t\tif (typeof(values[i + 1]) !== 'undefined') rlabel += ' - <br>' + values[i + 1].label;\n\n\t\t\t// \t\t\trvalues.push({\n\t\t\t// \t\t\t\tlabel: rlabel,\n\t\t\t// \t\t\t\tvalue: rvalue\n\t\t\t// \t\t\t});\n\t\t\t// \t\t\ti = i + 3;\n\t\t\t// \t\t}\n\t\t\t// \t} else {\n\t\t\t// \t\t/// by 2\n\t\t\t// \t\twhile (typeof(values[i]) !== 'undefined') {\n\t\t\t// \t\t\tvar rvalue = values[i].value;\n\t\t\t// \t\t\tif (typeof(values[i + 1]) !== 'undefined') rvalue += values[i + 1].value;\n\n\t\t\t// \t\t\tif (typeof(values[i + 1]) !== 'undefined')\n\t\t\t// \t\t\t\trvalue = rvalue / 2;\n\n\t\t\t// \t\t\tvar rlabel = values[i].label;\n\t\t\t// \t\t\tif (typeof(values[i + 1]) !== 'undefined') rlabel += ' - <br>' + values[i + 1].label;\n\n\t\t\t// \t\t\trvalues.push({\n\t\t\t// \t\t\t\tlabel: rlabel,\n\t\t\t// \t\t\t\tvalue: rvalue\n\t\t\t// \t\t\t});\n\t\t\t// \t\t\ti = i + 2;\n\t\t\t// \t\t}\n\t\t\t// \t}\n\n\t\t\t// \tvalues = rvalues;\n\t\t\t// }\n\n\t\t\tvar labels = _.map(values, function(item) {\n\t\t\t\treturn item.label;\n\t\t\t});\n\t\t\tvar series = [\n\t\t\t\t[]\n\t\t\t];\n\t\t\tseries[0] = _.map(values, function(item) {\n\t\t\t\treturn item.value;\n\t\t\t});\n\n\t\t\tthat._data = [];\n\t\t\tthat._data.push(['Date', 'Amount']);\n\t\t\tfor (var k in values)\n\t\t\t\tthat._data.push([values[k].label, +values[k].value.toFixed(2)]);\n\n\t\t\tthat.dataFetched = false;\n\n\t\t\tthat.dataReady = true;\n\t\t\tthat.trigger('dataReady');\n\t\t});\n\t\tthis.fetchTransactions();\n\t},\n\twakeUp: function() {\n\t\tthis.render();\n\t},\n\tsleep: function() {\n\t\t$(window).off('resize');\n\t},\n\trender: function() {\n\t\tconsole.log('Rendering chart');\n\n\t\tif (!$('#' + this.id).length)\n\t\t\treturn;\n\n\t\tvar that = this;\n\t\tthat.resize();\n\t\t$(window).on('resize', function() {\n\t\t\tthat.resize();\n\t\t});\n\n\t\tthis.fetchData();\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/add_profit.js",
    "content": "// add_profit.js\nApp.Views.Dialogs.AddProfit = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'add_profit',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_amount',\n\tinitialize: function(params) {\n\t\tthis.wallet = params.wallet || false;\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar amount = this.$('#input_amount').val();\n\t\tvar description = this.$('#input_description').val();\n\n\t\tamount = +amount;\n\t\tif (amount && amount > 0) {\n\t\t\tthis.wallet.addProfit(amount, description);\n\t\t}\n\n\t\tthis.hide();\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/add_wallet.js",
    "content": "// add_wallet.js\nApp.Views.Dialogs.AddWallet = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'add_wallet',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_name',\n\tinitialize: function() {\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\t\tvar name = this.$('#input_name').val();\n\t\tvar currency = this.$('#input_currency').val();\n\t\tvar error = '';\n\n\t\tif (!currency)\n\t\t\terror = 'Please select wallet currency';\n\n\t\tif (error) {\n\t\t\tthis.$('.errors-container').html(error);\n\t\t\tthis.$('.errors-container').slideDown();\n\n\t\t\tthis.$('#input_currency').focus();\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tvar that = this;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('.errors-container').slideUp();\n\t\t\t}, 2000);\n\t\t} else {\n\t\t\tvar item = new App.Models.Wallet();\n\t\t\titem.set('name', name);\n\t\t\titem.set('currency', currency);\n\t\t\titem.set('total', 0);\n\t\t\titem.set('status', 'active');\n\n\t\t\tif (typeof(App.page) !== 'undefined' && App.page && typeof(App.page.items) !== 'undefined' && App.page.items.model == App.Models.Wallet) {\n\t\t\t\tApp.page.items.add(item);\n\t\t\t}\n\n\t\t\titem.save();\n\n\t\t\tthis.hide();\n\t\t}\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/change_language.js",
    "content": "// change_language.js\nApp.Views.Dialogs.ChangeLanguage = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'change_language',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click .process_button\": \"doProcess\"\n\t},\n\tcurrentlyUpdating: false,\n\tinitialize: function() {\n\t\tvar that = this;\n\t\tthis.on('ready', function() {\n\n\t\t});\n\t\tthis.show({\n\t\t\tlocales: App.settings.availiableLocales,\n\t\t\tcurrent_locale: App.settings.language\n\t\t});\n\t},\n\tdoProcess: function(ev) {\n\t\tif (this.currentlyUpdating)\n\t\t\treturn false;\n\t\tvar code = $(ev.currentTarget).data('code');\n\t\tif (code == App.settings.language)\n\t\t\tthis.hide();\n\t\telse {\n\t\t\t// alert('set '+code);\n\t\t\tthis.currentlyUpdating = true;\n\t\t\tvar that = this;\n\t\t\tthat.$('.process_button_container').fadeTo(0.1, 0.1);\n\t\t\tApp.i18n.setLanguage(code, function() {\n\t\t\t\tthat.currentlyUpdating = false;\n\t\t\t\tthat.$('.process_button_container').fadeTo(1, 1);\n\t\t\t\tApp.settings.language = code;\n\t\t\t\tthat.hide();\n\t\t\t});\n\t\t}\n\t},\n\tonSubmit: function() {\n\t\tthis.hide();\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/edit_wallet.js",
    "content": "// edit_wallet.js\nApp.Views.Dialogs.EditWallet = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'edit_wallet',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_name',\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\n\t\tthis.show({\n\t\t\titem: this.item.toJSON()\n\t\t});\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\t\tvar name = this.$('#input_name').val();\n\t\tvar currency = this.$('#input_currency').val();\n\t\tvar error = '';\n\n\t\tif (!currency)\n\t\t\terror = 'Please select wallet currency';\n\n\t\tif (error) {\n\t\t\tthis.$('.errors-container').html(error);\n\t\t\tthis.$('.errors-container').slideDown();\n\n\t\t\tthis.$('#input_currency').focus();\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tvar that = this;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('.errors-container').slideUp();\n\t\t\t}, 2000);\n\t\t} else {\n\t\t\tthis.item.set('name', name);\n\t\t\tthis.item.set('currency', currency);\n\t\t\tthis.item.save();\n\n\t\t\tthis.hide();\n\t\t}\n\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/fill_profile.js",
    "content": "// fill_profile.js\nApp.Views.Dialogs.FillProfile = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'fill_profile',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_login',\n\tinitialize: function() {\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar login = this.$('#input_login').val();\n\t\tvar password = this.$('#input_password').val();\n\t\tvar email = this.$('#input_email').val();\n\n\t\tthis.listenTo(App.currentUser, 'invalid', function() {\n\t\t\tvar html = \"\";\n\t\t\tfor (var k in App.currentUser.validationError) html += App.currentUser.validationError[k].msg + \"<br>\";\n\t\t\tthis.$('.errors-container').html(html);\n\t\t\tthis.$('.errors-container').slideDown();\n\n\t\t\tthis.$('#input_login').focus(); /// @todo: focus to input with error\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tvar that = this;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('.errors-container').slideUp();\n\t\t\t}, 2000);\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'filled', function() {\n\t\t\t$('#fill_profile_invitation').slideUp();\n\t\t\tthis.$('.modal-body-default').slideUp();\n\t\t\tthis.$('.modal-body-success').slideDown();\n\n\t\t\tsetTimeout(function() {\n\t\t\t\tApp.dialog.hide();\n\t\t\t}, 2000);\n\t\t});\n\n\t\tApp.currentUser.fillProfile(login, email, password);\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/hide_wallet.js",
    "content": "// hide_wallet.js\nApp.Views.Dialogs.HideWallet = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'hide_wallet',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click .process_button\": \"doProcess\"\n\t},\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\n\t\tthis.show({\n\t\t\titem: this.item.toJSON()\n\t\t});\n\t},\n\tdoProcess: function() {\n\t\tthis.$('.btn-danger').button('loading');\n\t\tthis.item.hide();\n\t\tthis.hide();\n\t},\n\tonSubmit: function() {\n\t\tthis.hide();\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/logout.js",
    "content": "// logout.js\nApp.Views.Dialogs.Logout = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'logout', // don't need template for this one, as we are not going to show it\n\tinitialize: function() {\n\t\tApp.currentUser.signOut();\n\t\tApp.viewStack.clear();\n\t\tApp.router.redirect('/');\n\t\t$('#fill_profile_invitation').hide();\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/registration.js",
    "content": "// registration.js\nApp.Views.Dialogs.Registration = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'registration',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_login',\n\tinitialize: function() {\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar login = this.$('#input_login').val();\n\t\tvar password = this.$('#input_password').val();\n\t\tvar email = this.$('#input_email').val();\n\n\t\tApp.currentUser.clear();\n\n\t\tthis.listenTo(App.currentUser, 'signedInStatusChanged', function() {\n\t\t\tApp.userChanged();\n\t\t\tthis.hide();\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'registered', function() {\n\t\t\tthis.$('.modal-body-default').slideUp();\n\t\t\tthis.$('.modal-body-success').slideDown();\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'invalid', function() {\n\t\t\tvar html = \"\";\n\t\t\tfor (var k in App.currentUser.validationError) html += App.currentUser.validationError[k].msg + \"<br>\";\n\t\t\tthis.$('.errors-container').html(html);\n\t\t\tthis.$('.errors-container').slideDown();\n\n\t\t\tthis.$('#input_login').focus(); /// @todo: focus to input with error\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tvar that = this;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('.errors-container').slideUp();\n\t\t\t}, 2000);\n\t\t});\n\n\t\tApp.currentUser.register(login, email, password);\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/remove_access.js",
    "content": "// remove_access.js\nApp.Views.Dialogs.RemoveAccess = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'remove_access',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click .process_button\": \"doProcess\"\n\t},\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\n\n\t\tif (typeof(params.access) != 'undefined')\n\t\t\tthis.access = params.access;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.access';\n\n\t\tthis.show({\n\t\t\titem: this.item.toJSON(),\n\t\t\taccess: this.access.toJSON()\n\t\t});\n\t},\n\tdoProcess: function() {\n\t\tvar that = this;\n\t\tthis.$('.btn-danger').button('loading');\n\t\tthis.listenToOnce(this.access, 'sync error', function() {\n\t\t\tApp.showDialog('WalletAccesses', {\n\t\t\t\titem: that.item\n\t\t\t});\n\t\t});\n\t\tthis.access.destroy();\n\t},\n\tonSubmit: function() {\n\t\tApp.showDialog('WalletAccesses', {\n\t\t\titem: this.item\n\t\t});\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/remove_plan.js",
    "content": "// remove_plan.js\nApp.Views.Dialogs.RemovePlan = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'remove_plan',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click .process_button\": \"doProcess\"\n\t},\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\n\t\tthis.show({\n\t\t\titem: this.item.toJSON()\n\t\t});\n\t},\n\tdoProcess: function() {\n\t\tthis.$('.btn-danger').button('loading');\n\n\t\tApp.localStorage.remove('plan_' + this.item.id + '_data');\n\t\tthis.item.destroy();\n\t\tApp.page.render();\n\n\t\tthis.hide();\n\n\t\treturn false;\n\n\t},\n\tonSubmit: function() {\n\t\tthis.hide();\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/remove_transaction.js",
    "content": "// remove_transaction.js\nApp.Views.Dialogs.RemoveTransaction = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'remove_transaction',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click .process_button\": \"doProcess\"\n\t},\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\n\t\tif (typeof(params.wallet) != 'undefined')\n\t\t\tthis.wallet = params.wallet;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.wallet';\n\n\t\tthis.show({\n\t\t\titem: this.item.toJSON()\n\t\t});\n\t},\n\tdoProcess: function() {\n\n\t\tvar that = this;\n\n\t\tthis.$('.btn-danger').button('loading');\n\t\tApp.page.model.removeTransaction(this.item);\n\n\t\tthis.hide();\n\n\t\treturn false;\n\n\t\t// var that = this;\n\t\t// this.$('.btn-danger').button('loading');\t\n\t\t// this.listenToOnce(this.item, 'sync error', function(){\n\t\t// \tthat.hide();\n\t\t// \tif (typeof(App.page) !== 'undefined' && typeof(App.page.reloadWallet) === 'function')\n\t\t// \t\tApp.page.reloadWallet();\n\t\t// });\n\t\t// this.item.destroy();\n\t},\n\tonSubmit: function() {\n\t\tApp.showDialog('TransactionDetails', {\n\t\t\titem: this.item,\n\t\t\twallet: this.wallet\n\t\t});\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/restore.js",
    "content": "// restore.js\nApp.Views.Dialogs.Restore = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'restore',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_email',\n\tinitialize: function() {\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar email = this.$('#input_email').val();\n\n\t\tthis.listenTo(App.currentUser, 'restore:error', function() {\n\t\t\tvar html = \"\";\n\t\t\tfor (var k in App.currentUser.validationError) html += App.currentUser.validationError[k].msg + \"<br>\";\n\t\t\tthis.$('.errors-container').html(html);\n\t\t\tthis.$('.errors-container').slideDown();\n\n\t\t\tthis.$('#input_email').focus(); /// @todo: focus to input with error\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tvar that = this;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('.errors-container').slideUp();\n\t\t\t}, 2000);\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'restore:success', function() {\n\t\t\tthis.$('.modal-body-default').slideUp();\n\t\t\tthis.$('.modal-body-success').slideDown();\n\t\t});\n\n\t\t// App.currentUser.on(\"signedInStatusChanged\", function(){\n\t\t// \tApp.userChanged();\n\t\t// \tthat.hide();\n\t\t// });\n\t\tApp.currentUser.restorePassword(email);\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/set_total_to.js",
    "content": "// set_total_to.js\nApp.Views.Dialogs.SetTotalTo = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'set_total_to',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_total',\n\tinitialize: function(params) {\n\t\tthis.wallet = params.wallet || false;\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar total = this.$('#input_total').val();\n\t\t//var description = this.$('#input_description').val();\n\n\t\tif (Number(total) === parseFloat(total, 10)) {\n\t\t\ttotal = +total;\n\t\t\tthis.wallet.setTotalTo(total);\n\t\t}\n\n\t\tthis.hide();\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/signin.js",
    "content": "// signin.js\nApp.Views.Dialogs.Signin = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'signin',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\"\n\t},\n\tfocusOnInit: '#input_username',\n\tinitialize: function() {\n\t\tthis.show();\n\t},\n\tonSubmit: function() {\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar username = this.$('#input_username').val();\n\t\tvar password = this.$('#input_password').val();\n\n\t\tApp.currentUser.set('login', username);\n\t\tApp.currentUser.set('password', password);\n\t\tthis.listenTo(App.currentUser, 'signedin', function() {\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tthis.hide();\n\t\t});\n\t\tthis.listenTo(App.currentUser, 'invalid', function() {\n\t\t\tthis.$('.btn-primary').button('reset');\n\t\t\tthis.$('.errors-container').slideDown();\n\t\t\tthis.$('#input_username').focus();\n\t\t\tvar that = this;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('.errors-container').slideUp();\n\t\t\t}, 2000);\n\t\t});\n\n\t\t// App.currentUser.on('signedin', function(){\n\t\t// });\n\t\t// App.currentUser.on('invalid', function(){\n\t\t// \tthat.$('.btn-primary').button('reset');\n\t\t// \tthat.$('.errors-container').slideDown();\n\t\t// \tthat.$('#input_username').focus();\n\n\t\t// \tsetTimeout(function() {\n\t\t// \t\tthat.$('.errors-container').slideUp();\n\t\t// \t}, 2000);\n\t\t// });\n\t\tApp.currentUser.signIn(username, password);\n\n\t\treturn false;\n\t},\n\tonResponse: function(user) {\n\t\tvar that = this;\n\t\tif (user.isSignedIn()) {\n\t\t\tthis.$('#signin_modal_form_submit').button('reset');\n\t\t\tthis.hide();\n\t\t} else {\n\t\t\tthis.$('#signin_invalid_password_alert').slideDown();\n\t\t\tthis.$('#signin_modal_form_submit').button('reset');\n\t\t\tthis.$('#input_username').focus();\n\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.$('#signin_invalid_password_alert').slideUp();\n\t\t\t}, 1000);\n\t\t}\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/transaction_details.js",
    "content": "// transaction_details.js\nApp.Views.Dialogs.TransactionDetails = App.Views.Abstract.Dialog.extend({\n\n\tdialogName: 'transaction_details',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click #remove_transaction_button\": \"removeTransaction\"\n\t},\n\tremoveTransaction: function() {\n\t\tApp.showDialog('RemoveTransaction', {\n\t\t\titem: this.item,\n\t\t\twallet: this.wallet\n\t\t});\n\t\treturn false;\n\t},\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\t\tif (typeof(params.wallet) != 'undefined')\n\t\t\tthis.wallet = params.wallet;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.wallet';\n\n\t\tthis.show({\n\t\t\titem: this.item.toJSON(),\n\t\t\twallet: this.wallet.toJSON()\n\t\t});\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tthis.hide();\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/dialogs/wallet_accesses.js",
    "content": "// wallet_accesses.js\nApp.Views.Dialogs.WalletAccesses = App.Views.Abstract.Dialog.extend({\n\n\tstatus: 'loading',\n\tdialogName: 'wallet_accesses',\n\tevents: {\n\t\t\"submit form\": \"onSubmit\",\n\t\t\"click .item_button_remove_access\": \"removeAccess\"\n\t},\n\tremoveAccess: function(ev) {\n\t\tvar data = $(ev.currentTarget).data();\n\t\tif (typeof(data.id) === 'undefined')\n\t\t\treturn true;\n\n\t\tvar id = parseInt(data.id, 10);\n\t\tvar access = this.accesses.get(id);\n\n\t\tif (!access)\n\t\t\treturn true;\n\n\t\tApp.showDialog('RemoveAccess', {\n\t\t\titem: this.item,\n\t\t\taccess: access\n\t\t});\n\n\t\treturn false;\n\t},\n\tinitialize: function(params) {\n\t\tif (typeof(params.item) != 'undefined')\n\t\t\tthis.item = params.item;\n\t\telse\n\t\t\tthrow 'Can not initialize dialog without param.item';\n\n\t\tthis.accesses = new App.Collections.WalletsAccesses();\n\t\tthis.accesses.setWalletId(this.item.id);\n\t\tthis.listenTo(this.accesses, 'sync', this.loaded);\n\n\t\tthis.accesses.fetch();\n\n\t\tvar that = this;\n\t\tthis.on('ready', function() {\n\t\t\tthat.$('#input_email').focus();\n\t\t});\n\t\tthis.show(this.data());\n\t},\n\tdata: function() {\n\t\tvar ret_accesses = [];\n\n\t\tif (this.accesses && this.accesses.length)\n\t\t\tfor (var i = 0; i < this.accesses.length; i++) {\n\t\t\t\tvar acc = this.accesses.at(i).toJSON();\n\t\t\t\tacc['gravatar'] = this.accesses.at(i).getGravatarURL();\n\t\t\t\tret_accesses.push(acc);\n\t\t\t}\n\t\treturn {\n\t\t\titem: this.item.toJSON(),\n\t\t\taccesses: ret_accesses,\n\t\t\tstatus: this.status\n\t\t}\n\t},\n\tloaded: function() {\n\t\tthis.status = 'ready';\n\t\tthis.render();\n\t},\n\trender: function() {\n\t\tthis.renderHTML(this.data());\n\t},\n\tonSubmit: function() {\n\t\tvar that = this;\n\n\t\tvar email = this.$('#input_email').val();\n\t\tif (!email)\n\t\t\treturn false;\n\n\t\tvar already = this.accesses.where({\n\t\t\tto_email: email\n\t\t});\n\t\tif (already && already.length) {\n\t\t\t$(\"#emails_with_access_\" + already[0].id).animate({\n\t\t\t\topacity: 0.5\n\t\t\t}, 500).animate({\n\t\t\t\topacity: 1\n\t\t\t}, 500);\n\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tvar access = new App.Models.WalletsAccess();\n\t\taccess.set('to_email', email);\n\t\taccess.set('wallet_id', this.item.id);\n\t\taccess.save();\n\t\tthis.accesses.add(access);\n\t\t//this.item.set('name', name);\n\t\t//this.item.save();\n\n\t\t//this.hide();\n\n\t\treturn false;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/header.js",
    "content": "// header.js\nApp.Views.Header = Backbone.View.extend({\n\n\tel: $(\"#header\"),\n\tevents: {},\n\n\trender: function() {\n\t\tthis.setElement($(\"#header\"));\n\t\tif (App.currentUser.isSignedIn()) {\n\t\t\tconsole.log('header.js | Rendering for signed in user');\n\n\t\t\tthis.$('.header_is_not_signed_in').hide();\n\t\t\tthis.$('.header_is_signed_in').show();\n\t\t} else {\n\t\t\tconsole.log('header.js | Rendering for not signed in user');\n\t\t\tthis.$('.header_is_not_signed_in').show();\n\t\t\tthis.$('.header_is_signed_in').hide();\n\t\t}\n\n\n\t\t$(\".menu_category\").parent().removeClass('active');\n\t\tif (typeof(App.page) !== 'undefined' && App.page && typeof(App.page.category) !== 'undefined') {\n\t\t\t$(\".menu_category_\" + App.page.category).parent().addClass('active');\n\t\t} else {\n\t\t\t$(\".menu_category_home\").parent().addClass('active');\n\t\t}\n\n\n\t\tconsole.log('header.js | Header rendered');\n\t\treturn this;\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/pages/404.js",
    "content": "// 404.js\nApp.Views.Pages.NotFound = App.Views.Abstract.Page.extend({\n\n\ttemplateName: '404',\n\ttitle: 'Nothing is found. 404',\n\trender: function() {\n\t\tthis.renderHTML();\n\t},\n\tinitialize: function(params) {\n\t\tthis.render();\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/import_xls.js",
    "content": "// import_xls.js\nApp.Views.Pages.ImportXLS = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/import/xls',\n\tadditionalScripts: [\n\t\t'/vendors/js-xlsx/dist/xlsx.min.js',\n\t\t'/vendors/moment/min/moment.min.js'\n\t],\n\tcategory: 'wallets',\n\tevents: {\n\t\t'change #file_input': 'fileInputChanged',\n\t\t'change .import_row_type': 'checkRowsToImport',\n\t\t'click .select_file_button': 'selectFile',\n\t\t'click #proccess_step1_button': 'goToPreview',\n\t\t'click #proccess_step2_cancel': 'goToFirstStep',\n\t\t'click #proccess_step2_button': 'goToImport'\n\t},\n\tworksheet: null,\n\tsample: null,\n\tsampleWidth: null,\n\tsampleHeight: null,\n\timportPreview: null,\n\tstep: 1,\n\tselectedFields: {\n\t\tdate: false,\n\t\ttime: false,\n\t\tdescription: false,\n\t\tamount: false,\n\t\tabs_amount: false\n\t},\n\tselectedTimeFormat: false,\n\tselectedDateFormat: false,\n\tdateFormats: [\n\t\t'DD.MM.YYYY',\n\t\t'MM.DD.YYYY',\n\t\t'DD-MM-YYYY',\n\t\t'MM-DD-YYYY',\n\t\t'YYYY-MM-DD',\n\t\t'YYYY-DD-MM',\n\t\t'YYYY.MM.DD',\n\t\t'YYYY.DD.MM'\n\t],\n\ttimeFormats: [\n\t\t'H:m',\n\t\t'h:m a'\n\t],\n\ttitle: function() {\n\t\treturn 'Import';\n\t},\n\tselectFile: function() {\n\t\tthis.$('#file_input').click();\n\t},\n\tgoToFirstStep: function() {\n\t\tthis.step = 1;\n\t\tthis.render();\n\t},\n\tgoToPreview: function() {\n\t\tthis.step = 2;\n\t\tthis.render();\n\t},\n\tgoToImport: function() {\n\t\tthis.step = 3;\n\t\tthis.render();\n\t\tthis.import();\n\t},\n\trender: function() {\n\t\tthis.renderHTML({\n\t\t\tsample: this.sample,\n\t\t\tsampleHeight: this.sampleHeight,\n\t\t\tsampleWidth: this.sampleWidth,\n\t\t\tdateFormats: this.dateFormats,\n\t\t\ttimeFormats: this.timeFormats,\n\t\t\timportPreview: this.importPreview,\n\t\t\tstep: this.step,\n\t\t\tselectedFields: this.selectedFields,\n\t\t\twallet_id: this.model.id\n\t\t});\n\t},\n\twakeUp: function() {\n\t\tthis.holderReady = false;\n\t\tthis.render();\n\t},\n\talreadyImportedRowN: 0,\n\talreadyGotDataRowN: 0,\n\trowToImportCount: 0,\n\tminImportedRowDate: null,\n\tmaxImportedRowDate: null,\n\trowsToImport: [],\n\timport: function() {\n\t\tthis.alreadyImportedRowN = 0;\n\t\tthis.rowsToImport = [];\n\t\tthis.alreadyGotDataRowN = 0;\n\t\tthis.rowToImportCount = this.worksheet['!range'].e.r;\n\t\tvar that = this;\n\t\tsetTimeout(function() {\n\t\t\tthat.getNextRowData();\n\t\t}, 100);\n\t},\n\tgetNextRowData: function() {\n\t\tvar that = this;\n\n\t\tthis.alreadyGotDataRowN++;\n\n\t\tvar date = null;\n\t\tvar description = null;\n\t\tvar amount = null;\n\n\t\t/// date\n\t\tvar date_format = this.selectedDateFormat;\n\t\tvar time_format = this.selectedTimeFormat;\n\t\tif (this.selectedFields.date) {\n\t\t\tvar txt_date = that.getValueForCell(this.selectedFields.date, this.alreadyGotDataRowN);\n\t\t\tif (this.selectedFields.time && this.selectedFields.time != this.selectedFields.date)\n\t\t\t\ttxt_date += ' ' + that.getValueForCell(this.selectedFields.time, this.alreadyGotDataRowN);\n\t\t\tdate_format += ' ' + time_format;\n\n\t\t\tvar parsed = moment(txt_date, date_format);\n\n\t\t\tif (parsed.isValid()) {\n\t\t\t\tdate = parsed.unix();\n\t\t\t\tif (!this.minImportedRowDate || date < this.minImportedRowDate)\n\t\t\t\t\tthis.minImportedRowDate = date;\n\t\t\t\tif (!this.maxImportedRowDate || date < this.maxImportedRowDate)\n\t\t\t\t\tthis.maxImportedRowDate = date;\n\t\t\t}\n\t\t}\n\n\t\t/// description\n\t\tif (this.selectedFields.description) {\n\t\t\tvar value = that.getValueForCell(this.selectedFields.description, this.alreadyGotDataRowN);\n\t\t\tvalue = value.replace(/<\\/?[^>]+(>|$)/g, \"\");\n\t\t\tvalue = value.substring(0, 250);\n\t\t\tif (value)\n\t\t\t\tdescription = value;\n\t\t}\n\n\t\t/// amount\n\t\tif (this.selectedFields.amount) {\n\t\t\tvar value = that.getValueForCell(this.selectedFields.amount, this.alreadyGotDataRowN);\n\t\t\tvalue = parseFloat(value, 10);\n\t\t\tif (!isNaN(value))\n\t\t\t\tamount = value;\n\t\t}\n\t\tif (this.selectedFields.abs_amount) {\n\t\t\tvar value = that.getValueForCell(this.selectedFields.amount, this.alreadyGotDataRowN);\n\t\t\tvalue = Math.abs(parseFloat(value, 10));\n\t\t\tif (!isNaN(value))\n\t\t\t\tamount = -value;\n\t\t}\n\n\t\tif (amount !== null && date !== null)\n\t\t\tthis.rowsToImport.push({\n\t\t\t\tamount: amount,\n\t\t\t\tdatetime: date,\n\t\t\t\tdescription: description\n\t\t\t});\n\n\t\tvar progress = Math.floor((this.alreadyGotDataRowN / this.rowToImportCount) * 100 / 2);\n\t\tthis.$('#import_progress_bar').css('width', progress + '%');\n\n\t\tif (this.alreadyGotDataRowN < this.rowToImportCount) {\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.getNextRowData();\n\t\t\t}, 100);\n\t\t} else {\n\t\t\tthis.rowToImportCount = this.rowsToImport.length;\n\t\t\tsetTimeout(function() {\n\t\t\t\tthat.getTransactionsToCheckForDuplicates();\n\t\t\t}, 100);\n\t\t}\n\t},\n\ttrasactionsToCheckForDuplicates: [],\n\tgetTransactionsToCheckForDuplicates: function() {\n\t\tvar that = this;\n\t\tthis.trasactionsToCheckForDuplicates = [];\n\t\tvar minDate = new Date(this.minImportedRowDate * 1000);\n\t\tvar maxDate = new Date(this.maxImportedRowDate * 1000);\n\t\tvar minMonth = minDate.getMonth() + 1;\n\t\tvar minYear = minDate.getFullYear();\n\t\tvar maxMonth = maxDate.getMonth() + 1;\n\t\tvar maxYear = maxDate.getFullYear();\n\n\t\tvar curMonth = minMonth;\n\t\tvar curYear = minYear;\n\t\tdo {\n\t\t\tvar transactions = new App.Collections.Transactions();\n\t\t\ttransactions.setPeriod(curMonth, curYear);\n\t\t\ttransactions.setWalletId(this.model.id);\n\n\t\t\tthis.trasactionsToCheckForDuplicates.push(transactions);\n\t\t\tif (curMonth == 12) {\n\t\t\t\tcurMonth = 1;\n\t\t\t\tcurYear++;\n\t\t\t} else {\n\t\t\t\tcurMonth++;\n\t\t\t}\n\t\t} while ((curMonth <= maxMonth && curYear == maxYear) || curYear < maxYear);\n\n\t\tvar promises = [];\n\t\tfor (var k in this.trasactionsToCheckForDuplicates)\n\t\t\tpromises.push(this.trasactionsToCheckForDuplicates[k].fetch());\n\n\t\t$.when.apply($, promises).done(function() {\n\t\t\tthat.importNextRow();\n\t\t});\n\t},\n\tcheckIfNoDuplicates: function(row) {\n\t\tfor (var k in this.trasactionsToCheckForDuplicates)\n\t\t\tfor (var i = 0; i < this.trasactionsToCheckForDuplicates[k].length; i++) {\n\t\t\t\tvar transaction = this.trasactionsToCheckForDuplicates[k].models[i];\n\t\t\t\tif (transaction.get('amount') == row.amount &&\n\t\t\t\t\ttransaction.get('datetime') == row.datetime &&\n\t\t\t\t\ttransaction.get('description') == row.description)\n\t\t\t\t\treturn false;\n\t\t\t};\n\n\t\treturn true;\n\t},\n\timportNextRow: function() {\n\t\tvar that = this;\n\n\t\tvar row = this.rowsToImport[this.alreadyImportedRowN];\n\t\tthis.alreadyImportedRowN++;\n\n\t\tvar onNext = function() {\n\n\t\t\tvar progress = 50 + Math.floor((that.alreadyImportedRowN / that.rowToImportCount) * 100 / 2);\n\t\t\tthat.$('#import_progress_bar').css('width', progress + '%');\n\n\t\t\tif (that.alreadyImportedRowN < that.rowToImportCount) {\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tthat.importNextRow();\n\t\t\t\t}, 100);\n\t\t\t} else {\n\t\t\t\tthat.step = 4;\n\t\t\t\tthat.render();\n\t\t\t}\n\t\t}\n\n\t\tif (row && this.checkIfNoDuplicates(row)) {\n\t\t\tvar transaction = new App.Models.Transaction();\n\t\t\ttransaction.set('amount', row.amount);\n\t\t\ttransaction.set('description', row.description);\n\t\t\ttransaction.set('datetime', row.datetime);\n\t\t\ttransaction.set('wallet_id', this.model.id);\n\n\t\t\ttransaction.save().then(function() {\n\t\t\t\tonNext();\n\t\t\t});\n\t\t} else {\n\t\t\tonNext();\n\t\t}\n\n\t},\n\tcheckRowsToImport: function() {\n\t\tvar x = 1;\n\t\tvar y = 1;\n\t\tvar height = this.worksheet['!range'].e.r;\n\t\tvar badToImport = [];\n\t\tvar that = this;\n\n\t\tvar date_column_x = false;\n\t\tvar time_column_x = false;\n\n\t\tvar has_date = false;\n\t\tvar has_amount = false;\n\n\t\tvar importPreview = {};\n\n\n\t\t$('.import_row_date_format').hide();\n\t\t$('.import_row_time_format').hide();\n\n\t\t$('.import_row_type').each(function() {\n\t\t\tvar type = $(this).val();\n\n\t\t\tif (type == 'date')\n\t\t\t\t$('#import_row_' + x + '_date_format').show();\n\n\t\t\tif (type == 'time')\n\t\t\t\t$('#import_row_' + x + '_time_format').show();\n\n\t\t\tfor (y = 1; y < height; y++) {\n\t\t\t\tvar value = that.getValueForCell(x, y);\n\t\t\t\tif (type == 'amount') {\n\t\t\t\t\tif (isNaN(parseFloat(value))) badToImport.push(y);\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (typeof(importPreview[y]) == 'undefined') importPreview[y] = {};\n\t\t\t\t\t\timportPreview[y]['amount'] = value;\n\t\t\t\t\t\thas_amount = true;\n\n\t\t\t\t\t\tthat.selectedFields.amount = x;\n\t\t\t\t\t}\n\t\t\t\t} else if (type == 'abs_amount') {\n\t\t\t\t\tif (isNaN(parseFloat(value)) || value < 0) badToImport.push(y);\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (typeof(importPreview[y]) == 'undefined') importPreview[y] = {};\n\t\t\t\t\t\timportPreview[y]['amount'] = -parseFloat(value);\n\t\t\t\t\t\thas_amount = true;\n\n\t\t\t\t\t\tthat.selectedFields.abs_amount = x;\n\t\t\t\t\t}\n\t\t\t\t} else if (type == 'description') {\n\t\t\t\t\tif (typeof(importPreview[y]) == 'undefined') importPreview[y] = {};\n\t\t\t\t\timportPreview[y]['description'] = value;\n\t\t\t\t\tthat.selectedFields.description = x;\n\t\t\t\t} else if (type == 'date') {\n\t\t\t\t\tdate_column_x = x;\n\t\t\t\t\tthat.selectedFields.date = x;\n\t\t\t\t\tthat.selectedDateFormat = that.$('#import_row_' + x + '_date_format').val();\n\t\t\t\t} else if (type == 'time') {\n\t\t\t\t\ttime_column_x = x;\n\t\t\t\t\tthat.selectedFields.time = x;\n\t\t\t\t\tthat.selectedTimeFormat = that.$('#import_row_' + x + '_time_format').val();\n\t\t\t\t} else if (type == 'datetime') {\n\t\t\t\t\tdate_column_x = x;\n\t\t\t\t\ttime_column_x = x;\n\t\t\t\t\tthat.selectedFields.datetime = x;\n\t\t\t\t\tthat.selectedDateFormat = that.$('#import_row_' + x + '_date_format').val();\n\t\t\t\t\tthat.selectedTimeFormat = that.$('#import_row_' + x + '_time_format').val();\n\t\t\t\t}\n\t\t\t}\n\t\t\tx++;\n\t\t});\n\n\t\tvar date_format = this.selectedDateFormat;\n\t\tvar time_format = this.selectedTimeFormat;\n\t\tif (date_column_x)\n\t\t\tfor (y = 1; y < height; y++) {\n\t\t\t\tvar date = that.getValueForCell(date_column_x, y);\n\t\t\t\tif (time_column_x && time_column_x != date_column_x) {\n\t\t\t\t\tdate += ' ' + that.getValueForCell(time_column_x, y);\n\t\t\t\t\tdate_format += ' ' + time_format;\n\t\t\t\t}\n\n\t\t\t\tvar parsed = moment(date, date_format);\n\n\t\t\t\tif (!parsed.isValid())\n\t\t\t\t\tbadToImport.push(y);\n\t\t\t\telse {\n\t\t\t\t\tif (typeof(importPreview[y]) == 'undefined') importPreview[y] = {};\n\t\t\t\t\timportPreview[y]['date'] = parsed.unix();\n\t\t\t\t\thas_date = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\tthis.importPreview = null;\n\t\tfor (var k in importPreview) {\n\t\t\tif (typeof(importPreview[k]['date']) != 'undefined' && typeof(importPreview[k]['amount']) != 'undefined')\n\t\t\t\tif (!this.importPreview || this.importPreview.length < 10) {\n\t\t\t\t\tif (!this.importPreview)\n\t\t\t\t\t\tthis.importPreview = [];\n\t\t\t\t\tthis.importPreview.push(importPreview[k]);\n\t\t\t\t}\n\t\t}\n\n\t\t$('.sample_import_row').addClass('info');\n\t\tbadToImport.forEach(function(y) {\n\t\t\t$('#sample_import_row_' + y).removeClass('info');\n\t\t});\n\n\t\tif (has_date && has_amount) {\n\t\t\tthis.$('#proccess_step1_warning').hide();\n\t\t\tthis.$('#proccess_step1_button').prop('disabled', false);\n\t\t} else {\n\t\t\tthis.$('#proccess_step1_warning').show();\n\t\t\tthis.$('#proccess_step1_button').prop('disabled', 'disabled');\n\t\t}\n\t},\n\tgetValueForCell: function(x, y) {\n\t\tvar cell = this.worksheet[String.fromCharCode(64 + x) + y];\n\t\tif (typeof(cell) == 'undefined')\n\t\t\treturn '';\n\t\telse\n\t\t\treturn cell.v;\n\t},\n\tnewData: function(workbook) {\n\t\tvar first_sheet_name = workbook.SheetNames[0];\n\t\tthis.worksheet = workbook.Sheets[first_sheet_name];\n\n\t\tvar width = this.worksheet['!range'].e.c;\n\t\tvar height = this.worksheet['!range'].e.r;\n\t\tvar skip_line_from = 3;\n\t\tvar skip_line_to = height - 4;\n\t\tvar skiped_count = height - 6;\n\n\t\tvar sample = [];\n\t\tfor (var y = 1; y < height; y++) {\n\t\t\tif (height > 6 && y > skip_line_from && y < skip_line_to) {\n\t\t\t\ty = skip_line_to;\n\t\t\t\tsample.push({\n\t\t\t\t\tskiped: skiped_count\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tvar line = [];\n\t\t\t\tfor (var x = 1; x <= width; x++) {\n\t\t\t\t\tvar value = this.getValueForCell(x, y);\n\t\t\t\t\tline.push(value);\n\t\t\t\t}\n\t\t\t\tsample.push({\n\t\t\t\t\titems: line,\n\t\t\t\t\ty: y\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tthis.sample = sample;\n\n\t\tthis.sampleWidth = width;\n\t\tthis.sampleHeight = height;\n\t\tthis.render();\n\t},\n\tfileInputChanged: function(e) {\n\t\tthis.$('.select_file_button').button('loading');\n\t\tif (typeof(e.target.files) !== 'undefined' && e.target.files.length > 0)\n\t\t\tthis.fileChanged(e.target.files[0]);\n\t},\n\tfileChanged: function(file) {\n\t\tvar reader = new FileReader();\n\t\tvar that = this;\n\n\t\tthat.$('.alert', '#step_1').hide();\n\t\treader.onload = function(e) {\n\t\t\tvar data = e.target.result;\n\t\t\tvar workbook = null;\n\t\t\ttry {\n\t\t\t\tworkbook = XLSX.read(data, {\n\t\t\t\t\ttype: 'binary'\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tthat.$('.alert', '#step_1').show();\n\t\t\t}\n\n\t\t\tif (workbook)\n\t\t\t\tthat.newData(workbook);\n\n\t\t\tthat.$('.select_file_button').button('reset');\n\t\t}\n\t\treader.readAsBinaryString(file);\n\t},\n\tinitialize: function(params) {\n\t\tthis.renderLoading();\n\t\tvar that = this;\n\t\tApp.helper.loadAdditionalScripts(this.additionalScripts, function() {\n\n\t\t\tif (typeof(params.wallet_id) !== 'undefined') {\n\t\t\t\tthat.model = new App.Models.Wallet();\n\t\t\t\tthat.model.id = params.wallet_id;\n\n\t\t\t\tthat.model.fetch({\n\t\t\t\t\tsuccess: function() {\n\t\t\t\t\t\tthat.render();\n\t\t\t\t\t},\n\t\t\t\t\terror: function() {\n\t\t\t\t\t\tApp.showPage('NotFound');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else\n\t\t\t\tthrow 'wallet_id parameter required';\n\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/index.js",
    "content": "// index.js\nApp.Views.Pages.Index = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/index/index',\n\tcategory: 'home',\n\tevents: {\n\t\t\"click #demo_signup\": \"demoSignUp\",\n\t\t\"click #demo_without_mouse_signup\": \"demoSignUp\"\n\t},\n\tdemoSignUp: function() {\n\t\tApp.log.event('registration', 'Demo Sign Up', 'From Homepage');\n\t\tthis.renderLoading();\n\t\tApp.createCookie('show_tour_Wallets', 1);\n\t\tApp.createCookie('show_tour_Wallet', 1);\n\t\tApp.currentUser.demoRegister();\n\t},\n\ttitle: function() {\n\t\treturn 'Homepage';\n\t},\n\trender: function() {\n\t\tthis.renderHTML({});\n\t},\n\twakeUp: function() {\n\t\tif (typeof(App.currentUser) !== 'undefined' && App.currentUser && App.currentUser.isSignedIn())\n\t\t\tApp.router.redirect('/wallets/');\n\t\telse {\n\t\t\tthis.holderReady = false;\n\n\t\t\tvar that = this;\n\t\t\tthis.on('render', function() {\n\t\t\t\tthat.resize();\n\t\t\t\t$(window).on('resize', that.resize);\n\t\t\t});\n\t\t\tthis.render();\n\t\t}\n\t},\n\tsleep: function() {\n\t\t$(window).off('resize');\n\t},\n\tresize: function() {\n\t\tif (typeof(App.page.__resizeThrottled) === 'undefined') {\n\t\t\tApp.page.__resizeThrottled = _.throttle(function() {\n\t\t\t\tvar footerOffset = $(window).height() - $('#footer').height() - 20;\n\t\t\t\tvar rulerOffset = $('#screenshots_header_ruler').offset().top;\n\t\t\t\tif ($(window).width() >= 992 && footerOffset > rulerOffset + 190) {\n\t\t\t\t\tvar margin = footerOffset - (rulerOffset + 190);\n\t\t\t\t\t$('#screenshots_header').css('margin-top', margin + 'px');\n\t\t\t\t} else {\n\t\t\t\t\t$('#screenshots_header').css('margin-top', '20px');\n\t\t\t\t}\n\t\t\t}, 100);\n\t\t}\n\n\t\tApp.page.__resizeThrottled();\n\t},\n\tinitialize: function() {\n\t\tvar that = this;\n\t\tif (typeof(App.currentUser) !== 'undefined' && App.currentUser && App.currentUser.isSignedIn())\n\t\t\treturn App.router.redirect('/wallets/');\n\t\tthis.renderLoading();\n\t\t/// initialize models, collections etc. Request fetching from storage\n\n\t\tthis.listenTo(App.currentUser, 'signedInStatusChanged', function() {\n\t\t\tApp.router.redirect('/wallets/');\n\t\t});\n\n\t\tthis.on('render', function() {\n\t\t\t$('#demo_signup').clickonmouseover();\n\t\t\t$('.image-link').magnificPopup({\n\t\t\t\ttype: 'image',\n\t\t\t\tgallery: {\n\t\t\t\t\tenabled: true\n\t\t\t\t},\n\t\t\t\tcallbacks: {\n\t\t\t\t\topen: function() {\n\t\t\t\t\t\tApp.log.event('homepage', 'Zoom Screenshot');\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\timage: {\n\t\t\t\t\ttitleSrc: function(item) {\n\t\t\t\t\t\treturn $('#' + item.el.attr('id') + '-title').text() + '<small>' + $('#' + item.el.attr('id') + '-description').text() + '</small>';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthat.resize();\n\t\t\t$(window).on('resize', that.resize);\n\n\t\t\tif ('ontouchstart' in window || 'onmsgesturechange' in window) {\n\t\t\t\t//// touch device\n\t\t\t\t$('.register_without_mouse').fadeIn('slow');\n\t\t\t} else {\n\t\t\t\t//// pc\n\t\t\t\t$('.register_with_mouse').fadeIn('slow');\n\t\t\t}\n\t\t});\n\n\t\tthis.render();\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/plan.js",
    "content": "// plan.js\nApp.Views.Pages.Plan = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/plans/view',\n\tcategory: 'plan',\n\tevents: {\n\t\t\"click #reload_stats_button\": 'reloadStats'\n\t},\n\ttitle: function() {\n\t\treturn 'Plan report';\n\t},\n\turl: function() {\n\t\tif (typeof(this.model) != 'undefined' && this.model.id)\n\t\t\treturn 'plans/' + this.model.id;\n\t},\n\trender: function() {\n\t\tconsole.log('views/pages/plan.js | rendering');\n\n\t\tthis.once('render', function() {\n\t\t});\n\n\t\tthis.renderHTML({\n\t\t\tplan: this.model.toJSON(),\n\t\t\tstats: this.model.stats,\n\t\t\tcurrentTimestamp: (new Date().getTime() / 1000),\n\t\t\tadviceData: this.getAdviceData()\n\t\t});\n\t},\n\treloadStats: function() {\n\t\tvar that = this;\n\t\tthis.$('#reload_stats_button').button('loading');\n\t\tthis.listenToOnce(this.model, 'statsready', function() {\n\t\t\tthat.$('#reload_stats_button').button('reset');\n\n\t\t});\n\t\tthis.model.reloadStats();\n\n\t\treturn false;\n\t},\n\tgetAdviceData: function() {\n\t\tvar hasToday = false;\n\t\tvar hasTomorrow = false;\n\t\tvar hasFuture = false;\n\t\tvar currentTimestamp = (new Date().getTime() / 1000);\n\t\tvar todayI = null;\n\t\tvar todaysPlan = 0;\n\t\tvar todaysAlreadyTotal = 0;\n\t\tvar todaysDif = 0;\n\t\tvar tomorrowPlan = 0;\n\t\tvar futureMaxPlan = 0;\n\t\tvar futureEndDate = null;\n\n\t\tfor (var i = 0; i < this.model.stats.length; i++) {\n\t\t\tif (this.model.stats[i].date.unix_from < currentTimestamp && this.model.stats[i].date.unix_to > currentTimestamp) {\n\t\t\t\thasToday = true;\n\t\t\t\ttodayI = i;\n\t\t\t\tif (i < this.model.stats.length - 1) {\n\t\t\t\t\thasTomorrow = true;\n\t\t\t\t}\n\t\t\t\tif (i < this.model.stats.length - 2) {\n\t\t\t\t\thasFuture = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (hasToday) {\n\t\t\ttodaysPlan = this.model.stats[todayI].allowedToSpend;\n\t\t\ttodaysAlreadyTotal = this.model.stats[todayI].profitsTotal - this.model.stats[todayI].expensesTotal;\n\t\t\tif (hasTomorrow) {\n\t\t\t\ttomorrowPlan = this.model.stats[todayI+1].allowedToSpend;\n\t\t\t\tif (hasFuture) {\n\t\t\t\t\tfutureMaxPlan = this.model.stats[this.model.stats.length - 1].allowedToSpend; \n\t\t\t\t\tfutureEndDate = this.model.stats[this.model.stats.length - 1].date.unix;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttodaysDif = todaysPlan - todaysAlreadyTotal;\n\t\t\t}\n\t\t}\n\n\n\t\treturn {\n\t\t\thasToday: hasToday,\n\t\t\thasTomorrow: hasTomorrow,\n\t\t\thasFuture: hasFuture,\n\t\t\ttodaysPlan: todaysPlan,\n\t\t\ttodaysAlreadyTotal: todaysAlreadyTotal,\n\t\t\ttodaysDif: todaysDif,\n\t\t\ttomorrowPlan: tomorrowPlan,\n\t\t\tfutureMaxPlan: futureMaxPlan,\n\t\t\tfutureEndDate: futureEndDate\n\t\t};\n\t},\n\twakeUp: function() {\n\t\tconsole.log('views/pages/plan.js | waking up');\n\t\tthis.holderReady = false;\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tvar plan_id = that.model.id;\n\t\t\tthat.model = new App.Models.Plan();\n\t\t\tthat.model.id = plan_id;\n\n\t\t\tthat.model.fetch({\n\t\t\t\terror: function() {\n\t\t\t\t\tApp.showPage('NotFound');\n\t\t\t\t}\n\t\t\t}).done(function() {\n\t\t\t\tApp.exchange.loadRates(function() {\n\t\t\t\t\tthat.listenTo(that.model, 'statsready', that.render);\n\t\t\t\t\tthat.model.getStats();\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t},\n\tinitialize: function(params) {\n\t\tconsole.log('views/pages/plan.js | initializing');\n\t\tthis.renderLoading();\n\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\t/// initialize models, collections etc. Request fetching from storage\n\t\t\tif (typeof(params.item) !== 'undefined') {\n\t\t\t\tthat.model = params.item;\n\t\t\t\tthat.render();\n\t\t\t} else if (typeof(params.id) !== 'undefined') {\n\t\t\t\tthat.model = new App.Models.Plan();\n\t\t\t\tthat.model.id = params.id;\n\n\t\t\t\tthat.model.fetch({\n\t\t\t\t\terror: function() {\n\t\t\t\t\t\tApp.showPage('NotFound');\n\t\t\t\t\t}\n\t\t\t\t}).done(function() {\n\t\t\t\t\tApp.exchange.loadRates(function() {\n\t\t\t\t\t\tthat.listenTo(that.model, 'statsready', that.render);\n\t\t\t\t\t\tthat.model.getStats();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} else\n\t\t\t\tthrow 'id or item parameters required';\n\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/plans.js",
    "content": "// plans.js\nApp.Views.Pages.Plans = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/plans/index',\n\tcategory: 'plans',\n\tadditionalScripts: [\n\t\t'/vendors/moment/min/moment.min.js',\n\t\t'/vendors/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js'\n\t],\n\tevents: {\n\t\t\"click #button_create_new\": \"addNew\",\n\t\t\"click #button_step1_next\": \"step1Next\",\n\t\t\"click #button_step1_back\": \"step1Back\",\n\t\t\"click #button_step2_back\": \"step2Back\",\n\t\t\"click .step1_wallet_checkbox\": \"step1WalletChangeChecked\",\n\t\t\"click .edit_plan_button\": \"editPlan\",\n\t\t\"dp.change .datetimepicker\": \"dateChanged\",\n\t\t\"change #input_goal_balance\": \"goalBalanceChanged\",\n\t\t\"keyup #input_goal_balance\": \"goalBalanceChanged\",\n\t\t\"change #input_start_currency\": \"recalculateStartCurrency\",\n\t\t\"change #input_goal_currency\": \"recalculateGoalCurrency\",\n\t\t\"click #set_goal_to_start\": \"setGoalCurrencyToStart\",\n\t\t\"click #button_step2_save\": \"doSave\",\n\t\t\"click .remove_plan_button\": \"removePlan\"\n\t},\n\ttitle: function() {\n\t\treturn 'Plan your expenses';\n\t},\n\turl: function() {\n\t\treturn 'plans';\n\t},\n\tpreparedData: {},\n\tisNew: false,\n\tremovePlan: function(ev) {\n\t\tvar target = $(ev.currentTarget);\n\t\tvar plan_id = target.data('id');\n\n\t\tApp.showDialog('RemovePlan', {\n\t\t\titem: this.plans.get(plan_id)\n\t\t});\n\n\t\treturn false;\n\n\t},\n\taddNew: function() {\n\t\tthis.step = 1;\n\t\tthis.preparedData = {\n\t\t\tstart_datetime: (Date.now() / 1000 | 0),\n\t\t\tgoal_datetime: (Date.now() / 1000 | 0) + 24 * 60 * 60,\n\t\t\tstart_balance: 0,\n\t\t\tgoal_balance: 0,\n\t\t\tstart_currency: null,\n\t\t\tgoal_currency: null,\n\t\t\tname: 'Undefined'\n\t\t};\n\t\t// this.preparedData['start_datetime'] = (Date.now() / 1000 | 0);\n\t\t// this.preparedData['goal_datetime'] = (Date.now() / 1000 | 0) + 24 * 60 * 60;\n\t\t// this.preparedData['start_balance'] = 0;\n\t\t// this.preparedData['goal_balance'] = 0;\n\t\t// this.preparedData['start_currency'] = null;\n\t\t// this.preparedData['goal_currency'] = null;\n\t\t// this.preparedData['name'] = 'Undefined';\n\n\t\tthis.isNew = true;\n\n\t\tthis.render();\n\t},\n\teditPlan: function(ev) {\n\t\tvar target = $(ev.currentTarget);\n\t\tvar plan_id = target.data('id');\n\n\t\tvar plan = this.plans.get(plan_id);\n\n\t\tthis.preparedData = {\n\t\t\tstart_datetime: plan.get('start_datetime'),\n\t\t\tgoal_datetime: plan.get('goal_datetime'),\n\t\t\tstart_balance: plan.get('start_balance'),\n\t\t\tgoal_balance: plan.get('goal_balance'),\n\t\t\tstart_currency: plan.get('start_currency'),\n\t\t\tgoal_currency: plan.get('goal_currency'),\n\t\t\tname: plan.get('name'),\n\t\t\tid: plan.id\n\t\t};\n\n\t\tthis.preparedData.wallets = [];\n\t\tvar planWallets = plan.get('wallets');\n\t\tfor (var k in planWallets)\n\t\t\tthis.preparedData.wallets.push(planWallets[k].id);\n\n\t\tthis.isNew = false;\n\t\tthis.step = 1;\n\t\tthis.render();\n\t},\n\tdoSave: function() {\n\t\tif (this.isNew) {\n\n\t\t\tthis.preparedData['start_balance'] = App.exchange.convert(this.preparedData['start_balance'], this.preparedData['start_currency'], this.preparedData['goal_currency']);\n\t\t\tthis.preparedData['start_currency'] = this.preparedData['goal_currency'];\n\n\t\t\tvar plan = new App.Models.Plan();\n\t\t\tplan.set('name', this.preparedData['name']);\n\t\t\tplan.set('start_datetime', this.preparedData['start_datetime']);\n\t\t\tplan.set('start_currency', this.preparedData['start_currency']);\n\t\t\tplan.set('start_balance', this.preparedData['start_balance']);\n\t\t\tplan.set('goal_datetime', this.preparedData['goal_datetime']);\n\t\t\tplan.set('goal_currency', this.preparedData['goal_currency']);\n\t\t\tplan.set('goal_balance', this.preparedData['goal_balance']);\n\n\t\t\tplan.set('wallets', this.preparedData['wallets']);\n\n\t\t\tthis.listenToOnce(plan, 'sync', function() {\n\t\t\t\tApp.router.redirect('plans/' + plan.id);\n\t\t\t});\n\t\t\tplan.save();\n\n\t\t\tthis.plans.add(plan);\n\t\t} else {\n\t\t\tvar plan = this.plans.get(this.preparedData['id']);\n\t\t\tplan.set('name', this.preparedData['name']);\n\t\t\t// plan.set('start_datetime', this.preparedData['start_datetime']);\n\t\t\t// plan.set('start_currency', this.preparedData['start_currency']);\n\t\t\t// plan.set('start_balance', this.preparedData['start_balance']);\n\t\t\tplan.set('goal_datetime', this.preparedData['goal_datetime']);\n\t\t\tplan.set('goal_currency', this.preparedData['goal_currency']);\n\t\t\tplan.set('goal_balance', this.preparedData['goal_balance']);\n\n\t\t\tplan.set('wallets', this.preparedData['wallets']);\n\n\t\t\tApp.localStorage.remove('plan_' + plan.id + '_data');\n\t\t\tthis.listenToOnce(plan, 'sync', function() {\n\t\t\t\tApp.router.redirect('plans/' + plan.id);\n\t\t\t});\n\t\t\tplan.save();\n\t\t}\n\n\t\tthis.step = 0;\n\t},\n\tdateChanged: function(ev) {\n\t\tthis.preparedData['goal_datetime'] = ev.date.unix();\n\n\t\tthis.recalculatePreview();\n\t},\n\tgoalBalanceChanged: function(ev) {\n\t\tvar val = parseFloat($(ev.currentTarget).val(), 10);\n\t\tthis.preparedData['goal_balance'] = val;\n\n\t\tthis.recalculatePreview();\n\t},\n\tsetGoalCurrencyToStart: function() {\n\t\tthis.preparedData['goal_currency'] = this.preparedData['start_currency'];\n\t\tthis.$('#input_goal_currency').val(this.preparedData['goal_currency']);\n\n\t\tthis.recalculatePreview();\n\t\tthis.recalculateStartBalance();\n\t},\n\trecalculateGoalCurrency: function() {\n\t\tvar newCurrency = this.$('#input_goal_currency').val();\n\t\tthis.preparedData['goal_currency'] = newCurrency;\n\n\t\tthis.recalculatePreview();\n\t\tthis.recalculateStartBalance();\n\t},\n\trecalculateStartBalance: function() {\n\t\tvar balance = this.preparedData['start_balance'];\n\t\tvar decimal = App.templateManager.modifiers.decimal(balance);\n\t\tvar rational = App.templateManager.modifiers.rational(balance);\n\n\t\t$('#cb_decimal').text(decimal);\n\t\t$('#cb_rational').text(rational);\n\n\t\t$('#cb_c_other').text(this.preparedData['start_currency']);\n\t\tif (balance < 0)\n\t\t\t$('#cb_minus').show();\n\t\telse\n\t\t\t$('#cb_minus').hide();\n\n\t\tif (this.preparedData['start_currency'] == 'USD') {\n\t\t\t$('#cb_c_other').hide();\n\t\t\t$('#cb_c_dollar').show();\n\t\t} else {\n\t\t\t$('#cb_c_other').show();\n\t\t\t$('#cb_c_dollar').hide();\n\t\t}\n\n\t\tif (this.preparedData['start_currency'] != this.preparedData['goal_currency']) {\n\t\t\t$('#set_goal_to_start').show();\n\t\t\t$('#set_goal_to_start_c').text(this.preparedData['start_currency']); // @todo: currency name, not code\n\n\t\t\tvar o_balance = App.exchange.convert(this.preparedData['start_balance'], this.preparedData['start_currency'], this.preparedData['goal_currency']);\n\n\t\t\tvar o_decimal = App.templateManager.modifiers.decimal(o_balance);\n\t\t\tvar o_rational = App.templateManager.modifiers.rational(o_balance);\n\n\t\t\t$('#cb_o_decimal').text(o_decimal);\n\t\t\t$('#cb_o_rational').text(o_rational);\n\n\t\t\t$('#cb_o_c_other').text(this.preparedData['goal_currency']);\n\t\t\tif (o_balance < 0)\n\t\t\t\t$('#cb_o_minus').show();\n\t\t\telse\n\t\t\t\t$('#cb_o_minus').hide();\n\n\t\t\tif (this.preparedData['goal_currency'] == 'USD') {\n\t\t\t\t$('#cb_o_c_other').hide();\n\t\t\t\t$('#cb_o_c_dollar').show();\n\t\t\t} else {\n\t\t\t\t$('#cb_o_c_other').show();\n\t\t\t\t$('#cb_o_c_dollar').hide();\n\t\t\t}\n\n\t\t\t$('#cb_o').show();\n\t\t} else {\n\t\t\t$('#cb_o').hide();\n\t\t\t$('#set_goal_to_start').hide();\n\t\t}\n\t},\n\trecalculatePreview: function() {\n\t\tvar diff = this.preparedData['goal_balance'] - App.exchange.convert(this.preparedData['start_balance'], this.preparedData['start_currency'], this.preparedData['goal_currency']);\n\t\tvar decimal = App.templateManager.modifiers.decimal(diff);\n\t\tvar rational = App.templateManager.modifiers.rational(diff);\n\n\t\t$('#preview_diff_decimal').text(decimal);\n\t\t$('#preview_diff_rational').text(rational);\n\t\tif (diff < 0) {\n\t\t\t$('#preview_spend').show();\n\t\t\t$('#preview_get').hide();\n\t\t} else {\n\t\t\t$('#preview_spend').hide();\n\t\t\t$('#preview_get').show();\n\t\t}\n\n\t\t$('#preview_diff_c_other').text(this.preparedData['goal_currency']);\n\t\tif (this.preparedData['goal_currency'] == 'USD') {\n\t\t\t$('#preview_diff_c_other').hide();\n\t\t\t$('#preview_diff_c_dollar').show();\n\t\t} else {\n\t\t\t$('#preview_diff_c_other').show();\n\t\t\t$('#preview_diff_c_dollar').hide();\n\t\t}\n\n\t\tvar days_diff = Math.ceil((this.preparedData['goal_datetime'] - this.preparedData['start_datetime']) / (24 * 60 * 60));\n\t\t$('#preview_days_count').text(days_diff);\n\t\tif (days_diff <= 1) {\n\t\t\t$('#preview_one_day').show();\n\t\t\t$('#preview_few_days').hide();\n\t\t} else {\n\t\t\t$('#preview_one_day').hide();\n\t\t\t$('#preview_few_days').show();\n\t\t}\n\n\t\tvar per_day_diff = diff / days_diff;\n\t\tvar per_day_decimal = App.templateManager.modifiers.decimal(per_day_diff);\n\t\tvar per_day_rational = App.templateManager.modifiers.rational(per_day_diff);\n\n\t\t$('#preview_d_diff_decimal').text(per_day_decimal);\n\t\t$('#preview_d_diff_rational').text(per_day_rational);\n\t\tif (per_day_diff < 0)\n\t\t\t$('#preview_d_diff_minus').show();\n\t\telse\n\t\t\t$('#preview_d_diff_minus').hide();\n\n\t\t$('#preview_d_diff_c_other').text(this.preparedData['goal_currency']);\n\t\tif (this.preparedData['goal_currency'] == 'USD') {\n\t\t\t$('#preview_d_diff_c_other').hide();\n\t\t\t$('#preview_d_diff_c_dollar').show();\n\t\t} else {\n\t\t\t$('#preview_d_diff_c_other').show();\n\t\t\t$('#preview_d_diff_c_dollar').hide();\n\t\t}\n\n\t},\n\trecalculateStartCurrency: function() {\n\t\tvar newCurrency = this.$('#input_start_currency').val();\n\t\tthis.preparedData['start_balance'] = App.exchange.convert(this.preparedData['start_balance'], this.preparedData['start_currency'], newCurrency);\n\t\tthis.preparedData['start_currency'] = newCurrency;\n\n\t\tthis.recalculateStartBalance();\n\t},\n\tstep1WalletChangeChecked: function(ev) {\n\t\tvar target = $(ev.currentTarget);\n\t\tvar wallet_id = target.data('id');\n\t\tvar element = $('.step1_wallet_checkbox[data-id=\"' + wallet_id + '\"]');\n\t\tvar isChecked = element.hasClass('active');\n\n\t\tif (isChecked) {\n\t\t\telement.removeClass('active');\n\t\t\t$('span', element).addClass('glyphicon-unchecked').removeClass('glyphicon-check');\n\t\t\tif (!this.$('.step1_wallet_checkbox.active').length)\n\t\t\t\t$('#button_step1_next').prop('disabled', true);\n\t\t} else {\n\t\t\telement.addClass('active');\n\t\t\t$('span', element).removeClass('glyphicon-unchecked').addClass('glyphicon-check');\n\t\t\t$('#button_step1_next').prop('disabled', false);\n\t\t}\n\n\t\treturn false;\n\t},\n\tstep1Next: function() {\n\t\tvar that = this;\n\t\tthis.preparedData['name'] = this.$('#input_name').val();\n\n\t\tif (this.isNew) {\n\t\t\tvar wallets = [];\n\t\t\tthis.$('.step1_wallet_checkbox').each(function() {\n\t\t\t\tvar wallet_id = $(this).data('id');\n\t\t\t\tvar isChecked = $(this).hasClass('active');\n\t\t\t\tif (isChecked)\n\t\t\t\t\twallets.push(wallet_id);\n\t\t\t});\n\t\t\tthis.preparedData['wallets'] = wallets;\n\n\t\t\tif (this.preparedData['start_currency'] == null || this.preparedData['goal_currency'] == null) {\n\t\t\t\t/// guess start_currency\n\t\t\t\tthis.preparedData['start_currency'] = 'USD'; //default\n\t\t\t\tthis.preparedData['goal_currency'] = 'USD'; //default\n\t\t\t\tvar possibleCurrencies = {};\n\t\t\t\t_.each(this.preparedData['wallets'], function(wallet_id) {\n\t\t\t\t\tvar currency = that.wallets.get(wallet_id).get('currency');\n\t\t\t\t\tpossibleCurrencies[currency] = (possibleCurrencies[currency] || 0) + 1;\n\t\t\t\t});\n\t\t\t\tvar maxPossibleCurrency = null;\n\t\t\t\tvar maxvalue = 0;\n\t\t\t\t_.each(possibleCurrencies, function(value, key) {\n\t\t\t\t\tif (maxPossibleCurrency == null || value > maxvalue) {\n\t\t\t\t\t\tmaxvalue = value;\n\t\t\t\t\t\tmaxPossibleCurrency = key;\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tif (maxPossibleCurrency) {\n\t\t\t\t\tthis.preparedData['start_currency'] = maxPossibleCurrency;\n\t\t\t\t\tthis.preparedData['goal_currency'] = maxPossibleCurrency;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthat.preparedData['start_balance'] = 0;\n\t\t\t_.each(this.preparedData['wallets'], function(wallet_id) {\n\t\t\t\tvar currency = that.wallets.get(wallet_id).get('currency');\n\t\t\t\tvar balance = that.wallets.get(wallet_id).getTotal();\n\t\t\t\tthat.preparedData['start_balance'] += App.exchange.convert(balance, currency, that.preparedData['start_currency']);\n\t\t\t});\n\t\t}\n\n\t\tthis.step = 2;\n\t\tthis.render();\n\t},\n\tstep1Back: function() {\n\t\tthis.step = 0;\n\t\tthis.render();\n\t},\n\tstep2Back: function() {\n\t\tthis.step = 1;\n\t\tthis.render();\n\t},\n\tstep: 0,\n\trender: function() {\n\t\tvar that = this;\n\t\tthis.once('render', function() {\n\t\t\tif (that.step == 2) {\n\t\t\t\tvar datetime = that.preparedData['goal_datetime'];\n\t\t\t\tthat.$('.datetimepicker').datetimepicker({\n\t\t\t\t\tinline: true,\n\t\t\t\t\tminDate: moment(),\n\t\t\t\t\tformat: 'MM/dd/YYYY'\n\t\t\t\t})\n\n\t\t\t\tthat.$('.datetimepicker').data(\"DateTimePicker\").date(moment(datetime * 1000));\n\t\t\t\tthat.recalculatePreview();\n\t\t\t\tthat.recalculateStartBalance();\n\t\t\t}\n\t\t});\n\n\t\tthis.renderHTML({\n\t\t\tplans: this.plans.toJSON(),\n\t\t\twallets: this.wallets.toJSON(),\n\t\t\tstep: this.step,\n\t\t\tpreparedData: this.preparedData\n\t\t});\n\t},\n\twakeUp: function() {\n\t\tthis.holderReady = false;\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tthat.step = 0;\n\t\t\tthat.render();\n\t\t});\n\t},\n\tinitialize: function() {\n\t\tconsole.log('plan.js | initialize');\n\t\tthis.renderLoading();\n\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tApp.helper.loadAdditionalScripts(that.additionalScripts, function() {\n\n\t\t\t\tthat.wallets = App.currentUser.getWallets();\n\t\t\t\tthat.plans = App.currentUser.getPlans();\n\n\t\t\t\tvar complete = _.invoke([that.wallets, that.plans], 'fetch');\n\n\t\t\t\t$.when.apply($, complete).done(function() {\n\t\t\t\t\tApp.exchange.loadRates(function() {\n\t\t\t\t\t\tthat.render();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/profile.js",
    "content": "// profile.js\nApp.Views.Pages.Profile = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/profile/index',\n\tcategory: 'user',\n\tevents: {\n\t\t'click .select_part': 'selectPart'\n\t},\n\ttitle: function() {\n\t\treturn 'User Profile';\n\t},\n\turl: function() {\n\t\treturn 'profile';\n\t},\n\tselectPart: function(ev) {\n\t\tvar target = $(ev.currentTarget).data('target');\n\t\tthis.$('#profile_' + target + '_container').show();\n\t\tthis.$('.profile_container').not(\"[id='profile_\" + target + \"_container']\").hide();\n\t\t$(ev.currentTarget).parents('ul').children('li').removeClass('active');\n\t\t$(ev.currentTarget).parents('li').addClass('active');\n\t},\n\tinitializeParts: function() {\n\t\tconsole.info('views/pages/profile.js | initializing parts');\n\t\tthis.parts = [];\n\t\tthis.parts.push(new App.Views.Parts.ProfileChangePassword({\n\t\t\tid: 'profile_change_password_container'\n\t\t}));\n\t\tthis.parts.push(new App.Views.Parts.ProfileRemoveAccount({\n\t\t\tid: 'profile_remove_account_container'\n\t\t}));\n\t\tthis.partsInitialized = true;\n\t},\n\trender: function() {\n\t\tconsole.log('views/pages/profile.js | Renedring user profile');\n\t\tif (!this.partsInitialized)\n\t\t\tthis.initializeParts();\n\n\t\tthis.once('render', function() {\n\t\t\tfor (var k in this.parts)\n\t\t\t\tthis.parts[k].render();\n\t\t});\n\n\t\tthis.renderHTML({\n\t\t\tuser: App.currentUser\n\t\t});\n\t},\n\twakeUp: function() {\n\t\tconsole.log('views/pages/profile.js | waking up');\n\t\tthis.holderReady = false;\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\n\t\t\tthat.render();\n\t\t});\n\t},\n\tinitialize: function(params) {\n\t\tconsole.log('views/pages/profile.js | initializing');\n\t\tthis.renderLoading();\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tthat.render();\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/update_password.js",
    "content": "// update_password.js\nApp.Views.Pages.UpdatePassword = App.Views.Abstract.Page.extend({\n\tevents: {\n\t\t\"submit #update_password_form\": \"proccess\",\n\t},\n\ttemplateName: 'pages/user/update_password',\n\tcategory: 'user',\n\ttitle: function() {\n\t\treturn 'Update Password';\n\t},\n\tproccess: function() {\n\t\tvar password_restore_code = this.$('#password_restore_code').val();\n\t\tvar password_restore_hash = this.$('#password_restore_hash').val();\n\t\tvar newPassword = this.$('#new_password_input').val();\n\t\tvar repeatPassword = this.$('#new_password_repeat_input').val();\n\n\t\tif (repeatPassword != newPassword) {\n\t\t\tthis.showError(2);\n\t\t\treturn false;\n\t\t}\n\n\t\tif (newPassword.length < 6) {\n\t\t\tthis.showError(3);\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tthis.listenTo(App.currentUser, 'newpassword:error', function() {\n\t\t\tthis.showError(1);\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'newpassword:success', function() {\n\t\t\tthis.$('.alert-danger').hide();\n\t\t\tthis.$('form').hide();\n\t\t\tthis.$('.alert-info').show();\n\t\t});\n\n\t\tApp.currentUser.newPassword(password_restore_code, password_restore_hash, newPassword);\n\n\t\treturn false;\n\t},\n\tshowError: function(errorNo) {\n\n\t\tthis.$('.btn-primary').button('reset');\n\t\tthis.$('span', '.alert-danger').hide();\n\t\tthis.$('.errorNo' + errorNo, '.alert-danger').show();\n\n\t\tif (this.$('.errorNo' + errorNo, '.alert-danger') && typeof(this.$('.errorNo' + errorNo, '.alert-danger').data('input')) !== 'undefined') {\n\t\t\t/// highlight input described as  data-input=\"new_password_repeat_input\" in span\n\t\t\tvar formGroup = this.$('#' + this.$('.errorNo' + errorNo, '.alert-danger').data('input')).closest('.form-group');\n\t\t\tif (formGroup) {\n\t\t\t\tformGroup.addClass('has-error');\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tformGroup.removeClass('has-error');\n\t\t\t\t}, 3000);\n\t\t\t\tthis.$('#' + this.$('.errorNo' + errorNo, '.alert-danger').data('input')).focus();\n\t\t\t}\n\t\t}\n\n\t\tthis.$('.alert-danger').stop(true, true).slideDown('fast');\n\t\tvar that = this;\n\t\tsetTimeout(function() {\n\t\t\tthat.$('.alert-danger').slideUp('slow');\n\t\t}, 3000);\n\t},\n\trender: function() {\n\n\t\tvar that = this;\n\t\tthis.once('render', function() {\n\t\t\tthat.$('#new_password_input').focus();\n\t\t});\n\n\t\tthis.renderHTML({\n\t\t\tpassword_restore_code: this.password_restore_code,\n\t\t\tpassword_restore_hash: this.password_restore_hash\n\t\t});\n\t},\n\tinitialize: function(params) {\n\n\t\tif (typeof(params.password_restore_code) !== 'undefined') {\n\t\t\tthis.password_restore_code = '' + params.password_restore_code;\n\t\t\tthis.password_restore_hash = '' + params.password_restore_hash;\n\t\t} else\n\t\t\tthrow 'password_restore_code and password_restore_hash parameters required';\n\n\t\tthis.render();\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/wallet.js",
    "content": "// wallet.js\nApp.Views.Pages.Wallet = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/wallets/view',\n\tcategory: 'wallets',\n\tevents: {\n\t\t\"submit #add_transaction_form\": \"addExpense\",\n\t\t\"click #add_profit_button\": \"addProfit\",\n\t\t\"click #set_total_to_button\": \"setTotalTo\"\n\t},\n\ttitle: function() {\n\t\tif (typeof(this.model) != 'undefined' && this.model.get('name'))\n\t\t\treturn this.model.get('name');\n\t\telse\n\t\t\treturn 'Wallet';\n\t},\n\turl: function() {\n\t\tif (typeof(this.model) != 'undefined' && this.model.id)\n\t\t\treturn 'wallets/' + this.model.id;\n\t},\n\tsetTotalTo: function() {\n\t\tApp.showDialog('SetTotalTo', {\n\t\t\twallet: this.model\n\t\t});\n\t\treturn false;\n\t},\n\taddProfit: function() {\n\t\tApp.showDialog('AddProfit', {\n\t\t\twallet: this.model\n\t\t});\n\t\treturn false;\n\t},\n\taddExpense: function() {\n\t\tvar description = $(\"#add_transaction_text\").val();\n\t\tvar amount = $(\"#add_transaction_amount\").val(); // could be empty if we are getting amount from description (1st try).\n\n\t\tconsole.log('Add transaction with description: ' + description);\n\n\t\tvar numbers = description.split(\",\").join(\".\").match(/[0-9.]+/g);\n\t\tvar fromDescriptionAmount = false;\n\t\tif (typeof(numbers) !== 'undefined' && numbers && typeof(numbers[0]) !== 'undefined' && numbers[0]) {\n\t\t\tfromDescriptionAmount = +numbers[0];\n\t\t}\n\n\t\tif (fromDescriptionAmount) {\n\t\t\tthis.model.addExpense(fromDescriptionAmount, description);\n\t\t\tthis.$('#add_transaction_amount').hide();\n\t\t\t$(\"#add_transaction_text\").val('').blur();\n\t\t} else {\n\t\t\tamount = amount.split(',').join('.');\n\t\t\tamount = +amount;\n\t\t\tif (amount > 0) {\n\t\t\t\tthis.model.addExpense(amount, description);\n\t\t\t\tthis.$('#add_transaction_amount').hide();\n\t\t\t\tthis.$(\"#add_transaction_text\").val('').blur();\n\t\t\t} else {\n\t\t\t\tthis.$('#add_transaction_amount').show();\n\t\t\t\tthis.$('#add_transaction_amount').focus();\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t},\n\trender: function() {\n\t\tconsole.log('views/pages/wallet.js | rendering');\n\t\tif (!this.partsInitialized)\n\t\t\tthis.initializeParts();\n\n\t\t//// slide down invitation box if total is changed.\n\t\tif (App.currentUser.isDemo()) {\n\t\t\tif (typeof(this.initialWalletTotal) !== 'undefined') {\n\t\t\t\tif (!$('#fill_profile_invitation').is(\":visible\"))\n\t\t\t\t\tif (this.model.get('total') != this.initialWalletTotal)\n\t\t\t\t\t\t$('#fill_profile_invitation').slideDown('slow');\n\t\t\t} else {\n\t\t\t\tthis.initialWalletTotal = this.model.get('total');\n\t\t\t}\n\t\t}\n\n\t\tthis.once('render', function() {\n\t\t\tfor (var k in this.parts)\n\t\t\t\tthis.parts[k].render();\n\t\t\tfor (var k in this.charts)\n\t\t\t\tthis.charts[k].render();\n\n\t\t\t// Instance the tour\n\t\t\tif (typeof(App.Tours.Wallet) !== 'undefined')\n\t\t\t\tApp.Tours.Wallet.init(this);\n\t\t});\n\t\tthis.renderHTML({\n\t\t\titem: this.model.toJSON()\n\t\t});\n\t},\n\tinitializeParts: function() {\n\t\tconsole.info('views/pages/wallet.js | initializing parts');\n\t\tthis.parts = [];\n\t\tthis.parts.push(new App.Views.Parts.Transactions({\n\t\t\tid: 'transactions_container',\n\t\t\tmodel: this.model,\n\t\t\tcollection: this.model.getTransactions()\n\t\t}));\n\t\tthis.parts.push(new App.Views.Parts.WalletPlans({\n\t\t\tid: 'plans_container',\n\t\t\tmodel: this.model\n\t\t}));\n\t\tthis.partsInitialized = true;\n\n\t\tthis.charts = [];\n\t\tthis.charts.push(new App.Views.Charts.Balance({\n\t\t\tid: 'balance_canvas',\n\t\t\tmodel: this.model\n\t\t}));\n\t},\n\twakeUp: function() {\n\t\tconsole.log('views/pages/wallet.js | waking up');\n\t\tthis.holderReady = false;\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tthat.render();\n\t\t\tthat.listenTo(that.model, 'change sync destroy', that.render);\n\t\t\tfor (var k in that.parts)\n\t\t\t\tif (typeof(that.parts[k].wakeUp) === 'function')\n\t\t\t\t\tthat.parts[k].wakeUp();\n\t\t});\n\t},\n\treloadWallet: function() {\n\t\tvar wallet_id = this.model.id;\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tvar transactions = that.model.getTransactions();\n\t\t\tthat.model = new App.Models.Wallet();\n\t\t\tthat.model.id = wallet_id;\n\t\t\tthat.model.transactions = transactions;\n\t\t\tthat.model.transactions.fetch();\n\n\t\t\tthat.listenTo(that.model, 'change sync destroy', that.render);\n\n\t\t\tthat.model.fetch({\n\t\t\t\terror: function() {\n\t\t\t\t\tApp.showPage('NotFound');\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t},\n\tinitialize: function(params) {\n\t\tconsole.log('views/pages/wallet.js | initializing');\n\t\tthis.renderLoading();\n\n\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\n\t\t\t/// initialize models, collections etc. Request fetching from storage\n\t\t\tif (typeof(params.item) !== 'undefined') {\n\t\t\t\tthat.model = params.item;\n\t\t\t\tthat.render();\n\t\t\t\tthat.listenTo(that.model, 'change sync destroy', that.render);\n\t\t\t} else if (typeof(params.id) !== 'undefined') {\n\t\t\t\tthat.model = new App.Models.Wallet();\n\t\t\t\tthat.model.id = params.id;\n\n\t\t\t\tthat.listenTo(that.model, 'change sync destroy', that.render);\n\n\t\t\t\tthat.model.fetch({\n\t\t\t\t\terror: function() {\n\t\t\t\t\t\tApp.showPage('NotFound');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else\n\t\t\t\tthrow 'id or item parameters required';\n\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/pages/wallets.js",
    "content": "// wallets.js\nApp.Views.Pages.Wallets = App.Views.Abstract.Page.extend({\n\n\ttemplateName: 'pages/wallets/index',\n\tcategory: 'wallets',\n\tstatus: 'active',\n\torigin: 'both',\n\tevents: {\n\t\t\"mouseenter .item\": \"moreWalletDetails\",\n\t\t\"mouseleave .item\": \"lessWalletDetails\",\n\t\t\"click .item_button_remove\": \"removeItem\",\n\t\t\"click .item\": \"toItem\",\n\t\t\"click .item_button_edit\": \"editItem\",\n\t\t\"click .item_button_restore\": \"restoreItem\",\n\t\t\"click .item_button_accesses\": \"showAccesses\",\n\t\t\"click .filter_menu\": \"filter\",\n\t\t\"click .origin_menu\": \"filterOrigin\"\n\t},\n\ttitle: function() {\n\t\treturn 'Wallets';\n\t},\n\turl: function() {\n\t\treturn 'wallets';\n\t},\n\tfilter: function(ev) {\n\t\tvar status = $(ev.currentTarget).data('status');\n\t\tif ((status == 'active' || status == 'hidden') && status != this.status) {\n\t\t\tthis.status = status;\n\t\t\tthis.render();\n\t\t}\n\t\treturn false;\n\t},\n\tfilterOrigin: function(ev) {\n\t\tvar origin = $(ev.currentTarget).data('origin');\n\t\tif ((origin == 'both' || origin == 'mine' || origin == 'shared') && origin != this.origin) {\n\t\t\tthis.origin = origin;\n\t\t\tthis.render();\n\t\t}\n\t\treturn false;\n\t},\n\ttoItem: function(ev) {\n\t\tvar data = $(ev.currentTarget).data();\n\t\tif (typeof(data.id) === 'undefined')\n\t\t\treturn true;\n\n\t\tvar id = parseInt(data.id, 10);\n\t\tvar item = this.items.get(id);\n\n\t\tif (!item)\n\t\t\treturn true;\n\n\t\tApp.showPage('Wallet', {\n\t\t\titem: item\n\t\t});\n\n\t\treturn false;\n\t},\n\tmoreWalletDetails: function(ev) {\n\t\t$(ev.currentTarget).find(\".item_buttons\").show();\n\t\t//$(ev.currentTarget).find(\".item_information\").hide();\n\t},\n\tlessWalletDetails: function(ev) {\n\t\t$(ev.currentTarget).find(\".item_buttons\").hide();\n\t\t//$(ev.currentTarget).find(\".item_information\").show();\n\t},\n\tremoveItem: function(ev) {\n\t\tvar id = $(ev.currentTarget).parents('.item').data('id');\n\t\tApp.showDialog('HideWallet', {\n\t\t\titem: this.items.get(id)\n\t\t});\n\n\t\treturn false;\n\t},\n\trestoreItem: function(ev) {\n\t\tvar id = $(ev.currentTarget).parents('.item').data('id');\n\t\tvar item = this.items.get(id);\n\t\tif (item && item.get('status') == 'hidden') {\n\t\t\titem.set('status', 'active');\n\t\t\titem.save();\n\t\t}\n\n\t\treturn false;\n\t},\n\tshowAccesses: function(ev) {\n\t\tvar id = $(ev.currentTarget).parents('.item').data('id');\n\t\tApp.showDialog('WalletAccesses', {\n\t\t\titem: this.items.get(id)\n\t\t});\n\n\t\treturn false;\n\t},\n\teditItem: function(ev) {\n\t\tvar id = $(ev.currentTarget).parents('.item').data('id');\n\t\tApp.showDialog('EditWallet', {\n\t\t\titem: this.items.get(id)\n\t\t});\n\n\t\treturn false;\n\t},\n\trender: function() {\n\t\tif (this.origin == 'both')\n\t\t\tvar filtered = this.items.search({\n\t\t\t\tstatus: this.status\n\t\t\t});\n\t\telse\n\t\t\tvar filtered = this.items.search({\n\t\t\t\tstatus: this.status,\n\t\t\t\torigin: this.origin\n\t\t\t});\n\n\t\tthis.once('render', function() {\n\t\t\t// Instance the tour\n\t\t\tif (typeof(App.Tours.Wallets) !== 'undefined')\n\t\t\t\tApp.Tours.Wallets.init(this);\n\t\t});\n\n\t\tthis.renderHTML({\n\t\t\titems: filtered.toJSON(),\n\t\t\tstatus: this.status,\n\t\t\torigin: this.origin\n\t\t});\n\t},\n\twakeUp: function() {\n\t\tthis.holderReady = false;\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tthat.render();\n\t\t\tthat.listenTo(that.items, 'sync add change reset remove', that.render);\n\t\t});\n\t},\n\tinitialize: function() {\n\t\tconsole.log('wallets.js | initialize');\n\t\tthis.renderLoading();\n\n\t\tvar that = this;\n\t\tthis.requireSingedIn(function() {\n\t\t\tthat.items = App.currentUser.getWallets();\n\t\t\t/// initialize models, collections etc. Request fetching from storage\n\t\t\tthat.listenTo(that.items, 'sync', that.render);\n\t\t\tthat.items.fetch().done(function() {\n\t\t\t\tthat.listenTo(that.items, 'add change reset remove', that.render);\n\t\t\t}).error(function() {\n\t\t\t\tthat.render();\n\t\t\t});\n\t\t});\n\t}\n\n});"
  },
  {
    "path": "public/scripts/app/views/parts/profile_change_password.js",
    "content": "// profile_change_password.js\nApp.Views.Parts.ProfileChangePassword = Backbone.View.extend({\n\n\tevents: {\n\t\t\"submit #change_password_form\": \"proccess\",\n\t},\n\n\tproccess: function() {\n\t\tvar currentPassword = this.$('#current_password_input').val();\n\t\tvar newPassword = this.$('#new_password_input').val();\n\t\tvar repeatPassword = this.$('#new_password_repeat_input').val();\n\n\t\tif (repeatPassword != newPassword) {\n\t\t\tthis.showError(2);\n\t\t\treturn false;\n\t\t}\n\n\t\tif (newPassword.length < 6) {\n\t\t\tthis.showError(3);\n\t\t\treturn false;\n\t\t}\n\n\t\tthis.$('.btn-primary').button('loading');\n\n\t\tthis.listenTo(App.currentUser, 'invalid', function() {\n\t\t\tthis.showError(1);\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'changed', function() {\n\t\t\tthis.$('.alert-danger').hide();\n\t\t\tthis.$('form').hide();\n\t\t\tthis.$('.alert-info').show();\n\t\t});\n\n\t\tApp.currentUser.changePassword(currentPassword, newPassword);\n\n\t\treturn false;\n\t},\n\tshowError: function(errorNo) {\n\n\t\tthis.$('.btn-primary').button('reset');\n\t\tthis.$('span', '.alert-danger').hide();\n\t\tthis.$('.errorNo' + errorNo, '.alert-danger').show();\n\n\t\tif (this.$('.errorNo' + errorNo, '.alert-danger') && typeof(this.$('.errorNo' + errorNo, '.alert-danger').data('input')) !== 'undefined') {\n\t\t\t/// highlight input described as  data-input=\"new_password_repeat_input\" in span\n\t\t\tvar formGroup = this.$('#' + this.$('.errorNo' + errorNo, '.alert-danger').data('input')).closest('.form-group');\n\t\t\tif (formGroup) {\n\t\t\t\tformGroup.addClass('has-error');\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tformGroup.removeClass('has-error');\n\t\t\t\t}, 3000);\n\t\t\t\tthis.$('#' + this.$('.errorNo' + errorNo, '.alert-danger').data('input')).focus();\n\t\t\t}\n\t\t}\n\n\t\tthis.$('.alert-danger').stop(true, true).slideDown('fast');\n\t\tvar that = this;\n\t\tsetTimeout(function() {\n\t\t\tthat.$('.alert-danger').slideUp('slow');\n\t\t}, 3000);\n\t},\n\n\tinitialize: function() {\n\t\tconsole.log('views/parts/profile_change_password.js | Initializing  view');\n\t},\n\twakeUp: function() {\n\t\tconsole.error('views/parts/profile_change_password.js | Waking up');\n\t},\n\trender: function() {\n\t\tconsole.log('views/parts/profile_change_password.js | Rendering');\n\t\tthis.setElement($('#' + this.id));\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/parts/profile_remove_account.js",
    "content": "// profile_remove_account.js\nApp.Views.Parts.ProfileRemoveAccount = Backbone.View.extend({\n\n\tevents: {\n\t\t\"submit #remove_account_step_1_form\": \"proccess1\",\n\t\t\"submit #remove_account_step_2_form\": \"proccess2\"\n\t},\n\n\tproccess1: function() {\n\t\tthis.$('#remove_account_step_1_submit').button('loading');\n\n\t\tthis.listenTo(App.currentUser, 'removeaccountstart', function() {\n\t\t\tthis.$('#profile_remove_account_step_1').hide();\n\t\t\tthis.$('#profile_remove_account_step_2').show();\n\t\t});\n\n\t\tApp.currentUser.removeAccount();\n\t\treturn false;\n\t},\n\tshowWrongCodeMessage: function() {\n\t\tvar that = this;\n\t\tthat.$('#invalid_remove_account_code').slideDown('fast');\n\t\tsetTimeout(function() {\n\t\t\tthat.$('#invalid_remove_account_code').slideUp();\n\t\t}, 2000);\n\t},\n\tproccess2: function() {\n\t\tvar code = this.$('#remove_account_code').val();\n\t\tif (!code) {\n\t\t\tthis.showWrongCodeMessage();\n\t\t\treturn;\n\t\t}\n\t\tthis.$('#remove_account_step_2_submit').button('loading');\n\n\t\tthis.listenTo(App.currentUser, 'removeaccountdone', function() {\n\t\t\tthis.$('#profile_remove_account_done').show();\n\t\t\tsetTimeout(function() {\n\t\t\t\tApp.currentUser.signOut();\n\t\t\t}, 1000);\n\t\t});\n\n\t\tthis.listenTo(App.currentUser, 'removeaccountwrongcode', function() {\n\t\t\tthis.showWrongCodeMessage();\n\t\t\tthis.$('#remove_account_step_2_submit').button('reset');\n\t\t});\n\n\t\tApp.currentUser.removeAccountConfirm(code);\n\t\treturn false;\n\t},\n\tinitialize: function() {\n\t\tconsole.log('views/parts/profile_remove_account.js | Initializing  view');\n\t},\n\twakeUp: function() {\n\t\tconsole.error('views/parts/profile_remove_account.js | Waking up');\n\t},\n\trender: function() {\n\t\tconsole.log('views/parts/profile_remove_account.js | Rendering');\n\t\tthis.setElement($('#' + this.id));\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/parts/transactions.js",
    "content": "// transactions.js\nApp.Views.Parts.Transactions = Backbone.View.extend({\n\n\ttemplateName: 'parts/transactions',\n\tel: $(\"#comments_container\"),\n\tevents: {\n\t\t\"click .item\": \"transactionDetails\",\n\t\t\"click #goto_next\": \"gotoNext\",\n\t\t\"click #goto_prev\": \"gotoPrev\",\n\t\t\"click #goto_current\": \"gotoCurrent\"\n\t},\n\tgotoNext: function() {\n\t\tthis.collection.gotoNext();\n\t},\n\tgotoPrev: function() {\n\t\tthis.collection.gotoPrev();\n\t},\n\tgotoCurrent: function() {\n\t\tthis.collection.gotoCurrent();\n\t},\n\ttransactionDetails: function(ev) {\n\t\tconsole.log('views/parts/transactions.js | Show transactions details');\n\t\tvar data = $(ev.currentTarget).data();\n\t\tif (typeof(data.id) === 'undefined')\n\t\t\treturn true;\n\n\t\tvar id = parseInt(data.id, 10);\n\t\tvar item = this.collection.get(id);\n\n\t\tif (!item)\n\t\t\treturn true;\n\n\t\tApp.showDialog('TransactionDetails', {\n\t\t\titem: item,\n\t\t\twallet: this.model\n\t\t});\n\n\t\treturn false;\n\t},\n\n\tinitialize: function() {\n\t\tconsole.log('views/parts/transactions.js | Initializing Transactions view');\n\t\tif (!this.model || !this.collection)\n\t\t\tconsole.error('views/parts/transactions.js | model && collection && id should be provided for this view');\n\n\t\tthis.listenTo(this.collection, 'sync', this.render);\n\t\tthis.listenTo(this.collection, 'changedperiod', this.fadeOut);\n\t},\n\twakeUp: function() {\n\t\tconsole.error('views/parts/transactions.js | Waking up');\n\t\tthis.listenTo(this.collection, 'sync', this.render);\n\t\tthis.listenTo(this.collection, 'changedperiod', this.fadeOut);\n\t},\n\tfadeOut: function() {\n\t\tthis.$('#transactions_container').fadeTo(1, 0.5);\n\t},\n\trender: function() {\n\t\tconsole.log('views/parts/transactions.js | Rendering, state = ' + this.collection.state);\n\t\tthis.setElement($('#' + this.id));\n\t\tthis.$('#transactions_container').fadeTo(1, 1);\n\n\t\tvar data = {\n\t\t\tstate: this.collection.state,\n\t\t\tcollection: this.collection,\n\t\t\ttransactions: this.collection.sort().toJSON(),\n\t\t\titem: this.model.toJSON()\n\t\t};\n\t\tvar that = this;\n\t\tApp.templateManager.fetch(this.templateName, data, function(html) {\n\n\t\t\tthat.$el.html(html);\n\t\t\tthat.trigger('render');\n\t\t\tthat.trigger('loaded');\n\t\t});\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/parts/wallet_plans.js",
    "content": "// wallet_plans.js\nApp.Views.Parts.WalletPlans = Backbone.View.extend({\n\n\ttemplateName: 'parts/wallet_plans',\n\tevents: {},\n\tareStatsReady: false,\n\tinitialize: function() {\n\t\tconsole.log('views/parts/wallet_plans.js | Initializing Wallet Plans view');\n\t\tif (!this.model || !this.id)\n\t\t\tconsole.error('views/parts/wallet_plans.js | model and dom id should be provided for this view');\n\n\t\tthis.areStatsReady = false;\n\t\tvar that = this;\n\n\t\tApp.exchange.loadRates(function() {\n\t\t\tthat.listenToOnce(that.model, 'plansloaded', function() {\n\t\t\t\tthat.invokeStatsLoading();\n\t\t\t});\n\t\t\tthat.listenTo(that.model, 'plansloaded', that.render);\n\t\t\tthat.model.getPlans();\n\t\t});\n\t},\n\twakeUp: function() {\n\t\tconsole.error('views/parts/wallet_plans.js | Waking up');\n\t},\n\tinvokeStatsLoading: function() {\n\t\tvar that = this;\n\t\tvar complete = _.invoke(this.model.plans.models, 'getStats');\n\t\t$.when.apply($, complete).done(function() {\n\t\t\tthat.areStatsReady = true;\n\t\t\tthat.render();\n\t\t});\n\t},\n\trender: function() {\n\t\tconsole.log('views/parts/wallet_plans.js | Rendering');\n\t\tthis.setElement($('#' + this.id));\n\n\t\tvar plans = [];\n\t\tif (this.model.plans)\n\t\t\tfor (var i = 0; i < this.model.plans.length; i++) {\n\t\t\t\tvar allowedToSpend = null;\n\t\t\t\tvar allowedToSpendInWalletCurrency = null;\n\n\t\t\t\tif (this.areStatsReady) {\n\t\t\t\t\tallowedToSpend = this.model.plans.at(i).getPlanForToday();\n\t\t\t\t\tallowedToSpendInWalletCurrency = App.exchange.convert(allowedToSpend, this.model.plans.at(i).get('goal_currency'), this.model.get('currency'));\n\t\t\t\t\tconsole.log(allowedToSpendInWalletCurrency);\n\t\t\t\t}\n\n\t\t\t\tplans.push({\n\t\t\t\t\tplan: this.model.plans.at(i).toJSON(),\n\t\t\t\t\tallowedToSpend: allowedToSpend,\n\t\t\t\t\tallowedToSpendInWalletCurrency: allowedToSpendInWalletCurrency\n\t\t\t\t});\n\t\t\t}\n\n\t\tvar data = {\n\t\t\twallet: this.model.toJSON(),\n\t\t\tplans: plans,\n\t\t\tareStatsReady: this.areStatsReady\n\t\t};\n\t\tvar that = this;\n\t\tApp.templateManager.fetch(this.templateName, data, function(html) {\n\t\t\tthat.$el.html(html);\n\t\t\tthat.$('[data-toggle=\"tooltip\"]').tooltip();\n\t\t\tthat.trigger('render');\n\t\t\tthat.trigger('loaded');\n\t\t});\n\t}\n});"
  },
  {
    "path": "public/scripts/app/views/tours/wallet.js",
    "content": "// wallet.js\nApp.Tours.Wallet = {\n\ttour: null,\n\tpage: null,\n\tfinish: function() {\n\t\tApp.eraseCookie('show_tour_Wallet');\n\t\tthis.tour.end();\n\t},\n\tinit: function(page) {\n\t\tif (!App.readCookie('show_tour_Wallet'))\n\t\t\treturn false;\n\n\t\tvar that = this;\n\n\t\tApp.currentTour = this;\n\n\t\tvar nextFunction = function() {\n\t\t\tvar step = that.tour.getCurrentStep() + 1;\n\t\t\tthat.tour.restart();\n\t\t\tthat.tour.goTo(step);\n\t\t}\n\n\t\tthis.page = page;\n\t\tthis.tour = new Tour({\n\t\t\tonEnd: function(tour) {\n\t\t\t\tApp.eraseCookie('show_tour_Wallet');\n\t\t\t},\n\t\t\tsteps: [{\n\t\t\t\telement: \"#add_profit_button\",\n\t\t\t\ttitle: \"Step 1 of 6\",\n\t\t\t\tcontent: $('#tour_step_0').html(),\n\t\t\t\treflex: true,\n\t\t\t\tplacement: 'auto',\n\t\t\t\tonNext: function(tour) {\n\t\t\t\t\t\tthat.tour.end();\n\n\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\tif (App.dialog && App.dialog.isVisible)\n\t\t\t\t\t\t\t\tthat.page.listenToOnce(App.dialog, 'hidden', nextFunction);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tnextFunction();\n\t\t\t\t\t\t}, 50);\n\t\t\t\t\t} /// onNext\n\t\t\t}, {\n\t\t\t\telement: \"#set_total_to_button\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: true,\n\t\t\t\ttitle: \"Step 2 of 6\",\n\t\t\t\tcontent: $('#tour_step_1').html(),\n\t\t\t\tonNext: function(tour) {\n\t\t\t\t\t\tthat.tour.end();\n\n\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\tif (App.dialog && App.dialog.isVisible)\n\t\t\t\t\t\t\t\tthat.page.listenToOnce(App.dialog, 'hidden', nextFunction);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tnextFunction();\n\t\t\t\t\t\t}, 50);\n\t\t\t\t\t} //// onNext\n\t\t\t}, {\n\t\t\t\telement: \"#add_transaction_form\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: false,\n\t\t\t\ttitle: \"Step 3 of 6\",\n\t\t\t\tcontent: $('#tour_step_2').html(),\n\t\t\t\tonShown: function(tour) {\n\t\t\t\t\t\tvar nextStep = tour.getCurrentStep() + 1;\n\t\t\t\t\t\tthat.page.listenToOnce(that.page.model, 'addExpense', function() {\n\t\t\t\t\t\t\tthat.tour.goTo(nextStep);\n\t\t\t\t\t\t});\n\t\t\t\t\t} //// onShown\n\t\t\t}, {\n\t\t\t\telement: \"#transactions_container\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: true,\n\t\t\t\ttitle: \"Step 4 of 6\",\n\t\t\t\tcontent: $('#tour_step_3').html(),\n\t\t\t\tonShown: function() {\n\n\t\t\t\t},\n\t\t\t\tonNext: function(tour) {\n\t\t\t\t\t\tthat.tour.end();\n\n\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\tif (App.dialog && App.dialog.isVisible)\n\t\t\t\t\t\t\t\tthat.page.listenToOnce(App.dialog, 'hidden', nextFunction);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tnextFunction();\n\t\t\t\t\t\t}, 50);\n\t\t\t\t\t} //// onNext\n\t\t\t}, {\n\t\t\t\telement: \"#balance_canvas\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: true,\n\t\t\t\ttitle: \"Step 5 of 6\",\n\t\t\t\tcontent: $('#tour_step_4').html(),\n\t\t\t\tonNext: function() {\n\t\t\t\t\t$(\"#fill_profile_invitation\").show();\n\t\t\t\t}\n\t\t\t}, {\n\t\t\t\telement: \"#fill_profile_invitation\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: true,\n\t\t\t\ttitle: \"Step 6 of 6\",\n\t\t\t\tcontent: $('#tour_step_5').html(),\n\t\t\t\tonNext: function() {\n\t\t\t\t\tApp.currentTour.finish();\n\t\t\t\t}\n\t\t\t}]\n\t\t});\n\n\t\t// Initialize the tour\n\t\tthat.tour.init();\n\n\t\t// Start the tour\n\t\tthat.tour.start(true);\n\t\tthat.tour.goTo(0);\n\t}\n}"
  },
  {
    "path": "public/scripts/app/views/tours/wallets.js",
    "content": "// wallets.js\nApp.Tours.Wallets = {\n\ttour: null,\n\tpage: null,\n\tfinish: function() {\n\t\tApp.eraseCookie('show_tour_Wallets');\n\t\tthis.tour.end();\n\t},\n\tinit: function(page) {\n\t\tif (!App.readCookie('show_tour_Wallets'))\n\t\t\treturn false;\n\n\t\tvar that = this;\n\n\t\tApp.currentTour = this;\n\n\t\tvar nextFunction = function() {\n\t\t\tvar step = that.tour.getCurrentStep() + 1;\n\t\t\tthat.tour.restart();\n\t\t\tthat.tour.goTo(step);\n\t\t}\n\n\t\tthis.page = page;\n\t\tthis.tour = new Tour({\n\t\t\tonEnd: function(tour) {\n\t\t\t\tApp.eraseCookie('show_tour_Wallets');\n\t\t\t},\n\t\t\tsteps: [{\n\t\t\t\telement: \"#wallet_items\",\n\t\t\t\ttitle: \"Step 1 of 3\",\n\t\t\t\tcontent: $('#tour_step_0').html(),\n\t\t\t\treflex: false,\n\t\t\t\tplacement: 'auto'\n\t\t\t}, {\n\t\t\t\telement: \"#add_wallet_button\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: true,\n\t\t\t\ttitle: \"Step 2 of 3\",\n\t\t\t\tcontent: $('#tour_step_1').html(),\n\t\t\t\tonNext: function(tour) {\n\t\t\t\t\t\tthat.tour.end();\n\n\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\tif (App.dialog && App.dialog.isVisible)\n\t\t\t\t\t\t\t\tthat.page.listenToOnce(App.dialog, 'hidden', nextFunction);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tnextFunction();\n\t\t\t\t\t\t}, 50);\n\t\t\t\t\t} //// onNext\n\t\t\t}, {\n\t\t\t\telement: \"#wallet_items\",\n\t\t\t\tplacement: 'auto',\n\t\t\t\treflex: false,\n\t\t\t\ttitle: \"Step 3 of 3\",\n\t\t\t\tcontent: $('#tour_step_2').html(),\n\t\t\t\tonNext: function(tour) {\n\t\t\t\t\t\tthat.tour.end();\n\n\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\tif (App.dialog && App.dialog.isVisible)\n\t\t\t\t\t\t\t\tthat.page.listenToOnce(App.dialog, 'hidden', nextFunction);\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tnextFunction();\n\t\t\t\t\t\t}, 50);\n\t\t\t\t\t} //// onNext\n\t\t\t}]\n\t\t});\n\n\t\t// Initialize the tour\n\t\tthat.tour.init();\n\n\t\t// Start the tour\n\t\tthat.tour.start(true);\n\t\tthat.tour.goTo(0);\n\t}\n}"
  },
  {
    "path": "public/scripts/app/views/widgets/index.js",
    "content": ""
  },
  {
    "path": "public/scripts/app.js",
    "content": "// app.js\nwindow.App = {\n\n\tModels: {},\n\tCollections: {},\n\tViews: {\n\t\tAbstract: {},\n\t\tDialogs: {},\n\t\tPages: {},\n\t\tWidgets: {},\n\t\tParts: {},\n\t\tCharts: {}\n\t},\n\tTours: {},\n\tcurrentTour: null,\n\n\trouter: null,\n\n\tdialog: null,\n\tpage: null,\n\n\theader: null,\n\tfooter: null,\n\tsettings: null,\n\n\tcurrentUser: null,\n\n\tinit: function() {\n\t\tvar that = this;\n\t\t$.ajaxSetup({\n\t\t\tcache: false\n\t\t});\n\n\t\tvar doneCallback = function() {\n\t\t\tthat.localStorage.invalidate(that.settings.version);\n\t\t\tthat.i18n.setLanguage(that.settings.detectLanguage());\n\t\t\tthat.router.init();\n\t\t\tthat.loadingStatus(false);\n\t\t};\n\n\t\tif (document.cookie.indexOf(\"is_logged_in_user\") >= 0) {\n\t\t\t$.get(this.settings.apiEntryPoint + 'users', function(user) {\n\t\t\t\t\tif (user)\n\t\t\t\t\t\tthat.setUser(user);\n\t\t\t\t\telse\n\t\t\t\t\t\tthat.setUser();\n\t\t\t\t}, 'json')\n\t\t\t\t.fail(function() {\n\t\t\t\t\tthat.setUser();\n\t\t\t\t}).always(function() {\n\t\t\t\t\tdoneCallback();\n\t\t\t\t});\n\t\t} else {\n\t\t\tthat.setUser();\n\t\t\tdoneCallback();\n\t\t}\n\t},\n\tshowDialog: function(dialogName, params) {\n\t\tif (typeof(App.Views.Dialogs[dialogName]) === 'undefined') /// this page is already current\n\t\t\treturn false;\n\n\t\tif (App.dialog && App.dialog.isVisible) {\n\t\t\tApp.dialog.once('hidden', function() {\n\t\t\t\tconsole.log('Ready to show another dialog');\n\t\t\t\tApp.dialog = new App.Views.Dialogs[dialogName](params);\n\t\t\t}, this);\n\t\t\tApp.dialog.hide();\n\t\t} else {\n\t\t\tApp.dialog = new App.Views.Dialogs[dialogName](params);\n\t\t\tApp.log.event('dialog', 'Show Dialog ' + dialogName);\n\t\t}\n\n\t\treturn true;\n\t},\n\tshowPage: function(pageName, params) {\n\n\t\tconsole.log('Showing page: ' + pageName);\n\n\t\tif (App.currentTour)\n\t\t\tApp.currentTour.finish();\n\n\t\tif (typeof(params) === 'undefined')\n\t\t\tparams = {};\n\n\t\tif (typeof(App.Views.Pages[pageName]) === 'undefined') {\n\t\t\tconsole.error(\"There is no view class defined\");\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(this.page) !== 'undefined' && this.page) /// undelegate events from previous page\n\t\t{\n\t\t\tthis.page.sleep();\n\t\t}\n\n\t\t/// Trying to get view from stack\n\t\tvar fromStack = this.viewStack.getView(pageName, params);\n\n\n\t\tif (fromStack !== false) {\n\t\t\t/// Console log wake up page from stack\n\t\t\tconsole.log('Showing page from stack');\n\t\t\tthis.page = fromStack;\n\t\t\tthis.page.wakeUp();\n\t\t\tthis.loadingStatus(false);\n\n\t\t} else {\n\t\t\t/// or create new one\n\t\t\tthis.loadingStatus(true);\n\t\t\tthis.page = new App.Views.Pages[pageName](params);\n\t\t\tthis.page.on('loaded', function() {\n\t\t\t\tthis.loadingStatus(false);\n\t\t\t}, this);\n\t\t\tif (this.page.isReady)\n\t\t\t\tthis.loadingStatus(false);\n\t\t\t// this.listenTo(this.page, 'loaded', function(){ this.loadingStatus(false); });\n\t\t\t// this.listenTo(this.page, 'loading', function(){ this.loadingStatus(true); });\n\n\t\t\tthis.viewStack.addView(pageName, params, this.page);\n\t\t}\n\t\tthis.renderLayoutBlocks();\n\n\t\treturn true;\n\t},\n\tsetProgress: function(value) {\n\t\tif (!this.progress)\n\t\t\tthis.progress = new Mprogress();\n\n\t\tif (typeof(value) === 'undefined') {\n\t\t\tif (this.progress.status === null)\n\t\t\t\treturn this.progress.start();\n\t\t\telse\n\t\t\t\treturn this.progress.inc();\n\t\t}\n\t\tif (value >= 1 || value === true)\n\t\t\treturn this.progress.end();\n\t\tthis.progress.set(value);\n\t},\n\tloadingStatus: function(status) {\n\t\tif (status) {\n\t\t\tconsole.log('app.js | Loading status = true');\n\t\t\tthis.isLoading = true;\n\t\t\t$('#preloader').stop().show();\n\t\t} else {\n\t\t\tconsole.log('app.js | Loading status = false');\n\t\t\tthis.isLoading = false;\n\t\t\t$('#preloader').stop().fadeOut('slow');\n\t\t}\n\t},\n\tsetUser: function(data) {\n\t\tthis.currentUser = new App.Models.User();\n\t\tthis.currentUser.on('signedInStatusChanged', this.userChanged, this);\n\t\tif (typeof(data) !== 'undefined')\n\t\t\tthis.currentUser.signInWithData(data);\n\t},\n\tuserChanged: function() {\n\t\tconsole.log('User info changed');\n\t\t// You can also refresh the page here if you want to.\n\n\t\tthis.renderLayoutBlocks();\n\t},\n\trenderLayoutBlocks: function() {\n\t\tvar that = this;\n\n\t\tif (!this.header) {\n\t\t\tthis.header = new App.Views.Header();\n\t\t}\n\n\t\tvar renderFunc = function() {\n\t\t\tthat.header.render();\n\t\t};\n\n\t\tif ($.isReady) {\n\t\t\trenderFunc();\n\t\t} else {\n\t\t\t$(function() {\n\t\t\t\trenderFunc();\n\t\t\t});\n\t\t}\n\t},\n\tcreateCookie: function(name, value, days) {\n\t\tvar expires;\n\n\t\tif (days) {\n\t\t\tvar date = new Date();\n\t\t\tdate.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));\n\t\t\texpires = \"; expires=\" + date.toGMTString();\n\t\t} else {\n\t\t\texpires = \"\";\n\t\t}\n\t\tdocument.cookie = encodeURIComponent(name) + \"=\" + encodeURIComponent(value) + expires + \"; path=/\";\n\t},\n\treadCookie: function(name) {\n\t\tvar nameEQ = encodeURIComponent(name) + \"=\";\n\t\tvar ca = document.cookie.split(';');\n\t\tfor (var i = 0; i < ca.length; i++) {\n\t\t\tvar c = ca[i];\n\t\t\twhile (c.charAt(0) === ' ') c = c.substring(1, c.length);\n\t\t\tif (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length, c.length));\n\t\t}\n\t\treturn null;\n\t},\n\teraseCookie: function(name) {\n\t\tApp.createCookie(name, \"\", -1);\n\t}\n\n};"
  },
  {
    "path": "public/scripts/functions.js",
    "content": "function isEmail(email) {\n\tvar re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n\treturn re.test(email);\n}\n\n\nfunction md5cycle(x, k) {\n\tvar a = x[0],\n\t\tb = x[1],\n\t\tc = x[2],\n\t\td = x[3];\n\n\ta = ff(a, b, c, d, k[0], 7, -680876936);\n\td = ff(d, a, b, c, k[1], 12, -389564586);\n\tc = ff(c, d, a, b, k[2], 17, 606105819);\n\tb = ff(b, c, d, a, k[3], 22, -1044525330);\n\ta = ff(a, b, c, d, k[4], 7, -176418897);\n\td = ff(d, a, b, c, k[5], 12, 1200080426);\n\tc = ff(c, d, a, b, k[6], 17, -1473231341);\n\tb = ff(b, c, d, a, k[7], 22, -45705983);\n\ta = ff(a, b, c, d, k[8], 7, 1770035416);\n\td = ff(d, a, b, c, k[9], 12, -1958414417);\n\tc = ff(c, d, a, b, k[10], 17, -42063);\n\tb = ff(b, c, d, a, k[11], 22, -1990404162);\n\ta = ff(a, b, c, d, k[12], 7, 1804603682);\n\td = ff(d, a, b, c, k[13], 12, -40341101);\n\tc = ff(c, d, a, b, k[14], 17, -1502002290);\n\tb = ff(b, c, d, a, k[15], 22, 1236535329);\n\n\ta = gg(a, b, c, d, k[1], 5, -165796510);\n\td = gg(d, a, b, c, k[6], 9, -1069501632);\n\tc = gg(c, d, a, b, k[11], 14, 643717713);\n\tb = gg(b, c, d, a, k[0], 20, -373897302);\n\ta = gg(a, b, c, d, k[5], 5, -701558691);\n\td = gg(d, a, b, c, k[10], 9, 38016083);\n\tc = gg(c, d, a, b, k[15], 14, -660478335);\n\tb = gg(b, c, d, a, k[4], 20, -405537848);\n\ta = gg(a, b, c, d, k[9], 5, 568446438);\n\td = gg(d, a, b, c, k[14], 9, -1019803690);\n\tc = gg(c, d, a, b, k[3], 14, -187363961);\n\tb = gg(b, c, d, a, k[8], 20, 1163531501);\n\ta = gg(a, b, c, d, k[13], 5, -1444681467);\n\td = gg(d, a, b, c, k[2], 9, -51403784);\n\tc = gg(c, d, a, b, k[7], 14, 1735328473);\n\tb = gg(b, c, d, a, k[12], 20, -1926607734);\n\n\ta = hh(a, b, c, d, k[5], 4, -378558);\n\td = hh(d, a, b, c, k[8], 11, -2022574463);\n\tc = hh(c, d, a, b, k[11], 16, 1839030562);\n\tb = hh(b, c, d, a, k[14], 23, -35309556);\n\ta = hh(a, b, c, d, k[1], 4, -1530992060);\n\td = hh(d, a, b, c, k[4], 11, 1272893353);\n\tc = hh(c, d, a, b, k[7], 16, -155497632);\n\tb = hh(b, c, d, a, k[10], 23, -1094730640);\n\ta = hh(a, b, c, d, k[13], 4, 681279174);\n\td = hh(d, a, b, c, k[0], 11, -358537222);\n\tc = hh(c, d, a, b, k[3], 16, -722521979);\n\tb = hh(b, c, d, a, k[6], 23, 76029189);\n\ta = hh(a, b, c, d, k[9], 4, -640364487);\n\td = hh(d, a, b, c, k[12], 11, -421815835);\n\tc = hh(c, d, a, b, k[15], 16, 530742520);\n\tb = hh(b, c, d, a, k[2], 23, -995338651);\n\n\ta = ii(a, b, c, d, k[0], 6, -198630844);\n\td = ii(d, a, b, c, k[7], 10, 1126891415);\n\tc = ii(c, d, a, b, k[14], 15, -1416354905);\n\tb = ii(b, c, d, a, k[5], 21, -57434055);\n\ta = ii(a, b, c, d, k[12], 6, 1700485571);\n\td = ii(d, a, b, c, k[3], 10, -1894986606);\n\tc = ii(c, d, a, b, k[10], 15, -1051523);\n\tb = ii(b, c, d, a, k[1], 21, -2054922799);\n\ta = ii(a, b, c, d, k[8], 6, 1873313359);\n\td = ii(d, a, b, c, k[15], 10, -30611744);\n\tc = ii(c, d, a, b, k[6], 15, -1560198380);\n\tb = ii(b, c, d, a, k[13], 21, 1309151649);\n\ta = ii(a, b, c, d, k[4], 6, -145523070);\n\td = ii(d, a, b, c, k[11], 10, -1120210379);\n\tc = ii(c, d, a, b, k[2], 15, 718787259);\n\tb = ii(b, c, d, a, k[9], 21, -343485551);\n\n\tx[0] = add32(a, x[0]);\n\tx[1] = add32(b, x[1]);\n\tx[2] = add32(c, x[2]);\n\tx[3] = add32(d, x[3]);\n\n}\n\nfunction cmn(q, a, b, x, s, t) {\n\ta = add32(add32(a, q), add32(x, t));\n\treturn add32((a << s) | (a >>> (32 - s)), b);\n}\n\nfunction ff(a, b, c, d, x, s, t) {\n\treturn cmn((b & c) | ((~b) & d), a, b, x, s, t);\n}\n\nfunction gg(a, b, c, d, x, s, t) {\n\treturn cmn((b & d) | (c & (~d)), a, b, x, s, t);\n}\n\nfunction hh(a, b, c, d, x, s, t) {\n\treturn cmn(b ^ c ^ d, a, b, x, s, t);\n}\n\nfunction ii(a, b, c, d, x, s, t) {\n\treturn cmn(c ^ (b | (~d)), a, b, x, s, t);\n}\n\nfunction md51(s) {\n\tvar n = s.length,\n\t\tstate = [1732584193, -271733879, -1732584194, 271733878],\n\t\ti;\n\tfor (i = 64; i <= s.length; i += 64) {\n\t\tmd5cycle(state, md5blk(s.substring(i - 64, i)));\n\t}\n\ts = s.substring(i - 64);\n\tvar tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\tfor (i = 0; i < s.length; i++)\n\t\ttail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);\n\ttail[i >> 2] |= 0x80 << ((i % 4) << 3);\n\tif (i > 55) {\n\t\tmd5cycle(state, tail);\n\t\tfor (i = 0; i < 16; i++) tail[i] = 0;\n\t}\n\ttail[14] = n * 8;\n\tmd5cycle(state, tail);\n\treturn state;\n}\n\n/* there needs to be support for Unicode here,\n * unless we pretend that we can redefine the MD-5\n * algorithm for multi-byte characters (perhaps\n * by adding every four 16-bit characters and\n * shortening the sum to 32 bits). Otherwise\n * I suggest performing MD-5 as if every character\n * was two bytes--e.g., 0040 0025 = @%--but then\n * how will an ordinary MD-5 sum be matched?\n * There is no way to standardize text to something\n * like UTF-8 before transformation; speed cost is\n * utterly prohibitive. The JavaScript standard\n * itself needs to look at this: it should start\n * providing access to strings as preformed UTF-8\n * 8-bit unsigned value arrays.\n */\nfunction md5blk(s) { /* I figured global was faster.   */\n\tvar md5blks = [],\n\t\ti; /* Andy King said do it this way. */\n\tfor (i = 0; i < 64; i += 4) {\n\t\tmd5blks[i >> 2] = s.charCodeAt(i) +\n\t\t\t(s.charCodeAt(i + 1) << 8) +\n\t\t\t(s.charCodeAt(i + 2) << 16) +\n\t\t\t(s.charCodeAt(i + 3) << 24);\n\t}\n\treturn md5blks;\n}\n\nvar hex_chr = '0123456789abcdef'.split('');\n\nfunction rhex(n) {\n\tvar s = '',\n\t\tj = 0;\n\tfor (; j < 4; j++)\n\t\ts += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];\n\treturn s;\n}\n\nfunction hex(x) {\n\tfor (var i = 0; i < x.length; i++)\n\t\tx[i] = rhex(x[i]);\n\treturn x.join('');\n}\n\nfunction md5(s) {\n\treturn hex(md51(s));\n}\n\n/* this function is much faster,\nso if possible we use it. Some IEs\nare the only ones I know of that\nneed the idiotic second function,\ngenerated by an if clause.  */\n\nfunction add32(a, b) {\n\treturn (a + b) & 0xFFFFFFFF;\n}\n\nif (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {\n\tfunction add32(x, y) {\n\t\tvar lsw = (x & 0xFFFF) + (y & 0xFFFF),\n\t\t\tmsw = (x >> 16) + (y >> 16) + (lsw >> 16);\n\t\treturn (msw << 16) | (lsw & 0xFFFF);\n\t}\n}"
  },
  {
    "path": "public/scripts/setup.js",
    "content": "// setup.js\n$(function() {\n\n\tApp.init();\n\n});"
  },
  {
    "path": "public/scripts/table_helper.js",
    "content": "$(function() {\r\n\r\n\t$('body').append(\"<form id='table_helper_sort_form' method='post'><input type='hidden' name='order_by' value='id' id='table_helper_sort_column'></form>\");\r\n\t$('body').append(\"<form id='table_helper_search_form' method='post'><input type='hidden' name='q' value='id' id='table_helper_search'></form>\");\r\n\r\n});\r\n\r\nfunction sort(column) {\r\n\t$(\"#table_helper_sort_column\").val(column);\r\n\t$(\"#table_helper_sort_form\").submit();\r\n}\r\n\r\nfunction show_search() {\r\n\t$(\"#show_filter\").hide();\r\n\t$(\"#search_area\").show();\r\n}\r\n\r\nfunction do_search() {\r\n\t$(\"#table_helper_search\").val($(\"#search_q\").val());\r\n\t$(\"#table_helper_search_form\").submit();\r\n}\r\n\r\nfunction remove_search() {\r\n\t$(\"#search_q\").val(\"\");\r\n\tdo_search();\r\n}\r\n\r\n\r\nfunction remove_item(item_id) {\r\n\t$('#delete_item_modal_item_id').val(item_id);\r\n\t$('#delete_item_modal').modal({});\r\n}"
  },
  {
    "path": "tools/check_i18n_files.js",
    "content": "var fs = require('fs');\nvar path = require('path');\n\nvar i18n_dirname = path.join(__dirname, '..', 'data/i18n');\n\nfs.readdir(i18n_dirname, function(err, list) {\n\tlist.forEach(function(filename) {\n\n\t\tconsole.log('\\x1b[36m', 'i18n file:', '\\x1b[0m', filename);\n\n\t\tvar content = null;\n\t\ttry {\n\t\t\tcontent = \"\" + fs.readFileSync(path.join(i18n_dirname, filename), 'utf8');\n\t\t} catch (e) {\n\t\t\tconsole.log('\\x1b[31m', 'Error:', '\\x1b[0m', 'Can not open file. Permission denied');\n\t\t}\n\n\t\tif (content !== null) {\n\t\t\ttry {\n\t\t\t\tvar items = JSON.parse(content);\n\n\t\t\t\tvar items_count = 0;\n\t\t\t\tfor (var k in items) {\n\t\t\t\t\tif (items.hasOwnProperty(k)) {\n\t\t\t\t\t\titems_count++;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar strings_count = 'no strings';\n\n\t\t\t\tif (items_count == 1)\n\t\t\t\t\tstrings_count = '1 string';\n\t\t\t\telse if (items_count > 1)\n\t\t\t\t\tstrings_count = items_count + ' strings';\n\n\t\t\t\tconsole.log('\\x1b[36m', 'Valid:', '\\x1b[0m', strings_count);\n\n\t\t\t} catch (e) {\n\n\t\t\t\tconsole.log('\\x1b[31m', 'Error:', '\\x1b[0m', 'Invalid JSON format');\n\t\t\t\tconsole.log('NOT VALID');\n\t\t\t}\n\t\t}\n\t});\n});"
  },
  {
    "path": "tools/harvest_i18n_strings.js",
    "content": "var fs = require('fs');\nvar path = require('path');\n\nvar harvester = function(dirname, callback) {\n\n  var walk = function(dir, done) {\n    var results = [];\n    fs.readdir(dir, function(err, list) {\n      if (err) return done(err);\n      var i = 0;\n      (function next() {\n        var file = list[i++];\n        if (!file) return done(null, results);\n        file = dir + '/' + file;\n        fs.stat(file, function(err, stat) {\n          if (stat && stat.isDirectory()) {\n            walk(file, function(err, res) {\n              results = results.concat(res);\n              next();\n            });\n          } else {\n            results.push(file);\n            next();\n          }\n        });\n      })();\n    });\n  };\n\n  var foundItems = {};\n  var foundItemsCount = 0;\n\n  var parseFile = function(filename, transalateTag) {\n    transalateTag = transalateTag || 't';\n    var regex = new RegExp(\"\\{\" + transalateTag + \"\\}([^\\{]+)\\{\\/\" + transalateTag + \"\\}\", 'g');\n    var data = \"\" + fs.readFileSync(filename, 'utf8');\n    var matches = data.match(regex);\n\n    var openingTagLength = ('{' + transalateTag + '}').length;\n    var closingTag = '{/' + transalateTag + '}';\n    var closingTagLength = closingTag.length;\n\n    if (matches !== null)\n      matches.forEach(function(match) {\n        var string = '';\n        if (match.length > 7)\n          string = match.substr(openingTagLength, match.indexOf(closingTag) - openingTagLength);\n        else\n          return false;\n\n        if (typeof(foundItems[string]) == 'undefined') {\n          foundItems[string] = '';\n          foundItemsCount++;\n        }\n      });\n  };\n\n  var parseHTMLFile = function(filename) {\n    var regex = /data-i18n=\"([^\"]+)\"/g;\n    var data = \"\" + fs.readFileSync(filename, 'utf8');\n    var matches = data.match(regex);\n\n    if (matches !== null)\n      matches.forEach(function(match) {\n        var string = '';\n        if (match.length > 7)\n          string = match.substr((\"data-i18n=\\\"\").length, match.length - (\"data-i18n=\\\"\").length - 1);\n        else\n          return false;\n\n        if (typeof(foundItems[string]) == 'undefined') {\n          foundItems[string] = '';\n          foundItemsCount++;\n        }\n      });\n  };\n\n  walk(dirname, function(err, results) {\n\n    console.log('Found ' + results.length + ' files');\n    if (err) throw err;\n\n    var foundTplCount = 0;\n    var foundHtmlCount = 0;\n    results.forEach(function(file) {\n      if (file.slice(-4) === '.tpl') {\n        parseFile(file);\n        parseFile(file, 'ts');\n        parseFile(file, 'tp');\n        foundTplCount++;\n      }\n      if (file.slice(-5) === '.html' || file.slice(-4) === '.htm') {\n        parseHTMLFile(file);\n        foundHtmlCount++;\n      }\n    });\n\n    console.log('Found ' + foundTplCount + ' tpl files');\n    console.log('Found ' + foundHtmlCount + ' html files');\n    console.log('Found ' + foundItemsCount + ' i18n strings');\n\n    callback(Object.keys(foundItems));\n  });\n\n};\n\nvar dirname = path.join(__dirname, '..', 'public');\nvar i18n_dirname = path.join(__dirname, '..', 'data/i18n');\nharvester(dirname, function(strings) {\n  // console.log(strings);\n  var i18n_files = fs.readdirSync(i18n_dirname);\n  i18n_files.filter(function(file) {\n    if (file.slice(-5) !== '.json')\n      return false;\n    else\n      return true;\n  });\n\n  var updatei18n = function(i18n_file, strings) {\n    var data = {};\n    try {\n      data = JSON.parse(\"\" + fs.readFileSync(path.join(i18n_dirname, i18n_file), 'utf8'));\n    } catch (e) {\n\n    }\n\n    var newStringsCount = 0;\n\n    strings.forEach(function(string) {\n      if (typeof(data[string]) == 'undefined') {\n        data[string] = '';\n        newStringsCount++;\n      }\n    });\n\n    fs.writeFileSync(path.join(i18n_dirname, i18n_file), JSON.stringify(data, null, 2));\n\n    console.log('Updated. Added ' + newStringsCount + ' new strings.');\n  };\n\n  console.log(\"There're \" + i18n_files.length + ' i18n files');\n  // console.log(i18n_files);\n  // console.log(strings);\n\n  i18n_files.forEach(function(i18n_file) {\n    console.log('Updating ' + i18n_file);\n    updatei18n(i18n_file, strings);\n  });\n\n  console.log('Done');\n\n});"
  }
]