0

I have the following script in my cms page:

window.addEvent('domready', function () {

    SqueezeBox.initialize({});
    SqueezeBox.assign($$('a.modal'), {
        parse: 'rel'
    });
});

var j2storeURL = 'http://tours-international.com.gridhosted.co.uk/';

if (typeof (J2Store) == 'undefined') {
    var J2Store = jQuery.noConflict();
}


J2Store(document).ready(function () {
    J2Store('.j2storeCartForm').each(function () {
        J2Store(this).validate({
            errorElement: 'em',
            errorPlacement: function (error, element) {
                error.appendTo(element.parent().parent().next('div'));
            },
            success: function (label) {
                //label.text('Ok').addClass('success');
            },
            submitHandler: function (form) {

                j2storeAddToCart('addtocart', form);

            }
        });
    });
});

jQuery(document).ready(function () {
    jQuery('.hasTooltip').tooltip({});
});

I want to loop through the above and remove the following JS:

SqueezeBox.initialize({});

SqueezeBox.assign($$('a.modal'), {
    parse: 'rel'
});

Please advise easiest/smallest way to do this.

1 Answer 1

0

If I understood the question correctly, you want to remove that part from a file???

If yes, then you can do the following:

  1. Read the file into string $file_str = file_get_contents('your_file_path');
  2. Get the positions: $pos_a = strpos($file_str, "SqueezeBox") and $pos_b = strpos($file_str, "var")
  3. Write this back: substr_replace($file_str, "", $pos_a, ($pos_b - $pos_a));

Good luck

6
  • Well, sort of - this is Joomla, so a plugin is injecting the SqueezeBox part into & building that script... so I need a bit of php to remove just the SqueezeBox bit, after it has been created Commented Jun 15, 2013 at 8:38
  • there is not an actual file, the javascript is being built & input into my template - so I want to add something to my template to remove that part Commented Jun 15, 2013 at 8:40
  • when you say "i wanna loop through", what do you mean. How do you exactly access this code...from where??? Commented Jun 15, 2013 at 8:43
  • in my joomla template I have <jdoc:include type="head" /> - this pull's in bits & builds the head, including building that JS. So I just want to remove the SqueezeBox part of that JS after it has been built. So I thought about looping through the _scripts array and removing it from there. Commented Jun 15, 2013 at 8:47
  • what do you mean "scripts array"? If you can get a script from the array as a string => my answer still applies to it. Commented Jun 15, 2013 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.