-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable users to choose between BTC and USD currency #12
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1d5abf7
Updated UI of new transaction form.
yskhoo a3351d8
Merge branch 'master' of github.com:RepublicOfKids/coinflip
yskhoo 7c8213a
Implemented RJProto design pattern for executing JS functions selecti…
yskhoo 3b2373c
Dynamically change currency label.
yskhoo 554bbde
Convert between USD and BTC.
yskhoo a26c6d1
Added TODO for matching friends in DB
yskhoo 6cd28ad
Merge branch 'master' of github.com:RepublicOfKids/coinflip
yskhoo 7973609
Select elements by class instead of id.
yskhoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
//= require lib/bootstrap.min | ||
//= require lib/typeahead.bundle.min | ||
//= require main | ||
//= require new_transaction |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
$(document).ready(function() { | ||
var $transactionRecipient = $('#transactionRecipient'); | ||
if ($transactionRecipient.length) { | ||
var names = new Bloodhound({ | ||
datumTokenizer: function(d) { | ||
return Bloodhound.tokenizers.whitespace(d.name); | ||
}, | ||
queryTokenizer: Bloodhound.tokenizers.whitespace, | ||
local: window.cf.dump.friends | ||
}); | ||
if (typeof window.cf === 'undefined') { | ||
window.cf = { apps: {} }; | ||
} | ||
|
||
names.initialize(); | ||
|
||
$transactionRecipient.typeahead(null, { | ||
displayKey: 'name', | ||
source: names.ttAdapter() | ||
}); | ||
} | ||
}); | ||
if (typeof window.cf.apps === 'undefined') { | ||
window.cf.apps = {}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
function usdToBtc(usd) { | ||
return (Number(usd) * Number(window.cf.dump.rates.usd_to_btc)); | ||
} | ||
|
||
function btcToUsd(btc) { | ||
return (Number(btc) / Number(window.cf.dump.rates.usd_to_btc)); | ||
} | ||
|
||
cf.apps.new_transaction = function() { | ||
this.initializeForm(); | ||
}; | ||
|
||
cf.apps.new_transaction.prototype.initializeForm = function() { | ||
var $transactionRecipient = $('.transactionRecipient'); | ||
if ($transactionRecipient.length) { | ||
var names = new Bloodhound({ | ||
datumTokenizer: function(d) { | ||
return Bloodhound.tokenizers.whitespace(d.name); | ||
}, | ||
queryTokenizer: Bloodhound.tokenizers.whitespace, | ||
local: window.cf.dump.friends | ||
}); | ||
|
||
names.initialize(); | ||
|
||
$transactionRecipient.typeahead(null, { | ||
displayKey: 'name', | ||
source: names.ttAdapter() | ||
}); | ||
} | ||
|
||
$(".currency-btns label").on('click', function(event) { | ||
var $target = $(event.target); | ||
var $amount = $('.amount'); | ||
var $currencyLabel = $('.currencyLabel'); | ||
|
||
// TODO: Check if valid currency format | ||
// TODO: If you click fast enough, the conversion will be incorrect | ||
if ($target.is(".optionBTC:not(.active)")) { | ||
$currencyLabel.html('<i class="fa fa-btc"></i>'); | ||
$amount.val(usdToBtc($amount.val())); | ||
} else if ($target.is(".optionUSD:not(.active)")) { | ||
$currencyLabel.html('<i class="fa fa-usd"></i>'); | ||
$amount.val(btcToUsd($amount.val())); | ||
} | ||
}); | ||
}; |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yskhoo I'm gonna let this go because we might revamp the UI completely, but try to keep class name styles consistent.