public static JsString RemoveLast(this JsString s, JsString find)
        {
            var index = s.lastIndexOf(find);

            if (index >= 0)
            {
                return(s.substring(0, index) + s.substring(index + find.length));
            }
            return(s);
        }
Example #2
0
        /*
         *
         * We dont need this right now but keeping the code cause we might need it again someday soon
         * JsString correctPaths(JsString sheet, JsString urlPrefix) {
         *  //First, fix the path of any objects in the system. This fines url references and preprends paths
         *  //Right now this just works for relative urls, I am going to need to fix it for absolute
         *  //Now using this one instead for optional quotes
         *  //(url\s?\(\s?['"]?)([\w\W]*?)(['"]?\s?\))
         *
         *  var pathReplace = new JsRegExp("(url\\s?\\(\\s?[\'\"]?)([\\w\\W]*?)([\'\"]?\\s?\\))", "g");
         *  JsString replacementString = "$1" + urlPrefix + "/$2$3";
         *  sheet = sheet.replace(pathReplace, replacementString);
         *  return sheet;
         * }*/

        void resolveSheet(JsString url)
        {
            var      sheetRequest  = new XMLHttpRequest();
            JsString behaviorSheet = "";
            JsString prefix;

            sheetRequest.open("GET", url, false);
            sheetRequest.send("");

            if (sheetRequest.status == 404)
            {
                throw new JsError("Cannot Find StyleSheet " + url);
            }

            int lastSlash = url.lastIndexOf("/");

            prefix = url.substring(0, lastSlash);

            parseAndPersistBehaviors(sheetRequest.responseText);
        }
 public static bool EndsWith(this JsString s, JsString find)
 {
     return(s.lastIndexOf(find) == s.length - find.length);
 }
        /*
         *
         * We dont need this right now but keeping the code cause we might need it again someday soon
        JsString correctPaths(JsString sheet, JsString urlPrefix) {
            //First, fix the path of any objects in the system. This fines url references and preprends paths
            //Right now this just works for relative urls, I am going to need to fix it for absolute
            //Now using this one instead for optional quotes
            //(url\s?\(\s?['"]?)([\w\W]*?)(['"]?\s?\))

            var pathReplace = new JsRegExp("(url\\s?\\(\\s?[\'\"]?)([\\w\\W]*?)([\'\"]?\\s?\\))", "g");
            JsString replacementString = "$1" + urlPrefix + "/$2$3";
            sheet = sheet.replace(pathReplace, replacementString);
            return sheet;
        }*/
        void resolveSheet(JsString url)
        {
            var sheetRequest = new XMLHttpRequest();
            JsString behaviorSheet = "";
            JsString prefix;

            sheetRequest.open("GET", url, false);
            sheetRequest.send("");

            if (sheetRequest.status == 404) {
                throw new JsError("Cannot Find StyleSheet " + url);
            }

            int lastSlash = url.lastIndexOf("/");
            prefix = url.substring(0, lastSlash);

            parseAndPersistBehaviors(sheetRequest.responseText);
        }