mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-01-23 13:50:25 +01:00
Check for WebKit after connecting to the server
For some reason the original way only works in Safari after pressing the refresh button. It did not work if you typed the URL into the address bar in Safari without refreshing afterwards.
This commit is contained in:
parent
00c1f49ca1
commit
d7893a0b52
@ -79,7 +79,7 @@ var sman_allow_delete = false;
|
||||
var sman_allow_rename = false;
|
||||
|
||||
// This is true iff [we're in macOS and the browser is Safari] or [we're in iOS]
|
||||
var using_webkit_patch = false;
|
||||
var using_webkit_patch = null;
|
||||
|
||||
// Key states
|
||||
var shift_down = false;
|
||||
@ -1105,35 +1105,6 @@ $(document).ready(function(){
|
||||
seqselmenu = $("#seqselmenu");
|
||||
seqselcontents = $("#seqselcontents");
|
||||
|
||||
// A simple feature detection test to determine whether the user interface
|
||||
// is using WebKit (Safari browser's rendering engine) because WebKit
|
||||
// requires special treatment to work correctly with the KoboldAI editor
|
||||
using_webkit_patch = (function() {
|
||||
try {
|
||||
var active_element = document.activeElement;
|
||||
var c = document.createElement("chunk");
|
||||
var t = document.createTextNode("KoboldAI");
|
||||
c.appendChild(t);
|
||||
game_text[0].appendChild(c);
|
||||
var r = rangy.createRange();
|
||||
r.setStart(t, 6);
|
||||
r.collapse(true);
|
||||
var s = rangy.getSelection();
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
game_text.blur();
|
||||
game_text.focus();
|
||||
var offset = rangy.getSelection().focusOffset;
|
||||
c.removeChild(t);
|
||||
game_text[0].removeChild(c);
|
||||
document.activeElement.blur();
|
||||
active_element.focus();
|
||||
return offset !== 6;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
// Connect to SocketIO server
|
||||
socket = io.connect(window.document.origin);
|
||||
|
||||
@ -1158,6 +1129,36 @@ $(document).ready(function(){
|
||||
game_text.attr('contenteditable', allowedit);
|
||||
}
|
||||
});
|
||||
// A simple feature detection test to determine whether the user interface
|
||||
// is using WebKit (Safari browser's rendering engine) because WebKit
|
||||
// requires special treatment to work correctly with the KoboldAI editor
|
||||
if(using_webkit_patch === null) {
|
||||
using_webkit_patch = (function() {
|
||||
try {
|
||||
var active_element = document.activeElement;
|
||||
var c = document.createElement("chunk");
|
||||
var t = document.createTextNode("KoboldAI");
|
||||
c.appendChild(t);
|
||||
game_text[0].appendChild(c);
|
||||
var r = rangy.createRange();
|
||||
r.setStart(t, 6);
|
||||
r.collapse(true);
|
||||
var s = rangy.getSelection();
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
game_text.blur();
|
||||
game_text.focus();
|
||||
var offset = rangy.getSelection().focusOffset;
|
||||
c.removeChild(t);
|
||||
game_text[0].removeChild(c);
|
||||
document.activeElement.blur();
|
||||
active_element.focus();
|
||||
return offset !== 6;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
}
|
||||
} else if(msg.cmd == "updatescreen") {
|
||||
var _gamestarted = gamestarted;
|
||||
gamestarted = msg.gamestarted;
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="static/jquery-3.6.0.min.js"></script>
|
||||
<script src="static/socket.io.min.js"></script>
|
||||
<script src="static/application.js?ver=1.16.2c"></script>
|
||||
<script src="static/application.js?ver=1.16.2d"></script>
|
||||
<script src="static/bootstrap.min.js"></script>
|
||||
<script src="static/bootstrap-toggle.min.js"></script>
|
||||
<script src="static/rangy-core.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user