comparison 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
comparison
equal deleted inserted replaced
2:e942a968cb52 3:98a070c98982
16 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; 16 var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
17 po.src = 'https://apis.google.com/js/client:plusone.js'; 17 po.src = 'https://apis.google.com/js/client:plusone.js';
18 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); 18 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
19 })(); 19 })();
20 20
21 21
22 // load googleplus api sign in 22 // load googleplus api sign in
23 23
24 script(type='text/javascript'). 24 script(type='text/javascript').
25
26
25 (function() { 27 (function() {
26 var po = document.createElement('script'); 28 var po = document.createElement('script');
27 po.type = 'text/javascript'; po.async = true; 29 po.type = 'text/javascript'; po.async = true;
28 po.src = 'https://apis.google.com/js/client:plusone.js?onload=render'; 30 po.src = 'https://apis.google.com/js/client:plusone.js?onload=render';
29 var s = document.getElementsByTagName('script')[0]; 31 var s = document.getElementsByTagName('script')[0];
62 }); 64 });
63 request.execute(function(resp) { 65 request.execute(function(resp) {
64 //alert(JSON.stringify(resp)); 66 //alert(JSON.stringify(resp));
65 $('#gpstatus').html('<a href=' + resp.url + '> ' + resp.displayName + '</a>'); 67 $('#gpstatus').html('<a href=' + resp.url + '> ' + resp.displayName + '</a>');
66 var token = gapi.auth.getToken(); 68 var token = gapi.auth.getToken();
67 //alert(JSON.stringify(token)); 69 //alert(JSON.stringify(resp.id));
68 $('#gpid').val(resp.id+'@google'); 70 $('#gpid').val(resp.id+'@google');
69 $('#gptoken').val(token.access_token + ';' + token.code); 71 $('#gptoken').val(token.access_token + ';' + token.code);
70 }); 72 });
71 }); 73 });
72 74
79 // "immediate_failed" - Could not automatically log in the user 81 // "immediate_failed" - Could not automatically log in the user
80 //alert('you cancelled login or did not fully authorize: ' + authResult['error']); 82 //alert('you cancelled login or did not fully authorize: ' + authResult['error']);
81 } 83 }
82 } 84 }
83 85
86 script.
87 // twitter stuff
88 function getCookie(cname) {
89 var name = cname + "=";
90 var ca = document.cookie.split(';');
91 for(var i=0; i<ca.length; i++) {
92 var c = ca[i].trim();
93 if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
94 }
95 return "";
96 }
97
98
84 99
85 // load facebook api 100 // load facebook api
86 script. 101 script.
87 $(document).ready(function () { 102 $(document).ready(function () {
103
104 $('#twstatus').html('<a href=https://twitter.com/account/redirect_by_id/' + getCookie('twitterid') + '> ' + getCookie('twitteruser') + '</a>');
88 105
89 $.ajaxSetup({ 106 $.ajaxSetup({
90 cache: true 107 cache: true
91 }); 108 });
92 109
150 #fb-root.fb-root 167 #fb-root.fb-root
151 input(id='fbloginbutton',type='image',class='fbloginbutton',value='fbLogin',src='images/fb.svg',width='100px',height='100px') 168 input(id='fbloginbutton',type='image',class='fbloginbutton',value='fbLogin',src='images/fb.svg',width='100px',height='100px')
152 #gp-root.gp-root 169 #gp-root.gp-root
153 input(id='gploginbutton',type='image',class='gploginbutton',value='gpLogin',src='images/gp.svg',width='100px',height='100px') 170 input(id='gploginbutton',type='image',class='gploginbutton',value='gpLogin',src='images/gp.svg',width='100px',height='100px')
154 //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') 171 //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')
172 #tw-root.tw-root
173 a(href='/add-account'): input(id='twloginbutton',type='image',class='twloginbutton',value='twLogin',src='images/twitter.svg',width='100px',height='100px')
155 #pump-root.pump-root 174 #pump-root.pump-root
156 a(href='/login') 175 a(href='/login')
157 input(id='pumploginbutton',type='image',class='pumploginbutton',value='pumpLogin',src='images/pumpiologo.svg',width='100px',height='100px') 176 input(id='pumploginbutton',type='image',class='pumploginbutton',value='pumpLogin',src='images/pumpiologo.svg',width='100px',height='100px')
158 br 177 br
159 form(class='',action='/bridge',method='post') 178 form(class='',action='/bridge',method='post')
160 #connect.connect 179 #connect.connect
161 ul 180 ul
162 li Facebook: 181 li Facebook:
163 i(id='fbstatus') not logged in 182 i(id='fbstatus') &nbsp; not logged in
164 br 183 br
165 input(id='fbid',name='fbid',hidden='true') 184 input(id='fbid',name='fbid',hidden='true')
166 input(id='fbtoken',name='fbtoken',hidden='true') 185 input(id='fbtoken',name='fbtoken',hidden='true')
167 li GooglePlus: 186 li GooglePlus:
168 i(id='gpstatus') not logged in 187 i(id='gpstatus') &nbsp; not logged in
169 br 188 br
170 input(id='gpid',name='gpid',hidden='true') 189 input(id='gpid',name='gpid',hidden='true')
171 input(id='gptoken',name='gptoken',hidden='true',size=100) 190 input(id='gptoken',name='gptoken',hidden='true',size=100)
191 li Twitter:
192 i(id='twstatus') &nbsp; not logged in
193 br
194 input(id='twid',name='twid',hidden='true')
195 input(id='twtoken',name='twtoken',hidden='true',size=100)
172 li pump.io: 196 li pump.io:
173 a(id='pumpstatus',class='pumpstatus',href=user.homepage)= user.id 197 a(id='pumpstatus',class='pumpstatus',href=user.homepage)= user.id
174 br 198 br
175 input(id='pumpid',name='pumpid',hidden='true',value=user.id) 199 input(id='pumpid',name='pumpid',hidden='true',value=user.id)
176 input(id='pumptoken',name='pumptoken',hidden='true', value=user.token) 200 input(id='pumptoken',name='pumptoken',hidden='true', value=user.token)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)