let demoParameters = [{
		moduleType: "centralWavelength",
		url: "../cgi/cgi_CombMapManager.py",
		data: {
			requestType: "read_comb_map",
			id: 1
		}
	},
	{
		moduleType: "comboTone",
		url: "../cgi/cgi_DemuxMap.py",
		data: {
			requestType: "read_CombTone"
		}
	},
	{
		moduleType: "demuxMap",
		url: "../cgi/cgi_DemuxMap.py",
		data: {
			requestType: "read_DemuxMap"
		}
	},
	{
		moduleType: "demoDemuxMap",
		url: "../cgi/cgi_DemuxMap.py",
		data: {
			requestType: "read_DemoDemuxMap"
		}
	},
	{
		moduleType: "demoComboTone",
		url: "../cgi/cgi_DemuxMap.py",
		data: {
			requestType: "read_DemoCombTone"
		}
	}
]

function BindDemoDemuxMapData(set) {
	demoDemuxMapData.forEach(function (d, index) {
		if (set == 0 || set == 2) {
			$("#Demo_Demux_Setvalue_" + index).val(d.demo_demux_power);
			$("#Demo_Demux_Switch_" + index).prop("checked", d.demo_state == 1 ? true : false);
			$("#Demo_Demux_Setvalue_" + index).change(function () {
				var value = parseFloat(parseFloat($(this).val()).toFixed(2));
				eval("Demo_Demux_Slider_Obj_" + index).slider.setValues(value, d.get_max_Demux_power);
				outOffRange(d.get_demux_power, d.get_max_Demux_power, value)
			});
		}
	});
}


function saveDemoModeMapData() {
	var demo_wavelength = $("#demo-wavelength-setvalue").val();
	var demo_FSR = $("#demo-frequency-setvalue").val();
	$.ajax({
		type: "Get",
		url: "../cgi/cgi_CombMapManager.py",
		contentType: 'application/json',
		dataType: 'json',
		headers: {
			'Access-Control-Allow-Origin': '*'
		},
		data: {
			requestType: "update_demo_comb_map",
			id: opticalFrequencyCombData.id,
			demo_wavelength: demo_wavelength,
			demo_FSR: demo_FSR
		},
		success: function (response) {
			showModal('Success', response.description);
			$.ajax({
				type: "Get",
				url: demoParameters[4].url,
				contentType: 'application/json',
				dataType: 'json',
				headers: {
					'Access-Control-Allow-Origin': '*'
				},
				data: demoParameters[4].data,
				success: function (response) {
					demoCombToneData = response;
					BindDemoDropdownCombToneData();
					if ($("#demo_dr_demultiplexer_0").val() == -1 || $("#demo_dr_demultiplexer_1").val() == -1 || $("#demo_dr_demultiplexer_2").val() == -1 || $("#demo_dr_demultiplexer_3").val() == -1) {
						$("#updateView").prop("disabled", true);
					}
					isSetUnprotectedMode = true;
				},
				error: function (ex) {
					$("#test").html(ex.responseText)
				}
			});
		},
		error: function (ex) {
			$("#test").html(ex.responseText)
		}
	});
}

