author | Michael Krelin <hacker@klever.net> | 2006-09-29 23:02:49 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-09-29 23:02:49 (UTC) |
commit | 74a277c2d7ac5416c3b55565e6d5e8e5a15b389d (patch) (side-by-side diff) | |
tree | 755ac7da52079e87a29b68191e66d7e1d7c0a766 /content | |
parent | 3cf3cf1000ce6b27ac622c75fc3d114874e2f3a8 (diff) | |
download | fireflix-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
-rw-r--r-- | content/fireflix.js | 36 | ||||
-rw-r--r-- | content/util.js | 9 |
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 @@ -9,22 +9,18 @@ function splitascii(s) { } var fireflix = { flickr: new Flickr(), init: function() { - this.cmd_auth_auth = document.getElementById('cmd_auth_auth'); - this.cmd_auth_done = document.getElementById('cmd_auth_done'); - this.cmd_auth_unauth = document.getElementById('cmd_auth_unauth'); - this.menu_auth_done = document.getElementById('menu_auth_done'); - this.b_auth = document.getElementById('b_auth'); - this.b_auth_done = document.getElementById('b_auth_done'); - this.auth_info = document.getElementById('auth_info'); - this.loc_strings = document.getElementById('loc_strings'); + pull_elements(this,document,[ + 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth', + 'menu_auth_done','b_auth','b_auth_done','auth_info', + 'loc_strings','cmd_set_props' + ]); this.build_menus(); - this.cmd_set_props = document.getElementById('cmd_set_props'); this.foundphotos.init(this); this.photosets.init(this); this.photoset.init(this); this.uploads.init(this); this.uploadObserver.init(this); this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; @@ -309,18 +305,16 @@ var fireflix = { }, uploads: { fireflix: null, init: function(f) { this.fireflix=f; - this.upload_filename = document.getElementById('upload_filename'); - this.upload_title = document.getElementById('upload_title'); - this.upload_file_preview = document.getElementById('upload_file_preview'); - this.upload_file_props = document.getElementById('upload_file_props'); - this.upload_progress = document.getElementById('upload_progress'); - this.upload_tags = document.getElementById('upload_tags'); + pull_elements(this,document,[ + 'upload_filename','upload_title','upload_file_preview', + 'upload_file_props','upload_progress','upload_tags' + ]); }, files: new Array(), rowCount: 0, getCellText: function(r,c) { var f = this.files[r]; if(c.id=='up_file') return f.file; @@ -688,20 +682,18 @@ var fireflix = { * */ foundphotos: { fireflix: null, init: function(f) { this.fireflix = f; - this.search_for = document.getElementById('search_for'); - this.search_tags= document.getElementById('search_tags'); - this.search_mine = document.getElementById('search_mine'); + pull_elements(this,document,[ + 'search_for','search_tags','search_mine', + 'searchresult_props','search_photo', + 'searchresult_title','searchresult_description' + ]); document.getElementById('searchresults').view = this; - this.searchresult_props = document.getElementById('searchresult_props'); - this.search_photo = document.getElementById('search_photo'); - this.searchresult_title = document.getElementById('searchresult_title'); - this.searchresult_description = document.getElementById('searchresult_description'); }, photos: new Array(), rowCount: 0, getCellText: function(r,c) { var p = this.photos[r]; if(c.id=='sr_title') return p.title; diff --git a/content/util.js b/content/util.js index 5af0978..c4af09e 100644 --- a/content/util.js +++ b/content/util.js @@ -56,6 +56,15 @@ function xp_str(xp,x) { function xp_node(xp,x) { var rv = x.evaluate( xp, x, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ); return rv.singleNodeValue; } +/* + * pull in elements into documents as a member variables + */ +function pull_elements(th,d,els) { + for(var e in els) { + var en=els[e]; + th[en] = d.getElementById(en); + } +} |