summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2006-09-29 23:02:49 (UTC)
committer Michael Krelin <hacker@klever.net>2006-09-29 23:02:49 (UTC)
commit74a277c2d7ac5416c3b55565e6d5e8e5a15b389d (patch) (unidiff)
tree755ac7da52079e87a29b68191e66d7e1d7c0a766
parent3cf3cf1000ce6b27ac622c75fc3d114874e2f3a8 (diff)
downloadfireflix-74a277c2d7ac5416c3b55565e6d5e8e5a15b389d.zip
fireflix-74a277c2d7ac5416c3b55565e6d5e8e5a15b389d.tar.gz
fireflix-74a277c2d7ac5416c3b55565e6d5e8e5a15b389d.tar.bz2
code beauty: mass-assignment of xul elements to member variables
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@169 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js36
-rw-r--r--content/util.js9
2 files changed, 23 insertions, 22 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index daf4929..98b6d41 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -1,40 +1,36 @@
1function splitascii(s) { 1function splitascii(s) {
2 var rv=''; 2 var rv='';
3 for(var i=0;i<s.length;++i) { 3 for(var i=0;i<s.length;++i) {
4 var w = s.charCodeAt(i); 4 var w = s.charCodeAt(i);
5 rv += String.fromCharCode( 5 rv += String.fromCharCode(
6 w&0xff, (w>>8)&0xff ); 6 w&0xff, (w>>8)&0xff );
7 } 7 }
8 return rv; 8 return rv;
9} 9}
10 10
11 11
12var fireflix = { 12var fireflix = {
13 flickr: new Flickr(), 13 flickr: new Flickr(),
14 init: function() { 14 init: function() {
15 this.cmd_auth_auth = document.getElementById('cmd_auth_auth'); 15 pull_elements(this,document,[
16 this.cmd_auth_done = document.getElementById('cmd_auth_done'); 16 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth',
17 this.cmd_auth_unauth = document.getElementById('cmd_auth_unauth'); 17 'menu_auth_done','b_auth','b_auth_done','auth_info',
18 this.menu_auth_done = document.getElementById('menu_auth_done'); 18 'loc_strings','cmd_set_props'
19 this.b_auth = document.getElementById('b_auth'); 19 ]);
20 this.b_auth_done = document.getElementById('b_auth_done');
21 this.auth_info = document.getElementById('auth_info');
22 this.loc_strings = document.getElementById('loc_strings');
23 this.build_menus(); 20 this.build_menus();
24 this.cmd_set_props = document.getElementById('cmd_set_props');
25 this.foundphotos.init(this); 21 this.foundphotos.init(this);
26 this.photosets.init(this); 22 this.photosets.init(this);
27 this.photoset.init(this); 23 this.photoset.init(this);
28 this.uploads.init(this); 24 this.uploads.init(this);
29 this.uploadObserver.init(this); 25 this.uploadObserver.init(this);
30 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; 26 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3';
31 this.flickr.api_shs = '9c33c9e2f0f0cfd5'; 27 this.flickr.api_shs = '9c33c9e2f0f0cfd5';
32 this.flickr.prefs_root = 'net.klever.kin.fireflix'; 28 this.flickr.prefs_root = 'net.klever.kin.fireflix';
33 this.flickr.load_token(); 29 this.flickr.load_token();
34 document.getElementById('setslist').view = this.photosets; 30 document.getElementById('setslist').view = this.photosets;
35 document.getElementById('setphotos').view = this.photoset; 31 document.getElementById('setphotos').view = this.photoset;
36 document.getElementById('uploadlist').view = this.uploads; 32 document.getElementById('uploadlist').view = this.uploads;
37 this.no_auth_info_label = this.auth_info.value; 33 this.no_auth_info_label = this.auth_info.value;
38 this.set_auth_state(this.flickr.token,false); 34 this.set_auth_state(this.flickr.token,false);
39 if(this.flickr.token) { 35 if(this.flickr.token) {
40 this.refresh_stuff(); 36 this.refresh_stuff();
@@ -299,38 +295,36 @@ var fireflix = {
299 }, 295 },
300 drop_urilist: function(ev,ul,s) { 296 drop_urilist: function(ev,ul,s) {
301 // TODO: check for being a file? 297 // TODO: check for being a file?
302 var us = decodeURIComponent(ul).split(/[\r\n]/); 298 var us = decodeURIComponent(ul).split(/[\r\n]/);
303 for(var ui in us) 299 for(var ui in us)
304 if(/\S/.test(us[ui])) 300 if(/\S/.test(us[ui]))
305 this.fireflix.uploads.add(us[ui]); 301 this.fireflix.uploads.add(us[ui]);
306 document.getElementById('fireflix_tabs').selectedTab 302 document.getElementById('fireflix_tabs').selectedTab
307 = document.getElementById('tab_upload'); 303 = document.getElementById('tab_upload');
308 } 304 }
309 }, 305 },
310 306
311 uploads: { 307 uploads: {
312 fireflix: null, 308 fireflix: null,
313 init: function(f) { 309 init: function(f) {
314 this.fireflix=f; 310 this.fireflix=f;
315 this.upload_filename = document.getElementById('upload_filename'); 311 pull_elements(this,document,[
316 this.upload_title = document.getElementById('upload_title'); 312 'upload_filename','upload_title','upload_file_preview',
317 this.upload_file_preview = document.getElementById('upload_file_preview'); 313 'upload_file_props','upload_progress','upload_tags'
318 this.upload_file_props = document.getElementById('upload_file_props'); 314 ]);
319 this.upload_progress = document.getElementById('upload_progress');
320 this.upload_tags = document.getElementById('upload_tags');
321 }, 315 },
322 files: new Array(), 316 files: new Array(),
323 rowCount: 0, 317 rowCount: 0,
324 getCellText: function(r,c) { 318 getCellText: function(r,c) {
325 var f = this.files[r]; 319 var f = this.files[r];
326 if(c.id=='up_file') return f.file; 320 if(c.id=='up_file') return f.file;
327 if(c.id=='up_title') return f.title; 321 if(c.id=='up_title') return f.title;
328 if(c.id=='up_status') return f.state; 322 if(c.id=='up_status') return f.state;
329 return c.id; 323 return c.id;
330 }, 324 },
331 setTree: function(t) { this.tree = t }, 325 setTree: function(t) { this.tree = t },
332 isContainer: function(r) { return false; }, 326 isContainer: function(r) { return false; },
333 isSeparator: function(r) { return false; }, 327 isSeparator: function(r) { return false; },
334 isSorted: function(r) { return false; }, 328 isSorted: function(r) { return false; },
335 getLevel: function(r) { return 0; }, 329 getLevel: function(r) { return 0; },
336 getImageSrc: function(r,c) { return null }, 330 getImageSrc: function(r,c) { return null },
@@ -678,40 +672,38 @@ var fireflix = {
678 rv += _this.photo_html(pp,uti,utl)+'\n'; 672 rv += _this.photo_html(pp,uti,utl)+'\n';
679 } 673 }
680 _this.popup_content(rv); 674 _this.popup_content(rv);
681 }, function(x,s,c,m) { 675 }, function(x,s,c,m) {
682 _this.flickr_failure(x,s,c,m); 676 _this.flickr_failure(x,s,c,m);
683 } 677 }
684 ); 678 );
685 }, 679 },
686 680
687 /* 681 /*
688 * 682 *
689 */ 683 */
690 foundphotos: { 684 foundphotos: {
691 fireflix: null, 685 fireflix: null,
692 init: function(f) { 686 init: function(f) {
693 this.fireflix = f; 687 this.fireflix = f;
694 this.search_for = document.getElementById('search_for'); 688 pull_elements(this,document,[
695 this.search_tags= document.getElementById('search_tags'); 689 'search_for','search_tags','search_mine',
696 this.search_mine = document.getElementById('search_mine'); 690 'searchresult_props','search_photo',
691 'searchresult_title','searchresult_description'
692 ]);
697 document.getElementById('searchresults').view = this; 693 document.getElementById('searchresults').view = this;
698 this.searchresult_props = document.getElementById('searchresult_props');
699 this.search_photo = document.getElementById('search_photo');
700 this.searchresult_title = document.getElementById('searchresult_title');
701 this.searchresult_description = document.getElementById('searchresult_description');
702 }, 694 },
703 photos: new Array(), 695 photos: new Array(),
704 rowCount: 0, 696 rowCount: 0,
705 getCellText: function(r,c) { 697 getCellText: function(r,c) {
706 var p = this.photos[r]; 698 var p = this.photos[r];
707 if(c.id=='sr_title') return p.title; 699 if(c.id=='sr_title') return p.title;
708 return c.id; 700 return c.id;
709 }, 701 },
710 setTree: function(t) { this.tree = t }, 702 setTree: function(t) { this.tree = t },
711 isContainer: function(r) { return false }, 703 isContainer: function(r) { return false },
712 isSeparator: function(r) { return false }, 704 isSeparator: function(r) { return false },
713 isSorted: function(r) { return false }, 705 isSorted: function(r) { return false },
714 getLevel: function(r) { return 0 }, 706 getLevel: function(r) { return 0 },
715 getImageSrc: function(r,c) { return null }, 707 getImageSrc: function(r,c) { return null },
716 getRowProperties: function(r,p) { }, 708 getRowProperties: function(r,p) { },
717 getCellProperties: function(cid,cel,p) { }, 709 getCellProperties: function(cid,cel,p) { },
diff --git a/content/util.js b/content/util.js
index 5af0978..c4af09e 100644
--- a/content/util.js
+++ b/content/util.js
@@ -46,16 +46,25 @@ function toutf8(ucode) {
46 * extract xpath-specified string value 46 * extract xpath-specified string value
47 */ 47 */
48function xp_str(xp,x) { 48function xp_str(xp,x) {
49 var rv = x.evaluate( 49 var rv = x.evaluate(
50 xp, x, null, XPathResult.STRING_TYPE, null ); 50 xp, x, null, XPathResult.STRING_TYPE, null );
51 return rv.stringValue; 51 return rv.stringValue;
52} 52}
53/* 53/*
54 * extract xpath-specified node 54 * extract xpath-specified node
55 */ 55 */
56function xp_node(xp,x) { 56function xp_node(xp,x) {
57 var rv = x.evaluate( 57 var rv = x.evaluate(
58 xp, x, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ); 58 xp, x, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null );
59 return rv.singleNodeValue; 59 return rv.singleNodeValue;
60} 60}
61 61
62/*
63 * pull in elements into documents as a member variables
64 */
65function pull_elements(th,d,els) {
66 for(var e in els) {
67 var en=els[e];
68 th[en] = d.getElementById(en);
69 }
70}