1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}Device {{ device }}{% endblock %}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='codebase/dhtmlx.css') }}"/>
<script type=text/javascript src="{{ url_for('static', filename='jquery-2.2.1.js') }}"></script>
<script src="{{ url_for('static', filename='codebase/dhtmlx.js') }}"></script>
<script src="{{ url_for('static', filename='check_err.js') }}"></script>
<script>
var propsTree
function createPropertyTree(branch, id) {
function getPropertyItemsOnLevel(branch, id) {
pathToProperties = "{{ url_for('get_property_list_json') }}"
completePath = pathToProperties + '?branch=' + branch
$.getJSON(completePath,
function(json) {
checkError(json)
parsePropertyItems(json, branch, id)
});
}
function parsePropertyItems(json, branch, id) {
function loadPropertyInfo(branch) {
var pathToProperties = "{{ url_for('get_property_list') }}"
var completePath = pathToProperties + '?branch=' + branch
$("#prop_info_place").load(completePath)
}
function setPropertyField(id, name, branch) {
var func = function(){loadPropertyInfo(branch)}
propsTree.insertNewItem(id, branch,
name,
func);
propsTree.closeAllItems()
}
for(var i = 0; i < json.length; i++) {
setPropertyField(id, json[i].name, json[i].path)
if(json[i].flags.indexOf("childs") != -1)
getPropertyItemsOnLevel(json[i].path, json[i].path)
}
}
getPropertyItemsOnLevel(branch, id)
}
var regTree
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
//sort registers by bank
function compareRegistersByBank(a,b) {
if (a.bank < b.bank)
return -1;
else if (a.bank > b.bank)
return 1;
else
return 0;
}
json.sort(compareRegistersByBank)
//create bank dirs
var curBankName = json[0].bank
var created = 0
for(var i = 0; i < json.length; i++) {
//create new bank tab if it has not created already
if(json[i].bank != curBankName) {
curBankName = json[i].bank
created = 0
}
if(!created) {
setbankField(json[i].bank )
created = 1
}
//insert register info to bank
setRegisterField(json[i].bank, json[i].bank, json[i].name)
}
}
//get registers json list
getRegistersListPath = "{{ url_for('get_registers_list_json') }}"
$.getJSON(getRegistersListPath, parseJsonRegisterList);
}
function doOnLoad()
{
propsTree = new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
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("{{ url_for('static', filename='codebase/imgs/dhxtree_skyblue/') }}");
createRegistersList()
}
</script>
</head>
<body onload="doOnLoad()">
{% block info %}
<div class="block1" >
<h2>Device {{ device }} model={{ model }} control page </h2>
</div>
{% endblock %}
<style>
.tabs > div, .tabs > input { display: none; }
.tabs label {
padding: 5px;
border: 1px solid #aaa;
line-height: 28px;
cursor: pointer;
position: relative;
bottom: 1px;
background: #fff;
}
.tabs input[type="radio"]:checked + label { border-bottom: 2px solid #fff; }
.tabs > input:nth-of-type(1):checked ~ div:nth-of-type(1),
.tabs > input:nth-of-type(2):checked ~ div:nth-of-type(2) {
display: block;
padding: 5px;
border:
1px solid #aaa;
}
.tree {
height: 85vh;
padding: 5px;
border: 1px solid #aaa;
line-height: 28px;
cursor: pointer;
position: relative;
bottom: 1px;
background: #fff;
overflow:auto;
}
.infoTable {
padding: 2px;
border: 1px solid #aaa;
line-height: 28px;
cursor: pointer;
position: relative;
background: #fff;
overflow:auto;
bottom: 1px;
text-align: left;
}
</style>
<div class="tabs">
<input type="radio" name="current" checked="checked" id="props_id"/>
<label for="props_id">Properties</label>
<input type="radio" name="current" id="labels_id"/>
<label for="labels_id">Registers</label>
<div>
<table>
<tr>
<td valign="top">
<div id="treeboxbox_tree" class = "tree"></div>
</td>
<td valign="top" id="prop_info_place" />
</tr>
</table>
</div>
<div>
<table>
<tr>
<td valign="top">
<div id="treeboxbox_tree2" class="tree"></div>
</td>
<td valign="top" id="reg_info_place" />
</tr>
</table>
</div>
</div>
{% block content %}
{% endblock %}
</body>
</html>
|