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