const EvoPhpUrl = 'https://www.luxriot.com/oem/calculators/evo/evocalc2.php'; var copyright="Copyright © 2004-" + new Date().getFullYear() + " A&H Software House, Inc. All Rights Reserved."; var licences = ["Luxriot EVO S24","Luxriot EVO S48","Luxriot EVO S72","Luxriot EVO S96","Luxriot EVO Global","Luxriot EVO S"]; var editions = [[0,"EVO S"],[1,"Global"]]; var Resources; $(document).ready(function () { $(".clientresult").hide(); $(".centralresult").hide(); $(".serverresult").hide(); $(".evaserverresult").hide(); $(".resulttable").hide(); $(".gpuresult").hide(); $.support.cors = true; $.ajax({ url: EvoPhpUrl, type:"GET", data:"mode=resources", dataType:"json", success: function(response) { Resources = response; $("#calc tr:last").after(''); $(".gpuconfig").html(SelectGenerator(Resources['gpu'],'gpuconfiglist',0)); $(".onnx_gpus_config").html(SelectGenerator(Resources['onnx_gpus'],'onnx_gpus_configlist',0)); $(".cpumanufacturers").not('.evacpu').html(SelectGenerator(Resources['cpumanufacturers'],'cpumanufacturerslist',1)); $(".cpumanufacturers.evacpu").html(SelectGenerator(Resources['evacpumanufacturers'],'cpumanufacturerslist',1)); $(".edition").html(SelectGenerator(editions,'editionlist',1)); $("#cpurecommend").html(''); $("#editionrecommend").html(''); $('#cpurecommendcheckbox').prop('checked',true); $('#editionrecommendcheckbox').prop('checked',true); PopulateSeries(2,0); PopulateSeries(3,4); PopulateSeries(4,0); FillRow(); }}); $("#addgrp").click(function () { $("#calc tr:last").after(''); FillRow(); }); $.support.cors = true; $.ajax({ url: EvoPhpUrl, type:"GET", data:"mode=version", dataType:"text", success: function(response) { $("#copyright").html(copyright); $("#version").html(response); }}); }); $(document).on('click', ".delgrp", function() { parentrow = $(this).closest('tr') parentrow.prev('tr').remove(); parentrow.next('tr').remove(); parentrow.remove(); }); $(document).on('change', '.estimator', function(){ var parent = $(this).closest(".streamdata"); var estimatorData = []; estimatorData['fps'] = parent.find(".frameratelist").val(); estimatorData['resolution'] = parent.find(".resolutionlist").val(); estimatorData['compression'] = parent.find(".compressionlist").val(); $.support.cors = true; $.ajax({ url:EvoPhpUrl, type:"GET", data:'mode=estimate&fps='+ estimatorData['fps'] +'&resolution='+ estimatorData['resolution'] +'&compression=' + estimatorData['compression'], success: function(response) { parent.find(".bitratelist option[value='" + response + "']").attr("selected", "selected"); } }); }); $(document).on('click', "#calculate", function() { $(".clientresult").hide(); $(".centralresult").hide(); $(".serverresult").hide(); $(".evaserverresult").hide(); $(".resulttable").hide(); $("#result .server").remove(); $("#result .client").remove(); var i = 0; var gcount = 0; var tdata = []; tdata[gcount] = {}; tdata[gcount]["usagemode"] = $("#usagemode").val(); tdata[gcount]["streamserv"] = $("#streamserv").val(); tdata[gcount]["gpumode"] = $(".gpuconfiglist").val(); tdata[gcount]["onnx_gpu"] = $(".onnx_gpus_configlist").val(); tdata[gcount]["clientcpu"] = $(".clientCPU .cpumodelslist").val(); tdata[gcount]["evacpu"] = $(".evacpu .cpumodelslist").val(); tdata[gcount]["servercpu"] = $(".serverCPU .cpumodelslist").val(); tdata[gcount]["cpurecommend"] = $('#cpurecommendcheckbox').is(':checked') ? 1 : 0; tdata[gcount]["editionrecommend"] = $('#editionrecommendcheckbox').is(':checked') ? 1 : 0; tdata[gcount]["edition"] = $(".editionlist").val(); tdata[gcount]["evacpurecommend"] = $('#cpurecommendcheckbox').is(':checked') ? 1 : 0; tdata[gcount]["api"] = 3; gcount++; var streamcount = 0; $("#calc .streamdata").each(function(){ i++; if($(this).hasClass("mains")){; streamcount = $(this).find(".scount").val() tdata[gcount] = []; tdata[gcount][0] = {}; tdata[gcount][0]["streamcount"] = streamcount; tdata[gcount][0]["compression"] = $(this).find(".compressionlist").val(); tdata[gcount][0]["resolution"] = $(this).find(".resolutionlist").val(); tdata[gcount][0]["fps"] = $(this).find(".frameratelist").val(); tdata[gcount][0]["bitrate"] = $(this).find(".bitratelist").val(); tdata[gcount][0]["mdsource"] = $(this).find(".mdmainlist").val(); tdata[gcount][0]["odmodel"] = $(this).find(".onnx_models_list").val(); tdata[gcount][0]["odaccuracy"] = $(this).find(".onnx_accuracy_levels_list").val(); tdata[gcount][0]["odinterval"] = $(this).find(".onnx_detection_intervals_list").val(); tdata[gcount][0]["recevents"] = $(this).find(".recordingeventslist").val(); tdata[gcount][0]["prerec"] = $(this).find(".prerecordinglist").val(); tdata[gcount][0]["fpsnomotion"] = $(this).find(".fpsnomotionlist").val(); tdata[gcount][0]["storedays"] = $(this).find(".daystostore").val(); } else if($(this).find(".substreamlist").val() == 1 ){ tdata[gcount][1] = {}; tdata[gcount][1]["streamcount"] = streamcount; tdata[gcount][1]["substream"] = $(this).find(".substreamlist").val(); tdata[gcount][1]["compression"] = $(this).find(".compressionlist").val(); tdata[gcount][1]["resolution"] = $(this).find(".resolutionlist").val(); tdata[gcount][1]["fps"] = $(this).find(".frameratelist").val(); tdata[gcount][1]["bitrate"] = $(this).find(".bitratelist").val(); tdata[gcount][1]["mdsource"] = $(this).find(".mdsublist").val(); tdata[gcount][1]["odmodel"] = $(this).find(".onnx_models_list").val(); tdata[gcount][1]["odaccuracy"] = $(this).find(".onnx_accuracy_levels_list").val(); tdata[gcount][1]["odinterval"] = $(this).find(".onnx_detection_intervals_list").val(); tdata[gcount][1]["recevents"] = $(this).find(".recordingeventslist").val(); tdata[gcount][1]["prerec"] = $(this).find(".prerecordinglist").val(); tdata[gcount][1]["fpsnomotion"] = $(this).find(".fpsnomotionlist").val(); tdata[gcount][1]["storedays"] = $(this).find(".daystostore").val(); gcount ++; }else{ gcount ++; } }); $.support.cors = true; $.ajax({ url:EvoPhpUrl, type:"POST", data:JSON.stringify(tdata), contentType:"application/json; charset=utf-8", dataType:"json", success: function(response) { if (response['error'] > 0) { $(".resulttable").hide(); $(".gpuresult").hide(); $(".errors").show(); var errors = Resources['errors']; var error = response['error']; $("#errortext").html(errors[error][1]); } else { $(".gpuresult").hide(); $(".errors").hide(); $(".resulttable").show(); if(response['serverlicense'] == 4) { $(".centralresult").show(); $("#result #rescentral").after("" + response['centralserver']['cpu'] + "" + response['centralserver']['os'] + "" + response['centralserver']['ram'] + "" + response['centralserver']['net'] + "" + response['centralserver']['gpu'] + "") } if(response['servers'] > 0) { $(".serverresult").show(); $("#result #resserver").after("" + response['servers'] + "" + response['servercpumodel'] + "" + Resources['os'][response['serveros']][1] + "" + response['serverstreams'] + "" + response['serverram'] + "" + response['servernet'] + "" + response['serverdisk'] + "" + response['serverwrite'] + "") } if(response['evaservers'] > 0) { $(".evaserverresult").show(); $("#result #resevaserver").after("" + response['evaservers'] + "" + response['evaservercpumodel'] + "" + Resources['os'][response['evaserveros']][1] + "" + response['evaserverstreams'] + "" + response['evaserverram'] + "" + response['evaservernet'] + "" + response['evaserverdisk'] + "" + response['evaserverwrite'] + "" + response['evaservergpu'] + "") } if (response['clients'] > 0) { $(".clientresult").show(); $("#result #resclient").after("" + response['clients'] + "" + response['clientcpumodel'] + "" + Resources['os'][response['clientos']][1] + "" + response['clientstreams'] + "" + response['clientram'] + "" + response['clientnet'] + "" + response['clientgpu'] + "") } else if(response['servergpu'] != 0) { $(".gpuresult").show(); $("#result #resgpu").after("" + response['servergpu'] + "") } $("#licence").html(licences[response['serverlicense']]); } }, error: function(jqxhr,textStatus,errorThrown){ if(textStatus === 'parsererror'){ $(".resulttable").hide(); $(".errors").show(); $("#errortext").html("Selected CPU is not suitable for this configuration"); } } }); }); $(document).on('change', '.recordingeventslist',function(){ if($(this).val() == 9){ $(this).parent('td').parent('tr').find('.prerecordinglist').attr("disabled", "disabled"); }else{ $(this).parent('td').parent('tr').find('.prerecordinglist').removeAttr("disabled"); } }); $(document).on('change', '.softvcalist',function(){ if($(this).parents('.mains').length){ $(this).parent('td').parent('tr').next().find(".softvcalist option[value='0']").attr("selected", "selected"); } else { $(this).parent('td').parent('tr').prev().find(".softvcalist option[value='0']").attr("selected", "selected"); } }); $(document).on('change', '.mdsublist',function() { var parentrow = $(this).parent('td').parent('tr'); var prevrow = parentrow.prev(); if( $(this).val() == 1 || $(this).val() == 2 || $(this).val() == 3 ){ prevrow.find(".mdmainlist option[value='4']").removeAttr("disabled"); prevrow.find(".mdmainlist option[value='4']").attr("selected", "selected"); $(this).find("option[value='4']").attr("disabled", "disabled"); }else if( $(this).val() == 0 && prevrow.find(".mdmainlist").val() != 0){ prevrow.find(".mdmainlist option[value='0']").attr("selected", "selected"); } }); $(document).on('change', '.mdmainlist',function() { var parentrow = $(this).parent('td').parent('tr'); var nextrow = parentrow.next(); if( $(this).val() == 1 || $(this).val() == 2 || $(this).val() == 3 ){ nextrow.find(".mdsublist option[value='4']").removeAttr("disabled"); nextrow.find(".mdsublist option[value='4']").attr("selected", "selected"); $(this).find("option[value='4']").attr("disabled", "disabled"); }else if( $(this).val() == 0 && nextrow.find(".mdsublist").val() != 0){ nextrow.find(".mdsublist option[value='0']").attr("selected", "selected"); } }); $(document).on('change', '.substreamlist',function() { var parentrow = $(this).parent('td').parent('tr'); var prevrow = parentrow.prev(); if(this.value == 1){ parentrow.find("input,button,textarea,select").not(".substreamlist").prop("disabled", false); }else{ parentrow.find("input,button,textarea,select").not(".substreamlist").attr("disabled", "disabled"); if(prevrow.find(".mdmainlist option:selected").val() == "4"){ prevrow.find(".mdmainlist option[value='0']").attr("selected", "selected"); } } }); $(document).on('click','.estimator',function(){ var parentrow = $(this).parent('td').parent('tr'); if(parentrow.find(".substream").length){ var resolutionValue = parentrow.find(".subresolution option:selected").val(); var framerateValue = parentrow.find(".subframerate option:selected").val(); }else{ var resolutionValue = parentrow.find(".resolution option:selected").val(); var framerateValue = parentrow.find(".framerate option:selected").val(); } var compressionValue = parentrow.find(".compression option:selected").val(); var compressionResult; if(compressionValue == "H.264") compressionResult = 80; else if(compressionValue == "MPEG4") compressionResult = 100; else compressionResult = 350; var b = resolutionValue*framerateValue*compressionResult; parentrow.find(".bitrate > option").each(function() { if(this.value > b){ this.selected = true; return false; } }); }); function calcRound(value, precision) { var tmp = Math.pow( 10, precision ); return Math.round( value * tmp ) / tmp; } $(document).on('change', '#cpurecommendcheckbox', function (){ if($('#cpurecommendcheckbox').is(':checked')) { $('.cpuselect').css('display','none'); }else{ $('.cpuselect').css('display','table-row'); } }); $(document).on('change', '#editionrecommendcheckbox', function (){ if($('#editionrecommendcheckbox').is(':checked')) { $('.editionselect').css('display','none'); }else{ $('.editionselect').css('display','table-row'); } }); $(document).on('change', '.cpumanufacturerslist',function () { var columnNo = $(this).closest("td").index() + 1; if($(this).closest("td").hasClass('evacpu')){ PopulateSeries(columnNo,4); }else{ PopulateSeries(columnNo); } }); $(document).on('change', '.cpuserieslist', function () { var columnNo = $(this).closest("td").index() + 1; if($(this).closest("td").hasClass('evacpu')){ PopulateModels(columnNo,4); }else{ PopulateModels(columnNo); } }); $(document).on('change', '.gpuconfiglist', function () { var usageMode = $('#usagemode option:selected').val(); var gpuMode = $(this).val(); if(usageMode == 0){ PopulateManufacturers(4, gpuMode, EvoPhpUrl); PopulateManufacturers(2, 0, EvoPhpUrl); }else if(usageMode == 1){ PopulateManufacturers(2, gpuMode, EvoPhpUrl); PopulateManufacturers(4, 0, EvoPhpUrl); } else{ PopulateManufacturers(4, 0, EvoPhpUrl); PopulateManufacturers(2, 0, EvoPhpUrl); } }); function PopulateManufacturers(col, gpumode, phpurl) { try { $.ajax({ url: phpurl, type: "GET", data: "mode=manufacturers&gpumode=" + gpumode, dataType: "json", success: function (response) { $(".cputable").find("tr td:nth-child(" + col + ").cpumanufacturers").html(SelectGenerator(response,'cpumanufacturerslist',0)); PopulateSeries(col, gpumode); } }); } catch (err) { console.log(err); } } function PopulateSeries(columnNo, gpuMode = 0) { $.ajax({ url:EvoPhpUrl, type:"GET", data:"mode=cpuseries&manufacturer=" + $(".cputable").find("tr td:nth-child(" + columnNo + ") .cpumanufacturerslist").val() + "&gpumode=" + gpuMode, dataType:"json", success: function(response) { $(".cputable").find("tr td:nth-child(" + columnNo + ").cpuseries").html(SelectGenerator(response,'cpuserieslist',0)); PopulateModels(columnNo, gpuMode); }}); } function PopulateModels(columnNo, gpuMode = 0) { $.ajax({ url:EvoPhpUrl, type:"GET", data:"mode=cpumodels&series=" + $(".cputable").find("tr td:nth-child(" + columnNo + ") .cpuserieslist").val() + "&manufacturer=" + $(".cputable").find("tr td:nth-child(" + columnNo + ") .cpumanufacturerslist").val() + "&gpumode=" + gpuMode, dataType:"json", success: function(response) { $(".cputable").find("tr td:nth-child(" + columnNo + ").cpumodels").html(SelectGenerator(response,'cpumodelslist',0)); }}); } function SelectGenerator(res, name, defaultselected, disabled) { disabled = typeof(disabled) != 'undefined' ? 'disabled' : ''; var selectTemplate = ''; return selectTemplate; } function FillRow(){ var lastrow = $("#calc tr:last"); lastrow.prev().children("td.tstreams").html("

Main Stream

"); lastrow.children("td.tstreams").html(SelectGenerator(Resources['substream'],'substreamlist')); lastrow.prev().children("td.tcompr").html(SelectGenerator(Resources['compression'],'compressionlist estimator')); lastrow.children("td.tcompr").html(SelectGenerator(Resources['compression'],'compressionlist estimator')); lastrow.prev().children("td.tres").html(SelectGenerator(Resources['resolution'],'resolutionlist estimator')); lastrow.children("td.tres").html(SelectGenerator(Resources['resolution'],'resolutionlist estimator')); lastrow.prev().children("td.tfps").html(SelectGenerator(Resources['framerate'],'frameratelist estimator')); lastrow.children("td.tfps").html(SelectGenerator(Resources['framerate'],'frameratelist estimator')); lastrow.prev().children("td.tbit").html(SelectGenerator(Resources['bitrate'],'bitratelist')); lastrow.children("td.tbit").html(SelectGenerator(Resources['bitrate'],'bitratelist')); lastrow.prev().children("td.testim").html(""); lastrow.children("td.testim").html(""); lastrow.prev().children("td.tmds").html(SelectGenerator(Resources['motiondetectormain'],'mdmainlist')); lastrow.children("td.tmds").html(SelectGenerator(Resources['motiondetectorsub'],'mdsublist')); lastrow.prev().children("td.teva").html(SelectGenerator(Resources['onnx_models'],'onnx_models_list')); lastrow.children("td.teva").html(SelectGenerator(Resources['onnx_models'],'onnx_models_list')); lastrow.prev().children("td.tevamod").html(SelectGenerator(Resources['onnx_accuracy_levels'],'onnx_accuracy_levels_list')); lastrow.children("td.tevamod").html(SelectGenerator(Resources['onnx_accuracy_levels'],'onnx_accuracy_levels_list')); lastrow.prev().children("td.tevaint").html(SelectGenerator(Resources['onnx_detection_intervals'],'onnx_detection_intervals_list')); lastrow.children("td.tevaint").html(SelectGenerator(Resources['onnx_detection_intervals'],'onnx_detection_intervals_list')); lastrow.prev().children("td.trect").html(SelectGenerator(Resources['recordingevents'],'recordingeventslist')); lastrow.children("td.trect").html(SelectGenerator(Resources['recordingevents'],'recordingeventslist')); lastrow.prev().children("td.tprerec").html(SelectGenerator(Resources['prerecording'],'prerecordinglist')); lastrow.children("td.tprerec").html(SelectGenerator(Resources['prerecording'],'prerecordinglist')); lastrow.prev().children("td.tnomofps").html(SelectGenerator(Resources['frameratenomotion'],'fpsnomotionlist')); lastrow.children("td.tnomofps").html(SelectGenerator(Resources['frameratenomotion'],'fpsnomotionlist')); lastrow.prev().children("td.tstoreday").html(''); lastrow.children("td.tstoreday").html(''); lastrow.prev().children("td.tbit").html(SelectGenerator(Resources['bitrate'],'bitratelist')); lastrow.children("td.tbit").html(SelectGenerator(Resources['bitrate'],'bitratelist')); lastrow.find("input,button,textarea,select").not(".substreamlist").attr("disabled", "disabled"); };