Commit cc95e8af authored by Smari McCarthy's avatar Smari McCarthy
Browse files

Auto-build currency symbol regex

parent f34f999c
......@@ -19,14 +19,16 @@ function Marka(target) {
Marka.prototype.match = function() {
// docs: https://github.com/padolsey/findAndReplaceDOMText
this.currencySymbols = "[€$¢¥₹₨]";
/* var opts = [];
// this.currencySymbols = "[€$¢¥₹₨]";
var opts = [];
for (sym in currency_info) {
opts.push(currency_info[sym].symbol_native)
var sbl = currency_info[sym].symbol_native.replace("/", "\\/")
if (sbl == "$") { sbl = "\\$" }
opts.push(sbl)
}
this.currencySymbols = "(" + opts.join("|") + ")"
console.log(this.currencySymbols)
*/
var currencySymbols = this.currencySymbols;
var currencyWords = "(" + currencySymbols + "|kr|[Dd]ollars|[Cc]ents on the dollar|[Cc]ents|[Ee]uros|[Pp]ounds|[Rr]upees|[Zz]loty)";
var numbers = "[\\d,.]+";
......@@ -60,7 +62,7 @@ Marka.prototype.doConversions = function() {
self.getValueInSetCurrency(res.number, res.symbol, function(value, converted) {
if (converted) {
console.log(self.getCurrentCurrency())
node.text(value + " " + self.getCurrentCurrency());
node.text(value.toFixed(2) + " " + self.getCurrentCurrency());
} else {
node.text(node.data("original_value"))
}
......@@ -157,7 +159,7 @@ Marka.prototype.getCurrentCurrency = function(){
}
Marka.prototype.setCurrency = function(currency){
this.setCookie("currency", currency.toUpperCase(), 365);
this.setCookie("currency", currency.toUpperCase(), 365);
}
Marka.prototype.retreiveExchangeRates = function(currency_one, currency_two, callback) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment