X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fstatic%2Fjs%2Fcommon.functions.js;h=a74132e2a652e6849c9a999b257f996df0ea20fc;hb=bb7c2839a257b071008c32fe4a39eb5e48864368;hp=d6f3f9953281610bbea62b82045dee91b6e14b58;hpb=5d1ad393e97322f88eeee28fe237d85a008cb3b3;p=myslice.git diff --git a/portal/static/js/common.functions.js b/portal/static/js/common.functions.js index d6f3f995..a74132e2 100644 --- a/portal/static/js/common.functions.js +++ b/portal/static/js/common.functions.js @@ -15,6 +15,20 @@ function getKeySplitId(id,separator){ return key; } +// Adding startsWith & endsWith to the string prototype +if ( typeof String.prototype.startsWith != 'function' ) { + String.prototype.startsWith = function( str ) { + return this.substring( 0, str.length ) === str; + }; +}; + +if ( typeof String.prototype.endsWith != 'function' ) { + String.prototype.endsWith = function( str ) { + return this.substring( this.length - str.length, this.length ) === str; + }; +}; +// http://stackoverflow.com/questions/646628/javascript-startswith + function arrays_equal(a,b) { return !(a B ? 1 : 0)) * [1,-1][+!!reverse]; //return ((A < B) ? -1 : // (A > B) ? +1 : 0)) * [-1,1][+!!reverse]; - } + }; +}; + +function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); }