Sfoglia il codice sorgente

fixed the save function.

- also added some key attribute checking.

Signed-off-by: nicolaisi <nicholas.jerome@kit.edu>
nicolaisi 7 anni fa
parent
commit
5d0e2cb8b0
2 ha cambiato i file con 39 aggiunte e 19 eliminazioni
  1. 29 17
      designer.html
  2. 10 2
      status.html

+ 29 - 17
designer.html

@@ -25,11 +25,23 @@
 <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;' 
-    {% if "formula" in data['style'][key] %}
-    data-formula="{{ data['style'][key]['formula'] }}"
-    {% else %}
-    {% end %}
-    data-cond="{{ data['style'][key]['condition'] }}" data-lesser="{{ data['style'][key]['lesser'] }}" data-type="{{ data['style'][key]['type'] }}" data-larger="{{ data['style'][key]['larger'] }}" class='varbox' id="{{ key }}">
+{% if "condition" in data['style'][key] %}
+ data-cond="{{ data['style'][key]['condition'] }}"
+{% else%}
+{% end%}
+{% if "formula" in data['style'][key] %}
+ data-formula="{{ data['style'][key]['formula'] }}"
+{% else %}
+{% end %}
+{% if "lesser" in data['style'][key] %}
+ data-lesser="{{ data['style'][key]['lesser'] }}"
+{% else %}
+{% end %}
+{% if "larger" in data['style'][key] %}
+ data-larger="{{ data['style'][key]['larger'] }}"
+{% else %}
+{% end %}
+ 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><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval"> XXX.XX <span class='unit_title' style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" > {{ data['style'][key]['unit']['title'] }}</span></span></p>
 </div>
 {% else %}
@@ -313,27 +325,27 @@ function mysave(data) {
             tmp["top"] = $("#"+key).css("top");
             tmp["width"] = $("#"+key).width();
             tmp["height"] = $("#"+key).height();
-            tmp["type"] = $("#vartype option:selected").val();
+            tmp["type"] = $("#"+key).attr("data-type");
 
             if ( $("#"+key).attr("data-type") == "data" ) {
-            	tmp["condition"] = $("#elem_condition_range").val();
-            	tmp["formula"] = $("#elem_formula").val();
-            	tmp["lesser"] = $("#elem_lesser_range").val();
-            	tmp["larger"] = $("#elem_larger_range").val();
+            	tmp["condition"] = $("#"+key).attr("data-cond");
+            	tmp["formula"] = $("#"+key).attr("data-formula");
+            	tmp["lesser"] = $("#"+key).attr("data-lesser");
+            	tmp["larger"] = $("#"+key).attr("data-larger");
             	//tmp["min"] = $("#"+key).attr("min");
-           	    //tmp["max"] = $("#"+key).attr("max");
+           	//tmp["max"] = $("#"+key).attr("max");
             
             	header = {};
-            	header["title"] = $("#elem_title_text").val().trim();
+            	header["title"] = $(".title", "#"+key).text();
             	//header["color"] = $(".title", "#"+key).css("color");
-            	header["size"] = $("#elem_title_size").val();
-            	header["weight"] = $("#elem_title_style option:selected").val();
+            	header["size"] = $(".title", "#"+key).css("font-size");
+            	header["weight"] = $(".title", "#"+key).css("font-weight");
             
             	unit = {};
-            	unit["title"] = $("#elem_unit_text").val().trim();
+            	unit["title"] = $(".unit_title", "#"+key).text();
             	//unit["color"] = $(".varval", "#"+key).css("color");
-            	unit["size"] = $("#elem_unit_size").val();
-            	unit["weight"] = $("#elem_unit_style option:selected").val();
+            	unit["size"] = $(".varval", "#"+key).css("font-size");
+            	unit["weight"] = $(".varval", "#"+key).css("font-weight");
 
             	tmp["header"] = header;
             	tmp["unit"] = unit;

+ 10 - 2
status.html

@@ -22,7 +22,7 @@
 
 {% if data['style'][key]['type'] == "data" %}
 <div tooltip="{{ key }}" class="databox" 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;' 
-{% if data['style'][key]['condition'] %}
+{% if "condition" in data['style'][key] %}
 data-cond="{{ data['style'][key]['condition'] }}"
 {% else%}
 {% end%}
@@ -30,7 +30,15 @@ data-cond="{{ data['style'][key]['condition'] }}"
 data-formula="{{ data['style'][key]['formula'] }}"
 {% else %}
 {% end %}
-data-type="{{ data['style'][key]['type'] }}" data-lesser="{{ data['style'][key]['lesser'] }}" data-larger="{{ data['style'][key]['larger'] }}" onclick="window.open('http://katrin.kit.edu/adei-katrin/#module=graph&{{ data['varname'][key]}}&experiment=-&window=0&module=graph&virtual=srctree&srctree=&infomod=legend', '_blank');" id="{{ key }}">
+{% if "lesser" in data['style'][key] %}
+data-lesser="{{ data['style'][key]['lesser'] }}"
+{% else %}
+{% end %}
+{% if "larger" in data['style'][key] %}
+data-larger="{{ data['style'][key]['larger'] }}"
+{% else %}
+{% end %}
+data-type="{{ data['style'][key]['type'] }}" onclick="window.open('http://katrin.kit.edu/adei-katrin/#module=graph&{{ data['varname'][key]}}&experiment=-&window=0&module=graph&virtual=srctree&srctree=&infomod=legend', '_blank');" 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><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval"> XXX.XX </span><span class='unit_title' style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};"> {{ data['style'][key]['unit']['title'] }}</span></p>
 </div>
 {% else %}