svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2920 3ee337c8c769
parent 2919 c6e6051898f5
child 2921 2670f5c53caf
equal deleted inserted replaced
2919:c6e6051898f5 2920:3ee337c8c769
   685   </xsl:template>
   685   </xsl:template>
   686   <xsl:template mode="widget_subscribe" match="widget[@type='Page']"/>
   686   <xsl:template mode="widget_subscribe" match="widget[@type='Page']"/>
   687   <xsl:template name="defs_by_labels">
   687   <xsl:template name="defs_by_labels">
   688     <xsl:param name="labels" select="''"/>
   688     <xsl:param name="labels" select="''"/>
   689     <xsl:param name="mandatory" select="'yes'"/>
   689     <xsl:param name="mandatory" select="'yes'"/>
       
   690     <xsl:param name="subelements" select="/.."/>
   690     <xsl:param name="hmi_element"/>
   691     <xsl:param name="hmi_element"/>
   691     <xsl:variable name="widget_type" select="@type"/>
   692     <xsl:variable name="widget_type" select="@type"/>
   692     <xsl:for-each select="str:split($labels)">
   693     <xsl:for-each select="str:split($labels)">
   693       <xsl:variable name="name" select="."/>
   694       <xsl:variable name="name" select="."/>
   694       <xsl:variable name="elt_id" select="$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]/@id"/>
   695       <xsl:variable name="elt" select="$result_svg_ns//*[@id = $hmi_element/@id]//*[@inkscape:label=$name][1]"/>
   695       <xsl:choose>
   696       <xsl:choose>
   696         <xsl:when test="not($elt_id)">
   697         <xsl:when test="not($elt/@id)">
   697           <xsl:if test="$mandatory='yes'">
   698           <xsl:if test="$mandatory='yes'">
   698             <xsl:message terminate="no">
   699             <xsl:message terminate="yes">
   699               <xsl:value-of select="$widget_type"/>
   700               <xsl:value-of select="$widget_type"/>
   700               <xsl:text> widget must have a </xsl:text>
   701               <xsl:text> widget must have a </xsl:text>
   701               <xsl:value-of select="$name"/>
   702               <xsl:value-of select="$name"/>
   702               <xsl:text> element</xsl:text>
   703               <xsl:text> element</xsl:text>
   703             </xsl:message>
   704             </xsl:message>
   705         </xsl:when>
   706         </xsl:when>
   706         <xsl:otherwise>
   707         <xsl:otherwise>
   707           <xsl:text>    </xsl:text>
   708           <xsl:text>    </xsl:text>
   708           <xsl:value-of select="$name"/>
   709           <xsl:value-of select="$name"/>
   709           <xsl:text>_elt: id("</xsl:text>
   710           <xsl:text>_elt: id("</xsl:text>
   710           <xsl:value-of select="$elt_id"/>
   711           <xsl:value-of select="$elt/@id"/>
   711           <xsl:text>"),
   712           <xsl:text>"),
   712 </xsl:text>
   713 </xsl:text>
       
   714           <xsl:if test="$subelements">
       
   715             <xsl:text>    </xsl:text>
       
   716             <xsl:value-of select="$name"/>
       
   717             <xsl:text>_sub: {
       
   718 </xsl:text>
       
   719             <xsl:for-each select="str:split($subelements)">
       
   720               <xsl:variable name="subname" select="."/>
       
   721               <xsl:variable name="subelt" select="$elt/*[@inkscape:label=$subname][1]"/>
       
   722               <xsl:choose>
       
   723                 <xsl:when test="not($subelt/@id)">
       
   724                   <xsl:if test="$mandatory='yes'">
       
   725                     <xsl:message terminate="yes">
       
   726                       <xsl:value-of select="$widget_type"/>
       
   727                       <xsl:text> widget must have a </xsl:text>
       
   728                       <xsl:value-of select="$name"/>
       
   729                       <xsl:text>/</xsl:text>
       
   730                       <xsl:value-of select="$subname"/>
       
   731                       <xsl:text> element</xsl:text>
       
   732                     </xsl:message>
       
   733                   </xsl:if>
       
   734                   <xsl:text>        /* missing </xsl:text>
       
   735                   <xsl:value-of select="$name"/>
       
   736                   <xsl:text>/</xsl:text>
       
   737                   <xsl:value-of select="$subname"/>
       
   738                   <xsl:text> element */
       
   739 </xsl:text>
       
   740                 </xsl:when>
       
   741                 <xsl:otherwise>
       
   742                   <xsl:text>        "</xsl:text>
       
   743                   <xsl:value-of select="$subname"/>
       
   744                   <xsl:text>": id("</xsl:text>
       
   745                   <xsl:value-of select="$subelt/@id"/>
       
   746                   <xsl:text>")</xsl:text>
       
   747                   <xsl:if test="position()!=last()">
       
   748                     <xsl:text>,</xsl:text>
       
   749                   </xsl:if>
       
   750                   <xsl:text>
       
   751 </xsl:text>
       
   752                 </xsl:otherwise>
       
   753               </xsl:choose>
       
   754             </xsl:for-each>
       
   755             <xsl:text>    },
       
   756 </xsl:text>
       
   757           </xsl:if>
   713         </xsl:otherwise>
   758         </xsl:otherwise>
   714       </xsl:choose>
   759       </xsl:choose>
   715     </xsl:for-each>
   760     </xsl:for-each>
   716   </xsl:template>
   761   </xsl:template>
   717   <func:function name="func:escape_quotes">
   762   <func:function name="func:escape_quotes">
  1195       </xsl:with-param>
  1240       </xsl:with-param>
  1196     </xsl:call-template>
  1241     </xsl:call-template>
  1197     <xsl:call-template name="defs_by_labels">
  1242     <xsl:call-template name="defs_by_labels">
  1198       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1243       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1199       <xsl:with-param name="labels">
  1244       <xsl:with-param name="labels">
  1200         <xsl:text>Sign CapsLock Shift Space</xsl:text>
  1245         <xsl:text>Sign Space NumDot</xsl:text>
  1201       </xsl:with-param>
  1246       </xsl:with-param>
  1202       <xsl:with-param name="mandatory" select="'no'"/>
  1247       <xsl:with-param name="mandatory" select="'no'"/>
       
  1248     </xsl:call-template>
       
  1249     <xsl:call-template name="defs_by_labels">
       
  1250       <xsl:with-param name="hmi_element" select="$hmi_element"/>
       
  1251       <xsl:with-param name="labels">
       
  1252         <xsl:text>CapsLock Shift</xsl:text>
       
  1253       </xsl:with-param>
       
  1254       <xsl:with-param name="mandatory" select="'no'"/>
       
  1255       <xsl:with-param name="subelements" select="'active inactive'"/>
  1203     </xsl:call-template>
  1256     </xsl:call-template>
  1204     <xsl:text>    init: function() {
  1257     <xsl:text>    init: function() {
  1205 </xsl:text>
  1258 </xsl:text>
  1206     <xsl:for-each select="$hmi_element/*[@inkscape:label = 'Keys']/*">
  1259     <xsl:for-each select="$hmi_element/*[@inkscape:label = 'Keys']/*">
  1207       <xsl:text>        id("</xsl:text>
  1260       <xsl:text>        id("</xsl:text>
  1211       <xsl:text>'].on_key_click('</xsl:text>
  1264       <xsl:text>'].on_key_click('</xsl:text>
  1212       <xsl:value-of select="func:escape_quotes(@inkscape:label)"/>
  1265       <xsl:value-of select="func:escape_quotes(@inkscape:label)"/>
  1213       <xsl:text>')");
  1266       <xsl:text>')");
  1214 </xsl:text>
  1267 </xsl:text>
  1215     </xsl:for-each>
  1268     </xsl:for-each>
  1216     <xsl:for-each select="str:split('Esc Enter BackSpace Sign Space CapsLock Shift')">
  1269     <xsl:for-each select="str:split('Esc Enter BackSpace Sign Space NumDot CapsLock Shift')">
  1217       <xsl:text>        if(this.</xsl:text>
  1270       <xsl:text>        if(this.</xsl:text>
  1218       <xsl:value-of select="."/>
  1271       <xsl:value-of select="."/>
  1219       <xsl:text>_elt)
  1272       <xsl:text>_elt)
  1220 </xsl:text>
  1273 </xsl:text>
  1221       <xsl:text>            this.</xsl:text>
  1274       <xsl:text>            this.</xsl:text>
  1239 </xsl:text>
  1292 </xsl:text>
  1240     <xsl:text>        this.shift = false;
  1293     <xsl:text>        this.shift = false;
  1241 </xsl:text>
  1294 </xsl:text>
  1242     <xsl:text>        this.update();
  1295     <xsl:text>        this.update();
  1243 </xsl:text>
  1296 </xsl:text>
  1244     <xsl:text>        console.log(symbols);
       
  1245 </xsl:text>
       
  1246     <xsl:text>    },
  1297     <xsl:text>    },
  1247 </xsl:text>
  1298 </xsl:text>
  1248     <xsl:text>    on_Esc_click: function() {
  1299     <xsl:text>    on_Esc_click: function() {
  1249 </xsl:text>
  1300 </xsl:text>
  1250     <xsl:text>        end_modal.call(this);
  1301     <xsl:text>        end_modal.call(this);
  1251 </xsl:text>
  1302 </xsl:text>
  1252     <xsl:text>        console.log("Esc");
       
  1253 </xsl:text>
       
  1254     <xsl:text>    },
  1303     <xsl:text>    },
  1255 </xsl:text>
  1304 </xsl:text>
  1256     <xsl:text>    on_Enter_click: function() {
  1305     <xsl:text>    on_Enter_click: function() {
  1257 </xsl:text>
  1306 </xsl:text>
  1258     <xsl:text>        end_modal.call(this);
  1307     <xsl:text>        end_modal.call(this);
  1259 </xsl:text>
  1308 </xsl:text>
  1260     <xsl:text>        callback_obj = this.result_callback_obj;
  1309     <xsl:text>        callback_obj = this.result_callback_obj;
  1261 </xsl:text>
  1310 </xsl:text>
  1262     <xsl:text>        callback_obj.edit_callback(this.editstr);
  1311     <xsl:text>        callback_obj.edit_callback(this.editstr);
  1263 </xsl:text>
  1312 </xsl:text>
  1264     <xsl:text>        console.log("Enter");
       
  1265 </xsl:text>
       
  1266     <xsl:text>    },
  1313     <xsl:text>    },
  1267 </xsl:text>
  1314 </xsl:text>
  1268     <xsl:text>    on_BackSpace_click: function() {
  1315     <xsl:text>    on_BackSpace_click: function() {
  1269 </xsl:text>
  1316 </xsl:text>
  1270     <xsl:text>        this.editstr = this.editstr.slice(0,this.editstr.length-1);
  1317     <xsl:text>        this.editstr = this.editstr.slice(0,this.editstr.length-1);
  1271 </xsl:text>
  1318 </xsl:text>
  1272     <xsl:text>        this.update();
  1319     <xsl:text>        this.update();
  1273 </xsl:text>
  1320 </xsl:text>
  1274     <xsl:text>        console.log("BackSpace");
       
  1275 </xsl:text>
       
  1276     <xsl:text>    },
  1321     <xsl:text>    },
  1277 </xsl:text>
  1322 </xsl:text>
  1278     <xsl:text>    on_Sign_click: function() {
  1323     <xsl:text>    on_Sign_click: function() {
  1279 </xsl:text>
  1324 </xsl:text>
  1280     <xsl:text>        if(this.editstr[0] == "-")
  1325     <xsl:text>        if(this.editstr[0] == "-")
  1283 </xsl:text>
  1328 </xsl:text>
  1284     <xsl:text>        else
  1329     <xsl:text>        else
  1285 </xsl:text>
  1330 </xsl:text>
  1286     <xsl:text>            this.editstr = "-" + this.editstr;
  1331     <xsl:text>            this.editstr = "-" + this.editstr;
  1287 </xsl:text>
  1332 </xsl:text>
  1288     <xsl:text>        console.log("Sign");
  1333     <xsl:text>        this.update();
  1289 </xsl:text>
  1334 </xsl:text>
  1290     <xsl:text>    },
  1335     <xsl:text>    },
  1291 </xsl:text>
  1336 </xsl:text>
       
  1337     <xsl:text>    on_NumDot_click: function() {
       
  1338 </xsl:text>
       
  1339     <xsl:text>        if(this.editstr.indexOf(".") == "-1"){
       
  1340 </xsl:text>
       
  1341     <xsl:text>            this.editstr += ".";
       
  1342 </xsl:text>
       
  1343     <xsl:text>            this.update();
       
  1344 </xsl:text>
       
  1345     <xsl:text>        }
       
  1346 </xsl:text>
       
  1347     <xsl:text>    },
       
  1348 </xsl:text>
  1292     <xsl:text>    on_Space_click: function() {
  1349     <xsl:text>    on_Space_click: function() {
  1293 </xsl:text>
  1350 </xsl:text>
  1294     <xsl:text>        this.editstr += " ";
  1351     <xsl:text>        this.editstr += " ";
  1295 </xsl:text>
  1352 </xsl:text>
  1296     <xsl:text>        console.log("Space");
  1353     <xsl:text>        this.update();
  1297 </xsl:text>
  1354 </xsl:text>
  1298     <xsl:text>    },
  1355     <xsl:text>    },
  1299 </xsl:text>
  1356 </xsl:text>
  1300     <xsl:text>    caps: false,
  1357     <xsl:text>    caps: false,
  1301 </xsl:text>
  1358 </xsl:text>
       
  1359     <xsl:text>    _caps: undefined,
       
  1360 </xsl:text>
  1302     <xsl:text>    on_CapsLock_click: function() {
  1361     <xsl:text>    on_CapsLock_click: function() {
  1303 </xsl:text>
  1362 </xsl:text>
  1304     <xsl:text>        this.caps = !this.caps;
  1363     <xsl:text>        this.caps = !this.caps;
  1305 </xsl:text>
  1364 </xsl:text>
  1306     <xsl:text>        console.log("CapsLock");
  1365     <xsl:text>        this.update();
  1307 </xsl:text>
  1366 </xsl:text>
  1308     <xsl:text>    },
  1367     <xsl:text>    },
  1309 </xsl:text>
  1368 </xsl:text>
  1310     <xsl:text>    shift: false,
  1369     <xsl:text>    shift: false,
  1311 </xsl:text>
  1370 </xsl:text>
       
  1371     <xsl:text>    _shift: undefined,
       
  1372 </xsl:text>
  1312     <xsl:text>    on_Shift_click: function() {
  1373     <xsl:text>    on_Shift_click: function() {
  1313 </xsl:text>
  1374 </xsl:text>
  1314     <xsl:text>        this.shift = true;
  1375     <xsl:text>        this.shift = !this.shift;
  1315 </xsl:text>
  1376 </xsl:text>
  1316     <xsl:text>        console.log("Shift");
  1377     <xsl:text>        this.caps = false;
       
  1378 </xsl:text>
       
  1379     <xsl:text>        this.update();
  1317 </xsl:text>
  1380 </xsl:text>
  1318     <xsl:text>    },
  1381     <xsl:text>    },
  1319 </xsl:text>
  1382 </xsl:text>
  1320     <xsl:variable name="g" select="$geometry[@Id = $hmi_element/@id]"/>
  1383     <xsl:variable name="g" select="$geometry[@Id = $hmi_element/@id]"/>
  1321     <xsl:text>    coordinates: [</xsl:text>
  1384     <xsl:text>    coordinates: [</xsl:text>
  1324     <xsl:value-of select="$g/@y"/>
  1387     <xsl:value-of select="$g/@y"/>
  1325     <xsl:text>],
  1388     <xsl:text>],
  1326 </xsl:text>
  1389 </xsl:text>
  1327     <xsl:text>    editstr: "",
  1390     <xsl:text>    editstr: "",
  1328 </xsl:text>
  1391 </xsl:text>
       
  1392     <xsl:text>    _editstr: undefined,
       
  1393 </xsl:text>
  1329     <xsl:text>    result_callback_obj: undefined,
  1394     <xsl:text>    result_callback_obj: undefined,
  1330 </xsl:text>
  1395 </xsl:text>
  1331     <xsl:text>    start_edit: function(info, valuetype, callback_obj, initial) {
  1396     <xsl:text>    start_edit: function(info, valuetype, callback_obj, initial) {
  1332 </xsl:text>
  1397 </xsl:text>
  1333     <xsl:text>        show_modal.call(this);
  1398     <xsl:text>        show_modal.call(this);
  1346 </xsl:text>
  1411 </xsl:text>
  1347     <xsl:text>    },
  1412     <xsl:text>    },
  1348 </xsl:text>
  1413 </xsl:text>
  1349     <xsl:text>    update: function() {
  1414     <xsl:text>    update: function() {
  1350 </xsl:text>
  1415 </xsl:text>
  1351     <xsl:text>        /* TODO Swith shift and capslock active/inactive elements */
  1416     <xsl:text>        if(this.editstr != this._editstr){
  1352 </xsl:text>
  1417 </xsl:text>
  1353     <xsl:text>        this.Value_elt.textContent = this.editstr;
  1418     <xsl:text>            this._editstr = this.editstr;
       
  1419 </xsl:text>
       
  1420     <xsl:text>            this.Value_elt.textContent = this.editstr;
       
  1421 </xsl:text>
       
  1422     <xsl:text>        }
       
  1423 </xsl:text>
       
  1424     <xsl:text>        if(this.shift != this._shift){
       
  1425 </xsl:text>
       
  1426     <xsl:text>            this._shift = this.shift;
       
  1427 </xsl:text>
       
  1428     <xsl:text>            (this.shift?widget_active_activable:widget_inactive_activable)(this.Shift_sub);
       
  1429 </xsl:text>
       
  1430     <xsl:text>        }
       
  1431 </xsl:text>
       
  1432     <xsl:text>        if(this.caps != this._caps){
       
  1433 </xsl:text>
       
  1434     <xsl:text>            this._caps = this.caps;
       
  1435 </xsl:text>
       
  1436     <xsl:text>            (this.caps?widget_active_activable:widget_inactive_activable)(this.CapsLock_sub);
       
  1437 </xsl:text>
       
  1438     <xsl:text>        }
  1354 </xsl:text>
  1439 </xsl:text>
  1355     <xsl:text>    },
  1440     <xsl:text>    },
  1356 </xsl:text>
  1441 </xsl:text>
  1357   </xsl:template>
  1442   </xsl:template>
  1358   <xsl:template mode="widget_defs" match="widget[@type='Meter']">
  1443   <xsl:template mode="widget_defs" match="widget[@type='Meter']">
  2603 </xsl:text>
  2688 </xsl:text>
  2604     <xsl:text>    current_modal = undefined;
  2689     <xsl:text>    current_modal = undefined;
  2605 </xsl:text>
  2690 </xsl:text>
  2606     <xsl:text>};
  2691     <xsl:text>};
  2607 </xsl:text>
  2692 </xsl:text>
       
  2693     <xsl:text>
       
  2694 </xsl:text>
       
  2695     <xsl:text>function widget_active_activable(eltsub) {
       
  2696 </xsl:text>
       
  2697     <xsl:text>    if(eltsub.inactive_style === undefined)
       
  2698 </xsl:text>
       
  2699     <xsl:text>        eltsub.inactive_style = eltsub.inactive.getAttribute("style");
       
  2700 </xsl:text>
       
  2701     <xsl:text>    eltsub.inactive.setAttribute("style", "display:none");
       
  2702 </xsl:text>
       
  2703     <xsl:text>    if(eltsub.active_style !== undefined)
       
  2704 </xsl:text>
       
  2705     <xsl:text>            eltsub.active.setAttribute("style", eltsub.active_style);
       
  2706 </xsl:text>
       
  2707     <xsl:text>    console.log("active", eltsub);
       
  2708 </xsl:text>
       
  2709     <xsl:text>};
       
  2710 </xsl:text>
       
  2711     <xsl:text>function widget_inactive_activable(eltsub) {
       
  2712 </xsl:text>
       
  2713     <xsl:text>    if(eltsub.active_style === undefined)
       
  2714 </xsl:text>
       
  2715     <xsl:text>        eltsub.active_style = eltsub.active.getAttribute("style");
       
  2716 </xsl:text>
       
  2717     <xsl:text>    eltsub.active.setAttribute("style", "display:none");
       
  2718 </xsl:text>
       
  2719     <xsl:text>    if(eltsub.inactive_style !== undefined)
       
  2720 </xsl:text>
       
  2721     <xsl:text>            eltsub.inactive.setAttribute("style", eltsub.inactive_style);
       
  2722 </xsl:text>
       
  2723     <xsl:text>    console.log("inactive", eltsub);
       
  2724 </xsl:text>
       
  2725     <xsl:text>};
       
  2726 </xsl:text>
  2608   </xsl:template>
  2727   </xsl:template>
  2609 </xsl:stylesheet>
  2728 </xsl:stylesheet>