summaryrefslogtreecommitdiffabout
path: root/content/flickr.js
Side-by-side diff
Diffstat (limited to 'content/flickr.js') (more/less context) (show whitespace changes)
-rw-r--r--content/flickr.js65
1 files changed, 29 insertions, 36 deletions
diff --git a/content/flickr.js b/content/flickr.js
index 545144c..716874b 100644
--- a/content/flickr.js
+++ b/content/flickr.js
@@ -8,3 +8,3 @@ function Photoset(s) {
}else
- this.fromNode(s);
+ this.fromJSON(s);
}
@@ -18,11 +18,9 @@ Photoset.prototype = {
description: null,
- fromNode: function(n) {
- this.id = n.getAttribute('id');
- this.primary = n.getAttribute('primary');
- this.secret = n.getAttribute('secret');
- this.server = n.getAttribute('server');
- this.photos = n.getAttribute('photos');
- this.title = n.getElementsByTagName('title').item(0).firstChild.nodeValue;
- this.description = n.getElementsByTagName('description').item(0).firstChild;
- if(this.description) this.description = this.description.nodeValue;
+ fromJSON: function(j) {
+ this.id=j.id;
+ this.primary = j.primary;
+ this.secret = j.secret; this.server = j.server;
+ this.photos = j.photos;
+ this.title = j.title._content;
+ this.description = j.description._content;
}
@@ -37,3 +35,3 @@ function Photo(s) {
}else
- this.fromNode(s);
+ this.fromJSON(s);
}
@@ -50,30 +48,25 @@ Photo.prototype = {
lastupdate: null,
- fromNode: function(n) {
- this.id = n.getAttribute('id'); this.secret = n.getAttribute('secret');
- this.server = n.getAttribute('server');
- this.title = n.getAttribute('title');
- this.isprimary = n.getAttribute('isprimary');
- this.license = n.getAttribute('license');
- this.dateupload = n.getAttribute('dateupload');
- this.datetaken = n.getAttribute('datetaken'); this.datetakengranularity = n.getAttribute('datetakengranularity');
- this.ownername = n.getAttribute('ownername');
- this.iconserver = n.getAttribute('iconserver');
- this.originalformat = n.getAttribute('originalformat');
- this.lastupdate = n.getAttribute('lastupdate');
+ fromJSON: function(j) {
+ this.id = j.id; this.secret = j.secret;
+ this.server = j.server;
+ this.title=j.title;
+ this.isprimary = j.isprimary;
+ this.license = j.license;
+ this.dateupload = j.dateupload;
+ this.datetaken=j.datetaken; j.datetakengranularity=j.datetakengranularity;
+ this.ownername=j.ownername;
+ this.iconserver=j.iconserver;
+ this.originalformat=j.originalformat;
+ this.lastupdate=j.lastupdate;
},
- fromNode_: function(n) {
- var t;
- // TODO: @rotation @isfavorite
+ fromJSON_: function(j) {
this.owner = {};
- t = n.getElementsByTagName('owner').item(0);
- if(t) {
- this.owner.nsid=t.getAttribute('nsid');
- this.owner.username=t.getAttribute('username');
- this.owner.realname=t.getAttribute('realname');
- this.owner.location=t.getAttribute.location;
- }
- t = n.getElementsByTagName('description').item(0);
- if(t && t.firstChild) {
- this.description = t.firstChild.nodeValue;
+ var t;
+ if((t=j.owner)) {
+ this.owner.nsid=t.nsid;
+ this.owner.username=t.username; this.owner.realname=t.realname;
+ this.owner.location=t.location;
}
+ if((t=j.description)) this.description=t._content;
+ // TODO: @rotation @isfavorite
// TODO: visibility/@ispublic visibility/@isfriend visibility/@isfamily