From 6a91448aee5d036b35c621bbdaff250dc84e15f3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 30 Oct 2013 19:51:55 +0100 Subject: Improve performance and code readability by using String's startsWith() method, other code improvements --- plugins/archive/archive.js | 2 +- program/js/app.js | 24 ++++++++++++------------ program/js/common.js | 8 ++++++++ program/js/editor.js | 2 +- program/js/list.js | 7 ++++--- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/plugins/archive/archive.js b/plugins/archive/archive.js index 17a1ecdb4..2e5267425 100644 --- a/plugins/archive/archive.js +++ b/plugins/archive/archive.js @@ -27,7 +27,7 @@ function rcmail_is_archive() // check if current folder is an archive folder or one of its children if (rcmail.env.mailbox == rcmail.env.archive_folder - || rcmail.env.mailbox.indexOf(rcmail.env.archive_folder + rcmail.env.delimiter) != 0 + || rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter) ) { return true; } diff --git a/program/js/app.js b/program/js/app.js index 55dea3620..1f75e219c 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -1474,7 +1474,7 @@ function rcube_webmail() // select the folder if one of its childs is currently selected // don't select if it's virtual (#1488346) - if (this.env.mailbox && this.env.mailbox.indexOf(name + this.env.delimiter) == 0 && !node.virtual) + if (this.env.mailbox && this.env.mailbox.startsWith(name + this.env.delimiter) && !node.virtual) this.command('list', name); } else { @@ -1655,8 +1655,8 @@ function rcube_webmail() this.env.coltypes = []; for (i=0; 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; } -- cgit v1.2.3