Very wise idea. Actually in my own setting I am even more conservative:

custom phyrama_boot.js as in previous post;

custom phyrama_boot.html with call to phyrama_boot.js (and early jquery 
initialization):

<!doctype HTML>
<HTML>
    <HEAD>
       <meta http-equiv="Expires" content="0" />
       <meta charset="utf-8">
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <script src="/js/jquery.min.js" type="text/javascript"></script>

       <!-- Load jqueryui 1.11.4 -->
       <link href="/css/jquery-ui.min.css" rel="stylesheet">
       <script src="/js/jquery-ui.min.js"></script>

       <script>var gnoga_debug = true;</script>
       <script src="/js/phyrama_boot.js" type="text/javascript"></script>
       <link rel="Shortcut Icon" href=pasta.ico>
    </HEAD>
<BODY>
</BODY>
<noscript>Your browser must support JavaScript and be HTML 5 compilant 
to see this site.</noscript>
</HTML>


Le 23.05.2017 à 13:53, David Botton a écrit :
> I would say to update boot.js but also copy the old one to to 
> something like boot_without_touch_events.js
>
> David Botton
>
>
> On Tue, May 23, 2017 at 7:08 AM Gautier de Montmollin 
> <gdem...@hotmail.com <mailto:gdem...@hotmail.com>> wrote:
>
>     So, the workaround described here:
>
>     
> http://stackoverflow.com/questions/1517924/javascript-mapping-touch-events-to-mouse-events
>
>     is working :-)
>
>     Below, the completed boot.js (also with additional "Gnoga: " message
>     prefixes in the logs to js console).
>     ---
>
>        var ws;
>        var adr;
>        var reconnects=0;
>        var params={};
>        var gnoga={};
>        var pingerid;
>
>        if (typeof gnoga_debug == 'undefined') {
>           gnoga_debug = false;
>        }
>
>        function Ping_ws() {
>           if (ws.readyState == 1) {
>              ws.send ("0");
>           }
>        }
>
>        function Shutdown_ws() {
>           ws = null;
>           clearInterval (pingerid);
>           if (gnoga['html_on_close'] != "") {
>              $(document.body).html(gnoga['html_on_close']);
>            } else {
>              alert ("Server connection lost " + event.reason);
>            }
>        }
>
>        function Setup_ws() {
>           ws.onmessage = function (event) {
>              try {
>                 if (gnoga_debug == true) {
>                    console.log ("eval data = " + event.data);
>                 }
>                 eval (event.data);
>              } catch (e) {
>                 console.error (e.message);
>              }
>           }
>
>           ws.onerror = function (event) {
>              console.log ("onerror: reconnect");
>              ws=null;
>              ws = new WebSocket (adr  + "?Old_ID=" +
>     gnoga['Connection_ID']);
>              ws.onopen = function (event) {
>                 console.log ("onerror: reconnect successful");
>                 Setup_ws();
>              }
>              ws.onclose = function (event) {
>                 console.log ("onerror: reconnect failure");
>                 Shutdown_ws();
>              }
>           }
>
>           ws.onclose = function (event) {
>              console.log ("onclose: reconnect");
>              ws=null;
>              ws = new WebSocket (adr  + "?Old_ID=" +
>     gnoga['Connection_ID']);
>              ws.onopen = function (event) {
>                 console.log ("onclose: reconnect successful");
>                 Setup_ws();
>              }
>              ws.onclose = function (event) {
>                 console.log ("onclose: reconnect failure");
>                 Shutdown_ws();
>              }
>           }
>        }
>
>        function touchHandler(event)
>        {
>            var touches = event.changedTouches,
>                first = touches[0],
>                type = "";
>            switch(event.type)
>            {
>                case "touchstart": type = "mousedown"; break;
>                case "touchmove":  type = "mousemove"; break;
>                case "touchend":   type = "mouseup";   break;
>                default:           return;
>            }
>
>            // initMouseEvent(type, canBubble, cancelable, view,
>     clickCount,
>            //                screenX, screenY, clientX, clientY, ctrlKey,
>            //                altKey, shiftKey, metaKey, button,
>     relatedTarget);
>
>            var simulatedEvent = document.createEvent("MouseEvent");
>            simulatedEvent.initMouseEvent(type, true, true, window, 1,
>                                          first.screenX, first.screenY,
>                                          first.clientX, first.clientY,
>     false,
>                                          false, false, false,
>     0/*left*/, null);
>
>            first.target.dispatchEvent(simulatedEvent);
>            event.preventDefault();
>        }
>
>        function touch2mouseinit()
>        {
>            document.addEventListener("touchstart", touchHandler, true);
>            document.addEventListener("touchmove", touchHandler, true);
>            document.addEventListener("touchend", touchHandler, true);
>            document.addEventListener("touchcancel", touchHandler, true);
>        }
>
>        $( document ).ready(function() {
>           var s = document.location.search;
>           var tokens;
>           var r = /[?&]?([^=]+)=([^&]*)/g;
>
>           s = s.split("+").join(" ");
>
>           while (tokens = r.exec(s)) {
>              params[decodeURIComponent(tokens[1])]
>                 = decodeURIComponent(tokens[2]);
>           }
>
>           if (location.protocol == "https:") {
>              adr = "wss://" + location.hostname;
>           } else {
>              adr = "ws://" + location.hostname;
>           }
>
>           if (location.port != "") { adr = adr + ":" + location.port; }
>           adr = adr + "/gnoga";
>
>           try {
>              console.log ("Gnoga: connecting to " + adr);
>              ws = new WebSocket (adr);
>           } catch (e) {
>              console.log ("Gnoga: trying again, connecting to " + adr);
>              ws = new WebSocket (adr);
>           }
>
>           if (ws != null) {
>              ws.onopen = function (event) {
>                 console.log ("Gnoga: connection successful");
>                 Setup_ws();
>              }
>              pingerid = setInterval (function () {Ping_ws ();}, 10000);
>           } else {
>              document.writeln ("Gnoga: if you are seeing this your browser
>     or your connection to the internet is blocking websockets.");
>           }
>
>           touch2mouseinit();
>
>           console.log ("Gnoga: ready.");
>           });
>
>
>     
> ------------------------------------------------------------------------------
>     Check out the vibrant tech community on one of the world's most
>     engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>     _______________________________________________
>     Gnoga-list mailing list
>     Gnoga-list@lists.sourceforge.net
>     <mailto:Gnoga-list@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/gnoga-list
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
> _______________________________________________
> Gnoga-list mailing list
> Gnoga-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gnoga-list


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list

Reply via email to