ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

EE Removing Brackets in JS?

July 03, 2012 12:59pm

Subscribe [1]
  • #1 / Jul 03, 2012 12:59pm

    Jacob Graf

    163 posts

    I have a template with this code…

    <div id="wufoo-q7x1k3">
    Fill out my <a href="http://graftechnology.wufoo.com/forms/q7x1k3">online form</a>.
    </div>
    [removed]var q7x1k3;(function(d, t) {
    var s = d.createElement(t), options = {
    'userName':'graftechnology', 
    'formHash':'q7x1k3', 
    'autoResize':true,
    'height':'592',
    'async':true,
    'header':'show', 
    'ssl':true};
    s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js';
    s.onload = s.onreadystatechange = function() {
    var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return;
    try { q7x1k3 = new WufooForm();q7x1k3.initialize(options);q7x1k3.display(); } catch (e) {}};
    var scr = d.getElementsByTagName(t)[0], par = scr[removed]; par.insertBefore(s, scr);
    })(document, 'script');[removed]

    It’s located at http://www.victorycoc.com/contact/test

    When the page is rendered, it breaks, because EE is removing a set of brackets at the end. If you look at the source, you see this code.

    <div id="wufoo-q7x1k3">
    Fill out my <a href="http://graftechnology.wufoo.com/forms/q7x1k3">online form</a>.
    </div>
    [removed]var q7x1k3;(function(d, t) {
    var s = d.createElement(t), options = {
    'userName':'graftechnology', 
    'formHash':'q7x1k3', 
    'autoResize':true,
    'height':'592',
    'async':true,
    'header':'show', 
    'ssl':true};
    s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js';
    s.onload = s.onreadystatechange = function() {
    var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return;
    try { q7x1k3 = new WufooForm();q7x1k3.initialize(options);q7x1k3.display(); } catch (e) ;
    var scr = d.getElementsByTagName(t)[0], par = scr[removed]; par.insertBefore(s, scr);
    })(document, 'script');[removed]

    Down on the bottom, by the catch (e).

    Any ideas what’s going on here?

    Thanks!

  • #2 / Jul 03, 2012 1:08pm

    There’s probably a more elegant solution, but, one quick get-it-done-and-move-on solution is to include that JS via a file outside of EE’s templating system.

    Also, I’m not sure if the “removed” code you’ve got there is a tag of some sort, but, it looks like the last one isn’t closed…

  • #3 / Jul 03, 2012 5:30pm

    Jacob Graf

    163 posts

    Unreal. I am running EE 2.2.1 on this site and it appears there is a BUG. Apparently when your debug prefs are set to 0, it breaks some javascript. What’s weird, is this is the source I see in my Control Panel.

    <td><strong>Debug Preference</strong><div class='subtext'>Enables the display of error messages, which are valuable during site development</div></td><td><select name="debug" id="debug">
    <option value="0" selected="selected">1: PHP/SQL error messages shown only to Super Admins</option>
    <option value="2">2: PHP/SQL error messages shown to anyone - NOT SECURE</option>
    </select></td>

    Notice that it’s set to 1 even though the value is 0 and if I set it to 2, the value is 2. When I set it to 2, it works, but it’s not secure obviously. When I set it to 1, it’s actually setting it to 0 which is why it doesn’t work. Erghh.

    I guess I will have to upgrade to the latest version of EE and hope that fixes it! Apparently Ellis Lab finally acknowledged this as a BUG and new versions do not even give you the option of 0. Anyway, hope this helps someone!

    http://ellislab.com/forums/viewthread/177632/

    https://support.ellislab.com/bugs/detail/14013/

  • #4 / Jul 03, 2012 5:42pm

    Jacob Graf

    163 posts

    Manually set debug to 1 in config file and everything works like a charm. I still don’t show debug = 1 option in the CP but I am guessing that was fixed in a recent version!

  • #5 / Jul 04, 2012 2:19pm

    Dan Decker

    7338 posts

    Hi Jacob,

    Indeed, I remember that oddity “way back when” 2.2 was current. It made absolutely no sense.

    However, it is corrected in 2.5.2. And as always, the settings in /system/expressionengine/config/config.php will always win over the Control Panel.

    Is there anything else I can assist you with?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases