diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2013-10-30 19:51:55 +0100 |
---|---|---|
committer | Aleksander Machniak <machniak@kolabsys.com> | 2013-10-30 19:51:55 +0100 |
commit | 6a91448aee5d036b35c621bbdaff250dc84e15f3 (patch) | |
tree | 4cc4c149e05b163d8a2a209471d07b13344e5801 /program/js/list.js | |
parent | 8d9dcca2b6fc1117e170195aa4104980e5bfa238 (diff) |
Improve performance and code readability by using String's startsWith() method, other code improvements
Diffstat (limited to 'program/js/list.js')
-rw-r--r-- | program/js/list.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/program/js/list.js b/program/js/list.js index 46d9d2757..b2d4f8a63 100644 --- a/program/js/list.js +++ b/program/js/list.js @@ -31,6 +31,7 @@ function rcube_list_widget(list, p) this.list = list ? list : null; this.tagname = this.list ? this.list.nodeName.toLowerCase() : 'table'; + this.id_regexp = /^rcmrow([a-z0-9\-_=\+\/]+)/i; this.thead; this.tbody; this.fixed_header; @@ -110,7 +111,7 @@ init: function() init_row: function(row) { // make references in internal array and set event handlers - if (row && String(row.id).match(/^rcmrow([a-z0-9\-_=\+\/]+)/i)) { + if (row && String(row.id).match(this.id_regexp)) { var self = this, uid = RegExp.$1; row.uid = uid; @@ -728,7 +729,7 @@ get_first_row: function() var i, len, rows = this.tbody.childNodes; for (i=0, len=rows.length-1; i<len; i++) - if (rows[i].id && String(rows[i].id).match(/^rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null) + if (rows[i].id && String(rows[i].id).match(this.id_regexp) && this.rows[RegExp.$1] != null) return RegExp.$1; } @@ -741,7 +742,7 @@ get_last_row: function() var i, rows = this.tbody.childNodes; for (i=rows.length-1; i>=0; i--) - if (rows[i].id && String(rows[i].id).match(/^rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null) + if (rows[i].id && String(rows[i].id).match(this.id_regexp) && this.rows[RegExp.$1] != null) return RegExp.$1; } |