Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Is their is any compiler for the java script syntax

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 week 3 days ago - 1 week 3 days ago #261050 by rajkumar_dms
Please help us help you and fill where relevant:
Your LimeSurvey version: [6.5]
Own server or LimeSurvey hosting:Clould
Survey theme/template:
==================
I would like the below compile the below syntax in lime survey, can i compile it 
<script type="text/javascript">
  $(document).on('ready pjax:scriptcomplete',function(){
function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array, array[j]] = [array[j], array];
    }
    return array;
}

// Example: Customizing rotation for a multiple choice question
$(document).ready(function() {
    // Identify the question by its ID or class
    var questionId = $('#question{QID}'); // Change to the appropriate ID or class

    // Get the answer choices container
    var answerChoicesContainer = $(questionId).find('.answer-choices');

    // Get the answer choices
    var answerChoices = answerChoicesContainer.children('.answer-item');

    // Array to store fixed elements
    var fixedElements = [2,4,6];

    // Loop through answer choices to find fixed elements
    answerChoices.each(function() {
        if ($(this).hasClass('fixed')) { // Assuming 'fixed' is a class added to fixed elements
            fixedElements.push($(this));
        }
    });

    // Remove fixed elements from the answer choices array
    fixedElements.forEach(function(element) {
        answerChoices = answerChoices.not(element);
    });

    // Shuffle the remaining answer choices
    var shuffledChoices = shuffleArray(answerChoices);

    // Insert fixed elements back into the shuffled choices array
    fixedElements.forEach(function(element) {
        shuffledChoices.splice(element.data('position'), 0, element); // Assuming 'position' is a data attribute indicating the fixed position
    });

    // Append the shuffled choices back to the container
    answerChoicesContainer.empty().append(shuffledChoices);
});
</script>
Last edit: 1 week 3 days ago by tpartner. Reason: Remove invalid credit

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 week 3 days ago #261055 by tpartner
Please remove my credit in that script. I did not author it.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • rajkumar_dms
  • rajkumar_dms's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 week 3 days ago #261061 by rajkumar_dms
Replied by rajkumar_dms on topic Is their is any compiler for the java script syntax
Sure i will removed your credit

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 week 3 days ago #261063 by tpartner
You didn't so I edited your post.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 week 3 days ago #261108 by holch
Not an expert, but since when does Javascript require a compiler? It just runs in the Browser.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 week 2 days ago - 1 week 2 days ago #261128 by DenisChenu

Not an expert, but since when does Javascript require a compiler? It just runs in the Browser.

 
On big file : minimize for quicker loading.

But here i think it's to try to hide the javascript : duckduckgo.com/?q=javascript+obfuscated+code

No real interest (and you find the deobfuscate tool on the same way …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 1 week 2 days ago by DenisChenu.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose