diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..bad7b9f --- /dev/null +++ b/Rakefile @@ -0,0 +1,4 @@ +desc "Compress javascripts into /public/javascripts/application.min.js" +task :compress_scripts do + `closure --js=public/javascripts/json.js --js=public/javascripts/dataset.js --js=public/javascripts/application.js --compilation_level=SIMPLE_OPTIMIZATIONS --js_output_file=public/javascripts/application.min.js` +end \ No newline at end of file diff --git a/public/javascripts/application.min.js b/public/javascripts/application.min.js new file mode 100644 index 0000000..a1479ac --- /dev/null +++ b/public/javascripts/application.min.js @@ -0,0 +1,15 @@ +if(!this.JSON){if(!this.JSON)this.JSON={};(function(){function a(e){return e<10?"0"+e:e}function c(e){o.lastIndex=0;return o.test(e)?'"'+e.replace(o,function(j){var f=s[j];return typeof f==="string"?f:"\\u"+("0000"+j.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function b(e,j){var f,g,k,p,n=l,h,d=j[e];if(d&&typeof d==="object"&&typeof d.toJSON==="function")d=d.toJSON(e);if(typeof q==="function")d=q.call(j,e,d);switch(typeof d){case "string":return c(d);case "number":return isFinite(d)?String(d): +"null";case "boolean":case "null":return String(d);case "object":if(!d)return"null";l+=r;h=[];if(Object.prototype.toString.apply(d)==="[object Array]"){p=d.length;for(f=0;f1)){this.className="active";this.addEventListener("touchmove",c=function(){},false)}},false);this.addEventListener("touchend",function(b){b.preventDefault();this.className="";this.removeEventListener("touchmove",c);a&&a.apply(this,[b])},false)}else this.addEventListener("click",a)}; +for(var $=function(a,c){c=c||document;var b=c.querySelectorAll(a);return b.length>1?b:b[0]},Converter={draw_currencies:function(){var a="",c=window.currencies,b;for(b in c)if(window.currencies.hasOwnProperty(b)){a+="
  • ";a+=' ';a+=""+c[b].symbol+" "+b+" ("+c[b].name+")";a+=' ';a+="
  • "}$("#rate-selection ul").innerHTML=a},highlight_currencies:function(a,c){window.from_to.from=a;window.from_to.to=c;localStorage.from_to= +JSON.stringify(window.from_to);for(var b=0,m=rates.length;b "+b.name;$("#output h2").innerHTML=""+m.symbol+" "+m.name;html=a+" "+ +c;$("#rates span").innerHTML=html;Calculator.add("")},update_currencies:function(){if(navigator.onLine){var a=[],c;for(c in window.currencies)window.currencies.hasOwnProperty(c)&&a.push(c);var b=new XMLHttpRequest;b.open("POST","/exchange?currencies="+a.toString(),true);b.send(null);b.onreadystatechange=function(){if(b.readyState===4)if(this.status==200){var m=JSON.parse(b.responseText),o;for(o in m)window.currencies[o].rate_usd=m[o];localStorage.currencies=JSON.stringify(window.currencies);Converter.update_currency_display()}else console.error("Request failed.")}}}}, +Calculator={input:$("#input h1"),output:$("#output h1"),rate:0,add:function(a){this.update_values((this.input.innerText!=="0"?this.strip_commas(this.input.innerText):"")+a)},update_values:function(a){a=this.strip_commas(a);var c=(a*this.rate).toFixed(2);a||(a=0);if(!/\./.test(a)&&(a.length>5||c.length>6))c=c.slice(0,-3);if(!(a.length>10||c.length>10)){this.input.innerHTML=this.add_commas(a);this.output.innerHTML=this.add_commas(c)}},clear:function(){this.update_values("0")},add_commas:function(a){var c= +/(\d+)(\d{3,3})/,b=(""+a).split(".");a=b[0];for(b=b[1]!==undefined?"."+b[1]:"";c.test(a);)a=a.replace(c,"$1,$2");return a+b},strip_commas:function(a){return a.replace(/,/g,"")}},buttons=$("#input-pad p"),i=0,ii=buttons.length;i