svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2836 ce6cecdb7320
parent 2834 6ac6a9dff594
child 2837 53d9eb6a7498
equal deleted inserted replaced
2835:bc666f020ab3 2836:ce6cecdb7320
   384 </xsl:text>
   384 </xsl:text>
   385     <xsl:text>            throw new Error("Dunno how to dispatch to widget at index = " + index);
   385     <xsl:text>            throw new Error("Dunno how to dispatch to widget at index = " + index);
   386 </xsl:text>
   386 </xsl:text>
   387     <xsl:text>        }*/
   387     <xsl:text>        }*/
   388 </xsl:text>
   388 </xsl:text>
       
   389     <xsl:text>    } catch(err) {
       
   390 </xsl:text>
       
   391     <xsl:text>        console.log(err);
       
   392 </xsl:text>
   389     <xsl:text>    }
   393     <xsl:text>    }
   390 </xsl:text>
   394 </xsl:text>
   391     <xsl:text>}
   395     <xsl:text>}
   392 </xsl:text>
   396 </xsl:text>
   393     <xsl:text>
   397     <xsl:text>
   432 </xsl:text>
   436 </xsl:text>
   433     <xsl:text>                init.call(widget);
   437     <xsl:text>                init.call(widget);
   434 </xsl:text>
   438 </xsl:text>
   435     <xsl:text>            } catch(err) {
   439     <xsl:text>            } catch(err) {
   436 </xsl:text>
   440 </xsl:text>
   437     <xsl:text>                console.log("Widget initialization error : "+err.message);
   441     <xsl:text>                console.log(err);
   438 </xsl:text>
       
   439     <xsl:text>
       
   440 </xsl:text>
   442 </xsl:text>
   441     <xsl:text>            }
   443     <xsl:text>            }
   442 </xsl:text>
   444 </xsl:text>
   443     <xsl:text>        }
   445     <xsl:text>        }
   444 </xsl:text>
   446 </xsl:text>
   927     <xsl:param name="hmi_element"/>
   929     <xsl:param name="hmi_element"/>
   928     <xsl:variable name="widget_type" select="@type"/>
   930     <xsl:variable name="widget_type" select="@type"/>
   929     <xsl:for-each select="str:split($labels)">
   931     <xsl:for-each select="str:split($labels)">
   930       <xsl:variable name="name" select="."/>
   932       <xsl:variable name="name" select="."/>
   931       <xsl:variable name="elt_id" select="$hmi_element//*[@inkscape:label=$name][1]/@id"/>
   933       <xsl:variable name="elt_id" select="$hmi_element//*[@inkscape:label=$name][1]/@id"/>
   932       <xsl:if test="$mandatory='yes' and not($elt_id)">
   934       <xsl:choose>
   933         <xsl:message terminate="no">
   935         <xsl:when test="not($elt_id)">
   934           <xsl:value-of select="$widget_type"/>
   936           <xsl:if test="$mandatory='yes'">
   935           <xsl:text> widget must have a </xsl:text>
   937             <xsl:message terminate="no">
       
   938               <xsl:value-of select="$widget_type"/>
       
   939               <xsl:text> widget must have a </xsl:text>
       
   940               <xsl:value-of select="$name"/>
       
   941               <xsl:text> element</xsl:text>
       
   942             </xsl:message>
       
   943           </xsl:if>
       
   944         </xsl:when>
       
   945         <xsl:otherwise>
   936           <xsl:value-of select="$name"/>
   946           <xsl:value-of select="$name"/>
   937           <xsl:text> element</xsl:text>
   947           <xsl:text>_elt: document.getElementById("</xsl:text>
   938         </xsl:message>
   948           <xsl:value-of select="$elt_id"/>
   939       </xsl:if>
   949           <xsl:text>"),
   940       <xsl:value-of select="$name"/>
   950 </xsl:text>
   941       <xsl:text>_elt: document.getElementById("</xsl:text>
   951         </xsl:otherwise>
   942       <xsl:value-of select="$elt_id"/>
   952       </xsl:choose>
   943       <xsl:text>"),
       
   944 </xsl:text>
       
   945     </xsl:for-each>
   953     </xsl:for-each>
   946   </xsl:template>
   954   </xsl:template>
   947   <xsl:template mode="widget_defs" match="widget[@type='Display']">
   955   <xsl:template mode="widget_defs" match="widget[@type='Display']">
   948     <xsl:param name="hmi_element"/>
   956     <xsl:param name="hmi_element"/>
   949     <xsl:text>frequency: 5,
   957     <xsl:text>frequency: 5,
  1014       </xsl:otherwise>
  1022       </xsl:otherwise>
  1015     </xsl:choose>
  1023     </xsl:choose>
  1016   </func:function>
  1024   </func:function>
  1017   <xsl:template mode="widget_defs" match="widget[@type='Input']">
  1025   <xsl:template mode="widget_defs" match="widget[@type='Input']">
  1018     <xsl:param name="hmi_element"/>
  1026     <xsl:param name="hmi_element"/>
  1019     <xsl:text>frequency: 5,
  1027     <xsl:variable name="value_elt">
  1020 </xsl:text>
  1028       <xsl:call-template name="defs_by_labels">
  1021     <xsl:call-template name="defs_by_labels">
  1029         <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1022       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1030         <xsl:with-param name="labels">
  1023       <xsl:with-param name="labels">
  1031           <xsl:text>value</xsl:text>
  1024         <xsl:text>value</xsl:text>
  1032         </xsl:with-param>
  1025       </xsl:with-param>
  1033         <xsl:with-param name="mandatory" select="'no'"/>
  1026     </xsl:call-template>
  1034       </xsl:call-template>
       
  1035     </xsl:variable>
       
  1036     <xsl:value-of select="$value_elt"/>
       
  1037     <xsl:if test="$value_elt">
       
  1038       <xsl:text>frequency: 5,
       
  1039 </xsl:text>
       
  1040     </xsl:if>
  1027     <xsl:text>dispatch: function(value) {
  1041     <xsl:text>dispatch: function(value) {
  1028 </xsl:text>
  1042 </xsl:text>
  1029     <xsl:text>    this.value_elt.textContent = String(value);
  1043     <xsl:if test="$value_elt">
  1030 </xsl:text>
  1044       <xsl:text>    this.value_elt.textContent = String(value);
       
  1045 </xsl:text>
       
  1046     </xsl:if>
  1031     <xsl:text>},
  1047     <xsl:text>},
  1032 </xsl:text>
  1048 </xsl:text>
  1033     <xsl:variable name="edit_elt_id" select="$hmi_element/*[@inkscape:label='edit'][1]/@id"/>
  1049     <xsl:variable name="edit_elt_id" select="$hmi_element/*[@inkscape:label='edit'][1]/@id"/>
  1034     <xsl:text>init: function() {
  1050     <xsl:text>init: function() {
  1035 </xsl:text>
  1051 </xsl:text>