summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2011-08-28 16:23:16 (UTC)
committer Michael Krelin <hacker@klever.net>2011-08-28 16:23:16 (UTC)
commit63b7d8b9cd7b4c4fd010a46bb2737a47d5afa65e (patch) (side-by-side diff)
tree3533952c3632c34b25c399c2d9b6cf586d1cd4b0
parente58247a43552504e34ae31a5262a8a9dd338243c (diff)
downloadfireflix-63b7d8b9cd7b4c4fd010a46bb2737a47d5afa65e.zip
fireflix-63b7d8b9cd7b4c4fd010a46bb2737a47d5afa65e.tar.gz
fireflix-63b7d8b9cd7b4c4fd010a46bb2737a47d5afa65e.tar.bz2
more jsonification (is this code ever used?)
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--content/fireflix.js18
1 files changed, 6 insertions, 12 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index d70ab4d..34cfd3e 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -140,208 +140,202 @@ var fireflix = {
auth_token: 'default',
photoset_id: psid,
extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update'
}, function(x,j) {
that.import_json(j.photoset.photo);
}, function(x,s,c,m) {
that.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_props.hidden = false;
}else{
this.set_photo_props.hidden = true;
}
},
on_cmd_open: function(ev) {
if(this.selection.currentIndex<0) return;
var p = this.photos[this.selection.currentIndex];
if(!p.id) return;
this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p'));
}
},
/* 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 },
import_json: function(j) {
this.tree.beginUpdateBatch();
this.sets = new Array();
for(var i in j) this.sets.push(new Photoset(j[i]));
this.rowCount = this.sets.length;
this.tree.endUpdateBatch();
},
refresh_sets: function() {
var that = this;
this.fireflix.flickr.api_call_json(
{
method: 'flickr.photosets.getList',
auth_token: 'default'
}, function(x,j) {
that.import_json(j.photosets.photoset);
}, function(x,s,c,m) {
that.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');
}
},
on_cmd_open_in_flickr: function(ev) {
if(this.selection.currentIndex<0) return;
var p = this.sets[this.selection.currentIndex];
if(!p.id) return;
this.fireflix.openTab(this.fireflix.flickr.make_photoset_url(p));
}
},
refresh_user_tags: function() {
var lb = document.getElementById('tagslist');
- var _this = this;
- this.flickr.api_call(
+ var that = this;
+ this.flickr.api_call_json(
{
method: 'flickr.tags.getListUser',
auth_token: 'default',
- }, function(xr) {
- var x = xr.responseXML;
- var xp = x.evaluate(
- '/rsp/who/tags/tag', x, null,
- XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
- // TODO: clear list
- var n; while(n=xp.iterateNext()) {
- lb.appendItem(n.firstChild.nodeValue);
- }
+ }, function(x,j) {
+ var tt = j.who.tags.tag;
+ for(var i in tt) lb.appendItem(tt[i]._content);
}, function(x,s,c,m) {
- _this.flickr_failure(x,s,c,m);
+ that.flickr_failure(x,s,c,m);
}
);
},
uploadObserver: {
fireflix: null,
init: function(f) {
this.fireflix = f;
},
getSupportedFlavours: function() {
var rv = new FlavourSet();
rv.appendFlavour('application/x-moz-file','nsIFile');
rv.appendFlavour('application/x-moz-url');
rv.appendFlavour('text/uri-list');
rv.appendFlavour('text/unicode');
return rv;
},
canHandleMultipleItems: true,
onDragOver: function(ev,fl,sess) {
return true;
},
onDrop: function(ev,dd,s) {
var ldf = null;
for(var i in dd.dataList) {
var di = dd.dataList[i];
var dif = di.first;
if(
ldf==null
|| ldf.flavour.contentType!=dif.flavour.contentType
|| ldf.contentLength!=dif.contentLength
|| ldf.data!=dif.data )
this.drop_item(ev,di,s);
ldf = dif;
}
},
drop_item: function(ev,di,s) {
var d = di.first;
switch(d.flavour.contentType) {
case 'text/unicode':
this.drop_urilist(ev,d.data,s);
break;
case 'application/x-moz-file':
this.fireflix.uploads.add(d.data.path);
document.getElementById('fireflix_tabs').selectedTab
= document.getElementById('tab_upload');
break;
case 'text/uri-list':
// is it ascii or could it be utf8?
this.drop_urilist(ev,splitascii(d.data),s);
break;
default: alert(d.flavour.contentType+':'+d.data); break;
};
},
drop_urilist: function(ev,ul,s) {
// TODO: check for being a file?
var us = decodeURIComponent(ul).split(/[\r\n]/);
for(var ui in us)
if(/\S/.test(us[ui]))
this.fireflix.uploads.add(us[ui]);
document.getElementById('fireflix_tabs').selectedTab
= document.getElementById('tab_upload');
}
},
uploads: {
fireflix: null,
init: function(f) {
this.fireflix=f;
pull_elements(this,document,[
'upload_filename','upload_title','upload_file_preview',
'upload_file_props','upload_progress','upload_tags',
'cmd_uploads_upload', 'upload_failure', 'upload_is_public',
'upload_is_friends', 'upload_is_family'
]);
document.getElementById('uploadlist').view = this;
this.upload_is_public.addEventListener(
'CheckboxStateChange', { that: this,
handleEvent: function(ev) { this.that.propsToSel('is_public'); }
}, false );
this.upload_is_friends.addEventListener(
'CheckboxStateChange', { that: this,
handleEvent: function(ev) { this.that.propsToSel('is_friends'); }
}, false );
this.upload_is_family.addEventListener(
'CheckboxStateChange', { that: this,
handleEvent: function(ev) { this.that.propsToSel('is_family'); }
}, false );
},
files: new Array(),
rowCount: 0,
getCellText: function(r,c) {
var f = this.files[r];
if(c.id=='up_file') return f.file;
if(c.id=='up_title') return f.title;
if(c.id=='up_status') return f.state;
return c.id;