Created
July 29, 2013 16:15
-
-
Save nicksergeant/6105495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple.com is awesome. If you're waiting for goals, you can try using this with | |
// the dotjs plugin for Chrome or Firefox: | |
$(function() { | |
var NickSimple = function(NickSimple) { | |
var that = this; | |
this.init = function() { | |
that.$stsHeader = $('header#safe-to-spend'); | |
setTimeout(function() { that.checkIfReady(); }, 500); | |
}; | |
this.checkIfReady = function() { | |
if (!that.$stsHeader.hasClass('rendered')) { | |
setTimeout(function() { that.checkIfReady(); }, 500); | |
} else { | |
that.goGoGadget(); | |
} | |
}; | |
this.goGoGadget = function() { | |
that.$stsInfo = $('div#sts-info h3', that.$stsHeader); | |
that.$stsInfo.append('<span class="ns-goals">- <b id="ns-goal-balance">0.00</b> in goals</span>'); | |
that.$goalsBalance = $('b#ns-goal-balance', that.stsInfo); | |
that.$stsBalance = $('h1#sts-flag'); | |
that.goalsBalance = 0.00; | |
that.stsBalance = parseFloat(that.$stsBalance.text().replace(',', '').replace('$', '')); | |
that.goals = [ | |
{name: 'Bills', | |
amount: 2087.00, | |
memo: '$2,087 each paycheck'}, | |
{name: 'Gas', | |
amount: 20.00, | |
memo: '$30 each paycheck'}, | |
{name: 'Garbage', | |
amount: 80.00, | |
memo: '$20 each paycheck'}, | |
{name: 'Subscriptions', | |
amount: 68.00, | |
memo: '$34 each paycheck'}, | |
{name: 'Formula', | |
amount: 100.00, | |
memo: '$50 each paycheck' | |
} | |
]; | |
for (var i=0; i < that.goals.length; i++) { | |
var value = parseFloat(that.goals[i].amount); | |
that.stsBalance -= value; | |
that.goalsBalance += value; | |
} | |
that.$stsBalance.text('$' + that.round(that.stsBalance)); | |
that.$goalsBalance.text(that.round(that.goalsBalance)); | |
}; | |
this.round = function(val) { | |
return (Math.round(parseFloat(val) * 100) / 100).toFixed(2); | |
}; | |
}; | |
window.nicksimple = new NickSimple(); | |
window.nicksimple.init(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment