aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/client.js33
-rw-r--r--src/client/InputWithHistory.hx12
-rw-r--r--src/client/Main.hx2
-rw-r--r--src/client/players/Raw.hx14
4 files changed, 41 insertions, 20 deletions
diff --git a/res/client.js b/res/client.js
index 978a7aa..318971b 100644
--- a/res/client.js
+++ b/res/client.js
@@ -756,15 +756,22 @@ var client_InputWithHistory = function(element,history,maxItems,onEnter) {
element.onkeydown = $bind(this,this.onKeyDown);
};
client_InputWithHistory.__name__ = true;
+client_InputWithHistory.pushIfNotLast = function(arr,item) {
+ var len = arr.length;
+ if(len == 0 || arr[len - 1] != item) {
+ arr.push(item);
+ }
+};
client_InputWithHistory.prototype = {
onKeyDown: function(e) {
switch(e.keyCode) {
case 13:
- if(this.element.value.length == 0) {
+ var value = this.element.value;
+ if(value.length == 0) {
return;
}
- if(this.onEnter(this.element.value)) {
- this.history.push(this.element.value);
+ if(this.onEnter(value)) {
+ client_InputWithHistory.pushIfNotLast(this.history,value);
}
if(this.history.length > this.maxItems) {
this.history.shift();
@@ -1024,7 +1031,7 @@ client_Main.prototype = {
return;
}
mediaUrl.value = "";
- this.settings.latestLinks.push(url);
+ client_InputWithHistory.pushIfNotLast(this.settings.latestLinks,url);
client_Settings.write(this.settings);
var _this_r = new RegExp(", ?(https?)","g".split("u").join(""));
var links = url.replace(_this_r,"|$1").split("|");
@@ -2216,17 +2223,21 @@ client_players_Raw.prototype = {
var _gthis = this;
var decodedUrl = decodeURIComponent(url.split("+").join(" "));
var title = HxOverrides.substr(decodedUrl,decodedUrl.lastIndexOf("/") + 1,null);
- if(this.matchName.match(title)) {
+ var isNameMatched = this.matchName.match(title);
+ if(isNameMatched) {
title = this.matchName.matched(1);
} else {
title = Lang.get("rawVideo");
}
- var isHls = this.matchName.matched(2).indexOf("m3u8") != -1;
- if(isHls && !this.isHlsLoaded) {
- this.loadHlsPlugin(function() {
- _gthis.getVideoData(url,callback);
- });
- return;
+ var isHls = false;
+ if(isNameMatched) {
+ isHls = this.matchName.matched(2).indexOf("m3u8") != -1;
+ if(isHls && !this.isHlsLoaded) {
+ this.loadHlsPlugin(function() {
+ _gthis.getVideoData(url,callback);
+ });
+ return;
+ }
}
var video = window.document.createElement("video");
video.src = url;
diff --git a/src/client/InputWithHistory.hx b/src/client/InputWithHistory.hx
index 9c5b615..ecba43a 100644
--- a/src/client/InputWithHistory.hx
+++ b/src/client/InputWithHistory.hx
@@ -23,12 +23,18 @@ class InputWithHistory {
element.onkeydown = onKeyDown;
}
+ public static function pushIfNotLast(arr:Array<String>, item:String):Void {
+ final len = arr.length;
+ if (len == 0 || arr[len - 1] != item) arr.push(item);
+ }
+
function onKeyDown(e:KeyboardEvent) {
switch (e.keyCode) {
case 13: // Enter
- if (element.value.length == 0) return;
- final isAdd = onEnter(element.value);
- if (isAdd) history.push(element.value);
+ final value = element.value;
+ if (value.length == 0) return;
+ final isAdd = onEnter(value);
+ if (isAdd) pushIfNotLast(history, value);
if (history.length > maxItems) history.shift();
historyId = -1;
element.value = "";
diff --git a/src/client/Main.hx b/src/client/Main.hx
index 846acf6..7e3a3be 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -202,7 +202,7 @@ class Main {
final url = mediaUrl.value;
if (url.length == 0) return;
mediaUrl.value = "";
- settings.latestLinks.push(url);
+ InputWithHistory.pushIfNotLast(settings.latestLinks, url);
Settings.write(settings);
final url = ~/, ?(https?)/g.replace(url, "|$1");
final links = url.split("|");
diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx
index dacf45c..57dd9b3 100644
--- a/src/client/players/Raw.hx
+++ b/src/client/players/Raw.hx
@@ -33,12 +33,16 @@ class Raw implements IPlayer {
public function getVideoData(url:String, callback:(data:VideoData)->Void):Void {
final decodedUrl = url.urlDecode();
var title = decodedUrl.substr(decodedUrl.lastIndexOf("/") + 1);
- if (matchName.match(title)) title = matchName.matched(1);
+ final isNameMatched = matchName.match(title);
+ if (isNameMatched) title = matchName.matched(1);
else title = Lang.get("rawVideo");
- final isHls = matchName.matched(2).contains("m3u8");
- if (isHls && !isHlsLoaded) {
- loadHlsPlugin(() -> getVideoData(url, callback));
- return;
+ var isHls = false;
+ if (isNameMatched) {
+ isHls = matchName.matched(2).contains("m3u8");
+ if (isHls && !isHlsLoaded) {
+ loadHlsPlugin(() -> getVideoData(url, callback));
+ return;
+ }
}
final video = document.createVideoElement();
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage