Parcourir la source

added a header string.

- this header string is not binded by any data entry.

Signed-off-by: Nicholas Tan Jerome <nicholas.jerome@kit.edu>
Nicholas Tan Jerome il y a 8 ans
Parent
commit
102a600740
3 fichiers modifiés avec 107 ajouts et 13 suppressions
  1. 92 8
      designer.html
  2. 10 0
      status.html
  3. 5 5
      style.yaml

+ 92 - 8
designer.html

@@ -45,6 +45,15 @@
 {% else %}
 {% end %}
 
+{% if data['style'][key]['type'] == "header" %}
+<div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
+    data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
+    height:{{ data['style'][key]['height'] }}px;' data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
+<p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span></p>
+</div>
+{% else %}
+{% end %}
+
 
 {% end %}
 
@@ -56,8 +65,8 @@
 <div id="tool-btn">
 <span class="info">Variable</span>
 <select id="varname" style="font-size:16pt;">
-  {% for key in data['cache'] %}
-  <option value={{data['cache'][key]}}>{{key}}</option>
+  {% for key in data['style'] %}
+  <option value={{data['style'][key]}}>{{key}}</option>
   {% end %}
 </select>
 <span class="info">Type</span>
@@ -65,6 +74,7 @@
   <option value="data">data</option>
   <option value="ventil">ventil</option>
   <option value="integer-to-string">integer-to-string</option>
+  <option value="header">header</option>
 </select>
 <br /><br />
 <span class="info">Title</span>
@@ -126,12 +136,14 @@ function showhide() {
 function add() {
     console.log("add element");
     title_text = $("#elem_title_text").val();
+    title_text = title_text.trim();
     title_color = "#000000";
     //title_color = $("#elem_title_color").val();
     title_size = $("#elem_title_size").val();
     title_style = $("#elem_title_style option:selected").val();
     
     unit_text = $("#elem_unit_text").val();
+    unit_text = unit_text.trim();
     unit_color = "#000";
     //unit_color = $("#elem_unit_color").val();
     unit_size = $("#elem_unit_size").val();
@@ -149,7 +161,8 @@ function add() {
     console.log(title_text, unit_text, varname, varval, vartype);
     
     
-    if($("#" + varname).length == 0) {
+    if(($("#" + varname).length == 0) || (vartype="header")) {
+        console.log("Must enter here");
         if (vartype == "data") {
             html_text = "<div " +
                     "style='position: absolute; " +
@@ -174,6 +187,26 @@ function add() {
                     "class='varval'>" + parseFloat(varval).toFixed(2) + " </span>" + 
                     "<span class='unit_title'>" + unit_text + "</span></p>" +
         	    "</div>";
+        } else if (vartype == "header") {
+            varname = "header_" + title_text.replace(/\s+/g, '-').toLowerCase();
+            html_text = "<div " +
+                    "style='position: absolute; " +
+                           "top:0; " +
+                           "left:0;' " +
+                    "class='varbox' " + 
+                    "id='" + varname +
+                    "' data-type='" + vartype +
+                    "' data-cond='" + data_condition +
+                    "' data-lesser='" + data_lesser + 
+ 		            "' data-larger='" + data_larger + 
+                    "'>" +
+                    "<p>" +
+                    "<span style='color: " + title_color + ";" + 
+                    "font-size:" + title_size + "px; " + 
+                    "font-weight: " + title_style + ";' " + 
+                    "class='title'>" + title_text +
+                    " </span></p>" + 
+        	    "</div>";
         } else if (vartype == "ventil") {
             var token = JSON.parse(unit_text);
             data_on = token["on"];
@@ -196,7 +229,6 @@ function add() {
                     "src='{{ static_url("ventil_inactive.png") }}'></img>" +
         	    "</div>";	    
 	} else if (vartype == "integer-to-string") {
-            console.log("Inside I2S");
             html_text = "<div " +
                     "style='position: absolute; " +
                            "top:0; " +
@@ -219,7 +251,9 @@ function add() {
                     "class='varval'>Standard Operation </span>" + 
                     "</p>" +
         	    "</div>";
-	}
+        }
+        console.log("Adding element");
+        console.log(html_text);
         $( "body" ).append(html_text);
         $("#"+varname).draggable();
         $("#"+varname).resizable(); 
@@ -241,7 +275,7 @@ function mysave(data) {
     for(key in data) {
         var tmp = {};
         console.log(key);
-        if($("#" + key).length > 0) {
+        if($("#" + key).length > 0 ) {
             tmp["left"] = $("#"+key).css("left");
             tmp["top"] = $("#"+key).css("top");
             tmp["width"] = $("#"+key).width();
@@ -269,6 +303,26 @@ function mysave(data) {
 
             	tmp["header"] = header;
             	tmp["unit"] = unit;
+            } else if ( $("#"+key).attr("data-type") == "header" ) {
+            	//tmp["condition"] = $("#"+key).attr("data-cond");
+            	//tmp["lesser"] = $("#"+key).attr("data-lesser");
+            	//tmp["larger"] = $("#"+key).attr("data-larger");
+            	//tmp["min"] = $("#"+key).attr("min");
+           	    //tmp["max"] = $("#"+key).attr("max");
+            	header = {};
+            	header["title"] = $(".title", "#"+key).text();
+            	//header["color"] = $(".title", "#"+key).css("color");
+            	header["size"] = $(".title", "#"+key).css("font-size");
+            	header["weight"] = $(".title", "#"+key).css("font-weight");
+            
+            	//unit = {};
+            	//unit["title"] = $(".unit_title", "#"+key).text();
+            	//unit["color"] = $(".varval", "#"+key).css("color");
+            	//unit["size"] = $(".varval", "#"+key).css("font-size");
+            	//unit["weight"] = $(".varval", "#"+key).css("font-weight");
+
+            	tmp["header"] = header;
+            	//tmp["unit"] = unit;
             } else if ( $("#"+key).attr("data-type") == "ventil" ) {
             	tmp["on"] = $("#"+key).attr("data-on");
             	tmp["off"] = $("#"+key).attr("data-off");
@@ -294,8 +348,34 @@ function mysave(data) {
             position[key] = tmp;
         }
     }
-    console.log("Check here");
-    console.log(position);
+
+    $('[id^=header_]').each(function( index ) {
+        tmp = {};
+        var hkey = $( this ).attr('id');
+        tmp["left"] = $("#"+hkey).css("left");
+        tmp["top"] = $("#"+hkey).css("top");
+        tmp["width"] = $("#"+hkey).width();
+        tmp["height"] = $("#"+hkey).height();
+        tmp["type"] = $("#"+hkey).attr("data-type");
+
+        //tmp["condition"] = $("#"+hkey).attr("data-cond");
+        //tmp["lesser"] = $("#"+hkey).attr("data-lesser");
+        //tmp["larger"] = $("#"+hkey).attr("data-larger");
+        //tmp["min"] = $("#"+hkey).attr("min");
+        //tmp["max"] = $("#"+hkey).attr("max");
+        header = {};
+        header["title"] = $(".title", "#"+hkey).text();
+        //header["color"] = $(".title", "#"+hkey).css("color");
+        header["size"] = $(".title", "#"+hkey).css("font-size");
+        header["weight"] = $(".title", "#"+hkey).css("font-weight");
+
+        tmp["header"] = header;
+        position[hkey] = tmp;
+        //console.log( index + ": " + $( this ).text() );
+    });
+
+    //console.log("Check here");
+    //console.log(position);
     var dataToSend = JSON.stringify(position);
     //console.log(dataToSend);
     $.ajax({
@@ -331,6 +411,10 @@ jQuery(window).load(function () {
         }
         //console.log(this.text + ' ' + this.value);
     });
+    $('[id^=header_]').each(function( index ) {
+        $(this).draggable();
+        $(this).resizable(); 
+    });
 });
 </script>
 </body>

+ 10 - 0
status.html

@@ -50,6 +50,16 @@ data-type="{{ data['style'][key]['type'] }}" data-lesser="{{ data['style'][key][
 {% else %}
 {% end %}
 
+{% if data['style'][key]['type'] == "header" %}
+<div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{
+    data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px;
+    height:{{ data['style'][key]['height'] }}px;' data-type="{{
+    data['style'][key]['type'] }}" class='databox' id="{{ key }}">
+<p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span></p>
+</div>
+{% else %}
+{% end %}
+
 
 {% end %}
 {% else %}

+ 5 - 5
style.yaml

@@ -3,7 +3,7 @@
   dict: '{"5": "Five Mode", "0": "Zero Mode"}'
   header:
     size: 28px
-    title: ' '
+    title: '       '
     weight: '400'
   height: 137.99099999999999
   left: 409px
@@ -18,7 +18,7 @@
   condition: ''
   header:
     size: 28px
-    title: '  '
+    title: '        '
     weight: '400'
   height: 92.991
   larger: ''
@@ -28,14 +28,14 @@
   type: data
   unit:
     size: 28px
-    title: ' '
+    title: '       '
     weight: '400'
   width: 50.991
 320-RTY-3-3101:
   condition: ''
   header:
     size: 28px
-    title: '       '
+    title: '             '
     weight: '400'
   height: 95.991
   larger: '77'
@@ -45,7 +45,7 @@
   type: data
   unit:
     size: 28px
-    title: '      K'
+    title: '            K'
     weight: '400'
   width: 163.99099999999999
 411-REI-1-1110-0030: