diff --git a/css/style.css b/css/style.css
index c293e59..2a4ba39 100644
--- a/css/style.css
+++ b/css/style.css
@@ -1,3 +1,3 @@
/* this file is left blank on purpose, if developer can't find classes he needs in framework, he can customize his
app adding his own styles here
- */
\ No newline at end of file
+ */
diff --git a/index.html b/index.html
index 571ea1e..9d07a09 100644
--- a/index.html
+++ b/index.html
@@ -11,12 +11,14 @@
+
diff --git a/js/app.js b/js/app.js
index c984507..0a2104e 100644
--- a/js/app.js
+++ b/js/app.js
@@ -29,25 +29,72 @@ function parseWidgets(widgets) {
widgets.forEach( function(wdg) {
switch (wdg.type) {
case "Frame":
- s+=""+wdg.label+"
";
+ s+='
'+wdg.label+"";
if (("widgets" in wdg) && wdg.widgets.length >0){
s+=parseWidgets(wdg.widgets);
}
- s+="";
+ s+="
";
break;
case "Switch":
+ if (wdg.mappings.length === 0) {
+ s+=createElement(wdg.label,
+ wdg.item.name,
+ wdg.item.link,
+ ''
+ );
+
+//
+//
+// Single Toggle
+//
+//
+//
+// Toggle state
+//
+//
+ } else if (wdg.mappings.length === 1) {
+ s+=createElement(wdg.label,
+ wdg.item.name,
+ wdg.item.link,
+ '');
+ }
break;
+
case "Slider":
var value=0;
- if (wdg.item.state !== null){value = wdg.item.state;}
- s+=createElement(wdg.label, wdg.item.name,'');
+ if (wdg.item.state !== null) {
+ value = wdg.item.state;
+ }
+ s+=createElement(wdg.label,
+ wdg.item.name,
+ wdg.item.link,
+ '');
break;
+
case "Selection":
- s+="Selection
";
+// var items = '';
+// wdg.mappings.forEach(function(entry) {
+// items += '';
+// });
+// s+= createElement(wdg.label,
+// wdg.item.name,
+// wdg.item.link,
+// ''+items+'
');
break;
+
case "Text":
- s+=createElement(wdg.label,'','');
+ s+=createElement(wdg.label,'','','');
break;
default:
@@ -59,12 +106,38 @@ function parseWidgets(widgets) {
return s;
}
-function createElement(label, id, inner){
- return ''+label+''+inner+'
';
+function createElement(label, id, link, inner){
+ var inElement = '';
+ if (link != '' && id != '' && inner != ''){
+ inElement=''+inner+'
';
+ }
+ return ''+label+''+inElement+'
';
}
+function updateToggle(event) {
+ var item = event.target.parentElement.parentElement.getAttribute('data-link');
+ var value = event.target.checked === true ? "ON" : "OFF";
+ updateItem(item,value);
+}
-function loadgui() {
+function updateSelector(event) {
+ var s=3;
+ return true;
+}
+
+function updateSimple(event) {
+ var item = event.target.parentElement.getAttribute('data-link');
+ var value = event.target.value;
+ updateItem(item,value);
+}
+
+function updateItem(item,value) {
+ var client = new XMLHttpRequest();
+ client.open('POST', item, true);
+ client.send(value.toString());
+}
+
+function loadgui() {
var client = new XMLHttpRequest();
client.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
@@ -74,4 +147,5 @@ function loadgui() {
};
client.open('GET', 'http://habctrl:8080/rest/sitemaps/default', true);
client.send();
-}
\ No newline at end of file
+}
+