Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add compressed script and also the rakefile to do it :)

  • Loading branch information...
commit 0ae18aa45266882584194d20df573896e653a3c2 1 parent 0815378
Ben Schwarz authored
Showing with 19 additions and 0 deletions.
  1. +4 −0 Rakefile
  2. +15 −0 public/javascripts/application.min.js
4 Rakefile
View
@@ -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
15 public/javascripts/application.min.js
View
@@ -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;f<p;f+=1)h[f]=b(f,d)||"null";k=h.length===0?"[]":l?"[\n"+l+h.join(",\n"+l)+"\n"+n+"]":"["+h.join(",")+"]";l=n;return k}if(q&&typeof q==="object"){p=q.length;for(f=0;f<p;f+=1){g=q[f];if(typeof g==="string")if(k=b(g,d))h.push(c(g)+(l?": ":":")+k)}}else for(g in d)if(Object.hasOwnProperty.call(d,g))if(k=b(g,d))h.push(c(g)+(l?": ":":")+
+k);k=h.length===0?"{}":l?"{\n"+l+h.join(",\n"+l)+"\n"+n+"}":"{"+h.join(",")+"}";l=n;return k}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var m=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,l,r,s={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},q;if(typeof JSON.stringify!=="function")JSON.stringify=function(e,j,f){var g;r=l="";if(typeof f==="number")for(g=0;g<f;g+=1)r+=" ";else if(typeof f==="string")r=f;if((q=j)&&typeof j!=="function"&&(typeof j!=="object"||typeof j.length!=="number"))throw Error("JSON.stringify");return b("",
+{"":e})};if(typeof JSON.parse!=="function")JSON.parse=function(e,j){function f(k,p){var n,h,d=k[p];if(d&&typeof d==="object")for(n in d)if(Object.hasOwnProperty.call(d,n)){h=f(d,n);if(h!==undefined)d[n]=h;else delete d[n]}return j.call(k,p,d)}var g;e=String(e);m.lastIndex=0;if(m.test(e))e=e.replace(m,function(k){return"\\u"+("0000"+k.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(e.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){g=eval("("+e+")");return typeof j==="function"?f({"":g},""):g}throw new SyntaxError("JSON.parse");}})()};String.prototype.count=function(a){return this.split(a).length};
+var currencies=JSON.stringify({EUR:{name:"Euro",symbol:"\u20ac",rate_usd:1},USD:{name:"US Dollars",symbol:"$",rate_usd:1},GBP:{name:"British Pound",symbol:"\u00a3",rate_usd:1},JPY:{name:"Japanese Yen",symbol:"\u00a5",rate_usd:1},CHF:{name:"Swiss Francs",symbol:"chf",rate_usd:1},CAD:{name:"Canadian Dollars",symbol:"$",rate_usd:1},AUD:{name:"Australian Dollars",symbol:"$",rate_usd:1},SGD:{name:"Singapore Dollars",symbol:"$",rate_usd:1},HKD:{name:"Hong Kong Dollars",symbol:"$",rate_usd:1},NZD:{name:"New Zealand Dollars",
+symbol:"$",rate_usd:1,x:"x"}});if(!localStorage.currencies||localStorage.currencies.count(":")!==currencies.count(":")){localStorage.currencies=currencies;localStorage.from_to='{ "from": "JPY", "to": "AUD" }'}window.currencies=JSON.parse(localStorage.currencies);window.from_to=JSON.parse(localStorage.from_to);Object.prototype.touch=function(a){var c;if(window.Touch){this.addEventListener("touchstart",function(b){b.preventDefault();if(!(!b.touches||b.touches.length>1)){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+="<li>";a+='<a href="#" id="from-'+b+'">&nbsp;</a>';a+="<em>"+c[b].symbol+"</em> "+b+" <em>("+c[b].name+")</em>";a+='<a href="#" id="to-'+b+'">&nbsp;</a>';a+="</li>"}$("#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<m;b++)rates[b].className="";$("#from-"+a).className="selected";$("#to-"+c).className="selected"},update_currency_display:function(a,c){a=a||window.from_to.from;c=c||window.from_to.to;var b=window.currencies[a],m=window.currencies[c];this.highlight_currencies(a,c);Calculator.rate=b.rate_usd*(1/m.rate_usd);$("#input h2").innerHTML="<em>"+b.symbol+"</em> "+b.name;$("#output h2").innerHTML="<em>"+m.symbol+"</em> "+m.name;html=a+" <em>&rarr;</em> "+
+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<ii;i++)buttons[i].id.length||buttons[i].touch(function(){Calculator.add(this.innerText)});$("#clear").touch(function(){Calculator.clear()});$("#change").touch(function(){$("#rate-selection").style.display="block";$("#change").style.display="none";$("#flip").style.display="none"});
+$("#flip").touch(function(){var a={from:window.from_to.from,to:window.from_to.to};Converter.update_currency_display(a.to,a.from)});$("#save").touch(function(){$("#rate-selection").style.display="none";$("#change").style.display="inline";$("#flip").style.display="inline"});Converter.draw_currencies();var rates=$("#rate-selection a");i=0;
+for(ii=rates.length;i<ii;i++)rates[i].touch(function(a){a.preventDefault();a=this.id.split("-");args=a[0]=="from"?[a[1],null]:[null,a[1]];Converter.update_currency_display.apply(Converter,args)});if(!navigator.onLine)$("#network-status").className="offline";Converter.update_currency_display();setTimeout(function(){Converter.update_currencies()},100);
Please sign in to comment.
Something went wrong with that request. Please try again.