Browse files

[general] agrego la calculadora

  • Loading branch information...
1 parent 8a3d354 commit b1a39ad38823553949c790734bea18816222747b cronopio committed Jun 12, 2011
Showing with 64 additions and 15 deletions.
  1. +12 −0 facebook/base.js
  2. +1 −0 public/js/fx.js
  3. +11 −4 public/stylesheets/style.css
  4. +2 −0 server.js
  5. +35 −2 views/index.jade
  6. +3 −9 views/layout.jade
View
12 facebook/base.js
@@ -41,3 +41,15 @@ Facebook.prototype.verify_sign = function(sign,msg){
var real = crypto.createHmac('sha256', this.APP_SECRET).update(msg).digest('base64');
return (real == sign+'=');
};
+
+Facebook.prototype.url_encode = function(url){
+ var str = (url+'').toString();
+ return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27')
+ .replace(/\(/g, '%28').replace(/\)/g, '%29')
+ .replace(/\*/g, '%2A').replace(/%20/g, '+');
+};
+
+Facebook.prototype.auth_dialog = function(res, redir){
+ var auth_url = 'http://www.facebook.com/dialog/oauth?client_id='+this.APP_ID+'&redirect_uri='+this.url_encode(redir);
+ res.send('<html><head><script>top.location.href = "'+auth_url+'";</script></head></html>');
+};
View
1 public/js/fx.js
@@ -0,0 +1 @@
+eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('q $1y(g){7(g.18&&g.18==1)8 h=g;t 7(1z(g).19(/^#([^$]+)$/i)){8 h=1A.1B(K.$1+\'\');7(!h)9 Q}t 9 Q;7(W(h.6)!=\'X\'&&h.6){h.6.R();9 h};h.1C=0.1;h.6={};h.6.4=[];h.6.C=0;7(W(h.L)!=\'X\')1a{1b h.L}1c(1d){h.L=Q}8 k={\'1e|1f|1D|1E|1g|1h|1F|1G|1H|1i|1j\':\'1I\',\'1J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[c.r]=u(a)+b}}};7(z(c.F)){7(z(3.6[c.r]()))7(o[c.r])c.F=o[c.r]();t c.F=0;t c.F=3.6[c.r]()}c.11=c.F;3.6[c.r](c.F,c.D);3.6.4[d].w.20(c);9 3};h.1s=q(a,b,c){8 d=h.6.C;7(3.6.4[d].I){9 3}1t(q(){7(h.6.4[d].I)9 h;h.6.4[d].I=12;7(h.6.4[d].N>0)9 h;h.6.4[d].13=(a&&a.B)?a:q(){};h.6.4[d].1u=(c&&c.B)?c:q(){};7(!z(b))h.6.4[d].V=b;A(8 i=0;i<h.6.4[d].w.G;i++){h.6.4[d].w[i].J.B(h);h.6.O(d,i)}},h.6.4[d].10);9 3};h.1v=q(a,b){3.6.4[!z(b)?b:3.6.C].14=a;9 3};h.1w=q(a){3.6.4[!z(a)?a:3.6.C].15=12;9 3};h.1x=q(){A(8 i=0;i<3.6.4.G;i++){A(8 j=0;j<3.6.4[i].w.G;j++){8 a=3.6.4[i].w[j];7(z(a.11))3.6[a.r](\'\',\'\');t 3.6[a.r](a.11,a.D)}}8 b=[\'6\',\'1p\',\'1q\',\'1o\',\'1s\',\'1v\',\'1w\',\'1x\'];A(8 i=0;i<b.G;i++)1a{1b 3[b[i]]}1c(1d){3[b[i]]=Q}3.L=12};h.6.R=q(){8 a=3.4.G;3.C=a;3.4[a]={};3.4[a].V=1;3.4[a].15=16;3.4[a].w=[];3.4[a].N=0;3.4[a].P=0;3.4[a].10=0;3.4[a].14=16;3.4[a].I=16;3.4[a].13=q(){};9 3};h.6.O=q(a,b){7(!3.4[a]||3.4[a].15||h.L)9;8 c=3.4[a].w[b];8 d=3[c.r]();7((c.H>0&&d+c.H<=c.17)||(c.H<0&&d+c.H>=c.17)){7(!3.4[a].14)3[c.r](d+c.H,c.D);8 e=3;1t(q(){7(e.O)e.O(a,b)},c.1k)}t{3[c.r](c.17,c.D);3.4[a].N++;c.M.B(h);7(3.4[a].w.G==3.4[a].N){3.4[a].N=0;3.4[a].P++;3.4[a].1u.B(h,3.4[a].P);7(3.4[a].P<3.4[a].V||3.4[a].V==-1){A(8 i=0;i<3.4[a].w.G;i++){3[c.r](c.F,3.4[a].w[i].D);3.4[a].w[i].J.B(h,3.4[a].P);3.O(a,i)}}t{3.4[a].13.B(h)}}}};h.6.R();9 h}',62,125,'|||this|sets||_fx|if|var|return|||||||||||||||||function|type||else|parseInt|style|_queue|||isNaN|for|call|_currSet|unit|opacity|from|length|step|_isrunning|onstart|RegExp|_fxTerminated|onfinish|_effectsDone|_process|_loopsDone|null|_addSet|100|new|backgroundPosition|_loops|typeof|undefined|exec|Math|_holdTime|_initial|true|_onfinal|_paused|_stoped|false|to|nodeType|match|try|delete|catch|err|left|top|width|height|backgroundx|backgroundy|delay|alpha|filter|offsetParent|fxAddSet|fxHold|fxAdd|in|fxRun|setTimeout|_onloop|fxPause|fxStop|fxReset|fx|String|document|getElementById|fxVersion|right|bottom|margin|padding|spacing|px|font|pt|navigator|userAgent|MSIE|ig|round|parseFloat|min|max|zoom|offsetWidth|offsetHeight|offsetLeft|offsetTop|test|break|push'.split('|'),0,{}))
View
15 public/stylesheets/style.css
@@ -3,10 +3,6 @@ body {
background-image:url('/images/background.jpg');
}
-a {
- color: #00B7FF;
-}
-
.fbbox {
background-color: #EDEFF4;
padding: 5px;
@@ -18,4 +14,15 @@ a {
background-image:url('/images/fondo.png');
width: 372px;
height: 250px;
+}
+
+#contenido {
+ position: absolute;
+ top: 200px;
+ left: 150px;
+}
+
+#contenido .menu a {
+ color: #454545;
+ font-size: large;
}
View
2 server.js
@@ -75,6 +75,8 @@ app.post('/', function(req, res){
req.session.fbInfo = mensaje;
console.log('El usuario '+mensaje.user_id+' ha autorizado la app');
res.redirect('/');
+ } else {
+ fb.auth_dialog(res,'http://apps.facebook.com/bitcoin_price/');
}
}
});
View
37 views/index.jade
@@ -1,10 +1,43 @@
.imagenFondo
p(class='fbbox', style='position:absolute;top:155px;left:140px;')
img(src='/images/iconBtc.png', width='16px', height:'16px', style='float:left;')
- span(style='margin-left:4px;') El precio hoy: USD
+ span(style='margin-left:4px;') Today's price is: USD
b $#{dolares}
span(style='margin-left:4px;') EUR
b €#{euros}
span(style='margin-left:4px;') GBP
b £#{libras}
- p(class='fbbox', style='position:absolute;top:185px;left:140px;', id='userLine')
+ p(class='fbbox', style='position:absolute;top:5px;left:250px;', id='userLine')
+#contenido
+ .menu
+ a(href='javascript:void(0)', id='btn_calc') Calculate
+ div(id='calculadora', class='fbbox', style='opacity:0;')
+ input(id='calc_btc', size='4')
+ label(style='margin-left:3px') BTC equal to
+ input(id='calc_dest', size='8', disabled)
+ select(id='calc_list')
+ option(value='#{dolares}') USD
+ option(value='#{euros}') EUR
+ option(value='#{libras}') GBP
+
+script
+ var cant = document.getElementById('calc_btc');
+ var lista = document.getElementById('calc_list');
+ var calcular = function(){
+ var res = cant.value * lista.value;
+ document.getElementById('calc_dest').value = res;
+ };
+ cant.onchange = calcular;
+ lista.onchange = calcular;
+
+ document.getElementById('btn_calc').onclick = function(){
+ var calculadora = document.getElementById('calculadora');
+ var opacity = calculadora.style.opacity;
+ if (opacity == 1) {
+ $fx(calculadora).fxAdd({type:'opacity',from:100,to:0,step:-10,delay:30}).fxRun(null,0);
+ }
+ if (opacity == 0) {
+ $fx(calculadora).fxAdd({type:'opacity',from:0,to:100,step:10,delay:30}).fxRun(null,0);
+ }
+ };
+
View
12 views/layout.jade
@@ -4,16 +4,10 @@ html
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
script(type='text/javascript', src='http://connect.facebook.net/en_US/all.js')
- //script(type='text/javascript', src='http://static.ak.fbcdn.net/connect/en_US/core.debug.js')
+ script(type='text/javascript', src='js/fx.js')
body!= body
#fb-root
script(type='text/javascript')
- var urlencode = function(str){
- str = (str+'').toString();
- return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27')
- .replace(/\\(/g, '%28').replace(/\\)/g, '%29')
- .replace(/\\*/g, '%2A').replace(/%20/g, '+');
- };
FB.init({
appId: '124829930933291',
status: true,
@@ -31,11 +25,11 @@ html
imagen.src = 'http://graph.facebook.com/'+user.id+'/picture';
userLine.appendChild(imagen);
var nombre = document.createElement('span');
+ nombre.style['margin-left'] = '5px';
+ nombre.style['font-weight'] = 'bold';
nombre.innerHTML = user.name;
userLine.appendChild(nombre);
}
});
- } else {
- top.location.href = 'http://www.facebook.com/dialog/oauth?client_id=124829930933291&redirect_uri='+urlencode('http://apps.facebook.com/bitcoin_price/');
}
});

0 comments on commit b1a39ad

Please sign in to comment.