# HG changeset patch # User Edouard Tisserant # Date 1584002000 -3600 # Node ID 545902730141aa6b1b6cc3d24a5ea5f89bb76c7f # Parent 36f78f6cfabd2973a5579cd43c78e276a28eba0e SVGHMI: cosmetic code moving diff -r 36f78f6cfabd -r 545902730141 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Tue Mar 10 13:57:29 2020 +0100 +++ b/svghmi/gen_index_xhtml.xslt Thu Mar 12 09:33:20 2020 +0100 @@ -753,31 +753,41 @@ </xsl:text> <xsl:text>// Apply updates recieved through ws.onmessage to subscribed widgets </xsl:text> - <xsl:text>// Do the page swith if any one pending + <xsl:text>function apply_updates() { +</xsl:text> + <xsl:text> for(let index in updates){ +</xsl:text> + <xsl:text> // serving as a key, index becomes a string +</xsl:text> + <xsl:text> // -> pass Number(index) instead +</xsl:text> + <xsl:text> dispatch_value(Number(index), updates[index]); +</xsl:text> + <xsl:text> delete updates[index]; +</xsl:text> + <xsl:text> } +</xsl:text> + <xsl:text>} +</xsl:text> + <xsl:text> </xsl:text> <xsl:text>// Called on requestAnimationFrame, modifies DOM </xsl:text> + <xsl:text>var requestAnimationFrameID = null; +</xsl:text> <xsl:text>function animate() { </xsl:text> + <xsl:text> // Do the page swith if any one pending +</xsl:text> <xsl:text> if(current_subscribed_page != current_visible_page){ </xsl:text> <xsl:text> switch_visible_page(current_subscribed_page); </xsl:text> <xsl:text> } </xsl:text> - <xsl:text> -</xsl:text> - <xsl:text> for(let index in updates){ -</xsl:text> - <xsl:text> // serving as a key, index becomes a string -</xsl:text> - <xsl:text> // -> pass Number(index) instead -</xsl:text> - <xsl:text> dispatch_value(Number(index), updates[index]); -</xsl:text> - <xsl:text> delete updates[index]; -</xsl:text> - <xsl:text> } + <xsl:text> console.log("no page switch"); +</xsl:text> + <xsl:text> apply_updates(); </xsl:text> <xsl:text> requestAnimationFrameID = null; </xsl:text> @@ -785,8 +795,6 @@ </xsl:text> <xsl:text> </xsl:text> - <xsl:text>var requestAnimationFrameID = null; -</xsl:text> <xsl:text>function requestHMIAnimation() { </xsl:text> <xsl:text> if(requestAnimationFrameID == null){ diff -r 36f78f6cfabd -r 545902730141 svghmi/svghmi.js --- a/svghmi/svghmi.js Tue Mar 10 13:57:29 2020 +0100 +++ b/svghmi/svghmi.js Thu Mar 12 09:33:20 2020 +0100 @@ -66,23 +66,27 @@ }; // Apply updates recieved through ws.onmessage to subscribed widgets -// Do the page swith if any one pending -// Called on requestAnimationFrame, modifies DOM -function animate() { - if(current_subscribed_page != current_visible_page){ - switch_visible_page(current_subscribed_page); - } - +function apply_updates() { for(let index in updates){ // serving as a key, index becomes a string // -> pass Number(index) instead dispatch_value(Number(index), updates[index]); delete updates[index]; } +} + +// Called on requestAnimationFrame, modifies DOM +var requestAnimationFrameID = null; +function animate() { + // Do the page swith if any one pending + if(current_subscribed_page != current_visible_page){ + switch_visible_page(current_subscribed_page); + } + console.log("no page switch"); + apply_updates(); requestAnimationFrameID = null; } -var requestAnimationFrameID = null; function requestHMIAnimation() { if(requestAnimationFrameID == null){ requestAnimationFrameID = window.requestAnimationFrame(animate);