From e69e15bec70a8975aaf19236c321cc9fdd86884d Mon Sep 17 00:00:00 2001
From: Gnome Ann <>
Date: Thu, 30 Sep 2021 22:58:54 -0400
Subject: [PATCH] Move using_webkit_patch to earlier in the code
I don't know it this or help or not but I hope it does.
---
static/application.js | 49 +++++++++++++++++++------------------------
templates/index.html | 2 +-
2 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/static/application.js b/static/application.js
index 04cf862e..a2961c4c 100644
--- a/static/application.js
+++ b/static/application.js
@@ -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 = null;
+var using_webkit_patch = true;
// Key states
var shift_down = false;
@@ -1132,33 +1132,26 @@ $(document).ready(function(){
// 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;
- }
- })();
- }
+ (function() {
+ 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();
+ using_webkit_patch = rangy.getSelection().focusOffset !== 6;
+ c.removeChild(t);
+ game_text[0].removeChild(c);
+ document.activeElement.blur();
+ active_element.focus();
+ })();
} else if(msg.cmd == "updatescreen") {
var _gamestarted = gamestarted;
gamestarted = msg.gamestarted;
diff --git a/templates/index.html b/templates/index.html
index 55978aec..3e402eaf 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -6,7 +6,7 @@
-
+