summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix-panel.xul33
-rw-r--r--content/fireflix.js52
-rw-r--r--locale/en-US/fireflix.dtd10
3 files changed, 67 insertions, 28 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul
index 75d6c2d..70a58fe 100644
--- a/content/fireflix-panel.xul
+++ b/content/fireflix-panel.xul
@@ -22,4 +22,25 @@
22 </stringbundleset> 22 </stringbundleset>
23 23
24 <commandset>
25 <command id="cmd_auth_auth" label="&panel.auth.auth.label;"
26 oncommand="fireflix.on_cmd_auth()"/>
27 <command id="cmd_auth_done" label="&panel.auth.done.label;"
28 oncommand="fireflix.on_cmd_auth_done()" disabled="true"/>
29 <command id="cmd_auth_open_flickr" label="&panel.auth.flickr.label;"
30 oncommand="fireflix.openTab('htp://www.flickr.com/')" />
31 <command id="cmd_auth_unauth" label="&panel.auth.unauth.label;"
32 oncommand="fireflix.on_cmd_auth_unauth()" />
33 </commandset>
34
35 <popupset>
36 <popup id="auth_menu">
37 <menuitem command="cmd_auth_auth"/>
38 <menuitem command="cmd_auth_done" hidden="true" id="menu_auth_done"/>
39 <menuitem command="cmd_auth_unauth" />
40 <menuseparator/>
41 <menuitem command="cmd_auth_open_flickr"/>
42 </popup>
43 </popupset>
44
24 <commandset id="cmdset_search"> 45 <commandset id="cmdset_search">
25 <command id="cmd_search" label="&panel.search.cmd_search.label;" 46 <command id="cmd_search" label="&panel.search.cmd_search.label;"
@@ -70,14 +91,12 @@
70 <vbox class="wholething" flex="1"> 91 <vbox class="wholething" flex="1">
71 92
72 <groupbox> 93 <groupbox context="auth_menu">
73 <caption label="&panel.auth_info;"/> 94 <caption label="&panel.auth_info;"/>
74 <hbox> 95 <hbox>
75 <label id="auth_info" value="&panel.no_auth_info;" flex="1" disabled="true"/> 96 <label id="auth_info" value="&panel.no_auth_info;" flex="1" disabled="true"/>
76 <button id="b_auth" label="&panel.auth_button;" oncommand="fireflix.on_auth()"/> 97 <button id="b_auth" command="cmd_auth_auth"/>
77 <button id="b_auth_done" label="&panel.auth_complete_button;" hidden="true" 98 <button id="b_auth_done" command="cmd_auth_done" hidden="true"/>
78 oncommand="fireflix.on_auth_done()"/> 99 <button command="cmd_auth_open_flickr"
79 <button label="&panel.flickr_button.label;" 100 tooltiptext="&panel.auth.flickr.tip;"/>
80 tooltiptext="&panel.flickr_button.tip;"
81 oncommand="fireflix.openTab('http://www.flickr.com/')" />
82 </hbox> 101 </hbox>
83 </groupbox> 102 </groupbox>
diff --git a/content/fireflix.js b/content/fireflix.js
index 9518480..82c7b0c 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -13,4 +13,11 @@ var fireflix = {
13 flickr: new Flickr(), 13 flickr: new Flickr(),
14 init: function() { 14 init: function() {
15 this.cmd_auth_auth = document.getElementById('cmd_auth_auth');
16 this.cmd_auth_done = document.getElementById('cmd_auth_done');
17 this.cmd_auth_unauth = document.getElementById('cmd_auth_unauth');
18 this.menu_auth_done = document.getElementById('menu_auth_done');
19 this.b_auth = document.getElementById('b_auth');
20 this.b_auth_done = document.getElementById('b_auth_done');
21 this.auth_info = document.getElementById('auth_info');
15 this.loc_strings = document.getElementById('loc_strings'); 22 this.loc_strings = document.getElementById('loc_strings');
16 this.build_menus(); 23 this.build_menus();
@@ -28,19 +35,28 @@ var fireflix = {
28 document.getElementById('setphotos').view = this.photoset; 35 document.getElementById('setphotos').view = this.photoset;
29 document.getElementById('uploadlist').view = this.uploads; 36 document.getElementById('uploadlist').view = this.uploads;
30 this.flickr.no_auth_info_label = document.getElementById('auth_info').value; 37 this.no_auth_info_label = this.auth_info.value;
38 this.set_auth_state(this.flickr.token,false);
31 if(this.flickr.token) { 39 if(this.flickr.token) {
32 this.refresh_stuff(); 40 this.refresh_stuff();
33 document.getElementById('auth_info').value =
34 this.flickr.user.fullname+' ['+this.flickr.user.username+']';
35 document.getElementById('auth_info').disabled = false;
36 document.getElementById('b_auth').hidden = true;
37 } 41 }
38 }, 42 },
39 on_auth: function() { 43 set_auth_state: function(au,inp) { /* authorized, in progress */
44 this.cmd_auth_unauth.disabled = !au;
45 this.b_auth.hidden = au || inp;
46 this.b_auth_done.hidden = !inp;
47 this.menu_auth_done.hidden = !inp;
48 this.cmd_auth_done.setAttribute('disabled',!inp);
49 this.auth_info.disabled = !au;
50 if(au) {
51 this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */
52 }else{
53 this.auth_info.value = this.no_auth_info_label;
54 }
55 },
56 on_cmd_auth: function() {
40 var _this = this; 57 var _this = this;
41 this.flickr.authorize_0( 58 this.flickr.authorize_0(
42 function() { 59 function() {
43 document.getElementById('b_auth').hidden = true; 60 _this.set_auth_state(_this.flickr.token,true);
44 document.getElementById('b_auth_done').hidden = false;
45 }, function(x,s,c,m) { 61 }, function(x,s,c,m) {
46 _this.flickr_failure(x,s,c,m); 62 _this.flickr_failure(x,s,c,m);
@@ -48,6 +64,6 @@ var fireflix = {
48 ); 64 );
49 }, 65 },
50 on_auth_done: function() { 66 on_cmd_auth_done: function() {
51 document.getElementById('b_auth_done').hidden = true; 67 this.set_auth_state(this.flickr.token,false);
52 var _this = this; 68 var _this = this;
53 this.flickr.authorize_1( 69 this.flickr.authorize_1(
@@ -55,13 +71,17 @@ var fireflix = {
55 _this.flickr.save_token(); 71 _this.flickr.save_token();
56 _this.refresh_stuff(); 72 _this.refresh_stuff();
57 document.getElementById('auth_info').value = 73 _this.set_auth_state(_this.flickr.token,false);
74 _this.auth_info.value =
58 _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; 75 _this.flickr.user.fullname+' ['+_this.flickr.user.username+']';
59 document.getElementById('auth_info').disabled = false;
60 }, function(x,s,c,m) { 76 }, function(x,s,c,m) {
61 document.getElementById('b_auth').hidden = false; 77 _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */
62 _this.flickr_failure(x,s,c,m); 78 _this.flickr_failure(x,s,c,m);
63 } 79 }
64 ); 80 );
65 }, 81 },
82 on_cmd_auth_unauth: function() {
83 this.flickr.reset_token();
84 this.set_auth_state(false,false);
85 },
66 86
67 refresh_sets: function() { this.photosets.refresh_sets(); }, 87 refresh_sets: function() { this.photosets.refresh_sets(); },
@@ -867,10 +887,8 @@ var fireflix = {
867 if(c==98) { // Invalid auth token 887 if(c==98) { // Invalid auth token
868 this.flickr.reset_token(); 888 this.flickr.reset_token();
869 document.getElementById('auth_info').value = this.no_auth_info_label; 889 this.set_auth_state(false,false);
870 document.getElementById('auth_info').disabled = true;
871 document.getElementById('b_auth').hidden = false;
872 return; 890 return;
873 } 891 }
874 // TODO: is that beauty 892 // TODO: is that beauty?
875 alert('flickr api call failed\n'+c+' '+m); 893 alert('flickr api call failed\n'+c+' '+m);
876 } 894 }
diff --git a/locale/en-US/fireflix.dtd b/locale/en-US/fireflix.dtd
index 2b6e72a..f4ceb79 100644
--- a/locale/en-US/fireflix.dtd
+++ b/locale/en-US/fireflix.dtd
@@ -17,8 +17,10 @@
17<!ENTITY panel.auth_info "Authorization info"> 17<!ENTITY panel.auth_info "Authorization info">
18<!ENTITY panel.no_auth_info "No auth info available"> 18<!ENTITY panel.no_auth_info "No auth info available">
19<!ENTITY panel.auth_button "Authorize"> 19
20<!ENTITY panel.auth_complete_button "Authorization complete"> 20<!ENTITY panel.auth.auth.label "Authorize">
21<!ENTITY panel.flickr_button.label "Flickr"> 21<!ENTITY panel.auth.done.label "Authorization complete">
22<!ENTITY panel.flickr_button.tip "Open Flickr in new tab"> 22<!ENTITY panel.auth.flickr.label "Flickr">
23<!ENTITY panel.auth.flickr.tip "Open Flickr in new tab">
24<!ENTITY panel.auth.unauth.label "Sign off">
23 25
24<!ENTITY panel.tabs.search "Search" > 26<!ENTITY panel.tabs.search "Search" >