author | Michael Krelin <hacker@klever.net> | 2006-09-28 21:04:48 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-09-28 21:04:48 (UTC) |
commit | 5659bfd13d49fe56aba072b29de0bd0bb332aebd (patch) (side-by-side diff) | |
tree | 832f120283e5cc4f950c001ead3a94175a3ccca2 /content/fireflix.js | |
parent | 84e84c0f62208bba6012e0db7296a9808bbbb148 (diff) | |
download | fireflix-5659bfd13d49fe56aba072b29de0bd0bb332aebd.zip fireflix-5659bfd13d49fe56aba072b29de0bd0bb332aebd.tar.gz fireflix-5659bfd13d49fe56aba072b29de0bd0bb332aebd.tar.bz2 |
automatically start auth process in absence of token
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@166 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 82c7b0c..daf4929 100644 --- a/content/fireflix.js +++ b/content/fireflix.js @@ -1,88 +1,90 @@ function splitascii(s) { var rv=''; for(var i=0;i<s.length;++i) { var w = s.charCodeAt(i); rv += String.fromCharCode( w&0xff, (w>>8)&0xff ); } return rv; } var fireflix = { flickr: new Flickr(), init: function() { this.cmd_auth_auth = document.getElementById('cmd_auth_auth'); this.cmd_auth_done = document.getElementById('cmd_auth_done'); this.cmd_auth_unauth = document.getElementById('cmd_auth_unauth'); this.menu_auth_done = document.getElementById('menu_auth_done'); this.b_auth = document.getElementById('b_auth'); this.b_auth_done = document.getElementById('b_auth_done'); this.auth_info = document.getElementById('auth_info'); this.loc_strings = document.getElementById('loc_strings'); this.build_menus(); this.cmd_set_props = document.getElementById('cmd_set_props'); this.foundphotos.init(this); this.photosets.init(this); this.photoset.init(this); this.uploads.init(this); this.uploadObserver.init(this); this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; this.flickr.api_shs = '9c33c9e2f0f0cfd5'; this.flickr.prefs_root = 'net.klever.kin.fireflix'; this.flickr.load_token(); document.getElementById('setslist').view = this.photosets; document.getElementById('setphotos').view = this.photoset; document.getElementById('uploadlist').view = this.uploads; this.no_auth_info_label = this.auth_info.value; this.set_auth_state(this.flickr.token,false); if(this.flickr.token) { this.refresh_stuff(); + }else{ + this.on_cmd_auth(); } }, set_auth_state: function(au,inp) { /* authorized, in progress */ this.cmd_auth_unauth.disabled = !au; this.b_auth.hidden = au || inp; this.b_auth_done.hidden = !inp; this.menu_auth_done.hidden = !inp; this.cmd_auth_done.setAttribute('disabled',!inp); this.auth_info.disabled = !au; if(au) { this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */ }else{ this.auth_info.value = this.no_auth_info_label; } }, on_cmd_auth: function() { var _this = this; this.flickr.authorize_0( function() { _this.set_auth_state(_this.flickr.token,true); }, function(x,s,c,m) { _this.flickr_failure(x,s,c,m); } ); }, on_cmd_auth_done: function() { this.set_auth_state(this.flickr.token,false); var _this = this; this.flickr.authorize_1( function() { _this.flickr.save_token(); _this.refresh_stuff(); _this.set_auth_state(_this.flickr.token,false); _this.auth_info.value = _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; }, function(x,s,c,m) { _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ _this.flickr_failure(x,s,c,m); } ); }, on_cmd_auth_unauth: function() { this.flickr.reset_token(); this.set_auth_state(false,false); }, refresh_sets: function() { this.photosets.refresh_sets(); }, refresh_stuff: function() { |