summaryrefslogtreecommitdiffabout
path: root/content/fireflix.js
authorMichael Krelin <hacker@klever.net>2006-11-16 22:22:23 (UTC)
committer Michael Krelin <hacker@klever.net>2006-11-16 22:22:23 (UTC)
commitd98dfeb112f9db06c5e642e14ee9bbda4d90d0cb (patch) (unidiff)
treedee166a9e25442a9043492f38104397fb748633b /content/fireflix.js
parent4b21b4fc5248322c10ffb24edfd5ec78ebcce824 (diff)
downloadfireflix-d98dfeb112f9db06c5e642e14ee9bbda4d90d0cb.zip
fireflix-d98dfeb112f9db06c5e642e14ee9bbda4d90d0cb.tar.gz
fireflix-d98dfeb112f9db06c5e642e14ee9bbda4d90d0cb.tar.bz2
double click on photoset opens photoset in flickr now
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@229 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (limited to 'content/fireflix.js') (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index 24894df..48053c5 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -71,264 +71,268 @@ var fireflix = {
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 this.selection.clearSelection(); 135 this.selection.clearSelection();
136 }, 136 },
137 load_photos: function(psid) { 137 load_photos: function(psid) {
138 var _this = this; 138 var _this = this;
139 this.fireflix.flickr.api_call( 139 this.fireflix.flickr.api_call(
140 { 140 {
141 method: 'flickr.photosets.getPhotos', 141 method: 'flickr.photosets.getPhotos',
142 auth_token: 'default', 142 auth_token: 'default',
143 photoset_id: psid, 143 photoset_id: psid,
144 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' 144 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update'
145 }, function(xr) { 145 }, function(xr) {
146 var x = xr.responseXML; 146 var x = xr.responseXML;
147 var xp = x.evaluate( 147 var xp = x.evaluate(
148 '/rsp/photoset/photo', x, null, 148 '/rsp/photoset/photo', x, null,
149 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 149 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
150 _this.importXPR(xp); 150 _this.importXPR(xp);
151 }, function(x,s,c,m) { 151 }, function(x,s,c,m) {
152 _this.fireflix.flickr_failure(x,s,c,m); 152 _this.fireflix.flickr_failure(x,s,c,m);
153 } 153 }
154 ); 154 );
155 }, 155 },
156 on_select: function() { 156 on_select: function() {
157 if(this.selection.count==1) { 157 if(this.selection.count==1) {
158 var p = this.photos[this.selection.currentIndex]; 158 var p = this.photos[this.selection.currentIndex];
159 this.set_photo.src = 159 this.set_photo.src =
160 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); 160 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t');
161 this.set_photo.hidden = false; 161 this.set_photo.hidden = false;
162 }else{ 162 }else{
163 this.set_photo.hidden = true; 163 this.set_photo.hidden = true;
164 } 164 }
165 }, 165 },
166 on_cmd_open: function(ev) { 166 on_cmd_open: function(ev) {
167 if(this.selection.currentIndex<0) 167 if(this.selection.currentIndex<0) return;
168 return;
169 var p = this.photos[this.selection.currentIndex]; 168 var p = this.photos[this.selection.currentIndex];
170 if(!p.id) 169 if(!p.id) return;
171 return;
172 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); 170 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p'));
173 } 171 }
174 }, 172 },
175 173
176 /* photosets treeview */ 174 /* photosets treeview */
177 photosets: { 175 photosets: {
178 sets: new Array(), 176 sets: new Array(),
179 fireflix: null, 177 fireflix: null,
180 init: function(f) { 178 init: function(f) {
181 this.fireflix = f; 179 this.fireflix = f;
182 document.getElementById('setslist').view = this; 180 document.getElementById('setslist').view = this;
183 }, 181 },
184 rowCount: 0, 182 rowCount: 0,
185 getCellText: function(r,c) { 183 getCellText: function(r,c) {
186 var s = this.sets[r]; 184 var s = this.sets[r];
187 if(c.id=='sl_name') return s.title; 185 if(c.id=='sl_name') return s.title;
188 if(c.id=='sl_photos') return s.photos; 186 if(c.id=='sl_photos') return s.photos;
189 return c.id; 187 return c.id;
190 }, 188 },
191 setTree: function(t) { this.tree = t }, 189 setTree: function(t) { this.tree = t },
192 isContainer: function(r) { return false; }, 190 isContainer: function(r) { return false; },
193 isSeparator: function(r) { return false; }, 191 isSeparator: function(r) { return false; },
194 isSorted: function() { return false; }, 192 isSorted: function() { return false; },
195 getLevel: function(r) { return 0; }, 193 getLevel: function(r) { return 0; },
196 getImageSrc: function(r,c) { return null }, 194 getImageSrc: function(r,c) { return null },
197 getRowProperties: function(r,p) {}, 195 getRowProperties: function(r,p) {},
198 getCellProperties: function(cid,cel,p) { }, 196 getCellProperties: function(cid,cel,p) { },
199 getColumnProperties: function(cid,cel,p) { }, 197 getColumnProperties: function(cid,cel,p) { },
200 cycleHeader: function(cid,e) { }, 198 cycleHeader: function(cid,e) { },
201 getParentIndex: function(r) { return -1; }, 199 getParentIndex: function(r) { return -1; },
202 drop: function(r,o) { }, 200 drop: function(r,o) { },
203 canDropBeforeAfter: function(r,b) { return false }, 201 canDropBeforeAfter: function(r,b) { return false },
204 202
205 importXPR: function(xp) { 203 importXPR: function(xp) {
206 this.tree.beginUpdateBatch(); 204 this.tree.beginUpdateBatch();
207 this.sets = new Array(); 205 this.sets = new Array();
208 var n; while(n=xp.iterateNext()) { 206 var n; while(n=xp.iterateNext()) {
209 this.sets.push(new Photoset(n)); 207 this.sets.push(new Photoset(n));
210 } 208 }
211 this.rowCount = this.sets.length; 209 this.rowCount = this.sets.length;
212 this.tree.endUpdateBatch(); 210 this.tree.endUpdateBatch();
213 }, 211 },
214 refresh_sets: function() { 212 refresh_sets: function() {
215 var _this = this; 213 var _this = this;
216 this.fireflix.flickr.api_call( 214 this.fireflix.flickr.api_call(
217 { 215 {
218 method: 'flickr.photosets.getList', 216 method: 'flickr.photosets.getList',
219 auth_token: 'default' 217 auth_token: 'default'
220 }, function(xr) { 218 }, function(xr) {
221 var x = xr.responseXML; 219 var x = xr.responseXML;
222 var xp = x.evaluate( 220 var xp = x.evaluate(
223 '/rsp/photosets/photoset', x, null, 221 '/rsp/photosets/photoset', x, null,
224 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 222 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
225 _this.importXPR(xp); 223 _this.importXPR(xp);
226 }, function(x,s,c,m) { 224 }, function(x,s,c,m) {
227 _this.fireflix.flickr_failure(x,s,c,m); 225 _this.fireflix.flickr_failure(x,s,c,m);
228 } 226 }
229 ); 227 );
230 }, 228 },
231 on_select: function() { 229 on_select: function() {
232 if(this.selection.count==1) { 230 if(this.selection.count==1) {
233 this.fireflix.cmd_set_props.setAttribute('disabled','false'); 231 this.fireflix.cmd_set_props.setAttribute('disabled','false');
234 var s = this.sets[this.selection.currentIndex]; 232 var s = this.sets[this.selection.currentIndex];
235 this.fireflix.photoset.load_photos(s.id); 233 this.fireflix.photoset.load_photos(s.id);
236 }else{ 234 }else{
237 this.fireflix.cmd_set_props.setAttribute('disabled','true'); 235 this.fireflix.cmd_set_props.setAttribute('disabled','true');
238 } 236 }
237 },
238 on_cmd_open_in_flickr: function(ev) {
239 if(this.selection.currentIndex<0) return;
240 var p = this.sets[this.selection.currentIndex];
241 if(!p.id) return;
242 this.fireflix.openTab(this.fireflix.flickr.make_photoset_url(p));
239 } 243 }
240 }, 244 },
241 245
242 refresh_user_tags: function() { 246 refresh_user_tags: function() {
243 var lb = document.getElementById('tagslist'); 247 var lb = document.getElementById('tagslist');
244 var _this = this; 248 var _this = this;
245 this.flickr.api_call( 249 this.flickr.api_call(
246 { 250 {
247 method: 'flickr.tags.getListUser', 251 method: 'flickr.tags.getListUser',
248 auth_token: 'default', 252 auth_token: 'default',
249 }, function(xr) { 253 }, function(xr) {
250 var x = xr.responseXML; 254 var x = xr.responseXML;
251 var xp = x.evaluate( 255 var xp = x.evaluate(
252 '/rsp/who/tags/tag', x, null, 256 '/rsp/who/tags/tag', x, null,
253 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 257 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
254 // TODO: clear list 258 // TODO: clear list
255 var n; while(n=xp.iterateNext()) { 259 var n; while(n=xp.iterateNext()) {
256 lb.appendItem(n.firstChild.nodeValue); 260 lb.appendItem(n.firstChild.nodeValue);
257 } 261 }
258 }, function(x,s,c,m) { 262 }, function(x,s,c,m) {
259 _this.flickr_failure(x,s,c,m); 263 _this.flickr_failure(x,s,c,m);
260 } 264 }
261 ); 265 );
262 }, 266 },
263 267
264 uploadObserver: { 268 uploadObserver: {
265 fireflix: null, 269 fireflix: null,
266 init: function(f) { 270 init: function(f) {
267 this.fireflix = f; 271 this.fireflix = f;
268 }, 272 },
269 getSupportedFlavours: function() { 273 getSupportedFlavours: function() {
270 var rv = new FlavourSet(); 274 var rv = new FlavourSet();
271 rv.appendFlavour('application/x-moz-file','nsIFile'); 275 rv.appendFlavour('application/x-moz-file','nsIFile');
272 rv.appendFlavour('application/x-moz-url'); 276 rv.appendFlavour('application/x-moz-url');
273 rv.appendFlavour('text/uri-list'); 277 rv.appendFlavour('text/uri-list');
274 rv.appendFlavour('text/unicode'); 278 rv.appendFlavour('text/unicode');
275 return rv; 279 return rv;
276 }, 280 },
277 canHandleMultipleItems: true, 281 canHandleMultipleItems: true,
278 onDragOver: function(ev,fl,sess) { 282 onDragOver: function(ev,fl,sess) {
279 return true; 283 return true;
280 }, 284 },
281 onDrop: function(ev,dd,s) { 285 onDrop: function(ev,dd,s) {
282 var ldf = null; 286 var ldf = null;
283 for(var i in dd.dataList) { 287 for(var i in dd.dataList) {
284 var di = dd.dataList[i]; 288 var di = dd.dataList[i];
285 var dif = di.first; 289 var dif = di.first;
286 if( 290 if(
287 ldf==null 291 ldf==null
288 || ldf.flavour.contentType!=dif.flavour.contentType 292 || ldf.flavour.contentType!=dif.flavour.contentType
289 || ldf.contentLength!=dif.contentLength 293 || ldf.contentLength!=dif.contentLength
290 || ldf.data!=dif.data ) 294 || ldf.data!=dif.data )
291 this.drop_item(ev,di,s); 295 this.drop_item(ev,di,s);
292 ldf = dif; 296 ldf = dif;
293 } 297 }
294 }, 298 },
295 drop_item: function(ev,di,s) { 299 drop_item: function(ev,di,s) {
296 var d = di.first; 300 var d = di.first;
297 switch(d.flavour.contentType) { 301 switch(d.flavour.contentType) {
298 case 'text/unicode': 302 case 'text/unicode':
299 this.drop_urilist(ev,d.data,s); 303 this.drop_urilist(ev,d.data,s);
300 break; 304 break;
301 case 'application/x-moz-file': 305 case 'application/x-moz-file':
302 this.fireflix.uploads.add(d.data.path); 306 this.fireflix.uploads.add(d.data.path);
303 document.getElementById('fireflix_tabs').selectedTab 307 document.getElementById('fireflix_tabs').selectedTab
304 = document.getElementById('tab_upload'); 308 = document.getElementById('tab_upload');
305 break; 309 break;
306 case 'text/uri-list': 310 case 'text/uri-list':
307 // is it ascii or could it be utf8? 311 // is it ascii or could it be utf8?
308 this.drop_urilist(ev,splitascii(d.data),s); 312 this.drop_urilist(ev,splitascii(d.data),s);
309 break; 313 break;
310 default: alert(d.flavour.contentType+':'+d.data); break; 314 default: alert(d.flavour.contentType+':'+d.data); break;
311 }; 315 };
312 }, 316 },
313 drop_urilist: function(ev,ul,s) { 317 drop_urilist: function(ev,ul,s) {
314 // TODO: check for being a file? 318 // TODO: check for being a file?
315 var us = decodeURIComponent(ul).split(/[\r\n]/); 319 var us = decodeURIComponent(ul).split(/[\r\n]/);
316 for(var ui in us) 320 for(var ui in us)
317 if(/\S/.test(us[ui])) 321 if(/\S/.test(us[ui]))
318 this.fireflix.uploads.add(us[ui]); 322 this.fireflix.uploads.add(us[ui]);
319 document.getElementById('fireflix_tabs').selectedTab 323 document.getElementById('fireflix_tabs').selectedTab
320 = document.getElementById('tab_upload'); 324 = document.getElementById('tab_upload');
321 } 325 }
322 }, 326 },
323 327
324 uploads: { 328 uploads: {
325 fireflix: null, 329 fireflix: null,
326 init: function(f) { 330 init: function(f) {
327 this.fireflix=f; 331 this.fireflix=f;
328 pull_elements(this,document,[ 332 pull_elements(this,document,[
329 'upload_filename','upload_title','upload_file_preview', 333 'upload_filename','upload_title','upload_file_preview',
330 'upload_file_props','upload_progress','upload_tags', 334 'upload_file_props','upload_progress','upload_tags',
331 'cmd_uploads_upload' 335 'cmd_uploads_upload'
332 ]); 336 ]);
333 document.getElementById('uploadlist').view = this; 337 document.getElementById('uploadlist').view = this;
334 }, 338 },