diff --git a/css/qsm-admin.css b/css/qsm-admin.css
index d8b54ae8c..d26466f60 100644
--- a/css/qsm-admin.css
+++ b/css/qsm-admin.css
@@ -3383,4 +3383,11 @@ input#preferred-date-format-custom {
text-transform: none;
float: right;
}
+.qsm-hightlight-text{
+ color: #ffffff;
+ background: #187FFA;
+ padding: 1px 3px 4px 5px;
+ border-radius: 2px;
+ margin-right: 2px;
+}
/*TinyMCE Text-editor : end */
\ No newline at end of file
diff --git a/js/qsm-admin.js b/js/qsm-admin.js
index 056fb949c..70880fff5 100644
--- a/js/qsm-admin.js
+++ b/js/qsm-admin.js
@@ -411,27 +411,13 @@ var QSMAdmin;
// form_type (0, 1, 2).
function hide_show_quiz_options(form_type) {
if (0 == form_type) {
- $('#score_roundoff').parents('tr').show();
$('#correct_answer_logic').show();
} else {
- $('#score_roundoff').parents('tr').hide();
$('#correct_answer_logic').hide();
}
}
- $(document).on('click', '.qsm_tab_content input[name="system"]', function () {
- var value = $(this).val();
- $('#correct_answer_logic, #score_roundoff').hide();
- if (value == 0 || value == 3) {
- $('#correct_answer_logic, #score_roundoff').show();
- }
- });
$(document).ready(function () {
- var system_option = $("input[type=radio][name='system']:checked").val();
- $('#correct_answer_logic, #score_roundoff').hide();
- if (system_option == 0 || system_option == 3) {
- $('#correct_answer_logic, #score_roundoff').show();
- }
hide_show_quiz_options($("input[name='form_type']:checked").val());
if (jQuery('.qsm-date-picker').length) {
jQuery('.qsm-date-picker').datetimepicker({ format: 'm/d/Y H:i', step: 1});
@@ -608,20 +594,16 @@ var QSMAdmin;
$(document).on('change', '.qsm_page_qmn_global_settings input[name="qsm-quiz-settings[form_type]"]', function () {
if ( 0 == $(this).val() ) {
$('.global_setting_system').parents('tr').show();
- $('#qsm-score-roundoff').parents('label').show();
$("#qsm-correct-answer-logic").show();
} else {
$('.global_setting_system').parents('tr').hide();
- $('#qsm-score-roundoff').parents('label').hide();
$("#qsm-correct-answer-logic").hide();
}
});
$(document).on('change', '.global_setting_system input[name="qsm-quiz-settings[system]"]', function () {
if ( 1 != $(this).val() && 0 == $('.qsm_page_qmn_global_settings input[name="qsm-quiz-settings[form_type]"]:checked').val() ) {
- $('#qsm-score-roundoff').parents('label').show();
$("#qsm-correct-answer-logic").show();
} else {
- $('#qsm-score-roundoff').parents('label').hide();
$("#qsm-correct-answer-logic").hide();
}
});
@@ -756,7 +738,6 @@ var QSMAdmin;
container.removeClass('opened');
}
});
-
}(jQuery));
// result page
@@ -995,8 +976,11 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();}
}
}(jQuery));
-// QSM - Quiz Wizard
-
+function qsm_is_substring_in_array( text, array ) {
+ return array.some(function(item) {
+ return text.includes(item);
+ });
+}
(function ($) {
if (jQuery('body').hasClass('post-type-qsm_quiz') || jQuery('body').hasClass('toplevel_page_qsm_dashboard')) {
$('#create-quiz-button').on('click', function (event) {
@@ -1274,7 +1258,7 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();}
editor.execCommand('Delete');
}
//editor.insertContent( command.description );
- editor.execCommand('mceInsertContent', false, ''+ command.value.replace(/%/g, '') +' ' );
+ editor.execCommand('mceInsertContent', false, command.value.replace(/%([^%]+)%/g, '$1 ') );
autocomplete.remove();
editor.getContainer().setAttribute('qsm_search', '');
@@ -1313,6 +1297,20 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();}
//on keydowm inside editor
editor.on('keydown', function (e) {
+ if (e.keyCode === 13) {
+ let selection = editor.selection;
+ let range = selection.getRng();
+ let tagText = range.startContainer.parentNode.textContent;
+ if ( 'qsmvariabletag' === range.startContainer.parentNode.nodeName.toLowerCase() && range.startOffset === tagText.length ) {
+ let newParagraph = editor.dom.create('p');
+ editor.dom.insertAfter(newParagraph, range.startContainer.parentNode);
+ range.setStartAfter(newParagraph);
+ range.collapse(true);
+ selection.setRng(range);
+ e.preventDefault();
+ }
+ }
+
if (e.keyCode === 191 && e.ctrlKey === false && e.altKey === false && e.shiftKey === false) {
// "/" key pressed, trigger autocomplete
showAutocomplete( editor, true );
@@ -1345,61 +1343,15 @@ if(current_id == 'qsm_variable_text'){ jQuery(".current_variable")[0].click();}
});
- function sanitizeHtml(content) {
-
- // Match tags with src attributes
- content = content.replace(//gi, function(match, src) {
- src = ( 'undefined' === typeof src || null === src ) ? '': src.split('?')[0];
- // Check if the src URL is valid (ends with .jpg, .jpeg, .png, or .gif)
- if (src.match(/\.(jpg|jpeg|png|gif|webp)$/i)) {
- return match; // Valid src, keep the tag
- } else {
- return ''; // Invalid src, remove the tag
- }
+ editor.on('paste', function (event) {
+ let clipboardData = (event.originalEvent || event).clipboardData;
+ let pastedValue = clipboardData.getData('text');
+ var variables = commands.map(function(item) {
+ return item.value;
});
-
- // Remove style attribute
- content = content.replace(/style\s*=\s*(['"])(.*?)\1/gi, '');
-
- // Remove background attribute
- content = content.replace(/background\s*=\s*(['"])(.*?)\1/gi, '');
-
- // Remove 'javascript:' injection, alert, prompt, confirm
- content = content.replace(/javascript:/gi, '');
- content = content.replace(/alert\(/gi, '');
- content = content.replace(/prompt\(/gi, '');
- content = content.replace(/confirm\(/gi, '');
-
- // Remove unwanted HTML tags like script, svg, title, meta, input etc.
- content = content.replace(/