{% load switch %} {% switch code %} {% case "html" %} {% ifequal action "1" %} {% if rw_access %} {% for val in values %} {% endfor %} {% else %} {% endif %} {% else %} {% endifequal %} {% case "tag_update_func" %} function UpdateTextlist(object_id, tag_name, description, value, texts, values) { if (!skup_update) { var txt = ""; if (!isNaN(value)) { var val = parseFloat(value); var valIndex = 0; for (var i = 0; i < values.length; i++) { valIndex = i; if (values[i] > val) { break; } } if (valIndex < values.length) { if (values[valIndex] <= val) { valIndex++; } } if (valIndex < texts.length) { txt = texts[valIndex]; } $("#" + object_id + " > input[name=\"curr_index\"]").val(valIndex); } $("#" + object_id + " > .read_value").html(txt); $("#" + object_id + " > .read_value").removeClass("active"); SetObjectTitle($("#" + object_id + " > .read_value"), tag_name, description); } } function TextlistSubmitValue(object_id, cybro_var, curr_index, max_index) { {% if rw_access %} skup_update = true; var next_index = curr_index + 1; if (next_index > max_index) { next_index = 0; } var value = GetObjectProperties(object_id)["value_" + next_index]; $("#" + object_id + " > input[name=\"curr_index\"]").val(next_index); if (!isNaN(value)) { SetTagValue(cybro_var, value); $("#" + object_id + " > .read_value").addClass("active"); } {% endif %} } {% case "tag_update_code" %} UpdateTextlist("{{ id }}", "{{ var }}", descriptions["{{ var }}"], vars["{{ var }}"], {{ texts|safe }}, {{ change_values|safe }}); {% case "init_jq_binding" %} $(".cybro_{{ type }} > .read_value").click( function() { var parent = $(this).parent(); var id = $(parent).attr("id"); var prop = GetObjectProperties(id); if (prop["tag"] != null && prop["tag"].length > 0) { TextlistSubmitValue(id, prop["tag"], parseInt(prop["curr_index"]), parseInt(prop["max_index"])); } return false; } ); {% endswitch %}