From 147028f1a5fb695acf2979df3cb0f7bc4125ee84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 9 Jul 2023 14:13:35 +0200 Subject: [PATCH] lint --- src/js/glowingbear.js | 2 +- src/js/plugins.js | 47 ++++++++++++++++++++++--------------------- src/js/utils.js | 2 +- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/js/glowingbear.js b/src/js/glowingbear.js index 1ab8cc0..f9eaf9e 100644 --- a/src/js/glowingbear.js +++ b/src/js/glowingbear.js @@ -131,7 +131,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', // Show a TLS warning if GB was loaded over an unencrypted connection, // except for local instances (local files, testing) $scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) && - (["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1) + (["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1); $rootScope.isWindowFocused = function() { if (typeof $scope.documentHidden === "undefined") { diff --git a/src/js/plugins.js b/src/js/plugins.js index ffd4ab2..a6e7412 100644 --- a/src/js/plugins.js +++ b/src/js/plugins.js @@ -239,34 +239,35 @@ plugins.factory('userPlugins', function() { var twitchPlugin = new UrlPlugin('Twitch video', function(url) { var regex = /(?:https?:\/\/)?clips\.twitch\.tv\/([^\?\&\/\s]+)/i, - match = url.match(regex); + match = url.match(regex), + embedurl, + element; - if (match){ + if (match) { var clipId = match[1]; - var embedurl = "https://clips.twitch.tv/embed?clip=" + clipId + "&parent=" + window.location.hostname; - - var element = angular.element('') - .attr('src', embedurl) - .attr('width', '560') - .attr('height', '315') - .attr('allowfullscreen', 'true'); + embedurl = "https://clips.twitch.tv/embed?clip=" + clipId + "&parent=" + window.location.hostname; + element = angular.element('') + .attr('src', embedurl) + .attr('width', '560') + .attr('height', '315') + .attr('allowfullscreen', 'true'); return element.prop('outerHTML'); } - - var regex = /(?:https?:(?:\/\/www\.)?)?twitch\.tv\/(?:videos\/(\d+)|(\w+))/i, - match = url.match(regex); + + regex = /(?:https?:(?:\/\/www\.)?)?twitch\.tv\/(?:videos\/(\d+)|(\w+))/i; + match = url.match(regex); if (match) { - var mediaType = "video"; - if(match[1] === undefined) { - mediaType = "channel"; - } - var mediaId = match[1] === undefined ? match[2] : match[1]; - var embedurl = "https://player.twitch.tv/?" + mediaType + "=" + mediaId + "&parent=" + window.location.hostname + "&autoplay=false&muted=true"; - var element = angular.element('') - .attr('src', embedurl) - .attr('width', '560') - .attr('height', '315') - .attr('allowfullscreen', 'true'); + var mediaType = "video"; + if (match[1] === undefined) { + mediaType = "channel"; + } + var mediaId = match[1] === undefined ? match[2] : match[1]; + embedurl = "https://player.twitch.tv/?" + mediaType + "=" + mediaId + "&parent=" + window.location.hostname + "&autoplay=false&muted=true"; + element = angular.element('') + .attr('src', embedurl) + .attr('width', '560') + .attr('height', '315') + .attr('allowfullscreen', 'true'); return element.prop('outerHTML'); } }); diff --git a/src/js/utils.js b/src/js/utils.js index ac5dde0..dfa4e0a 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -27,7 +27,7 @@ weechat.factory('utils', function() { const _isTauri = window.__TAURI__ !== undefined; var isTauri = function() { return _isTauri; - } + }; // Inject a javascript (used by KaTeX) var inject_script = function(script_url) {