├── .gitignore ├── public ├── templates │ └── card.html ├── assets │ ├── 404.gif │ ├── graph.png │ ├── help.gif │ ├── love.gif │ ├── lucas.jpg │ ├── charles.png │ ├── loader.gif │ ├── logoblue.png │ ├── logowhite.png │ ├── lucasfinal.jpg │ ├── lucasfinal-1.jpg │ ├── venmonavlogo.png │ ├── venmonavlogo2.jpg │ └── venmonavlogo2.png ├── font │ ├── roboto │ │ ├── Roboto-Bold.ttf │ │ ├── Roboto-Bold.woff │ │ ├── Roboto-Light.ttf │ │ ├── Roboto-Thin.ttf │ │ ├── Roboto-Thin.woff │ │ ├── Roboto-Bold.woff2 │ │ ├── Roboto-Light.woff │ │ ├── Roboto-Light.woff2 │ │ ├── Roboto-Medium.ttf │ │ ├── Roboto-Medium.woff │ │ ├── Roboto-Medium.woff2 │ │ ├── Roboto-Regular.ttf │ │ ├── Roboto-Regular.woff │ │ ├── Roboto-Thin.woff2 │ │ └── Roboto-Regular.woff2 │ └── material-design-icons │ │ ├── Material-Design-Icons.eot │ │ ├── Material-Design-Icons.ttf │ │ ├── Material-Design-Icons.woff │ │ ├── Material-Design-Icons.woff2 │ │ └── LICENSE.txt ├── css │ ├── splash.css │ ├── custom.css │ └── chartist.min.css ├── pages │ ├── login.html │ └── app.html └── js │ ├── app.js │ ├── helpers │ ├── require.js │ └── backbone.stickit.js │ └── chartist.min.js ├── app ├── config │ ├── database.js │ └── passport.js ├── models │ └── user.js └── routes.js ├── README.md ├── package.json └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /public/templates/card.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/assets/404.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/404.gif -------------------------------------------------------------------------------- /public/assets/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/graph.png -------------------------------------------------------------------------------- /public/assets/help.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/help.gif -------------------------------------------------------------------------------- /public/assets/love.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/love.gif -------------------------------------------------------------------------------- /public/assets/lucas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/lucas.jpg -------------------------------------------------------------------------------- /public/assets/charles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/charles.png -------------------------------------------------------------------------------- /public/assets/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/loader.gif -------------------------------------------------------------------------------- /public/assets/logoblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/logoblue.png -------------------------------------------------------------------------------- /public/assets/logowhite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/logowhite.png -------------------------------------------------------------------------------- /public/assets/lucasfinal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/lucasfinal.jpg -------------------------------------------------------------------------------- /public/assets/lucasfinal-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/lucasfinal-1.jpg -------------------------------------------------------------------------------- /public/assets/venmonavlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/venmonavlogo.png -------------------------------------------------------------------------------- /app/config/database.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 3 | 'url' : 'mongodb://127.0.0.1:27017/data/db' 4 | 5 | }; 6 | -------------------------------------------------------------------------------- /public/assets/venmonavlogo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/venmonavlogo2.jpg -------------------------------------------------------------------------------- /public/assets/venmonavlogo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/assets/venmonavlogo2.png -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Bold.ttf -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Bold.woff -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Light.ttf -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Thin.ttf -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Thin.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Thin.woff -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Bold.woff2 -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Light.woff -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Light.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Light.woff2 -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Medium.ttf -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Medium.woff -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Medium.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Medium.woff2 -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Regular.ttf -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Regular.woff -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Thin.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Thin.woff2 -------------------------------------------------------------------------------- /public/font/roboto/Roboto-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/roboto/Roboto-Regular.woff2 -------------------------------------------------------------------------------- /public/font/material-design-icons/Material-Design-Icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/material-design-icons/Material-Design-Icons.eot -------------------------------------------------------------------------------- /public/font/material-design-icons/Material-Design-Icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/material-design-icons/Material-Design-Icons.ttf -------------------------------------------------------------------------------- /public/font/material-design-icons/Material-Design-Icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/material-design-icons/Material-Design-Icons.woff -------------------------------------------------------------------------------- /public/font/material-design-icons/Material-Design-Icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sup/venmo-dash/master/public/font/material-design-icons/Material-Design-Icons.woff2 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # venmo-dash 2 | Dashboard and augmented functions including future and scheduled payments with Venmo. Won the Braintree/Paypal prize at Hack The Planet. 3 | 4 | ![LucasBros](http://i.imgur.com/izsjlzP.png) 5 | -------------------------------------------------------------------------------- /public/css/splash.css: -------------------------------------------------------------------------------- 1 | .page-container { 2 | background-image: url('../assets/lucasfinal-1.jpg'); 3 | height: 100vh; 4 | width: 100vw; 5 | background-size: cover; 6 | } 7 | 8 | #login { 9 | position: absolute; 10 | top: 30rem; 11 | left: 20rem; 12 | background-color: white; 13 | border-color: #3D95CE; 14 | border-width: 2px; 15 | border-style: solid; 16 | color: #3D95CE; 17 | border-radius: 5px; 18 | } 19 | -------------------------------------------------------------------------------- /app/models/user.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | 3 | var userSchema = mongoose.Schema({ 4 | name: { 5 | type: String, 6 | required: true 7 | }, 8 | email: String, 9 | username: { 10 | type: String, 11 | unique: true 12 | }, 13 | balance: String, 14 | provider: String, 15 | salt: String, 16 | venmo: {}, 17 | access_token: String, 18 | refresh_token: String, 19 | uid: String, 20 | profilePic: String, 21 | dateJoined: String 22 | }); 23 | 24 | module.exports = mongoose.model('User', userSchema); 25 | -------------------------------------------------------------------------------- /public/pages/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | Login with Venmo 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "venmo-dash", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/charleslai/venmo-dash" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/charleslai/venmo-dash/issues" 17 | }, 18 | "homepage": "https://github.com/charleslai/venmo-dash", 19 | "dependencies": { 20 | "async": "^1.4.2", 21 | "body-parser": "^1.13.3", 22 | "cookie-parser": "^1.3.5", 23 | "express": "^4.13.3", 24 | "express-session": "^1.11.3", 25 | "mongoose": "^4.1.2", 26 | "morgan": "^1.6.1", 27 | "passport": "^0.2.2", 28 | "request": "^2.60.0", 29 | "passport-venmo": "0.0.1", 30 | "node-schedule": "~0.2.9" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var mongoose = require('mongoose'); 4 | var morgan = require('morgan'); 5 | var bodyParser = require('body-parser'); 6 | var cookieParser = require('cookie-parser'); 7 | var session = require('express-session'); 8 | var passport = require('passport'); 9 | var request = require('request'); 10 | var async = require('async'); 11 | var cron = require('node-schedule'); 12 | 13 | var configDB = require('./app/config/database.js'); 14 | mongoose.connect(configDB.url); 15 | 16 | require('./app/config/passport.js')(passport); 17 | 18 | app.set('port', (process.env.PORT || 3000)); 19 | app.use(morgan('dev')); 20 | app.use(express.static('./public')); 21 | app.use(cookieParser()); 22 | app.use(bodyParser.json()); 23 | app.use(session({ 24 | secret: 'hacktheplanet', 25 | resave: false, 26 | saveUninitialized: true 27 | })); 28 | 29 | app.use(passport.initialize()); 30 | app.use(passport.session()); 31 | 32 | require('./app/routes.js')(app, request, async, passport, cron); 33 | 34 | app.listen(app.get('port'), function() { 35 | console.log("listening on port: "+app.get('port')); 36 | }); 37 | -------------------------------------------------------------------------------- /app/config/passport.js: -------------------------------------------------------------------------------- 1 | var VenmoStrategy = require('passport-venmo').Strategy; 2 | var User = require('../models/user'); 3 | 4 | var VENMO_CLIENT_ID = process.env.VENMO_CLIENT_ID; 5 | var VENMO_CLIENT_SECRET = process.env.VENMO_CLIENT_SECRET; 6 | 7 | module.exports = function(passport) { 8 | 9 | passport.serializeUser(function(user, done) { 10 | done(null, user.id); 11 | }); 12 | 13 | passport.deserializeUser(function(id, done) { 14 | User.findById(id, function(err, user) { 15 | done(err, user); 16 | }); 17 | }); 18 | 19 | console.log("CLIENT_ID= "+VENMO_CLIENT_ID); 20 | console.log("CLIENT_SECRET= "+VENMO_CLIENT_SECRET); 21 | 22 | passport.use(new VenmoStrategy({ 23 | clientID: VENMO_CLIENT_ID, 24 | clientSecret: VENMO_CLIENT_SECRET, 25 | callbackURL: "http://venmo-dash.me/auth/venmo/callback" 26 | }, function(accessToken, refreshToken, venmo, done) { 27 | console.log("Trying to find User"); 28 | User.findOne({ 29 | 'venmo.id': venmo.id 30 | }, function(err, user) { 31 | if (err) { 32 | console.log("error"); 33 | return done(err); 34 | } 35 | if(!user) { 36 | console.log("USER NOT FOUND"); 37 | user = new User({ 38 | name: venmo.displayName, 39 | username: venmo.username, 40 | email: venmo.email, 41 | provider: 'venmo', 42 | venmo: venmo._json, 43 | balance: venmo.balance, 44 | access_token: accessToken, 45 | refresh_token: refreshToken, 46 | uid: venmo.id, 47 | profileUrl: venmo.profile_picture_url, 48 | dataJoined: venmo.date_joined 49 | }); 50 | user.save(function(err) { 51 | if (err) console.log(err); 52 | return done(err, user); 53 | }); 54 | } else { 55 | console.log("USER FOUND UPDATING"); 56 | user.balance = venmo.balance; 57 | user.access_token = accessToken; 58 | user.uid = venmo.id; 59 | user.save(); 60 | user.venmo = venmo._json; 61 | return done(err, user); 62 | } 63 | }); 64 | } 65 | )); 66 | 67 | }; 68 | -------------------------------------------------------------------------------- /public/css/custom.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-image: url('../assets/graph.png'); 3 | } 4 | 5 | .sr-only { 6 | font-size: 15px; 7 | } 8 | 9 | .ct-label { 10 | font-size: 15px; 11 | } 12 | 13 | .green-background { 14 | background-color: #C7F464; 15 | } 16 | 17 | .collapsible-header:hover { 18 | color: grey; 19 | } 20 | 21 | .username { 22 | font-size: 18px; 23 | } 24 | 25 | .user_id { 26 | color: #99a7a7; 27 | } 28 | 29 | .progress { 30 | margin-bottom: 0px; 31 | } 32 | 33 | #maincard .username { 34 | margin-top: 0px; 35 | margin-bottom: 0px; 36 | font-size: 32px; 37 | } 38 | 39 | .email { 40 | color: #99a7a7; 41 | font-size: 22px; 42 | } 43 | 44 | .collapsible-body { 45 | background-color: white; 46 | } 47 | 48 | .balance { 49 | font-size: 55px; 50 | } 51 | 52 | #pay { 53 | margin-left: 75%; 54 | } 55 | 56 | #card-grid .card-panel .row { 57 | margin-bottom: 0px; 58 | } 59 | 60 | .card-panel { 61 | box-shadow: none; 62 | } 63 | 64 | #maincardcontent { 65 | margin-bottom: 0px; 66 | } 67 | 68 | .avatar-div { 69 | padding: 0 0 0 0; 70 | } 71 | 72 | .avatar { 73 | border-radius: 5px 74 | } 75 | 76 | #maincard { 77 | margin-top: 1.5rem; 78 | } 79 | 80 | nav { 81 | background-color: #3D95CE; 82 | } 83 | 84 | .green-font { 85 | color: #5cb85c; 86 | } 87 | 88 | #search { 89 | margin-top: 0; 90 | margin-left: 0; 91 | margin-bottom: 0; 92 | margin-right: 60px; 93 | } 94 | 95 | .ct-series-b .ct-slice-donut { 96 | /* give the donut slice a custom colour */ 97 | stroke: #C7F464 !important; 98 | /* customize stroke width of the donut slices in CSS. Note that this property is already set in JavaScript and label positioning also relies on this. In the right situation though it can be very useful to style this property. You need to use !important to override the style attribute */ 99 | stroke-width: 40px !important; 100 | } 101 | 102 | .ct-series-a .ct-slice-donut { 103 | /* give the donut slice a custom colour */ 104 | stroke: #FF6B6B !important; 105 | /* customize stroke width of the donut slices in CSS. Note that this property is already set in JavaScript and label positioning also relies on this. In the right situation though it can be very useful to style this property. You need to use !important to override the style attribute */ 106 | stroke-width: 40px !important; 107 | } 108 | 109 | 110 | 111 | /* Bootstrap Progress Bars */ 112 | @-webkit-keyframes progress-bar-stripes { 113 | from { 114 | background-position: 40px 0; 115 | } 116 | to { 117 | background-position: 0 0; 118 | } 119 | } 120 | @-o-keyframes progress-bar-stripes { 121 | from { 122 | background-position: 40px 0; 123 | } 124 | to { 125 | background-position: 0 0; 126 | } 127 | } 128 | @keyframes progress-bar-stripes { 129 | from { 130 | background-position: 40px 0; 131 | } 132 | to { 133 | background-position: 0 0; 134 | } 135 | } 136 | .progress { 137 | height: 20px; 138 | margin-bottom: 20px; 139 | overflow: hidden; 140 | background-color: #f5f5f5; 141 | border-radius: 4px; 142 | -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); 143 | box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); 144 | } 145 | .progress-bar { 146 | float: left; 147 | width: 0; 148 | height: 100%; 149 | font-size: 10px; 150 | line-height: 20px; 151 | color: #fff; 152 | text-align: center; 153 | background-color: #337ab7; 154 | -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); 155 | box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15); 156 | -webkit-transition: width .6s ease; 157 | -o-transition: width .6s ease; 158 | transition: width .6s ease; 159 | } 160 | .progress-striped .progress-bar, 161 | .progress-bar-striped { 162 | background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 163 | background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 164 | background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 165 | -webkit-background-size: 40px 40px; 166 | background-size: 40px 40px; 167 | } 168 | .progress.active .progress-bar, 169 | .progress-bar.active { 170 | -webkit-animation: progress-bar-stripes 2s linear infinite; 171 | -o-animation: progress-bar-stripes 2s linear infinite; 172 | animation: progress-bar-stripes 2s linear infinite; 173 | } 174 | .progress-bar-success { 175 | background-color: #C7F464; 176 | } 177 | .progress-striped .progress-bar-success { 178 | background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 179 | background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 180 | background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 181 | } 182 | .progress-bar-info { 183 | background-color: #5bc0de; 184 | } 185 | .progress-striped .progress-bar-info { 186 | background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 187 | background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 188 | background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 189 | } 190 | .progress-bar-warning { 191 | background-color: #f0ad4e; 192 | } 193 | .progress-striped .progress-bar-warning { 194 | background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 195 | background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 196 | background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 197 | } 198 | .progress-bar-danger { 199 | background-color: #FF6B6B; 200 | } 201 | .progress-striped .progress-bar-danger { 202 | background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 203 | background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 204 | background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent); 205 | } 206 | 207 | 208 | -------------------------------------------------------------------------------- /public/js/app.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | var ProfileCard = Backbone.Model.extend({}); 4 | 5 | var InputModel = Backbone.Model.extend({ 6 | initialize: function() { 7 | console.log(this); 8 | } 9 | }); 10 | 11 | var ModalView = Backbone.View.extend({ 12 | 13 | el: $('#main-view-anchor'), 14 | 15 | tagName: 'div', 16 | 17 | template: '', 18 | 19 | initialize: function() { 20 | this.render(); 21 | }, 22 | 23 | render: function() { 24 | this.$el.append(this.template); 25 | } 26 | 27 | }); 28 | 29 | var ProfileView = Backbone.View.extend({ 30 | 31 | el: $('#card-grid'), 32 | 33 | tagName: 'div', 34 | 35 | template: '
{{profile.display_name}}
ID: {{profile.id}}
${{graph.payed}}
${{graph.charged}}
', 36 | 37 | initialize: function() { 38 | this.render(); 39 | }, 40 | 41 | render: function() { 42 | this.$el.append((Mustache.render(this.template, this.model.toJSON()))); 43 | return this; 44 | }, 45 | 46 | hide: function() { 47 | $('#'+this.model.attributes.profile.username).hide(); 48 | }, 49 | 50 | show: function() { 51 | $('#'+this.model.attributes.profile.username).show(); 52 | } 53 | 54 | }); 55 | 56 | var MainView = Backbone.View.extend({ 57 | 58 | el: $('#main-view-anchor'), 59 | 60 | template: '

{{profile.venmo.display_name}}

${{profile.balance}}
', 61 | 62 | initialize: function() { 63 | console.log(this.model); 64 | this.render(); 65 | var graph_data = this.model.toJSON().graph; 66 | new Chartist.Pie('.ct-chart', { 67 | series: [graph_data.payed, graph_data.charged], 68 | labels: ["$"+graph_data.payed.toFixed(2), "$"+graph_data.charged.toFixed(2)], 69 | }, { 70 | donut: true, 71 | donutWidth: 35, 72 | }); 73 | }, 74 | 75 | render: function() { 76 | // TODO MAKE THIS.MODEL.TOJSON() 77 | this.$el.append((Mustache.render(this.template, this.model.toJSON()))); 78 | //var graph_data = this.model.toJSON().graph; 79 | return this; 80 | }, 81 | 82 | }); 83 | 84 | ProfileCollection = Backbone.Collection.extend({ 85 | comparator: function(model) { 86 | var paid = model.attributes.graph.charged + model.attributes.graph.payed; 87 | return -paid 88 | } 89 | }); 90 | 91 | var profileCollection = new ProfileCollection(); 92 | 93 | ProfileCollectionView = Backbone.View.extend({ 94 | 95 | collection: null, 96 | 97 | viewCollection: null, 98 | 99 | el: 'body', 100 | 101 | bindings: { 102 | '#search': 'inputVal' 103 | }, 104 | 105 | initialize: function() { 106 | this.model = new InputModel({}); 107 | this.listenTo(this.model, { 108 | 'change:inputVal': this.updateText 109 | }); 110 | this.inputVal = $('#search').val(); 111 | this.stickit(); 112 | }, 113 | 114 | updateText: function(e) { 115 | console.log("updatedText"); 116 | this.inputVal = $('#search').val(); 117 | this.filter(); 118 | }, 119 | 120 | render: function() { 121 | var viewCollection = []; 122 | this.collection.forEach(function(item) { 123 | var view = new ProfileView({model: item}); 124 | viewCollection.push(view); 125 | }); 126 | this.viewCollection = viewCollection; 127 | }, 128 | 129 | filter: function() { 130 | var inputValue = this.inputVal.toLowerCase(); 131 | this.viewCollection.forEach(function(item) { 132 | var username = item.model.attributes.profile.display_name.toLowerCase(); 133 | if(username.indexOf(inputValue) > -1 || username.length === 0) { 134 | item.show(); 135 | } else { 136 | item.hide(); 137 | } 138 | }); 139 | } 140 | }); 141 | 142 | 143 | $.ajax({ 144 | type: "GET", 145 | url: "/profile" 146 | }) 147 | .done(function(body) { 148 | var MainCard = new ProfileCard(body); 149 | var MainCardView = new MainView({model: MainCard}); 150 | // Update graph with graph data 151 | //var modalView = new ModalView({model: {}}); 152 | 153 | $.ajax({ 154 | type: "GET", 155 | url: "/friends" 156 | }) 157 | .done(function(body) { 158 | var data = body; 159 | console.log(body); 160 | for(var i in data) { 161 | var profileCard = new ProfileCard(data[i]); 162 | profileCollection.add(profileCard); 163 | } 164 | console.log(profileCollection); 165 | profileCollection.sort(); 166 | var profileCollectionView = new ProfileCollectionView({collection: profileCollection}); 167 | profileCollectionView.render(); 168 | }) 169 | .fail(function() { 170 | console.log("FAILED"); 171 | }); 172 | }) 173 | .fail(function() { 174 | console.log("PROFILE FAILED"); 175 | }); 176 | 177 | }); 178 | -------------------------------------------------------------------------------- /app/routes.js: -------------------------------------------------------------------------------- 1 | module.exports = function(app, request, async, passport, cron) { 2 | 3 | app.get('/', isLoggedIn, function(req, res) { 4 | res.sendfile('public/pages/app.html'); 5 | }); 6 | 7 | app.get('/login', function(req, res) { 8 | res.sendfile('public/pages/login.html'); 9 | }); 10 | 11 | app.get('/logout', function(req, res) { 12 | req.logout(); 13 | res.redirect('/'); 14 | }); 15 | 16 | app.get('/auth/venmo', passport.authenticate('venmo', { scope: [ 17 | 'make_payments', 18 | 'access_payment_history', 19 | 'access_feed', 20 | 'access_profile', 21 | 'access_email', 22 | 'access_phone', 23 | 'access_balance', 24 | 'access_friends' 25 | ]})); 26 | 27 | app.get('/auth/venmo/callback', 28 | passport.authenticate('venmo', { failureRedirect: '/login'}), 29 | function(req, res) { 30 | res.redirect('/'); 31 | }); 32 | 33 | app.get('/friends', isLoggedIn, function(req, res) { 34 | getFriendsList(req.user.uid, req.user.access_token, function(error, friendsList) { 35 | getPayHistoryFriendsList(req.user.access_token, friendsList, function(error, newFriendsList) { 36 | res.send(newFriendsList); 37 | }); 38 | }); 39 | }); 40 | 41 | app.get('/profile', isLoggedIn, function(req, res) { 42 | payHistory(req.user.access_token, req.user.username, function(error, data) { 43 | var user = req.user; 44 | var profileData = { 45 | profile: user, 46 | graph: data 47 | }; 48 | res.send(profileData); 49 | }); 50 | }); 51 | 52 | app.post('/payment', isLoggedIn, function(req, res) { 53 | var body = req.body; 54 | console.log("PAYMENT BODY="+JSON.stringify(req.body)); 55 | var user_id = body.user_id; 56 | var note = body.note; 57 | var amount= body.amount; 58 | var date = body.date; 59 | var time = body.time; //assume time in hh:mm:ss 60 | var social = body.social ? 'public' : 'private'; 61 | 62 | if (!date) { 63 | pay(req.user.access_token, user_id, note, amount, social); 64 | res.status(200).send('{}'); 65 | } else { 66 | // Parse date to create date object 67 | var datearr = date.split("-"); 68 | var timearr = time.split(":"); 69 | var dateobj = new Date(datearr[0], datearr[1], datearr[2], timearr[0], timearr[1], timearr[2]); 70 | cron.scheduleJob(dateobj, function(){ 71 | pay(req.user.access_token, user_id, note, amount, social); 72 | }); 73 | res.status(200).send('{}'); 74 | } 75 | }); 76 | 77 | app.post('/recurrence', isLoggedIn, function(req, res) { 78 | var body = req.body; 79 | console.log("PAYMENT BODY="+JSON.stringify(req.body)); 80 | var user_id = body.user_id; 81 | var note = body.note; 82 | var amount= body.amount; 83 | var date = body.date; 84 | var time = body.time; //assume time in hh:mm:ss 85 | var social = body.social ? 'public' : 'private'; 86 | 87 | if (!date) { 88 | pay(req.user.access_token, user_id, note, amount, social); 89 | res.status(200).send('{}'); 90 | } else { 91 | // Parse date to create date object 92 | var datearr = date.split("-"); 93 | var timearr = time.split(":"); 94 | var rule = new cron.RecurrenceRule(); 95 | rule.month = int(timearr[1])-1; 96 | rule.hour = int(timearr[0]); 97 | rule.minute = int(timearr[1]); 98 | rule.second = int(timearr[2]); 99 | cron.scheduleJob(dateobj, function(){ 100 | pay(req.user.access_token, user_id, note, amount, social); 101 | }); 102 | res.status(200).send('{}'); 103 | } 104 | }); 105 | 106 | function pay(userToken, user_id, note, amount, social) { 107 | var venmoUrl = 'https://api.venmo.com/v1/payments?access_token='+userToken+'&user_id='+user_id+'¬e='+note+'&amount='+amount+'&audience='+social; 108 | 109 | var options = { 110 | url: venmoUrl 111 | }; 112 | console.log("Payment URL "+venmoUrl); 113 | request.post(options, function(error, response, body) { 114 | if (!error) { 115 | console.log(response); 116 | console.log("PAYMENT CREATED"); 117 | console.log(body); 118 | }; 119 | }); 120 | }; 121 | 122 | 123 | function getFriendsList(userId, userToken, callback) { 124 | var venmoUrl = 'https://api.venmo.com/v1/users/'+userId+'/friends?access_token='+userToken+'&limit=300'; 125 | var options = { 126 | url: venmoUrl 127 | }; 128 | console.log("venmoUrl="+venmoUrl); 129 | console.log("User Token="+userToken); 130 | 131 | request.get(options, function(error, response, body) { 132 | if (!error) { 133 | //console.log("BODY= "+body); 134 | var bodyData = JSON.parse(body); 135 | console.log("WE AMDE IT TO THE REQ "+bodyData); 136 | callback(error, bodyData); 137 | } 138 | }); 139 | }; 140 | 141 | function getPayHistoryFriendsList(userToken, friendsList, callback) { 142 | var venmoUrl ='https://api.venmo.com/v1/payments?access_token='+userToken+'&limit=1000'; 143 | var options = { 144 | url: venmoUrl 145 | }; 146 | var newFriendsList = []; 147 | 148 | request.get(options, function(error, response, body) { 149 | if(!error) { 150 | var bodyData = JSON.parse(body); 151 | for(var i in friendsList.data) { 152 | var friendPayed = 0; 153 | var friendCharged = 0; 154 | var friend = friendsList.data[i]; 155 | console.log("FRIEND= "+ JSON.stringify(friend)); 156 | console.log("FRIEND USERNAME= "+friend.username); 157 | for (var z in bodyData.data) { 158 | if(bodyData.data[z].status === "settled" || bodyData.data[z].status === "pending") { 159 | if (bodyData.data[z].action === "pay") { 160 | if (bodyData.data[z].target.user.username === friend.username) { 161 | friendCharged += bodyData.data[z].amount; 162 | } else if (bodyData.data[z].actor.username === friend.username) { 163 | friendPayed += bodyData.data[z].amount; 164 | } 165 | } else if (bodyData.data[z].action === "charge") { 166 | if (bodyData.data[z].target.user.username === friend.username) { 167 | friendPayed += bodyData.data[z].amount; 168 | } else if (bodyData.data[z].actor.username === friend.username) { 169 | friendCharged += bodyData.data[z].amount; 170 | } 171 | } 172 | } 173 | } 174 | var friend = { 175 | profile: friend, 176 | graph: { 177 | payed: friendPayed, 178 | charged: friendCharged, 179 | payedPercent: friendPayed / (friendCharged + friendPayed) * 100, 180 | chargedPercent: friendCharged / (friendCharged + friendPayed) * 100 181 | } 182 | }; 183 | newFriendsList.push(friend); 184 | } 185 | callback(error, newFriendsList); 186 | } 187 | }); 188 | }; 189 | 190 | function payHistory(userToken, username, callback) { 191 | var venmoUrl ='https://api.venmo.com/v1/payments?access_token='+userToken+'&limit=1000'; 192 | var options = { 193 | url: venmoUrl 194 | }; 195 | var charged = 0; 196 | var payed = 0; 197 | 198 | console.log("URL: "+venmoUrl); 199 | console.log("Before request to payment"); 200 | request.get(options, function(error, response, body) { 201 | if (!error) { 202 | var bodyData = JSON.parse(body); 203 | console.log("BODY COUNT="+bodyData.data.count); 204 | for(var i in bodyData.data) { 205 | if(bodyData.data[i].status === "settled" || bodyData.data[i].status === "pending") { 206 | if (bodyData.data[i].action === "pay") { 207 | if (bodyData.data[i].actor.username != username) { 208 | charged += bodyData.data[i].amount; 209 | } else { 210 | payed += bodyData.data[i].amount; 211 | } 212 | } else if (bodyData.data[i].action === "charge") { 213 | if (bodyData.data[i].actor.username != username) { 214 | payed += bodyData.data[i].amount; 215 | } else { 216 | charged += bodyData.data[i].amount; 217 | } 218 | } 219 | } 220 | } 221 | var results = { 222 | charged: charged, 223 | payed: payed 224 | }; 225 | callback(error, results); 226 | } 227 | }); 228 | }; 229 | 230 | function isLoggedIn(req, res, next) { 231 | if (req.isAuthenticated()) { 232 | return next(); 233 | } 234 | res.redirect('/login'); 235 | }; 236 | }; 237 | -------------------------------------------------------------------------------- /public/css/chartist.min.css: -------------------------------------------------------------------------------- 1 | .ct-double-octave:after,.ct-major-eleventh:after,.ct-major-second:after,.ct-major-seventh:after,.ct-major-sixth:after,.ct-major-tenth:after,.ct-major-third:after,.ct-major-twelfth:after,.ct-minor-second:after,.ct-minor-seventh:after,.ct-minor-sixth:after,.ct-minor-third:after,.ct-octave:after,.ct-perfect-fifth:after,.ct-perfect-fourth:after,.ct-square:after{content:"";clear:both}.ct-double-octave:after,.ct-double-octave:before,.ct-golden-section:after,.ct-major-eleventh:after,.ct-major-eleventh:before,.ct-major-second:after,.ct-major-second:before,.ct-major-seventh:after,.ct-major-seventh:before,.ct-major-sixth:after,.ct-major-sixth:before,.ct-major-tenth:after,.ct-major-tenth:before,.ct-major-third:after,.ct-major-third:before,.ct-major-twelfth:after,.ct-major-twelfth:before,.ct-minor-second:after,.ct-minor-second:before,.ct-minor-seventh:after,.ct-minor-seventh:before,.ct-minor-sixth:after,.ct-minor-sixth:before,.ct-minor-third:after,.ct-minor-third:before,.ct-octave:after,.ct-octave:before,.ct-perfect-fifth:after,.ct-perfect-fifth:before,.ct-perfect-fourth:after,.ct-perfect-fourth:before,.ct-square:after,.ct-square:before{content:""}.ct-label{fill:rgba(0,0,0,.4);color:rgba(0,0,0,.4);font-size:.75rem;line-height:1}.ct-chart-bar .ct-label,.ct-chart-line .ct-label{display:block;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex}.ct-label.ct-horizontal.ct-start{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-ms-flex-align:flex-end;align-items:flex-end;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:flex-start;justify-content:flex-start;text-align:left;text-anchor:start}.ct-label.ct-horizontal.ct-end{-webkit-box-align:flex-start;-webkit-align-items:flex-start;-ms-flex-align:flex-start;align-items:flex-start;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:flex-start;justify-content:flex-start;text-align:left;text-anchor:start}.ct-label.ct-vertical.ct-start{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-ms-flex-align:flex-end;align-items:flex-end;-webkit-box-pack:flex-end;-webkit-justify-content:flex-end;-ms-flex-pack:flex-end;justify-content:flex-end;text-align:right;text-anchor:end}.ct-label.ct-vertical.ct-end{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-ms-flex-align:flex-end;align-items:flex-end;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:flex-start;justify-content:flex-start;text-align:left;text-anchor:start}.ct-chart-bar .ct-label.ct-horizontal.ct-start{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-ms-flex-align:flex-end;align-items:flex-end;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;text-anchor:start}.ct-chart-bar .ct-label.ct-horizontal.ct-end{-webkit-box-align:flex-start;-webkit-align-items:flex-start;-ms-flex-align:flex-start;align-items:flex-start;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;text-anchor:start}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-horizontal.ct-start{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-ms-flex-align:flex-end;align-items:flex-end;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:flex-start;justify-content:flex-start;text-align:left;text-anchor:start}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-horizontal.ct-end{-webkit-box-align:flex-start;-webkit-align-items:flex-start;-ms-flex-align:flex-start;align-items:flex-start;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:flex-start;justify-content:flex-start;text-align:left;text-anchor:start}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-vertical.ct-start{-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:flex-end;-webkit-justify-content:flex-end;-ms-flex-pack:flex-end;justify-content:flex-end;text-align:right;text-anchor:end}.ct-chart-bar.ct-horizontal-bars .ct-label.ct-vertical.ct-end{-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-ms-flex-pack:flex-start;justify-content:flex-start;text-align:left;text-anchor:end}.ct-grid{stroke:rgba(0,0,0,.2);stroke-width:1px;stroke-dasharray:2px}.ct-point{stroke-width:10px;stroke-linecap:round}.ct-line{fill:none;stroke-width:4px}.ct-area{stroke:none;fill-opacity:.1}.ct-bar{fill:none;stroke-width:10px}.ct-slice-donut{fill:none;stroke-width:60px}.ct-series-a .ct-bar,.ct-series-a .ct-line,.ct-series-a .ct-point,.ct-series-a .ct-slice-donut{stroke:#d70206}.ct-series-a .ct-area,.ct-series-a .ct-slice-pie{fill:#d70206}.ct-series-b .ct-bar,.ct-series-b .ct-line,.ct-series-b .ct-point,.ct-series-b .ct-slice-donut{stroke:#f05b4f}.ct-series-b .ct-area,.ct-series-b .ct-slice-pie{fill:#f05b4f}.ct-series-c .ct-bar,.ct-series-c .ct-line,.ct-series-c .ct-point,.ct-series-c .ct-slice-donut{stroke:#f4c63d}.ct-series-c .ct-area,.ct-series-c .ct-slice-pie{fill:#f4c63d}.ct-series-d .ct-bar,.ct-series-d .ct-line,.ct-series-d .ct-point,.ct-series-d .ct-slice-donut{stroke:#d17905}.ct-series-d .ct-area,.ct-series-d .ct-slice-pie{fill:#d17905}.ct-series-e .ct-bar,.ct-series-e .ct-line,.ct-series-e .ct-point,.ct-series-e .ct-slice-donut{stroke:#453d3f}.ct-series-e .ct-area,.ct-series-e .ct-slice-pie{fill:#453d3f}.ct-series-f .ct-bar,.ct-series-f .ct-line,.ct-series-f .ct-point,.ct-series-f .ct-slice-donut{stroke:#59922b}.ct-series-f .ct-area,.ct-series-f .ct-slice-pie{fill:#59922b}.ct-series-g .ct-bar,.ct-series-g .ct-line,.ct-series-g .ct-point,.ct-series-g .ct-slice-donut{stroke:#0544d3}.ct-series-g .ct-area,.ct-series-g .ct-slice-pie{fill:#0544d3}.ct-series-h .ct-bar,.ct-series-h .ct-line,.ct-series-h .ct-point,.ct-series-h .ct-slice-donut{stroke:#6b0392}.ct-series-h .ct-area,.ct-series-h .ct-slice-pie{fill:#6b0392}.ct-series-i .ct-bar,.ct-series-i .ct-line,.ct-series-i .ct-point,.ct-series-i .ct-slice-donut{stroke:#f05b4f}.ct-series-i .ct-area,.ct-series-i .ct-slice-pie{fill:#f05b4f}.ct-series-j .ct-bar,.ct-series-j .ct-line,.ct-series-j .ct-point,.ct-series-j .ct-slice-donut{stroke:#dda458}.ct-series-j .ct-area,.ct-series-j .ct-slice-pie{fill:#dda458}.ct-series-k .ct-bar,.ct-series-k .ct-line,.ct-series-k .ct-point,.ct-series-k .ct-slice-donut{stroke:#eacf7d}.ct-series-k .ct-area,.ct-series-k .ct-slice-pie{fill:#eacf7d}.ct-series-l .ct-bar,.ct-series-l .ct-line,.ct-series-l .ct-point,.ct-series-l .ct-slice-donut{stroke:#86797d}.ct-series-l .ct-area,.ct-series-l .ct-slice-pie{fill:#86797d}.ct-series-m .ct-bar,.ct-series-m .ct-line,.ct-series-m .ct-point,.ct-series-m .ct-slice-donut{stroke:#b2c326}.ct-series-m .ct-area,.ct-series-m .ct-slice-pie{fill:#b2c326}.ct-series-n .ct-bar,.ct-series-n .ct-line,.ct-series-n .ct-point,.ct-series-n .ct-slice-donut{stroke:#6188e2}.ct-series-n .ct-area,.ct-series-n .ct-slice-pie{fill:#6188e2}.ct-series-o .ct-bar,.ct-series-o .ct-line,.ct-series-o .ct-point,.ct-series-o .ct-slice-donut{stroke:#a748ca}.ct-series-o .ct-area,.ct-series-o .ct-slice-pie{fill:#a748ca}.ct-square{display:block;position:relative;width:100%}.ct-square:before{display:block;float:left;width:0;height:0;padding-bottom:100%}.ct-square:after{display:table}.ct-square>svg{display:block;position:absolute;top:0;left:0}.ct-minor-second{display:block;position:relative;width:100%}.ct-minor-second:before{display:block;float:left;width:0;height:0;padding-bottom:93.75%}.ct-minor-second:after{display:table}.ct-minor-second>svg{display:block;position:absolute;top:0;left:0}.ct-major-second{display:block;position:relative;width:100%}.ct-major-second:before{display:block;float:left;width:0;height:0;padding-bottom:88.8888888889%}.ct-major-second:after{display:table}.ct-major-second>svg{display:block;position:absolute;top:0;left:0}.ct-minor-third{display:block;position:relative;width:100%}.ct-minor-third:before{display:block;float:left;width:0;height:0;padding-bottom:83.3333333333%}.ct-minor-third:after{display:table}.ct-minor-third>svg{display:block;position:absolute;top:0;left:0}.ct-major-third{display:block;position:relative;width:100%}.ct-major-third:before{display:block;float:left;width:0;height:0;padding-bottom:80%}.ct-major-third:after{display:table}.ct-major-third>svg{display:block;position:absolute;top:0;left:0}.ct-perfect-fourth{display:block;position:relative;width:100%}.ct-perfect-fourth:before{display:block;float:left;width:0;height:0;padding-bottom:75%}.ct-perfect-fourth:after{display:table}.ct-perfect-fourth>svg{display:block;position:absolute;top:0;left:0}.ct-perfect-fifth{display:block;position:relative;width:100%}.ct-perfect-fifth:before{display:block;float:left;width:0;height:0;padding-bottom:66.6666666667%}.ct-perfect-fifth:after{display:table}.ct-perfect-fifth>svg{display:block;position:absolute;top:0;left:0}.ct-minor-sixth{display:block;position:relative;width:100%}.ct-minor-sixth:before{display:block;float:left;width:0;height:0;padding-bottom:62.5%}.ct-minor-sixth:after{display:table}.ct-minor-sixth>svg{display:block;position:absolute;top:0;left:0}.ct-golden-section{display:block;position:relative;width:100%}.ct-golden-section:before{display:block;float:left;content:"";width:0;height:0;padding-bottom:61.804697157%}.ct-golden-section:after{display:table;clear:both}.ct-golden-section>svg{display:block;position:absolute;top:0;left:0}.ct-major-sixth{display:block;position:relative;width:100%}.ct-major-sixth:before{display:block;float:left;width:0;height:0;padding-bottom:60%}.ct-major-sixth:after{display:table}.ct-major-sixth>svg{display:block;position:absolute;top:0;left:0}.ct-minor-seventh{display:block;position:relative;width:100%}.ct-minor-seventh:before{display:block;float:left;width:0;height:0;padding-bottom:56.25%}.ct-minor-seventh:after{display:table}.ct-minor-seventh>svg{display:block;position:absolute;top:0;left:0}.ct-major-seventh{display:block;position:relative;width:100%}.ct-major-seventh:before{display:block;float:left;width:0;height:0;padding-bottom:53.3333333333%}.ct-major-seventh:after{display:table}.ct-major-seventh>svg{display:block;position:absolute;top:0;left:0}.ct-octave{display:block;position:relative;width:100%}.ct-octave:before{display:block;float:left;width:0;height:0;padding-bottom:50%}.ct-octave:after{display:table}.ct-octave>svg{display:block;position:absolute;top:0;left:0}.ct-major-tenth{display:block;position:relative;width:100%}.ct-major-tenth:before{display:block;float:left;width:0;height:0;padding-bottom:40%}.ct-major-tenth:after{display:table}.ct-major-tenth>svg{display:block;position:absolute;top:0;left:0}.ct-major-eleventh{display:block;position:relative;width:100%}.ct-major-eleventh:before{display:block;float:left;width:0;height:0;padding-bottom:37.5%}.ct-major-eleventh:after{display:table}.ct-major-eleventh>svg{display:block;position:absolute;top:0;left:0}.ct-major-twelfth{display:block;position:relative;width:100%}.ct-major-twelfth:before{display:block;float:left;width:0;height:0;padding-bottom:33.3333333333%}.ct-major-twelfth:after{display:table}.ct-major-twelfth>svg{display:block;position:absolute;top:0;left:0}.ct-double-octave{display:block;position:relative;width:100%}.ct-double-octave:before{display:block;float:left;width:0;height:0;padding-bottom:25%}.ct-double-octave:after{display:table}.ct-double-octave>svg{display:block;position:absolute;top:0;left:0} -------------------------------------------------------------------------------- /public/js/helpers/require.js: -------------------------------------------------------------------------------- 1 | /* 2 | RequireJS 2.1.18 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved. 3 | Available via the MIT or new BSD license. 4 | see: http://github.com/jrburke/requirejs for details 5 | */ 6 | var requirejs,require,define; 7 | (function(ba){function G(b){return"[object Function]"===K.call(b)}function H(b){return"[object Array]"===K.call(b)}function v(b,c){if(b){var d;for(d=0;dthis.depCount&&!this.defined){if(G(l)){if(this.events.error&&this.map.isDefine||g.onError!==ca)try{f=i.execCb(c,l,b,f)}catch(d){a=d}else f=i.execCb(c,l,b,f);this.map.isDefine&&void 0===f&&((b=this.module)?f=b.exports:this.usingExports&& 19 | (f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=l;this.exports=f;if(this.map.isDefine&&!this.ignore&&(r[c]=f,g.onResourceLoad))g.onResourceLoad(i,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a= 20 | this.map,b=a.id,d=p(a.prefix);this.depMaps.push(d);q(d,"defined",u(this,function(f){var l,d;d=m(aa,this.map.id);var e=this.map.name,P=this.map.parentMap?this.map.parentMap.name:null,n=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(e=f.normalize(e,function(a){return c(a,P,!0)})||""),f=p(a.prefix+"!"+e,this.map.parentMap),q(f,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=m(h,f.id)){this.depMaps.push(f); 21 | if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else d?(this.map.url=i.nameToUrl(d),this.load()):(l=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),l.error=u(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(h,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),l.fromText=u(this,function(f,c){var d=a.name,e=p(d),P=M;c&&(f=c);P&&(M=!1);s(e);t(j.config,b)&&(j.config[d]=j.config[b]);try{g.exec(f)}catch(h){return w(C("fromtexteval", 22 | "fromText eval for "+b+" failed: "+h,h,[b]))}P&&(M=!0);this.depMaps.push(e);i.completeLoad(d);n([d],l)}),f.load(a.name,n,l,j))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){V[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,u(this,function(a,b){var c,f;if("string"===typeof a){a=p(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(L,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",u(this,function(a){this.undefed|| 23 | (this.defineDep(b,a),this.check())}));this.errback?q(a,"error",u(this,this.errback)):this.events.error&&q(a,"error",u(this,function(a){this.emit("error",a)}))}c=a.id;f=h[c];!t(L,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,u(this,function(a){var b=m(h,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}}; 24 | i={config:j,contextName:b,registry:h,defined:r,urlFetched:S,defQueue:A,Module:Z,makeModuleMap:p,nextTick:g.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(j[b]||(j[b]={}),U(j[b],a,!0,!0)):j[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(aa[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn= 25 | i.makeShimExports(a);b[c]=a}),j.shim=b);a.packages&&v(a.packages,function(a){var b,a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(j.paths[b]=a.location);j.pkgs[b]=a.name+"/"+(a.main||"main").replace(ia,"").replace(Q,"")});B(h,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=p(b,null,!0))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a, 26 | e){function j(c,d,m){var n,q;e.enableBuildCallback&&(d&&G(d))&&(d.__requireJsBuild=!0);if("string"===typeof c){if(G(d))return w(C("requireargs","Invalid require call"),m);if(a&&t(L,c))return L[c](h[a.id]);if(g.get)return g.get(i,c,a,j);n=p(c,a,!1,!0);n=n.id;return!t(r,n)?w(C("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[n]}J();i.nextTick(function(){J();q=s(p(null,a));q.skipMap=e.skipMap;q.init(c,d,m,{enabled:!0});D()});return j}e=e||{};U(j, 27 | {isBrowser:z,toUrl:function(b){var d,e=b.lastIndexOf("."),k=b.split("/")[0];if(-1!==e&&(!("."===k||".."===k)||1e.attachEvent.toString().indexOf("[native code"))&&!Y?(M=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=d,J=e,D?y.insertBefore(e,D):y.appendChild(e),J=null,e;if(ea)try{importScripts(d),b.completeLoad(c)}catch(m){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,m,[c]))}};z&&!q.skipDataMain&&T(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(I=b.getAttribute("data-main"))return s= 35 | I,q.baseUrl||(E=s.split("/"),s=E.pop(),O=E.length?E.join("/")+"/":"./",q.baseUrl=O),s=s.replace(Q,""),g.jsExtRegExp.test(s)&&(s=I),q.deps=q.deps?q.deps.concat(s):[s],!0});define=function(b,c,d){var e,g;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(ka,"").replace(la,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(M){if(!(e=J))N&&"interactive"===N.readyState||T(document.getElementsByTagName("script"), 36 | function(b){if("interactive"===b.readyState)return N=b}),e=N;e&&(b||(b=e.getAttribute("data-requiremodule")),g=F[e.getAttribute("data-requirecontext")])}(g?g.defQueue:R).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(q)}})(this); 37 | -------------------------------------------------------------------------------- /public/pages/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 41 | 42 | 43 |
44 |
45 | 46 | 64 | 65 | 66 |
    67 |
  • 68 |
    paymentSchedule Payments and Charges
    69 |
    70 |
    71 |
    72 |
    73 |
    Scheduled Payment/Charge
    74 |
    75 |
    76 |
    77 |
    78 | 79 | 80 |
    81 |
    82 | 83 | 84 |
    85 |
    86 | 87 |
    88 |
    89 | 90 | 91 |
    92 |
    93 | 94 | 95 |
    96 |
    97 |
    98 | 104 |
    105 |
    106 |
    107 | Pay 108 | Charge 109 |
    110 |
    111 |
    112 |
    113 |
  • 114 |
  • 115 |
    replayRecurring Payments and Charges
    116 |
    117 |
    118 |
    119 |
    120 |
    Recurring Payment/Charge
    121 |
    122 |
    123 |
    124 |
    125 | 126 | 127 |
    128 |
    129 | 130 | 131 |
    132 |
    133 | 134 |
    135 |
    136 | 137 | 138 |
    139 |
    140 | 141 | 142 |
    143 |
    144 |
    145 | 151 |
    152 |
    153 |
    154 | Pay 155 | Charge 156 |
    157 |
    158 |
    159 |
    160 |
  • 161 |
162 |
163 | 164 | 204 | 249 | 250 |
251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 403 | 404 | 405 | 406 | -------------------------------------------------------------------------------- /public/font/material-design-icons/LICENSE.txt: -------------------------------------------------------------------------------- 1 | https://github.com/google/material-design-icons/blob/master/LICENSE 2 | https://github.com/FezVrasta/bootstrap-material-design/blob/master/fonts/LICENSE.txt 3 | 4 | Attribution-ShareAlike 4.0 International 5 | 6 | ======================================================================= 7 | 8 | Creative Commons Corporation ("Creative Commons") is not a law firm and 9 | does not provide legal services or legal advice. Distribution of 10 | Creative Commons public licenses does not create a lawyer-client or 11 | other relationship. Creative Commons makes its licenses and related 12 | information available on an "as-is" basis. Creative Commons gives no 13 | warranties regarding its licenses, any material licensed under their 14 | terms and conditions, or any related information. Creative Commons 15 | disclaims all liability for damages resulting from their use to the 16 | fullest extent possible. 17 | 18 | Using Creative Commons Public Licenses 19 | 20 | Creative Commons public licenses provide a standard set of terms and 21 | conditions that creators and other rights holders may use to share 22 | original works of authorship and other material subject to copyright 23 | and certain other rights specified in the public license below. The 24 | following considerations are for informational purposes only, are not 25 | exhaustive, and do not form part of our licenses. 26 | 27 | Considerations for licensors: Our public licenses are 28 | intended for use by those authorized to give the public 29 | permission to use material in ways otherwise restricted by 30 | copyright and certain other rights. Our licenses are 31 | irrevocable. Licensors should read and understand the terms 32 | and conditions of the license they choose before applying it. 33 | Licensors should also secure all rights necessary before 34 | applying our licenses so that the public can reuse the 35 | material as expected. Licensors should clearly mark any 36 | material not subject to the license. This includes other CC- 37 | licensed material, or material used under an exception or 38 | limitation to copyright. More considerations for licensors: 39 | wiki.creativecommons.org/Considerations_for_licensors 40 | 41 | Considerations for the public: By using one of our public 42 | licenses, a licensor grants the public permission to use the 43 | licensed material under specified terms and conditions. If 44 | the licensor's permission is not necessary for any reason--for 45 | example, because of any applicable exception or limitation to 46 | copyright--then that use is not regulated by the license. Our 47 | licenses grant only permissions under copyright and certain 48 | other rights that a licensor has authority to grant. Use of 49 | the licensed material may still be restricted for other 50 | reasons, including because others have copyright or other 51 | rights in the material. A licensor may make special requests, 52 | such as asking that all changes be marked or described. 53 | Although not required by our licenses, you are encouraged to 54 | respect those requests where reasonable. More_considerations 55 | for the public: 56 | wiki.creativecommons.org/Considerations_for_licensees 57 | 58 | ======================================================================= 59 | 60 | Creative Commons Attribution-ShareAlike 4.0 International Public 61 | License 62 | 63 | By exercising the Licensed Rights (defined below), You accept and agree 64 | to be bound by the terms and conditions of this Creative Commons 65 | Attribution-ShareAlike 4.0 International Public License ("Public 66 | License"). To the extent this Public License may be interpreted as a 67 | contract, You are granted the Licensed Rights in consideration of Your 68 | acceptance of these terms and conditions, and the Licensor grants You 69 | such rights in consideration of benefits the Licensor receives from 70 | making the Licensed Material available under these terms and 71 | conditions. 72 | 73 | 74 | Section 1 -- Definitions. 75 | 76 | a. Adapted Material means material subject to Copyright and Similar 77 | Rights that is derived from or based upon the Licensed Material 78 | and in which the Licensed Material is translated, altered, 79 | arranged, transformed, or otherwise modified in a manner requiring 80 | permission under the Copyright and Similar Rights held by the 81 | Licensor. For purposes of this Public License, where the Licensed 82 | Material is a musical work, performance, or sound recording, 83 | Adapted Material is always produced where the Licensed Material is 84 | synched in timed relation with a moving image. 85 | 86 | b. Adapter's License means the license You apply to Your Copyright 87 | and Similar Rights in Your contributions to Adapted Material in 88 | accordance with the terms and conditions of this Public License. 89 | 90 | c. BY-SA Compatible License means a license listed at 91 | creativecommons.org/compatiblelicenses, approved by Creative 92 | Commons as essentially the equivalent of this Public License. 93 | 94 | d. Copyright and Similar Rights means copyright and/or similar rights 95 | closely related to copyright including, without limitation, 96 | performance, broadcast, sound recording, and Sui Generis Database 97 | Rights, without regard to how the rights are labeled or 98 | categorized. For purposes of this Public License, the rights 99 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 100 | Rights. 101 | 102 | e. Effective Technological Measures means those measures that, in the 103 | absence of proper authority, may not be circumvented under laws 104 | fulfilling obligations under Article 11 of the WIPO Copyright 105 | Treaty adopted on December 20, 1996, and/or similar international 106 | agreements. 107 | 108 | f. Exceptions and Limitations means fair use, fair dealing, and/or 109 | any other exception or limitation to Copyright and Similar Rights 110 | that applies to Your use of the Licensed Material. 111 | 112 | g. License Elements means the license attributes listed in the name 113 | of a Creative Commons Public License. The License Elements of this 114 | Public License are Attribution and ShareAlike. 115 | 116 | h. Licensed Material means the artistic or literary work, database, 117 | or other material to which the Licensor applied this Public 118 | License. 119 | 120 | i. Licensed Rights means the rights granted to You subject to the 121 | terms and conditions of this Public License, which are limited to 122 | all Copyright and Similar Rights that apply to Your use of the 123 | Licensed Material and that the Licensor has authority to license. 124 | 125 | j. Licensor means the individual(s) or entity(ies) granting rights 126 | under this Public License. 127 | 128 | k. Share means to provide material to the public by any means or 129 | process that requires permission under the Licensed Rights, such 130 | as reproduction, public display, public performance, distribution, 131 | dissemination, communication, or importation, and to make material 132 | available to the public including in ways that members of the 133 | public may access the material from a place and at a time 134 | individually chosen by them. 135 | 136 | l. Sui Generis Database Rights means rights other than copyright 137 | resulting from Directive 96/9/EC of the European Parliament and of 138 | the Council of 11 March 1996 on the legal protection of databases, 139 | as amended and/or succeeded, as well as other essentially 140 | equivalent rights anywhere in the world. 141 | 142 | m. You means the individual or entity exercising the Licensed Rights 143 | under this Public License. Your has a corresponding meaning. 144 | 145 | 146 | Section 2 -- Scope. 147 | 148 | a. License grant. 149 | 150 | 1. Subject to the terms and conditions of this Public License, 151 | the Licensor hereby grants You a worldwide, royalty-free, 152 | non-sublicensable, non-exclusive, irrevocable license to 153 | exercise the Licensed Rights in the Licensed Material to: 154 | 155 | a. reproduce and Share the Licensed Material, in whole or 156 | in part; and 157 | 158 | b. produce, reproduce, and Share Adapted Material. 159 | 160 | 2. Exceptions and Limitations. For the avoidance of doubt, where 161 | Exceptions and Limitations apply to Your use, this Public 162 | License does not apply, and You do not need to comply with 163 | its terms and conditions. 164 | 165 | 3. Term. The term of this Public License is specified in Section 166 | 6(a). 167 | 168 | 4. Media and formats; technical modifications allowed. The 169 | Licensor authorizes You to exercise the Licensed Rights in 170 | all media and formats whether now known or hereafter created, 171 | and to make technical modifications necessary to do so. The 172 | Licensor waives and/or agrees not to assert any right or 173 | authority to forbid You from making technical modifications 174 | necessary to exercise the Licensed Rights, including 175 | technical modifications necessary to circumvent Effective 176 | Technological Measures. For purposes of this Public License, 177 | simply making modifications authorized by this Section 2(a) 178 | (4) never produces Adapted Material. 179 | 180 | 5. Downstream recipients. 181 | 182 | a. Offer from the Licensor -- Licensed Material. Every 183 | recipient of the Licensed Material automatically 184 | receives an offer from the Licensor to exercise the 185 | Licensed Rights under the terms and conditions of this 186 | Public License. 187 | 188 | b. Additional offer from the Licensor -- Adapted Material. 189 | Every recipient of Adapted Material from You 190 | automatically receives an offer from the Licensor to 191 | exercise the Licensed Rights in the Adapted Material 192 | under the conditions of the Adapter's License You apply. 193 | 194 | c. No downstream restrictions. You may not offer or impose 195 | any additional or different terms or conditions on, or 196 | apply any Effective Technological Measures to, the 197 | Licensed Material if doing so restricts exercise of the 198 | Licensed Rights by any recipient of the Licensed 199 | Material. 200 | 201 | 6. No endorsement. Nothing in this Public License constitutes or 202 | may be construed as permission to assert or imply that You 203 | are, or that Your use of the Licensed Material is, connected 204 | with, or sponsored, endorsed, or granted official status by, 205 | the Licensor or others designated to receive attribution as 206 | provided in Section 3(a)(1)(A)(i). 207 | 208 | b. Other rights. 209 | 210 | 1. Moral rights, such as the right of integrity, are not 211 | licensed under this Public License, nor are publicity, 212 | privacy, and/or other similar personality rights; however, to 213 | the extent possible, the Licensor waives and/or agrees not to 214 | assert any such rights held by the Licensor to the limited 215 | extent necessary to allow You to exercise the Licensed 216 | Rights, but not otherwise. 217 | 218 | 2. Patent and trademark rights are not licensed under this 219 | Public License. 220 | 221 | 3. To the extent possible, the Licensor waives any right to 222 | collect royalties from You for the exercise of the Licensed 223 | Rights, whether directly or through a collecting society 224 | under any voluntary or waivable statutory or compulsory 225 | licensing scheme. In all other cases the Licensor expressly 226 | reserves any right to collect such royalties. 227 | 228 | 229 | Section 3 -- License Conditions. 230 | 231 | Your exercise of the Licensed Rights is expressly made subject to the 232 | following conditions. 233 | 234 | a. Attribution. 235 | 236 | 1. If You Share the Licensed Material (including in modified 237 | form), You must: 238 | 239 | a. retain the following if it is supplied by the Licensor 240 | with the Licensed Material: 241 | 242 | i. identification of the creator(s) of the Licensed 243 | Material and any others designated to receive 244 | attribution, in any reasonable manner requested by 245 | the Licensor (including by pseudonym if 246 | designated); 247 | 248 | ii. a copyright notice; 249 | 250 | iii. a notice that refers to this Public License; 251 | 252 | iv. a notice that refers to the disclaimer of 253 | warranties; 254 | 255 | v. a URI or hyperlink to the Licensed Material to the 256 | extent reasonably practicable; 257 | 258 | b. indicate if You modified the Licensed Material and 259 | retain an indication of any previous modifications; and 260 | 261 | c. indicate the Licensed Material is licensed under this 262 | Public License, and include the text of, or the URI or 263 | hyperlink to, this Public License. 264 | 265 | 2. You may satisfy the conditions in Section 3(a)(1) in any 266 | reasonable manner based on the medium, means, and context in 267 | which You Share the Licensed Material. For example, it may be 268 | reasonable to satisfy the conditions by providing a URI or 269 | hyperlink to a resource that includes the required 270 | information. 271 | 272 | 3. If requested by the Licensor, You must remove any of the 273 | information required by Section 3(a)(1)(A) to the extent 274 | reasonably practicable. 275 | 276 | b. ShareAlike. 277 | 278 | In addition to the conditions in Section 3(a), if You Share 279 | Adapted Material You produce, the following conditions also apply. 280 | 281 | 1. The Adapter's License You apply must be a Creative Commons 282 | license with the same License Elements, this version or 283 | later, or a BY-SA Compatible License. 284 | 285 | 2. You must include the text of, or the URI or hyperlink to, the 286 | Adapter's License You apply. You may satisfy this condition 287 | in any reasonable manner based on the medium, means, and 288 | context in which You Share Adapted Material. 289 | 290 | 3. You may not offer or impose any additional or different terms 291 | or conditions on, or apply any Effective Technological 292 | Measures to, Adapted Material that restrict exercise of the 293 | rights granted under the Adapter's License You apply. 294 | 295 | 296 | Section 4 -- Sui Generis Database Rights. 297 | 298 | Where the Licensed Rights include Sui Generis Database Rights that 299 | apply to Your use of the Licensed Material: 300 | 301 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 302 | to extract, reuse, reproduce, and Share all or a substantial 303 | portion of the contents of the database; 304 | 305 | b. if You include all or a substantial portion of the database 306 | contents in a database in which You have Sui Generis Database 307 | Rights, then the database in which You have Sui Generis Database 308 | Rights (but not its individual contents) is Adapted Material, 309 | 310 | including for purposes of Section 3(b); and 311 | c. You must comply with the conditions in Section 3(a) if You Share 312 | all or a substantial portion of the contents of the database. 313 | 314 | For the avoidance of doubt, this Section 4 supplements and does not 315 | replace Your obligations under this Public License where the Licensed 316 | Rights include other Copyright and Similar Rights. 317 | 318 | 319 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 320 | 321 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 322 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 323 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 324 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 325 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 326 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 327 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 328 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 329 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 330 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 331 | 332 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 333 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 334 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 335 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 336 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 337 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 338 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 339 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 340 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 341 | 342 | c. The disclaimer of warranties and limitation of liability provided 343 | above shall be interpreted in a manner that, to the extent 344 | possible, most closely approximates an absolute disclaimer and 345 | waiver of all liability. 346 | 347 | 348 | Section 6 -- Term and Termination. 349 | 350 | a. This Public License applies for the term of the Copyright and 351 | Similar Rights licensed here. However, if You fail to comply with 352 | this Public License, then Your rights under this Public License 353 | terminate automatically. 354 | 355 | b. Where Your right to use the Licensed Material has terminated under 356 | Section 6(a), it reinstates: 357 | 358 | 1. automatically as of the date the violation is cured, provided 359 | it is cured within 30 days of Your discovery of the 360 | violation; or 361 | 362 | 2. upon express reinstatement by the Licensor. 363 | 364 | For the avoidance of doubt, this Section 6(b) does not affect any 365 | right the Licensor may have to seek remedies for Your violations 366 | of this Public License. 367 | 368 | c. For the avoidance of doubt, the Licensor may also offer the 369 | Licensed Material under separate terms or conditions or stop 370 | distributing the Licensed Material at any time; however, doing so 371 | will not terminate this Public License. 372 | 373 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 374 | License. 375 | 376 | 377 | Section 7 -- Other Terms and Conditions. 378 | 379 | a. The Licensor shall not be bound by any additional or different 380 | terms or conditions communicated by You unless expressly agreed. 381 | 382 | b. Any arrangements, understandings, or agreements regarding the 383 | Licensed Material not stated herein are separate from and 384 | independent of the terms and conditions of this Public License. 385 | 386 | 387 | Section 8 -- Interpretation. 388 | 389 | a. For the avoidance of doubt, this Public License does not, and 390 | shall not be interpreted to, reduce, limit, restrict, or impose 391 | conditions on any use of the Licensed Material that could lawfully 392 | be made without permission under this Public License. 393 | 394 | b. To the extent possible, if any provision of this Public License is 395 | deemed unenforceable, it shall be automatically reformed to the 396 | minimum extent necessary to make it enforceable. If the provision 397 | cannot be reformed, it shall be severed from this Public License 398 | without affecting the enforceability of the remaining terms and 399 | conditions. 400 | 401 | c. No term or condition of this Public License will be waived and no 402 | failure to comply consented to unless expressly agreed to by the 403 | Licensor. 404 | 405 | d. Nothing in this Public License constitutes or may be interpreted 406 | as a limitation upon, or waiver of, any privileges and immunities 407 | that apply to the Licensor or You, including from the legal 408 | processes of any jurisdiction or authority. 409 | 410 | 411 | ======================================================================= 412 | 413 | Creative Commons is not a party to its public licenses. 414 | Notwithstanding, Creative Commons may elect to apply one of its public 415 | licenses to material it publishes and in those instances will be 416 | considered the "Licensor." Except for the limited purpose of indicating 417 | that material is shared under a Creative Commons public license or as 418 | otherwise permitted by the Creative Commons policies published at 419 | creativecommons.org/policies, Creative Commons does not authorize the 420 | use of the trademark "Creative Commons" or any other trademark or logo 421 | of Creative Commons without its prior written consent including, 422 | without limitation, in connection with any unauthorized modifications 423 | to any of its public licenses or any other arrangements, 424 | understandings, or agreements concerning use of licensed material. For 425 | the avoidance of doubt, this paragraph does not form part of the public 426 | licenses. 427 | 428 | Creative Commons may be contacted at creativecommons.org. 429 | -------------------------------------------------------------------------------- /public/js/helpers/backbone.stickit.js: -------------------------------------------------------------------------------- 1 | // Backbone.Stickit v0.9.2, MIT Licensed 2 | // Copyright (c) 2012-2015 The New York Times, CMS Group, Matthew DeLambo 3 | 4 | (function (factory) { 5 | 6 | // Set up Stickit appropriately for the environment. Start with AMD. 7 | if (typeof define === 'function' && define.amd) 8 | define(['underscore', 'backbone', 'exports'], factory); 9 | 10 | // Next for Node.js or CommonJS. 11 | else if (typeof exports === 'object') 12 | factory(require('underscore'), require('backbone'), exports); 13 | 14 | // Finally, as a browser global. 15 | else 16 | factory(_, Backbone, {}); 17 | 18 | }(function (_, Backbone, Stickit) { 19 | 20 | // Stickit Namespace 21 | // -------------------------- 22 | 23 | // Export onto Backbone object 24 | Backbone.Stickit = Stickit; 25 | 26 | Stickit._handlers = []; 27 | 28 | Stickit.addHandler = function(handlers) { 29 | // Fill-in default values. 30 | handlers = _.map(_.flatten([handlers]), function(handler) { 31 | return _.defaults({}, handler, { 32 | updateModel: true, 33 | updateView: true, 34 | updateMethod: 'text' 35 | }); 36 | }); 37 | this._handlers = this._handlers.concat(handlers); 38 | }; 39 | 40 | // Backbone.View Mixins 41 | // -------------------- 42 | 43 | Stickit.ViewMixin = { 44 | 45 | // Collection of model event bindings. 46 | // [{model,event,fn,config}, ...] 47 | _modelBindings: null, 48 | 49 | // Unbind the model and event bindings from `this._modelBindings` and 50 | // `this.$el`. If the optional `model` parameter is defined, then only 51 | // delete bindings for the given `model` and its corresponding view events. 52 | unstickit: function(model, bindingSelector) { 53 | 54 | // Support passing a bindings hash in place of bindingSelector. 55 | if (_.isObject(bindingSelector)) { 56 | _.each(bindingSelector, function(v, selector) { 57 | this.unstickit(model, selector); 58 | }, this); 59 | return; 60 | } 61 | 62 | var models = [], destroyFns = []; 63 | this._modelBindings = _.reject(this._modelBindings, function(binding) { 64 | if (model && binding.model !== model) return; 65 | if (bindingSelector && binding.config.selector != bindingSelector) return; 66 | 67 | binding.model.off(binding.event, binding.fn); 68 | destroyFns.push(binding.config._destroy); 69 | models.push(binding.model); 70 | return true; 71 | }); 72 | 73 | // Trigger an event for each model that was unbound. 74 | _.invoke(_.uniq(models), 'trigger', 'stickit:unstuck', this.cid); 75 | 76 | // Call `_destroy` on a unique list of the binding callbacks. 77 | _.each(_.uniq(destroyFns), function(fn) { fn.call(this); }, this); 78 | 79 | this.$el.off('.stickit' + (model ? '.' + model.cid : ''), bindingSelector); 80 | }, 81 | 82 | // Initilize Stickit bindings for the view. Subsequent binding additions 83 | // can either call `stickit` with the new bindings, or add them directly 84 | // with `addBinding`. Both arguments to `stickit` are optional. 85 | stickit: function(optionalModel, optionalBindingsConfig) { 86 | var model = optionalModel || this.model, 87 | bindings = optionalBindingsConfig || _.result(this, "bindings") || {}; 88 | 89 | this._modelBindings || (this._modelBindings = []); 90 | 91 | // Add bindings in bulk using `addBinding`. 92 | this.addBinding(model, bindings); 93 | 94 | // Wrap `view.remove` to unbind stickit model and dom events. 95 | var remove = this.remove; 96 | if (!remove.stickitWrapped) { 97 | this.remove = function() { 98 | var ret = this; 99 | this.unstickit(); 100 | if (remove) ret = remove.apply(this, arguments); 101 | return ret; 102 | }; 103 | } 104 | this.remove.stickitWrapped = true; 105 | return this; 106 | }, 107 | 108 | // Add a single Stickit binding or a hash of bindings to the model. If 109 | // `optionalModel` is ommitted, will default to the view's `model` property. 110 | addBinding: function(optionalModel, selector, binding) { 111 | var model = optionalModel || this.model, 112 | namespace = '.stickit.' + model.cid; 113 | 114 | binding = binding || {}; 115 | 116 | // Support jQuery-style {key: val} event maps. 117 | if (_.isObject(selector)) { 118 | var bindings = selector; 119 | _.each(bindings, function(val, key) { 120 | this.addBinding(model, key, val); 121 | }, this); 122 | return; 123 | } 124 | 125 | // Special case the ':el' selector to use the view's this.$el. 126 | var $el = selector === ':el' ? this.$el : this.$(selector); 127 | 128 | // Clear any previous matching bindings. 129 | this.unstickit(model, selector); 130 | 131 | // Fail fast if the selector didn't match an element. 132 | if (!$el.length) return; 133 | 134 | // Allow shorthand setting of model attributes - `'selector':'observe'`. 135 | if (_.isString(binding)) binding = {observe: binding}; 136 | 137 | // Handle case where `observe` is in the form of a function. 138 | if (_.isFunction(binding.observe)) binding.observe = binding.observe.call(this); 139 | 140 | // Find all matching Stickit handlers that could apply to this element 141 | // and store in a config object. 142 | var config = getConfiguration($el, binding); 143 | 144 | // The attribute we're observing in our config. 145 | var modelAttr = config.observe; 146 | 147 | // Store needed properties for later. 148 | config.selector = selector; 149 | config.view = this; 150 | 151 | // Create the model set options with a unique `bindId` so that we 152 | // can avoid double-binding in the `change:attribute` event handler. 153 | var bindId = config.bindId = _.uniqueId(); 154 | 155 | // Add a reference to the view for handlers of stickitChange events 156 | var options = _.extend({stickitChange: config}, config.setOptions); 157 | 158 | // Add a `_destroy` callback to the configuration, in case `destroy` 159 | // is a named function and we need a unique function when unsticking. 160 | config._destroy = function() { 161 | applyViewFn.call(this, config.destroy, $el, model, config); 162 | }; 163 | 164 | initializeAttributes($el, config, model, modelAttr); 165 | initializeVisible($el, config, model, modelAttr); 166 | initializeClasses($el, config, model, modelAttr); 167 | 168 | if (modelAttr) { 169 | // Setup one-way (input element -> model) bindings. 170 | _.each(config.events, function(type) { 171 | var eventName = type + namespace; 172 | var listener = function(event) { 173 | var val = applyViewFn.call(this, config.getVal, $el, event, config, slice.call(arguments, 1)); 174 | 175 | // Don't update the model if false is returned from the `updateModel` configuration. 176 | var currentVal = evaluateBoolean(config.updateModel, val, event, config); 177 | if (currentVal) setAttr(model, modelAttr, val, options, config); 178 | }; 179 | var sel = selector === ':el'? '' : selector; 180 | this.$el.on(eventName, sel, _.bind(listener, this)); 181 | }, this); 182 | 183 | // Setup a `change:modelAttr` observer to keep the view element in sync. 184 | // `modelAttr` may be an array of attributes or a single string value. 185 | _.each(_.flatten([modelAttr]), function(attr) { 186 | observeModelEvent(model, 'change:' + attr, config, function(m, val, options) { 187 | var changeId = options && options.stickitChange && options.stickitChange.bindId; 188 | if (changeId !== bindId) { 189 | var currentVal = getAttr(model, modelAttr, config); 190 | updateViewBindEl($el, config, currentVal, model); 191 | } 192 | }); 193 | }); 194 | 195 | var currentVal = getAttr(model, modelAttr, config); 196 | updateViewBindEl($el, config, currentVal, model, true); 197 | } 198 | 199 | // After each binding is setup, call the `initialize` callback. 200 | applyViewFn.call(this, config.initialize, $el, model, config); 201 | } 202 | }; 203 | 204 | _.extend(Backbone.View.prototype, Stickit.ViewMixin); 205 | 206 | // Helpers 207 | // ------- 208 | 209 | var slice = [].slice; 210 | 211 | // Evaluates the given `path` (in object/dot-notation) relative to the given 212 | // `obj`. If the path is null/undefined, then the given `obj` is returned. 213 | var evaluatePath = function(obj, path) { 214 | var parts = (path || '').split('.'); 215 | var result = _.reduce(parts, function(memo, i) { return memo[i]; }, obj); 216 | return result == null ? obj : result; 217 | }; 218 | 219 | // If the given `fn` is a string, then view[fn] is called, otherwise it is 220 | // a function that should be executed. 221 | var applyViewFn = function(fn) { 222 | fn = _.isString(fn) ? evaluatePath(this, fn) : fn; 223 | if (fn) return (fn).apply(this, slice.call(arguments, 1)); 224 | }; 225 | 226 | // Given a function, string (view function reference), or a boolean 227 | // value, returns the truthy result. Any other types evaluate as false. 228 | // The first argument must be `reference` and the last must be `config`, but 229 | // middle arguments can be variadic. 230 | var evaluateBoolean = function(reference, val, config) { 231 | if (_.isBoolean(reference)) { 232 | return reference; 233 | } else if (_.isFunction(reference) || _.isString(reference)) { 234 | var view = _.last(arguments).view; 235 | return applyViewFn.apply(view, arguments); 236 | } 237 | return false; 238 | }; 239 | 240 | // Setup a model event binding with the given function, and track the event 241 | // in the view's _modelBindings. 242 | var observeModelEvent = function(model, event, config, fn) { 243 | var view = config.view; 244 | model.on(event, fn, view); 245 | view._modelBindings.push({model:model, event:event, fn:fn, config:config}); 246 | }; 247 | 248 | // Prepares the given `val`ue and sets it into the `model`. 249 | var setAttr = function(model, attr, val, options, config) { 250 | var value = {}, view = config.view; 251 | if (config.onSet) { 252 | val = applyViewFn.call(view, config.onSet, val, config); 253 | } 254 | 255 | if (config.set) { 256 | applyViewFn.call(view, config.set, attr, val, options, config); 257 | } else { 258 | value[attr] = val; 259 | // If `observe` is defined as an array and `onSet` returned 260 | // an array, then map attributes to their values. 261 | if (_.isArray(attr) && _.isArray(val)) { 262 | value = _.reduce(attr, function(memo, attribute, index) { 263 | memo[attribute] = _.has(val, index) ? val[index] : null; 264 | return memo; 265 | }, {}); 266 | } 267 | model.set(value, options); 268 | } 269 | }; 270 | 271 | // Returns the given `attr`'s value from the `model`, escaping and 272 | // formatting if necessary. If `attr` is an array, then an array of 273 | // respective values will be returned. 274 | var getAttr = function(model, attr, config) { 275 | var view = config.view; 276 | var retrieveVal = function(field) { 277 | return model[config.escape ? 'escape' : 'get'](field); 278 | }; 279 | var sanitizeVal = function(val) { 280 | return val == null ? '' : val; 281 | }; 282 | var val = _.isArray(attr) ? _.map(attr, retrieveVal) : retrieveVal(attr); 283 | if (config.onGet) val = applyViewFn.call(view, config.onGet, val, config); 284 | return _.isArray(val) ? _.map(val, sanitizeVal) : sanitizeVal(val); 285 | }; 286 | 287 | // Find handlers in `Backbone.Stickit._handlers` with selectors that match 288 | // `$el` and generate a configuration by mixing them in the order that they 289 | // were found with the given `binding`. 290 | var getConfiguration = Stickit.getConfiguration = function($el, binding) { 291 | var handlers = [{ 292 | updateModel: false, 293 | updateMethod: 'text', 294 | update: function($el, val, m, opts) { if ($el[opts.updateMethod]) $el[opts.updateMethod](val); }, 295 | getVal: function($el, e, opts) { return $el[opts.updateMethod](); } 296 | }]; 297 | handlers = handlers.concat(_.filter(Stickit._handlers, function(handler) { 298 | return $el.is(handler.selector); 299 | })); 300 | handlers.push(binding); 301 | 302 | // Merge handlers into a single config object. Last props in wins. 303 | var config = _.extend.apply(_, handlers); 304 | 305 | // `updateView` is defaulted to false for configutrations with 306 | // `visible`; otherwise, `updateView` is defaulted to true. 307 | if (!_.has(config, 'updateView')) config.updateView = !config.visible; 308 | return config; 309 | }; 310 | 311 | // Setup the attributes configuration - a list that maps an attribute or 312 | // property `name`, to an `observe`d model attribute, using an optional 313 | // `onGet` formatter. 314 | // 315 | // attributes: [{ 316 | // name: 'attributeOrPropertyName', 317 | // observe: 'modelAttrName' 318 | // onGet: function(modelAttrVal, modelAttrName) { ... } 319 | // }, ...] 320 | // 321 | var initializeAttributes = function($el, config, model, modelAttr) { 322 | var props = ['autofocus', 'autoplay', 'async', 'checked', 'controls', 323 | 'defer', 'disabled', 'hidden', 'indeterminate', 'loop', 'multiple', 324 | 'open', 'readonly', 'required', 'scoped', 'selected']; 325 | 326 | var view = config.view; 327 | 328 | _.each(config.attributes || [], function(attrConfig) { 329 | attrConfig = _.clone(attrConfig); 330 | attrConfig.view = view; 331 | 332 | var lastClass = ''; 333 | var observed = attrConfig.observe || (attrConfig.observe = modelAttr); 334 | var updateAttr = function() { 335 | var updateType = _.contains(props, attrConfig.name) ? 'prop' : 'attr', 336 | val = getAttr(model, observed, attrConfig); 337 | 338 | // If it is a class then we need to remove the last value and add the new. 339 | if (attrConfig.name === 'class') { 340 | $el.removeClass(lastClass).addClass(val); 341 | lastClass = val; 342 | } else { 343 | $el[updateType](attrConfig.name, val); 344 | } 345 | }; 346 | 347 | _.each(_.flatten([observed]), function(attr) { 348 | observeModelEvent(model, 'change:' + attr, config, updateAttr); 349 | }); 350 | 351 | // Initialize the matched element's state. 352 | updateAttr(); 353 | }); 354 | }; 355 | 356 | var initializeClasses = function($el, config, model, modelAttr) { 357 | _.each(config.classes || [], function(classConfig, name) { 358 | if (_.isString(classConfig)) classConfig = {observe: classConfig}; 359 | classConfig.view = config.view; 360 | 361 | var observed = classConfig.observe; 362 | var updateClass = function() { 363 | var val = getAttr(model, observed, classConfig); 364 | $el.toggleClass(name, !!val); 365 | }; 366 | 367 | _.each(_.flatten([observed]), function(attr) { 368 | observeModelEvent(model, 'change:' + attr, config, updateClass); 369 | }); 370 | updateClass(); 371 | }); 372 | }; 373 | 374 | // If `visible` is configured, then the view element will be shown/hidden 375 | // based on the truthiness of the modelattr's value or the result of the 376 | // given callback. If a `visibleFn` is also supplied, then that callback 377 | // will be executed to manually handle showing/hiding the view element. 378 | // 379 | // observe: 'isRight', 380 | // visible: true, // or function(val, options) {} 381 | // visibleFn: function($el, isVisible, options) {} // optional handler 382 | // 383 | var initializeVisible = function($el, config, model, modelAttr) { 384 | if (config.visible == null) return; 385 | var view = config.view; 386 | 387 | var visibleCb = function() { 388 | var visible = config.visible, 389 | visibleFn = config.visibleFn, 390 | val = getAttr(model, modelAttr, config), 391 | isVisible = !!val; 392 | 393 | // If `visible` is a function then it should return a boolean result to show/hide. 394 | if (_.isFunction(visible) || _.isString(visible)) { 395 | isVisible = !!applyViewFn.call(view, visible, val, config); 396 | } 397 | 398 | // Either use the custom `visibleFn`, if provided, or execute the standard show/hide. 399 | if (visibleFn) { 400 | applyViewFn.call(view, visibleFn, $el, isVisible, config); 401 | } else { 402 | $el.toggle(isVisible); 403 | } 404 | }; 405 | 406 | _.each(_.flatten([modelAttr]), function(attr) { 407 | observeModelEvent(model, 'change:' + attr, config, visibleCb); 408 | }); 409 | 410 | visibleCb(); 411 | }; 412 | 413 | // Update the value of `$el` using the given configuration and trigger the 414 | // `afterUpdate` callback. This action may be blocked by `config.updateView`. 415 | // 416 | // update: function($el, val, model, options) {}, // handler for updating 417 | // updateView: true, // defaults to true 418 | // afterUpdate: function($el, val, options) {} // optional callback 419 | // 420 | var updateViewBindEl = function($el, config, val, model, isInitializing) { 421 | var view = config.view; 422 | if (!evaluateBoolean(config.updateView, val, config)) return; 423 | applyViewFn.call(view, config.update, $el, val, model, config); 424 | if (!isInitializing) applyViewFn.call(view, config.afterUpdate, $el, val, config); 425 | }; 426 | 427 | // Default Handlers 428 | // ---------------- 429 | 430 | Stickit.addHandler([{ 431 | selector: '[contenteditable]', 432 | updateMethod: 'html', 433 | events: ['input', 'change'] 434 | }, { 435 | selector: 'input', 436 | events: ['propertychange', 'input', 'change'], 437 | update: function($el, val) { $el.val(val); }, 438 | getVal: function($el) { 439 | return $el.val(); 440 | } 441 | }, { 442 | selector: 'textarea', 443 | events: ['propertychange', 'input', 'change'], 444 | update: function($el, val) { $el.val(val); }, 445 | getVal: function($el) { return $el.val(); } 446 | }, { 447 | selector: 'input[type="radio"]', 448 | events: ['change'], 449 | update: function($el, val) { 450 | $el.filter('[value="'+val+'"]').prop('checked', true); 451 | }, 452 | getVal: function($el) { 453 | return $el.filter(':checked').val(); 454 | } 455 | }, { 456 | selector: 'input[type="checkbox"]', 457 | events: ['change'], 458 | update: function($el, val, model, options) { 459 | if ($el.length > 1) { 460 | // There are multiple checkboxes so we need to go through them and check 461 | // any that have value attributes that match what's in the array of `val`s. 462 | val || (val = []); 463 | $el.each(function(i, el) { 464 | var checkbox = Backbone.$(el); 465 | var checked = _.contains(val, checkbox.val()); 466 | checkbox.prop('checked', checked); 467 | }); 468 | } else { 469 | var checked = _.isBoolean(val) ? val : val === $el.val(); 470 | $el.prop('checked', checked); 471 | } 472 | }, 473 | getVal: function($el) { 474 | var val; 475 | if ($el.length > 1) { 476 | val = _.reduce($el, function(memo, el) { 477 | var checkbox = Backbone.$(el); 478 | if (checkbox.prop('checked')) memo.push(checkbox.val()); 479 | return memo; 480 | }, []); 481 | } else { 482 | val = $el.prop('checked'); 483 | // If the checkbox has a value attribute defined, then 484 | // use that value. Most browsers use "on" as a default. 485 | var boxval = $el.val(); 486 | if (boxval !== 'on' && boxval != null) { 487 | val = val ? $el.val() : null; 488 | } 489 | } 490 | return val; 491 | } 492 | }, { 493 | selector: 'select', 494 | events: ['change'], 495 | update: function($el, val, model, options) { 496 | var optList, 497 | selectConfig = options.selectOptions, 498 | list = selectConfig && selectConfig.collection || undefined, 499 | isMultiple = $el.prop('multiple'); 500 | 501 | // If there are no `selectOptions` then we assume that the `