const STEP_FINISHED = 1000; function Wizard() { this.error_message = ""; this.autoinfo_mode = false; this.autoshow_mode = false; this.save_validating = false; this.steps_containers_array = []; this.first_unfilled_control = null; } Wizard.prototype.AddSelectOptions = function(select_control, option_text, option_value) { var option = document.createElement("option"); option.text = option_text; option.value = option_value; $(select_control)[0].appendChild(option); } Wizard.prototype.DoShowContainer = function(step) { $("#" + step).changeVisibility(this.IsStepVisible(step)) } Wizard.prototype.DoHideContainer = function(step) { if (this.autoshow_mode) $("#" + step).hide(); else $("#" + step).changeVisibility(this.IsStepVisible(step)); } Wizard.prototype.GetErrorClass = function () { return 'error-control-value'; } Wizard.prototype.ChangeControlBackgroundColor = function(is_filled, element_control, visual_control) { if (!visual_control) visual_control = element_control; if (!$(element_control).hasClass('skip-background')) { $(visual_control).removeClass("error-control-value"); $(visual_control).removeClass("filled-control-value"); $(visual_control).removeClass("unknown-control-value"); if (is_filled) $(visual_control).addClass('filled-control-value'); else { if ((this.save_validating) && (this.IsElementMustBeFilled(element_control))) { if (!$(element_control).hasClass("can-be-empty")) { $(visual_control).addClass(this.GetErrorClass()); } } else $(visual_control).addClass('unknown-control-value'); } } } Wizard.prototype.IsRadioBoxLabelElementFilled = function(element) { var result = null; var parent = $(element).parent(); $(parent).children().each(function(index, child) { if (IsRadioBox(child)) { result = IsRadioBoxFilled(child); return; } }); return result; } Wizard.prototype.ElementCanBeSaved = function(element) { var result = true; if (this.IsElementMustBeFilled(element)) { result = this.IsElementFilled(element); result = result || ($(element).hasClass("can-be-empty")); } return result; } Wizard.prototype.IsElementFilled = function(element) { var result = true; if (IsButtonGroup(element)) { result &= IsButtonGroupSelected(element); } if (element.tagName.toLowerCase() == "select") { result &= (IsSelectBoxFilled(element)); } if (element.tagName.toLowerCase() == "textarea") { result &= IsTextBoxFilled(element); } if (element.tagName.toLowerCase() == "input") { result &= IsInputFilled(element); } if ($(element).hasClass("file-upload-container")) result = this.IsFileContainerFilled(element); /* if ($(element).hasClass("can-be-empty")) result = true; */ return result; } Wizard.prototype.ValidateElement = function(element) { var result = this.IsElementFilled(element); if ((this.save_validating) && (!this.ElementCanBeSaved(element))) { result = false; } return result; } Wizard.prototype.ChangeInputControlStyle = function() { var object = this; $("#ServiceForm select, #ServiceForm textarea, #ServiceForm input[type=text], #ServiceForm input[type=number], #ServiceForm input[type=tel], #ServiceForm input[type=date], #ServiceForm input[type=email]").each(function() { object.ChangeControlBackgroundColor(object.ValidateElement(this), this); }); $("#ServiceForm .btn-group-member").each(function() { object.ChangeControlBackgroundColor(object.ValidateElement($(this).parent()[0]), this); }); $("#ServiceForm .file-upload-container").each(function() { object.ChangeControlBackgroundColor(object.ValidateElement(this), this, $(this).find(".file-add")); }); $("#ServiceForm span.radio-label").each(function() { object.ChangeControlBackgroundColor(object.IsRadioBoxLabelElementFilled(this), this); }); } Wizard.prototype.IsStepVisible = function(step) { var result = true; return result; } Wizard.prototype.IsSaveAvailable = function() { var current_step = this.GetCurrentStepIndex(); return (current_step == STEP_FINISHED); } Wizard.prototype.IsElementMustBeFilled = function(element) { return true; } Wizard.prototype.IsFileContainerFilled = function(element) { return this.HasAttachedFiles(element); } Wizard.prototype.IsVirtualContainer = function(element) { return ($(element).hasClass("virtual-container")); } Wizard.prototype.EnumerateStepElementsParent = function(step, element, check_parent) { var result = true; var object = this; var is_virtual_container = false; if (check_parent) is_virtual_container = this.IsVirtualContainer(element); var is_protype = ($(element).hasClass("prototype")); if (!is_protype) { // enumerate all nesting divs of given step $(element).children().each(function (child_div_index, child_div) { var is_hidden = $(child_div).hasClass("hidden-container"); var is_child_virtual_container = object.IsVirtualContainer(child_div); if (!is_hidden) { if (is_virtual_container) { result &= object.EnumerateStepElementsParent(step, child_div, true); } else if (is_child_virtual_container) { result &= object.EnumerateStepElementsParent(step, child_div, false); } else { result &= object.EnumerateStepElements(step, child_div); } if (!result) return; } }); } return result; } Wizard.prototype.EnumerateStepElements = function(step, element) { var result = true; if (!$(element).hasClass("skip-enumeration")) { var object = this; $(element).children().each(function (index, child) { var is_virtual_container = object.IsVirtualContainer(child); if (is_virtual_container) result = result && (object.EnumerateStepElements(step, child)); else { var dom_element = $(child).get(0); result = result && (object.ElementCanBeSaved(dom_element)); if (!result) { if (object.first_unfilled_control == null) object.first_unfilled_control = dom_element; return; } } }); } return result; } Wizard.prototype.IsStepFilled = function(step) { if (this.IsStepVisible(step)) { var children_containers_selector = "#" + step; return this.EnumerateStepElementsParent(step, children_containers_selector, true); } return true; } Wizard.prototype.AnalyzeCondition = function(condition, error_message) { if (!condition) this.error_message = error_message; return condition; } Wizard.prototype.GetCurrentStepIndex = function() { this.error_message = ""; this.first_unfilled_control = null; for (var i = 0; i < this.steps_containers_array.length; i++) { // console.log(this.steps_containers_array[i] + ": " + this.IsStepFilled(this.steps_containers_array[i])); if (!this.IsStepFilled(this.steps_containers_array[i])) return i; } return STEP_FINISHED; } Wizard.prototype.InitializeInterface = function() { var current_step = this.GetCurrentStepIndex(); var is_save_visible = (current_step == STEP_FINISHED); this.save_validating = false; this.ChangeInputControlStyle(); if (this.autoshow_mode) $(".save_form").changeVisibility(is_save_visible); if (is_save_visible) { if (this.autoinfo_mode) { this.SendProfileToServerInternal(false, true); } } else { $("#ajax_results").html(''); } for (var i = 0; i < this.steps_containers_array.length; i++) { if (i <= current_step) { this.DoShowContainer(this.steps_containers_array[i]); } else { this.DoHideContainer(this.steps_containers_array[i]); } } } Wizard.prototype.AddSerializedValue = function(result, value) { if ((result != "") && (value != "")) { result += "&"; } result += value; return result; } Wizard.prototype.CreateFileObjectInfoFromFileElement = function(file_element) { var result = null; var file_name = $(file_element).find(".file-container-name").val(); if (file_name != "") { result = {"name": file_name, "original_name": file_name}; result.id = $(file_element).find(".file-container-id").val(); result.url = $(file_element).find(".file-container-url").val(); result.size = $(file_element).find(".file-container-size").val(); result.data = $(file_element).find(".file-container-data").val(); result.type = $(file_element).find(".file-container-type").val(); result.js_id = $(file_element).find(".file-container-id").attr("data-js-id"); } return result; } Wizard.prototype.GetFilesListForSelectorArray = function(selectors_array) { var result = []; for (var i = 0; i < selectors_array.length; i++) { var items_list = $(selectors_array[i]); for (var j = 0; j < items_list.length; j++) { var file_data_items = $(items_list.get(j)).find(".file-container-file-data"); for (var z = 0; z < file_data_items.children().length; z++) { var object_info = this.CreateFileObjectInfoFromFileElement(file_data_items.children().get(z)); if (Assigned(object_info)) { result.push(object_info); } } } } return result; } Wizard.prototype.SerializeFilesList = function(selectors_array) { if (selectors_array.length > 0) { var files = {}; files.files = this.GetFilesListForSelectorArray(selectors_array); if (files.files.length > 0) return $.param(files); } return ""; } Wizard.prototype.SerializeAdditionalFields = function() { var result = ""; return result; } Wizard.prototype.CheckSaveAvailability = function() { var object = this; this.save_validating = true; this.ChangeInputControlStyle(); var result = this.IsSaveAvailable(); if (this.first_unfilled_control != null) { var parent = $(this.first_unfilled_control).parent(); while (this.IsVirtualContainer(parent)) parent = $(parent).parent(); // console.log(this.first_unfilled_control); $(parent)[0].scrollIntoView({ behavior: 'smooth'}); setTimeout(function () { if (Assigned(object.error_message)) alert(object.error_message); }, 500); } return result; } Wizard.prototype.ChangeInputsEnabledState = function(is_disabled) { $(".prototype-item").attr("disabled", is_disabled); } Wizard.prototype.SendProfileToServer = function(save_data) { if (this.CheckSaveAvailability()) this.SaveProfile(save_data); else console.log(this.first_unfilled_control); } Wizard.prototype.SaveProfile = function(save_data) { this.SendProfileToServerInternal(save_data, true); } Wizard.prototype.SubmitForm = function() { this.SendProfileToServer(true); } Wizard.prototype.shouldLoadPropertyFromJSON = function(json, propertyName) { return true; } Wizard.prototype.SetControlValueFromJSON = function(propertyName, propertyValue) { var jquery_name = "#" + propertyName; if (IsCheckBox(jquery_name)) { if ((propertyValue == "true") || ((propertyValue == "1"))) $(jquery_name).attr('checked', 'checked'); else $(jquery_name).removeAttr('checked'); } else if (IsButtonGroup(jquery_name + "_group")) { SetButtonGroupValue(jquery_name + "_group", propertyValue); } else if (IsInputBox(jquery_name)) $(jquery_name).val(propertyValue); else if (IsSelectBox(jquery_name)) SetSelectBoxValue(jquery_name, propertyValue); else if (IsAnchor(jquery_name)) $(jquery_name).attr("href", propertyValue); else if (IsImage(jquery_name)) $(jquery_name).attr("src", propertyValue); else if (IsTextArea(jquery_name)) $(jquery_name).val(propertyValue); } Wizard.prototype.LoadControlsFromJSON = function(json) { for (var propertyName in json) { if (this.shouldLoadPropertyFromJSON(json, propertyName)) this.SetControlValueFromJSON(propertyName, json[propertyName]); } this.LoadFilesFromJSON(json); } Wizard.prototype.LoadControlsFromJSONContent = function(json_content) { if (json_content) { var json = JSON.parse(json_content); this.LoadControlsFromJSON(json); } } Wizard.prototype.LoadParameters = function() { this.autoshow_mode = (ReadCurrentURLParam("auto_show") == "1"); this.autoinfo_mode = false; } Wizard.prototype.InitializeInternalObjects = function() { this.InitializeDragAndDropObjects(); } Wizard.prototype.UpdateCallBackURL = function() { call_back_url = $("#calback-url").attr("href"); if ((call_back_url) && (call_back_url != "")) { // $("#calback-url").show(); $(".logo").attr("href", call_back_url); } } Wizard.prototype.OnBtnGroupChange = function(btn_group, is_active, data_object) { data_object.InitializeInterface(); } Wizard.prototype.PrepareForm = function() { // do nothing in base class AddButtonGroupEventListenerForAll(this.OnBtnGroupChange, this); } Wizard.prototype.DoOnLoading = function() { // do nothing in base class } Wizard.prototype.AnalyzeSendDataAvailability = function(save_data) { if (save_data) { var is_blocked_profile = $("#inputBlockProfile").prop('checked'); if (is_blocked_profile) { alert("Entsperren Sie den Fragebogen, bevor Sie ihn speichern"); } return (!is_blocked_profile); } return true; } Wizard.prototype.SaveObjectsIDFromSaveJSON = function(json) { var items_array = json["saved_items"]; if (items_array) { for (var i = 0; i < items_array.length; i++) { var item_id_info = items_array[i]; if (item_id_info.js_id) { var item = $('[data-js-id=' + item_id_info.js_id + ']'); if (item.length > 0) $(item[0]).val(item_id_info.id); } } } } Wizard.prototype.DoOnSuccessSaving = function(json_answer, show_success_message) { // update service id if (json_answer.id) $("#service_id").val(json_answer.id); this.SaveObjectsIDFromSaveJSON(json_answer); this.InitializeInterface(); if (show_success_message) alert("Gespeicherte Daten"); } Wizard.prototype.onSubmitFormToServerAjax = function(json_answer, save_data, show_success_message, success_callback) { if (save_data == true) { this.DoOnSuccessSaving(json_answer, show_success_message); if (success_callback) success_callback(json_answer); } } Wizard.prototype.SubmitFormToServerAjax = function(post_url, request_method, form_data, save_data, show_success_message, success_callback) { var object = this; $.ajax({ url: post_url, type: request_method, data: form_data }).done(function(response) { var json_answer = JSON.parse(response); if (json_answer.status == "error") alert(json_answer.error_desc); else object.onSubmitFormToServerAjax(json_answer, save_data, show_success_message, success_callback); }); } Wizard.prototype.shouldAddLanguageToProfile = function() { return true; } Wizard.prototype.SendProfileToServerInternal = function(save_data, show_success_message, success_callback) { // prototype items // console.log('SendProfileToServerInternal'); if (this.AnalyzeSendDataAvailability(save_data)) { // AddStackTrace(); var object = this; var form = $("#ServiceForm"); var additional_data_fields = this.SerializeAdditionalFields(); this.ChangeInputsEnabledState(true); var post_url = form.attr("action"); var request_method = form.attr("method"); var form_data = form.serialize(); if (additional_data_fields != "") form_data += "&" + additional_data_fields; if (this.shouldAddLanguageToProfile()) form_data += "&lang=de"; if (save_data) { form_data += "&save_info=1"; } this.ChangeInputsEnabledState(false); // console.log("Is ajax Submiting: " + this.IsAjaxSubmitting()); if (this.IsAjaxSubmitting()) this.SubmitFormToServerAjax(post_url, request_method, form_data, save_data, show_success_message, success_callback); else SubmitSerializedDataToServer(post_url, request_method, form_data); } } Wizard.prototype.IsAjaxSubmitting = function() { return true; } Wizard.prototype.ProcessDragEvent = function(event) { if (this.IsSupportedDragTarget(event)) { event.preventDefault(); event.stopPropagation(); return true; } return false; } Wizard.prototype.IsSupportedDragTarget = function(event) { return (Assigned(this.ExtractDraggedTarget(event))); } Wizard.prototype.InitializeDragAndDropObjects = function() { var object = this; $(document).on('drag dragstart', function(e) { object.ProcessDragEvent(e); }); $(document).on('dragover dragenter', function(e) { if (object.ProcessDragEvent(e)) { object.InitializeInterface(); $(object.ExtractDraggedTarget(e)).addClass('is-dragover'); } }); $(document).on('dragleave dragend', function(e) { if (object.ProcessDragEvent(e)) { object.InitializeInterface(); $(object.ExtractDraggedTarget(e)).removeClass('is-dragover'); } }); $(document).on('drop', function(e) { if (object.ProcessDragEvent(e)) { $(object.ExtractDraggedTarget(e)).removeClass('is-dragover'); var droppedFiles = e.originalEvent.dataTransfer.files; for (let i = 0; i < droppedFiles.length; i++) object.UploadDraggedFile(object.ExtractDraggedTarget(e), droppedFiles[i]); } }); } Wizard.prototype.GenerateFileDisplayNameByParams = function(file_info) { prefix = "Bytes" file_size_str = file_info.size; if (file_size_str > 1024) { file_size_str = (file_size_str / 1024).toFixed(2); prefix = "KB"; } if (file_size_str > 1024) { file_size_str = (file_size_str / 1024).toFixed(2); prefix = "MB"; } var display_file_name = file_info.name; if (file_info.url != "") display_file_name = "" + display_file_name + ""; return display_file_name + ", " + file_size_str + " " + prefix; } Wizard.prototype.GetAttachedFileNameForElement = function(element, file) { return file.name; } Wizard.prototype.UpdateFileInterface = function(element) { if (!$(element).hasClass("allow-multi-files")) $(element).find(".file-drag-container").changeVisibility(!this.HasAttachedFiles(element)); this.InitializeInterface(); } Wizard.prototype.AddNewFileElement = function(element, file_info, is_hidden) { is_hidden = (!is_hidden) ? false : is_hidden; // get prototype html let prototype_html = $(element).find('.file-container-file-data-prototype').html(); var is_hidden_html = is_hidden ? "display: none" : ""; var file_html = "
"; $(element).find(".file-container-file-data").append(file_html); // create new item with file this.UpdateFileInterface(element); var result = $(element).find(".file-container-file-data").children().last(); file_info = (!file_info) ? {} : file_info; this.InitializeFileStructureInternal(result, file_info); this.UpdateFileInterface(element); return result; } Wizard.prototype.SearchFileElementByFileType = function(file_type_id) { let result = $(".file-container-type[value='" + file_type_id + "']"); if (result.length > 0) return this.SearchFileContainerByNestingElement(result); return null; } Wizard.prototype.LoadFilesFromJSON = function(json) { if (json["files"]) { var files_array = json["files"]; for (var i = 0; i < files_array.length; i++) { let file_info = files_array[i]; let file_element = this.SearchFileElementByFileType(file_info.type); if (Assigned(file_element)) this.AddNewFileElement(file_element, file_info); } } } Wizard.prototype.InitializeFileStructureInternal = function(file_element, file_info) { this.InitializeFileStructure(file_element, file_info); $(file_element).find(".file-container-file-info").show(); $(file_element).find(".file-container-file-name").html(this.GenerateFileDisplayNameByParams(file_info)); $(file_element).find(".file-container-file-url").attr("href", file_info.url); } Wizard.prototype.InitializeFileStructure = function(file_element, file_info) { file_info.type = $(file_element).find(".file-container-type").val(); if (!file_info.original_name) file_info.original_name = file_info.name; $(file_element).find(".file-container-name").val(file_info.name); $(file_element).find(".file-container-url").val(file_info.url); $(file_element).find(".file-container-size").val(file_info.size); $(file_element).find(".file-container-id").attr("data-js-id", CreateUniqueString()); // set file id (if assigned) if (file_info.id) $(file_element).find(".file-container-id").val(file_info.id); // set file data (if assigned) if (file_info.data) $(file_element).find(".file-container-data").val(file_info.data); } Wizard.prototype.AddFileDataToFileElementInternal = async function(file_element, file) { let object = this; return new Promise((fulfilled, reject) => { object.AddFileDataToFileElement(file_element, file, fulfilled, reject); }); } Wizard.prototype.AddFileDataToFileElement = async function(file_element, file, fulfilled, reject) { reader = new FileReader(); reader.onload = function(event) { $(file_element).find(".file-container-data").val(event.target.result); fulfilled(file_element, file); } reader.readAsDataURL(file); } Wizard.prototype.FileNameCanBeProcessed = function(file_name) { return true; } Wizard.prototype.AddFileFromDrive = function(element, file) { if (file) { var object = this; if (this.FileNameCanBeProcessed(file.name)) { var file_info = {"name": this.GetAttachedFileNameForElement(element, file), "original_name": file.name, "url": "", "size": file.size}; this.StartFileUploadingAnimation(element); let file_element = this.AddNewFileElement(element, file_info, true); this.AddFileDataToFileElementInternal(file_element, file).then(function(file_element, file) { object.StopFileUploadingAnimation(file_element); $(file_element).show(); }, function(file_element, file) { alert("Unbekannter Fehler beim Hinzufügen einer Datei"); object.StopFileUploadingAnimation(file_element); object.DeleteAttachedFileClick(file_element); }); } } } Wizard.prototype.DeleteAttachedFile = function(element, index) { if ($(element).find(".file-container-file-data").children().length > index) { $(element).find(".file-container-file-data").children().eq(index).remove(); this.UpdateFileInterface(element); } } Wizard.prototype.IsFileElementUploading = function(element) { var file_container = this.SearchFileContainerByNestingElement(element); return $(file_container).find(".file-drag-box-loading-animation-container").is(":visible"); } Wizard.prototype.HasAttachedFiles = function(element) { var result = ($(element).find(".file-container-file-data").children().length > 0); result = result && (!this.IsFileElementUploading(element)); return result; } Wizard.prototype.ExtractDraggedTarget = function(event) { return SearchParentElementByNestingElement(event.target, 'file-drag-box'); } Wizard.prototype.SearchFileContainerByNestingElement = function(element) { return SearchParentElementByNestingElement(element, "file-upload-container"); } Wizard.prototype.SearchFileByNestingElement = function(element) { return SearchParentElementByNestingElement(element, "file-container-file"); } Wizard.prototype.UploadDraggedFile = function(target, file) { this.AddFileFromDrive($(target).parent(), file); } Wizard.prototype.SelectAttachedFile = function(element) { let file_upload = $(element).find(".file-container-upload").get(0); if (file_upload) { for (let i = 0; i < file_upload.files.length; i++) { var file = file_upload.files[i]; this.AddFileFromDrive(element, file); } file_upload.value = ""; } } Wizard.prototype.AttachFileClick = function(target) { this.SelectAttachedFile($(target).parent()); } Wizard.prototype.AddAttachedFileClick = function(target) { var label = SearchParentElementByNestingElement(target, "file-drag-box-label"); // temporary remove "for" attribute of label var label_for_attrubute = $(label).attr("for"); $(label).attr("for", ""); var file_container = this.SearchFileContainerByNestingElement(target); this.AddNewFileElement(file_container); setInterval(function() { $(label).attr("for", label_for_attrubute); }, 50); } Wizard.prototype.ChangeFileUploadingAnimation = function(file_container, is_animation_visible) { file_container = this.SearchFileContainerByNestingElement(file_container); $(file_container).find(".file-drag-box-drop-container").changeVisibility(!is_animation_visible); $(file_container).find(".file-drag-box-loading-animation-container").changeVisibility(is_animation_visible); this.UpdateFileInterface(file_container); } Wizard.prototype.StartFileUploadingAnimation = function(file_container) { this.ChangeFileUploadingAnimation(file_container, true); } Wizard.prototype.StopFileUploadingAnimation = function(file_container) { this.ChangeFileUploadingAnimation(file_container, false); } Wizard.prototype.DeleteAttachedFileClick = function(target) { var removed_file = this.SearchFileByNestingElement(target); var removed_file_container = this.SearchFileContainerByNestingElement(removed_file); this.DeleteAttachedFile(removed_file_container, removed_file.index()); } Wizard.prototype.CopyTextToClipboard = function(element_selector) { if (element_selector) { var textArea = document.createElement("textarea"); textArea.style.position = 'fixed'; textArea.style.top = 0; textArea.style.left = 0; textArea.style.width = '2em'; textArea.style.height = '2em'; textArea.style.padding = 0; textArea.style.border = 'none'; textArea.style.outline = 'none'; textArea.style.boxShadow = 'none'; textArea.style.background = 'transparent'; textArea.value = $(element_selector).val(); document.body.appendChild(textArea); $(textArea).focus(); $(textArea).select(); document.execCommand('copy'); document.body.removeChild(textArea); } } Wizard.prototype.GetServiceID = function() { var result = $("#service_id").val(); if (result == "") result = -1; return result; } Wizard.prototype.IsModifing = function() { return (this.GetServiceID() > 0); } Wizard.prototype.Initialize = function(json_content) { this.LoadParameters(); this.InitializeInternalObjects(); this.PrepareForm(); this.LoadControlsFromJSONContent(json_content); this.InitializeInterface(); } Wizard.prototype.CreatePrototypeManager = function(parent_container, prototype_container, remove_button, add_button, auto_add_item, useActualVersion) { var object = this; var on_change = function (sender){ object.InitializeInterface(); }; var result = new PrototypeManager(parent_container, prototype_container, remove_button, add_button, useActualVersion); if (auto_add_item) result.AddItem(); result.OnAdd(on_change); result.OnRemove(on_change); return result; } Wizard.prototype.SerializePrototypeManagerToArray = function(prototype_manager, fill_object_info_callback) { var result = []; if (prototype_manager) { // console.log(prototype_manager.items_list.length); for (var i = 0; i < prototype_manager.items_list.length; i++) { var object_info = {}; let item = prototype_manager.items_list[i]; if (fill_object_info_callback) fill_object_info_callback(item, object_info); // result[i] = object_info; result.push(object_info); } } return result; } Wizard.prototype.SerializePrototypeManager = function(prototype_manager, param_name, fill_object_info_callback) { if ((param_name) && (prototype_manager)) { var items = {}; items[param_name] = []; for (i = 0; i < prototype_manager.items_list.length; i++) { var object_info = {}; let item = prototype_manager.items_list[i]; if (fill_object_info_callback) fill_object_info_callback(item, object_info); items[param_name][i] = object_info; } if (items[param_name].length > 0) return $.param(items); } return ""; } Wizard.prototype.Finalize = function() { // do nothing in base class } Wizard.prototype.LoadPrototypeManagerFromJSON = function(json, prototype_manager, json_name, load_object_info_callback, auto_add_item_on_empty) { if ((json) && (json_name) && (json[json_name])) { return this.LoadPrototypeManagerFromArray(json[json_name], prototype_manager, load_object_info_callback, auto_add_item_on_empty); } return 0; } Wizard.prototype.LoadPrototypeManagerFromArray = function(array, prototype_manager, load_object_info_callback, auto_add_item_on_empty) { let result = 0; if ((array) && (prototype_manager)) { let item = null; auto_add_item_on_empty = (typeof(auto_add_item_on_empty) === "undefined") ? true : auto_add_item_on_empty; for (let i = 0; i < array.length; i++) { item = prototype_manager.AddItem(); if (load_object_info_callback) load_object_info_callback(item, array[i]); result++; } if ((item == null) && (auto_add_item_on_empty)) item = prototype_manager.AddItem(); } return result; } Wizard.prototype.setSelectBoxValueByMaximumValue = function(selectBox, maxValue, selectLastIfNotFound) { var wasFound = false; var optionValue = ""; selectLastIfNotFound = (typeof(selectLastIfNotFound) === "undefined") ? true : selectLastIfNotFound; $(selectBox).find("option").each(function() { optionValue = $(this).val(); if (optionValue >= maxValue) { wasFound = true; SetSelectBoxValue(selectBox, optionValue); return false; } }); if ((!wasFound) && (selectLastIfNotFound)) SetSelectBoxValue(selectBox, optionValue); }