Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- public/index.html +68 -0
- public/script.js +751 -0
- public/style.css +272 -0
public/index.html
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
|
| 6 |
+
<title>Sakuga Video: A Showcase of Beautiful Animation</title>
|
| 7 |
+
<meta name="description" content="Watch an endless stream of beautiful anime and western animation clips and discover artists and shows you've never seen before.">
|
| 8 |
+
<link rel="icon" type="image/png" href="https://ik.imagekit.io/9llyyueko/STATIC%20IMAGES/Axinity%20Icons/AxinLogos/Variations/Axinity-Developer-Logos/Axinity-Developer-Logos/PNGs/Axin-Dev-Logo_512.png?updatedAt=1776325773641" />
|
| 9 |
+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
| 10 |
+
<link rel="stylesheet" href="style.css">
|
| 11 |
+
<script>
|
| 12 |
+
window.dataLayer = window.dataLayer || [];
|
| 13 |
+
function gtag(){dataLayer.push(arguments);}
|
| 14 |
+
gtag('js', new Date());
|
| 15 |
+
gtag('config', 'UA-143412573-1');
|
| 16 |
+
</script>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
<div id="videocontainer" class="fade-out">
|
| 20 |
+
<video muted preload="auto"></video>
|
| 21 |
+
<video muted preload="auto"></video>
|
| 22 |
+
<video muted preload="auto"></video>
|
| 23 |
+
<div id="other-controls" class="controls">
|
| 24 |
+
<p>options</p>
|
| 25 |
+
<div id="hidden">
|
| 26 |
+
<label class="checkbox">
|
| 27 |
+
<input type="checkbox" name="show-titles" id="show-titles">
|
| 28 |
+
Show titles
|
| 29 |
+
</label>
|
| 30 |
+
<label for="title-delay">Delay before showing
|
| 31 |
+
<div>
|
| 32 |
+
0s <input type="range" min="0" max="10" value="0" class="slider" id="title-delay"> 10s
|
| 33 |
+
</div>
|
| 34 |
+
</label>
|
| 35 |
+
<label class="checkbox">
|
| 36 |
+
<input type="checkbox" name="content-filter" id="questionable-content">
|
| 37 |
+
Allow questionable content
|
| 38 |
+
</label>
|
| 39 |
+
<label class="checkbox">
|
| 40 |
+
<input type="checkbox" name="content-filter" id="explicit-content">
|
| 41 |
+
Allow explicit content
|
| 42 |
+
</label>
|
| 43 |
+
</div>
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
<p id="title" class="fade-out"></p>
|
| 47 |
+
|
| 48 |
+
<div id="main-controls" class="controls">
|
| 49 |
+
<input list="tags" autocomplete="off" placeholder="Search for other themes">
|
| 50 |
+
<datalist id="tags"></datalist>
|
| 51 |
+
<ul id="copyright-tags" class="video-tags"></ul>
|
| 52 |
+
<ul id="artist-tags" class="video-tags"></ul>
|
| 53 |
+
<ul id="character-tags" class="video-tags"></ul>
|
| 54 |
+
<ul id="general-tags" class="video-tags"></ul>
|
| 55 |
+
|
| 56 |
+
<ul id="playback-controls">
|
| 57 |
+
<li><button id="previous" type="button"><i class="material-icons md-light md-48">skip_previous</i></button></li>
|
| 58 |
+
<li><button id="playpause" type="button"><i class="material-icons md-light md-48">pause</i></button></li>
|
| 59 |
+
<li><button id="next" type="button"><i class="material-icons md-light md-48">skip_next</i></button></li>
|
| 60 |
+
<li><button id="mute" type="button"><i class="material-icons md-light md-48">volume_off</i></button></li>
|
| 61 |
+
<li><button id="fullscreen" type="button"><i class="material-icons md-light md-48">fullscreen</i></button></li>
|
| 62 |
+
</ul>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
<iframe id="youtube-player" width="0" height="0" src="https://www.youtube.com/embed/hHW1oY26kxQ?enablejsapi=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"></iframe>
|
| 66 |
+
<script src="script.js"></script>
|
| 67 |
+
</body>
|
| 68 |
+
</html>
|
public/script.js
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const videoContainer = document.querySelector("#videocontainer");
|
| 2 |
+
const fullscreenButton = document.querySelector("#fullscreen");
|
| 3 |
+
const playpauseButton = document.querySelector("#playpause");
|
| 4 |
+
const nextButton = document.querySelector("#next");
|
| 5 |
+
const previousButton = document.querySelector("#previous");
|
| 6 |
+
const mainControls = document.querySelector("#main-controls");
|
| 7 |
+
const otherControls = document.querySelector("#other-controls");
|
| 8 |
+
const playPauseIcon = document.querySelector("#playpause i");
|
| 9 |
+
const fullscreenIcon = document.querySelector("#fullscreen i");
|
| 10 |
+
const muteIcon = document.querySelector("#mute i");
|
| 11 |
+
const input = document.querySelector("input[list=tags]");
|
| 12 |
+
const tagsDatalist = document.querySelector("#tags");
|
| 13 |
+
const generalTagsList = document.querySelector("#general-tags");
|
| 14 |
+
const characterTagsList = document.querySelector("#character-tags");
|
| 15 |
+
const artistTagsList = document.querySelector("#artist-tags");
|
| 16 |
+
const copyrightTagsList = document.querySelector("#copyright-tags");
|
| 17 |
+
const muteButton = document.querySelector("#mute");
|
| 18 |
+
const tagsToExclude = ["animated", "artist_unknown", "presumed"];
|
| 19 |
+
const questionableContentButton = document.querySelector(
|
| 20 |
+
"#questionable-content"
|
| 21 |
+
);
|
| 22 |
+
const explicitContentButton = document.querySelector("#explicit-content");
|
| 23 |
+
const showTitlesButton = document.querySelector("#show-titles");
|
| 24 |
+
const title = document.querySelector("#title");
|
| 25 |
+
const titleDelaySlider = document.querySelector("#title-delay");
|
| 26 |
+
|
| 27 |
+
const SHOW_TITLE_DURATION = 2500;
|
| 28 |
+
const PREVIOUS = 0;
|
| 29 |
+
const CURRENT = 1;
|
| 30 |
+
const NEXT = 2;
|
| 31 |
+
const PLAYING = 1;
|
| 32 |
+
const GENERAL = 0;
|
| 33 |
+
const ARTIST = 1;
|
| 34 |
+
const COPYRIGHT = 3;
|
| 35 |
+
const CHARACTER = 4;
|
| 36 |
+
|
| 37 |
+
const videos = document.querySelectorAll("video");
|
| 38 |
+
const videoPlayers = [videos[PREVIOUS], videos[CURRENT], videos[NEXT]];
|
| 39 |
+
const videoData = [null, null, null];
|
| 40 |
+
const videoIndexes = [null, null, null];
|
| 41 |
+
|
| 42 |
+
var tagsByName = new Map();
|
| 43 |
+
var playlist = [];
|
| 44 |
+
var currentTag = null;
|
| 45 |
+
var skipNextPlayPause = false;
|
| 46 |
+
var musicPlayer = null;
|
| 47 |
+
var muted = true;
|
| 48 |
+
let options = {
|
| 49 |
+
"show-titles": false,
|
| 50 |
+
"title-delay": 0,
|
| 51 |
+
"questionable-content": false,
|
| 52 |
+
"explicit-content": false,
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
let hideTitleTimeout;
|
| 56 |
+
let showTitleTimeout;
|
| 57 |
+
|
| 58 |
+
Array.prototype.rotate = function (n) {
|
| 59 |
+
while (this.length && n < 0) n += this.length;
|
| 60 |
+
this.push.apply(this, this.splice(0, n));
|
| 61 |
+
return this;
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
function playPlaylist(tag, videoId) {
|
| 65 |
+
currentTag = tag;
|
| 66 |
+
var count;
|
| 67 |
+
if (!tag) {
|
| 68 |
+
count = 50000;
|
| 69 |
+
} else {
|
| 70 |
+
count = tagsByName.get(tag).count;
|
| 71 |
+
}
|
| 72 |
+
saveTagToUrl(currentTag);
|
| 73 |
+
|
| 74 |
+
playlist = shuffle(Array.from(Array(count).keys()).map((n) => ++n));
|
| 75 |
+
|
| 76 |
+
videoIndexes[NEXT] = 0;
|
| 77 |
+
|
| 78 |
+
const videoDataPromise = videoId
|
| 79 |
+
? fetchVideoDataById(videoId)
|
| 80 |
+
: fetchVideoData(videoIndexes[NEXT], 1);
|
| 81 |
+
videoDataPromise
|
| 82 |
+
.then((data) => {
|
| 83 |
+
videoIndexes[NEXT] = data.index;
|
| 84 |
+
preloadVideo(data.video, NEXT);
|
| 85 |
+
})
|
| 86 |
+
.then(playNextPreloadedVideo);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
function shuffle(array) {
|
| 90 |
+
var currentIndex = array.length,
|
| 91 |
+
temporaryValue,
|
| 92 |
+
randomIndex;
|
| 93 |
+
|
| 94 |
+
// While there remain elements to shuffle...
|
| 95 |
+
while (0 !== currentIndex) {
|
| 96 |
+
// Pick a remaining element...
|
| 97 |
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
| 98 |
+
currentIndex -= 1;
|
| 99 |
+
|
| 100 |
+
// And swap it with the current element.
|
| 101 |
+
temporaryValue = array[currentIndex];
|
| 102 |
+
array[currentIndex] = array[randomIndex];
|
| 103 |
+
array[randomIndex] = temporaryValue;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
return array;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
function shiftIndex(index, offset) {
|
| 110 |
+
// increase or decrease index with wraparound
|
| 111 |
+
return (index + offset + playlist.length) % playlist.length;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
async function fetchVideoData(index, direction) {
|
| 115 |
+
var url = "/api/post.json?limit=1&page=" + playlist[index] + "&tags=";
|
| 116 |
+
if (currentTag) {
|
| 117 |
+
url = url + useUnderscores(currentTag);
|
| 118 |
+
}
|
| 119 |
+
url = url + explicitUrlFilter();
|
| 120 |
+
return fetchNextValidVideoData(url, index, direction);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
async function fetchVideoDataById(videoId) {
|
| 124 |
+
var url = "/api/post.json?tags=id:" + videoId;
|
| 125 |
+
return fetchNextValidVideoData(url, 1, 1);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
async function fetchNextValidVideoData(url, index, direction) {
|
| 129 |
+
const response = await fetch(url);
|
| 130 |
+
const videos = await response.json();
|
| 131 |
+
const video = videos[0];
|
| 132 |
+
|
| 133 |
+
if (videoIsValid(video)) {
|
| 134 |
+
return { video: video, index: index };
|
| 135 |
+
} else {
|
| 136 |
+
return fetchVideoData(shiftIndex(index, direction), direction);
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
function videoIsValid(video) {
|
| 141 |
+
return (
|
| 142 |
+
video &&
|
| 143 |
+
video.file_url &&
|
| 144 |
+
(video.file_ext === "mp4" || video.file_ext === "webm") &&
|
| 145 |
+
video.id
|
| 146 |
+
);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
function explicitUrlFilter() {
|
| 150 |
+
const questionable = questionableContentButton.checked;
|
| 151 |
+
const explicit = explicitContentButton.checked;
|
| 152 |
+
if (!questionable && !explicit) {
|
| 153 |
+
return " rating:safe";
|
| 154 |
+
} else if (questionable && !explicit) {
|
| 155 |
+
return " -rating:explicit";
|
| 156 |
+
} else {
|
| 157 |
+
return "";
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function tagIsValid(tag) {
|
| 162 |
+
return tagsByName.has(tag);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
function showPauseIcon() {
|
| 166 |
+
playPauseIcon.innerHTML = "pause";
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
function showPlayIcon() {
|
| 170 |
+
playPauseIcon.innerHTML = "play_arrow";
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
function toggleControlsOnTouch(event) {
|
| 174 |
+
toggleControls();
|
| 175 |
+
if (event.target === videoPlayers[CURRENT]) {
|
| 176 |
+
event.preventDefault();
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
function toggleMute() {
|
| 181 |
+
muted = !muted;
|
| 182 |
+
if (muted) {
|
| 183 |
+
musicPlayer.pauseVideo();
|
| 184 |
+
muteIcon.innerHTML = "volume_off";
|
| 185 |
+
} else {
|
| 186 |
+
musicPlayer.playVideo();
|
| 187 |
+
muteIcon.innerHTML = "volume_up";
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
function togglePause() {
|
| 192 |
+
if (skipNextPlayPause) {
|
| 193 |
+
skipNextPlayPause = false;
|
| 194 |
+
return;
|
| 195 |
+
}
|
| 196 |
+
if (isPaused()) {
|
| 197 |
+
videoPlayers[CURRENT].play();
|
| 198 |
+
if (!muted) {
|
| 199 |
+
musicPlayer.playVideo();
|
| 200 |
+
}
|
| 201 |
+
} else {
|
| 202 |
+
videoPlayers[CURRENT].pause();
|
| 203 |
+
musicPlayer.pauseVideo();
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
const FRAME_RATE = 1 / 24;
|
| 208 |
+
|
| 209 |
+
function previousFrame() {
|
| 210 |
+
videoPlayers[CURRENT].currentTime = Math.max(
|
| 211 |
+
0,
|
| 212 |
+
videoPlayers[CURRENT].currentTime - FRAME_RATE
|
| 213 |
+
);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
function nextFrame() {
|
| 217 |
+
videoPlayers[CURRENT].currentTime = Math.min(
|
| 218 |
+
videoPlayers[CURRENT].duration,
|
| 219 |
+
videoPlayers[CURRENT].currentTime + FRAME_RATE
|
| 220 |
+
);
|
| 221 |
+
}
|
| 222 |
+
function isPaused() {
|
| 223 |
+
return videoPlayers[CURRENT].paused || videoPlayers[CURRENT].ended;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
function handleNext() {
|
| 227 |
+
if (isPaused()) {
|
| 228 |
+
nextFrame();
|
| 229 |
+
} else {
|
| 230 |
+
playNextPreloadedVideo();
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
function handlePrevious() {
|
| 235 |
+
if (isPaused()) {
|
| 236 |
+
previousFrame();
|
| 237 |
+
} else {
|
| 238 |
+
playPreviousPreloadedVideo();
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
function playNextPreloadedVideo() {
|
| 243 |
+
playPreloadedVideo(1);
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
function playPreviousPreloadedVideo() {
|
| 247 |
+
playPreloadedVideo(-1);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
function playPreloadedVideo(direction) {
|
| 251 |
+
const nextVideoIndexToPreload = CURRENT + direction;
|
| 252 |
+
const previouslyPlayingVideo = videoPlayers[CURRENT];
|
| 253 |
+
|
| 254 |
+
if (videoData[nextVideoIndexToPreload] === null) {
|
| 255 |
+
return;
|
| 256 |
+
}
|
| 257 |
+
videoData.rotate(direction);
|
| 258 |
+
videoPlayers.rotate(direction);
|
| 259 |
+
videoIndexes.rotate(direction);
|
| 260 |
+
|
| 261 |
+
videoData[nextVideoIndexToPreload] = null;
|
| 262 |
+
videoIndexes[nextVideoIndexToPreload] = shiftIndex(
|
| 263 |
+
videoIndexes[CURRENT],
|
| 264 |
+
direction
|
| 265 |
+
);
|
| 266 |
+
|
| 267 |
+
removeVideoEventListeners(previouslyPlayingVideo);
|
| 268 |
+
addVideoEventListeners(videoPlayers[CURRENT]);
|
| 269 |
+
|
| 270 |
+
removeClass(previouslyPlayingVideo, "active");
|
| 271 |
+
addClass(videoPlayers[CURRENT], "active");
|
| 272 |
+
|
| 273 |
+
previouslyPlayingVideo.pause();
|
| 274 |
+
previouslyPlayingVideo.currentTime = 0;
|
| 275 |
+
playVideo();
|
| 276 |
+
fetchVideoData(videoIndexes[nextVideoIndexToPreload], direction).then(
|
| 277 |
+
(data) => {
|
| 278 |
+
videoIndexes[nextVideoIndexToPreload] = data.index;
|
| 279 |
+
preloadVideo(data.video, nextVideoIndexToPreload);
|
| 280 |
+
}
|
| 281 |
+
);
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
function removeClass(element, cssClass) {
|
| 285 |
+
if (element.classList.contains(cssClass)) {
|
| 286 |
+
element.classList.remove(cssClass);
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
function addClass(element, cssClass) {
|
| 291 |
+
if (!element.classList.contains(cssClass)) {
|
| 292 |
+
element.classList.add(cssClass);
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
function preloadVideo(video, index) {
|
| 297 |
+
videoData[index] = video;
|
| 298 |
+
videoPlayers[index].src = video.file_url;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
function playVideo() {
|
| 302 |
+
var tags = videoData[CURRENT].tags.split(" ").map(makeReadable);
|
| 303 |
+
hideTitle();
|
| 304 |
+
showTitleAfterDelay(tags);
|
| 305 |
+
addVideoTagsToUi(tags);
|
| 306 |
+
saveVideoIdToUrl(videoData[CURRENT]);
|
| 307 |
+
videoPlayers[CURRENT].play();
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
function showTitleAfterDelay(tags) {
|
| 311 |
+
clearTimeout(showTitleTimeout);
|
| 312 |
+
if (showTitlesButton.checked) {
|
| 313 |
+
const longestPossibleDelay =
|
| 314 |
+
videoPlayers[CURRENT].duration * 1000 - SHOW_TITLE_DURATION;
|
| 315 |
+
const delayUntilTitle = Math.min(
|
| 316 |
+
options["title-delay"] * 1000,
|
| 317 |
+
longestPossibleDelay
|
| 318 |
+
);
|
| 319 |
+
showTitleTimeout = setTimeout(
|
| 320 |
+
() => showTitleBriefly(tags),
|
| 321 |
+
delayUntilTitle
|
| 322 |
+
);
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
function showTitleBriefly(tags) {
|
| 327 |
+
const titles = tags.filter(isTagType(COPYRIGHT));
|
| 328 |
+
if (titles.length === 0) {
|
| 329 |
+
titles.push("unknown");
|
| 330 |
+
}
|
| 331 |
+
title.innerHTML = pickBestTitle(titles);
|
| 332 |
+
showTitle();
|
| 333 |
+
clearTimeout(hideTitleTimeout);
|
| 334 |
+
hideTitleTimeout = setTimeout(hideTitle, SHOW_TITLE_DURATION);
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
function pickBestTitle(titles) {
|
| 338 |
+
return titles[titles.length - 1];
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
function addVideoTagsToUi(tags) {
|
| 342 |
+
const artistTags = tags.filter(isTagType(ARTIST));
|
| 343 |
+
const generalTags = tags.filter(isTagType(GENERAL));
|
| 344 |
+
const copyrightTags = tags.filter(isTagType(COPYRIGHT));
|
| 345 |
+
const characterTags = tags.filter(isTagType(CHARACTER));
|
| 346 |
+
|
| 347 |
+
generalTagsList.innerHTML = generateTagsHtml(generalTags);
|
| 348 |
+
artistTagsList.innerHTML = generateTagsHtml(artistTags);
|
| 349 |
+
copyrightTagsList.innerHTML = generateTagsHtml(copyrightTags);
|
| 350 |
+
characterTagsList.innerHTML = generateTagsHtml(characterTags);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
function generateTagsHtml(tags) {
|
| 354 |
+
var tagsHtml = "";
|
| 355 |
+
|
| 356 |
+
for (tag of tags) {
|
| 357 |
+
if (tagIsValid(tag)) {
|
| 358 |
+
tagsHtml = tagsHtml + "<li><a ";
|
| 359 |
+
if (currentTag === tag) {
|
| 360 |
+
tagsHtml = tagsHtml + 'class="current-tag" ';
|
| 361 |
+
}
|
| 362 |
+
tagsHtml = tagsHtml + 'href="?tag=' + tag + '">' + tag + "</a></li>";
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
return tagsHtml;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
function isTagType(tagType) {
|
| 369 |
+
return (tagName) => {
|
| 370 |
+
const tag = tagsByName.get(tagName);
|
| 371 |
+
return tag && tag.type === tagType;
|
| 372 |
+
};
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
var fullScreenEnabled = !!(
|
| 376 |
+
document.fullscreenEnabled ||
|
| 377 |
+
document.mozFullScreenEnabled ||
|
| 378 |
+
document.msFullscreenEnabled ||
|
| 379 |
+
document.webkitSupportsFullscreen ||
|
| 380 |
+
document.webkitFullscreenEnabled ||
|
| 381 |
+
document.createElement("video").webkitRequestFullScreen
|
| 382 |
+
);
|
| 383 |
+
if (!fullScreenEnabled) {
|
| 384 |
+
fullscreenButton.style.display = "none";
|
| 385 |
+
}
|
| 386 |
+
var isFullScreen = function () {
|
| 387 |
+
return !!(
|
| 388 |
+
document.fullScreen ||
|
| 389 |
+
document.webkitIsFullScreen ||
|
| 390 |
+
document.mozFullScreen ||
|
| 391 |
+
document.msFullscreenElement ||
|
| 392 |
+
document.fullscreenElement
|
| 393 |
+
);
|
| 394 |
+
};
|
| 395 |
+
var setFullscreenData = function (state) {
|
| 396 |
+
videoContainer.setAttribute("data-fullscreen", !!state);
|
| 397 |
+
fullscreenIcon.innerHTML = state ? "fullscreen_exit" : "fullscreen";
|
| 398 |
+
};
|
| 399 |
+
var handleFullscreen = function () {
|
| 400 |
+
if (isFullScreen()) {
|
| 401 |
+
if (document.exitFullscreen) document.exitFullscreen();
|
| 402 |
+
else if (document.mozCancelFullScreen) document.mozCancelFullScreen();
|
| 403 |
+
else if (document.webkitCancelFullScreen) document.webkitCancelFullScreen();
|
| 404 |
+
else if (document.msExitFullscreen) document.msExitFullscreen();
|
| 405 |
+
setFullscreenData(false);
|
| 406 |
+
} else {
|
| 407 |
+
if (videoContainer.requestFullscreen) videoContainer.requestFullscreen();
|
| 408 |
+
else if (videoContainer.mozRequestFullScreen)
|
| 409 |
+
videoContainer.mozRequestFullScreen();
|
| 410 |
+
else if (videoContainer.webkitRequestFullScreen)
|
| 411 |
+
videoContainer.webkitRequestFullScreen();
|
| 412 |
+
else if (videoContainer.msRequestFullscreen)
|
| 413 |
+
videoContainer.msRequestFullscreen();
|
| 414 |
+
setFullscreenData(true);
|
| 415 |
+
}
|
| 416 |
+
};
|
| 417 |
+
function saveOptions(options) {
|
| 418 |
+
localStorage.setItem("options", JSON.stringify(options));
|
| 419 |
+
}
|
| 420 |
+
explicitContentButton.addEventListener("change", () => {
|
| 421 |
+
options["explicit-content"] = explicitContentButton.checked;
|
| 422 |
+
saveOptions(options);
|
| 423 |
+
});
|
| 424 |
+
questionableContentButton.addEventListener("change", () => {
|
| 425 |
+
options["questionable-content"] = questionableContentButton.checked;
|
| 426 |
+
saveOptions(options);
|
| 427 |
+
});
|
| 428 |
+
showTitlesButton.addEventListener("change", () => {
|
| 429 |
+
if (showTitlesButton.checked) {
|
| 430 |
+
options["show-titles"] = true;
|
| 431 |
+
var tags = videoData[CURRENT].tags.split(" ").map(makeReadable);
|
| 432 |
+
showTitleAfterDelay(tags);
|
| 433 |
+
} else {
|
| 434 |
+
options["show-titles"] = false;
|
| 435 |
+
hideTitle();
|
| 436 |
+
}
|
| 437 |
+
saveOptions(options);
|
| 438 |
+
});
|
| 439 |
+
titleDelaySlider.addEventListener("change", () => {
|
| 440 |
+
options["title-delay"] = titleDelaySlider.value;
|
| 441 |
+
saveOptions(options);
|
| 442 |
+
});
|
| 443 |
+
document.addEventListener("fullscreenchange", (e) =>
|
| 444 |
+
setFullscreenData(!!(document.fullScreen || document.fullscreenElement))
|
| 445 |
+
);
|
| 446 |
+
document.addEventListener("webkitfullscreenchange", () =>
|
| 447 |
+
setFullscreenData(!!document.webkitIsFullScreen)
|
| 448 |
+
);
|
| 449 |
+
document.addEventListener("mozfullscreenchange", () =>
|
| 450 |
+
setFullscreenData(!!document.mozFullScreen)
|
| 451 |
+
);
|
| 452 |
+
document.addEventListener("msfullscreenchange", () =>
|
| 453 |
+
setFullscreenData(!!document.msFullscreenElement)
|
| 454 |
+
);
|
| 455 |
+
fullscreenButton.addEventListener("click", handleFullscreen);
|
| 456 |
+
playpauseButton.addEventListener("click", togglePause);
|
| 457 |
+
nextButton.addEventListener("click", handleNext);
|
| 458 |
+
previousButton.addEventListener("click", handlePrevious);
|
| 459 |
+
muteButton.addEventListener("click", toggleMute);
|
| 460 |
+
generalTagsList.addEventListener("click", tagClicked);
|
| 461 |
+
artistTagsList.addEventListener("click", tagClicked);
|
| 462 |
+
copyrightTagsList.addEventListener("click", tagClicked);
|
| 463 |
+
characterTagsList.addEventListener("click", tagClicked);
|
| 464 |
+
|
| 465 |
+
function tagClicked(event) {
|
| 466 |
+
const node = event.target;
|
| 467 |
+
if (node.tagName === "A") {
|
| 468 |
+
event.preventDefault();
|
| 469 |
+
const tag = parseTagFromQueryParams(node.getAttribute("href"));
|
| 470 |
+
if (currentTag !== tag) {
|
| 471 |
+
setCurrentTag(tag);
|
| 472 |
+
} else {
|
| 473 |
+
clearCurrentTag();
|
| 474 |
+
}
|
| 475 |
+
}
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
var userActivity, activityCheck, inactivityTimeout, controlsHovered;
|
| 479 |
+
|
| 480 |
+
videoContainer.addEventListener("mousemove", (event) => (userActivity = true));
|
| 481 |
+
mainControls.addEventListener("click", (event) => (userActivity = true));
|
| 482 |
+
otherControls.addEventListener("click", (event) => (userActivity = true));
|
| 483 |
+
|
| 484 |
+
function removeVideoEventListeners(videoElement) {
|
| 485 |
+
videoElement.removeEventListener("touchstart", toggleControlsOnTouch);
|
| 486 |
+
videoElement.removeEventListener("click", togglePause);
|
| 487 |
+
videoElement.removeEventListener("mousedown", preventNextPlayPause);
|
| 488 |
+
videoElement.removeEventListener("ended", playNextPreloadedVideo);
|
| 489 |
+
videoElement.removeEventListener("play", showPauseIcon);
|
| 490 |
+
videoElement.removeEventListener("pause", showPlayIcon);
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
function addVideoEventListeners(videoElement) {
|
| 494 |
+
videoElement.addEventListener("touchstart", toggleControlsOnTouch);
|
| 495 |
+
videoElement.addEventListener("click", togglePause);
|
| 496 |
+
videoElement.addEventListener("mousedown", preventNextPlayPause);
|
| 497 |
+
videoElement.addEventListener("ended", playNextPreloadedVideo);
|
| 498 |
+
videoElement.addEventListener("play", showPauseIcon);
|
| 499 |
+
videoElement.addEventListener("pause", showPlayIcon);
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
function tagSearchActive() {
|
| 503 |
+
return document.activeElement === input;
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
function hideControlsTimeout() {
|
| 507 |
+
return controlsHovered ? 3500 : 750;
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
activityCheck = setInterval(() => {
|
| 511 |
+
if (userActivity) {
|
| 512 |
+
userActivity = false;
|
| 513 |
+
showControls();
|
| 514 |
+
|
| 515 |
+
// Clear any existing inactivity timeout to start the timer over
|
| 516 |
+
clearTimeout(inactivityTimeout);
|
| 517 |
+
|
| 518 |
+
// In X seconds, if no more activity has occurred
|
| 519 |
+
// the user will be considered inactive
|
| 520 |
+
inactivityTimeout = setTimeout(() => {
|
| 521 |
+
// Protect against the case where the inactivity timeout can trigger
|
| 522 |
+
// before the next user activity is picked up by the
|
| 523 |
+
// activityCheck loop.
|
| 524 |
+
if (!userActivity && !tagSearchActive()) {
|
| 525 |
+
hideControls();
|
| 526 |
+
}
|
| 527 |
+
}, hideControlsTimeout());
|
| 528 |
+
}
|
| 529 |
+
}, 250);
|
| 530 |
+
|
| 531 |
+
async function getTags() {
|
| 532 |
+
const response = await fetch("/api/tag.json?limit=1500&order=count");
|
| 533 |
+
return await response.json();
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
function putTagsInForm(tags) {
|
| 537 |
+
var innerString = "";
|
| 538 |
+
for (tag of tags) {
|
| 539 |
+
innerString = innerString + "<option>" + tag + "</option>";
|
| 540 |
+
}
|
| 541 |
+
tagsDatalist.innerHTML = innerString;
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
mainControls.addEventListener("mouseenter", () => {
|
| 545 |
+
controlsHovered = true;
|
| 546 |
+
});
|
| 547 |
+
|
| 548 |
+
mainControls.addEventListener("mouseleave", () => {
|
| 549 |
+
controlsHovered = false;
|
| 550 |
+
});
|
| 551 |
+
|
| 552 |
+
otherControls.addEventListener("mouseenter", () => {
|
| 553 |
+
controlsHovered = true;
|
| 554 |
+
});
|
| 555 |
+
|
| 556 |
+
otherControls.addEventListener("mouseleave", () => {
|
| 557 |
+
controlsHovered = false;
|
| 558 |
+
});
|
| 559 |
+
|
| 560 |
+
input.addEventListener("input", () => {
|
| 561 |
+
const tag = input.value;
|
| 562 |
+
if (tagIsValid(tag)) {
|
| 563 |
+
playPlaylist(tag, null);
|
| 564 |
+
}
|
| 565 |
+
});
|
| 566 |
+
input.addEventListener("keyup", (event) => {
|
| 567 |
+
if (event.key === "Enter") {
|
| 568 |
+
input.blur();
|
| 569 |
+
}
|
| 570 |
+
});
|
| 571 |
+
input.addEventListener("blur", (event) => {
|
| 572 |
+
hideControls();
|
| 573 |
+
input.value = "";
|
| 574 |
+
});
|
| 575 |
+
|
| 576 |
+
function preventNextPlayPause() {
|
| 577 |
+
if (tagSearchActive()) {
|
| 578 |
+
skipNextPlayPause = true;
|
| 579 |
+
}
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
window.addEventListener("keyup", (event) => {
|
| 583 |
+
if (event.target === input) {
|
| 584 |
+
return;
|
| 585 |
+
}
|
| 586 |
+
if (event.key === "ArrowRight") {
|
| 587 |
+
handleNext();
|
| 588 |
+
}
|
| 589 |
+
if (event.key === "ArrowLeft") {
|
| 590 |
+
handlePrevious();
|
| 591 |
+
}
|
| 592 |
+
if (event.key === " ") {
|
| 593 |
+
togglePause();
|
| 594 |
+
}
|
| 595 |
+
});
|
| 596 |
+
window.addEventListener("popstate", (event) => {
|
| 597 |
+
setCurrentTag(event.state.tag);
|
| 598 |
+
});
|
| 599 |
+
|
| 600 |
+
function setCurrentTag(tag) {
|
| 601 |
+
if (tag && tag !== currentTag) {
|
| 602 |
+
playPlaylist(tag, null);
|
| 603 |
+
}
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
function clearCurrentTag() {
|
| 607 |
+
if (currentTag) {
|
| 608 |
+
playPlaylist(null, null);
|
| 609 |
+
}
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
function toggleControls() {
|
| 613 |
+
if (controlsHidden()) {
|
| 614 |
+
showControls();
|
| 615 |
+
} else {
|
| 616 |
+
hideControls();
|
| 617 |
+
}
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
function controlsHidden() {
|
| 621 |
+
return videoContainer.classList.contains("fade-out");
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
function titleHidden() {
|
| 625 |
+
return title.classList.contains("fade-out");
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
function showTitle() {
|
| 629 |
+
if (titleHidden()) {
|
| 630 |
+
title.classList.remove("fade-out");
|
| 631 |
+
}
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
function hideTitle() {
|
| 635 |
+
if (!titleHidden()) {
|
| 636 |
+
title.classList.add("fade-out");
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
function showControls() {
|
| 641 |
+
if (controlsHidden()) {
|
| 642 |
+
videoContainer.classList.remove("fade-out");
|
| 643 |
+
}
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
function hideControls() {
|
| 647 |
+
if (!controlsHidden()) {
|
| 648 |
+
videoContainer.classList.add("fade-out");
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
function useUnderscores(tag) {
|
| 653 |
+
return tag.split(" ").join("_");
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
function makeReadable(tag) {
|
| 657 |
+
return tag.split("_").join(" ");
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
function saveTagToUrl(tag) {
|
| 661 |
+
if (tag !== parseTagFromUrl()) {
|
| 662 |
+
if (tag) {
|
| 663 |
+
history.pushState(
|
| 664 |
+
{ tag: tag },
|
| 665 |
+
tag + " videos",
|
| 666 |
+
"?tag=" + encodeURIComponent(useUnderscores(tag))
|
| 667 |
+
);
|
| 668 |
+
} else {
|
| 669 |
+
history.pushState({ tag: tag }, "All videos", "./");
|
| 670 |
+
}
|
| 671 |
+
}
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
function saveVideoIdToUrl(video) {
|
| 675 |
+
const tag = new URLSearchParams(window.location.search).get("tag");
|
| 676 |
+
var queryParams = "?video=" + video.id;
|
| 677 |
+
if (tag) {
|
| 678 |
+
queryParams += "&tag=" + tag;
|
| 679 |
+
}
|
| 680 |
+
history.replaceState(history.state, tag + " videos", queryParams);
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
function parseTagFromUrl() {
|
| 684 |
+
return parseTagFromQueryParams(window.location.search);
|
| 685 |
+
}
|
| 686 |
+
|
| 687 |
+
function parseTagFromQueryParams(queryParams) {
|
| 688 |
+
const encodedTag = new URLSearchParams(queryParams).get("tag");
|
| 689 |
+
if (encodedTag) {
|
| 690 |
+
return makeReadable(decodeURIComponent(encodedTag));
|
| 691 |
+
} else {
|
| 692 |
+
return null;
|
| 693 |
+
}
|
| 694 |
+
}
|
| 695 |
+
|
| 696 |
+
function parseVideoIdFromUrl() {
|
| 697 |
+
const videoId = new URLSearchParams(window.location.search).get("video");
|
| 698 |
+
return videoId ? videoId : null;
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
function putTagsInUi(tags) {
|
| 702 |
+
tagsByName = new Map(
|
| 703 |
+
tags.filter(shouldIncludeTag).map((tag) => [makeReadable(tag.name), tag])
|
| 704 |
+
);
|
| 705 |
+
putTagsInForm(tagsByName.keys());
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
function shouldIncludeTag(tag) {
|
| 709 |
+
return !tagsToExclude.includes(tag.name);
|
| 710 |
+
}
|
| 711 |
+
|
| 712 |
+
function setupMusic() {
|
| 713 |
+
var youtubeScriptTag = document.createElement("script");
|
| 714 |
+
youtubeScriptTag.src = "https://www.youtube.com/iframe_api";
|
| 715 |
+
var firstScriptTag = document.getElementsByTagName("script")[0];
|
| 716 |
+
firstScriptTag.parentNode.insertBefore(youtubeScriptTag, firstScriptTag);
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
// required by youtube script
|
| 720 |
+
function onYouTubeIframeAPIReady() {
|
| 721 |
+
musicPlayer = new YT.Player("youtube-player");
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
function startPage() {
|
| 725 |
+
setupMusic();
|
| 726 |
+
addClass(videoPlayers[CURRENT], "active");
|
| 727 |
+
addVideoEventListeners(videoPlayers[CURRENT]);
|
| 728 |
+
const tag = parseTagFromUrl();
|
| 729 |
+
const videoId = parseVideoIdFromUrl();
|
| 730 |
+
if (tag) {
|
| 731 |
+
history.replaceState({ tag: tag }, null);
|
| 732 |
+
}
|
| 733 |
+
const tagsSavedFuture = getTags().then((tags) => {
|
| 734 |
+
localStorage.setItem("tags", JSON.stringify(tags));
|
| 735 |
+
putTagsInUi(tags);
|
| 736 |
+
});
|
| 737 |
+
const cachedTags = JSON.parse(localStorage.getItem("tags"));
|
| 738 |
+
options = JSON.parse(localStorage.getItem("options")) || options;
|
| 739 |
+
showTitlesButton.checked = options["show-titles"];
|
| 740 |
+
questionableContentButton.checked = options["questionable-content"];
|
| 741 |
+
explicitContentButton.checked = options["explicit-content"];
|
| 742 |
+
titleDelaySlider.value = options["title-delay"];
|
| 743 |
+
if (cachedTags) {
|
| 744 |
+
putTagsInUi(cachedTags);
|
| 745 |
+
playPlaylist(tag, videoId);
|
| 746 |
+
} else {
|
| 747 |
+
tagsSavedFuture.then(() => playPlaylist(tag, videoId));
|
| 748 |
+
}
|
| 749 |
+
}
|
| 750 |
+
|
| 751 |
+
startPage();
|
public/style.css
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
| 2 |
+
|
| 3 |
+
body, html, video, #videocontainer {
|
| 4 |
+
margin:0;
|
| 5 |
+
padding:0;
|
| 6 |
+
background:#000;
|
| 7 |
+
height: 100%;
|
| 8 |
+
width: 100%;
|
| 9 |
+
overflow-y: hidden;
|
| 10 |
+
font: 15px 'Open Sans', sans-serif;
|
| 11 |
+
-webkit-font-smoothing: antialiased;
|
| 12 |
+
-moz-osx-font-smoothing: grayscale;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
display: flex;
|
| 17 |
+
align-items: center;
|
| 18 |
+
justify-content: center;
|
| 19 |
+
}
|
| 20 |
+
video {
|
| 21 |
+
position: fixed;
|
| 22 |
+
visibility: hidden;
|
| 23 |
+
}
|
| 24 |
+
video::-webkit-media-controls {
|
| 25 |
+
display:none !important;
|
| 26 |
+
}
|
| 27 |
+
video.active {
|
| 28 |
+
object-fit: contain;
|
| 29 |
+
visibility: visible;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
#title {
|
| 33 |
+
background: rgba(2, 2, 2, .7);
|
| 34 |
+
color: rgba(255, 255, 255, 0.9);
|
| 35 |
+
position:fixed;
|
| 36 |
+
left: 50%;
|
| 37 |
+
transform: translateX(-50%);
|
| 38 |
+
margin:0;
|
| 39 |
+
padding:14px;
|
| 40 |
+
font-size: 40px;
|
| 41 |
+
z-index: 2147483647;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.controls {
|
| 45 |
+
z-index: 2147483647;
|
| 46 |
+
padding: 14px;
|
| 47 |
+
margin: 0;
|
| 48 |
+
position: fixed;
|
| 49 |
+
background: rgba(2, 2, 2, .7);
|
| 50 |
+
color: rgba(255, 255, 255, 0.9);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
#main-controls {
|
| 54 |
+
bottom: 0%;
|
| 55 |
+
left: 50%;
|
| 56 |
+
transform: translateX(-50%);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
#main-controls #donate {
|
| 60 |
+
margin: 11px 14px;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
#main-controls #donate a{
|
| 64 |
+
color: #30BCED;
|
| 65 |
+
text-decoration: none;
|
| 66 |
+
background: rgba(50, 50, 50, 0.9);
|
| 67 |
+
padding: 11px;
|
| 68 |
+
display: block;
|
| 69 |
+
text-align: center;
|
| 70 |
+
transition: background-color 0.2s 0.1s, color 0.2s 0.1s;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
#main-controls #donate a:hover {
|
| 74 |
+
background:#30BCED;
|
| 75 |
+
color: rgba(50, 50, 50, 0.9);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.controls ul#playback-controls {
|
| 79 |
+
list-style: none;
|
| 80 |
+
padding: 0;
|
| 81 |
+
margin: 0;
|
| 82 |
+
white-space: nowrap;
|
| 83 |
+
}
|
| 84 |
+
.controls ul#playback-controls li {
|
| 85 |
+
display: inline-block;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.controls button {
|
| 89 |
+
-moz-appearance: none;
|
| 90 |
+
-webkit-appearance: none;
|
| 91 |
+
background: none;
|
| 92 |
+
border: none;
|
| 93 |
+
outline: none;
|
| 94 |
+
}
|
| 95 |
+
.controls button:hover {
|
| 96 |
+
text-shadow: 0px 0px 5px #fff;
|
| 97 |
+
}
|
| 98 |
+
.controls button:active {
|
| 99 |
+
text-shadow: 0px 0px 20px #fff;
|
| 100 |
+
}
|
| 101 |
+
.controls input[list=tags] {
|
| 102 |
+
font: inherit;
|
| 103 |
+
color: inherit;
|
| 104 |
+
background-color: transparent;
|
| 105 |
+
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
| 106 |
+
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
| 107 |
+
box-sizing: border-box; /* Opera/IE 8+ */
|
| 108 |
+
border: none;
|
| 109 |
+
padding: 11px 14px 12px 14px;
|
| 110 |
+
width: 100%;
|
| 111 |
+
-moz-appearance: none;
|
| 112 |
+
-webkit-appearance: none;
|
| 113 |
+
resize: none;
|
| 114 |
+
outline: 0;
|
| 115 |
+
}
|
| 116 |
+
.controls input:focus {
|
| 117 |
+
background: rgba(0, 0, 0, 0.9);
|
| 118 |
+
}
|
| 119 |
+
.controls input::placeholder,
|
| 120 |
+
.controls input:-ms-input-placeholder,
|
| 121 |
+
.controls input::-ms-input-placeholder {
|
| 122 |
+
color: rgba(255, 255, 255, 0.8);
|
| 123 |
+
opacity: 1; /* Firefox */
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
#about {
|
| 127 |
+
right: 0;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
#about a {
|
| 131 |
+
color: rgba(255, 255, 255, 0.5);
|
| 132 |
+
text-decoration: none;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
#about a:hover {
|
| 136 |
+
text-decoration: underline;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
#other-controls p, #about p {
|
| 140 |
+
margin: 0;
|
| 141 |
+
padding: 0;
|
| 142 |
+
color: rgba(255, 255, 255, 0.5);
|
| 143 |
+
user-select: none;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
#other-controls label, #other-controls div {
|
| 147 |
+
padding-bottom: 5px;
|
| 148 |
+
display:block;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#other-controls #hidden {
|
| 152 |
+
height: 0px;
|
| 153 |
+
visibility: hidden;
|
| 154 |
+
opacity: 0;
|
| 155 |
+
padding: 0;
|
| 156 |
+
transition: visibility 0.2s, opacity 0.2s, height 0.2s, padding 0.2s;
|
| 157 |
+
transition-delay: 0.3s;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
#other-controls:hover #hidden{
|
| 161 |
+
height: 96px;
|
| 162 |
+
visibility: visible;
|
| 163 |
+
padding: 14px 0px;
|
| 164 |
+
opacity: 1;
|
| 165 |
+
transition-delay: .1s;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
#other-controls:hover {
|
| 169 |
+
height: fit-content;
|
| 170 |
+
opacity: 1;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
label.checkbox {
|
| 174 |
+
display: block;
|
| 175 |
+
padding: 0px 14px;
|
| 176 |
+
text-indent: -14px;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
input[type=checkbox] {
|
| 180 |
+
width: 13px;
|
| 181 |
+
height: 13px;
|
| 182 |
+
padding: 0;
|
| 183 |
+
margin:0;
|
| 184 |
+
vertical-align: middle;
|
| 185 |
+
position: relative;
|
| 186 |
+
top: -1px;
|
| 187 |
+
*overflow: hidden;
|
| 188 |
+
opacity: .7;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.video-tags {
|
| 192 |
+
list-style: none;
|
| 193 |
+
padding: 11px 14px;
|
| 194 |
+
margin: 0px;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
#artist-tags::before {
|
| 198 |
+
content: "artist";
|
| 199 |
+
color: rgba(255, 255, 255, 0.5);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
#copyright-tags::before {
|
| 203 |
+
color: rgba(255, 255, 255, 0.5);
|
| 204 |
+
content: "source";
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
#character-tags::before {
|
| 208 |
+
color: rgba(255, 255, 255, 0.5);
|
| 209 |
+
content: "character";
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
.video-tags:empty {
|
| 213 |
+
display: none;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.video-tags a {
|
| 217 |
+
color: inherit;
|
| 218 |
+
text-decoration: none;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.video-tags a:hover, label.checkbox:hover, #about a:hover {
|
| 222 |
+
color: rgba(255, 255, 255, 1);
|
| 223 |
+
text-shadow: 0px 0px 5px #fff;
|
| 224 |
+
cursor: pointer;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.video-tags .current-tag {
|
| 228 |
+
text-shadow: 0px 0px 5px #fff;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
.video-tags .current-tag::before {
|
| 232 |
+
content: "➤";
|
| 233 |
+
position: absolute;
|
| 234 |
+
text-shadow: 0px 0px 5px #fff;
|
| 235 |
+
left: 10px;
|
| 236 |
+
margin-top:1px;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.video-tags .current-tag:hover::before {
|
| 240 |
+
content: "✕";
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
input::-webkit-calendar-picker-indicator {
|
| 244 |
+
background-color: inherit;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
.material-icons.md-48 {
|
| 248 |
+
font-size: 48px;
|
| 249 |
+
}
|
| 250 |
+
.material-icons.md-light {
|
| 251 |
+
color: rgba(255, 255, 255, 1);
|
| 252 |
+
}
|
| 253 |
+
.fade-out .controls, #title.fade-out {
|
| 254 |
+
display: block;
|
| 255 |
+
visibility: hidden !important;
|
| 256 |
+
opacity: 0 !important;
|
| 257 |
+
transition: visibility 0.2s, opacity 0.2s;
|
| 258 |
+
}
|
| 259 |
+
.fade-out {
|
| 260 |
+
cursor: none;
|
| 261 |
+
}
|
| 262 |
+
@media (max-width: 500px) {
|
| 263 |
+
#title {
|
| 264 |
+
font-size: 24px;
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
@media (max-height: 500px) {
|
| 269 |
+
#title {
|
| 270 |
+
font-size: 24px;
|
| 271 |
+
}
|
| 272 |
+
}
|