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
[email protected]
https://lists.sourceforge.net/lists/listinfo/gnoga-list