author | Michael Krelin <hacker@klever.net> | 2006-11-12 22:09:39 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-11-12 22:09:39 (UTC) |
commit | afcae0d9514f35c96484e6db1eb21e76821b5654 (patch) (side-by-side diff) | |
tree | 09f24641d6d156e4592778813cbeda62ce03eded /content/fireflix.js | |
parent | 41d39823cf8a9e08ad17b9863e5e3ed88df0ac4e (diff) | |
download | fireflix-afcae0d9514f35c96484e6db1eb21e76821b5654.zip fireflix-afcae0d9514f35c96484e6db1eb21e76821b5654.tar.gz fireflix-afcae0d9514f35c96484e6db1eb21e76821b5654.tar.bz2 |
display human readable picture upload time
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@215 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 85b4d39..a4f13b6 100644 --- a/content/fireflix.js +++ b/content/fireflix.js @@ -1,232 +1,238 @@ function splitascii(s) { var rv=''; for(var i=0;i<s.length;++i) { var w = s.charCodeAt(i); rv += String.fromCharCode( w&0xff, (w>>8)&0xff ); } return rv; } var fireflix = { flickr: new Flickr(), init: function() { pull_elements(this,document,[ 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth', 'menu_auth_done','b_auth','b_auth_done','auth_info', 'loc_strings','cmd_set_props' ]); this.build_menus(); this.foundphotos.init(this); this.photosets.init(this); this.photoset.init(this); this.uploads.init(this); this.uploadObserver.init(this); this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; this.flickr.api_shs = '9c33c9e2f0f0cfd5'; this.flickr.prefs_root = 'net.klever.kin.fireflix'; this.flickr.load_token(); this.no_auth_info_label = this.auth_info.value; this.set_auth_state(this.flickr.token,false); if(this.flickr.token) { this.refresh_stuff(); }else{ this.on_cmd_auth(); } }, set_auth_state: function(au,inp) { /* authorized, in progress */ this.cmd_auth_unauth.disabled = !au; this.b_auth.hidden = au || inp; this.b_auth_done.hidden = !inp; this.menu_auth_done.hidden = !inp; this.cmd_auth_done.setAttribute('disabled',!inp); this.auth_info.disabled = !au; if(au) { this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */ }else{ this.auth_info.value = this.no_auth_info_label; } }, on_cmd_auth: function() { var _this = this; this.flickr.authorize_0( 'delete', function(x,f,u) { _this.openTab(u); _this.set_auth_state(_this.flickr.token,true); }, function(x,s,c,m) { _this.flickr_failure(x,s,c,m); } ); }, on_cmd_auth_done: function() { this.set_auth_state(this.flickr.token,false); var _this = this; this.flickr.authorize_1( function() { _this.flickr.save_token(); _this.refresh_stuff(); _this.set_auth_state(_this.flickr.token,false); _this.auth_info.value = _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; }, function(x,s,c,m) { _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ _this.flickr_failure(x,s,c,m); } ); }, on_cmd_auth_unauth: function() { this.flickr.reset_token(); this.set_auth_state(false,false); }, refresh_sets: function() { this.photosets.refresh_sets(); }, refresh_stuff: function() { this.refresh_sets(); this.refresh_user_tags(); }, /* photoset treeview */ photoset: { photos: new Array(), fireflix: null, init: function(f) { this.fireflix = f; pull_elements(this,document,[ 'set_photo' ]); document.getElementById('setphotos').view = this; }, rowCount: 0, getCellText: function(r,c) { var p = this.photos[r]; if(c.id=='sp_title') return p.title; if(c.id=='sp_taken') return p.datetaken; - if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ + if(c.id=='sp_upload') { + var du = new Date(p.dateupload*1000); + var rv = du.getFullYear()+'-'+(du.getMonth()+1)+'-'+du.getDate() + +' '+ + du.getHours()+':'+du.getMinutes()+':'+du.getSeconds(); + return rv.replace(/(\D)(\d)(\D)/,'$10$2$3'); + } return c.id; }, setTree: function(t) { this.tree = t }, isContainer: function(r) { return false; }, isSeparator: function(r) { return false; }, isSorted: function(r) { return false; }, getLevel: function(r) { return 0; }, getImageSrc: function(r,c) { return null }, getRowProperties: function(r,p) {}, getCellProperties: function(cid,cel,p) {}, getColumnProperties: function(cid,cel,p) { }, cycleHeader: function(cid,e) { }, getParentIndex: function(r) { return -1; }, drop: function(r,o) { }, canDropBeforeAfter: function(r,b) { return false }, importXPR: function(xp) { this.tree.beginUpdateBatch(); this.photos = new Array(); var n; while(n=xp.iterateNext()) { this.photos.push(new Photo(n)); } this.rowCount = this.photos.length; this.tree.endUpdateBatch(); }, load_photos: function(psid) { var _this = this; this.fireflix.flickr.api_call( { method: 'flickr.photosets.getPhotos', auth_token: 'default', photoset_id: psid, extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' }, function(xr) { var x = xr.responseXML; var xp = x.evaluate( '/rsp/photoset/photo', x, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); _this.importXPR(xp); }, function(x,s,c,m) { _this.fireflix.flickr_failure(x,s,c,m); } ); }, on_select: function() { if(this.selection.count==1) { var p = this.photos[this.selection.currentIndex]; this.set_photo.src = this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); this.set_photo.hidden = false; }else{ this.set_photo.hidden = true; } } }, /* photosets treeview */ photosets: { sets: new Array(), fireflix: null, init: function(f) { this.fireflix = f; document.getElementById('setslist').view = this; }, rowCount: 0, getCellText: function(r,c) { var s = this.sets[r]; if(c.id=='sl_name') return s.title; if(c.id=='sl_photos') return s.photos; return c.id; }, setTree: function(t) { this.tree = t }, isContainer: function(r) { return false; }, isSeparator: function(r) { return false; }, isSorted: function() { return false; }, getLevel: function(r) { return 0; }, getImageSrc: function(r,c) { return null }, getRowProperties: function(r,p) {}, getCellProperties: function(cid,cel,p) { }, getColumnProperties: function(cid,cel,p) { }, cycleHeader: function(cid,e) { }, getParentIndex: function(r) { return -1; }, drop: function(r,o) { }, canDropBeforeAfter: function(r,b) { return false }, importXPR: function(xp) { this.tree.beginUpdateBatch(); this.sets = new Array(); var n; while(n=xp.iterateNext()) { this.sets.push(new Photoset(n)); } this.rowCount = this.sets.length; this.tree.endUpdateBatch(); }, refresh_sets: function() { var _this = this; this.fireflix.flickr.api_call( { method: 'flickr.photosets.getList', auth_token: 'default' }, function(xr) { var x = xr.responseXML; var xp = x.evaluate( '/rsp/photosets/photoset', x, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); _this.importXPR(xp); }, function(x,s,c,m) { _this.fireflix.flickr_failure(x,s,c,m); } ); }, on_select: function() { if(this.selection.count==1) { this.fireflix.cmd_set_props.setAttribute('disabled','false'); var s = this.sets[this.selection.currentIndex]; this.fireflix.photoset.load_photos(s.id); }else{ this.fireflix.cmd_set_props.setAttribute('disabled','true'); } } }, refresh_user_tags: function() { var lb = document.getElementById('tagslist'); var _this = this; this.flickr.api_call( { method: 'flickr.tags.getListUser', |