{% load switch %} {% switch code %} {% case "html" %} {% case "tag_update_func" %} function UpdateSubmit(object_id, tag_name, description, value, decimals) { if (!isNaN(value)) value = (value / Math.pow(10, decimals)).toFixed(decimals); else value = "?"; $("#" + object_id + " .read_value").val(value); $("#" + object_id + " .read_value").removeClass("active"); SetObjectTitle($("#" + object_id + " .read_value"), tag_name, description); } function SubmitValue(object_id, cybro_var, min, max, decimals) { {% if rw_access %} skup_update = true; var input = $("#" + object_id + " > .value"); var value = $(input).val(); $(input).val(""); if (!isNaN(value) && value != "") { value = value * Math.pow(10, decimals); value = (value < min) ? min : (value > max) ? max : value; SetTagValue(cybro_var, value); value = (value / Math.pow(10,decimals)).toFixed(decimals); $("#" + object_id + " > .read_value").val(value).addClass("active"); } {% endif %} } {% case "tag_update_code" %} UpdateSubmit("{{ id }}", "{{ var }}", descriptions["{{ var }}"], vars["{{ var }}"], {{ decimals }}); {% case "init_jq_binding" %} $(".cybro_{{ type }} > button").click( function() { var parent = $(this).parent(); var id = $(parent).attr("id"); var prop = GetObjectProperties(id); SubmitValue(id, prop["tag"], parseInt(prop["min"]), parseInt(prop["max"]), parseInt(prop["decimals"])); return false; } ); {% endswitch %}