- Posts: 55
- Thank you received: 0
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
- Topic Author
- Offline
- Senior Member
Less
More
1 week 3 days ago - 1 week 3 days ago #261050
by rajkumar_dms
Is their is any compiler for the java script syntax was created 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>
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
1 week 3 days ago #261055
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Is their is any compiler for the java script syntax
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 55
- Thank you received: 0
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
1 week 3 days ago #261063
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Is their is any compiler for the java script syntax
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11681
- Thank you received: 2748
1 week 3 days ago #261108
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Is their is any compiler for the java script syntax
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13675
- Thank you received: 2496
1 week 2 days ago - 1 week 2 days ago #261128
by DenisChenu
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.
Replied by DenisChenu on topic Is their is any compiler for the java script syntax
On big file : minimize for quicker loading.Not an expert, but since when does Javascript require a compiler? It just runs in the Browser.
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.