From bde6b9ee051beb1949d1b626de5747993dcb6cce Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 25 Sep 2022 01:29:55 +0300 Subject: [PATCH] update app code --- docs/.nojekyll | 0 docs/ytcg.js | 13 ------------- {docs => src}/index.html | 0 {docs => src}/styles.css | 0 {docs => src}/youtubeID.js | 0 src/ytcg.js | 21 +++++++++++++++++++++ 6 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 docs/.nojekyll delete mode 100644 docs/ytcg.js rename {docs => src}/index.html (100%) rename {docs => src}/styles.css (100%) rename {docs => src}/youtubeID.js (100%) create mode 100644 src/ytcg.js diff --git a/docs/.nojekyll b/docs/.nojekyll deleted file mode 100644 index e69de29..0000000 diff --git a/docs/ytcg.js b/docs/ytcg.js deleted file mode 100644 index f6bcc06..0000000 --- a/docs/ytcg.js +++ /dev/null @@ -1,13 +0,0 @@ -function getCover() -{ - var videoUrl = document.getElementById('videoUrl').value; - var videoCover = new Image(); - - videoCover.onload = function() - { - document.getElementById('ytImage').innerHTML = - ''; - } - - videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg'; -} diff --git a/docs/index.html b/src/index.html similarity index 100% rename from docs/index.html rename to src/index.html diff --git a/docs/styles.css b/src/styles.css similarity index 100% rename from docs/styles.css rename to src/styles.css diff --git a/docs/youtubeID.js b/src/youtubeID.js similarity index 100% rename from docs/youtubeID.js rename to src/youtubeID.js diff --git a/src/ytcg.js b/src/ytcg.js new file mode 100644 index 0000000..9703f83 --- /dev/null +++ b/src/ytcg.js @@ -0,0 +1,21 @@ +function getCover() +{ + 'use strict'; + + let videoUrl = document.getElementById('videoUrl').value; + let imageDiv = document.getElementById('ytImage'); + imageDiv.innerHTML = ''; + + let videoCover = document.createElement('img'); + let imageLink = document.createElement('a'); + + videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg'; + imageLink.href = videoCover.src; + imageLink.download = 'cover'; + videoCover.onload = function() { + imageLink.title = videoCover.width + 'x' + videoCover.height; + } + + imageLink.appendChild(videoCover); + imageDiv.appendChild(imageLink); +}