summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2006-09-28 19:40:39 (UTC)
committer Michael Krelin <hacker@klever.net>2006-09-28 19:40:39 (UTC)
commit438c60c606a15792893c38415d0f405ae21e433d (patch) (unidiff)
treed8a56268d5ebedf8669587af7469fedbe1527154
parentb62171950ffbbdae7826b1b8cdd4cfd0bde8cc93 (diff)
downloadfireflix-438c60c606a15792893c38415d0f405ae21e433d.zip
fireflix-438c60c606a15792893c38415d0f405ae21e433d.tar.gz
fireflix-438c60c606a15792893c38415d0f405ae21e433d.tar.bz2
Better tracking of auth state, added possibility to sign off and reauth
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@164 fe716a7a-6dde-0310-88d9-d003556173a8
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
@@ -1,177 +1,196 @@
1<?xml version="1.0"?> 1<?xml version="1.0"?>
2<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 2<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
3<?xml-stylesheet href="fireflix.css" type="text/css"?> 3<?xml-stylesheet href="fireflix.css" type="text/css"?>
4<!DOCTYPE page SYSTEM "chrome://fireflix/locale/fireflix.dtd"> 4<!DOCTYPE page SYSTEM "chrome://fireflix/locale/fireflix.dtd">
5<page 5<page
6 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 6 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
7 id="fireflixwindow" title="Fireflix" 7 id="fireflixwindow" title="Fireflix"
8 onload="fireflix.init()" 8 onload="fireflix.init()"
9 orient="vertical" 9 orient="vertical"
10 ondragover="nsDragAndDrop.dragOver(event,fireflix.uploadObserver)" 10 ondragover="nsDragAndDrop.dragOver(event,fireflix.uploadObserver)"
11 ondragdrop="nsDragAndDrop.drop(event,fireflix.uploadObserver)" 11 ondragdrop="nsDragAndDrop.drop(event,fireflix.uploadObserver)"
12 > 12 >
13 13
14 <script src="chrome://global/content/nsDragAndDrop.js"/> 14 <script src="chrome://global/content/nsDragAndDrop.js"/>
15 <script src="chrome://global/content/nsTransferable.js"/> 15 <script src="chrome://global/content/nsTransferable.js"/>
16 <script type="application/x-javascript" src="md5.js" /> 16 <script type="application/x-javascript" src="md5.js" />
17 <script type="application/x-javascript" src="flickr.js" /> 17 <script type="application/x-javascript" src="flickr.js" />
18 <script type="application/x-javascript" src="fireflix.js" /> 18 <script type="application/x-javascript" src="fireflix.js" />
19 19
20 <stringbundleset> 20 <stringbundleset>
21 <stringbundle id="loc_strings" src="chrome://fireflix/locale/fireflix.properties" /> 21 <stringbundle id="loc_strings" src="chrome://fireflix/locale/fireflix.properties" />
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;"
26 oncommand="fireflix.foundphotos.search_photos()"/> 47 oncommand="fireflix.foundphotos.search_photos()"/>
27 <command id="cmd_search_open" label="&panel.search.cmd_search_open.label;" 48 <command id="cmd_search_open" label="&panel.search.cmd_search_open.label;"
28 oncommand="fireflix.foundphotos.on_cmd_open(event)" /> 49 oncommand="fireflix.foundphotos.on_cmd_open(event)" />
29 </commandset> 50 </commandset>
30 51
31 <commandset id="cmdset_sets"> 52 <commandset id="cmdset_sets">
32 <command id="cmd_refresh_sets" label="&panel.sets.cmd_refresh_sets;" 53 <command id="cmd_refresh_sets" label="&panel.sets.cmd_refresh_sets;"
33 oncommand="fireflix.on_refresh_sets()" /> 54 oncommand="fireflix.on_refresh_sets()" />
34 <command id="cmd_set_props" label="&panel.sets.cmd_properties;" 55 <command id="cmd_set_props" label="&panel.sets.cmd_properties;"
35 oncommand="fireflix.on_set_props()" disabled="true" /> 56 oncommand="fireflix.on_set_props()" disabled="true" />
36 </commandset> 57 </commandset>
37 58
38 <popupset> 59 <popupset>
39 <popup id="sets_menu"> 60 <popup id="sets_menu">
40 <menuitem command="cmd_set_props"/> 61 <menuitem command="cmd_set_props"/>
41 <menuitem command="cmd_refresh_sets"/> 62 <menuitem command="cmd_refresh_sets"/>
42 <menuseparator/> 63 <menuseparator/>
43 <menu label="&panel.sets.generate_html;" id="sets_html_menu"/> 64 <menu label="&panel.sets.generate_html;" id="sets_html_menu"/>
44 </popup> 65 </popup>
45 </popupset> 66 </popupset>
46 67
47 <commandset id="cmdset_uploads"> 68 <commandset id="cmdset_uploads">
48 <command id="cmd_uploads_clear" label="&panel.uploads.clear.label;" 69 <command id="cmd_uploads_clear" label="&panel.uploads.clear.label;"
49 oncommand="fireflix.uploads.on_clear()" /> 70 oncommand="fireflix.uploads.on_clear()" />
50 <command id="cmd_uploads_upload" label="&panel.uploads.upload.label;" 71 <command id="cmd_uploads_upload" label="&panel.uploads.upload.label;"
51 oncommand="fireflix.uploads.on_upload()" /> 72 oncommand="fireflix.uploads.on_upload()" />
52 <command id="cmd_uploads_remove" label="&panel.uploads.remove.label;" 73 <command id="cmd_uploads_remove" label="&panel.uploads.remove.label;"
53 oncommand="fireflix.uploads.on_remove()" /> 74 oncommand="fireflix.uploads.on_remove()" />
54 <command id="cmd_uploads_add" label="&panel.uploads.add.label;" 75 <command id="cmd_uploads_add" label="&panel.uploads.add.label;"
55 oncommand="fireflix.uploads.on_add()" /> 76 oncommand="fireflix.uploads.on_add()" />
56 </commandset> 77 </commandset>
57 78
58 <popupset> 79 <popupset>
59 <popup id="uploads_menu"> 80 <popup id="uploads_menu">
60 <menuitem command="cmd_uploads_add"/> 81 <menuitem command="cmd_uploads_add"/>
61 <menuitem command="cmd_uploads_clear"/> 82 <menuitem command="cmd_uploads_clear"/>
62 <menuitem command="cmd_uploads_remove"/> 83 <menuitem command="cmd_uploads_remove"/>
63 <menuseparator/> 84 <menuseparator/>
64 <menuitem command="cmd_uploads_upload"/> 85 <menuitem command="cmd_uploads_upload"/>
65 <menuseparator/> 86 <menuseparator/>
66 <menu label="&panel.uploads.generate_html;" id="uploads_html_menu"/> 87 <menu label="&panel.uploads.generate_html;" id="uploads_html_menu"/>
67 </popup> 88 </popup>
68 </popupset> 89 </popupset>
69 90
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>
84 103
85 <tabbox flex="1" id="fireflix_tabs"> 104 <tabbox flex="1" id="fireflix_tabs">
86 105
87 <tabs> 106 <tabs>
88 <tab label="&panel.tabs.search;"/> 107 <tab label="&panel.tabs.search;"/>
89 <tab label="&panel.tabs.sets;"/> 108 <tab label="&panel.tabs.sets;"/>
90 <tab label="&panel.tabs.tags;" hidden="true"/> <!-- TODO: --> 109 <tab label="&panel.tabs.tags;" hidden="true"/> <!-- TODO: -->
91 <tab id="tab_upload" label="&panel.tabs.upload;"/> 110 <tab id="tab_upload" label="&panel.tabs.upload;"/>
92 </tabs> 111 </tabs>
93 112
94 <tabpanels flex="1"> 113 <tabpanels flex="1">
95 114
96 <tabpanel id="tabpanel_search" flex="1"> 115 <tabpanel id="tabpanel_search" flex="1">
97 <vbox flex="1"> 116 <vbox flex="1">
98 <groupbox class="search_params" orient="vertical" onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.foundphotos.search_photos()"> 117 <groupbox class="search_params" orient="vertical" onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.foundphotos.search_photos()">
99 <hbox> 118 <hbox>
100 <label control="search_for" value="&panel.search.search_for.label;" 119 <label control="search_for" value="&panel.search.search_for.label;"
101 accesskey="s"/> 120 accesskey="s"/>
102 <textbox id="search_for" flex="1"/> 121 <textbox id="search_for" flex="1"/>
103 </hbox> 122 </hbox>
104 <hbox> 123 <hbox>
105 <checkbox id="search_tags" label="&panel.search.mode.tagsonly.label;" 124 <checkbox id="search_tags" label="&panel.search.mode.tagsonly.label;"
106 tooltiptext="&panel.search.mode.tagsonly.tip;" checked="false" 125 tooltiptext="&panel.search.mode.tagsonly.tip;" checked="false"
107 accesskey="t" /> 126 accesskey="t" />
108 <checkbox id="search_mine" label="&panel.search.mode.mine.label;" checked="true" accesskey="m"/> 127 <checkbox id="search_mine" label="&panel.search.mode.mine.label;" checked="true" accesskey="m"/>
109 <spacer flex="1"/> 128 <spacer flex="1"/>
110 <button command="cmd_search"/> 129 <button command="cmd_search"/>
111 </hbox> 130 </hbox>
112 </groupbox> 131 </groupbox>
113 <tree id="searchresults" rows="2" flex="1" 132 <tree id="searchresults" rows="2" flex="1"
114 onselect="fireflix.foundphotos.on_select()" 133 onselect="fireflix.foundphotos.on_select()"
115 ondblclick="fireflix.foundphotos.on_cmd_open(event)" 134 ondblclick="fireflix.foundphotos.on_cmd_open(event)"
116 onkeypress="if(event.keyCode==event.DOM_VK_RETURN) 135 onkeypress="if(event.keyCode==event.DOM_VK_RETURN)
117 fireflix.foundphotos.on_cmd_open(event)"> 136 fireflix.foundphotos.on_cmd_open(event)">
118 <treecols> 137 <treecols>
119 <treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" /> 138 <treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" />
120 </treecols> 139 </treecols>
121 <treechildren/> 140 <treechildren/>
122 </tree> 141 </tree>
123 <groupbox id="searchresult_props" orient="horizontal" hidden="true"> 142 <groupbox id="searchresult_props" orient="horizontal" hidden="true">
124 <vbox width="100" pack="center"> 143 <vbox width="100" pack="center">
125 <hbox pack="center"> 144 <hbox pack="center">
126 <image id="search_photo"/> 145 <image id="search_photo"/>
127 </hbox> 146 </hbox>
128 </vbox> 147 </vbox>
129 <vbox flex="1"> 148 <vbox flex="1">
130 <label id="searchresult_title"/> 149 <label id="searchresult_title"/>
131 <textbox flex="1" multiline="true" class="plain" readonly="true" id="searchresult_description"/> 150 <textbox flex="1" multiline="true" class="plain" readonly="true" id="searchresult_description"/>
132 <hbox pack="end"> 151 <hbox pack="end">
133 <button command="cmd_search_open"/> 152 <button command="cmd_search_open"/>
134 </hbox> 153 </hbox>
135 </vbox> 154 </vbox>
136 </groupbox> 155 </groupbox>
137 </vbox> 156 </vbox>
138 </tabpanel> 157 </tabpanel>
139 158
140 <tabpanel id="tabpanel_sets" flex="1" 159 <tabpanel id="tabpanel_sets" flex="1"
141 onkeypress="if(event.keyCode==event.DOM_VK_RETURN) 160 onkeypress="if(event.keyCode==event.DOM_VK_RETURN)
142 document.getElementById('setphotos').focus()"> 161 document.getElementById('setphotos').focus()">
143 <vbox flex="1"> 162 <vbox flex="1">
144 <tree id="setslist" rows="2" onselect="fireflix.photosets.on_select()" 163 <tree id="setslist" rows="2" onselect="fireflix.photosets.on_select()"
145 flex="1" context="sets_menu" 164 flex="1" context="sets_menu"
146 > 165 >
147 <treecols> 166 <treecols>
148 <treecol id="sl_name" label="&panel.sets.name.label;" flex="4" crop="end" align="start" tooltiptext="&panel.sets.name.tip;"/> 167 <treecol id="sl_name" label="&panel.sets.name.label;" flex="4" crop="end" align="start" tooltiptext="&panel.sets.name.tip;"/>
149 <splitter class="tree-splitter" /> 168 <splitter class="tree-splitter" />
150 <treecol id="sl_photos" label="&panel.sets.photos.label;" flex="1" align="end" tooltiptext="&panel.sets.photos.tip;" /> 169 <treecol id="sl_photos" label="&panel.sets.photos.label;" flex="1" align="end" tooltiptext="&panel.sets.photos.tip;" />
151 </treecols> 170 </treecols>
152 <treechildren/> 171 <treechildren/>
153 </tree> 172 </tree>
154 <hbox> 173 <hbox>
155 <button command="cmd_refresh_sets" /> 174 <button command="cmd_refresh_sets" />
156 <button command="cmd_set_props" /> 175 <button command="cmd_set_props" />
157 </hbox> 176 </hbox>
158 <tree id="setphotos" rows="2" onselect="fireflix.photoset.on_select()" 177 <tree id="setphotos" rows="2" onselect="fireflix.photoset.on_select()"
159 flex="1"> 178 flex="1">
160 <treecols> 179 <treecols>
161 <treecol id="sp_title" label="&panel.setphotos.title.label;" flex="1" crop="end" align="start" tooltiptext="&panel.setphotos.title.tip;" /> 180 <treecol id="sp_title" label="&panel.setphotos.title.label;" flex="1" crop="end" align="start" tooltiptext="&panel.setphotos.title.tip;" />
162 <splitter class="tree-splitter" /> 181 <splitter class="tree-splitter" />
163 <treecol id="sp_taken" label="&panel.setphotos.taken.label;" crop="end" align="start" tooltiptext="&panel.setphotos.taken.tip;" hidden="true" /> 182 <treecol id="sp_taken" label="&panel.setphotos.taken.label;" crop="end" align="start" tooltiptext="&panel.setphotos.taken.tip;" hidden="true" />
164 <treecol id="sp_upload" label="&panel.setphotos.upload.label;" crop="end" align="start" tooltiptext="&panel.setphotos.upload.tip;" hidden="true" /> 183 <treecol id="sp_upload" label="&panel.setphotos.upload.label;" crop="end" align="start" tooltiptext="&panel.setphotos.upload.tip;" hidden="true" />
165 </treecols> 184 </treecols>
166 <treechildren/> 185 <treechildren/>
167 </tree> 186 </tree>
168 <groupbox id="set_photo_props" orient="horizontal"> 187 <groupbox id="set_photo_props" orient="horizontal">
169 <vbox width="100" pack="center"> 188 <vbox width="100" pack="center">
170 <hbox pack="center"> 189 <hbox pack="center">
171 <image id="set_photo" hidden="true"/> 190 <image id="set_photo" hidden="true"/>
172 </hbox> 191 </hbox>
173 </vbox> 192 </vbox>
174 <spacer flex="1"/> 193 <spacer flex="1"/>
175 </groupbox> 194 </groupbox>
176 </vbox> 195 </vbox>
177 </tabpanel> 196 </tabpanel>
diff --git a/content/fireflix.js b/content/fireflix.js
index 9518480..82c7b0c 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -1,161 +1,181 @@
1function splitascii(s) { 1function splitascii(s) {
2 var rv=''; 2 var rv='';
3 for(var i=0;i<s.length;++i) { 3 for(var i=0;i<s.length;++i) {
4 var w = s.charCodeAt(i); 4 var w = s.charCodeAt(i);
5 rv += String.fromCharCode( 5 rv += String.fromCharCode(
6 w&0xff, (w>>8)&0xff ); 6 w&0xff, (w>>8)&0xff );
7 } 7 }
8 return rv; 8 return rv;
9} 9}
10 10
11 11
12var fireflix = { 12var 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();
17 this.cmd_set_props = document.getElementById('cmd_set_props'); 24 this.cmd_set_props = document.getElementById('cmd_set_props');
18 this.foundphotos.init(this); 25 this.foundphotos.init(this);
19 this.photosets.init(this); 26 this.photosets.init(this);
20 this.photoset.init(this); 27 this.photoset.init(this);
21 this.uploads.init(this); 28 this.uploads.init(this);
22 this.uploadObserver.init(this); 29 this.uploadObserver.init(this);
23 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; 30 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3';
24 this.flickr.api_shs = '9c33c9e2f0f0cfd5'; 31 this.flickr.api_shs = '9c33c9e2f0f0cfd5';
25 this.flickr.prefs_root = 'net.klever.kin.fireflix'; 32 this.flickr.prefs_root = 'net.klever.kin.fireflix';
26 this.flickr.load_token(); 33 this.flickr.load_token();
27 document.getElementById('setslist').view = this.photosets; 34 document.getElementById('setslist').view = this.photosets;
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);
47 } 63 }
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(
54 function() { 70 function() {
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(); },
68 refresh_stuff: function() { 88 refresh_stuff: function() {
69 this.refresh_sets(); 89 this.refresh_sets();
70 this.refresh_user_tags(); 90 this.refresh_user_tags();
71 }, 91 },
72 92
73 /* photoset treeview */ 93 /* photoset treeview */
74 photoset: { 94 photoset: {
75 photos: new Array(), 95 photos: new Array(),
76 fireflix: null, 96 fireflix: null,
77 init: function(f) { 97 init: function(f) {
78 this.fireflix = f; 98 this.fireflix = f;
79 }, 99 },
80 rowCount: 0, 100 rowCount: 0,
81 getCellText: function(r,c) { 101 getCellText: function(r,c) {
82 var p = this.photos[r]; 102 var p = this.photos[r];
83 if(c.id=='sp_title') return p.title; 103 if(c.id=='sp_title') return p.title;
84 if(c.id=='sp_taken') return p.datetaken; 104 if(c.id=='sp_taken') return p.datetaken;
85 if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ 105 if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */
86 return c.id; 106 return c.id;
87 }, 107 },
88 setTree: function(t) { this.tree = t }, 108 setTree: function(t) { this.tree = t },
89 isContainer: function(r) { return false; }, 109 isContainer: function(r) { return false; },
90 isSeparator: function(r) { return false; }, 110 isSeparator: function(r) { return false; },
91 isSorted: function(r) { return false; }, 111 isSorted: function(r) { return false; },
92 getLevel: function(r) { return 0; }, 112 getLevel: function(r) { return 0; },
93 getImageSrc: function(r,c) { return null }, 113 getImageSrc: function(r,c) { return null },
94 getRowProperties: function(r,p) {}, 114 getRowProperties: function(r,p) {},
95 getCellProperties: function(cid,cel,p) {}, 115 getCellProperties: function(cid,cel,p) {},
96 getColumnProperties: function(cid,cel,p) { }, 116 getColumnProperties: function(cid,cel,p) { },
97 cycleHeader: function(cid,e) { }, 117 cycleHeader: function(cid,e) { },
98 getParentIndex: function(r) { return -1; }, 118 getParentIndex: function(r) { return -1; },
99 drop: function(r,o) { }, 119 drop: function(r,o) { },
100 canDropBeforeAfter: function(r,b) { return false }, 120 canDropBeforeAfter: function(r,b) { return false },
101 121
102 importXPR: function(xp) { 122 importXPR: function(xp) {
103 this.tree.beginUpdateBatch(); 123 this.tree.beginUpdateBatch();
104 this.photos = new Array(); 124 this.photos = new Array();
105 var n; while(n=xp.iterateNext()) { 125 var n; while(n=xp.iterateNext()) {
106 this.photos.push(new Photo(n)); 126 this.photos.push(new Photo(n));
107 } 127 }
108 this.rowCount = this.photos.length; 128 this.rowCount = this.photos.length;
109 this.tree.endUpdateBatch(); 129 this.tree.endUpdateBatch();
110 }, 130 },
111 load_photos: function(psid) { 131 load_photos: function(psid) {
112 var _this = this; 132 var _this = this;
113 this.fireflix.flickr.api_call( 133 this.fireflix.flickr.api_call(
114 { 134 {
115 method: 'flickr.photosets.getPhotos', 135 method: 'flickr.photosets.getPhotos',
116 auth_token: 'default', 136 auth_token: 'default',
117 photoset_id: psid, 137 photoset_id: psid,
118 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' 138 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update'
119 }, function(xr) { 139 }, function(xr) {
120 var x = xr.responseXML; 140 var x = xr.responseXML;
121 var xp = x.evaluate( 141 var xp = x.evaluate(
122 '/rsp/photoset/photo', x, null, 142 '/rsp/photoset/photo', x, null,
123 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 143 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
124 _this.importXPR(xp); 144 _this.importXPR(xp);
125 }, function(x,s,c,m) { 145 }, function(x,s,c,m) {
126 _this.fireflix.flickr_failure(x,s,c,m); 146 _this.fireflix.flickr_failure(x,s,c,m);
127 } 147 }
128 ); 148 );
129 }, 149 },
130 on_select: function() { 150 on_select: function() {
131 if(this.selection.count==1) { 151 if(this.selection.count==1) {
132 var p = this.photos[this.selection.currentIndex]; 152 var p = this.photos[this.selection.currentIndex];
133 document.getElementById('set_photo').src = 153 document.getElementById('set_photo').src =
134 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); 154 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t');
135 document.getElementById('set_photo').hidden = false; 155 document.getElementById('set_photo').hidden = false;
136 }else{ 156 }else{
137 document.getElementById('set_photo').hidden = true; 157 document.getElementById('set_photo').hidden = true;
138 } 158 }
139 } 159 }
140 }, 160 },
141 161
142 /* photosets treeview */ 162 /* photosets treeview */
143 photosets: { 163 photosets: {
144 sets: new Array(), 164 sets: new Array(),
145 fireflix: null, 165 fireflix: null,
146 init: function(f) { 166 init: function(f) {
147 this.fireflix = f; 167 this.fireflix = f;
148 }, 168 },
149 rowCount: 0, 169 rowCount: 0,
150 getCellText: function(r,c) { 170 getCellText: function(r,c) {
151 var s = this.sets[r]; 171 var s = this.sets[r];
152 if(c.id=='sl_name') return s.title; 172 if(c.id=='sl_name') return s.title;
153 if(c.id=='sl_photos') return s.photos; 173 if(c.id=='sl_photos') return s.photos;
154 return c.id; 174 return c.id;
155 }, 175 },
156 setTree: function(t) { this.tree = t }, 176 setTree: function(t) { this.tree = t },
157 isContainer: function(r) { return false; }, 177 isContainer: function(r) { return false; },
158 isSeparator: function(r) { return false; }, 178 isSeparator: function(r) { return false; },
159 isSorted: function() { return false; }, 179 isSorted: function() { return false; },
160 getLevel: function(r) { return 0; }, 180 getLevel: function(r) { return 0; },
161 getImageSrc: function(r,c) { return null }, 181 getImageSrc: function(r,c) { return null },
@@ -773,106 +793,104 @@ var fireflix = {
773 this.searchresult_props.hidden = false; 793 this.searchresult_props.hidden = false;
774 }else{ 794 }else{
775 this.searchresult_description.value=p.description?p.description:null; 795 this.searchresult_description.value=p.description?p.description:null;
776 } 796 }
777 } 797 }
778 } 798 }
779 }, 799 },
780 on_cmd_open: function(ev) { 800 on_cmd_open: function(ev) {
781 if(this.selection.currentIndex<0) 801 if(this.selection.currentIndex<0)
782 return; 802 return;
783 var p = this.photos[this.selection.currentIndex]; 803 var p = this.photos[this.selection.currentIndex];
784 if(!p.id) 804 if(!p.id)
785 return; 805 return;
786 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); 806 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p'));
787 } 807 }
788 }, 808 },
789 809
790 photo_html: function(p,i,l) { 810 photo_html: function(p,i,l) {
791 // TODO: add alt/title when possible 811 // TODO: add alt/title when possible
792 var rv = 812 var rv =
793 '<a href="'+this.flickr.make_photo_url(p,l)+'">' + 813 '<a href="'+this.flickr.make_photo_url(p,l)+'">' +
794 '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+ 814 '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+
795 '</a>'; 815 '</a>';
796 return rv; 816 return rv;
797 }, 817 },
798 build_html: function(photos,uti,utl) { 818 build_html: function(photos,uti,utl) {
799 var rv = ''; 819 var rv = '';
800 for(var i in photos) { 820 for(var i in photos) {
801 var p = photos[i]; 821 var p = photos[i];
802 rv += this.photo_html(p,utl,uti)+'\n'; 822 rv += this.photo_html(p,utl,uti)+'\n';
803 } 823 }
804 return rv; 824 return rv;
805 }, 825 },
806 826
807 popup_content: function(s) { 827 popup_content: function(s) {
808 window.openDialog( 828 window.openDialog(
809 "chrome://fireflix/content/generated-content.xul", 829 "chrome://fireflix/content/generated-content.xul",
810 null, "dialog,chrome", this, s ); 830 null, "dialog,chrome", this, s );
811 }, 831 },
812 copy_to_clipboard: function(s) { 832 copy_to_clipboard: function(s) {
813 var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"] 833 var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
814 .getService(Components.interfaces.nsIClipboardHelper); 834 .getService(Components.interfaces.nsIClipboardHelper);
815 ch.copyString(s); 835 ch.copyString(s);
816 }, 836 },
817 openTab: function(l) { 837 openTab: function(l) {
818 var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService( 838 var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(
819 Components.interfaces.nsIWindowMediator ); 839 Components.interfaces.nsIWindowMediator );
820 var bw = wm.getMostRecentWindow('navigator:browser'); 840 var bw = wm.getMostRecentWindow('navigator:browser');
821 var b = bw.getBrowser(); 841 var b = bw.getBrowser();
822 var t = b.addTab(l); 842 var t = b.addTab(l);
823 b.selectedTab = t; 843 b.selectedTab = t;
824 }, 844 },
825 845
826 build_menus: function() { 846 build_menus: function() {
827 this.append_html_menu( 847 this.append_html_menu(
828 document.getElementById('sets_html_menu'), 848 document.getElementById('sets_html_menu'),
829 'stm_','m_bop','cmdset_sets','cmd_sets_html' 849 'stm_','m_bop','cmdset_sets','cmd_sets_html'
830 ); 850 );
831 this.append_html_menu( 851 this.append_html_menu(
832 document.getElementById('uploads_html_menu'), 852 document.getElementById('uploads_html_menu'),
833 'stm_','m_bop','cmdset_uploads','cmd_uploads_html' 853 'stm_','m_bop','cmdset_uploads','cmd_uploads_html'
834 ); 854 );
835 return; 855 return;
836 }, 856 },
837 append_html_menu: function(m,imgt,lnkt,csid,cpfx) { 857 append_html_menu: function(m,imgt,lnkt,csid,cpfx) {
838 var mp = m.appendChild(document.createElement('menupopup')); 858 var mp = m.appendChild(document.createElement('menupopup'));
839 var t; 859 var t;
840 t=mp.appendChild(document.createElement('menuitem')); 860 t=mp.appendChild(document.createElement('menuitem'));
841 t.setAttribute('label',this.loc_strings.getString('menutitle_Images')); 861 t.setAttribute('label',this.loc_strings.getString('menutitle_Images'));
842 t.setAttribute('class','menuhead');t.setAttribute('disabled','true'); 862 t.setAttribute('class','menuhead');t.setAttribute('disabled','true');
843 mp.appendChild(document.createElement('menuseparator')); 863 mp.appendChild(document.createElement('menuseparator'));
844 var cs = document.getElementById(csid); 864 var cs = document.getElementById(csid);
845 for(var iti=0;iti<imgt.length;++iti) { 865 for(var iti=0;iti<imgt.length;++iti) {
846 t = mp.appendChild(document.createElement('menu')); 866 t = mp.appendChild(document.createElement('menu'));
847 t.setAttribute('label',this.loc_strings.getString('urltype_'+imgt.charAt(iti))); 867 t.setAttribute('label',this.loc_strings.getString('urltype_'+imgt.charAt(iti)));
848 var smp = t.appendChild(document.createElement('menupopup')); 868 var smp = t.appendChild(document.createElement('menupopup'));
849 t=smp.appendChild(document.createElement('menuitem')); 869 t=smp.appendChild(document.createElement('menuitem'));
850 t.setAttribute('label',this.loc_strings.getString('menutitle_Links')); 870 t.setAttribute('label',this.loc_strings.getString('menutitle_Links'));
851 t.setAttribute('class','menuhead');t.setAttribute('disabled','true'); 871 t.setAttribute('class','menuhead');t.setAttribute('disabled','true');
852 smp.appendChild(document.createElement('menuseparator')); 872 smp.appendChild(document.createElement('menuseparator'));
853 for(var lti=0;lti<lnkt.length;++lti) { 873 for(var lti=0;lti<lnkt.length;++lti) {
854 var csfx = imgt.charAt(iti)+lnkt.charAt(lti); 874 var csfx = imgt.charAt(iti)+lnkt.charAt(lti);
855 t=smp.appendChild(document.createElement('menuitem')); 875 t=smp.appendChild(document.createElement('menuitem'));
856 t.setAttribute('label',this.loc_strings.getString('urltype_'+lnkt.charAt(lti))); 876 t.setAttribute('label',this.loc_strings.getString('urltype_'+lnkt.charAt(lti)));
857 t.setAttribute('command',cpfx+'_'+csfx); 877 t.setAttribute('command',cpfx+'_'+csfx);
858 t=cs.appendChild(document.createElement('command')); 878 t=cs.appendChild(document.createElement('command'));
859 t.setAttribute('id',cpfx+'_'+csfx); 879 t.setAttribute('id',cpfx+'_'+csfx);
860 t.setAttribute('oncommand','fireflix.on_'+cpfx+"('"+csfx+"',event)"); 880 t.setAttribute('oncommand','fireflix.on_'+cpfx+"('"+csfx+"',event)");
861 } 881 }
862 } 882 }
863 return mp; 883 return mp;
864 }, 884 },
865 885
866 flickr_failure: function(x,s,c,m) { 886 flickr_failure: function(x,s,c,m) {
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 }
877 895
878}; 896};
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
@@ -1,79 +1,81 @@
1<!ENTITY % autoconf SYSTEM "chrome://fireflix/content/autoconf.dtd"> 1<!ENTITY % autoconf SYSTEM "chrome://fireflix/content/autoconf.dtd">
2%autoconf; 2%autoconf;
3 3
4<!-- About Box --> 4<!-- About Box -->
5 5
6<!ENTITY aboutFireflix "About Fireflix" > 6<!ENTITY aboutFireflix "About Fireflix" >
7<!ENTITY about.ok.label "OK"> 7<!ENTITY about.ok.label "OK">
8<!ENTITY about.license.label "License"> 8<!ENTITY about.license.label "License">
9<!ENTITY about.license.tip "Show copying policy"> 9<!ENTITY about.license.tip "Show copying policy">
10 10
11<!-- COPYING --> 11<!-- COPYING -->
12 12
13<!ENTITY copying.title "Filreflix: copying policy"> 13<!ENTITY copying.title "Filreflix: copying policy">
14 14
15<!-- Sidebar --> 15<!-- Sidebar -->
16 16
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" >
25<!ENTITY panel.tabs.sets "Sets" > 27<!ENTITY panel.tabs.sets "Sets" >
26<!ENTITY panel.tabs.tags "Tags" > 28<!ENTITY panel.tabs.tags "Tags" >
27<!ENTITY panel.tabs.upload "Upload" > 29<!ENTITY panel.tabs.upload "Upload" >
28 30
29<!ENTITY panel.search.cmd_search.label "Search" > 31<!ENTITY panel.search.cmd_search.label "Search" >
30<!ENTITY panel.search.search_for.label "Search for:" > 32<!ENTITY panel.search.search_for.label "Search for:" >
31<!ENTITY panel.search.mode.tagsonly.label "tags"> 33<!ENTITY panel.search.mode.tagsonly.label "tags">
32<!ENTITY panel.search.mode.tagsonly.tip "Search tags only"> 34<!ENTITY panel.search.mode.tagsonly.tip "Search tags only">
33<!ENTITY panel.search.mode.mine.label "mine"> 35<!ENTITY panel.search.mode.mine.label "mine">
34<!ENTITY panel.search.col.title.label "Title"> 36<!ENTITY panel.search.col.title.label "Title">
35<!ENTITY panel.search.cmd_search_open.label "Open"> 37<!ENTITY panel.search.cmd_search_open.label "Open">
36 38
37<!ENTITY panel.sets.name.label "Set"> 39<!ENTITY panel.sets.name.label "Set">
38<!ENTITY panel.sets.name.tip "Photoset name"> 40<!ENTITY panel.sets.name.tip "Photoset name">
39<!ENTITY panel.sets.photos.label "Photos"> 41<!ENTITY panel.sets.photos.label "Photos">
40<!ENTITY panel.sets.photos.tip "Number of photos in set"> 42<!ENTITY panel.sets.photos.tip "Number of photos in set">
41 43
42<!ENTITY panel.sets.cmd_refresh_sets "Refresh"> 44<!ENTITY panel.sets.cmd_refresh_sets "Refresh">
43<!ENTITY panel.sets.cmd_properties "Properties"> 45<!ENTITY panel.sets.cmd_properties "Properties">
44 46
45<!ENTITY panel.sets.generate_html "Generate HTML"> 47<!ENTITY panel.sets.generate_html "Generate HTML">
46 48
47<!ENTITY panel.setphotos.title.label "Title"> 49<!ENTITY panel.setphotos.title.label "Title">
48<!ENTITY panel.setphotos.title.tip "Picture title"> 50<!ENTITY panel.setphotos.title.tip "Picture title">
49<!ENTITY panel.setphotos.taken.label "Taken"> 51<!ENTITY panel.setphotos.taken.label "Taken">
50<!ENTITY panel.setphotos.taken.tip "When the picture was taken"> 52<!ENTITY panel.setphotos.taken.tip "When the picture was taken">
51<!ENTITY panel.setphotos.upload.label "Uploaded"> 53<!ENTITY panel.setphotos.upload.label "Uploaded">
52<!ENTITY panel.setphotos.upload.tip "When the picure was uploaded"> 54<!ENTITY panel.setphotos.upload.tip "When the picure was uploaded">
53 55
54<!ENTITY panel.tagslist.tag.label "Tag"> 56<!ENTITY panel.tagslist.tag.label "Tag">
55 57
56<!ENTITY panel.uploadlist.file.label "File name"> 58<!ENTITY panel.uploadlist.file.label "File name">
57<!ENTITY panel.uploadlist.title.label "Title"> 59<!ENTITY panel.uploadlist.title.label "Title">
58<!ENTITY panel.uploadlist.status.label "Status"> 60<!ENTITY panel.uploadlist.status.label "Status">
59 61
60<!ENTITY panel.upload_props.filename.label "File:"> 62<!ENTITY panel.upload_props.filename.label "File:">
61<!ENTITY panel.upload_props.title.label "Title:"> 63<!ENTITY panel.upload_props.title.label "Title:">
62<!ENTITY panel.upload_props.tags.label "Tags:"> 64<!ENTITY panel.upload_props.tags.label "Tags:">
63 65
64<!ENTITY panel.uploads.upload.label "Upload"> 66<!ENTITY panel.uploads.upload.label "Upload">
65<!ENTITY panel.uploads.clear.label "Clear"> 67<!ENTITY panel.uploads.clear.label "Clear">
66<!ENTITY panel.uploads.remove.label "Remove"> 68<!ENTITY panel.uploads.remove.label "Remove">
67<!ENTITY panel.uploads.add.label "Add"> 69<!ENTITY panel.uploads.add.label "Add">
68<!ENTITY panel.uploads.generate_html "Generate HTML"> 70<!ENTITY panel.uploads.generate_html "Generate HTML">
69 71
70<!ENTITY generated.title "Fireflix: Generated content"> 72<!ENTITY generated.title "Fireflix: Generated content">
71<!ENTITY generated.copy "copy"> 73<!ENTITY generated.copy "copy">
72 74
73<!ENTITY browser.sidebar.label "Fireflix"> 75<!ENTITY browser.sidebar.label "Fireflix">
74<!ENTITY browser.sidebar.title "Fireflix"> 76<!ENTITY browser.sidebar.title "Fireflix">
75 77
76<!ENTITY photosetprops.title "Photoset properties"> 78<!ENTITY photosetprops.title "Photoset properties">
77<!ENTITY photosetprops.set_title.label "Photoset title:"> 79<!ENTITY photosetprops.set_title.label "Photoset title:">
78<!ENTITY photosetprops.set_desc.label "Photoset description:"> 80<!ENTITY photosetprops.set_desc.label "Photoset description:">
79 81