-rw-r--r-- | content/photoset-props.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/content/photoset-props.js b/content/photoset-props.js new file mode 100644 index 0000000..43dc1b9 --- a/dev/null +++ b/content/photoset-props.js | |||
@@ -0,0 +1,81 @@ | |||
1 | |||
2 | var psetprops = { | ||
3 | fireflix: null, | ||
4 | photoset: null, | ||
5 | pripic: null, | ||
6 | |||
7 | settitle: null, setdesc: null, | ||
8 | primarypic: null, | ||
9 | photos: new Array(), | ||
10 | init: function() { | ||
11 | this.fireflix = window.arguments[0]; | ||
12 | this.photoset = window.arguments[1]; | ||
13 | this.settitle = document.getElementById('set_title'); | ||
14 | this.settitle.value = this.photoset.title; | ||
15 | this.setdesc = document.getElementById('set_desc'); | ||
16 | this.setdesc.value = this.photoset.description; | ||
17 | this.primarypic = document.getElementById('primary_picture'); | ||
18 | this.primarypic.src = | ||
19 | this.fireflix.flickr.get_image_url( this.photoset, 't' ); | ||
20 | this.primarypic.hidden = false; | ||
21 | this.picslist = document.getElementById('primary_picture_list'); | ||
22 | |||
23 | var _this = this; | ||
24 | this.fireflix.flickr.api_call( | ||
25 | { | ||
26 | method: 'flickr.photosets.getPhotos', | ||
27 | auth_token: 'default', | ||
28 | photoset_id: this.photoset.id | ||
29 | }, function(xr) { | ||
30 | var x = xr.responseXML; | ||
31 | var xp = x.evaluate( | ||
32 | '/rsp/photoset/photo', x, null, | ||
33 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | ||
34 | _this.picslist.removeAllItems(); _this.photos= new Array(); | ||
35 | var n; while(n=xp.iterateNext()) { | ||
36 | _this.photos.push( | ||
37 | { | ||
38 | id: n.getAttribute('id'), | ||
39 | secret: n.getAttribute('secret'), | ||
40 | server: n.getAttribute('server') | ||
41 | } | ||
42 | ); | ||
43 | var ni = _this.picslist.appendItem( | ||
44 | n.getAttribute('title'), _this.photos.length-1 | ||
45 | ); | ||
46 | ni.setAttribute('command','cmd_select_picture'); | ||
47 | if(n.getAttribute('isprimary')==1) { | ||
48 | _this.picslist.selectedItem = ni; | ||
49 | _this.pripic = _this.photos[_this.photos.length-1]; | ||
50 | } | ||
51 | } | ||
52 | _this.picslist.hidden = false; | ||
53 | }, function() { } | ||
54 | ); | ||
55 | }, | ||
56 | on_select_picture: function(ev) { | ||
57 | var epic = ev.explicitOriginalTarget; | ||
58 | this.picslist.selectedItem = epic; | ||
59 | var pic = this.photos[this.picslist.selectedItem.value]; | ||
60 | this.pripic = pic; | ||
61 | this.primarypic.src = | ||
62 | this.fireflix.flickr.get_photo_url( | ||
63 | pic.server, | ||
64 | pic.id, | ||
65 | pic.secret, | ||
66 | 't' | ||
67 | ); | ||
68 | }, | ||
69 | on_accept: function() { | ||
70 | this.photoset.title = | ||
71 | document.getElementById('set_title').value; | ||
72 | this.photoset.description = | ||
73 | document.getElementById('set_desc').value; | ||
74 | this.photoset.server = this.pripic.server; | ||
75 | this.photoset.primary = this.pripic.id; | ||
76 | this.photoset.secret = this.pripic.secret; | ||
77 | this.photoset.dirty = true; | ||
78 | return; | ||
79 | } | ||
80 | }; | ||
81 | |||