From 5c77554df0f130c8d5c3c439cf7546ff6b48b192 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Sun, 13 Mar 2022 09:53:25 +0100 Subject: [PATCH] add download as link --- frontend/script.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/frontend/script.js b/frontend/script.js index d0d52fc..e6e1cdf 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -27,32 +27,19 @@ const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably"); if(canPlayType) { const Button = videojs.getComponent("Button"); + const Component = videojs.getComponent("Component"); + const cbutton = {}; cbutton.clickHandler = (ev) => { player.trigger("chromecastRequested"); } - cbutton.text = "Chromecast"; - - const dbutton = {}; - dbutton.text = "Download"; - dbutton.clickHandler = (ev) => { - if(info.download) { - window.open(info.download); - } - } const bigCastButtonWrapper = new Button(player, cbutton); - const bigDownloadButtonWrapper = new Button(player, dbutton); + const bigDownloadButtonWrapper = new Component(player); + bigDownloadButtonWrapper.el_ = document.createElement("a"); const bigCastButton = bigCastButtonWrapper.el(); const bigDownloadButton = bigDownloadButtonWrapper.el(); - for(const elem of bigCastButton.children) { - bigCastButton.removeChild(elem); - } - - for(const elem of bigDownloadButton.children) { - bigDownloadButton.removeChild(elem); - } bigCastButton.classList.add("vjs-control"); bigCastButton.classList.add("vjs-button"); @@ -62,6 +49,7 @@ player.addChild(bigCastButtonWrapper); if(info.download) { + bigDownloadButton.href = info.download; bigDownloadButton.classList.add("vjs-control"); bigDownloadButton.classList.add("vjs-button"); bigDownloadButton.classList.add("fas");