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 --- program/js/common.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'program/js/common.js') diff --git a/program/js/common.js b/program/js/common.js index afaf91639..02934f734 100644 --- a/program/js/common.js +++ b/program/js/common.js @@ -592,6 +592,14 @@ Date.prototype.getStdTimezoneOffset = function() return tzo; } +// define String's startsWith() method for old browsers +if (!String.prototype.startsWith) { + String.prototype.startsWith = function(search, position) { + position = position || 0; + return this.slice(position, search.length) === search; + }; +} + // Make getElementById() case-sensitive on IE if (bw.ie) { document._getElementById = document.getElementById; -- cgit v1.2.3