function BindDemoDropdownCombToneData() {
	$("#demo_dr_demultiplexer_0,#demo_dr_demultiplexer_1,#demo_dr_demultiplexer_2,#demo_dr_demultiplexer_3").empty();
	$("#demo_dr_demultiplexer_0,#demo_dr_demultiplexer_1,#demo_dr_demultiplexer_2,#demo_dr_demultiplexer_3").append(new Option("Select", -1));
	demoCombToneData.forEach(function (data) {
		$("#demo_dr_demultiplexer_0,#demo_dr_demultiplexer_1,#demo_dr_demultiplexer_2,#demo_dr_demultiplexer_3").append(new Option(data.tone + " , " + data.comb_central_wav, data.id));
	});
	demo_combtone1 = demoDemuxMapData[0].lut_id;
	demo_combtone2 = demoDemuxMapData[1].lut_id;
	demo_combtone3 = demoDemuxMapData[2].lut_id;
	demo_combtone4 = demoDemuxMapData[3].lut_id;

	if (demoCombToneData.find(x => x.id === demoDemuxMapData[0].lut_id)) {
		$("#demo_dr_demultiplexer_0").val(demoDemuxMapData[0].lut_id);
		$("#demo_dr_demultiplexer_1 option[value='" + demoDemuxMapData[0].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_2 option[value='" + demoDemuxMapData[0].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_3 option[value='" + demoDemuxMapData[0].lut_id + "'").remove();
	} else {
		$("#demo_dr_demultiplexer_0").val(-1);
	}

	if (demoCombToneData.find(x => x.id === demoDemuxMapData[1].lut_id)) {
		$("#demo_dr_demultiplexer_1").val(demoDemuxMapData[1].lut_id);
		$("#demo_dr_demultiplexer_0 option[value='" + demoDemuxMapData[1].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_2 option[value='" + demoDemuxMapData[1].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_3 option[value='" + demoDemuxMapData[1].lut_id + "'").remove();
	} else {
		$("#demo_dr_demultiplexer_1").val(-1);
	}

	if (demoCombToneData.find(x => x.id === demoDemuxMapData[2].lut_id)) {
		$("#demo_dr_demultiplexer_2").val(demoDemuxMapData[2].lut_id);
		$("#demo_dr_demultiplexer_0 option[value='" + demoDemuxMapData[2].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_1 option[value='" + demoDemuxMapData[2].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_3 option[value='" + demoDemuxMapData[2].lut_id + "'").remove();
	} else {
		$("#demo_dr_demultiplexer_2").val(-1);
	}

	if (demoCombToneData.find(x => x.id === demoDemuxMapData[3].lut_id)) {
		$("#demo_dr_demultiplexer_3").val(demoDemuxMapData[3].lut_id);
		$("#demo_dr_demultiplexer_0 option[value='" + demoDemuxMapData[3].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_1 option[value='" + demoDemuxMapData[3].lut_id + "'").remove();
		$("#demo_dr_demultiplexer_2 option[value='" + demoDemuxMapData[3].lut_id + "'").remove();
	} else {
		$("#demo_dr_demultiplexer_3").val(-1);
	}
}

function saveDemoDemultiplexData(url, requestType, id, name, setvalue, turnOffState, demo_demux_id, demo_set_tone, showMsg) {
	if (setvalue == "")
		setvalue = 0;

	$.ajax({
		type: "Get",
		url: url,
		contentType: 'application/json',
		dataType: 'json',
		headers: {
			'Access-Control-Allow-Origin': '*'
		},
		data: {
			requestType: requestType,
			id: id,
			name: name,
			set_on_off_state: turnOffState,
			set_power: setvalue,
			demo_demux_lut_id: demo_demux_id,
			demo_set_tone: demo_set_tone
		},
		success: function (response) {
			console.log(response.status + "," + response.description);
			if (showMsg)
				showModal(response.status, response.description);
			isSetUnprotectedMode = true;
			$("#updateView").prop("disabled", false);
			
		},
		error: function (ex) {
			$("#test").html(ex.responseText)
		}
	});
}

function BindCombData(set) {
	if (set == 0 || set == 1) {
		if (opticalFrequencyCombData.set_on_off_state == 1)
			$("#wavelength-turn-on-off").prop("checked", true);
		else
			$("#wavelength-turn-on-off").prop("checked", false);
		$("#wavelength-setvalue").val(opticalFrequencyCombData.set_central_wavelength);
		$("#frequency-setvalue").val(opticalFrequencyCombData.set_comb_FSR);
	}
	if (set == 0 || set == 2) {
		if (opticalFrequencyCombData.demoState == 1)
			$("#demo-wavelength-turn-on-off").prop("checked", true);
		else
			$("#demo-wavelength-turn-on-off").prop("checked", false);
		$("#demo-wavelength-setvalue").val(opticalFrequencyCombData.demoWavelength);
		$("#demo-frequency-setvalue").val(opticalFrequencyCombData.demoFSR);
	}
}

function loadDemoData() {
	demoParameters.forEach(function (parameter) {
		$.ajax({
			type: "Get",
			url: parameter.url,
			async: false,
			contentType: 'application/json',
			dataType: 'json',
			headers: {
				'Access-Control-Allow-Origin': '*'
			},
			data: parameter.data,
			success: function (response) {
				switch (parameter.moduleType) {
					case "centralWavelength":
						opticalFrequencyCombData = response[0];
						BindCombData(0);
						break;
					case "comboTone":
						combToneData = response;
						break;
					case "demuxMap":
						demuxMapData = response;
						// BindDemuxMapData(0);
						break;
					case "demoDemuxMap":
						demoDemuxMapData = response;
						BindDemoDemuxMapData(0);
						break;
					case "demoComboTone":
						demoCombToneData = response;
						BindDemoDropdownCombToneData();
						break;
				}
				$("#graph-water-mark").addClass("d-none");
				$("#demoMode").removeClass("d-none");
			},
			error: function (ex) {
				$("#test").html(ex.responseText)
			}
		});
	});
	if ($("#demo_dr_demultiplexer_0").val() == -1 || $("#demo_dr_demultiplexer_1").val() == -1 || $("#demo_dr_demultiplexer_2").val() == -1 || $("#demo_dr_demultiplexer_3").val() == -1) {
		$("#updateView").prop("disabled", true);
	}
}
$(document).ready(function () {

	

	OpticalfrequencycombSeries_1000();
	DemuxSpectrumSeries();

	$("#updateView").prop("disabled", true);


	loadDemoData();

	$("#demo-cancel-btn").click(function () {
		let i = 0;

		if ($("#demo-central-wavelength-slider").next().length > 0) { 
			let waveValue = $("#demo-wavelength-turn-on-off").prop("checked") == true ? 1 : 0;
			if(waveValue !=opticalFrequencyCombData.set_on_off_state){
				i++;
			}
			if($("#demo-wavelength-setvalue").val() != opticalFrequencyCombData.demoWavelength){
				i++;
			}
			if($("#demo-frequency-setvalue").val() != opticalFrequencyCombData.demoFSR){
				i++;
			}
		}
		if ($("#Demo_Demux_Slider_0").next().length > 0) { 		
			// console.log(demoDemuxMapData)	
			for(k=0; k<4; k++){
				// if($(`#Demo_Demux_Switch_${k}`).prop("checked") == true ? 1 : 0 != demoDemuxMapData.set_on_off_state){
				// 	i++;
				// }
				if($(`#Demo_Demux_Setvalue_${k}`).val() != demoDemuxMapData[k].demo_demux_power){
					i++;
				}
			}
		}
		if ($("#demo-central-wavelength-slider").next().length > 0) {
			BindCombData(2);
			demoCentralWavelengthSliderObj.slider.setValues(opticalFrequencyCombData.demoWavelength, opticalFrequencyCombData.get_max_central_wavelength)
			demoCombFrequencySliderObj.slider.setValues(opticalFrequencyCombData.demoFSR, opticalFrequencyCombData.get_max_FSR)
		}

		if ($("#Demo_Demux_Slider_0").next().length > 0) {
			Demo_Demux_Slider_Obj_0.slider.setValues(demoDemuxMapData[0].demo_demux_power, demoDemuxMapData[0].get_max_Demux_power);
			Demo_Demux_Slider_Obj_1.slider.setValues(demoDemuxMapData[1].demo_demux_power, demoDemuxMapData[1].get_max_Demux_power);
			Demo_Demux_Slider_Obj_2.slider.setValues(demoDemuxMapData[2].demo_demux_power, demoDemuxMapData[2].get_max_Demux_power);
			Demo_Demux_Slider_Obj_3.slider.setValues(demoDemuxMapData[3].demo_demux_power, demoDemuxMapData[3].get_max_Demux_power);
			BindDemoDemuxMapData(2);
		}
		if(i > 0){
			showMsg = true
			showModal("Alert!", "Changes Reversed")
		}
		else {
			showMsg = true
			showModal("Alert!", "No Changes Detected")
		}
	});

	$(".demo-setvalue").focus(function () {
		if (isDemoSetUnprotectedMode == false) {
			commonOpticalCombId = "#demo-wavelength-turn-on-off";
			if ($("#demo-wavelength-turn-on-off").prop("checked") == true) {
				$(".state-box-layout").fadeIn();
			} else {
				$(this).prop("disabled", true);
				$(".warning-box-layout").fadeIn();
				$("#warning-password").focus();
			}
		}
	});

	$(".demo-idriveBtn").click(function (e) {
		if (isDemoSetUnprotectedMode == false) {
			commonOpticalCombId = "#demo-wavelength-turn-on-off";
			e.preventDefault();
			if ($("#demo-wavelength-turn-on-off").prop("checked") == true) {
				$(".state-box-layout").fadeIn();
			} else {
				$(".warning-box-layout").fadeIn();
				$("#warning-password").focus();
			}
		}
	});


	$("#demo-demux-tab").click(function () {
		if ($("#Demo_Demux_Slider_0").next().length == 0) {
			setTimeout(function () {
				loadSlider(Demo_Demux_Slider_Obj_0, "#Demo_Demux_Slider_0", "#Demo_Demux_Setvalue_0", demoDemuxMapData[0].get_demux_power, demoDemuxMapData[0].get_max_Demux_power, demoDemuxMapData[0].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
				loadSlider(Demo_Demux_Slider_Obj_1, "#Demo_Demux_Slider_1", "#Demo_Demux_Setvalue_1", demoDemuxMapData[1].get_demux_power, demoDemuxMapData[1].get_max_Demux_power, demoDemuxMapData[1].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
				loadSlider(Demo_Demux_Slider_Obj_2, "#Demo_Demux_Slider_2", "#Demo_Demux_Setvalue_2", demoDemuxMapData[2].get_demux_power, demoDemuxMapData[2].get_max_Demux_power, demoDemuxMapData[2].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
				loadSlider(Demo_Demux_Slider_Obj_3, "#Demo_Demux_Slider_3", "#Demo_Demux_Setvalue_3", demoDemuxMapData[3].get_demux_power, demoDemuxMapData[3].get_max_Demux_power, demoDemuxMapData[3].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
			}, 1);
		}
	});

	$("#demo_dr_demultiplexer_0").change(function () {

		var prevTone = demoCombToneData.filter(function (item) {
			return item.id == demo_combtone1;
		});

		if (prevTone.length > 0)
			$("#demo_dr_demultiplexer_1,#demo_dr_demultiplexer_2,#demo_dr_demultiplexer_3").append(new Option(prevTone[0].tone + " , " + prevTone[0].comb_central_wav, prevTone[0].id));

		if (parseInt($(this).val()) > 0) {
			$("#demo_dr_demultiplexer_1 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_2 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_3 option[value='" + $(this).val() + "'").remove();
			demo_combtone1 = $(this).val();
		}

	});

	$("#demo_dr_demultiplexer_1").change(function () {

		var prevTone = demoCombToneData.filter(function (item) {
			return item.id == demo_combtone2;
		});

		if (prevTone.length > 0)
			$("#demo_dr_demultiplexer_0,#demo_dr_demultiplexer_2,#demo_dr_demultiplexer_3").append(new Option(prevTone[0].tone + " , " + prevTone[0].comb_central_wav, prevTone[0].id));

		if (parseInt($(this).val()) > 0) {
			$("#demo_dr_demultiplexer_0 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_2 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_3 option[value='" + $(this).val() + "'").remove();
			demo_combtone2 = $(this).val();
		}

	});

	$("#demo_dr_demultiplexer_2").change(function () {
		var prevTone = demoCombToneData.filter(function (item) {
			return item.id == demo_combtone3;
		});

		if (prevTone.length > 0)
			$("#demo_dr_demultiplexer_1,#demo_dr_demultiplexer_0,#demo_dr_demultiplexer_3").append(new Option(prevTone[0].tone + " , " + prevTone[0].comb_central_wav, prevTone[0].id));

		if (parseInt($(this).val()) > 0) {
			$("#demo_dr_demultiplexer_0 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_1 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_3 option[value='" + $(this).val() + "'").remove();
			demo_combtone3 = $(this).val();
		}

	});

	$("#demo_dr_demultiplexer_3").change(function () {
		var prevTone = demoCombToneData.filter(function (item) {
			return item.id == demo_combtone4;
		});

		if (prevTone.length > 0)
			$("#demo_dr_demultiplexer_1,#demo_dr_demultiplexer_2,#demo_dr_demultiplexer_0").append(new Option(prevTone[0].tone + " , " + prevTone[0].comb_central_wav, prevTone[0].id));

		if (parseInt($(this).val()) > 0) {
			$("#demo_dr_demultiplexer_1 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_2 option[value='" + $(this).val() + "'").remove();
			$("#demo_dr_demultiplexer_0 option[value='" + $(this).val() + "'").remove();
			demo_combtone4 = $(this).val();
		}

	});

	$(".save-btn").click(function () {
		switch ($(this).val()) {

			case "opticalComb":
				saveOpticalCombData(true);
				break;
			case "demoModeMap":
				saveDemoModeMapData(true);
				// $("#demo-demux-tab").click()
				if ($("#Demo_Demux_Slider_0").next().length == 0) {
					setTimeout(function () {
						loadSlider(Demo_Demux_Slider_Obj_0, "#Demo_Demux_Slider_0", "#Demo_Demux_Setvalue_0", demoDemuxMapData[0].get_demux_power, demoDemuxMapData[0].get_max_Demux_power, demoDemuxMapData[0].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
						loadSlider(Demo_Demux_Slider_Obj_1, "#Demo_Demux_Slider_1", "#Demo_Demux_Setvalue_1", demoDemuxMapData[1].get_demux_power, demoDemuxMapData[1].get_max_Demux_power, demoDemuxMapData[1].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
						loadSlider(Demo_Demux_Slider_Obj_2, "#Demo_Demux_Slider_2", "#Demo_Demux_Setvalue_2", demoDemuxMapData[2].get_demux_power, demoDemuxMapData[2].get_max_Demux_power, demoDemuxMapData[2].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
						loadSlider(Demo_Demux_Slider_Obj_3, "#Demo_Demux_Slider_3", "#Demo_Demux_Setvalue_3", demoDemuxMapData[3].get_demux_power, demoDemuxMapData[3].get_max_Demux_power, demoDemuxMapData[3].demo_demux_power, demuxSliderWidth, true, 0.01, false, false);
					}, 1);
				}
				$("#demo-demux-tab").addClass('icon');
				$("#demo-demux-tab").next().addClass('show-level');
				$('html, body').animate({
					scrollTop: $("#demo-demux-tab").offset().top-100
				}, 1500);
				break;
			case "demoDemux":
				demoDemuxMapData.forEach(function (data, index) {
					var setvalue = $("#Demo_Demux_Setvalue_" + (data.id - 1)).val();
					var turnOffState = $("#Demo_Demux_Switch_" + (data.id - 1)).prop("checked") == true ? 1 : 0;
					var demo_demux_id = $("#demo_dr_demultiplexer_" + (data.id - 1)).val();
					var demo_set_tone = $("#demo_dr_demultiplexer_" + (data.id - 1) + " option:selected").html().split(",")[0].slice(-2).trim();
					saveDemoDemultiplexData("../cgi/cgi_DemuxMap.py", "update_DemoDemuxMap", data.id, data.name, setvalue, turnOffState, demo_demux_id, demo_set_tone, false);
				});

				// if ($("#demo_dr_demultiplexer_0").val() == -1 || $("#demo_dr_demultiplexer_1").val() == -1 || $("#demo_dr_demultiplexer_2").val() == -1 || $("#demo_dr_demultiplexer_3").val() == -1) {
				// 	$("#updateView").prop("disabled", true);
				// } else {
				// 	$("#updateView").prop("disabled", false);
				// }

				showModal('Success', 'updated successfully');
				// if (commonOpticalCombId == "#demo-wavelength-turn-on-off") {
				// 	isDemoSetUnprotectedMode = false;
				// 	$("#demo-wavelength-switch-off").css("pointerEvents", "auto");
				// 	showMsgBox = true;
				// } else {
				// 	isSetUnprotectedMode = false;
				// 	$("#wavelength-switch-off").css("pointerEvents", "auto");
				// 	showMsgBox = true;
				// }
				// isIDriveValChange = false
				break;
		}
		loadDemoData();
	});

	//cancel
	$("#cancel-btn").click(function () {
		if ($("#central-wavelength-slider").next().length > 0) {
			BindCombData(1);
			centralWavelengthSliderObj.slider.setValues(opticalFrequencyCombData.set_central_wavelength, opticalFrequencyCombData.get_max_central_wavelength)
			combFrequencySliderObj.slider.setValues(opticalFrequencyCombData.set_comb_FSR, opticalFrequencyCombData.get_max_FSR)
		}
		showModal("Success", "Values have been reset successfully");
	});


	$("#updateView").click(function () {
		$.ajax({
			type: "Get",
			url: "../cgi/cgi_PilotGraphs.py",
			contentType: 'application/json',
			dataType: 'json',
			headers: {
				'Access-Control-Allow-Origin': '*'
			},
			data: {
				requestType: "create_csv",
				id: opticalFrequencyCombData.id,
				demo_wavelength: $("#demo-wavelength-setvalue").val(),
				demo_FSR: $("#demo-frequency-setvalue").val(),
				demux_set_tone1: $("#demo_dr_demultiplexer_0 option:selected").html().split(",")[0].slice(-2).trim(),
				demux_set_tone2: $("#demo_dr_demultiplexer_1 option:selected").html().split(",")[0].slice(-2).trim(),
				demux_set_tone3: $("#demo_dr_demultiplexer_2 option:selected").html().split(",")[0].slice(-2).trim(),
				demux_set_tone4: $("#demo_dr_demultiplexer_3 option:selected").html().split(",")[0].slice(-2).trim()
			},
			beforeSend: function () {
				$('.loaderDiv').css('display', 'block');
				$('.msg-box').hide();
			},
			success: function (response) {
				$('.loaderDiv').css('display', 'none');
				showModal('Success', response.description);
				OpticalfrequencycombSeries_1000();
				DemuxSpectrumSeries();
				$("#updateView").prop("disabled", true);
			},
			error: function (ex) {
				/*$("#test").html(ex.responseText);	*/
				$('.loaderDiv').css('display', 'none');
				showModal('Success', "Successfully created");
				OpticalfrequencycombSeries_1000();
				DemuxSpectrumSeries();
				$("#updateView").prop("disabled", true);
			}
		});
	});

	//Optical comb
	$("#demo-optical-comb-tab").click(function () {
		console.log("demo comb")
		if ($("#demo-central-wavelength-slider").next().length == 0) {
			setTimeout(function () {
				loadSlider(demoCentralWavelengthSliderObj, "#demo-central-wavelength-slider", "#demo-wavelength-setvalue", opticalFrequencyCombData.get_min_central_wavelength, opticalFrequencyCombData.get_max_central_wavelength, opticalFrequencyCombData.demoWavelength, generalSliderWidthLVL1, false, 1, true);
				loadSlider(demoCombFrequencySliderObj, "#demo-central-frequency-slider", "#demo-frequency-setvalue", opticalFrequencyCombData.get_min_FSR, opticalFrequencyCombData.get_max_FSR, opticalFrequencyCombData.demoFSR, generalSliderWidthLVL1, false, 1, true);
			}, 1);
		}
	});
	$("#demo-wavelength-setvalue").change(function () {
		var value = parseFloat(parseFloat($(this).val()).toFixed(2));
		demoCentralWavelengthSliderObj.slider.setValues(value, opticalFrequencyCombData.get_max_central_wavelength);
		outOffRange(opticalFrequencyCombData.get_min_central_wavelength, opticalFrequencyCombData.get_max_central_wavelength, value);
	});

	$("#demo-frequency-setvalue").change(function () {
		var value = parseFloat(parseFloat($(this).val()).toFixed(2));
		demoCombFrequencySliderObj.slider.setValues(value, opticalFrequencyCombData.get_max_FSR)
		outOffRange(opticalFrequencyCombData.get_min_FSR, opticalFrequencyCombData.get_max_FSR, value);
	});

	$("#restore-demo-btn").click(()=>{
		let parameter = {url : "../cgi/cgi_RestoreDefaultSettings.py", data : {requestType : "restore_demo"}};
		$.ajax({
			url : parameter.url,
			type : "get",
			data : parameter.data,
			contentType: 'application/json',
			dataType: 'json',
			headers: {
				'Access-Control-Allow-Origin': '*'
			},
			success: function (response) {
				showModal('Success', response.response);
			}
		})
	})
})