-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 | |||
@@ -56,97 +56,103 @@ var fireflix = { | |||
56 | _this.openTab(u); | 56 | _this.openTab(u); |
57 | _this.set_auth_state(_this.flickr.token,true); | 57 | _this.set_auth_state(_this.flickr.token,true); |
58 | }, function(x,s,c,m) { | 58 | }, function(x,s,c,m) { |
59 | _this.flickr_failure(x,s,c,m); | 59 | _this.flickr_failure(x,s,c,m); |
60 | } | 60 | } |
61 | ); | 61 | ); |
62 | }, | 62 | }, |
63 | on_cmd_auth_done: function() { | 63 | on_cmd_auth_done: function() { |
64 | this.set_auth_state(this.flickr.token,false); | 64 | this.set_auth_state(this.flickr.token,false); |
65 | var _this = this; | 65 | var _this = this; |
66 | this.flickr.authorize_1( | 66 | this.flickr.authorize_1( |
67 | function() { | 67 | function() { |
68 | _this.flickr.save_token(); | 68 | _this.flickr.save_token(); |
69 | _this.refresh_stuff(); | 69 | _this.refresh_stuff(); |
70 | _this.set_auth_state(_this.flickr.token,false); | 70 | _this.set_auth_state(_this.flickr.token,false); |
71 | _this.auth_info.value = | 71 | _this.auth_info.value = |
72 | _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; | 72 | _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; |
73 | }, function(x,s,c,m) { | 73 | }, function(x,s,c,m) { |
74 | _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ | 74 | _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ |
75 | _this.flickr_failure(x,s,c,m); | 75 | _this.flickr_failure(x,s,c,m); |
76 | } | 76 | } |
77 | ); | 77 | ); |
78 | }, | 78 | }, |
79 | on_cmd_auth_unauth: function() { | 79 | on_cmd_auth_unauth: function() { |
80 | this.flickr.reset_token(); | 80 | this.flickr.reset_token(); |
81 | this.set_auth_state(false,false); | 81 | this.set_auth_state(false,false); |
82 | }, | 82 | }, |
83 | 83 | ||
84 | refresh_sets: function() { this.photosets.refresh_sets(); }, | 84 | refresh_sets: function() { this.photosets.refresh_sets(); }, |
85 | refresh_stuff: function() { | 85 | refresh_stuff: function() { |
86 | this.refresh_sets(); | 86 | this.refresh_sets(); |
87 | this.refresh_user_tags(); | 87 | this.refresh_user_tags(); |
88 | }, | 88 | }, |
89 | 89 | ||
90 | /* photoset treeview */ | 90 | /* photoset treeview */ |
91 | photoset: { | 91 | photoset: { |
92 | photos: new Array(), | 92 | photos: new Array(), |
93 | fireflix: null, | 93 | fireflix: null, |
94 | init: function(f) { | 94 | init: function(f) { |
95 | this.fireflix = f; | 95 | this.fireflix = f; |
96 | pull_elements(this,document,[ 'set_photo' ]); | 96 | pull_elements(this,document,[ 'set_photo' ]); |
97 | document.getElementById('setphotos').view = this; | 97 | document.getElementById('setphotos').view = this; |
98 | }, | 98 | }, |
99 | rowCount: 0, | 99 | rowCount: 0, |
100 | getCellText: function(r,c) { | 100 | getCellText: function(r,c) { |
101 | var p = this.photos[r]; | 101 | var p = this.photos[r]; |
102 | if(c.id=='sp_title') return p.title; | 102 | if(c.id=='sp_title') return p.title; |
103 | if(c.id=='sp_taken') return p.datetaken; | 103 | if(c.id=='sp_taken') return p.datetaken; |
104 | if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ | 104 | if(c.id=='sp_upload') { |
105 | var du = new Date(p.dateupload*1000); | ||
106 | var rv = du.getFullYear()+'-'+(du.getMonth()+1)+'-'+du.getDate() | ||
107 | +' '+ | ||
108 | du.getHours()+':'+du.getMinutes()+':'+du.getSeconds(); | ||
109 | return rv.replace(/(\D)(\d)(\D)/,'$10$2$3'); | ||
110 | } | ||
105 | return c.id; | 111 | return c.id; |
106 | }, | 112 | }, |
107 | setTree: function(t) { this.tree = t }, | 113 | setTree: function(t) { this.tree = t }, |
108 | isContainer: function(r) { return false; }, | 114 | isContainer: function(r) { return false; }, |
109 | isSeparator: function(r) { return false; }, | 115 | isSeparator: function(r) { return false; }, |
110 | isSorted: function(r) { return false; }, | 116 | isSorted: function(r) { return false; }, |
111 | getLevel: function(r) { return 0; }, | 117 | getLevel: function(r) { return 0; }, |
112 | getImageSrc: function(r,c) { return null }, | 118 | getImageSrc: function(r,c) { return null }, |
113 | getRowProperties: function(r,p) {}, | 119 | getRowProperties: function(r,p) {}, |
114 | getCellProperties: function(cid,cel,p) {}, | 120 | getCellProperties: function(cid,cel,p) {}, |
115 | getColumnProperties: function(cid,cel,p) { }, | 121 | getColumnProperties: function(cid,cel,p) { }, |
116 | cycleHeader: function(cid,e) { }, | 122 | cycleHeader: function(cid,e) { }, |
117 | getParentIndex: function(r) { return -1; }, | 123 | getParentIndex: function(r) { return -1; }, |
118 | drop: function(r,o) { }, | 124 | drop: function(r,o) { }, |
119 | canDropBeforeAfter: function(r,b) { return false }, | 125 | canDropBeforeAfter: function(r,b) { return false }, |
120 | 126 | ||
121 | importXPR: function(xp) { | 127 | importXPR: function(xp) { |
122 | this.tree.beginUpdateBatch(); | 128 | this.tree.beginUpdateBatch(); |
123 | this.photos = new Array(); | 129 | this.photos = new Array(); |
124 | var n; while(n=xp.iterateNext()) { | 130 | var n; while(n=xp.iterateNext()) { |
125 | this.photos.push(new Photo(n)); | 131 | this.photos.push(new Photo(n)); |
126 | } | 132 | } |
127 | this.rowCount = this.photos.length; | 133 | this.rowCount = this.photos.length; |
128 | this.tree.endUpdateBatch(); | 134 | this.tree.endUpdateBatch(); |
129 | }, | 135 | }, |
130 | load_photos: function(psid) { | 136 | load_photos: function(psid) { |
131 | var _this = this; | 137 | var _this = this; |
132 | this.fireflix.flickr.api_call( | 138 | this.fireflix.flickr.api_call( |
133 | { | 139 | { |
134 | method: 'flickr.photosets.getPhotos', | 140 | method: 'flickr.photosets.getPhotos', |
135 | auth_token: 'default', | 141 | auth_token: 'default', |
136 | photoset_id: psid, | 142 | photoset_id: psid, |
137 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' | 143 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' |
138 | }, function(xr) { | 144 | }, function(xr) { |
139 | var x = xr.responseXML; | 145 | var x = xr.responseXML; |
140 | var xp = x.evaluate( | 146 | var xp = x.evaluate( |
141 | '/rsp/photoset/photo', x, null, | 147 | '/rsp/photoset/photo', x, null, |
142 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | 148 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); |
143 | _this.importXPR(xp); | 149 | _this.importXPR(xp); |
144 | }, function(x,s,c,m) { | 150 | }, function(x,s,c,m) { |
145 | _this.fireflix.flickr_failure(x,s,c,m); | 151 | _this.fireflix.flickr_failure(x,s,c,m); |
146 | } | 152 | } |
147 | ); | 153 | ); |
148 | }, | 154 | }, |
149 | on_select: function() { | 155 | on_select: function() { |
150 | if(this.selection.count==1) { | 156 | if(this.selection.count==1) { |
151 | var p = this.photos[this.selection.currentIndex]; | 157 | var p = this.photos[this.selection.currentIndex]; |
152 | this.set_photo.src = | 158 | this.set_photo.src = |