From 203640a06162f16442d55923a8fcce6243b48b83 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Tue, 12 Jan 2021 16:01:13 +0100 Subject: [PATCH] fix: Avoiding loading forever on unsupported url. Issue #12 --- lib/Peertube/DL/public/css/index.css | 12 ++++----- lib/Peertube/DL/public/index.html | 28 +++++++++++--------- lib/Peertube/DL/public/js/peertube-dl-web.js | 24 +++++++++++++++-- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/lib/Peertube/DL/public/css/index.css b/lib/Peertube/DL/public/css/index.css index 005477a..ca46a24 100644 --- a/lib/Peertube/DL/public/css/index.css +++ b/lib/Peertube/DL/public/css/index.css @@ -135,7 +135,7 @@ h2 { width: 10%; } -#poping-notice { +.poping-notice { display: none; position: fixed; top: 50%; @@ -149,17 +149,17 @@ h2 { max-height: 95%; overflow-y: scroll; } -#poping-notice.active { +.poping-notice.active { display: block; } -#poping-notice-container-bar { +.poping-notice-container-bar { display: flex; justify-content: center; font-size: 5rem; } -#close-poping-notice { +.close-poping-notice { width: 150px; height: 150px; align-items: center; @@ -172,13 +172,13 @@ h2 { text-decoration: none; } -#close-poping-notice:hover,#close-poping-notice:focus { +.close-poping-notice:hover,.close-poping-notice:focus { background: black; color: white; } @media (min-width: 668px) { - #poping-notice { + .poping-notice { width: 629px; } } diff --git a/lib/Peertube/DL/public/index.html b/lib/Peertube/DL/public/index.html index a92b6ba..729e86b 100644 --- a/lib/Peertube/DL/public/index.html +++ b/lib/Peertube/DL/public/index.html @@ -30,21 +30,23 @@ -
-

This webpage is free as in freedom software, it is offered to you with the hope it will be useful, but without any warranty, - you can find the source code at my gitea with docs to setup your own - webpage like this, this software is licensed under the AGPLv3 license which means you MUST convey the source code in a human readable form - if you distribute this software or use it as an service to users of service or distributees.

+

+
+

This webpage is free as in freedom software, it is offered to you with the hope it will be useful, but without any warranty, + you can find the source code at my gitea with docs to setup your own + webpage like this, this software is licensed under the AGPLv3 license which means you MUST convey the source code in a human readable form + if you distribute this software or use it as an service to users of service or distributees.

-

I hope that if you find a non supported url which should be supported, a bug, or a feature you would like this webpage to have you file an issue in - https://gitea.sergiotarxz.freemyip.com/sergiotarxz/Peertube-dl/issues - to help this software improve since I find tracking users a pretty bad way to discover bugs and potential good features.

+

I hope that if you find a non supported url which should be supported, a bug, or a feature you would like this webpage to have you file an issue in + https://gitea.sergiotarxz.freemyip.com/sergiotarxz/Peertube-dl/issues + to help this software improve since I find tracking users a pretty bad way to discover bugs and potential good features.

-

This webpage may load third party resources depending on the url you give to it which may put cookies in your browser, you are - encouraged to frecuently delete your browser cookies to avoid those third parties tracking you on internet, Firefox offers you an - option to delete cookies as soon as you close the browser which may be a good idea to enable in the orwellian internet of today.

-
- X +

This webpage may load third party resources depending on the url you give to it which may put cookies in your browser, you are + encouraged to frecuently delete your browser cookies to avoid those third parties tracking you on internet, Firefox offers you an + option to delete cookies as soon as you close the browser which may be a good idea to enable in the orwellian internet of today.

+
+
+ X
diff --git a/lib/Peertube/DL/public/js/peertube-dl-web.js b/lib/Peertube/DL/public/js/peertube-dl-web.js index d51184e..f6a6d31 100644 --- a/lib/Peertube/DL/public/js/peertube-dl-web.js +++ b/lib/Peertube/DL/public/js/peertube-dl-web.js @@ -13,6 +13,7 @@ let modalLoading; let filename; let url; let popingNotice; +let popingNoticeContent; let closePopingNotice; function downloadFormButtonHandler(event) { @@ -26,6 +27,24 @@ function downloadFormButtonHandler(event) { modalLoading.classList.remove('active'); modalVideoContainer.style.display = 'block'; }); + }).catch ( (error) => { + modalLoading.classList.remove('active'); + popingNoticeContent.innerHTML = ''; + let p = document.createElement('p'); + p.appendChild(document.createTextNode('The url ')); + let input_url = document.createElement('a'); + input_url.href = downloadFormUrl.value; + input_url.innerText = downloadFormUrl.value; + p.appendChild(input_url) + p.appendChild(document.createTextNode(' is not supported, if you think this is an error, report it ')); + let issues_url = 'https://gitea.sergiotarxz.freemyip.com/sergiotarxz/Peertube-dl/issues'; + let issues_url_element = document.createElement('a'); + issues_url_element.href = issues_url; + issues_url_element.innerText = 'here'; + p.appendChild(issues_url_element); + p.appendChild(document.createTextNode('.')); + popingNoticeContent.appendChild(p); + popingNotice.classList.add('active'); }); } @@ -99,8 +118,9 @@ window.addEventListener('load', (event) => { downloadVideoPrepare = document.querySelector('#download-video-prepare'); closeAndResetVideoContainer = document.querySelector('#close-and-reset-video-container'); modalLoading = document.querySelector('#modal-loading'); - popingNotice = document.querySelector('#poping-notice'); - closePopingNotice = document.querySelector('#close-poping-notice'); + popingNotice = document.querySelector('.poping-notice'); + popingNoticeContent = document.querySelector('.poping-notice-content'); + closePopingNotice = document.querySelector('.close-poping-notice'); downloadFormButton.addEventListener('click', downloadFormButtonHandler); downloadVideoPrepare.addEventListener('click', downloadVideoPrepareHandler);