Mercurial > pumpbridge
diff views/index.jade @ 3:98a070c98982
add Twitter support
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Thu, 05 Jun 2014 18:02:25 +0200 |
parents | b73191efc65b |
children | a94ac7c3b182 |
line wrap: on
line diff
--- a/views/index.jade Thu Jun 05 11:09:18 2014 +0200 +++ b/views/index.jade Thu Jun 05 18:02:25 2014 +0200 @@ -18,10 +18,12 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); - + // load googleplus api sign in script(type='text/javascript'). + + (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; @@ -64,7 +66,7 @@ //alert(JSON.stringify(resp)); $('#gpstatus').html('<a href=' + resp.url + '> ' + resp.displayName + '</a>'); var token = gapi.auth.getToken(); - //alert(JSON.stringify(token)); + //alert(JSON.stringify(resp.id)); $('#gpid').val(resp.id+'@google'); $('#gptoken').val(token.access_token + ';' + token.code); }); @@ -81,10 +83,25 @@ } } + script. + // twitter stuff + function getCookie(cname) { + var name = cname + "="; + var ca = document.cookie.split(';'); + for(var i=0; i<ca.length; i++) { + var c = ca[i].trim(); + if (c.indexOf(name) == 0) return c.substring(name.length,c.length); + } + return ""; + } + + // load facebook api script. $(document).ready(function () { + + $('#twstatus').html('<a href=https://twitter.com/account/redirect_by_id/' + getCookie('twitterid') + '> ' + getCookie('twitteruser') + '</a>'); $.ajaxSetup({ cache: true @@ -152,6 +169,8 @@ #gp-root.gp-root input(id='gploginbutton',type='image',class='gploginbutton',value='gpLogin',src='images/gp.svg',width='100px',height='100px') //span.g-signin(data-scope='https://www.googleapis.com/auth/plus.login', data-clientid='460404084439-rgb5r2vh7hh8hvf2na65c7n1ofhmomek.apps.googleusercontent.com', data-redirecturi='postmessage', data-accesstype='offline', data-cookiepolicy='single_host_origin', data-callback='signInCallback', approval_prompt='force') + #tw-root.tw-root + a(href='/add-account'): input(id='twloginbutton',type='image',class='twloginbutton',value='twLogin',src='images/twitter.svg',width='100px',height='100px') #pump-root.pump-root a(href='/login') input(id='pumploginbutton',type='image',class='pumploginbutton',value='pumpLogin',src='images/pumpiologo.svg',width='100px',height='100px') @@ -160,15 +179,20 @@ #connect.connect ul li Facebook: - i(id='fbstatus') not logged in + i(id='fbstatus') not logged in br input(id='fbid',name='fbid',hidden='true') input(id='fbtoken',name='fbtoken',hidden='true') li GooglePlus: - i(id='gpstatus') not logged in + i(id='gpstatus') not logged in br input(id='gpid',name='gpid',hidden='true') input(id='gptoken',name='gptoken',hidden='true',size=100) + li Twitter: + i(id='twstatus') not logged in + br + input(id='twid',name='twid',hidden='true') + input(id='twtoken',name='twtoken',hidden='true',size=100) li pump.io: a(id='pumpstatus',class='pumpstatus',href=user.homepage)= user.id br