summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index 34cfd3e..f30daee 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -585,143 +585,139 @@ var fireflix = {
on_remove: function() {
if(this.selection.count) {
this.tree.beginUpdateBatch();
for(var i=this.files.length-1;i>=0;--i) {
if(this.selection.isSelected(i)) {
this.files.splice(i,1);
this.rowCount--;
}
}
this.tree.endUpdateBatch();
this.selection.clearSelection();
}
},
on_add: function() {
var ifp = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp);
fp.init(window, "Select a File", ifp.modeOpenMultiple);
fp.appendFilters(ifp.filterImages);
var rv = fp.show();
if(rv==ifp.returnOK) {
var ff = fp.files;
while(ff.hasMoreElements()) {
var f = ff.getNext();
f.QueryInterface(Components.interfaces.nsIFile);
this.add(f.path);
}
}
},
on_cmd_open: function(ev) {
if(this.selection.currentIndex<0) return;
var f = this.files[this.selection.currentIndex];
if(f.photoid) {
this.fireflix.openTab(
this.fireflix.flickr.make_uploader_edit_url(f.photoid)
);
}else{
this.fireflix.openTab( 'file://'+f.file);
}
}
},
on_set_props: function() {
var pset = this.photosets.sets[this.photosets.selection.currentIndex];
window.openDialog(
"chrome://fireflix/content/photoset-props.xul",
null, "dependent,modal,dialog,chrome", this,
pset );
if(pset.dirty) {
- var _this = this;
- this.flickr.api_call(
+ var that = this;
+ this.flickr.api_call_json(
{
method: 'flickr.photosets.editMeta',
auth_token: 'default',
photoset_id: pset.id,
title: pset.title,
description: pset.description
- }, function(xr) {
+ }, function(x,j) {
pset.dirty = false;
- _this.flickr.api_call(
+ that.flickr.api_call_json(
{
method: 'flickr.photosets.getPhotos',
auth_token: 'default',
photoset_id: pset.id
- }, function(xr) {
- var x = xr.responseXML;
- var xp = x.evaluate(
- '/rsp/photoset/photo', x, null,
- XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
+ }, function(x,j) {
+ var pp = j.photoset.photo;
var phids = new Array();
var priph = null;
- var n; while(n=xp.iterateNext()) {
- var pid = n.getAttribute('id');
- phids.push( pid );
- if(pid==pset.primary && n.getAttribute('isprimary')!='1')
- priph = pid;
+ for(var i in pp) {
+ var pid = pp[i].id;
+ phids.push(pid);
+ if(pid==pset.primary && pp[i].isprimary) priph = pid;
}
if(priph) {
- _this.flickr.api_call(
+ that.flickr.api_call_json(
{
method: 'flickr.photosets.editPhotos',
auth_token: 'default',
photoset_id: pset.id,
primary_photo_id: priph,
photo_ids: phids.join(',')
}, function() { }, function(x,s,c,m) { /* flickr.photosets.editPhotos */
- _this.flickr_failure(x,s,c,m);
+ that.flickr_failure(x,s,c,m);
}
);
}
}, function(x,s,c,m) { /* flickr.photosets.getPhotos */
- _this.flickr_failure(x,s,c,m);
+ that.flickr_failure(x,s,c,m);
}
);
}, function(x,s,c,m) { /* flickr.photosets.editMeta */
- _this.flickr_failure(x,s,c,m);
+ that.flickr_failure(x,s,c,m);
}
);
}
},
on_refresh_sets: function() {
this.refresh_sets();
},
on_cmd_sets_html: function(csfx,ev) {
var uti = csfx.charAt(0); var utl = csfx.charAt(1);
var rv = this.build_html(this.photoset.photos,uti,utl);
this.popup_content(rv);
},
on_cmd_setphotos_html: function(csfx,ev) {
var uti = csfx.charAt(0); var utl = csfx.charAt(1);
var rv = '';
for(var p in this.photoset.photos) {
if(this.photoset.selection.isSelected(p))
rv += this.photo_html(this.photoset.photos[p],uti,utl)+'\n';
}
this.popup_content(rv);
},
on_cmd_uploads_html: function(csfx,ev) {
var uti = csfx.charAt(0); var utl = csfx.charAt(1);
var pids = new Array();
for(var f in this.uploads.files) {
if(this.uploads.selection.isSelected(f))
if(this.uploads.files[f].photoid)
pids.push(this.uploads.files[f].photoid);
}
var pp = this.uploads.rowCount*2; if(pp>500) pp = 500;
var _this = this;
this.flickr.api_call(
{
method: 'flickr.photos.search',
auth_token: 'default',
extras: 'original_format',
user_id: 'me',
per_page: pp
},
function(xr) {
var x = xr.responseXML;
var rv = '';
for(var pn in pids) {
var p = pids[pn];
var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x));
rv += _this.photo_html(pp,uti,utl)+'\n';
}