{% if code == "html" %} {% elif code == "tag_update_func" %} function UpdateIncDec(object_id, tag_name, description, value) { if (!skup_update) { let prop = GetObjectProperties(object_id); if (!isNaN(value)) { if (prop["decimals"] != "0") { if (Number.isInteger(value)) { value = (value / Math.pow(10, prop["decimals"])).toFixed(prop["decimals"]); } else { value = Number(value).toFixed(prop["decimals"]); } } } else { value = "?"; } $("#" + object_id + " > .value").val(value).removeClass("active"); SetObjectTitle($("#" + object_id + " .value"), tag_name, description); } } function IncDecChangeValue(object_id, cybro_var, min, max, step, decimals) { {% if rw_access %} skup_update = true; let input = $("#" + object_id + " > .value"); let value = $(input).val(); if (!isNaN(value)) { let istep = step * Math.pow(10, decimals); value = value * Math.pow(10, decimals) + istep; value -= value % istep; value = (value / Math.pow(10, decimals)).toFixed(decimals); value = (value < min) ? min : (value > max) ? max : value; SetTagValue(cybro_var, value); $(input).val(value).addClass("active"); } {% endif %} } {% elif code == "tag_update_code" %} UpdateIncDec("{{ id }}", "{{ var }}", descriptions["{{ var }}"], vars["{{ var }}"]); {% elif code == "init_jq_binding" %} $(".cybro_{{ type }} > .inc").click(function(){ let parent = $(this).parent(); let id = $(parent).attr("id"); let prop = GetObjectProperties(id); IncDecChangeValue(id, prop["tag"], parseInt(prop["min"]), parseInt(prop["max"]), Number(prop["step"]), parseInt(prop["decimals"])); return false; }); $(".cybro_{{ type }} > .dec").click(function() { let parent = $(this).parent(); let id = $(parent).attr("id"); let prop = GetObjectProperties(id); IncDecChangeValue(id, prop["tag"], parseInt(prop["min"]), parseInt(prop["max"]), - Number(prop["step"]), parseInt(prop["decimals"])); return false; }); {% endif %}