diff options
Diffstat (limited to 'html_server/templates')
-rw-r--r-- | html_server/templates/base.html | 54 | ||||
-rw-r--r-- | html_server/templates/property_info.html | 30 | ||||
-rw-r--r-- | html_server/templates/register_info.html | 145 | ||||
-rw-r--r-- | html_server/templates/registers/table_cell.html | 99 | ||||
-rw-r--r-- | html_server/templates/registers/table_header.html | 9 | ||||
-rw-r--r-- | html_server/templates/registers/table_scripts.html | 42 | ||||
-rw-r--r-- | html_server/templates/registers_list.html | 24 |
7 files changed, 206 insertions, 197 deletions
diff --git a/html_server/templates/base.html b/html_server/templates/base.html index 639dc00..39f8d00 100644 --- a/html_server/templates/base.html +++ b/html_server/templates/base.html @@ -58,6 +58,37 @@ function createRegistersList() { function parseJsonRegisterList(json) { + function loadRegistersList(bank) { + var pathToGetRegisterList = "{{ url_for('get_registers_list') }}" + var completePath = pathToGetRegisterList + '?bank=' + bank + + $("#reg_info_place").load(completePath) + } + + function loadRegisterInfo(bank, name) { + var pathToGetRegister = "{{ url_for('get_register_info') }}" + var completePath = pathToGetRegister + '?bank=' + bank + + '&name=' + name + + $("#reg_info_place").load(completePath) + } + + function setRegisterField(id, bank, name) { + + var itemId = bank + "_" + name + var func = function(){loadRegisterInfo(bank, name)} + + regTree.insertNewItem(id, itemId, name, func) + regTree.closeAllItems() + } + + function setbankField(bank) { + + var func = function(){loadRegistersList(bank)} + regTree.insertNewItem(0, bank, bank, func); + regTree.closeAllItems() + } + checkError(json) if(json.lenght <= 0) return @@ -86,28 +117,12 @@ } if(!created) { - regTree.insertNewItem(0, json[i].bank, json[i].bank, 0); + setbankField(json[i].bank ) created = 1 } //insert register info to bank - function loadRegisterInfo(bank, name) { - var pathToGetProperty = "{{ url_for('get_register_info') }}" - var completePath = pathToGetProperty + '?bank=' + bank + - '&name=' + name - - $("#reg_info_place").load(completePath) - } - - function setRegisterField(id, bank, name) { - - var itemId = bank + "_" + name - var func = function(){loadRegisterInfo(bank, name)} - - regTree.insertNewItem(id, itemId, name, func) - regTree.closeAllItems() - } setRegisterField(json[i].bank, json[i].bank, json[i].name) } @@ -121,12 +136,12 @@ function doOnLoad() { propsTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); - propsTree.setImagePath("codebase/imgs/dhxtree_skyblue/"); + propsTree.setImagePath("{{ url_for('static', filename='codebase/imgs/dhxtree_skyblue/') }}"); //generating properties list createPropertyTree('', 0) regTree = new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0,0,0,0,'SELECT') - regTree.setImagePath("codebase/imgs/dhxtree_skyblue/"); + regTree.setImagePath("{{ url_for('static', filename='codebase/imgs/dhxtree_skyblue/') }}"); createRegistersList() } </script> @@ -137,7 +152,6 @@ <h2>Device {{ device }} model={{ model }} control page </h2> </div> {% endblock %} - <style> .tabs > div, .tabs > input { display: none; } diff --git a/html_server/templates/property_info.html b/html_server/templates/property_info.html index ce974ac..4e7c92f 100644 --- a/html_server/templates/property_info.html +++ b/html_server/templates/property_info.html @@ -12,14 +12,14 @@ $.getJSON(completePath, function(json){ checkError(json) - var valFieldId = "#actVal"+prop.split('/').join("_") - $(valFieldId).text(json.value) + var valFieldId = "#set_val_" + prop.split('/').join("_") + $(valFieldId).val(json.value) }) } function setProperty(prop) { - var value = document.getElementById("set_val_" + prop).value; + var value = document.getElementById("set_val_" + prop.split('/').join("_")).value; if(value == "") return @@ -34,7 +34,7 @@ }) }; </script> - + <table class="infoTable"> <tr class="infoTable"> <td class="infoTable">Name</td> @@ -55,24 +55,22 @@ </td> <td class="infoTable"> <table> - <tr> - <td id = "actVal{{ property.path.replace('/', '_') }}" class="infoTable"> - {{ value }} - </td> - {% if 'R' in property.mode %} - <td> - <input type="button" value="update" style="width:100%;height:100%" onclick="updateProperty('{{ property.path }}')"> - </td> - {% endif %} - </tr> - {% if 'W' in property.mode %} + {% if 'R' in property.mode %} <tr> <td> - <input type="text" name="set_val_{{ property.path }}" id="set_val_{{ property.path }}" value="" /> + <input type="text" + name="set_val_{{ property.path.replace('/', '_') }}" + id="set_val_{{ property.path.replace('/', '_') }}" + value="{{ value[property.path] }}" /> </td> + {% if 'W' in property.mode %} <td> <input type="button" value="set" style="width:100%;height:100%" onclick="setProperty('{{ property.path }}')"> </td> + {% endif %} + <td> + <input type="button" value="update" style="width:100%;height:100%" onclick="updateProperty('{{ property.path }}')"> + </td> </tr> {% endif %} </table> diff --git a/html_server/templates/register_info.html b/html_server/templates/register_info.html index 1118dbf..3efebd7 100644 --- a/html_server/templates/register_info.html +++ b/html_server/templates/register_info.html @@ -1,148 +1,9 @@ {% block content %} -{% if standalone %} -<script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script> -<script src="{{ url_for('static', filename='check_err.js') }}"></script> -{% endif %} - -<script> - function updateRegister(bank, name) { - var pathToReadRegister = "{{ url_for('read_register_json') }}" - var completePath = pathToReadRegister + '?bank=' + bank + - '&name=' + name - - $.getJSON(completePath, function(json){ - checkError(json) - $("#actVal").text(json.value) - }) - } - - function writeRegister(bank, name) - { - var value = document.getElementById("set_val_box").value; - if(value == "") - return - - var pathToReadRegister = "{{ url_for('write_register_json') }}" - var completePath = pathToReadRegister + '?bank=' + bank + - '&name=' + name + '&val=' + value; - - $.getJSON(completePath, - function(json) { - checkError(json) - updateRegister(bank, name) - }) - }; -</script> +{% include 'registers/table_scripts.html' %} <table class="infoTable"> - <tr class="infoTable"> - {% if 'description' in register %} - <td class="infoTable"> Description </td> - {% endif %} - <td class="infoTable"> Value </td> - <td class="infoTable">Default value</td> - <td class="infoTable">Bank</td> - <td class="infoTable">Mode</td> - {% if 'range' in register %} - <td class="infoTable">Range</td> - {% endif %} - {% if 'values' in register %} - <td class="infoTable">Values</td> - {% endif %} - </tr> - - <tr class="infoTable"> - {% if 'description' in register %} - <td class="infoTable"> {{ register.description }} </td> - {% endif %} - <td class="infoTable"> - <table> - <tr class="infoTable"> - <td id="actVal" class="infoTable"> {{ value }} </td> - {% if 'R' in register.mode %} - <td> - <input type="button" value="update" - style="width:100%;height:100%" - onclick="updateRegister('{{ register.bank }}', '{{ register.name }}')"> - </td> - {% endif %} - </tr> - {% if 'W' in register.mode %} - <tr class="infoTable"> - <td> - <input type="text" name="set_val_box" id="set_val_box" value="" /> - </td> - <td> - <input type="button" value="set" - style="width:100%;height:100%" - onclick="writeRegister('{{ register.bank }}', '{{ register.name }}')"> - </td> - </tr> - {% endif %} - </table> - </td> - <td class="infoTable">{{ register.defvalue }}</td> - <td class="infoTable">{{ register.bank }}</td> - <td class="infoTable"> - <ul> - {% for m in register.mode %} - {{ m + '; '}} - {% endfor %} - </ul> - </td> - {% if 'range' in register %} - <td class="infoTable"> - <table> - <tr class="infoTable"> - <td class="infoTable"> min </td> - <td class="infoTable"> max </td> - </tr> - <tr class="infoTable"> - <td class="infoTable"> {{ register.range.min }} </td> - <td class="infoTable"> {{ register.range.max }} </td> - </tr> - </table> - </td> - {% endif %} - {% if 'values' in register %} - <td class="infoTable"> - <table> - <tr> - {% for v in register['values'] %} - <td> - <table> - {% if 'name' in v %} - <tr class="infoTable"> - <td class="infoTable"> Name </td> - <td class="infoTable"> {{v.name}} </td> - </tr> - {% endif %} - {% if 'description' in v %} - <tr class="infoTable"> - <td class="infoTable"> Description </td> - <td class="infoTable"> {{ v.description }} </td> - </tr> - {% endif %} - <tr class="infoTable"> - <td class="infoTable"> Min </td> - <td class="infoTable"> {{ v.min }} </td> - </tr> - <tr class="infoTable"> - <td class="infoTable"> Max </td> - <td class="infoTable"> {{ v.max }} </td> - </tr> - <tr class="infoTable"> - <td class="infoTable"> Value </td> - <td class="infoTable"> {{ v.value }} </td> - </tr> - </table> - </td> - {% endfor %} - </tr> - </table> - </td> - {% endif %} - </tr> + {% include 'registers/table_header.html' %} + {% include 'registers/table_cell.html' %} </table> {% endblock %} diff --git a/html_server/templates/registers/table_cell.html b/html_server/templates/registers/table_cell.html new file mode 100644 index 0000000..690f052 --- /dev/null +++ b/html_server/templates/registers/table_cell.html @@ -0,0 +1,99 @@ +<tr class="infoTable"> + {% if 'description' in register %} + <td class="infoTable"> {{ register.description }} </td> + {% else %} + <td class="infoTable"> </td> + {% endif %} + <td class="infoTable"> + <table> + {% if 'R' in register.mode %} + <tr class="infoTable"> + <td> + <input type="text" + name="set_val_box_{{ register.bank }}_{{ register.name }}" + id="set_val_box_{{ register.bank }}_{{ register.name }}" + value="{{ value[register.name] }}" /> + </td> + {% if 'W' in register.mode %} + <td> + <input type="button" value="set" + style="width:100%;height:100%" + onclick="writeRegister('{{ register.bank }}', '{{ register.name }}')"> + </td> + {% endif %} + <td> + <input type="button" value="update" + style="width:100%;height:100%" + onclick="updateRegister('{{ register.bank }}', '{{ register.name }}')"> + </td> + </tr> + {% endif %} + </table> + </td> + <td class="infoTable">{{ register.defvalue }}</td> + <td class="infoTable">{{ register.bank }}</td> + <td class="infoTable"> + <ul> + {% for m in register.mode %} + {{ m + '; '}} + {% endfor %} + </ul> + </td> + {% if 'range' in register %} + <td class="infoTable"> + <table> + <tr class="infoTable"> + <td class="infoTable"> min </td> + <td class="infoTable"> max </td> + </tr> + <tr class="infoTable"> + <td class="infoTable"> {{ register.range.min }} </td> + <td class="infoTable"> {{ register.range.max }} </td> + </tr> + </table> + </td> + {% else %} + <td class="infoTable"> </td> + {% endif %} + {% if 'values' in register %} + <td class="infoTable"> + <table> + <tr> + {% for v in register['values'] %} + <td> + <table> + {% if 'name' in v %} + <tr class="infoTable"> + <td class="infoTable"> Name </td> + <td class="infoTable"> {{v.name}} </td> + </tr> + {% endif %} + {% if 'description' in v %} + <tr class="infoTable"> + <td class="infoTable"> Description </td> + <td class="infoTable"> {{ v.description }} </td> + </tr> + {% endif %} + <tr class="infoTable"> + <td class="infoTable"> Min </td> + <td class="infoTable"> {{ v.min }} </td> + </tr> + <tr class="infoTable"> + <td class="infoTable"> Max </td> + <td class="infoTable"> {{ v.max }} </td> + </tr> + <tr class="infoTable"> + <td class="infoTable"> Value </td> + <td class="infoTable"> {{ v.value }} </td> + </tr> + </table> + </td> + {% endfor %} + </tr> + </table> + </td> + {% else %} + <td class="infoTable"> </td> + {% endif %} +</tr> + diff --git a/html_server/templates/registers/table_header.html b/html_server/templates/registers/table_header.html new file mode 100644 index 0000000..f96ec20 --- /dev/null +++ b/html_server/templates/registers/table_header.html @@ -0,0 +1,9 @@ +<tr class="infoTable"> + <td class="infoTable"> Description </td> + <td class="infoTable"> Value </td> + <td class="infoTable">Default value</td> + <td class="infoTable">Bank</td> + <td class="infoTable">Mode</td> + <td class="infoTable">Range</td> + <td class="infoTable">Values</td> +</tr> diff --git a/html_server/templates/registers/table_scripts.html b/html_server/templates/registers/table_scripts.html new file mode 100644 index 0000000..017c910 --- /dev/null +++ b/html_server/templates/registers/table_scripts.html @@ -0,0 +1,42 @@ +{% if standalone %} +<script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script> +<script src="{{ url_for('static', filename='check_err.js') }}"></script> +{% endif %} + +<script> + /* + $("#set_val_box").keyup(function(event){ + if(event.keyCode == 13){ + $("#set_val_button").click(); + } + }); + */ + + function updateRegister(bank, name) { + var pathToReadRegister = "{{ url_for('read_register_json') }}" + var completePath = pathToReadRegister + '?bank=' + bank + + '&name=' + name + + $.getJSON(completePath, function(json){ + checkError(json) + $("#set_val_box_" + bank + "_" + name).val(json.value) + }) + } + + function writeRegister(bank, name) + { + var value = document.getElementById("set_val_box_" + bank + "_" + name).value; + if(value == "") + return + + var pathToReadRegister = "{{ url_for('write_register_json') }}" + var completePath = pathToReadRegister + '?bank=' + bank + + '&name=' + name + '&val=' + value; + + $.getJSON(completePath, + function(json) { + checkError(json) + updateRegister(bank, name) + }) + }; +</script> diff --git a/html_server/templates/registers_list.html b/html_server/templates/registers_list.html index 199475b..26a6721 100644 --- a/html_server/templates/registers_list.html +++ b/html_server/templates/registers_list.html @@ -1,24 +1,10 @@ -{% extends "base.html" %} -{% block title %}Registers list{% endblock %} -{% block info %} -<h1>List of aviable registers</h1> -{% endblock %} - {% block content %} -<table border="1" style="width:100%"> - <tr> - <th>Name</th> - <th>Description</th> - </tr> +{% include 'registers/table_scripts.html' %} + +<table class="infoTable"> +{% include 'registers/table_header.html' %} {% for register in registers %} - <tr> - <td><a href="{{ url_for('get_register_info', bank=register.bank, name=register.name) }}">{{ register.name }}</td> - {% if 'description' in register %} - <td>{{ register.description }}</td> - {% else %} - <td></td> - {% endif %} - </tr> + {% include 'registers/table_cell.html' %} {% endfor %} </table> {% endblock %} |