-rw-r--r-- | content/fireflix.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 0f01d26..f180379 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -9,97 +9,99 @@ function splitascii(s) { | |||
9 | } | 9 | } |
10 | 10 | ||
11 | 11 | ||
12 | var fireflix = { | 12 | var fireflix = { |
13 | flickr: new Flickr(), | 13 | flickr: new Flickr(), |
14 | init: function() { | 14 | init: function() { |
15 | pull_elements(this,document,[ | 15 | pull_elements(this,document,[ |
16 | 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth', | 16 | 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth', |
17 | 'menu_auth_done','b_auth','b_auth_done','auth_info', | 17 | 'menu_auth_done','b_auth','b_auth_done','auth_info', |
18 | 'loc_strings','cmd_set_props' | 18 | 'loc_strings','cmd_set_props' |
19 | ]); | 19 | ]); |
20 | this.build_menus(); | 20 | this.build_menus(); |
21 | this.foundphotos.init(this); | 21 | this.foundphotos.init(this); |
22 | this.photosets.init(this); | 22 | this.photosets.init(this); |
23 | this.photoset.init(this); | 23 | this.photoset.init(this); |
24 | this.uploads.init(this); | 24 | this.uploads.init(this); |
25 | this.uploadObserver.init(this); | 25 | this.uploadObserver.init(this); |
26 | this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; | 26 | this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; |
27 | this.flickr.api_shs = '9c33c9e2f0f0cfd5'; | 27 | this.flickr.api_shs = '9c33c9e2f0f0cfd5'; |
28 | this.flickr.prefs_root = 'net.klever.kin.fireflix'; | 28 | this.flickr.prefs_root = 'net.klever.kin.fireflix'; |
29 | this.flickr.load_token(); | 29 | this.flickr.load_token(); |
30 | document.getElementById('setslist').view = this.photosets; | 30 | document.getElementById('setslist').view = this.photosets; |
31 | document.getElementById('setphotos').view = this.photoset; | 31 | document.getElementById('setphotos').view = this.photoset; |
32 | document.getElementById('uploadlist').view = this.uploads; | 32 | document.getElementById('uploadlist').view = this.uploads; |
33 | this.no_auth_info_label = this.auth_info.value; | 33 | this.no_auth_info_label = this.auth_info.value; |
34 | this.set_auth_state(this.flickr.token,false); | 34 | this.set_auth_state(this.flickr.token,false); |
35 | if(this.flickr.token) { | 35 | if(this.flickr.token) { |
36 | this.refresh_stuff(); | 36 | this.refresh_stuff(); |
37 | }else{ | 37 | }else{ |
38 | this.on_cmd_auth(); | 38 | this.on_cmd_auth(); |
39 | } | 39 | } |
40 | }, | 40 | }, |
41 | set_auth_state: function(au,inp) { /* authorized, in progress */ | 41 | set_auth_state: function(au,inp) { /* authorized, in progress */ |
42 | this.cmd_auth_unauth.disabled = !au; | 42 | this.cmd_auth_unauth.disabled = !au; |
43 | this.b_auth.hidden = au || inp; | 43 | this.b_auth.hidden = au || inp; |
44 | this.b_auth_done.hidden = !inp; | 44 | this.b_auth_done.hidden = !inp; |
45 | this.menu_auth_done.hidden = !inp; | 45 | this.menu_auth_done.hidden = !inp; |
46 | this.cmd_auth_done.setAttribute('disabled',!inp); | 46 | this.cmd_auth_done.setAttribute('disabled',!inp); |
47 | this.auth_info.disabled = !au; | 47 | this.auth_info.disabled = !au; |
48 | if(au) { | 48 | if(au) { |
49 | this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */ | 49 | this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */ |
50 | }else{ | 50 | }else{ |
51 | this.auth_info.value = this.no_auth_info_label; | 51 | this.auth_info.value = this.no_auth_info_label; |
52 | } | 52 | } |
53 | }, | 53 | }, |
54 | on_cmd_auth: function() { | 54 | on_cmd_auth: function() { |
55 | var _this = this; | 55 | var _this = this; |
56 | this.flickr.authorize_0( | 56 | this.flickr.authorize_0( |
57 | function() { | 57 | 'delete', |
58 | function(x,f,u) { | ||
59 | _this.openTab(u); | ||
58 | _this.set_auth_state(_this.flickr.token,true); | 60 | _this.set_auth_state(_this.flickr.token,true); |
59 | }, function(x,s,c,m) { | 61 | }, function(x,s,c,m) { |
60 | _this.flickr_failure(x,s,c,m); | 62 | _this.flickr_failure(x,s,c,m); |
61 | } | 63 | } |
62 | ); | 64 | ); |
63 | }, | 65 | }, |
64 | on_cmd_auth_done: function() { | 66 | on_cmd_auth_done: function() { |
65 | this.set_auth_state(this.flickr.token,false); | 67 | this.set_auth_state(this.flickr.token,false); |
66 | var _this = this; | 68 | var _this = this; |
67 | this.flickr.authorize_1( | 69 | this.flickr.authorize_1( |
68 | function() { | 70 | function() { |
69 | _this.flickr.save_token(); | 71 | _this.flickr.save_token(); |
70 | _this.refresh_stuff(); | 72 | _this.refresh_stuff(); |
71 | _this.set_auth_state(_this.flickr.token,false); | 73 | _this.set_auth_state(_this.flickr.token,false); |
72 | _this.auth_info.value = | 74 | _this.auth_info.value = |
73 | _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; | 75 | _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; |
74 | }, function(x,s,c,m) { | 76 | }, function(x,s,c,m) { |
75 | _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ | 77 | _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ |
76 | _this.flickr_failure(x,s,c,m); | 78 | _this.flickr_failure(x,s,c,m); |
77 | } | 79 | } |
78 | ); | 80 | ); |
79 | }, | 81 | }, |
80 | on_cmd_auth_unauth: function() { | 82 | on_cmd_auth_unauth: function() { |
81 | this.flickr.reset_token(); | 83 | this.flickr.reset_token(); |
82 | this.set_auth_state(false,false); | 84 | this.set_auth_state(false,false); |
83 | }, | 85 | }, |
84 | 86 | ||
85 | refresh_sets: function() { this.photosets.refresh_sets(); }, | 87 | refresh_sets: function() { this.photosets.refresh_sets(); }, |
86 | refresh_stuff: function() { | 88 | refresh_stuff: function() { |
87 | this.refresh_sets(); | 89 | this.refresh_sets(); |
88 | this.refresh_user_tags(); | 90 | this.refresh_user_tags(); |
89 | }, | 91 | }, |
90 | 92 | ||
91 | /* photoset treeview */ | 93 | /* photoset treeview */ |
92 | photoset: { | 94 | photoset: { |
93 | photos: new Array(), | 95 | photos: new Array(), |
94 | fireflix: null, | 96 | fireflix: null, |
95 | init: function(f) { | 97 | init: function(f) { |
96 | this.fireflix = f; | 98 | this.fireflix = f; |
97 | pull_elements(this,document,[ 'set_photo' ]); | 99 | pull_elements(this,document,[ 'set_photo' ]); |
98 | }, | 100 | }, |
99 | rowCount: 0, | 101 | rowCount: 0, |
100 | getCellText: function(r,c) { | 102 | getCellText: function(r,c) { |
101 | var p = this.photos[r]; | 103 | var p = this.photos[r]; |
102 | if(c.id=='sp_title') return p.title; | 104 | if(c.id=='sp_title') return p.title; |
103 | if(c.id=='sp_taken') return p.datetaken; | 105 | if(c.id=='sp_taken') return p.datetaken; |
104 | if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ | 106 | if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ |
105 | return c.id; | 107 | return c.id; |