myslice.ini possible themes = onelab, fed4fire, fibre, smartfire
[myslice.git] / portal / static / js / common.functions.js
index 2414216..481e947 100644 (file)
@@ -1,6 +1,7 @@
-/*
- * This file is included in tophat_render.php
- */
+// Escape special characters in jQuery Selector
+function escape_id( myid ) {
+    return "#" + myid.replace( /(:|\.|\[|\])/g, "\\$1" );
+}
 
 function getKeySplitId(id,separator){
     // id of elements must respect this rule
@@ -14,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 || b<a); }
 
 function arrayInArray(elt,tab){