aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/client.js39
-rw-r--r--src/client/Buttons.hx32
-rw-r--r--src/client/Player.hx6
3 files changed, 58 insertions, 19 deletions
diff --git a/res/client.js b/res/client.js
index 66d48ae..478cacd 100644
--- a/res/client.js
+++ b/res/client.js
@@ -772,12 +772,7 @@ client_Buttons.initHotkeys = function(main,player) {
if(!client_Buttons.settings.hotkeysEnabled) {
return;
}
- var target = e.target;
- if(target.isContentEditable) {
- return;
- }
- var tagName = target.tagName;
- if(tagName == "INPUT" || tagName == "TEXTAREA") {
+ if(client_Buttons.isElementEditable(e.target)) {
return;
}
var key = e.keyCode;
@@ -819,6 +814,19 @@ client_Buttons.initHotkeys = function(main,player) {
e.preventDefault();
};
};
+client_Buttons.isElementEditable = function(target) {
+ if(target == null) {
+ return false;
+ }
+ if(target.isContentEditable) {
+ return true;
+ }
+ var tagName = target.tagName;
+ if(tagName == "INPUT" || tagName == "TEXTAREA") {
+ return true;
+ }
+ return false;
+};
client_Buttons.updateSynchThresholdBtn = function() {
var tmp = "" + Lang.get("synchThreshold") + ": " + client_Buttons.settings.synchThreshold;
window.document.querySelector("#synchThresholdBtn").innerText = tmp + "s";
@@ -852,6 +860,7 @@ client_Buttons.initChatInput = function(main) {
window.document.ontouchmove = function(e) {
return e.preventDefault();
};
+ window.document.body.style.height = "-webkit-fill-available";
window.document.querySelector("#chat").style.height = "-webkit-fill-available";
}
var chatline = window.document.querySelector("#chatline");
@@ -860,17 +869,25 @@ client_Buttons.initChatInput = function(main) {
var startY = window.scrollY;
haxe_Timer.delay(function() {
window.scrollBy(0,-(window.scrollY - startY));
- var tmp = "" + Std.string(window.innerHeight);
- window.document.querySelector("#chat").style.height = tmp + "px";
window.document.querySelector("#video").scrollTop = 0;
main.scrollChatToEnd();
+ if(window.visualViewport == null) {
+ var tmp = "" + Std.string(window.innerHeight);
+ window.document.querySelector("#chat").style.height = tmp + "px";
+ }
},100);
} else if(client_Utils.isTouch()) {
main.scrollChatToEnd();
}
};
+ if(client_Utils.isIOS() && window.visualViewport != null) {
+ window.visualViewport.addEventListener("resize",function(e) {
+ var tmp = "" + Std.string(window.innerHeight);
+ return window.document.querySelector("#chat").style.height = tmp + "px";
+ });
+ }
chatline.onblur = function(e) {
- if(client_Utils.isIOS()) {
+ if(client_Utils.isIOS() && window.visualViewport == null) {
window.document.querySelector("#chat").style.height = "-webkit-fill-available";
}
};
@@ -2189,7 +2206,7 @@ client_Player.prototype = {
return;
}
this.main.send({ type : "Play", play : { time : this.getTime()}});
- if(this.main.hasLeaderOnPauseRequest()) {
+ if(this.main.hasLeaderOnPauseRequest() && this.items.length > 0) {
if(this.main.hasPermission((this.main.personal.group & 8) != 0 ? ClientGroup.Admin : ClientGroup.User,"requestLeader")) {
this.main.toggleLeader();
}
@@ -2197,7 +2214,7 @@ client_Player.prototype = {
}
,onPause: function() {
var _gthis = this;
- if(this.main.hasLeaderOnPauseRequest() && this.getTime() != 0 && !this.main.hasLeader()) {
+ if(this.main.hasLeaderOnPauseRequest() && this.items.length > 0 && this.getTime() != 0 && !this.main.hasLeader()) {
client_JsApi.once("SetLeader",function(event) {
if(event.setLeader.clientName != _gthis.main.personal.name) {
return;
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx
index b11e3fd..902da1b 100644
--- a/src/client/Buttons.hx
+++ b/src/client/Buttons.hx
@@ -8,6 +8,7 @@ import js.html.Element;
import js.html.ImageElement;
import js.html.InputElement;
import js.html.KeyboardEvent;
+import js.html.VisualViewport;
using StringTools;
@@ -288,9 +289,7 @@ class Buttons {
window.onkeydown = function(e:KeyboardEvent) {
if (!settings.hotkeysEnabled) return;
final target:Element = cast e.target;
- if (target.isContentEditable) return;
- final tagName = target.tagName;
- if (tagName == "INPUT" || tagName == "TEXTAREA") return;
+ if (isElementEditable(target)) return;
final key:KeyCode = cast e.keyCode;
if (key == Backspace) e.preventDefault();
if (!e.altKey) return;
@@ -320,6 +319,14 @@ class Buttons {
}
}
+ static function isElementEditable(target:Element):Bool {
+ if (target == null) return false;
+ if (target.isContentEditable) return true;
+ final tagName = target.tagName;
+ if (tagName == "INPUT" || tagName == "TEXTAREA") return true;
+ return false;
+ }
+
static function updateSynchThresholdBtn():Void {
final text = Lang.get("synchThreshold");
final secs = settings.synchThreshold;
@@ -354,22 +361,31 @@ class Buttons {
document.ontouchmove = e -> {
e.preventDefault();
}
+ document.body.style.height = "-webkit-fill-available";
ge("#chat").style.height = "-webkit-fill-available";
}
final chatline:InputElement = cast ge("#chatline");
chatline.onfocus = e -> {
if (Utils.isIOS()) {
- var startY = window.scrollY;
+ final startY = window.scrollY;
Timer.delay(() -> {
window.scrollBy(0, -(window.scrollY - startY));
- ge("#chat").style.height = '${window.innerHeight}px';
ge("#video").scrollTop = 0;
main.scrollChatToEnd();
+ if (getVisualViewport() == null) { // ios < 13
+ ge("#chat").style.height = '${window.innerHeight}px';
+ }
}, 100);
} else if (Utils.isTouch()) main.scrollChatToEnd();
}
+ if (Utils.isIOS() && getVisualViewport() != null) {
+ final viewport = getVisualViewport();
+ viewport.addEventListener("resize", e -> {
+ ge("#chat").style.height = '${window.innerHeight}px';
+ });
+ }
chatline.onblur = e -> {
- if (Utils.isIOS()) {
+ if (Utils.isIOS() && getVisualViewport() == null) { // ios < 13
ge("#chat").style.height = "-webkit-fill-available";
}
}
@@ -387,6 +403,10 @@ class Buttons {
});
}
+ static inline function getVisualViewport():Null<VisualViewport> {
+ return (window : Dynamic).visualViewport;
+ }
+
static function initPageFullscreen():Void {
document.onfullscreenchange = e -> {
final el = document.documentElement;
diff --git a/src/client/Player.hx b/src/client/Player.hx
index 7dbe018..b9de8cb 100644
--- a/src/client/Player.hx
+++ b/src/client/Player.hx
@@ -175,7 +175,8 @@ class Player {
time: getTime()
}
});
- if (main.hasLeaderOnPauseRequest()) {
+ final hasAutoPause = main.hasLeaderOnPauseRequest() && items.length > 0;
+ if (hasAutoPause) {
// do not remove leader if user cannot request it back
final group:Client.ClientGroup = main.isAdmin() ? Admin : User;
if (main.hasPermission(group, RequestLeaderPerm)) main.toggleLeader();
@@ -183,7 +184,8 @@ class Player {
}
public function onPause():Void {
- final hasAutoPause = main.hasLeaderOnPauseRequest() && getTime() != 0;
+ final hasAutoPause = main.hasLeaderOnPauseRequest() && items.length > 0
+ && getTime() != 0;
if (hasAutoPause && !main.hasLeader()) {
JsApi.once(SetLeader, event -> {
final name = event.setLeader.clientName;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage