const LANGUAGE_TEST_NO_LANG = 'no_language'; const LANGUAGE_TEST_COMMON_NAME = 'no_tests'; const ENGLISH_TEST_IELTS_NAME = 'pass_ielts'; const ENGLISH_TEST_CELPIP_NAME = 'pass_celpip'; const ENGLISH_TEST_PTE_NAME = 'pass_pte'; const FRENCH_TEST_TEF_NAME = 'pass_tef'; const FRENCH_TEST_TCF_NAME = 'pass_tcf'; const LANGUAGES_ITEMS_LIST = ["english", "french"]; const ENGLISH_TEST_IELTS_CLB_ANALOG_VALUES = { clb4: [3.5, 4.0, 4.5, 4.0], clb5: [4.0, 5.0, 5.0, 5.0], clb6: [5.0, 5.5, 5.5, 5.5], clb7: [6.0, 6.0, 6.0, 6.0], clb8: [6.5, 6.5, 7.5, 6.5], clb9: [7.0, 7.0, 8.0, 7.0], clb10: [8.0, 7.5, 8.5, 7.5] }; const ENGLISH_TEST_CELPIP_CLB_ANALOG_VALUES = { clb4: [4, 4, 4, 4], clb5: [5, 5, 5, 5], clb6: [6, 6, 6, 6], clb7: [7, 7, 7, 7], clb8: [8, 8, 8, 8], clb9: [9, 9, 9, 9], clb10: [10, 10, 10, 10] }; const ENGLISH_TEST_PTE_CLB_ANALOG_VALUES = { clb3: [24, 32, 18, 34], clb4: [33, 41, 28, 42], clb5: [42, 51, 39, 51], clb6: [51, 60, 50, 59], clb7: [60, 69, 60, 68], clb8: [69, 79, 71, 76], clb9: [78, 88, 82, 84], clb10: [88, 90, 89, 89] }; const FRENCH_TEST_TEF_CLB_ANALOG_VALUES = { clb4: [121, 181, 145, 181], clb5: [151, 226, 181, 226], clb6: [181, 271, 217, 271], clb7: [207, 310, 249, 310], clb8: [233, 349, 280, 349], clb9: [248, 371, 298, 371], clb10: [263, 393, 316, 393] }; const FRENCH_TEST_TCF_CLB_ANALOG_VALUES = { clb4: [342, 4, 331, 4], clb5: [375, 6, 369, 6], clb6: [406, 7, 398, 7], clb7: [453, 10, 458, 10], clb8: [499, 12, 503, 12], clb9: [524, 14, 523, 14], clb10: [549, 16, 549, 16] }; const LANGUAGE_CEFR_CLB_ANALOG_VALUES = { clb4: "A2", clb5: "B1", clb7: "B2", clb9: "C1", clb12: "C2" }; const ENGLISH_TEST_IELTS_RANGE_VALUES = { minValue: 0, maxValue: 9, step: 0.5 }; const ENGLISH_TEST_CELPIP_RANGE_VALUES = { minValue: 0, maxValue: 12, step: 1 }; const ENGLISH_TEST_PTE_RANGE_VALUES = { minValue: 0, maxValue: 90, step: 1 }; const FRENCH_TEST_TEF_RANGE_VALUES = { minValue: 0, maxValue: 415, step: 1 }; const FRENCH_TEST_TCF_RANGE_VALUES = { minValue: 0, maxValue: 699, step: 1 }; function WizardScore() { Wizard.call(this); this.ajax_structure = {}; this.nocs_manager = null; this.nocs_manager_spouse = null; this.job_offer_nocs_manager = null; this.job_offer_nocs_manager_spouse = null; // generate steps array this.steps_containers_array = this.GetStepContainersArray(); this.steps_containers_array = this.steps_containers_array.concat("user_contact_info", "user_terms_data_accuracy"); } WizardScore.prototype = Object.create(Wizard.prototype); WizardScore.prototype.constructor = WizardScore; WizardScore.prototype.SerializeAdditionalFields = function() { var result = Wizard.prototype.SerializeAdditionalFields.call(this); result = this.AddSerializedValue(result, this.serializeNocsFields(this.nocs_manager, "user_jobs")); result = this.AddSerializedValue(result, this.serializeNocsFields(this.nocs_manager_spouse, "user_jobs_spouse")); result = this.AddSerializedValue(result, this.serializeJobOfferFields(this.job_offer_nocs_manager)); result = this.AddSerializedValue(result, this.serializeJobOfferFields(this.job_offer_nocs_manager_spouse)); return result; } WizardScore.prototype.fillUserAgeControl = function(select_box_id) { var user_age_select = $("#" + select_box_id); if (user_age_select.length > 0) { const MIN_USER_AGE_NUMBER = 18; const MAX_USER_AGE_NUMBER = 100; this.AddSelectOptions(user_age_select, "少于 {0} 年".format(18), 17); for (var i = MIN_USER_AGE_NUMBER; i <= MAX_USER_AGE_NUMBER; i++) { this.AddSelectOptions(user_age_select, AgeToString(i), i); } } } WizardScore.prototype.GetStepContainersArray = function() { return []; } WizardScore.prototype.createNocManagers = function(isSpouse) { var object = this; result = new NocsManager(isSpouse); result.AddItem(); result.OnChangeNocs(function(sender) { object.InitializeInterface(); }); return result; } WizardScore.prototype.initializeAgeControls = function() { this.fillUserAgeControl("user_age"); this.fillUserAgeControl("user_age_spouse"); } WizardScore.prototype.initializeNocsManagers = function() { this.nocs_manager = this.createNocManagers(false); this.nocs_manager_spouse = this.createNocManagers(true); } WizardScore.prototype.getWorkProfessionStartYear = function() { return new Date().getFullYear(); } WizardScore.prototype.getWorkProfessionEndYear = function() { const PROFESSION_YEARS_MAX_COUNT = 10; return (this.getWorkProfessionStartYear() - PROFESSION_YEARS_MAX_COUNT); } WizardScore.prototype.addWorkProfessionWhenYear = function(control, start_year, end_year, isSpouse) { for (var i = start_year; i >= end_year; i--) { var option_prefix = isSpouse ? "停止工作于 " : "停止工作于 "; this.AddSelectOptions(control, option_prefix + i + " 年", i); } } WizardScore.prototype.IsAjaxSubmitting = function() { return this.autoinfo_mode; } WizardScore.prototype.onSubmitFormToServerAjax = function(json_answer, save_data, show_success_message, success_callback) { this.saveToogleState(); $("#ajax_results").html(json_answer.results); Wizard.prototype.onSubmitFormToServerAjax.call(this, json_answer, save_data, show_success_message, success_callback); this.restoreToogleState(); } WizardScore.prototype.fillWorkProfessionWhenPrototype = function(control, isSpouse) { if ($(control).length > 0) { var start_year = this.getWorkProfessionStartYear(); var end_year = this.getWorkProfessionEndYear(); var option_text = isSpouse ? "目前正在工作 " : "目前正在工作 "; this.AddSelectOptions(control, option_text, 0); this.addWorkProfessionWhenYear(control, start_year, end_year, isSpouse) } } WizardScore.prototype.createJobOfferNocsManager = function(isSpouse) { const controlSelector = (isSpouse) ? "#user_job_offer_profession_spouse" : "#user_job_offer_profession"; if ($(controlSelector).length > 0) { var object = this; var on_change_job_offer_nocs = function (sender){ object.InitializeInterface(); }; // nocs manager for client var result = new NocsManager(isSpouse, "user_job_offer_profession"); result.clear_job_on_key_press = true; result.AddItem(); result.OnChangeNocs(on_change_job_offer_nocs); return result; } return null; } WizardScore.prototype.initializeJobOfferNocsManagers = function() { this.job_offer_nocs_manager = this.createJobOfferNocsManager(false); this.job_offer_nocs_manager_spouse = this.createJobOfferNocsManager(true); } WizardScore.prototype.initializeWorkProfessionPrototypes = function() { this.fillWorkProfessionWhenPrototype("#user_work_profession_when", false); this.fillWorkProfessionWhenPrototype("#user_work_profession_when_spouse", true); } WizardScore.prototype.shouldSerializeJobOfferManager = function(nocs_manager) { if (nocs_manager) { var result = IsButtonGroupCheckBoxOn("#has_job_offer_group"); if (nocs_manager.is_spouse) { result = this.hasSpouse(); result &= IsButtonGroupCheckBoxOn("#has_job_offer_spouse"); } result &= (nocs_manager.items_list.length > 0); return result; } return false; } WizardScore.prototype.serializeJobOfferFields = function(nocs_manager) { if (this.shouldSerializeJobOfferManager(nocs_manager)) { var offer_noc_id = nocs_manager.items_list[0].noc_id; var offer_job_id = nocs_manager.items_list[0].job_id; var spouse_prefix = (nocs_manager.is_spouse) ? "_spouse" : ""; return "user_job_offer_canada_noc_id" + spouse_prefix + "=" + offer_noc_id + "&user_job_offer_canada_job_id" + spouse_prefix + "=" + offer_job_id; } return ""; } WizardScore.prototype.shouldSerializeNocsManager = function(nocs_manager) { if (nocs_manager) { var result = IsButtonGroupCheckBoxOn("#has_work_experience"); if (nocs_manager.is_spouse) { result = this.hasSpouse(); result &= IsButtonGroupCheckBoxOn("#has_work_experience_spouse"); } return result; } return false; } WizardScore.prototype.serializeNocsFields = function(nocs_manager, title) { if (this.shouldSerializeNocsManager(nocs_manager)) return nocs_manager.SerializeNocsFields(title); return ""; } WizardScore.prototype.hasSpouse = function() { return IsButtonGroupCheckBoxOn("#user_has_spouse_group"); } WizardScore.prototype.getLanguageTest = function(elementPrefix) { return $("#" + elementPrefix + "_test option:selected").attr("data-name"); } WizardScore.prototype.isWithoutKnowledgeLanguageTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == LANGUAGE_TEST_NO_LANG); } WizardScore.prototype.isCommonLanguageTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == LANGUAGE_TEST_COMMON_NAME); } WizardScore.prototype.isIELTSEnglishTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == ENGLISH_TEST_IELTS_NAME); } WizardScore.prototype.isCELPIPEnglishTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == ENGLISH_TEST_CELPIP_NAME); } WizardScore.prototype.isPTEEnglishTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == ENGLISH_TEST_PTE_NAME); } WizardScore.prototype.isTEFFrenchTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == FRENCH_TEST_TEF_NAME); } WizardScore.prototype.isTCFFrenchTest = function(elementPrefix) { return (this.getLanguageTest(elementPrefix) == FRENCH_TEST_TCF_NAME); } WizardScore.prototype.isExactLanguageTest = function(elementPrefix) { let result = (this.getLanguageTest(elementPrefix) != ""); result = result && (isDefined(this.getLanguageTest(elementPrefix))); result = result && (!this.isCommonLanguageTest(elementPrefix)); result = result && (!this.isWithoutKnowledgeLanguageTest(elementPrefix)); return result; } WizardScore.prototype.changeLanguageEnabledState = function(is_disabled, languageName, isSpouse) { let elementName = this.generateLanguageTestPrefix(languageName, isSpouse); $(`#${elementName}_common`).attr("disabled", is_disabled && (!this.isCommonLanguageTest(elementName))); $(`.${elementName}_exact_item`).attr("disabled", is_disabled && (!this.isExactLanguageTest(elementName))); } WizardScore.prototype.changeLanguagesEnabledState = function(is_disabled) { for (let i = 0; i < LANGUAGES_ITEMS_LIST.length; i++) { this.changeLanguageEnabledState(is_disabled, LANGUAGES_ITEMS_LIST[i], false); this.changeLanguageEnabledState(is_disabled, LANGUAGES_ITEMS_LIST[i], true); } } WizardScore.prototype.ChangeInputsEnabledState = function(is_disabled) { Wizard.prototype.ChangeInputsEnabledState.call(this, is_disabled); this.changeLanguagesEnabledState(is_disabled); $(".spouse_step").attr("disabled", is_disabled && (!this.hasSpouse())); } WizardScore.prototype.analyzeLanguageStepVisibility = function(step, languageName, isSpouse) { let elementName = this.generateLanguageTestPrefix(languageName, isSpouse); // console.log(elementName); let result = true; if (step == elementName + "_common_info") result &= (this.isCommonLanguageTest(elementName)); if (step == elementName + "_exact_info") result &= (this.isExactLanguageTest(elementName)); return result; } WizardScore.prototype.analyzeLanguagesStepVisibility = function(step) { var result = true; for (let i = 0; i < LANGUAGES_ITEMS_LIST.length; i++) { result = result && (this.analyzeLanguageStepVisibility(step, LANGUAGES_ITEMS_LIST[i], false)); result = result && (this.analyzeLanguageStepVisibility(step, LANGUAGES_ITEMS_LIST[i], true)); } return result; } WizardScore.prototype.IsStepVisible = function(step) { let result = Wizard.prototype.IsStepVisible.call(this, step); result = result && (this.analyzeLanguagesStepVisibility(step)); if ($("#" + step).hasClass("spouse_step")) result = result && (this.hasSpouse()); return result; } WizardScore.prototype.InitializeInterface = function() { Wizard.prototype.InitializeInterface.call(this); this.updateSpouseInterface(); this.updateLanguagesCLBLevel(); $(".spouse_step_block").changeVisibility(this.hasSpouse()); } WizardScore.prototype.agreedWithResultsAccuracy = function() { return ($("#user_terms_data_accuracy_accept").is(":checked")); } WizardScore.prototype.changeUserTermsData = function() { $("#user_terms_data_accuracy_accept_warning").changeVisibility(!this.agreedWithResultsAccuracy()); } WizardScore.prototype.generateLanguageTestPrefix = function(language, isSpouse) { var spousePrefix = (isSpouse) ? "_spouse" : ""; return `user_${language}_language${spousePrefix}`; } WizardScore.prototype.generateLanguageTestName = function(language, isSpouse) { return this.generateLanguageTestPrefix(language, isSpouse) + "_test"; } WizardScore.prototype.loadLanguageFromJSON = function(json, languageName, isSpouse) { var elementName = this.generateLanguageTestName(languageName, isSpouse); var elementPrefix = this.generateLanguageTestPrefix(languageName, isSpouse); if (json[elementName]) SetSelectBoxValue("#" + elementName, json[elementName]); if ($("#" + elementName).length > 0) { this.onChangeLanguageTestParameters("#" + elementName); this.loadLanguageTestParametersFromJSON(json, elementPrefix + "_exact", this.isExactLanguageTest(elementPrefix)); } } WizardScore.prototype.loadLanguagesFromJSON = function(json) { for (let i = 0; i < LANGUAGES_ITEMS_LIST.length; i++) { this.loadLanguageFromJSON(json, LANGUAGES_ITEMS_LIST[i], false); this.loadLanguageFromJSON(json, LANGUAGES_ITEMS_LIST[i], true); } } WizardScore.prototype.LoadControlsFromJSON = function(json) { Wizard.prototype.LoadControlsFromJSON.call(this, json); this.loadLanguagesFromJSON(json); } WizardScore.prototype.AnalyzeSendDataAvailability = function(save_data) { let result = Wizard.prototype.AnalyzeSendDataAvailability.call(this, save_data); if (result) { result = result && (this.agreedWithResultsAccuracy()); this.changeUserTermsData(); } return result; } WizardScore.prototype.LoadParameters = function() { this.autoinfo_mode = ($("#auto_info").val() == "1"); } WizardScore.prototype.getLanguageTestValueFromTitle = function(itemTitle) { let result = itemTitle; const separatorPos = result.indexOf("-"); if (separatorPos >= 0) result = result.substring(separatorPos + 1, result.length); return result; } WizardScore.prototype.updateInputMinMaxValues = function(itemPrefix, propertyName, minMaxArray) { let controlName = "#" + itemPrefix + "_exact_" + propertyName; $(controlName).attr('step', minMaxArray.step); $(controlName).attr('min', minMaxArray.minValue); $(controlName).attr('max', minMaxArray.maxValue); } WizardScore.prototype.fillLanguageTestItemsByPointsObject = function(itemPrefix, minMaxArray) { this.updateInputMinMaxValues(itemPrefix, "reading", minMaxArray); this.updateInputMinMaxValues(itemPrefix, "writing", minMaxArray); this.updateInputMinMaxValues(itemPrefix, "listening", minMaxArray); this.updateInputMinMaxValues(itemPrefix, "speaking", minMaxArray); /* for(var propertyName in pointsObject) { var itemsHTML = ""; for (let i = 0; i < pointsObject[propertyName].length; i++) { let itemValue = this.getLanguageTestValueFromTitle(pointsObject[propertyName][i]); itemsHTML += ``; } $("#" + itemPrefix + "_exact_" + propertyName).html(itemsHTML); } */ } WizardScore.prototype.setLanguageTestExactInfoParameter = function(json, itemPrefix, parameterName) { let propertyName = itemPrefix + "_" + parameterName; $("#" + propertyName).val(json[propertyName]); // SetSelectBoxValue("#" + propertyName, json[propertyName]); } WizardScore.prototype.getLanguageTestExactInfoParameter = function(itemPrefix, parameterName) { let propertyName = itemPrefix + "_" + parameterName; return $("#" + propertyName).val(); // SetSelectBoxValue("#" + propertyName, json[propertyName]); } WizardScore.prototype.updateLanguageInputMinMaxValues = function(input) { var max = parseInt($(input).attr('max')); var min = parseInt($(input).attr('min')); if ($(input).val() > max) { $(input).val(max); } else if ($(input).val() < min) { $(input).val(min); } } WizardScore.prototype.updateLanguagesMinMaxValues = function() { let _this = this; $(".user_english_language_exact_item,.user_french_language_exact_item").each(function() { _this.updateLanguageInputMinMaxValues(this); }); } WizardScore.prototype.loadLanguageTestParametersFromJSON = function(json, itemPrefix, isExactLangugeText) { if (isExactLangugeText) { this.setLanguageTestExactInfoParameter(json, itemPrefix, "reading"); this.setLanguageTestExactInfoParameter(json, itemPrefix, "writing"); this.setLanguageTestExactInfoParameter(json, itemPrefix, "listening"); this.setLanguageTestExactInfoParameter(json, itemPrefix, "speaking"); this.updateLanguagesMinMaxValues(); } } WizardScore.prototype.addWorkEntry = function() { this.nocs_manager.AddItem(); } WizardScore.prototype.AddSpouseWorkEntry = function() { this.nocs_manager_spouse.AddItem(); } WizardScore.prototype.SetWorkProfessionWhenValue = function(current_item, finished_year, is_spouse) { var year_exists = false; var select_box_name = "#" + current_item.GetNocsElementIndexedPrefixedName("when"); $(select_box_name).children().each(function(child_index, child) { if (child.value == finished_year) { year_exists = true; return; } }); if (!year_exists) this.addWorkProfessionWhenYear($(select_box_name)[0], this.GetWorkProfessionEndYear() - 1, finished_year, is_spouse); current_item.SetInputValue("when", finished_year); } WizardScore.prototype.loadNocsControlsFromJSON = function(json, is_spouse) { var has_nocs = false; var nocs_suffix = (is_spouse) ? "_spouse" : ""; var nocs_manager = (is_spouse) ? this.nocs_manager_spouse : this.nocs_manager; if (json["user_jobs" + nocs_suffix]) { nocs_array = json["user_jobs" + nocs_suffix]; has_nocs = (nocs_array.length > 0); if (has_nocs) { for (var i = 0; i < nocs_array.length; i++) { var current_item = nocs_manager.current_item; current_item.SetInputValue("", nocs_array[i].job_title); this.SetWorkProfessionWhenValue(current_item, nocs_array[i].work_finished_year, is_spouse); current_item.ShowWorkExperience(nocs_array[i].job_title, nocs_array[i].job_id, nocs_array[i].noc_id, nocs_array[i].noc, nocs_array[i].noc_level, nocs_array[i].noc_title_en, undefined, nocs_array[i].average_income); current_item.ShowNocVideoFiles(nocs_array[i].job_id, nocs_array[i].noc_id, nocs_array[i].video_files, false); var work_experience_monthes = (nocs_array[i].work_experience % MONTHES_PER_YEAR); var work_experience_years = nocs_array[i].work_experience - work_experience_monthes; current_item.SetInputValue("length", work_experience_years); current_item.SetInputValue("length_monthes", work_experience_monthes); $(current_item.duration_select).trigger("onchange"); SetRadioBoxCheckedByNameValue(current_item.GetNocsElementIndexedPrefixedName("worktime"), nocs_array[i].work_time_id); SetRadioBoxCheckedByNameValue(current_item.GetNocsElementIndexedPrefixedName("worktype"), nocs_array[i].work_type_id); // is at Canada var at_canada = (nocs_array[i].province_id > 0); SetButtonGroupCheckBoxValue(current_item.location_check_box, at_canada); if (at_canada) { current_item.SetInputValue("province", nocs_array[i].province_id); } if (i != (nocs_array.length - 1)) nocs_manager.AddItem(); } } } SetButtonGroupCheckBoxValue("#has_work_experience" + nocs_suffix, has_nocs); } WizardScore.prototype.loadJobOfferControlsFromJSON = function(json, is_spouse) { var nocs_suffix = (is_spouse) ? "_spouse" : ""; var nocs_manager = (is_spouse) ? this.job_offer_nocs_manager_spouse : this.job_offer_nocs_manager; if ((nocs_manager) && (json["user_job_offer_canada_job_title" + nocs_suffix])) { var offer_job_title = json["user_job_offer_canada_job_title" + nocs_suffix]; var current_item = nocs_manager.current_item; current_item.SetInputValue("", offer_job_title); current_item.ShowWorkExperience(offer_job_title, json["user_job_offer_canada_job_id" + nocs_suffix], json["user_job_offer_canada_noc_id" + nocs_suffix]); } } WizardScore.prototype.getLanguagePointsArr = function(langPrefix) { if (this.isIELTSEnglishTest(langPrefix)) return ENGLISH_TEST_IELTS_CLB_ANALOG_VALUES; if (this.isCELPIPEnglishTest(langPrefix)) return ENGLISH_TEST_CELPIP_CLB_ANALOG_VALUES; if (this.isPTEEnglishTest(langPrefix)) return ENGLISH_TEST_PTE_CLB_ANALOG_VALUES; if (this.isTEFFrenchTest(langPrefix)) return FRENCH_TEST_TEF_CLB_ANALOG_VALUES; if (this.isTCFFrenchTest(langPrefix)) return FRENCH_TEST_TCF_CLB_ANALOG_VALUES; return null; } WizardScore.prototype.isCLBMeetsRequirementsForPointsArray = function(langPrefix, pointsArray) { langPrefix += "_exact"; let result = (this.getLanguageTestExactInfoParameter(langPrefix, "reading") >= pointsArray[0]); result = result && (this.getLanguageTestExactInfoParameter(langPrefix, "writing") >= pointsArray[1]); result = result && (this.getLanguageTestExactInfoParameter(langPrefix, "listening") >= pointsArray[2]); result = result && (this.getLanguageTestExactInfoParameter(langPrefix, "speaking") >= pointsArray[3]); return result; } WizardScore.prototype.getCLBLevelOfExactLanguage = function(langPrefix) { let result = ""; let languagePointsObject = this.getLanguagePointsArr(langPrefix); if (languagePointsObject) { for (var clbParam in languagePointsObject) { if (languagePointsObject.hasOwnProperty(clbParam)) { if (this.isCLBMeetsRequirementsForPointsArray(langPrefix, languagePointsObject[clbParam])) result = clbParam; } } } result = result.replace("clb", ""); return result; } WizardScore.prototype.getCLBLevelOfCommonLanguage = function(langPrefix) { let languageKnowing = $(`#${langPrefix}_common option:selected`).attr("data-name"); for (var clbParam in LANGUAGE_CEFR_CLB_ANALOG_VALUES) { if (LANGUAGE_CEFR_CLB_ANALOG_VALUES.hasOwnProperty(clbParam)) { if (languageKnowing == LANGUAGE_CEFR_CLB_ANALOG_VALUES[clbParam]) return clbParam.replace("clb", ""); } } return ""; } WizardScore.prototype.getCLBLevelOfLanguage = function(langPrefix) { let languageTest = $(`#${langPrefix}_test option:selected`).attr("data-name"); if (languageTest == "no_tests") return this.getCLBLevelOfCommonLanguage(langPrefix); else if ((languageTest == "no_language") || (languageTest == "")) return ""; return this.getCLBLevelOfExactLanguage(langPrefix); } WizardScore.prototype.updateLanguageCLBLevel = function(langPrefix) { let clbLevel = this.getCLBLevelOfLanguage(langPrefix); clbLevel = (clbLevel == "") ? "" : ("CLB Level: " + clbLevel); $(`#${langPrefix}_clb_info`).html(clbLevel); } WizardScore.prototype.updateLanguagesCLBLevel = function() { this.updateLanguageCLBLevel("user_english_language"); this.updateLanguageCLBLevel("user_french_language"); } WizardScore.prototype.onChangeEnglishTestParameters = function(langPrefix) { if (this.isIELTSEnglishTest(langPrefix)) this.fillLanguageTestItemsByPointsObject(langPrefix, ENGLISH_TEST_IELTS_RANGE_VALUES); else if (this.isCELPIPEnglishTest(langPrefix)) this.fillLanguageTestItemsByPointsObject(langPrefix, ENGLISH_TEST_CELPIP_RANGE_VALUES); else if (this.isPTEEnglishTest(langPrefix)) this.fillLanguageTestItemsByPointsObject(langPrefix, ENGLISH_TEST_PTE_RANGE_VALUES); this.InitializeInterface(); } WizardScore.prototype.onChangeFrenchTestParameters = function(langPrefix) { if (this.isTEFFrenchTest(langPrefix)) this.fillLanguageTestItemsByPointsObject(langPrefix, FRENCH_TEST_TEF_RANGE_VALUES); else if (this.isTCFFrenchTest(langPrefix)) this.fillLanguageTestItemsByPointsObject(langPrefix, FRENCH_TEST_TCF_RANGE_VALUES); this.InitializeInterface(); } WizardScore.prototype.onChangeLanguageTestParameters = function(element) { var language = $(element).attr("data-language"); var langPrefix = $(element).attr("data-lang-prefix"); if (language == "english") this.onChangeEnglishTestParameters(langPrefix); else if (language == "french") this.onChangeFrenchTestParameters(langPrefix); this.updateLanguagesMinMaxValues(); this.InitializeInterface(); } WizardScore.prototype.shouldAddLanguageToProfile = function() { return false; } WizardScore.prototype.shouldLoadPropertyFromJSON = function(json, propertyName) { return (json[propertyName] !== "null"); } WizardScore.prototype.updateSpouseInterface = function() { // relatives label var relativesText = this.hasSpouse() ? "您或您的配偶/伴侣在加拿大是否有近亲(兄弟姐妹),他们是加拿大的居民或公民?" : "Do you have any close relatives (siblings) who are residents or citizens of Canada?"; $("#relatives_label").html(relativesText); } WizardScore.prototype.initializeMinMaxLanguageHandlers = function() { let _this = this; $(".user_english_language_exact_item,.user_french_language_exact_item").change(function() { _this.updateLanguageInputMinMaxValues(this); }); } WizardScore.prototype.saveEnumToogleState = function(element, structure) { var object = this; $(element).children().each(function(index, child) { var passing_object = structure; var tag = $(child).prop("tagName").toLowerCase(); if (tag == "details") { var is_opened = $(child).prop("open"); var dataID = $(child).attr("data-id"); if (Assigned(dataID)) { structure[dataID] = {}; structure[dataID].opened = is_opened; passing_object = structure[dataID]; } } object.saveEnumToogleState(child, passing_object); }); } WizardScore.prototype.loadEnumToogleState = function(element, structure) { var object = this; $(element).children().each(function(index, child) { var passing_object = structure; var tag = $(child).prop("tagName").toLowerCase(); if (tag == "details") { var dataID = $(child).attr("data-id"); if (Assigned(dataID)) { if (structure.hasOwnProperty(dataID)) { var is_opened = structure[dataID].opened; $(child).prop("open", is_opened); passing_object = structure[dataID]; } } } object.loadEnumToogleState(child, passing_object); }); } WizardScore.prototype.saveToogleState = function() { if ($("#ajax_results").html() != "") { this.ajax_structure = {}; this.saveEnumToogleState("#ajax_results", this.ajax_structure); } } WizardScore.prototype.getHourWageForNocID = function(nocID, wageLocation, onGetHourWageCallback) { wageLocation = wageLocation || ""; ExecuteAjaxRequest(location.protocol + '//' + location.host + location.pathname, {mode: "wage_search_ajax", noc_id: nocID, location: wageLocation}, function(serverAnswer) { if ((serverAnswer.wage) && (onGetHourWageCallback)) { onGetHourWageCallback(serverAnswer.wage); } }, function(serverAnswer) { // do nothing }); } WizardScore.prototype.restoreToogleState = function() { this.loadEnumToogleState("#ajax_results", this.ajax_structure); } WizardScore.prototype.InitializeInternalObjects = function() { this.initializeAgeControls(); this.initializeWorkProfessionPrototypes(); this.initializeNocsManagers(); this.initializeJobOfferNocsManagers(); this.initializeMinMaxLanguageHandlers(); Wizard.prototype.InitializeInternalObjects.call(this); }