summaryrefslogtreecommitdiffabout
path: root/content
authorMichael Krelin <hacker@klever.net>2006-11-16 21:54:55 (UTC)
committer Michael Krelin <hacker@klever.net>2006-11-16 21:54:55 (UTC)
commit8db8cc953a91ccba910228bdaf2563ffd92f3d61 (patch) (unidiff)
treecce7bfe83b5273f309f8b3a47ae0373bc029910d /content
parent26b7e66a091703dab249ca11f00a1cb49987c393 (diff)
downloadfireflix-8db8cc953a91ccba910228bdaf2563ffd92f3d61.zip
fireflix-8db8cc953a91ccba910228bdaf2563ffd92f3d61.tar.gz
fireflix-8db8cc953a91ccba910228bdaf2563ffd92f3d61.tar.bz2
open flickr page on enter or dblclicking photo in set browser
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@226 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (limited to 'content') (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix-panel.xul9
-rw-r--r--content/fireflix.js8
2 files changed, 13 insertions, 4 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul
index 2356c82..b2ca7dc 100644
--- a/content/fireflix-panel.xul
+++ b/content/fireflix-panel.xul
@@ -1,294 +1,295 @@
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="util.js" /> 17 <script type="application/x-javascript" src="util.js" />
18 <script type="application/x-javascript" src="flickr.js" /> 18 <script type="application/x-javascript" src="flickr.js" />
19 <script type="application/x-javascript" src="fireflix.js" /> 19 <script type="application/x-javascript" src="fireflix.js" />
20 20
21 <stringbundleset> 21 <stringbundleset>
22 <stringbundle id="loc_strings" src="chrome://fireflix/locale/fireflix.properties" /> 22 <stringbundle id="loc_strings" src="chrome://fireflix/locale/fireflix.properties" />
23 </stringbundleset> 23 </stringbundleset>
24 24
25 <commandset> 25 <commandset>
26 <command id="cmd_auth_auth" label="&panel.auth.auth.label;" 26 <command id="cmd_auth_auth" label="&panel.auth.auth.label;"
27 oncommand="fireflix.on_cmd_auth()"/> 27 oncommand="fireflix.on_cmd_auth()"/>
28 <command id="cmd_auth_done" label="&panel.auth.done.label;" 28 <command id="cmd_auth_done" label="&panel.auth.done.label;"
29 oncommand="fireflix.on_cmd_auth_done()" disabled="true"/> 29 oncommand="fireflix.on_cmd_auth_done()" disabled="true"/>
30 <command id="cmd_auth_open_flickr" label="&panel.auth.flickr.label;" 30 <command id="cmd_auth_open_flickr" label="&panel.auth.flickr.label;"
31 oncommand="fireflix.openTab('http://www.flickr.com/')" /> 31 oncommand="fireflix.openTab('http://www.flickr.com/')" />
32 <command id="cmd_auth_unauth" label="&panel.auth.unauth.label;" 32 <command id="cmd_auth_unauth" label="&panel.auth.unauth.label;"
33 oncommand="fireflix.on_cmd_auth_unauth()" /> 33 oncommand="fireflix.on_cmd_auth_unauth()" />
34 <command id="cmd_help" label="?" 34 <command id="cmd_help" label="?"
35 oncommand="fireflix.openTab('chrome://fireflix/content/help.xml')" /> 35 oncommand="fireflix.openTab('chrome://fireflix/content/help.xml')" />
36 </commandset> 36 </commandset>
37 37
38 <popupset> 38 <popupset>
39 <popup id="auth_menu"> 39 <popup id="auth_menu">
40 <menuitem command="cmd_auth_auth"/> 40 <menuitem command="cmd_auth_auth"/>
41 <menuitem command="cmd_auth_done" hidden="true" id="menu_auth_done"/> 41 <menuitem command="cmd_auth_done" hidden="true" id="menu_auth_done"/>
42 <menuitem command="cmd_auth_unauth" /> 42 <menuitem command="cmd_auth_unauth" />
43 <menuseparator/> 43 <menuseparator/>
44 <menuitem command="cmd_auth_open_flickr"/> 44 <menuitem command="cmd_auth_open_flickr"/>
45 </popup> 45 </popup>
46 </popupset> 46 </popupset>
47 47
48 <commandset id="cmdset_search"> 48 <commandset id="cmdset_search">
49 <command id="cmd_search" label="&panel.search.cmd_search.label;" 49 <command id="cmd_search" label="&panel.search.cmd_search.label;"
50 oncommand="fireflix.foundphotos.search_photos()"/> 50 oncommand="fireflix.foundphotos.search_photos()"/>
51 <command id="cmd_search_open" label="&panel.search.cmd_search_open.label;" 51 <command id="cmd_search_open" label="&panel.search.cmd_search_open.label;"
52 oncommand="fireflix.foundphotos.on_cmd_open(event)" /> 52 oncommand="fireflix.foundphotos.on_cmd_open(event)" />
53 <command id="cmd_search_prev_page" 53 <command id="cmd_search_prev_page"
54 label="&panel.search.cmd_search_prev_page.label;" 54 label="&panel.search.cmd_search_prev_page.label;"
55 oncommand="fireflix.foundphotos.on_cmd_prev(event)" disabled="true"/> 55 oncommand="fireflix.foundphotos.on_cmd_prev(event)" disabled="true"/>
56 <command id="cmd_search_next_page" 56 <command id="cmd_search_next_page"
57 label="&panel.search.cmd_search_next_page.label;" 57 label="&panel.search.cmd_search_next_page.label;"
58 oncommand="fireflix.foundphotos.on_cmd_next(event)" disabled="true"/> 58 oncommand="fireflix.foundphotos.on_cmd_next(event)" disabled="true"/>
59 </commandset> 59 </commandset>
60 60
61 <commandset id="cmdset_sets"> 61 <commandset id="cmdset_sets">
62 <command id="cmd_refresh_sets" label="&panel.sets.cmd_refresh_sets;" 62 <command id="cmd_refresh_sets" label="&panel.sets.cmd_refresh_sets;"
63 oncommand="fireflix.on_refresh_sets()" /> 63 oncommand="fireflix.on_refresh_sets()" />
64 <command id="cmd_set_props" label="&panel.sets.cmd_properties;" 64 <command id="cmd_set_props" label="&panel.sets.cmd_properties;"
65 oncommand="fireflix.on_set_props()" disabled="true" /> 65 oncommand="fireflix.on_set_props()" disabled="true" />
66 </commandset> 66 </commandset>
67 67
68 <popupset> 68 <popupset>
69 <popup id="sets_menu"> 69 <popup id="sets_menu">
70 <menuitem command="cmd_set_props"/> 70 <menuitem command="cmd_set_props"/>
71 <menuitem command="cmd_refresh_sets"/> 71 <menuitem command="cmd_refresh_sets"/>
72 <menuseparator/> 72 <menuseparator/>
73 <menu label="&panel.sets.generate_html;" id="sets_html_menu"/> 73 <menu label="&panel.sets.generate_html;" id="sets_html_menu"/>
74 </popup> 74 </popup>
75 </popupset> 75 </popupset>
76 76
77 <commandset id="cmdset_uploads"> 77 <commandset id="cmdset_uploads">
78 <command id="cmd_uploads_clear" label="&panel.uploads.clear.label;" 78 <command id="cmd_uploads_clear" label="&panel.uploads.clear.label;"
79 oncommand="fireflix.uploads.on_clear()" /> 79 oncommand="fireflix.uploads.on_clear()" />
80 <command id="cmd_uploads_upload" label="&panel.uploads.upload.label;" 80 <command id="cmd_uploads_upload" label="&panel.uploads.upload.label;"
81 oncommand="fireflix.uploads.on_upload()" /> 81 oncommand="fireflix.uploads.on_upload()" />
82 <command id="cmd_uploads_remove" label="&panel.uploads.remove.label;" 82 <command id="cmd_uploads_remove" label="&panel.uploads.remove.label;"
83 oncommand="fireflix.uploads.on_remove()" /> 83 oncommand="fireflix.uploads.on_remove()" />
84 <command id="cmd_uploads_add" label="&panel.uploads.add.label;" 84 <command id="cmd_uploads_add" label="&panel.uploads.add.label;"
85 oncommand="fireflix.uploads.on_add()" /> 85 oncommand="fireflix.uploads.on_add()" />
86 </commandset> 86 </commandset>
87 87
88 <popupset> 88 <popupset>
89 <popup id="uploads_menu"> 89 <popup id="uploads_menu">
90 <menuitem command="cmd_uploads_add"/> 90 <menuitem command="cmd_uploads_add"/>
91 <menuitem command="cmd_uploads_clear"/> 91 <menuitem command="cmd_uploads_clear"/>
92 <menuitem command="cmd_uploads_remove"/> 92 <menuitem command="cmd_uploads_remove"/>
93 <menuseparator/> 93 <menuseparator/>
94 <menuitem command="cmd_uploads_upload"/> 94 <menuitem command="cmd_uploads_upload"/>
95 <menuseparator/> 95 <menuseparator/>
96 <menu label="&panel.uploads.generate_html;" id="uploads_html_menu"/> 96 <menu label="&panel.uploads.generate_html;" id="uploads_html_menu"/>
97 </popup> 97 </popup>
98 </popupset> 98 </popupset>
99 99
100 <vbox class="wholething" flex="1"> 100 <vbox class="wholething" flex="1">
101 101
102 <groupbox context="auth_menu"> 102 <groupbox context="auth_menu">
103 <caption label="&panel.auth_info;"/> 103 <caption label="&panel.auth_info;"/>
104 <hbox> 104 <hbox>
105 <vbox pack="center" flex="1"> 105 <vbox pack="center" flex="1">
106 <label id="auth_info" value="&panel.no_auth_info;" disabled="true" crop="end"/> 106 <label id="auth_info" value="&panel.no_auth_info;" disabled="true" crop="end"/>
107 </vbox> 107 </vbox>
108 <button class="lean" id="b_auth" command="cmd_auth_auth"/> 108 <button class="lean" id="b_auth" command="cmd_auth_auth"/>
109 <button class="lean" id="b_auth_done" command="cmd_auth_done" hidden="true"/> 109 <button class="lean" id="b_auth_done" command="cmd_auth_done" hidden="true"/>
110 <button class="lean" command="cmd_auth_open_flickr" 110 <button class="lean" command="cmd_auth_open_flickr"
111 tooltiptext="&panel.auth.flickr.tip;"/> 111 tooltiptext="&panel.auth.flickr.tip;"/>
112 <button class="lean" command="cmd_help"/> 112 <button class="lean" command="cmd_help"/>
113 </hbox> 113 </hbox>
114 </groupbox> 114 </groupbox>
115 115
116 <tabbox flex="1" id="fireflix_tabs"> 116 <tabbox flex="1" id="fireflix_tabs">
117 117
118 <tabs> 118 <tabs>
119 <tab label="&panel.tabs.search;"/> 119 <tab label="&panel.tabs.search;"/>
120 <tab label="&panel.tabs.sets;"/> 120 <tab label="&panel.tabs.sets;"/>
121 <tab label="&panel.tabs.tags;" hidden="true"/> <!-- TODO: --> 121 <tab label="&panel.tabs.tags;" hidden="true"/> <!-- TODO: -->
122 <tab id="tab_upload" label="&panel.tabs.upload;"/> 122 <tab id="tab_upload" label="&panel.tabs.upload;"/>
123 </tabs> 123 </tabs>
124 124
125 <tabpanels flex="1"> 125 <tabpanels flex="1">
126 126
127 <tabpanel id="tabpanel_search" flex="1"> 127 <tabpanel id="tabpanel_search" flex="1">
128 <vbox flex="1"> 128 <vbox flex="1">
129 <groupbox class="search_params" orient="vertical" onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.foundphotos.search_photos()"> 129 <groupbox class="search_params" orient="vertical" onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.foundphotos.search_photos()">
130 <hbox> 130 <hbox>
131 <vbox pack="center"> 131 <vbox pack="center">
132 <label control="search_for" value="&panel.search.search_for.label;" accesskey="s"/> 132 <label control="search_for" value="&panel.search.search_for.label;" accesskey="s"/>
133 </vbox> 133 </vbox>
134 <textbox id="search_for" flex="1"/> 134 <textbox id="search_for" flex="1"/>
135 </hbox> 135 </hbox>
136 <hbox> 136 <hbox>
137 <checkbox id="search_tags" label="&panel.search.mode.tagsonly.label;" 137 <checkbox id="search_tags" label="&panel.search.mode.tagsonly.label;"
138 tooltiptext="&panel.search.mode.tagsonly.tip;" checked="false" 138 tooltiptext="&panel.search.mode.tagsonly.tip;" checked="false"
139 accesskey="t" /> 139 accesskey="t" />
140 <checkbox id="search_mine" label="&panel.search.mode.mine.label;" checked="true" accesskey="m"/> 140 <checkbox id="search_mine" label="&panel.search.mode.mine.label;" checked="true" accesskey="m"/>
141 <spacer flex="1"/> 141 <spacer flex="1"/>
142 <button class="lean" command="cmd_search"/> 142 <button class="lean" command="cmd_search"/>
143 </hbox> 143 </hbox>
144 </groupbox> 144 </groupbox>
145 <hbox> 145 <hbox>
146 <button class="lean" command="cmd_search_prev_page"/> 146 <button class="lean" command="cmd_search_prev_page"/>
147 <spacer flex="1"/> 147 <spacer flex="1"/>
148 <label id="search_page" hidden="true"/> 148 <label id="search_page" hidden="true"/>
149 <spacer flex="1"/> 149 <spacer flex="1"/>
150 <button class="lean" command="cmd_search_next_page"/> 150 <button class="lean" command="cmd_search_next_page"/>
151 </hbox> 151 </hbox>
152 <tree id="searchresults" rows="2" flex="1" 152 <tree id="searchresults" rows="2" flex="1"
153 onselect="fireflix.foundphotos.on_select()" 153 onselect="fireflix.foundphotos.on_select()"
154 ondblclick="fireflix.foundphotos.on_cmd_open(event)" 154 ondblclick="fireflix.foundphotos.on_cmd_open(event)"
155 onkeypress="if(event.keyCode==event.DOM_VK_RETURN) 155 onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.foundphotos.on_cmd_open(event)">
156 fireflix.foundphotos.on_cmd_open(event)">
157 <treecols> 156 <treecols>
158 <treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" /> 157 <treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" />
159 </treecols> 158 </treecols>
160 <treechildren/> 159 <treechildren/>
161 </tree> 160 </tree>
162 <groupbox id="searchresult_props" orient="horizontal" hidden="true"> 161 <groupbox id="searchresult_props" orient="horizontal" hidden="true">
163 <vbox width="100" pack="center"> 162 <vbox width="100" pack="center">
164 <hbox pack="center"> 163 <hbox pack="center">
165 <image id="search_photo" 164 <image id="search_photo"
166 ondblclick="fireflix.foundphotos.on_cmd_open(event)"/> 165 ondblclick="fireflix.foundphotos.on_cmd_open(event)"/>
167 </hbox> 166 </hbox>
168 </vbox> 167 </vbox>
169 <vbox flex="1"> 168 <vbox flex="1">
170 <label id="searchresult_title" crop="end"/> 169 <label id="searchresult_title" crop="end"/>
171 <hbox flex="1" pack="center"> 170 <hbox flex="1" pack="center">
172 <div flex="1" id="searchresult_description" xmlns="http://www.w3.org/1999/xhtml"/> 171 <div flex="1" id="searchresult_description" xmlns="http://www.w3.org/1999/xhtml"/>
173 </hbox> 172 </hbox>
174 <hbox pack="end"> 173 <hbox pack="end">
175 <button command="cmd_search_open"/> 174 <button command="cmd_search_open"/>
176 </hbox> 175 </hbox>
177 </vbox> 176 </vbox>
178 </groupbox> 177 </groupbox>
179 </vbox> 178 </vbox>
180 </tabpanel> 179 </tabpanel>
181 180
182 <tabpanel id="tabpanel_sets" flex="1" 181 <tabpanel id="tabpanel_sets" flex="1"
183 onkeypress="if(event.keyCode==event.DOM_VK_RETURN) 182 onkeypress="if(event.keyCode==event.DOM_VK_RETURN)
184 document.getElementById('setphotos').focus()"> 183 document.getElementById('setphotos').focus()">
185 <vbox flex="1"> 184 <vbox flex="1">
186 <tree id="setslist" rows="2" onselect="fireflix.photosets.on_select()" 185 <tree id="setslist" rows="2" onselect="fireflix.photosets.on_select()"
187 flex="1" context="sets_menu" 186 flex="1" context="sets_menu"
188 > 187 >
189 <treecols> 188 <treecols>
190 <treecol id="sl_name" label="&panel.sets.name.label;" flex="4" crop="end" align="start" tooltiptext="&panel.sets.name.tip;"/> 189 <treecol id="sl_name" label="&panel.sets.name.label;" flex="4" crop="end" align="start" tooltiptext="&panel.sets.name.tip;"/>
191 <splitter class="tree-splitter" /> 190 <splitter class="tree-splitter" />
192 <treecol id="sl_photos" label="&panel.sets.photos.label;" flex="1" align="end" tooltiptext="&panel.sets.photos.tip;" /> 191 <treecol id="sl_photos" label="&panel.sets.photos.label;" flex="1" align="end" tooltiptext="&panel.sets.photos.tip;" />
193 </treecols> 192 </treecols>
194 <treechildren/> 193 <treechildren/>
195 </tree> 194 </tree>
196 <hbox> 195 <hbox>
197 <button command="cmd_refresh_sets" /> 196 <button command="cmd_refresh_sets" />
198 <button command="cmd_set_props" /> 197 <button command="cmd_set_props" />
199 </hbox> 198 </hbox>
200 <tree id="setphotos" rows="2" onselect="fireflix.photoset.on_select()" 199 <tree id="setphotos" rows="2" onselect="fireflix.photoset.on_select()"
201 flex="1"> 200 flex="1" ondblclick="fireflix.photoset.on_cmd_open(event)"
201 onkeypress="if(event.keyCode==event.DOM_VK_RETURN) fireflix.photoset.on_cmd_open(event)">
202 <treecols> 202 <treecols>
203 <treecol id="sp_title" label="&panel.setphotos.title.label;" flex="1" crop="end" align="start" tooltiptext="&panel.setphotos.title.tip;" /> 203 <treecol id="sp_title" label="&panel.setphotos.title.label;" flex="1" crop="end" align="start" tooltiptext="&panel.setphotos.title.tip;" />
204 <splitter class="tree-splitter" /> 204 <splitter class="tree-splitter" />
205 <treecol id="sp_taken" label="&panel.setphotos.taken.label;" crop="end" align="start" tooltiptext="&panel.setphotos.taken.tip;" hidden="true" /> 205 <treecol id="sp_taken" label="&panel.setphotos.taken.label;" crop="end" align="start" tooltiptext="&panel.setphotos.taken.tip;" hidden="true" />
206 <treecol id="sp_upload" label="&panel.setphotos.upload.label;" crop="end" align="start" tooltiptext="&panel.setphotos.upload.tip;" hidden="true" /> 206 <treecol id="sp_upload" label="&panel.setphotos.upload.label;" crop="end" align="start" tooltiptext="&panel.setphotos.upload.tip;" hidden="true" />
207 </treecols> 207 </treecols>
208 <treechildren/> 208 <treechildren/>
209 </tree> 209 </tree>
210 <groupbox id="set_photo_props" orient="horizontal"> 210 <groupbox id="set_photo_props" orient="horizontal">
211 <vbox width="100" pack="center"> 211 <vbox width="100" pack="center">
212 <hbox pack="center"> 212 <hbox pack="center">
213 <image id="set_photo" hidden="true"/> 213 <image id="set_photo" hidden="true"
214 ondblclick="fireflix.photoset.on_cmd_open(event)" />
214 </hbox> 215 </hbox>
215 </vbox> 216 </vbox>
216 <spacer flex="1"/> 217 <spacer flex="1"/>
217 </groupbox> 218 </groupbox>
218 </vbox> 219 </vbox>
219 </tabpanel> 220 </tabpanel>
220 221
221 <tabpanel id="tabpanel_tags"> 222 <tabpanel id="tabpanel_tags">
222 <listbox id="tagslist" rows="8" flex="1"> 223 <listbox id="tagslist" rows="8" flex="1">
223 <listhead> 224 <listhead>
224 <listheader label="&panel.tagslist.tag.label;"/> 225 <listheader label="&panel.tagslist.tag.label;"/>
225 </listhead> 226 </listhead>
226 <listcols> 227 <listcols>
227 <listcol flex="1"/> 228 <listcol flex="1"/>
228 </listcols> 229 </listcols>
229 </listbox> 230 </listbox>
230 </tabpanel> 231 </tabpanel>
231 232
232 <tabpanel id="tabpanel_upload"> 233 <tabpanel id="tabpanel_upload">
233 <vbox flex="1"> 234 <vbox flex="1">
234 <tree id="uploadlist" rows="2" flex="1" 235 <tree id="uploadlist" rows="2" flex="1"
235 onselect="fireflix.uploads.selectionChanged()" 236 onselect="fireflix.uploads.selectionChanged()"
236 context="uploads_menu"> 237 context="uploads_menu">
237 <treecols> 238 <treecols>
238 <treecol id="up_file" label="&panel.uploadlist.file.label;" flex="4" crop="start" align="start"/> 239 <treecol id="up_file" label="&panel.uploadlist.file.label;" flex="4" crop="start" align="start"/>
239 <splitter class="tree-splitter" /> 240 <splitter class="tree-splitter" />
240 <treecol id="up_title" label="&panel.uploadlist.title.label;" flex="5" crop="end" align="start" /> 241 <treecol id="up_title" label="&panel.uploadlist.title.label;" flex="5" crop="end" align="start" />
241 <splitter class="tree-splitter" /> 242 <splitter class="tree-splitter" />
242 <treecol id="up_status" label="&panel.uploadlist.status.label;" flex="1" crop="end" align="start" /> 243 <treecol id="up_status" label="&panel.uploadlist.status.label;" flex="1" crop="end" align="start" />
243 </treecols> 244 </treecols>
244 <treechildren/> 245 <treechildren/>
245 </tree> 246 </tree>
246 <progressmeter id="upload_progress" mode="undetermined" hidden="true" /> 247 <progressmeter id="upload_progress" mode="undetermined" hidden="true" />
247 <groupbox id="upload_file_props" orient="horizontal" hidden="true"> 248 <groupbox id="upload_file_props" orient="horizontal" hidden="true">
248 <image id="upload_file_preview" width="100" height="100" /> 249 <image id="upload_file_preview" width="100" height="100" />
249 <grid flex="1"> 250 <grid flex="1">
250 <columns> 251 <columns>
251 <column/> 252 <column/>
252 <column flex="1"/> 253 <column flex="1"/>
253 </columns> 254 </columns>
254 <rows> 255 <rows>
255 <row> 256 <row>
256 <label control="upload_filename" 257 <label control="upload_filename"
257 value="&panel.upload_props.filename.label;" /> 258 value="&panel.upload_props.filename.label;" />
258 <textbox id="upload_filename" 259 <textbox id="upload_filename"
259 oninput="fireflix.uploads.propsToSel('filename')"/> 260 oninput="fireflix.uploads.propsToSel('filename')"/>
260 </row> 261 </row>
261 <row> 262 <row>
262 <label control="upload_title" value="&panel.upload_props.title.label;" /> 263 <label control="upload_title" value="&panel.upload_props.title.label;" />
263 <textbox id="upload_title" 264 <textbox id="upload_title"
264 oninput="fireflix.uploads.propsToSel('title')"/> 265 oninput="fireflix.uploads.propsToSel('title')"/>
265 </row> 266 </row>
266 <row> 267 <row>
267 <label control="uplod_tags" value="&panel.upload_props.tags.label;" /> 268 <label control="uplod_tags" value="&panel.upload_props.tags.label;" />
268 <textbox id="upload_tags" 269 <textbox id="upload_tags"
269 oninput="fireflix.uploads.propsToSel('tags')"/> 270 oninput="fireflix.uploads.propsToSel('tags')"/>
270 </row> 271 </row>
271 <!-- TODO: description, public, friend, family --> 272 <!-- TODO: description, public, friend, family -->
272 </rows> 273 </rows>
273 </grid> 274 </grid>
274 </groupbox> 275 </groupbox>
275 <hbox> 276 <hbox>
276 <button class="lean" command="cmd_uploads_add" /> 277 <button class="lean" command="cmd_uploads_add" />
277 <spacer flex="1"/> 278 <spacer flex="1"/>
278 <button class="lean" command="cmd_uploads_remove" /> 279 <button class="lean" command="cmd_uploads_remove" />
279 <spacer flex="1"/> 280 <spacer flex="1"/>
280 <button class="lean" command="cmd_uploads_clear" /> 281 <button class="lean" command="cmd_uploads_clear" />
281 </hbox> 282 </hbox>
282 <hbox pack="center"> 283 <hbox pack="center">
283 <button command="cmd_uploads_upload" flex="1"/> 284 <button command="cmd_uploads_upload" flex="1"/>
284 </hbox> 285 </hbox>
285 </vbox> 286 </vbox>
286 </tabpanel> 287 </tabpanel>
287 288
288 </tabpanels> 289 </tabpanels>
289 290
290 </tabbox> 291 </tabbox>
291 292
292 </vbox> 293 </vbox>
293 294
294</page> 295</page>
diff --git a/content/fireflix.js b/content/fireflix.js
index 0f51397..2ee408f 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -1,957 +1,965 @@
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 pull_elements(this,document,[ 15 pull_elements(this,document,[
16 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth', 16 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth',
17 'menu_auth_done','b_auth','b_auth_done','auth_info', 17 'menu_auth_done','b_auth','b_auth_done','auth_info',
18 'loc_strings','cmd_set_props' 18 'loc_strings','cmd_set_props'
19 ]); 19 ]);
20 this.build_menus(); 20 this.build_menus();
21 this.foundphotos.init(this); 21 this.foundphotos.init(this);
22 this.photosets.init(this); 22 this.photosets.init(this);
23 this.photoset.init(this); 23 this.photoset.init(this);
24 this.uploads.init(this); 24 this.uploads.init(this);
25 this.uploadObserver.init(this); 25 this.uploadObserver.init(this);
26 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; 26 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3';
27 this.flickr.api_shs = '9c33c9e2f0f0cfd5'; 27 this.flickr.api_shs = '9c33c9e2f0f0cfd5';
28 this.flickr.prefs_root = 'net.klever.kin.fireflix'; 28 this.flickr.prefs_root = 'net.klever.kin.fireflix';
29 this.flickr.load_token(); 29 this.flickr.load_token();
30 this.no_auth_info_label = this.auth_info.value; 30 this.no_auth_info_label = this.auth_info.value;
31 this.set_auth_state(this.flickr.token,false); 31 this.set_auth_state(this.flickr.token,false);
32 if(this.flickr.token) { 32 if(this.flickr.token) {
33 this.refresh_stuff(); 33 this.refresh_stuff();
34 }else{ 34 }else{
35 this.on_cmd_auth(); 35 this.on_cmd_auth();
36 } 36 }
37 }, 37 },
38 set_auth_state: function(au,inp) { /* authorized, in progress */ 38 set_auth_state: function(au,inp) { /* authorized, in progress */
39 this.cmd_auth_unauth.disabled = !au; 39 this.cmd_auth_unauth.disabled = !au;
40 this.b_auth.hidden = au || inp; 40 this.b_auth.hidden = au || inp;
41 this.b_auth_done.hidden = !inp; 41 this.b_auth_done.hidden = !inp;
42 this.menu_auth_done.hidden = !inp; 42 this.menu_auth_done.hidden = !inp;
43 this.cmd_auth_done.setAttribute('disabled',!inp); 43 this.cmd_auth_done.setAttribute('disabled',!inp);
44 this.auth_info.disabled = !au; 44 this.auth_info.disabled = !au;
45 if(au) { 45 if(au) {
46 this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */ 46 this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */
47 }else{ 47 }else{
48 this.auth_info.value = this.no_auth_info_label; 48 this.auth_info.value = this.no_auth_info_label;
49 } 49 }
50 }, 50 },
51 on_cmd_auth: function() { 51 on_cmd_auth: function() {
52 var _this = this; 52 var _this = this;
53 this.flickr.authorize_0( 53 this.flickr.authorize_0(
54 'delete', 54 'delete',
55 function(x,f,u) { 55 function(x,f,u) {
56 _this.openTab(u); 56 _this.openTab(u);
57 _this.set_auth_state(_this.flickr.token,true); 57 _this.set_auth_state(_this.flickr.token,true);
58 }, function(x,s,c,m) { 58 }, function(x,s,c,m) {
59 _this.flickr_failure(x,s,c,m); 59 _this.flickr_failure(x,s,c,m);
60 } 60 }
61 ); 61 );
62 }, 62 },
63 on_cmd_auth_done: function() { 63 on_cmd_auth_done: function() {
64 this.set_auth_state(this.flickr.token,false); 64 this.set_auth_state(this.flickr.token,false);
65 var _this = this; 65 var _this = this;
66 this.flickr.authorize_1( 66 this.flickr.authorize_1(
67 function() { 67 function() {
68 _this.flickr.save_token(); 68 _this.flickr.save_token();
69 _this.refresh_stuff(); 69 _this.refresh_stuff();
70 _this.set_auth_state(_this.flickr.token,false); 70 _this.set_auth_state(_this.flickr.token,false);
71 _this.auth_info.value = 71 _this.auth_info.value =
72 _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; 72 _this.flickr.user.fullname+' ['+_this.flickr.user.username+']';
73 }, function(x,s,c,m) { 73 }, function(x,s,c,m) {
74 _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ 74 _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */
75 _this.flickr_failure(x,s,c,m); 75 _this.flickr_failure(x,s,c,m);
76 } 76 }
77 ); 77 );
78 }, 78 },
79 on_cmd_auth_unauth: function() { 79 on_cmd_auth_unauth: function() {
80 this.flickr.reset_token(); 80 this.flickr.reset_token();
81 this.set_auth_state(false,false); 81 this.set_auth_state(false,false);
82 }, 82 },
83 83
84 refresh_sets: function() { this.photosets.refresh_sets(); }, 84 refresh_sets: function() { this.photosets.refresh_sets(); },
85 refresh_stuff: function() { 85 refresh_stuff: function() {
86 this.refresh_sets(); 86 this.refresh_sets();
87 this.refresh_user_tags(); 87 this.refresh_user_tags();
88 }, 88 },
89 89
90 /* photoset treeview */ 90 /* photoset treeview */
91 photoset: { 91 photoset: {
92 photos: new Array(), 92 photos: new Array(),
93 fireflix: null, 93 fireflix: null,
94 init: function(f) { 94 init: function(f) {
95 this.fireflix = f; 95 this.fireflix = f;
96 pull_elements(this,document,[ 'set_photo' ]); 96 pull_elements(this,document,[ 'set_photo' ]);
97 document.getElementById('setphotos').view = this; 97 document.getElementById('setphotos').view = this;
98 }, 98 },
99 rowCount: 0, 99 rowCount: 0,
100 getCellText: function(r,c) { 100 getCellText: function(r,c) {
101 var p = this.photos[r]; 101 var p = this.photos[r];
102 if(c.id=='sp_title') return p.title; 102 if(c.id=='sp_title') return p.title;
103 if(c.id=='sp_taken') return p.datetaken; 103 if(c.id=='sp_taken') return p.datetaken;
104 if(c.id=='sp_upload') { 104 if(c.id=='sp_upload') {
105 var du = new Date(p.dateupload*1000); 105 var du = new Date(p.dateupload*1000);
106 var rv = du.getFullYear()+'-'+(du.getMonth()+1)+'-'+du.getDate() 106 var rv = du.getFullYear()+'-'+(du.getMonth()+1)+'-'+du.getDate()
107 +' '+ 107 +' '+
108 du.getHours()+':'+du.getMinutes()+':'+du.getSeconds(); 108 du.getHours()+':'+du.getMinutes()+':'+du.getSeconds();
109 return rv.replace(/(\D)(\d)(\D)/,'$10$2$3'); 109 return rv.replace(/(\D)(\d)(\D)/,'$10$2$3');
110 } 110 }
111 return c.id; 111 return c.id;
112 }, 112 },
113 setTree: function(t) { this.tree = t }, 113 setTree: function(t) { this.tree = t },
114 isContainer: function(r) { return false; }, 114 isContainer: function(r) { return false; },
115 isSeparator: function(r) { return false; }, 115 isSeparator: function(r) { return false; },
116 isSorted: function(r) { return false; }, 116 isSorted: function(r) { return false; },
117 getLevel: function(r) { return 0; }, 117 getLevel: function(r) { return 0; },
118 getImageSrc: function(r,c) { return null }, 118 getImageSrc: function(r,c) { return null },
119 getRowProperties: function(r,p) {}, 119 getRowProperties: function(r,p) {},
120 getCellProperties: function(cid,cel,p) {}, 120 getCellProperties: function(cid,cel,p) {},
121 getColumnProperties: function(cid,cel,p) { }, 121 getColumnProperties: function(cid,cel,p) { },
122 cycleHeader: function(cid,e) { }, 122 cycleHeader: function(cid,e) { },
123 getParentIndex: function(r) { return -1; }, 123 getParentIndex: function(r) { return -1; },
124 drop: function(r,o) { }, 124 drop: function(r,o) { },
125 canDropBeforeAfter: function(r,b) { return false }, 125 canDropBeforeAfter: function(r,b) { return false },
126 126
127 importXPR: function(xp) { 127 importXPR: function(xp) {
128 this.tree.beginUpdateBatch(); 128 this.tree.beginUpdateBatch();
129 this.photos = new Array(); 129 this.photos = new Array();
130 var n; while(n=xp.iterateNext()) { 130 var n; while(n=xp.iterateNext()) {
131 this.photos.push(new Photo(n)); 131 this.photos.push(new Photo(n));
132 } 132 }
133 this.rowCount = this.photos.length; 133 this.rowCount = this.photos.length;
134 this.tree.endUpdateBatch(); 134 this.tree.endUpdateBatch();
135 }, 135 },
136 load_photos: function(psid) { 136 load_photos: function(psid) {
137 var _this = this; 137 var _this = this;
138 this.fireflix.flickr.api_call( 138 this.fireflix.flickr.api_call(
139 { 139 {
140 method: 'flickr.photosets.getPhotos', 140 method: 'flickr.photosets.getPhotos',
141 auth_token: 'default', 141 auth_token: 'default',
142 photoset_id: psid, 142 photoset_id: psid,
143 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' 143 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update'
144 }, function(xr) { 144 }, function(xr) {
145 var x = xr.responseXML; 145 var x = xr.responseXML;
146 var xp = x.evaluate( 146 var xp = x.evaluate(
147 '/rsp/photoset/photo', x, null, 147 '/rsp/photoset/photo', x, null,
148 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 148 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
149 _this.importXPR(xp); 149 _this.importXPR(xp);
150 }, function(x,s,c,m) { 150 }, function(x,s,c,m) {
151 _this.fireflix.flickr_failure(x,s,c,m); 151 _this.fireflix.flickr_failure(x,s,c,m);
152 } 152 }
153 ); 153 );
154 }, 154 },
155 on_select: function() { 155 on_select: function() {
156 if(this.selection.count==1) { 156 if(this.selection.count==1) {
157 var p = this.photos[this.selection.currentIndex]; 157 var p = this.photos[this.selection.currentIndex];
158 this.set_photo.src = 158 this.set_photo.src =
159 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); 159 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t');
160 this.set_photo.hidden = false; 160 this.set_photo.hidden = false;
161 }else{ 161 }else{
162 this.set_photo.hidden = true; 162 this.set_photo.hidden = true;
163 } 163 }
164 },
165 on_cmd_open: function(ev) {
166 if(this.selection.currentIndex<0)
167 return;
168 var p = this.photos[this.selection.currentIndex];
169 if(!p.id)
170 return;
171 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p'));
164 } 172 }
165 }, 173 },
166 174
167 /* photosets treeview */ 175 /* photosets treeview */
168 photosets: { 176 photosets: {
169 sets: new Array(), 177 sets: new Array(),
170 fireflix: null, 178 fireflix: null,
171 init: function(f) { 179 init: function(f) {
172 this.fireflix = f; 180 this.fireflix = f;
173 document.getElementById('setslist').view = this; 181 document.getElementById('setslist').view = this;
174 }, 182 },
175 rowCount: 0, 183 rowCount: 0,
176 getCellText: function(r,c) { 184 getCellText: function(r,c) {
177 var s = this.sets[r]; 185 var s = this.sets[r];
178 if(c.id=='sl_name') return s.title; 186 if(c.id=='sl_name') return s.title;
179 if(c.id=='sl_photos') return s.photos; 187 if(c.id=='sl_photos') return s.photos;
180 return c.id; 188 return c.id;
181 }, 189 },
182 setTree: function(t) { this.tree = t }, 190 setTree: function(t) { this.tree = t },
183 isContainer: function(r) { return false; }, 191 isContainer: function(r) { return false; },
184 isSeparator: function(r) { return false; }, 192 isSeparator: function(r) { return false; },
185 isSorted: function() { return false; }, 193 isSorted: function() { return false; },
186 getLevel: function(r) { return 0; }, 194 getLevel: function(r) { return 0; },
187 getImageSrc: function(r,c) { return null }, 195 getImageSrc: function(r,c) { return null },
188 getRowProperties: function(r,p) {}, 196 getRowProperties: function(r,p) {},
189 getCellProperties: function(cid,cel,p) { }, 197 getCellProperties: function(cid,cel,p) { },
190 getColumnProperties: function(cid,cel,p) { }, 198 getColumnProperties: function(cid,cel,p) { },
191 cycleHeader: function(cid,e) { }, 199 cycleHeader: function(cid,e) { },
192 getParentIndex: function(r) { return -1; }, 200 getParentIndex: function(r) { return -1; },
193 drop: function(r,o) { }, 201 drop: function(r,o) { },
194 canDropBeforeAfter: function(r,b) { return false }, 202 canDropBeforeAfter: function(r,b) { return false },
195 203
196 importXPR: function(xp) { 204 importXPR: function(xp) {
197 this.tree.beginUpdateBatch(); 205 this.tree.beginUpdateBatch();
198 this.sets = new Array(); 206 this.sets = new Array();
199 var n; while(n=xp.iterateNext()) { 207 var n; while(n=xp.iterateNext()) {
200 this.sets.push(new Photoset(n)); 208 this.sets.push(new Photoset(n));
201 } 209 }
202 this.rowCount = this.sets.length; 210 this.rowCount = this.sets.length;
203 this.tree.endUpdateBatch(); 211 this.tree.endUpdateBatch();
204 }, 212 },
205 refresh_sets: function() { 213 refresh_sets: function() {
206 var _this = this; 214 var _this = this;
207 this.fireflix.flickr.api_call( 215 this.fireflix.flickr.api_call(
208 { 216 {
209 method: 'flickr.photosets.getList', 217 method: 'flickr.photosets.getList',
210 auth_token: 'default' 218 auth_token: 'default'
211 }, function(xr) { 219 }, function(xr) {
212 var x = xr.responseXML; 220 var x = xr.responseXML;
213 var xp = x.evaluate( 221 var xp = x.evaluate(
214 '/rsp/photosets/photoset', x, null, 222 '/rsp/photosets/photoset', x, null,
215 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 223 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
216 _this.importXPR(xp); 224 _this.importXPR(xp);
217 }, function(x,s,c,m) { 225 }, function(x,s,c,m) {
218 _this.fireflix.flickr_failure(x,s,c,m); 226 _this.fireflix.flickr_failure(x,s,c,m);
219 } 227 }
220 ); 228 );
221 }, 229 },
222 on_select: function() { 230 on_select: function() {
223 if(this.selection.count==1) { 231 if(this.selection.count==1) {
224 this.fireflix.cmd_set_props.setAttribute('disabled','false'); 232 this.fireflix.cmd_set_props.setAttribute('disabled','false');
225 var s = this.sets[this.selection.currentIndex]; 233 var s = this.sets[this.selection.currentIndex];
226 this.fireflix.photoset.load_photos(s.id); 234 this.fireflix.photoset.load_photos(s.id);
227 }else{ 235 }else{
228 this.fireflix.cmd_set_props.setAttribute('disabled','true'); 236 this.fireflix.cmd_set_props.setAttribute('disabled','true');
229 } 237 }
230 } 238 }
231 }, 239 },
232 240
233 refresh_user_tags: function() { 241 refresh_user_tags: function() {
234 var lb = document.getElementById('tagslist'); 242 var lb = document.getElementById('tagslist');
235 var _this = this; 243 var _this = this;
236 this.flickr.api_call( 244 this.flickr.api_call(
237 { 245 {
238 method: 'flickr.tags.getListUser', 246 method: 'flickr.tags.getListUser',
239 auth_token: 'default', 247 auth_token: 'default',
240 }, function(xr) { 248 }, function(xr) {
241 var x = xr.responseXML; 249 var x = xr.responseXML;
242 var xp = x.evaluate( 250 var xp = x.evaluate(
243 '/rsp/who/tags/tag', x, null, 251 '/rsp/who/tags/tag', x, null,
244 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 252 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
245 // TODO: clear list 253 // TODO: clear list
246 var n; while(n=xp.iterateNext()) { 254 var n; while(n=xp.iterateNext()) {
247 lb.appendItem(n.firstChild.nodeValue); 255 lb.appendItem(n.firstChild.nodeValue);
248 } 256 }
249 }, function(x,s,c,m) { 257 }, function(x,s,c,m) {
250 _this.flickr_failure(x,s,c,m); 258 _this.flickr_failure(x,s,c,m);
251 } 259 }
252 ); 260 );
253 }, 261 },
254 262
255 uploadObserver: { 263 uploadObserver: {
256 fireflix: null, 264 fireflix: null,
257 init: function(f) { 265 init: function(f) {
258 this.fireflix = f; 266 this.fireflix = f;
259 }, 267 },
260 getSupportedFlavours: function() { 268 getSupportedFlavours: function() {
261 var rv = new FlavourSet(); 269 var rv = new FlavourSet();
262 rv.appendFlavour('application/x-moz-file','nsIFile'); 270 rv.appendFlavour('application/x-moz-file','nsIFile');
263 rv.appendFlavour('application/x-moz-url'); 271 rv.appendFlavour('application/x-moz-url');
264 rv.appendFlavour('text/uri-list'); 272 rv.appendFlavour('text/uri-list');
265 rv.appendFlavour('text/unicode'); 273 rv.appendFlavour('text/unicode');
266 return rv; 274 return rv;
267 }, 275 },
268 canHandleMultipleItems: true, 276 canHandleMultipleItems: true,
269 onDragOver: function(ev,fl,sess) { 277 onDragOver: function(ev,fl,sess) {
270 return true; 278 return true;
271 }, 279 },
272 onDrop: function(ev,dd,s) { 280 onDrop: function(ev,dd,s) {
273 var ldf = null; 281 var ldf = null;
274 for(var i in dd.dataList) { 282 for(var i in dd.dataList) {
275 var di = dd.dataList[i]; 283 var di = dd.dataList[i];
276 var dif = di.first; 284 var dif = di.first;
277 if( 285 if(
278 ldf==null 286 ldf==null
279 || ldf.flavour.contentType!=dif.flavour.contentType 287 || ldf.flavour.contentType!=dif.flavour.contentType
280 || ldf.contentLength!=dif.contentLength 288 || ldf.contentLength!=dif.contentLength
281 || ldf.data!=dif.data ) 289 || ldf.data!=dif.data )
282 this.drop_item(ev,di,s); 290 this.drop_item(ev,di,s);
283 ldf = dif; 291 ldf = dif;
284 } 292 }
285 }, 293 },
286 drop_item: function(ev,di,s) { 294 drop_item: function(ev,di,s) {
287 var d = di.first; 295 var d = di.first;
288 switch(d.flavour.contentType) { 296 switch(d.flavour.contentType) {
289 case 'text/unicode': 297 case 'text/unicode':
290 this.drop_urilist(ev,d.data,s); 298 this.drop_urilist(ev,d.data,s);
291 break; 299 break;
292 case 'application/x-moz-file': 300 case 'application/x-moz-file':
293 this.fireflix.uploads.add(d.data.path); 301 this.fireflix.uploads.add(d.data.path);
294 document.getElementById('fireflix_tabs').selectedTab 302 document.getElementById('fireflix_tabs').selectedTab
295 = document.getElementById('tab_upload'); 303 = document.getElementById('tab_upload');
296 break; 304 break;
297 case 'text/uri-list': 305 case 'text/uri-list':
298 // is it ascii or could it be utf8? 306 // is it ascii or could it be utf8?
299 this.drop_urilist(ev,splitascii(d.data),s); 307 this.drop_urilist(ev,splitascii(d.data),s);
300 break; 308 break;
301 default: alert(d.flavour.contentType+':'+d.data); break; 309 default: alert(d.flavour.contentType+':'+d.data); break;
302 }; 310 };
303 }, 311 },
304 drop_urilist: function(ev,ul,s) { 312 drop_urilist: function(ev,ul,s) {
305 // TODO: check for being a file? 313 // TODO: check for being a file?
306 var us = decodeURIComponent(ul).split(/[\r\n]/); 314 var us = decodeURIComponent(ul).split(/[\r\n]/);
307 for(var ui in us) 315 for(var ui in us)
308 if(/\S/.test(us[ui])) 316 if(/\S/.test(us[ui]))
309 this.fireflix.uploads.add(us[ui]); 317 this.fireflix.uploads.add(us[ui]);
310 document.getElementById('fireflix_tabs').selectedTab 318 document.getElementById('fireflix_tabs').selectedTab
311 = document.getElementById('tab_upload'); 319 = document.getElementById('tab_upload');
312 } 320 }
313 }, 321 },
314 322
315 uploads: { 323 uploads: {
316 fireflix: null, 324 fireflix: null,
317 init: function(f) { 325 init: function(f) {
318 this.fireflix=f; 326 this.fireflix=f;
319 pull_elements(this,document,[ 327 pull_elements(this,document,[
320 'upload_filename','upload_title','upload_file_preview', 328 'upload_filename','upload_title','upload_file_preview',
321 'upload_file_props','upload_progress','upload_tags', 329 'upload_file_props','upload_progress','upload_tags',
322 'cmd_uploads_upload' 330 'cmd_uploads_upload'
323 ]); 331 ]);
324 document.getElementById('uploadlist').view = this; 332 document.getElementById('uploadlist').view = this;
325 }, 333 },
326 files: new Array(), 334 files: new Array(),
327 rowCount: 0, 335 rowCount: 0,
328 getCellText: function(r,c) { 336 getCellText: function(r,c) {
329 var f = this.files[r]; 337 var f = this.files[r];
330 if(c.id=='up_file') return f.file; 338 if(c.id=='up_file') return f.file;
331 if(c.id=='up_title') return f.title; 339 if(c.id=='up_title') return f.title;
332 if(c.id=='up_status') return f.state; 340 if(c.id=='up_status') return f.state;
333 return c.id; 341 return c.id;
334 }, 342 },
335 setTree: function(t) { this.tree = t }, 343 setTree: function(t) { this.tree = t },
336 isContainer: function(r) { return false; }, 344 isContainer: function(r) { return false; },
337 isSeparator: function(r) { return false; }, 345 isSeparator: function(r) { return false; },
338 isSorted: function(r) { return false; }, 346 isSorted: function(r) { return false; },
339 getLevel: function(r) { return 0; }, 347 getLevel: function(r) { return 0; },
340 getImageSrc: function(r,c) { return null }, 348 getImageSrc: function(r,c) { return null },
341 getRowProperties: function(r,p) { 349 getRowProperties: function(r,p) {
342 try { 350 try {
343 if(!Components) return; 351 if(!Components) return;
344 }catch(e) { return } 352 }catch(e) { return }
345 var f = this.files[r]; 353 var f = this.files[r];
346 var as = Components.classes['@mozilla.org/atom-service;1']. 354 var as = Components.classes['@mozilla.org/atom-service;1'].
347 getService(Components.interfaces.nsIAtomService); 355 getService(Components.interfaces.nsIAtomService);
348 p.AppendElement(as.getAtom(f.state)); 356 p.AppendElement(as.getAtom(f.state));
349 }, 357 },
350 getCellProperties: function(r,c,p) { this.getRowProperties(r,p); }, 358 getCellProperties: function(r,c,p) { this.getRowProperties(r,p); },
351 getColumnProperties: function(c,p) { }, 359 getColumnProperties: function(c,p) { },
352 cycleHeader: function(cid,e) { }, 360 cycleHeader: function(cid,e) { },
353 getParentIndex: function(r) { return -1; }, 361 getParentIndex: function(r) { return -1; },
354 drop: function(r,o) { }, 362 drop: function(r,o) { },
355 canDropBeforeAfter: function(r,b) { return false }, 363 canDropBeforeAfter: function(r,b) { return false },
356 364
357 add: function(f) { 365 add: function(f) {
358 if(f.indexOf('file:/')==0) { 366 if(f.indexOf('file:/')==0) {
359 f = f.substr(5); 367 f = f.substr(5);
360 while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-) 368 while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-)
361 f = f.substr(1); 369 f = f.substr(1);
362 } 370 }
363 } 371 }
364 var t = f; 372 var t = f;
365 var ls = t.lastIndexOf('/'); 373 var ls = t.lastIndexOf('/');
366 if(ls>0) t = t.substr(ls+1); 374 if(ls>0) t = t.substr(ls+1);
367 ls = t.lastIndexOf('\\'); 375 ls = t.lastIndexOf('\\');
368 if(ls>0) t = t.substr(ls+1); 376 if(ls>0) t = t.substr(ls+1);
369 var ld = t.lastIndexOf('.'); 377 var ld = t.lastIndexOf('.');
370 if(ld>0) t = t.substr(0,ld); 378 if(ld>0) t = t.substr(0,ld);
371 this.files.push( { 379 this.files.push( {
372 file: f, 380 file: f,
373 title: t, 381 title: t,
374 tags: '', 382 tags: '',
375 state: 'pending' 383 state: 'pending'
376 } ); 384 } );
377 this.rowCount = this.files.length; 385 this.rowCount = this.files.length;
378 this.tree.rowCountChanged(this.rowCount-1,1); 386 this.tree.rowCountChanged(this.rowCount-1,1);
379 }, 387 },
380 388
381 upload_worker: function() { 389 upload_worker: function() {
382 for(var f in this.files) { 390 for(var f in this.files) {
383 if(this.files[f].state=='pending') { 391 if(this.files[f].state=='pending') {
384 var ff = this.files[f]; 392 var ff = this.files[f];
385 this.on_file_upload(ff); 393 this.on_file_upload(ff);
386 ff.state='uploading'; 394 ff.state='uploading';
387 this.tree.invalidate(); 395 this.tree.invalidate();
388 var _this = this; 396 var _this = this;
389 this.fireflix.flickr.upload_file( 397 this.fireflix.flickr.upload_file(
390 ff.file, { title: ff.title, tags: ff.tags }, 398 ff.file, { title: ff.title, tags: ff.tags },
391 function(x,p) { 399 function(x,p) {
392 ff.photoid = p; 400 ff.photoid = p;
393 _this.batch_ids.push(p); 401 _this.batch_ids.push(p);
394 ff.state='completed'; 402 ff.state='completed';
395 _this.tree.invalidate(); 403 _this.tree.invalidate();
396 window.setTimeout(_this.upload_to,0,_this); 404 window.setTimeout(_this.upload_to,0,_this);
397 }, function(x,s,c,m) { 405 }, function(x,s,c,m) {
398 ff.state='failed'; 406 ff.state='failed';
399 ff.flickr_errcode = c; 407 ff.flickr_errcode = c;
400 ff.flickr_errmsg = m; 408 ff.flickr_errmsg = m;
401 _this.tree.invalidate(); 409 _this.tree.invalidate();
402 window.setTimeout(_this.upload_to,0,_this); 410 window.setTimeout(_this.upload_to,0,_this);
403 } 411 }
404 ); 412 );
405 return; 413 return;
406 } 414 }
407 } 415 }
408 this.on_finish_upload(); 416 this.on_finish_upload();
409 }, 417 },
410 upload_to: function(_this) { _this.upload_worker(); }, 418 upload_to: function(_this) { _this.upload_worker(); },
411 on_file_upload: function(f) { 419 on_file_upload: function(f) {
412 this.cmd_uploads_upload.setAttribute('disabled','true'); 420 this.cmd_uploads_upload.setAttribute('disabled','true');
413 for(var fi in this.files) { 421 for(var fi in this.files) {
414 if(this.files[fi].file==f.file) { 422 if(this.files[fi].file==f.file) {
415 this.tree.ensureRowIsVisible(fi); 423 this.tree.ensureRowIsVisible(fi);
416 this.selection.rangedSelect(fi,fi,false); 424 this.selection.rangedSelect(fi,fi,false);
417 this.selection.currentIndex = fi; 425 this.selection.currentIndex = fi;
418 this.selToProps(); 426 this.selToProps();
419 break; 427 break;
420 } 428 }
421 } 429 }
422 }, 430 },
423 on_finish_upload: function() { 431 on_finish_upload: function() {
424 if(this.batch_ids.length) { 432 if(this.batch_ids.length) {
425 var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); 433 var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset'));
426 if(psn!=null) { 434 if(psn!=null) {
427 var pids = this.batch_ids.join(','); 435 var pids = this.batch_ids.join(',');
428 var ppid = this.batch_ids[0]; 436 var ppid = this.batch_ids[0];
429 var _this = this; 437 var _this = this;
430 this.fireflix.flickr.api_call( 438 this.fireflix.flickr.api_call(
431 { 439 {
432 method: 'flickr.photosets.create', 440 method: 'flickr.photosets.create',
433 auth_token: 'default', 441 auth_token: 'default',
434 title: psn, 442 title: psn,
435 primary_photo_id: ppid 443 primary_photo_id: ppid
436 }, function(x) { 444 }, function(x) {
437 var npid = 445 var npid =
438 x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id'); 446 x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id');
439 _this.fireflix.flickr.api_call( 447 _this.fireflix.flickr.api_call(
440 { 448 {
441 method: 'flickr.photosets.editPhotos', 449 method: 'flickr.photosets.editPhotos',
442 auth_token: 'default', 450 auth_token: 'default',
443 photoset_id: npid, 451 photoset_id: npid,
444 primary_photo_id: ppid, 452 primary_photo_id: ppid,
445 photo_ids: pids 453 photo_ids: pids
446 }, function(x) { 454 }, function(x) {
447 _this.fireflix.refresh_sets(); 455 _this.fireflix.refresh_sets();
448 }, function(x,s,c,m) { 456 }, function(x,s,c,m) {
449 _this.fireflix.flickr_failure(x,s,c,m); 457 _this.fireflix.flickr_failure(x,s,c,m);
450 } 458 }
451 ); 459 );
452 }, function(x,s,c,m) { 460 }, function(x,s,c,m) {
453 _this.fireflix.flickr_failure(x,s,c,m); 461 _this.fireflix.flickr_failure(x,s,c,m);
454 } 462 }
455 ); 463 );
456 } 464 }
457 } 465 }
458 this.selection.clearSelection(); 466 this.selection.clearSelection();
459 this.cmd_uploads_upload.setAttribute('disabled','false'); 467 this.cmd_uploads_upload.setAttribute('disabled','false');
460 this.upload_progress.setAttribute('hidden','true'); 468 this.upload_progress.setAttribute('hidden','true');
461 }, 469 },
462 470
463 clear_list: function() { 471 clear_list: function() {
464 this.tree.beginUpdateBatch(); 472 this.tree.beginUpdateBatch();
465 this.rowCount = 0; 473 this.rowCount = 0;
466 this.files = new Array(); 474 this.files = new Array();
467 this.tree.endUpdateBatch(); 475 this.tree.endUpdateBatch();
468 this.selToProps(); 476 this.selToProps();
469 }, 477 },
470 selectionChanged: function() { 478 selectionChanged: function() {
471 this.selToProps(); 479 this.selToProps();
472 }, 480 },
473 disableProps: function() { 481 disableProps: function() {
474 this.upload_filename.value=''; 482 this.upload_filename.value='';
475 this.upload_filename.disabled = true; 483 this.upload_filename.disabled = true;
476 this.upload_title.value=''; 484 this.upload_title.value='';
477 this.upload_title.disabled = true; 485 this.upload_title.disabled = true;
478 this.upload_file_preview.src = null; 486 this.upload_file_preview.src = null;
479 this.upload_file_props.hidden = true; 487 this.upload_file_props.hidden = true;
480 this.upload_tags.value=''; 488 this.upload_tags.value='';
481 this.upload_tags.disabled = true; 489 this.upload_tags.disabled = true;
482 }, 490 },
483 selToProps: function() { 491 selToProps: function() {
484 if(!this.selection.count) { 492 if(!this.selection.count) {
485 this.disableProps(); 493 this.disableProps();
486 }else if(this.selection.count==1) { 494 }else if(this.selection.count==1) {
487 var f=this.files[this.selection.currentIndex]; 495 var f=this.files[this.selection.currentIndex];
488 if(f==null || f.state!='pending') { 496 if(f==null || f.state!='pending') {
489 this.disableProps(); 497 this.disableProps();
490 }else{ 498 }else{
491 this.upload_filename.value = f.file; 499 this.upload_filename.value = f.file;
492 this.upload_filename.disabled = false; 500 this.upload_filename.disabled = false;
493 this.upload_title.value = f.title; 501 this.upload_title.value = f.title;
494 this.upload_title.disabled = false; 502 this.upload_title.disabled = false;
495 this.upload_file_preview.src = 'file:///'+f.file; 503 this.upload_file_preview.src = 'file:///'+f.file;
496 this.upload_file_props.hidden = false; 504 this.upload_file_props.hidden = false;
497 this.upload_tags.value = f.tags; 505 this.upload_tags.value = f.tags;
498 this.upload_tags.disabled = false; 506 this.upload_tags.disabled = false;
499 } 507 }
500 }else{ 508 }else{
501 var ftitle = null; var onetitle = true; 509 var ftitle = null; var onetitle = true;
502 var ftags = null; var onetag = true; 510 var ftags = null; var onetag = true;
503 var fs = 0; 511 var fs = 0;
504 for(var ff in this.files) { 512 for(var ff in this.files) {
505 if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) { 513 if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) {
506 ++fs; 514 ++fs;
507 if(ftitle==null) { 515 if(ftitle==null) {
508 ftitle = this.files[ff].title; 516 ftitle = this.files[ff].title;
509 }else if(ftitle!=this.files[ff].title) { 517 }else if(ftitle!=this.files[ff].title) {
510 onetitle = false; 518 onetitle = false;
511 } 519 }
512 if(ftags==null) { 520 if(ftags==null) {
513 ftags = this.files[ff].tags; 521 ftags = this.files[ff].tags;
514 }else if(ftags!=this.files[ff].tags) { 522 }else if(ftags!=this.files[ff].tags) {
515 onetag = false; 523 onetag = false;
516 } 524 }
517 } 525 }
518 } 526 }
519 if(fs) { 527 if(fs) {
520 this.upload_filename.value=''; 528 this.upload_filename.value='';
521 this.upload_filename.disabled = true; 529 this.upload_filename.disabled = true;
522 if(onetitle) 530 if(onetitle)
523 this.upload_title.value = ftitle; 531 this.upload_title.value = ftitle;
524 this.upload_title.disabled = false; 532 this.upload_title.disabled = false;
525 if(onetag) 533 if(onetag)
526 this.upload_tags.value = ftags; 534 this.upload_tags.value = ftags;
527 this.upload_tags.disabled = false; 535 this.upload_tags.disabled = false;
528 this.upload_file_preview.src = null; 536 this.upload_file_preview.src = null;
529 this.upload_file_props.hidden = false; 537 this.upload_file_props.hidden = false;
530 }else 538 }else
531 this.disableProps(); 539 this.disableProps();
532 } 540 }
533 }, 541 },
534 propsToSel: function(prop) { 542 propsToSel: function(prop) {
535 if(this.selection.count<=0) return; 543 if(this.selection.count<=0) return;
536 for(var ff in this.files) { 544 for(var ff in this.files) {
537 if(this.selection.isSelected(ff) && this.files[ff].state=='pending') { 545 if(this.selection.isSelected(ff) && this.files[ff].state=='pending') {
538 if(prop=='filename') 546 if(prop=='filename')
539 this.files[ff].file = this.upload_filename.value; 547 this.files[ff].file = this.upload_filename.value;
540 if(prop=='title') 548 if(prop=='title')
541 this.files[ff].title = this.upload_title.value; 549 this.files[ff].title = this.upload_title.value;
542 if(prop=='tags') 550 if(prop=='tags')
543 this.files[ff].tags = this.upload_tags.value; 551 this.files[ff].tags = this.upload_tags.value;
544 this.tree.invalidateRow(ff); 552 this.tree.invalidateRow(ff);
545 } 553 }
546 } 554 }
547 }, 555 },
548 556
549 on_upload: function() { 557 on_upload: function() {
550 this.selToProps(); 558 this.selToProps();
551 this.batch_ids = new Array(); 559 this.batch_ids = new Array();
552 this.upload_progress.value=0; 560 this.upload_progress.value=0;
553 this.upload_progress.setAttribute('hidden','false'); 561 this.upload_progress.setAttribute('hidden','false');
554 this.upload_worker(); 562 this.upload_worker();
555 }, 563 },
556 on_clear: function() { 564 on_clear: function() {
557 this.clear_list(); 565 this.clear_list();
558 }, 566 },
559 on_remove: function() { 567 on_remove: function() {
560 if(this.selection.count) { 568 if(this.selection.count) {
561 this.tree.beginUpdateBatch(); 569 this.tree.beginUpdateBatch();
562 for(var i=this.files.length-1;i>=0;--i) { 570 for(var i=this.files.length-1;i>=0;--i) {
563 if(this.selection.isSelected(i)) { 571 if(this.selection.isSelected(i)) {
564 this.files.splice(i,1); 572 this.files.splice(i,1);
565 this.rowCount--; 573 this.rowCount--;
566 } 574 }
567 } 575 }
568 this.tree.endUpdateBatch(); 576 this.tree.endUpdateBatch();
569 this.selection.clearSelection(); 577 this.selection.clearSelection();
570 } 578 }
571 }, 579 },
572 on_add: function() { 580 on_add: function() {
573 var ifp = Components.interfaces.nsIFilePicker; 581 var ifp = Components.interfaces.nsIFilePicker;
574 var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp); 582 var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp);
575 fp.init(window, "Select a File", ifp.modeOpenMultiple); 583 fp.init(window, "Select a File", ifp.modeOpenMultiple);
576 fp.appendFilters(ifp.filterImages); 584 fp.appendFilters(ifp.filterImages);
577 var rv = fp.show(); 585 var rv = fp.show();
578 if(rv==ifp.returnOK) { 586 if(rv==ifp.returnOK) {
579 var ff = fp.files; 587 var ff = fp.files;
580 while(ff.hasMoreElements()) { 588 while(ff.hasMoreElements()) {
581 var f = ff.getNext(); 589 var f = ff.getNext();
582 f.QueryInterface(Components.interfaces.nsIFile); 590 f.QueryInterface(Components.interfaces.nsIFile);
583 this.add(f.path); 591 this.add(f.path);
584 } 592 }
585 } 593 }
586 } 594 }
587 }, 595 },
588 596
589 on_set_props: function() { 597 on_set_props: function() {
590 var pset = this.photosets.sets[this.photosets.selection.currentIndex]; 598 var pset = this.photosets.sets[this.photosets.selection.currentIndex];
591 window.openDialog( 599 window.openDialog(
592 "chrome://fireflix/content/photoset-props.xul", 600 "chrome://fireflix/content/photoset-props.xul",
593 null, "dependent,modal,dialog,chrome", this, 601 null, "dependent,modal,dialog,chrome", this,
594 pset ); 602 pset );
595 if(pset.dirty) { 603 if(pset.dirty) {
596 var _this = this; 604 var _this = this;
597 this.flickr.api_call( 605 this.flickr.api_call(
598 { 606 {
599 method: 'flickr.photosets.editMeta', 607 method: 'flickr.photosets.editMeta',
600 auth_token: 'default', 608 auth_token: 'default',
601 photoset_id: pset.id, 609 photoset_id: pset.id,
602 title: pset.title, 610 title: pset.title,
603 description: pset.description 611 description: pset.description
604 }, function(xr) { 612 }, function(xr) {
605 pset.dirty = false; 613 pset.dirty = false;
606 _this.flickr.api_call( 614 _this.flickr.api_call(
607 { 615 {
608 method: 'flickr.photosets.getPhotos', 616 method: 'flickr.photosets.getPhotos',
609 auth_token: 'default', 617 auth_token: 'default',
610 photoset_id: pset.id 618 photoset_id: pset.id
611 }, function(xr) { 619 }, function(xr) {
612 var x = xr.responseXML; 620 var x = xr.responseXML;
613 var xp = x.evaluate( 621 var xp = x.evaluate(
614 '/rsp/photoset/photo', x, null, 622 '/rsp/photoset/photo', x, null,
615 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 623 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
616 var phids = new Array(); 624 var phids = new Array();
617 var priph = null; 625 var priph = null;
618 var n; while(n=xp.iterateNext()) { 626 var n; while(n=xp.iterateNext()) {
619 var pid = n.getAttribute('id'); 627 var pid = n.getAttribute('id');
620 phids.push( pid ); 628 phids.push( pid );
621 if(pid==pset.primary && n.getAttribute('isprimary')!='1') 629 if(pid==pset.primary && n.getAttribute('isprimary')!='1')
622 priph = pid; 630 priph = pid;
623 } 631 }
624 if(priph) { 632 if(priph) {
625 _this.flickr.api_call( 633 _this.flickr.api_call(
626 { 634 {
627 method: 'flickr.photosets.editPhotos', 635 method: 'flickr.photosets.editPhotos',
628 auth_token: 'default', 636 auth_token: 'default',
629 photoset_id: pset.id, 637 photoset_id: pset.id,
630 primary_photo_id: priph, 638 primary_photo_id: priph,
631 photo_ids: phids.join(',') 639 photo_ids: phids.join(',')
632 }, function() { }, function(x,s,c,m) { /* flickr.photosets.editPhotos */ 640 }, function() { }, function(x,s,c,m) { /* flickr.photosets.editPhotos */
633 _this.flickr_failure(x,s,c,m); 641 _this.flickr_failure(x,s,c,m);
634 } 642 }
635 ); 643 );
636 } 644 }
637 }, function(x,s,c,m) { /* flickr.photosets.getPhotos */ 645 }, function(x,s,c,m) { /* flickr.photosets.getPhotos */
638 _this.flickr_failure(x,s,c,m); 646 _this.flickr_failure(x,s,c,m);
639 } 647 }
640 ); 648 );
641 }, function(x,s,c,m) { /* flickr.photosets.editMeta */ 649 }, function(x,s,c,m) { /* flickr.photosets.editMeta */
642 _this.flickr_failure(x,s,c,m); 650 _this.flickr_failure(x,s,c,m);
643 } 651 }
644 ); 652 );
645 } 653 }
646 }, 654 },
647 on_refresh_sets: function() { 655 on_refresh_sets: function() {
648 this.refresh_sets(); 656 this.refresh_sets();
649 }, 657 },
650 on_cmd_sets_html: function(csfx,ev) { 658 on_cmd_sets_html: function(csfx,ev) {
651 var uti = csfx.charAt(0); var utl = csfx.charAt(1); 659 var uti = csfx.charAt(0); var utl = csfx.charAt(1);
652 var rv = this.build_html(this.photoset.photos,uti,utl); 660 var rv = this.build_html(this.photoset.photos,uti,utl);
653 this.popup_content(rv); 661 this.popup_content(rv);
654 }, 662 },
655 663
656 on_cmd_uploads_html: function(csfx,ev) { 664 on_cmd_uploads_html: function(csfx,ev) {
657 var uti = csfx.charAt(0); var utl = csfx.charAt(1); 665 var uti = csfx.charAt(0); var utl = csfx.charAt(1);
658 var pids = new Array(); 666 var pids = new Array();
659 for(var f in this.uploads.files) { 667 for(var f in this.uploads.files) {
660 if(this.uploads.selection.isSelected(f)) 668 if(this.uploads.selection.isSelected(f))
661 if(this.uploads.files[f].photoid) 669 if(this.uploads.files[f].photoid)
662 pids.push(this.uploads.files[f].photoid); 670 pids.push(this.uploads.files[f].photoid);
663 } 671 }
664 var pp = this.uploads.rowCount*2; if(pp>500) pp = 500; 672 var pp = this.uploads.rowCount*2; if(pp>500) pp = 500;
665 var _this = this; 673 var _this = this;
666 this.flickr.api_call( 674 this.flickr.api_call(
667 { 675 {
668 method: 'flickr.photos.search', 676 method: 'flickr.photos.search',
669 auth_token: 'default', 677 auth_token: 'default',
670 extras: 'original_format', 678 extras: 'original_format',
671 user_id: 'me', 679 user_id: 'me',
672 per_page: pp 680 per_page: pp
673 }, 681 },
674 function(xr) { 682 function(xr) {
675 var x = xr.responseXML; 683 var x = xr.responseXML;
676 var rv = ''; 684 var rv = '';
677 for(var pn in pids) { 685 for(var pn in pids) {
678 var p = pids[pn]; 686 var p = pids[pn];
679 var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x)); 687 var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x));
680 rv += _this.photo_html(pp,uti,utl)+'\n'; 688 rv += _this.photo_html(pp,uti,utl)+'\n';
681 } 689 }
682 _this.popup_content(rv); 690 _this.popup_content(rv);
683 }, function(x,s,c,m) { 691 }, function(x,s,c,m) {
684 _this.flickr_failure(x,s,c,m); 692 _this.flickr_failure(x,s,c,m);
685 } 693 }
686 ); 694 );
687 }, 695 },
688 696
689 /* 697 /*
690 * 698 *
691 */ 699 */
692 foundphotos: { 700 foundphotos: {
693 fireflix: null, 701 fireflix: null,
694 init: function(f) { 702 init: function(f) {
695 this.fireflix = f; 703 this.fireflix = f;
696 pull_elements(this,document,[ 704 pull_elements(this,document,[
697 'search_for','search_tags','search_mine', 705 'search_for','search_tags','search_mine',
698 'searchresult_props','search_photo', 706 'searchresult_props','search_photo',
699 'searchresult_title','searchresult_description', 707 'searchresult_title','searchresult_description',
700 'search_page','cmd_search_prev_page','cmd_search_next_page' 708 'search_page','cmd_search_prev_page','cmd_search_next_page'
701 ]); 709 ]);
702 document.getElementById('searchresults').view = this; 710 document.getElementById('searchresults').view = this;
703 }, 711 },
704 photos: new Array(), 712 photos: new Array(),
705 rowCount: 0, 713 rowCount: 0,
706 getCellText: function(r,c) { 714 getCellText: function(r,c) {
707 var p = this.photos[r]; 715 var p = this.photos[r];
708 if(c.id=='sr_title') return p.title; 716 if(c.id=='sr_title') return p.title;
709 return c.id; 717 return c.id;
710 }, 718 },
711 setTree: function(t) { this.tree = t }, 719 setTree: function(t) { this.tree = t },
712 isContainer: function(r) { return false }, 720 isContainer: function(r) { return false },
713 isSeparator: function(r) { return false }, 721 isSeparator: function(r) { return false },
714 isSorted: function(r) { return false }, 722 isSorted: function(r) { return false },
715 getLevel: function(r) { return 0 }, 723 getLevel: function(r) { return 0 },
716 getImageSrc: function(r,c) { return null }, 724 getImageSrc: function(r,c) { return null },
717 getRowProperties: function(r,p) { }, 725 getRowProperties: function(r,p) { },
718 getCellProperties: function(cid,cel,p) { }, 726 getCellProperties: function(cid,cel,p) { },
719 getColumnProperties: function(cid,cel,p) { }, 727 getColumnProperties: function(cid,cel,p) { },
720 cycleHeader: function(cid,e) { }, 728 cycleHeader: function(cid,e) { },
721 getParentIndex: function(r) { return -1 }, 729 getParentIndex: function(r) { return -1 },
722 drop: function(r,o) { }, 730 drop: function(r,o) { },
723 canDropBeforeAfter: function(r,b) { return false }, 731 canDropBeforeAfter: function(r,b) { return false },
724 732
725 importXPR: function(xp) { 733 importXPR: function(xp) {
726 this.selection.clearSelection(); 734 this.selection.clearSelection();
727 this.selection.currentIndex = -1; 735 this.selection.currentIndex = -1;
728 this.searchresult_props.hidden = true; 736 this.searchresult_props.hidden = true;
729 this.tree.beginUpdateBatch(); 737 this.tree.beginUpdateBatch();
730 this.photos = new Array(); 738 this.photos = new Array();
731 var n; while(n=xp.iterateNext()) { 739 var n; while(n=xp.iterateNext()) {
732 this.photos.push(new Photo(n)); 740 this.photos.push(new Photo(n));
733 } 741 }
734 this.rowCount = this.photos.length; 742 this.rowCount = this.photos.length;
735 this.tree.endUpdateBatch(); 743 this.tree.endUpdateBatch();
736 }, 744 },
737 paging: { 745 paging: {
738 pars: null, 746 pars: null,
739 page: null, pages: null, perpage: null, total: null 747 page: null, pages: null, perpage: null, total: null
740 }, 748 },
741 search_photos: function() { 749 search_photos: function() {
742 var pars = { 750 var pars = {
743 method: 'flickr.photos.search', 751 method: 'flickr.photos.search',
744 auth_token: 'default', 752 auth_token: 'default',
745 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' 753 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo'
746 }; 754 };
747 if(this.search_mine.checked) 755 if(this.search_mine.checked)
748 pars.user_id='me'; 756 pars.user_id='me';
749 if(this.search_tags.checked) { 757 if(this.search_tags.checked) {
750 pars.tags=this.search_for.value.split(/ +/).join(','); 758 pars.tags=this.search_for.value.split(/ +/).join(',');
751 }else{ 759 }else{
752 pars.text=this.search_for.value; 760 pars.text=this.search_for.value;
753 } 761 }
754 this.paging.pars = new Object(); 762 this.paging.pars = new Object();
755 this.paging.page = null; this.paging.pages = null; 763 this.paging.page = null; this.paging.pages = null;
756 this.paging.perpage = null; this.paging.total = null; 764 this.paging.perpage = null; this.paging.total = null;
757 for(var p in pars) this.paging.pars[p] = pars[p]; 765 for(var p in pars) this.paging.pars[p] = pars[p];
758 this.perform_search(pars); 766 this.perform_search(pars);
759 }, 767 },
760 perform_search: function(p) { 768 perform_search: function(p) {
761 var _this = this; 769 var _this = this;
762 this.fireflix.flickr.api_call( p, 770 this.fireflix.flickr.api_call( p,
763 function(xr) { 771 function(xr) {
764 var x = xr.responseXML; 772 var x = xr.responseXML;
765 var xp = xp_nodes('/rsp/photos/photo',x); 773 var xp = xp_nodes('/rsp/photos/photo',x);
766 _this.importXPR(xp); 774 _this.importXPR(xp);
767 _this.tree.ensureRowIsVisible(0); 775 _this.tree.ensureRowIsVisible(0);
768 xp = xp_node('/rsp/photos',x); 776 xp = xp_node('/rsp/photos',x);
769 _this.paging.page = parseInt(xp.getAttribute('page')); 777 _this.paging.page = parseInt(xp.getAttribute('page'));
770 _this.paging.pages = parseInt(xp.getAttribute('pages')); 778 _this.paging.pages = parseInt(xp.getAttribute('pages'));
771 _this.paging.perpage = parseInt(xp.getAttribute('perpage')); 779 _this.paging.perpage = parseInt(xp.getAttribute('perpage'));
772 _this.paging.total = parseInt(xp.getAttribute('total')); 780 _this.paging.total = parseInt(xp.getAttribute('total'));
773 _this.update_paging(); 781 _this.update_paging();
774 _this.on_select(); 782 _this.on_select();
775 }, function(x,s,c,m) { 783 }, function(x,s,c,m) {
776 _this.fireflix.flickr_failure(x,s,c,m); 784 _this.fireflix.flickr_failure(x,s,c,m);
777 } 785 }
778 ); 786 );
779 }, 787 },
780 on_cmd_prev: function(ev) { 788 on_cmd_prev: function(ev) {
781 var pars = new Object(); 789 var pars = new Object();
782 for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; 790 for(var p in this.paging.pars) pars[p] = this.paging.pars[p];
783 pars.page=this.paging.page-1; pars.per_page=this.paging.perpage; 791 pars.page=this.paging.page-1; pars.per_page=this.paging.perpage;
784 this.perform_search(pars); 792 this.perform_search(pars);
785 }, 793 },
786 on_cmd_next: function(ev) { 794 on_cmd_next: function(ev) {
787 var pars = new Object(); 795 var pars = new Object();
788 for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; 796 for(var p in this.paging.pars) pars[p] = this.paging.pars[p];
789 pars.page=this.paging.page+1; pars.per_page=this.paging.perpage; 797 pars.page=this.paging.page+1; pars.per_page=this.paging.perpage;
790 this.perform_search(pars); 798 this.perform_search(pars);
791 }, 799 },
792 update_paging: function() { 800 update_paging: function() {
793 if(! (this.paging.pars && this.paging.page && this.paging.pages) ) { 801 if(! (this.paging.pars && this.paging.page && this.paging.pages) ) {
794 this.search_page.value=''; this.search_page.hidden = true; 802 this.search_page.value=''; this.search_page.hidden = true;
795 this.cmd_search_prev_page.setAttribute('disabled','true'); 803 this.cmd_search_prev_page.setAttribute('disabled','true');
796 this.cmd_search_next_page.setAttribute('disabled','true'); 804 this.cmd_search_next_page.setAttribute('disabled','true');
797 }else{ 805 }else{
798 this.search_page.value=this.fireflix.loc_strings.getFormattedString('search_page',[this.paging.page,this.paging.pages]); 806 this.search_page.value=this.fireflix.loc_strings.getFormattedString('search_page',[this.paging.page,this.paging.pages]);
799 this.search_page.hidden=false; 807 this.search_page.hidden=false;
800 this.cmd_search_prev_page.setAttribute('disabled',(this.paging.page>1)?'false':'true'); 808 this.cmd_search_prev_page.setAttribute('disabled',(this.paging.page>1)?'false':'true');
801 this.cmd_search_next_page.setAttribute('disabled',(this.paging.page<this.paging.pages)?'false':'true'); 809 this.cmd_search_next_page.setAttribute('disabled',(this.paging.page<this.paging.pages)?'false':'true');
802 } 810 }
803 }, 811 },
804 render_description_frame: function(content) { 812 render_description_frame: function(content) {
805 this.searchresult_description.innerHTML = ''; 813 this.searchresult_description.innerHTML = '';
806 if(content) { 814 if(content) {
807 var dp = new DOMParser(); 815 var dp = new DOMParser();
808 var pd = dp.parseFromString( 816 var pd = dp.parseFromString(
809 '<div xmlns="http://www.w3.org/1999/xhtml">'+content+'</div>', 'text/xml' ); 817 '<div xmlns="http://www.w3.org/1999/xhtml">'+content+'</div>', 'text/xml' );
810 var de = pd.documentElement; 818 var de = pd.documentElement;
811 if(de.tagName=='parsererror') 819 if(de.tagName=='parsererror')
812 this.searchresult_description.innerHTML=this.fireflix.loc_strings.getString('broken_description'); 820 this.searchresult_description.innerHTML=this.fireflix.loc_strings.getString('broken_description');
813 else 821 else
814 this.searchresult_description.appendChild(de); 822 this.searchresult_description.appendChild(de);
815 /* of all linking elements flickr only allows a */ 823 /* of all linking elements flickr only allows a */
816 var as = this.searchresult_description.getElementsByTagName('a'); 824 var as = this.searchresult_description.getElementsByTagName('a');
817 for(var a=0;a<as.length;++a) 825 for(var a=0;a<as.length;++a)
818 as.item(a).setAttribute('target','_blank'); 826 as.item(a).setAttribute('target','_blank');
819 } 827 }
820 }, 828 },
821 on_select: function() { 829 on_select: function() {
822 if(this.selection.currentIndex<0) { 830 if(this.selection.currentIndex<0) {
823 this.searchresult_props.hidden = true; 831 this.searchresult_props.hidden = true;
824 }else{ 832 }else{
825 var p = this.photos[this.selection.currentIndex]; 833 var p = this.photos[this.selection.currentIndex];
826 if(!p) { 834 if(!p) {
827 this.searchresult_props.hidden = true; 835 this.searchresult_props.hidden = true;
828 }else{ 836 }else{
829 this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); 837 this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t');
830 this.searchresult_title.value = p.title; 838 this.searchresult_title.value = p.title;
831 this.searchresult_title.tooltipText = p.title; 839 this.searchresult_title.tooltipText = p.title;
832 this.render_description_frame(null); 840 this.render_description_frame(null);
833 if(p.description==null && p.description==undefined) { 841 if(p.description==null && p.description==undefined) {
834 var pid = p.id; 842 var pid = p.id;
835 var ci = this.selection.currentIndex; 843 var ci = this.selection.currentIndex;
836 var _this = this; 844 var _this = this;
837 this.fireflix.flickr.api_call( 845 this.fireflix.flickr.api_call(
838 { 846 {
839 method: 'flickr.photos.getInfo', 847 method: 'flickr.photos.getInfo',
840 auth_token: 'default', 848 auth_token: 'default',
841 photo_id: p.id, 849 photo_id: p.id,
842 secret: p.secret 850 secret: p.secret
843 }, function(xr) { 851 }, function(xr) {
844 var pp = _this.photos[ci]; 852 var pp = _this.photos[ci];
845 if(ci==_this.selection.currentIndex && pp.id==pid) { 853 if(ci==_this.selection.currentIndex && pp.id==pid) {
846 var n = xp_node('/rsp/photo',xr.responseXML); 854 var n = xp_node('/rsp/photo',xr.responseXML);
847 pp.fromNode_(n); 855 pp.fromNode_(n);
848 _this.render_description_frame(pp.description); 856 _this.render_description_frame(pp.description);
849 } 857 }
850 }, function(x,s,c,m) { 858 }, function(x,s,c,m) {
851 _this.fireflix.flickr_failure(x,s,c,m); 859 _this.fireflix.flickr_failure(x,s,c,m);
852 } 860 }
853 ); 861 );
854 this.searchresult_props.hidden = false; 862 this.searchresult_props.hidden = false;
855 }else{ 863 }else{
856 this.render_description_frame(p.description); 864 this.render_description_frame(p.description);
857 } 865 }
858 } 866 }
859 } 867 }
860 }, 868 },
861 on_cmd_open: function(ev) { 869 on_cmd_open: function(ev) {
862 if(this.selection.currentIndex<0) 870 if(this.selection.currentIndex<0)
863 return; 871 return;
864 var p = this.photos[this.selection.currentIndex]; 872 var p = this.photos[this.selection.currentIndex];
865 if(!p.id) 873 if(!p.id)
866 return; 874 return;
867 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); 875 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p'));
868 } 876 }
869 }, 877 },
870 878
871 photo_html: function(p,i,l) { 879 photo_html: function(p,i,l) {
872 // TODO: add alt/title when possible 880 // TODO: add alt/title when possible
873 var rv = 881 var rv =
874 '<a href="'+this.flickr.make_photo_url(p,l)+'">' + 882 '<a href="'+this.flickr.make_photo_url(p,l)+'">' +
875 '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+ 883 '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+
876 '</a>'; 884 '</a>';
877 return rv; 885 return rv;
878 }, 886 },
879 build_html: function(photos,uti,utl) { 887 build_html: function(photos,uti,utl) {
880 var rv = ''; 888 var rv = '';
881 for(var i in photos) { 889 for(var i in photos) {
882 var p = photos[i]; 890 var p = photos[i];
883 rv += this.photo_html(p,uti,utl)+'\n'; 891 rv += this.photo_html(p,uti,utl)+'\n';
884 } 892 }
885 return rv; 893 return rv;
886 }, 894 },
887 895
888 popup_content: function(s) { 896 popup_content: function(s) {
889 window.openDialog( 897 window.openDialog(
890 "chrome://fireflix/content/generated-content.xul", 898 "chrome://fireflix/content/generated-content.xul",
891 null, "dialog,chrome", this, s ); 899 null, "dialog,chrome", this, s );
892 }, 900 },
893 copy_to_clipboard: function(s) { 901 copy_to_clipboard: function(s) {
894 var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"] 902 var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
895 .getService(Components.interfaces.nsIClipboardHelper); 903 .getService(Components.interfaces.nsIClipboardHelper);
896 ch.copyString(s); 904 ch.copyString(s);
897 }, 905 },
898 openTab: function(l) { 906 openTab: function(l) {
899 var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService( 907 var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(
900 Components.interfaces.nsIWindowMediator ); 908 Components.interfaces.nsIWindowMediator );
901 var bw = wm.getMostRecentWindow('navigator:browser'); 909 var bw = wm.getMostRecentWindow('navigator:browser');
902 var b = bw.getBrowser(); 910 var b = bw.getBrowser();
903 var t = b.addTab(l); 911 var t = b.addTab(l);
904 b.selectedTab = t; 912 b.selectedTab = t;
905 }, 913 },
906 914
907 build_menus: function() { 915 build_menus: function() {
908 this.append_html_menu( 916 this.append_html_menu(
909 document.getElementById('sets_html_menu'), 917 document.getElementById('sets_html_menu'),
910 'stm_','m_bop','cmdset_sets','cmd_sets_html' 918 'stm_','m_bop','cmdset_sets','cmd_sets_html'
911 ); 919 );
912 this.append_html_menu( 920 this.append_html_menu(
913 document.getElementById('uploads_html_menu'), 921 document.getElementById('uploads_html_menu'),
914 'stm_','m_bop','cmdset_uploads','cmd_uploads_html' 922 'stm_','m_bop','cmdset_uploads','cmd_uploads_html'
915 ); 923 );
916 return; 924 return;
917 }, 925 },
918 append_html_menu: function(m,imgt,lnkt,csid,cpfx) { 926 append_html_menu: function(m,imgt,lnkt,csid,cpfx) {
919 var mp = m.appendChild(document.createElement('menupopup')); 927 var mp = m.appendChild(document.createElement('menupopup'));
920 var t; 928 var t;
921 t=mp.appendChild(document.createElement('menuitem')); 929 t=mp.appendChild(document.createElement('menuitem'));
922 t.setAttribute('label',this.loc_strings.getString('menutitle_Images')); 930 t.setAttribute('label',this.loc_strings.getString('menutitle_Images'));
923 t.setAttribute('class','menuhead');t.setAttribute('disabled','true'); 931 t.setAttribute('class','menuhead');t.setAttribute('disabled','true');
924 mp.appendChild(document.createElement('menuseparator')); 932 mp.appendChild(document.createElement('menuseparator'));
925 var cs = document.getElementById(csid); 933 var cs = document.getElementById(csid);
926 for(var iti=0;iti<imgt.length;++iti) { 934 for(var iti=0;iti<imgt.length;++iti) {
927 t = mp.appendChild(document.createElement('menu')); 935 t = mp.appendChild(document.createElement('menu'));
928 t.setAttribute('label',this.loc_strings.getString('urltype_'+imgt.charAt(iti))); 936 t.setAttribute('label',this.loc_strings.getString('urltype_'+imgt.charAt(iti)));
929 var smp = t.appendChild(document.createElement('menupopup')); 937 var smp = t.appendChild(document.createElement('menupopup'));
930 t=smp.appendChild(document.createElement('menuitem')); 938 t=smp.appendChild(document.createElement('menuitem'));
931 t.setAttribute('label',this.loc_strings.getString('menutitle_Links')); 939 t.setAttribute('label',this.loc_strings.getString('menutitle_Links'));
932 t.setAttribute('class','menuhead');t.setAttribute('disabled','true'); 940 t.setAttribute('class','menuhead');t.setAttribute('disabled','true');
933 smp.appendChild(document.createElement('menuseparator')); 941 smp.appendChild(document.createElement('menuseparator'));
934 for(var lti=0;lti<lnkt.length;++lti) { 942 for(var lti=0;lti<lnkt.length;++lti) {
935 var csfx = imgt.charAt(iti)+lnkt.charAt(lti); 943 var csfx = imgt.charAt(iti)+lnkt.charAt(lti);
936 t=smp.appendChild(document.createElement('menuitem')); 944 t=smp.appendChild(document.createElement('menuitem'));
937 t.setAttribute('label',this.loc_strings.getString('urltype_'+lnkt.charAt(lti))); 945 t.setAttribute('label',this.loc_strings.getString('urltype_'+lnkt.charAt(lti)));
938 t.setAttribute('command',cpfx+'_'+csfx); 946 t.setAttribute('command',cpfx+'_'+csfx);
939 t=cs.appendChild(document.createElement('command')); 947 t=cs.appendChild(document.createElement('command'));
940 t.setAttribute('id',cpfx+'_'+csfx); 948 t.setAttribute('id',cpfx+'_'+csfx);
941 t.setAttribute('oncommand','fireflix.on_'+cpfx+"('"+csfx+"',event)"); 949 t.setAttribute('oncommand','fireflix.on_'+cpfx+"('"+csfx+"',event)");
942 } 950 }
943 } 951 }
944 return mp; 952 return mp;
945 }, 953 },
946 954
947 flickr_failure: function(x,s,c,m) { 955 flickr_failure: function(x,s,c,m) {
948 if(c==98) { // Invalid auth token 956 if(c==98) { // Invalid auth token
949 this.flickr.reset_token(); 957 this.flickr.reset_token();
950 this.set_auth_state(false,false); 958 this.set_auth_state(false,false);
951 return; 959 return;
952 } 960 }
953 // TODO: is that beauty? 961 // TODO: is that beauty?
954 alert('flickr api call failed\n'+c+' '+m); 962 alert('flickr api call failed\n'+c+' '+m);
955 } 963 }
956 964
957}; 965};