-rw-r--r-- | content/flickr.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/content/flickr.js b/content/flickr.js index b5bfa43..75d1a72 100644 --- a/content/flickr.js +++ b/content/flickr.js | |||
@@ -234,51 +234,56 @@ Flickr.prototype = { | |||
234 | }catch(e) { return this._reset_token(); } | 234 | }catch(e) { return this._reset_token(); } |
235 | return true; | 235 | return true; |
236 | }, | 236 | }, |
237 | reset_token: function() { | 237 | reset_token: function() { |
238 | this._reset_token(); | 238 | this._reset_token(); |
239 | this.save_token(); | 239 | this.save_token(); |
240 | }, | 240 | }, |
241 | 241 | ||
242 | get_photo_url: function(ser,id,sec,sfx,ext) { | 242 | get_photo_url: function(ser,id,sec,sfx,ext) { |
243 | var rv = this.photo_url + ser + '/' + id + '_' + sec; | 243 | var rv = this.photo_url + ser + '/' + id + '_' + sec; |
244 | if(sfx && sfx!='_') rv += '_'+sfx; | 244 | if(sfx && sfx!='_') rv += '_'+sfx; |
245 | rv += ext?'.'+ext:'.jpg'; | 245 | rv += ext?'.'+ext:'.jpg'; |
246 | return rv; | 246 | return rv; |
247 | }, | 247 | }, |
248 | get_image_url: function(o,sfx) { | 248 | get_image_url: function(o,sfx) { |
249 | return this.get_photo_url( | 249 | return this.get_photo_url( |
250 | o.server, | 250 | o.server, |
251 | (o instanceof Photoset)? o.primary : o.id, | 251 | (o instanceof Photoset)? o.primary : o.id, |
252 | o.secret, | 252 | o.secret, |
253 | sfx, | 253 | sfx, |
254 | (sfx=='o')?o.originalformat:null | 254 | (sfx=='o')?o.originalformat:null |
255 | ); | 255 | ); |
256 | }, | 256 | }, |
257 | get_photo_page_url: function(p) { | 257 | get_photo_page_url: function(p) { |
258 | if(p instanceof Photo) // TODO: half wrong, what if no owner? | 258 | if(p instanceof Photo) { |
259 | return this.photos_url + (p.owner.nsid?p.owner.nsid:this.user.nsid) + '/' + p.id; | 259 | // TODO: track photoset and user owner id from there? |
260 | else // TODO: take owner into account? | 260 | // The approach below is sheerly wrong. |
261 | var o = this.user.nsid; | ||
262 | if(p.owner && p.owner.nsid) o = p.owner.nsid; | ||
263 | var rv = this.photos_url + o +'/' + p.id; | ||
264 | return rv; | ||
265 | }else // TODO: take owner into account? | ||
261 | return this.photos_url + this.user.nsid + '/' + p; | 266 | return this.photos_url + this.user.nsid + '/' + p; |
262 | }, | 267 | }, |
263 | make_photo_url: function(p,sfx) { | 268 | make_photo_url: function(p,sfx) { |
264 | if(sfx=='p') | 269 | if(sfx=='p') |
265 | return this.get_photo_page_url(p); | 270 | return this.get_photo_page_url(p); |
266 | else | 271 | else |
267 | return this.get_image_url(p,sfx); | 272 | return this.get_image_url(p,sfx); |
268 | }, | 273 | }, |
269 | 274 | ||
270 | upload_file: function(f,fa,on_success,on_failure) { | 275 | upload_file: function(f,fa,on_success,on_failure) { |
271 | try { | 276 | try { |
272 | var fi = Components.classes["@mozilla.org/file/local;1"] | 277 | var fi = Components.classes["@mozilla.org/file/local;1"] |
273 | .createInstance(Components.interfaces.nsILocalFile); | 278 | .createInstance(Components.interfaces.nsILocalFile); |
274 | fi.initWithPath( f ); | 279 | fi.initWithPath( f ); |
275 | var st = Components.classes["@mozilla.org/network/file-input-stream;1"] | 280 | var st = Components.classes["@mozilla.org/network/file-input-stream;1"] |
276 | .createInstance(Components.interfaces.nsIFileInputStream); | 281 | .createInstance(Components.interfaces.nsIFileInputStream); |
277 | st.init(fi,0x01,00004,null); | 282 | st.init(fi,0x01,00004,null); |
278 | var bis = Components.classes["@mozilla.org/binaryinputstream;1"] | 283 | var bis = Components.classes["@mozilla.org/binaryinputstream;1"] |
279 | .createInstance(Components.interfaces.nsIBinaryInputStream); | 284 | .createInstance(Components.interfaces.nsIBinaryInputStream); |
280 | bis.setInputStream(st); | 285 | bis.setInputStream(st); |
281 | 286 | ||
282 | // allocate and initialize temp storage string | 287 | // allocate and initialize temp storage string |
283 | var pbs = Components.classes["@mozilla.org/storagestream;1"] | 288 | var pbs = Components.classes["@mozilla.org/storagestream;1"] |
284 | .createInstance(Components.interfaces.nsIStorageStream); | 289 | .createInstance(Components.interfaces.nsIStorageStream); |