aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Main.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-07-05 17:09:56 +0300
committerRblSb <msrblsb@gmail.com>2021-07-05 17:09:56 +0300
commitcf78d464be214eedcd7909001ece2aa0a216d136 (patch)
tree5801ef0ca01589ed923c961a93b30278df9ea9d3 /src/client/Main.hx
parentede45cea8706eb8540e466df9861c2af8ebf9c44 (diff)
vtt/srt subs support
Diffstat (limited to 'src/client/Main.hx')
-rw-r--r--src/client/Main.hx24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx
index e9cda39..c5dca67 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -26,7 +26,7 @@ using ClientTools;
using StringTools;
class Main {
- static inline var SETTINGS_VERSION = 2;
+ static inline var SETTINGS_VERSION = 3;
public final settings:ClientSettings;
public var isSyncActive = true;
@@ -65,6 +65,7 @@ class Main {
isSwapped: false,
isUserListHidden: true,
latestLinks: [],
+ latestSubs: [],
hotkeysEnabled: true
}
Settings.init(defaults, settingsPatcher);
@@ -93,6 +94,9 @@ class Main {
case 1:
final data:ClientSettings = data;
data.hotkeysEnabled = true;
+ case 2:
+ final data:ClientSettings = data;
+ data.latestSubs = [];
case SETTINGS_VERSION, _:
throw 'skipped version $version';
}
@@ -154,9 +158,10 @@ class Main {
ge("#mediatitle").onkeydown = (e:KeyboardEvent) -> {
if (e.keyCode == KeyCode.Return) addVideoUrl(true);
}
- ge("#subsurl").onkeydown = (e:KeyboardEvent) -> {
- if (e.keyCode == KeyCode.Return) addVideoUrl(true);
- }
+ new InputWithHistory(cast ge("#subsurl"), settings.latestSubs, 10, value -> {
+ addVideoUrl(true);
+ return false;
+ });
ge("#ce_queue_next").onclick = e -> addIframe(false);
ge("#ce_queue_end").onclick = e -> addIframe(true);
@@ -205,12 +210,17 @@ class Main {
function addVideoUrl(atEnd:Bool):Void {
final mediaUrl:InputElement = cast ge("#mediaurl");
+ final subsUrl:InputElement = cast ge("#subsurl");
final checkbox:InputElement = cast ge("#addfromurl").querySelector(".add-temp");
final isTemp = checkbox.checked;
final url = mediaUrl.value;
+ final subs = subsUrl.value;
if (url.length == 0) return;
mediaUrl.value = "";
InputWithHistory.pushIfNotLast(settings.latestLinks, url);
+ if (subs.length != 0) {
+ InputWithHistory.pushIfNotLast(settings.latestSubs, subs);
+ }
Settings.write(settings);
final url = ~/, ?(https?)/g.replace(url, "|$1");
final links = url.split("|");
@@ -351,8 +361,7 @@ class Main {
public function getPlaylistLinks():Array<String> {
final items = player.getItems();
return [
- for (item in items)
- item.url
+ for (item in items) item.url
];
}
@@ -801,7 +810,8 @@ class Main {
function onChatVideoLoaded(e:Event):Void {
final el:VideoElement = cast e.target;
if (emoteMaxSize == null) {
- emoteMaxSize = Std.parseInt(window.getComputedStyle(el).getPropertyValue("max-width"));
+ emoteMaxSize = Std.parseInt(window.getComputedStyle(el)
+ .getPropertyValue("max-width"));
}
// fixes default video tag size in chat when tab unloads videos in background
// (some browsers optimization i guess)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage