fix the browser Forward button
This commit is contained in:
parent
235f6efbac
commit
2f76cbd05c
2 changed files with 48 additions and 43 deletions
File diff suppressed because one or more lines are too long
|
|
@ -321,11 +321,32 @@ window.addEventListener("load", function() {
|
||||||
var keyboard = document.getElementById("keyboard");
|
var keyboard = document.getElementById("keyboard");
|
||||||
var fullscreenbutton = document.getElementById("fullscreenbutton");
|
var fullscreenbutton = document.getElementById("fullscreenbutton");
|
||||||
var text = document.getElementById("text");
|
var text = document.getElementById("text");
|
||||||
closed.style.display = "none";
|
|
||||||
pad.style.display = "none";
|
function showScene(scene) {
|
||||||
keys.style.display = "none";
|
[opening, closed, pad, keys, keyboard].forEach(function (e) {
|
||||||
keyboard.style.display = "none";
|
e.style.display = e == scene ? "flex" : "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showKeys() {
|
||||||
|
exitFullscreen();
|
||||||
|
showScene(keys);
|
||||||
|
if (history.state != "keys") {
|
||||||
|
history.pushState("keys", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showKeyboard() {
|
||||||
|
exitFullscreen();
|
||||||
|
showScene(keyboard);
|
||||||
|
text.focus();
|
||||||
|
if (history.state != "keyboard") {
|
||||||
|
history.pushState("keyboard", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
text.value = "";
|
text.value = "";
|
||||||
|
showScene(opening);
|
||||||
|
|
||||||
var wsProtocol = "wss:";
|
var wsProtocol = "wss:";
|
||||||
if (location.protocol == "http:") {
|
if (location.protocol == "http:") {
|
||||||
|
|
@ -342,45 +363,26 @@ window.addEventListener("load", function() {
|
||||||
}
|
}
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
ws.send(challengeResponse(event.data));
|
ws.send(challengeResponse(event.data));
|
||||||
opening.style.display = "none";
|
|
||||||
if (history.state == "keyboard") {
|
if (history.state == "keyboard") {
|
||||||
keyboard.style.display = "flex";
|
showKeyboard();
|
||||||
text.focus();
|
|
||||||
} else if (history.state == "keys") {
|
} else if (history.state == "keys") {
|
||||||
keys.style.display = "flex";
|
showKeys()
|
||||||
} else {
|
} else {
|
||||||
pad.style.display = "flex";
|
showScene(pad);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
exitFullscreen();
|
exitFullscreen();
|
||||||
opening.style.display = "none";
|
showScene(closed);
|
||||||
pad.style.display = "none";
|
|
||||||
keys.style.display = "none";
|
|
||||||
keyboard.style.display = "none";
|
|
||||||
closed.style.display = "flex";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("keysbutton").addEventListener("click",
|
document.getElementById("keysbutton").addEventListener("click", showKeys);
|
||||||
function(e) {
|
document.getElementById("keyboardbutton").addEventListener("click", showKeyboard);
|
||||||
exitFullscreen();
|
|
||||||
pad.style.display = "none";
|
|
||||||
keys.style.display = "flex";
|
|
||||||
history.pushState("keys", "");
|
|
||||||
});
|
|
||||||
document.getElementById("keyboardbutton").addEventListener("click",
|
|
||||||
function(e) {
|
|
||||||
exitFullscreen();
|
|
||||||
pad.style.display = "none";
|
|
||||||
keyboard.style.display = "flex";
|
|
||||||
text.focus();
|
|
||||||
history.pushState("keyboard", "");
|
|
||||||
});
|
|
||||||
if (!fullscreenEnabled()) {
|
if (!fullscreenEnabled()) {
|
||||||
fullscreenbutton.style.display = "none";
|
fullscreenbutton.style.display = "none";
|
||||||
}
|
}
|
||||||
fullscreenbutton.addEventListener("click", function(e) {
|
fullscreenbutton.addEventListener("click", function() {
|
||||||
if (fullscreenElement()) {
|
if (fullscreenElement()) {
|
||||||
exitFullscreen();
|
exitFullscreen();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -394,30 +396,33 @@ window.addEventListener("load", function() {
|
||||||
{id: "volumemutebutton", key: KEY_VOLUME_MUTE},
|
{id: "volumemutebutton", key: KEY_VOLUME_MUTE},
|
||||||
{id: "volumeupbutton", key: KEY_VOLUME_UP}].forEach(function(o) {
|
{id: "volumeupbutton", key: KEY_VOLUME_UP}].forEach(function(o) {
|
||||||
document.getElementById(o.id).addEventListener("click",
|
document.getElementById(o.id).addEventListener("click",
|
||||||
function(e) {
|
function() {
|
||||||
ws.send("k" + o.key);
|
ws.send("k" + o.key);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
document.getElementById("sendbutton").addEventListener("click",
|
document.getElementById("sendbutton").addEventListener("click",
|
||||||
function(e) {
|
function() {
|
||||||
if (text.value != "") {
|
if (text.value != "") {
|
||||||
ws.send("t" + text.value);
|
ws.send("t" + text.value);
|
||||||
text.value = "";
|
text.value = "";
|
||||||
}
|
}
|
||||||
window.history.back();
|
window.history.back();
|
||||||
});
|
});
|
||||||
window.onpopstate = function(event) {
|
window.onpopstate = function() {
|
||||||
if (keyboard.style.display == "flex" ||
|
if (pad.style.display != "none" ||
|
||||||
keys.style.display == "flex") {
|
keyboard.style.display != "none" ||
|
||||||
pad.style.display = "flex";
|
keys.style.display != "none") {
|
||||||
keys.style.display = "none";
|
if (history.state == "keys") {
|
||||||
keyboard.style.display = "none";
|
showKeys();
|
||||||
} else {
|
} else if (history.state == "keyboard") {
|
||||||
window.history.back();
|
showKeyboard();
|
||||||
|
} else {
|
||||||
|
showScene(pad);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.getElementById("reloadbutton").addEventListener("click",
|
document.getElementById("reloadbutton").addEventListener("click",
|
||||||
function(e) {
|
function() {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
pad.addEventListener("touchstart", handleStart, false);
|
pad.addEventListener("touchstart", handleStart, false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue