{% load switch %} {% switch code %} {% case "html" %} {% for val in values %} {% endfor %} {% case "tag_update_func" %} function UpdateToggle(object_id, tag_name, description, value, values) { if (!skup_update) { if (isNaN(value)) { value = "?"; } else { 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++; } } $("#" + object_id + " > input[name=\"curr_index\"]").val(valIndex); } $("#" + object_id + " > .value").val(value).removeClass("active"); SetObjectTitle($("#" + object_id + " > .value"), tag_name, description); } } function ToggleValue(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 + " > .value").val(value).addClass("active"); } {% endif %} } {% case "tag_update_code" %} UpdateToggle("{{ id }}", "{{ var }}", descriptions["{{ var }}"], vars["{{ var }}"], {{ change_values|safe }}); {% case "init_jq_binding" %} $(".cybro_{{ type }} > button").click( function() { var parent = $(this).parent(); var id = $(parent).attr("id"); var prop = GetObjectProperties(id); ToggleValue(id, prop["tag"], parseInt(prop["curr_index"]), parseInt(prop["max_index"])); return false; } ); {% endswitch %}