Cosmetics
This commit is contained in:
parent
dd2d13b4e4
commit
64327f326c
2 changed files with 30 additions and 37 deletions
File diff suppressed because one or more lines are too long
|
|
@ -82,6 +82,7 @@ function requestFullscreen(e, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function exitFullscreen() {
|
function exitFullscreen() {
|
||||||
|
if (fullscreenElement()) {
|
||||||
if (document.exitFullscreen) {
|
if (document.exitFullscreen) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
} else if (document.webkitExitFullscreen) {
|
} else if (document.webkitExitFullscreen) {
|
||||||
|
|
@ -91,6 +92,7 @@ function exitFullscreen() {
|
||||||
} else if (document.msExitFullscreen) {
|
} else if (document.msExitFullscreen) {
|
||||||
document.msExitFullscreen();
|
document.msExitFullscreen();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fullscreenElement() {
|
function fullscreenElement() {
|
||||||
|
|
@ -125,7 +127,7 @@ function copyTouch(touch, timeStamp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ongoingTouchIndexById(idToFind) {
|
function ongoingTouchIndexById(idToFind) {
|
||||||
for (var i = 0; i < ongoingTouches.length; i++) {
|
for (var i = 0; i < ongoingTouches.length; i += 1) {
|
||||||
if (ongoingTouches[i].identifier == idToFind) {
|
if (ongoingTouches[i].identifier == idToFind) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +136,7 @@ function ongoingTouchIndexById(idToFind) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculatePointerAccelerationMult(speed) {
|
function calculatePointerAccelerationMult(speed) {
|
||||||
for (var i = 0; i < POINTER_ACCELERATION.length; i++) {
|
for (var i = 0; i < POINTER_ACCELERATION.length; i += 1) {
|
||||||
var s2 = POINTER_ACCELERATION[i][0];
|
var s2 = POINTER_ACCELERATION[i][0];
|
||||||
var a2 = POINTER_ACCELERATION[i][1];
|
var a2 = POINTER_ACCELERATION[i][1];
|
||||||
if (s2 <= speed) {
|
if (s2 <= speed) {
|
||||||
|
|
@ -183,7 +185,7 @@ function handleStart(evt) {
|
||||||
touchMoved = false;
|
touchMoved = false;
|
||||||
}
|
}
|
||||||
var touches = evt.changedTouches;
|
var touches = evt.changedTouches;
|
||||||
for (var i = 0; i < touches.length; i++) {
|
for (var i = 0; i < touches.length; i += 1) {
|
||||||
if (touches[i].target != pad && touches[i].target != padlabel &&
|
if (touches[i].target != pad && touches[i].target != padlabel &&
|
||||||
ongoingTouches.length == 0) {
|
ongoingTouches.length == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -217,13 +219,13 @@ function handleStart(evt) {
|
||||||
|
|
||||||
function handleEnd(evt) {
|
function handleEnd(evt) {
|
||||||
var touches = evt.changedTouches;
|
var touches = evt.changedTouches;
|
||||||
for (var i = 0; i < touches.length; i++) {
|
for (var i = 0; i < touches.length; i += 1) {
|
||||||
var idx = ongoingTouchIndexById(touches[i].identifier);
|
var idx = ongoingTouchIndexById(touches[i].identifier);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ongoingTouches.splice(idx, 1);
|
ongoingTouches.splice(idx, 1);
|
||||||
touchReleasedCount++;
|
touchReleasedCount += 1;
|
||||||
touchLastEnd = evt.timeStamp;
|
touchLastEnd = evt.timeStamp;
|
||||||
if (scrolling) {
|
if (scrolling) {
|
||||||
ws.send("sf");
|
ws.send("sf");
|
||||||
|
|
@ -262,7 +264,7 @@ function handleMove(evt) {
|
||||||
var sumX = 0;
|
var sumX = 0;
|
||||||
var sumY = 0;
|
var sumY = 0;
|
||||||
var touches = evt.changedTouches;
|
var touches = evt.changedTouches;
|
||||||
for (var i = 0; i < touches.length; i++) {
|
for (var i = 0; i < touches.length; i += 1) {
|
||||||
var idx = ongoingTouchIndexById(touches[i].identifier);
|
var idx = ongoingTouchIndexById(touches[i].identifier);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -322,9 +324,7 @@ window.addEventListener("load", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showKeys() {
|
function showKeys() {
|
||||||
if (fullscreenElement()) {
|
|
||||||
exitFullscreen();
|
exitFullscreen();
|
||||||
}
|
|
||||||
showScene(keys);
|
showScene(keys);
|
||||||
if (history.state != "keys") {
|
if (history.state != "keys") {
|
||||||
history.pushState("keys", "");
|
history.pushState("keys", "");
|
||||||
|
|
@ -332,9 +332,7 @@ window.addEventListener("load", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showKeyboard() {
|
function showKeyboard() {
|
||||||
if (fullscreenElement()) {
|
|
||||||
exitFullscreen();
|
exitFullscreen();
|
||||||
}
|
|
||||||
showScene(keyboard);
|
showScene(keyboard);
|
||||||
text.focus();
|
text.focus();
|
||||||
if (history.state != "keyboard") {
|
if (history.state != "keyboard") {
|
||||||
|
|
@ -356,24 +354,21 @@ window.addEventListener("load", function() {
|
||||||
}
|
}
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
ws.send(challengeResponse(evt.data));
|
ws.send(challengeResponse(evt.data));
|
||||||
if (history.state == "keyboard") {
|
window.onpopstate();
|
||||||
showKeyboard();
|
|
||||||
} else if (history.state == "keys") {
|
|
||||||
showKeys()
|
|
||||||
} else {
|
|
||||||
showScene(pad);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
if (fullscreenElement()) {
|
authenticated = false;
|
||||||
exitFullscreen();
|
exitFullscreen();
|
||||||
}
|
|
||||||
showScene(closed);
|
showScene(closed);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("keysbutton").addEventListener("click", showKeys);
|
document.getElementById("keysbutton").addEventListener("click", function() {
|
||||||
document.getElementById("keyboardbutton").addEventListener("click", showKeyboard);
|
showKeys();
|
||||||
|
});
|
||||||
|
document.getElementById("keyboardbutton").addEventListener("click", function() {
|
||||||
|
showKeyboard();
|
||||||
|
});
|
||||||
if (!fullscreenEnabled()) {
|
if (!fullscreenEnabled()) {
|
||||||
fullscreenbutton.classList.add("hidden");
|
fullscreenbutton.classList.add("hidden");
|
||||||
}
|
}
|
||||||
|
|
@ -405,9 +400,7 @@ window.addEventListener("load", function() {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
});
|
});
|
||||||
window.onpopstate = function() {
|
window.onpopstate = function() {
|
||||||
if (!pad.classList.contains("hidden") ||
|
if (authenticated) {
|
||||||
!keyboard.classList.contains("hidden") ||
|
|
||||||
!keys.classList.contains("hidden")) {
|
|
||||||
if (history.state == "keys") {
|
if (history.state == "keys") {
|
||||||
showKeys();
|
showKeys();
|
||||||
} else if (history.state == "keyboard") {
|
} else if (history.state == "keyboard") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue