-rw-r--r-- | content/flickr.js | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/content/flickr.js b/content/flickr.js index add628a..b5bfa43 100644 --- a/content/flickr.js +++ b/content/flickr.js @@ -124,63 +124,57 @@ Flickr.prototype = { x.open("GET",this.api_call_url(params)); x.onreadystatechange=function() { if(x.readyState!=4) return false; if(x.status==200) { var stat = x.responseXML.firstChild.getAttribute('stat'); if(stat=='ok') { if(on_success) on_success(x); }else{ var e = x.responseXML.getElementsByTagName('err').item(0); var ecode = e.getAttribute('code'); var emsg = e.getAttribute('msg'); dump(params.method+' failed: '+ecode+' '+emsg+'\n'); if(on_failure) on_failure(x,stat,ecode,emsg); } }else{ if(on_failure) on_failure(x); } return true; } x.send(null); return true; }, frob: null, - authorize_0: function(on_s, on_f) { + authorize_0: function(perms, on_s, on_f) { var _this = this; this.api_call( { method: 'flickr.auth.getFrob' }, function(x) { _this.frob = xp_str('/rsp/frob',x.responseXML); var u = _this.api_call_url( - { frob: _this.frob, perms: 'delete' }, _this.auth_url ); - var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService( - Components.interfaces.nsIWindowMediator ); - var bw = wm.getMostRecentWindow('navigator:browser'); - var b = bw.getBrowser(); - var t = b.addTab(u); - b.selectedTab = t; - if(on_s) on_s(); + { frob: _this.frob, perms: perms?perms:'delete' }, _this.auth_url ); + if(on_s) on_s(x,_this.frob,u); }, function(x,s,c,m) { if(on_f) on_f(x,s,c,m); } ); }, token: null, perms: null, user: null, authorize_1: function(on_s, on_f) { var _this = this; this.api_call( { method: 'flickr.auth.getToken', frob: this.frob }, function(x) { _this.token = xp_str('/rsp/auth/token',x.responseXML); _this.perms = xp_str('/rsp/auth/perms',x.responseXML); var u = xp_node('/rsp/auth/user',x.responseXML); _this.user = { nsid: u.getAttribute('nsid'), username: u.getAttribute('username'), fullname: u.getAttribute('fullname') }; if(on_s) on_s(x); }, function(x,s,c,m) { if(on_f) on_f(x,s,c,m); |