Appending twitter button - Limesurvey wreaking havoc on returned JS from Twitter

More
4 years 3 months ago #95206 by McdanielMackenzie
McdanielMackenzie created the topic: Appending twitter button - Limesurvey wreaking havoc on returned JS from Twitter
Hi. I'm hopeful someone has solved this problem already. I cannot find mention of how to do this.

Specifically, I am trying to add a "Follow" button for twitter to the end of a survey. The button is generated dynamically.

From Twitter, the code should be:
<a href="https://twitter.com/THINGTOFOLLOW" class="twitter-follow-button" data-show-count="false">Follow @THINGTOFOLLOW</a>
 
<script>
    ! function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0],
            p = /^http:/.test(d.location) ? 'http' : 'https';
        if (!d.getElementById(id)) {
            js = d.createElement(s);
            js.id = id;
            js.src = p + '://platform.twitter.com/widgets.js';
            fjs.parentNode.insertBefore(js, fjs);
        }
    }(document, 'script', 'twitter-wjs');
</script>

And this is what is stored in the database table surveys_languagesettings.

That said, rendering of the image does not appear. Rather, the script gets altered as follows:
 <a href="https://twitter.com/THINGTOFOLLOW" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @THINGTOFOLLOW</a>
 
<script>
    ! function (d, s, id) < span style = 'background-color: #eee8aa;' > < span title = 'Undefined variable'
    style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined variable'
    style = 'color: red; font-weight: bold' >
    var < /span></span > < span title = ''
    style = 'color: red; font-weight: bold' > js < /span>, <span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>fjs</span > < /span><span title='Assigning a new value to a variable' style='color: red; font-weight: bold'>=</span > < span title = 'Undefined function'
    style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined function'
    style = 'color: blue; font-weight: bold' > d.getElementsByTagName < /span></span > ( < span title = 'Undefined variable'
    style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined variable'
    style = 'color: red; font-weight: bold' > s < /span></span > ) < span title = 'Unsupported syntax'
    style = 'border-style: solid; border-width: 2px; border-color: red;' > [ < /span>1<span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> ] </span > , < span title = 'Undefined variable'
        style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined variable'
        style = 'color: red; font-weight: bold' > p < /span></span > < span title = 'Assigning a new value to a variable'
        style = 'color: red; font-weight: bold' >= < /span> / < span title = 'Unsupported syntax'
        style = 'border-style: solid; border-width: 2px; border-color: red;' > ^ < /span><span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>http</span > < /span><span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> : </span > / <span title='Undefined function' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined function' style='color: blue; font-weight: bold'>.test</span > < /span>(<span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>d.location</span > < /span>)<span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> ? </span > < span title = ''
        style = 'color: gray' > 'http' < /span><span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> : </span > < span title = ''
        style = 'color: gray' > 'https' < /span><span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> ; </span > < span title = 'Conditional processing; if(test,result_if_true,result_if_false)'
        style = 'color: blue; font-weight: bold' >
        if </span>( ! <span title='Undefined function' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined function' style='color: blue; font-weight: bold'>d.getElementById</span > < /span>(<span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>id</span > < /span>))<span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> { </span > < span title = 'Undefined variable'
        style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined variable'
        style = 'color: red; font-weight: bold' > js < /span></span > < span title = 'Assigning a new value to a variable'
        style = 'color: red; font-weight: bold' >= < /span><span title='Undefined function' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined function' style='color: blue; font-weight: bold'>d.createElement</span > < /span>(<span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>s</span > < /span>)<span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> ; </span > < span title = 'Undefined variable'
        style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined variable'
        style = 'color: red; font-weight: bold' > js.id < /span></span > < span title = 'Assigning a new value to a variable'
        style = 'color: red; font-weight: bold' >= < /span><span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>id</span > < /span><span title='Unsupported syntax' style='border-style: solid; border-width: 2px; border-color: red;'> ; </span > < span title = 'Undefined variable'
        style = 'border-style: solid; border-width: 2px; border-color: red;' > < span title = 'Undefined variable'
        style = 'color: red; font-weight: bold' > js.src < /span></span > < span title = 'Assigning a new value to a variable'
        style = 'color: red; font-weight: bold' >= < /span><span title='Undefined variable' style='border-style: solid; border-width: 2px; border-color: red;'><span title='Undefined variable' style='color: red; font-weight: bold'>p</span > < /span> + <span title='' style='color: gray'>':/ / platform.twitter.com / widgets.js '</span><span title='
        Unsupported syntax ' style='
        border - style: solid; border - width: 2px; border - color: red;
        '> ; </span><span title='
        Undefined
        function ' style='
        border - style: solid; border - width: 2px; border - color: red;
        '><span title='
        Undefined
        function ' style='
        color: blue; font - weight: bold '>fjs.parentNode.insertBefore</span></span>(<span title='
        Undefined variable ' style='
        border - style: solid; border - width: 2px; border - color: red;
        '><span title='
        Undefined variable ' style='
        color: red; font - weight: bold '>js</span></span>, <span title='
        Undefined variable ' style='
        border - style: solid; border - width: 2px; border - color: red;
        '><span title='
        Undefined variable ' style='
        color: red; font - weight: bold '>fjs</span></span>)<span title='
        Unsupported syntax ' style='
        border - style: solid; border - width: 2px; border - color: red;
        '> ; </span><span title='
        Unsupported syntax ' style='
        border - style: solid; border - width: 2px; border - color: red;
        '> } </span></span>(document, '
        script ', '
        twitter - wjs ');
</script>

Obviously something is awry.

As information, the prescribed script / code work just fine in a self-standing "test.html" file so I've come to the conclusion that it must be related to LimeSurvey and the code that is returned - perhaps related to how content in "{{ }}" is parsed.

Any help or suggestions?

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now