General theme: add license and add URL source code in footer

This commit is contained in:
Jesús
2020-12-29 15:36:23 -05:00
parent 701786a9cc
commit 0f78e73e80
17 changed files with 636 additions and 110 deletions

View File

@@ -130,95 +130,7 @@
<button type="reset" id="item-selection-reset">Clear selection</button>
</div>
</form>
<script>
(function main() {
/* Takes control of the form if javascript is enabled, so that adding stuff to a playlist will not cause things to stop loading, and will display a status message. If javascript is disabled, the form will still work using regular HTML methods, but causes things on the page (such as the video) to stop loading. */
const playlistAddForm = document.getElementById('playlist-edit');
function setStyle(element, property, value){
element.style[property] = value;
}
function removeMessage(messageBox){
messageBox.parentNode.removeChild(messageBox);
}
function displayMessage(text, error=false){
let currentMessageBox = document.getElementById('message-box');
if(currentMessageBox !== null){
currentMessageBox.parentNode.removeChild(currentMessageBox);
}
let messageBox = document.createElement('div');
if(error){
messageBox.setAttribute('role', 'alert');
} else {
messageBox.setAttribute('role', 'status');
}
messageBox.setAttribute('id', 'message-box');
let textNode = document.createTextNode(text);
messageBox.appendChild(textNode);
document.querySelector('main').appendChild(messageBox);
let currentstyle = window.getComputedStyle(messageBox);
let removalDelay;
if(error){
removalDelay = 5000;
} else {
removalDelay = 1500;
}
window.setTimeout(setStyle, 20, messageBox, 'opacity', 1);
window.setTimeout(setStyle, removalDelay, messageBox, 'opacity', 0);
window.setTimeout(removeMessage, removalDelay+300, messageBox);
}
// https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript
function sendData(event){
var clicked_button = document.activeElement;
if(clicked_button === null || clicked_button.getAttribute('type') !== 'submit' || clicked_button.parentElement != event.target){
console.log('ERROR: clicked_button not valid');
return;
}
if(clicked_button.getAttribute('value') !== 'add'){
return; // video(s) are being removed from playlist, just let it refresh the page
}
event.preventDefault();
var XHR = new XMLHttpRequest();
var FD = new FormData(playlistAddForm);
if(FD.getAll('video_info_list').length === 0){
displayMessage('Error: No videos selected', true);
return;
}
if(FD.get('playlist_name') === ""){
displayMessage('Error: No playlist selected', true);
return;
}
// https://stackoverflow.com/questions/48322876/formdata-doesnt-include-value-of-buttons
FD.append('action', 'add');
XHR.addEventListener('load', function(event){
if(event.target.status == 204){
displayMessage('Added videos to playlist "' + FD.get('playlist_name') + '"');
} else {
displayMessage('Error adding videos to playlist: ' + event.target.status.toString(), true);
}
});
XHR.addEventListener('error', function(event){
if(event.target.status == 0){
displayMessage('XHR failed: Check that XHR requests are allowed', true);
} else {
displayMessage('XHR failed: Unknown error', true);
}
});
XHR.open('POST', playlistAddForm.getAttribute('action'));
XHR.send(FD);
}
playlistAddForm.addEventListener('submit', sendData);
}());
</script>
<script src="/youtube.com/static/js/playlistadd.js"></script>
{% endif %}
</header>
@@ -230,12 +142,23 @@
</main>
<footer class="footer">
<p>This site is Free/Libre Software</p>
{% if current_commit and current_version %}
<p>Current version: {{ current_version }}-{{ current_commit }} @ {{ current_branch }}</p>
{% else %}
<p>Current version: {{ current_version }}</p>
{% endif %}
<div>
<a href="https://libregit.org/heckyel/yt-local.git"
rel="noopener noreferrer" target="_blank">
Released under the AGPLv3 or later
</a>
</div>
<div>
<p>This site is Free/Libre Software</p>
{% if current_commit and current_version %}
<p>Current version: {{ current_version }}-{{ current_commit }} @ {{ current_branch }}</p>
{% else %}
<p>Current version: {{ current_version }}</p>
{% endif %}
</div>
<div>
<a href="/youtube.com/licenses" data-jslicense="1" rel="noopener noreferrer" target="_blank">JavaScript licenses</a>
</div>
</footer>
</body>

View File

@@ -0,0 +1,49 @@
{% set page_title = title %}
{% extends "base.html" %}
{% block style %}
<link href="/youtube.com/static/license.css" rel="stylesheet"/>
{% endblock style %}
{% block main %}
<table id="jslicense-labels1" class="table">
<caption>JavaScript Licensing Table</caption>
<thead>
<tr>
<th>File</th>
<th>License</th>
<th>Source</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="File"><a href="/youtube.com/static/js/comments.js">comments.js</a></td>
<td data-label="License"><a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0 or later</a></td>
<td data-label="Source"><a href="/youtube.com/static/js/comments.js">comments.js</a></td>
</tr>
<tr>
<td data-label="File"><a href="/youtube.com/static/js/common.js">common.js</a></td>
<td data-label="License"><a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0 or later</a></td>
<td data-label="Source"><a href="/youtube.com/static/js/common.js">common.js</a></td>
</tr>
<tr>
<td data-label="File"><a href="/youtube.com/static/js/hotkeys.js">hotkeys.js</a></td>
<td data-label="License"><a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0 or later</a></td>
<td data-label="Source"><a href="/youtube.com/static/js/hotkeys.js">hotkeys.js</a></td>
</tr>
<tr>
<td data-label="File"><a href="/youtube.com/static/js/playlistadd.js">playlistadd.js</a></td>
<td data-label="License"><a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0 or later</a></td>
<td data-label="Source"><a href="/youtube.com/static/js/playlistadd.js">playlistadd.js</a></td>
</tr>
<tr>
<td data-label="File"><a href="/youtube.com/static/js/speedyplay.js">speedyplay.js</a></td>
<td data-label="License"><a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0 or later</a></td>
<td data-label="Source"><a href="/youtube.com/static/js/speedyplay.js">speedyplay.js</a></td>
</tr>
<tr>
<td data-label="File"><a href="/youtube.com/static/js/transcript-table.js">transcript-table.js</a></td>
<td data-label="License"><a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0 or later</a></td>
<td data-label="Source"><a href="/youtube.com/static/js/transcript-table.js">transcript-table.js</a></td>
</tr>
</tbody>
</table>
{% endblock main %}

View File

@@ -76,21 +76,7 @@
<div class="external-player-controls">
<input class="speed" id="speed-control" type="text">
<script>
(function main() {
'use strict';
const video = document.getElementById('js-video-player');
const speedInput = document.getElementById('speed-control');
speedInput.addEventListener('keyup', (event) => {
if (event.key === 'Enter') {
let speed = parseFloat(speedInput.value);
if(!isNaN(speed)){
video.playbackRate = speed;
}
}
});
}());
</script>
<script src="/youtube.com/static/js/speedyplay.js"></script>
</div>
<input class="v-checkbox" name="video_info_list" value="{{ video_info }}" form="playlist-edit" type="checkbox">
@@ -184,6 +170,7 @@
</nav>
{% if playlist['current_index'] is not none %}
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
(function main() {
// from https://stackoverflow.com/a/6969486
function escapeRegExp(string) {
@@ -260,10 +247,12 @@
}
}
}());
// @license-end
</script>
{% endif %}
{% if playlist['id'] is not none %}
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
(function main() {
// lazy load playlist images
// copied almost verbatim from
@@ -296,6 +285,7 @@
observer.observe(img);
});
}());
// @license-end
</script>
{% endif %}
</div>