mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-21 01:12:07 +00:00
- Minor formatting and QoL changes
This commit is contained in:
parent
7a1fdd9032
commit
4ced5ff9fe
2 changed files with 195 additions and 173 deletions
|
|
@ -1,23 +1,23 @@
|
||||||
var query,
|
var query;
|
||||||
variables = {
|
var variables = {
|
||||||
type: "ANIME",
|
type: "ANIME",
|
||||||
page: 1,
|
page: 1,
|
||||||
perPage: 50
|
perPage: 50
|
||||||
},
|
}
|
||||||
request;
|
var request;
|
||||||
|
|
||||||
var url = 'https://graphql.anilist.co',
|
var url = 'https://graphql.anilist.co'
|
||||||
options = {
|
var options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
query: query,
|
query: query,
|
||||||
variables: variables
|
variables: variables
|
||||||
})
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
let search = document.querySelector("#search").value
|
let search = document.querySelector("#search").value
|
||||||
|
|
@ -33,92 +33,92 @@ function alRequest(a) {
|
||||||
variables.sort = "TRENDING_DESC"
|
variables.sort = "TRENDING_DESC"
|
||||||
delete variables.search
|
delete variables.search
|
||||||
query = `
|
query = `
|
||||||
query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType) {
|
query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType) {
|
||||||
Page (page: $page, perPage: $perPage) {
|
Page (page: $page, perPage: $perPage) {
|
||||||
pageInfo {
|
pageInfo {
|
||||||
total
|
total
|
||||||
currentPage
|
currentPage
|
||||||
lastPage
|
lastPage
|
||||||
hasNextPage
|
hasNextPage
|
||||||
perPage
|
perPage
|
||||||
}
|
}
|
||||||
media(type: $type, sort: $sort) {
|
media(type: $type, sort: $sort) {
|
||||||
id
|
id
|
||||||
title {
|
title {
|
||||||
romaji
|
romaji
|
||||||
english
|
english
|
||||||
native
|
native
|
||||||
}
|
}
|
||||||
description(
|
description(
|
||||||
asHtml: true
|
asHtml: true
|
||||||
)
|
)
|
||||||
season
|
season
|
||||||
seasonYear
|
seasonYear
|
||||||
format
|
format
|
||||||
status
|
status
|
||||||
episodes
|
episodes
|
||||||
duration
|
duration
|
||||||
averageScore
|
averageScore
|
||||||
genres
|
genres
|
||||||
coverImage {
|
coverImage {
|
||||||
extraLarge
|
extraLarge
|
||||||
medium
|
medium
|
||||||
}
|
}
|
||||||
bannerImage
|
bannerImage
|
||||||
synonyms
|
synonyms
|
||||||
nextAiringEpisode {
|
nextAiringEpisode {
|
||||||
timeUntilAiring
|
timeUntilAiring
|
||||||
episode
|
episode
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
`
|
||||||
}
|
|
||||||
`
|
|
||||||
} else {
|
} else {
|
||||||
variables.search = a
|
variables.search = a
|
||||||
delete variables.sort
|
delete variables.sort
|
||||||
query = `
|
query = `
|
||||||
query ($page: Int, $perPage: Int, $search: String, $type: MediaType) {
|
query ($page: Int, $perPage: Int, $search: String, $type: MediaType) {
|
||||||
Page (page: $page, perPage: $perPage) {
|
Page (page: $page, perPage: $perPage) {
|
||||||
pageInfo {
|
pageInfo {
|
||||||
total
|
total
|
||||||
currentPage
|
currentPage
|
||||||
lastPage
|
lastPage
|
||||||
hasNextPage
|
hasNextPage
|
||||||
perPage
|
perPage
|
||||||
}
|
}
|
||||||
media (type: $type, search: $search) {
|
media (type: $type, search: $search) {
|
||||||
id
|
id
|
||||||
title {
|
title {
|
||||||
romaji
|
romaji
|
||||||
english
|
english
|
||||||
native
|
native
|
||||||
}
|
}
|
||||||
description(
|
description(
|
||||||
asHtml: true
|
asHtml: true
|
||||||
)
|
)
|
||||||
season
|
season
|
||||||
seasonYear
|
seasonYear
|
||||||
format
|
format
|
||||||
status
|
status
|
||||||
episodes
|
episodes
|
||||||
duration
|
duration
|
||||||
averageScore
|
averageScore
|
||||||
genres
|
genres
|
||||||
coverImage {
|
coverImage {
|
||||||
extraLarge
|
extraLarge
|
||||||
medium
|
medium
|
||||||
}
|
}
|
||||||
bannerImage
|
bannerImage
|
||||||
synonyms
|
synonyms
|
||||||
nextAiringEpisode {
|
nextAiringEpisode {
|
||||||
timeUntilAiring
|
timeUntilAiring
|
||||||
episode
|
episode
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
`
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
}
|
||||||
options.body = JSON.stringify({
|
options.body = JSON.stringify({
|
||||||
query: query,
|
query: query,
|
||||||
|
|
@ -138,37 +138,37 @@ function alRequest(a) {
|
||||||
function handleData(data) {
|
function handleData(data) {
|
||||||
request = data
|
request = data
|
||||||
console.log(request);
|
console.log(request);
|
||||||
let frag = document.createDocumentFragment(),
|
let frag = document.createDocumentFragment()
|
||||||
hasBegun = true
|
let hasBegun = true
|
||||||
try {
|
try {
|
||||||
data.data.Page.media.forEach((media, index) => {
|
data.data.Page.media.forEach((media, index) => {
|
||||||
let template = document.createElement("div")
|
let template = document.createElement("div")
|
||||||
template.classList.add("card", "m-0", "p-0")
|
template.classList.add("card", "m-0", "p-0")
|
||||||
template.innerHTML = `
|
template.innerHTML = `
|
||||||
|
|
||||||
<div class="row h-full">
|
<div class="row h-full">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<img src="${media.coverImage.extraLarge}"
|
<img src="${media.coverImage.extraLarge}"
|
||||||
class="cover-img w-full h-full">
|
class="cover-img w-full h-full">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8 h-full card-grid">
|
<div class="col-8 h-full card-grid">
|
||||||
<div class="px-15 py-10">
|
<div class="px-15 py-10">
|
||||||
<h5 class="m-0 text-capitalize font-weight-bold">${!!media.title.english ? media.title.english : media.title.romaji}</h5>
|
<h5 class="m-0 text-capitalize font-weight-bold">${!!media.title.english ? media.title.english : media.title.romaji}</h5>
|
||||||
<p class="text-muted m-0 text-capitalize details">
|
<p class="text-muted m-0 text-capitalize details">
|
||||||
${(!!media.format ? (media.format == "TV" ? "<span>" + media.format + " Show" : "<span>" + media.format) : "") + "</span>"}
|
${(!!media.format ? (media.format == "TV" ? "<span>" + media.format + " Show" : "<span>" + media.format) : "") + "</span>"}
|
||||||
${!!media.episodes ? "<span>" + media.episodes + " Episodes</span>" : (!!media.duration ? "<span>" + media.duration + " Minutes</span>" : "")}
|
${!!media.episodes ? "<span>" + media.episodes + " Episodes</span>" : (!!media.duration ? "<span>" + media.duration + " Minutes</span>" : "")}
|
||||||
${!!media.status ? "<span>" + media.status.toLowerCase() + "</span>" : ""}
|
${!!media.status ? "<span>" + media.status.toLowerCase() + "</span>" : ""}
|
||||||
${"<span>" + (!!media.season ? media.season.toLowerCase() + " " : "") + (!!media.seasonYear ? media.seasonYear : "") + "</span>"}
|
${"<span>" + (!!media.season ? media.season.toLowerCase() + " " : "") + (!!media.seasonYear ? media.seasonYear : "") + "</span>"}
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="overflow-y-scroll px-15 py-10 bg-very-dark card-desc">
|
||||||
|
${media.description}
|
||||||
|
</div>
|
||||||
|
<div class="px-15 pb-10 pt-5">
|
||||||
|
${media.genres.map(key => (`<span class="badge badge-pill badge-primary mt-5">${key}</span> `)).join('')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-y-scroll px-15 py-10 bg-very-dark card-desc">
|
|
||||||
${media.description}
|
|
||||||
</div>
|
|
||||||
<div class="px-15 pb-10 pt-5">
|
|
||||||
${media.genres.map(key => (`<span class="badge badge-pill badge-primary mt-5">${key}</span> `)).join('')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
`
|
`
|
||||||
template.onclick = function () {
|
template.onclick = function () {
|
||||||
|
|
@ -185,23 +185,24 @@ function handleData(data) {
|
||||||
}
|
}
|
||||||
document.querySelector(".gallery").appendChild(frag)
|
document.querySelector(".gallery").appendChild(frag)
|
||||||
}
|
}
|
||||||
let detailsfrag = document.createDocumentFragment(),
|
|
||||||
details = {
|
|
||||||
averageScore: "Average Score",
|
|
||||||
duration: "Episode Duration",
|
|
||||||
episodes: "Episodes",
|
|
||||||
format: "Format",
|
|
||||||
genres: "Genres",
|
|
||||||
season: "Season",
|
|
||||||
seasonYear: "Year",
|
|
||||||
status: "Status",
|
|
||||||
english: "English",
|
|
||||||
romaji: "Romaji",
|
|
||||||
native: "Native",
|
|
||||||
synonyms: "Synonyms"
|
|
||||||
}
|
|
||||||
function viewAnime(media) {
|
|
||||||
|
|
||||||
|
let detailsfrag = document.createDocumentFragment()
|
||||||
|
let details = {
|
||||||
|
averageScore: "Average Score",
|
||||||
|
duration: "Episode Duration",
|
||||||
|
episodes: "Episodes",
|
||||||
|
format: "Format",
|
||||||
|
genres: "Genres",
|
||||||
|
season: "Season",
|
||||||
|
seasonYear: "Year",
|
||||||
|
status: "Status",
|
||||||
|
english: "English",
|
||||||
|
romaji: "Romaji",
|
||||||
|
native: "Native",
|
||||||
|
synonyms: "Synonyms"
|
||||||
|
}
|
||||||
|
|
||||||
|
function viewAnime(media) {
|
||||||
halfmoon.toggleModal("view")
|
halfmoon.toggleModal("view")
|
||||||
document.querySelector(".view .banner img").src = ""
|
document.querySelector(".view .banner img").src = ""
|
||||||
document.querySelector(".view .banner img").src = media.bannerImage
|
document.querySelector(".view .banner img").src = media.bannerImage
|
||||||
|
|
@ -213,6 +214,7 @@ function viewAnime(media) {
|
||||||
detailsCreator(media)
|
detailsCreator(media)
|
||||||
document.querySelector(".view .details").appendChild(detailsfrag)
|
document.querySelector(".view .details").appendChild(detailsfrag)
|
||||||
}
|
}
|
||||||
|
|
||||||
function detailsCreator(entry) {
|
function detailsCreator(entry) {
|
||||||
if (entry != undefined) {
|
if (entry != undefined) {
|
||||||
Object.entries(entry).forEach(value => {
|
Object.entries(entry).forEach(value => {
|
||||||
|
|
@ -235,33 +237,37 @@ function detailsCreator(entry) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const DOMPARSER = new DOMParser().parseFromString.bind(new DOMParser()),
|
|
||||||
searchTitle = document.querySelector("#title"),
|
|
||||||
searchEpisode = document.querySelector("#ep")
|
|
||||||
|
|
||||||
var selected
|
const DOMPARSER = new DOMParser().parseFromString.bind(new DOMParser())
|
||||||
|
const searchTitle = document.querySelector("#title")
|
||||||
|
const searchEpisode = document.querySelector("#ep")
|
||||||
|
|
||||||
|
var selected;
|
||||||
|
|
||||||
async function nyaaSearch(media, episode) {
|
async function nyaaSearch(media, episode) {
|
||||||
if (parseInt(episode) < 10) {
|
if (parseInt(episode) < 10) {
|
||||||
episode = `0${episode}`
|
episode = `0${episode}`
|
||||||
}
|
}
|
||||||
let titles = Object.values(media.title).concat(media.synonyms).filter(name => name != null),
|
|
||||||
table = document.querySelector("tbody.results"),
|
let titles = Object.values(media.title).concat(media.synonyms).filter(name => name != null)
|
||||||
results = document.createDocumentFragment()
|
let table = document.querySelector("tbody.results")
|
||||||
|
let results = document.createDocumentFragment()
|
||||||
|
|
||||||
for (let title of titles) {
|
for (let title of titles) {
|
||||||
if (results.children.length == 0) {
|
if (results.children.length == 0) {
|
||||||
title = title.replace(/ /g, "+")
|
title = title.replace(/ /g, "+")
|
||||||
let url = new URL(`https://nyaa.si/?page=rss&c=1_2&f=2&s=seeders&o=desc&q=${title}"+${episode}+"`)
|
let url = new URL(`https://nyaa.si/?page=rss&c=1_2&f=2&s=seeders&o=desc&q=${title}"+${episode}+"`)
|
||||||
results = await rssFetch(url)
|
results = await rssFetch(url)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if (results.children.length == 0) {
|
if (results.children.length == 0) {
|
||||||
halfmoon.initStickyAlert({
|
halfmoon.initStickyAlert({
|
||||||
content: `Couldn't find torrent for ${!!media.title.english ? media.title.english : media.title.romaji} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
|
content: `Couldn't find torrent for ${!!media.title.english ? media.title.english : media.title.romaji} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
|
||||||
title: "Search Failed",
|
title: "Search Failed",
|
||||||
alertType: "alert-danger",
|
alertType: "alert-danger",
|
||||||
fillType: ""
|
fillType: ""
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
table.textContent = ""
|
table.textContent = ""
|
||||||
table.appendChild(results)
|
table.appendChild(results)
|
||||||
|
|
@ -272,13 +278,14 @@ async function nyaaSearch(media, episode) {
|
||||||
|
|
||||||
async function rssFetch(url) {
|
async function rssFetch(url) {
|
||||||
let frag = document.createDocumentFragment()
|
let frag = document.createDocumentFragment()
|
||||||
|
|
||||||
res = await fetch(url)
|
res = await fetch(url)
|
||||||
await res.text().then((xmlTxt) => {
|
await res.text().then((xmlTxt) => {
|
||||||
try {
|
try {
|
||||||
let doc = DOMPARSER(xmlTxt, "text/xml")
|
let doc = DOMPARSER(xmlTxt, "text/xml")
|
||||||
doc.querySelectorAll("item").forEach((item, index) => {
|
doc.querySelectorAll("item").forEach((item, index) => {
|
||||||
let i = item.querySelector.bind(item),
|
let i = item.querySelector.bind(item)
|
||||||
template = document.createElement("tr")
|
let template = document.createElement("tr")
|
||||||
template.innerHTML += `
|
template.innerHTML += `
|
||||||
<th>${(index + 1)}</th>
|
<th>${(index + 1)}</th>
|
||||||
<td>${i("title").textContent}</td>
|
<td>${i("title").textContent}</td>
|
||||||
|
|
@ -293,6 +300,7 @@ async function rssFetch(url) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return frag
|
return frag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const controls = document.getElementsByClassName('ctrl'),
|
||||||
thumbnail = document.querySelector("#dThumb")
|
thumbnail = document.querySelector("#dThumb")
|
||||||
|
|
||||||
|
|
||||||
//event listeners
|
// event listeners
|
||||||
volume.addEventListener("input", function () {
|
volume.addEventListener("input", function () {
|
||||||
updateVolume()
|
updateVolume()
|
||||||
});
|
});
|
||||||
|
|
@ -45,25 +45,29 @@ for (let i = 0; i < controls.length; i++) {
|
||||||
// progress bar and display
|
// progress bar and display
|
||||||
|
|
||||||
function updateDisplay() {
|
function updateDisplay() {
|
||||||
let progressPercent = (video.currentTime / video.duration * 100),
|
let progressPercent = (video.currentTime / video.duration * 100)
|
||||||
bufferPercent = video.buffered.length == 0 ? 0 : video.buffered.end(video.buffered.length - 1) / video.duration * 100
|
let bufferPercent = video.buffered.length == 0 ? 0 : video.buffered.end(video.buffered.length - 1) / video.duration * 100
|
||||||
progress.style.setProperty("--buffer", bufferPercent + "%");
|
progress.style.setProperty("--buffer", bufferPercent + "%");
|
||||||
updateBar(progressPercent || progress.value / 10);
|
updateBar(progressPercent || progress.value / 10);
|
||||||
createThumbnail(video);
|
createThumbnail(video);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dragBar() {
|
function dragBar() {
|
||||||
video.pause()
|
video.pause()
|
||||||
updateBar(progress.value / 10)
|
updateBar(progress.value / 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
function dragBarEnd() {
|
function dragBarEnd() {
|
||||||
video.currentTime = currentTime || 0
|
video.currentTime = currentTime || 0
|
||||||
playVideo()
|
playVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dragBarStart() {
|
async function dragBarStart() {
|
||||||
await video.pause()
|
await video.pause()
|
||||||
updateBar(progress.value / 10)
|
updateBar(progress.value / 10)
|
||||||
}
|
}
|
||||||
let currentTime
|
|
||||||
|
let currentTime;
|
||||||
function updateBar(progressPercent) {
|
function updateBar(progressPercent) {
|
||||||
currentTime = video.duration * progressPercent / 100
|
currentTime = video.duration * progressPercent / 100
|
||||||
progress.style.setProperty("--progress", progressPercent + "%");
|
progress.style.setProperty("--progress", progressPercent + "%");
|
||||||
|
|
@ -77,12 +81,11 @@ function updateBar(progressPercent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// dynamic thumbnails
|
// dynamic thumbnails
|
||||||
let thumbnails = [],
|
let thumbnails = []
|
||||||
ratio,
|
let ratio
|
||||||
canvas = document.createElement("canvas"),
|
let canvas = document.createElement("canvas")
|
||||||
context = canvas.getContext('2d'),
|
let context = canvas.getContext('2d')
|
||||||
w = 150,
|
let w = 150, h
|
||||||
h
|
|
||||||
|
|
||||||
function initThumbnail() {
|
function initThumbnail() {
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
|
|
@ -92,6 +95,7 @@ function initThumbnail() {
|
||||||
canvas.height = h;
|
canvas.height = h;
|
||||||
progress.style.setProperty("--height", h + "px");
|
progress.style.setProperty("--height", h + "px");
|
||||||
}
|
}
|
||||||
|
|
||||||
function createThumbnail(vid) {
|
function createThumbnail(vid) {
|
||||||
let index = Math.floor(vid.currentTime / 5)
|
let index = Math.floor(vid.currentTime / 5)
|
||||||
if (!thumbnails[index] && h) {
|
if (!thumbnails[index] && h) {
|
||||||
|
|
@ -100,6 +104,7 @@ function createThumbnail(vid) {
|
||||||
thumbnails[index] = canvas.toDataURL("image/jpeg")
|
thumbnails[index] = canvas.toDataURL("image/jpeg")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishThumbnails() {
|
function finishThumbnails() {
|
||||||
let thumbVid = document.createElement("video")
|
let thumbVid = document.createElement("video")
|
||||||
thumbVid.src = video.src
|
thumbVid.src = video.src
|
||||||
|
|
@ -122,7 +127,7 @@ function finishThumbnails() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//bufering spinner
|
// bufering spinner
|
||||||
|
|
||||||
let buffer;
|
let buffer;
|
||||||
function resetBuffer() {
|
function resetBuffer() {
|
||||||
|
|
@ -136,13 +141,14 @@ function resetBuffer() {
|
||||||
function isBuffering() {
|
function isBuffering() {
|
||||||
buffer = setTimeout(displayBuffer, 150)
|
buffer = setTimeout(displayBuffer, 150)
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayBuffer() {
|
function displayBuffer() {
|
||||||
buffering.classList.remove('hidden')
|
buffering.classList.remove('hidden')
|
||||||
resetTimer()
|
resetTimer()
|
||||||
}
|
}
|
||||||
//immerse timeout
|
|
||||||
let immerseTime;
|
|
||||||
|
|
||||||
|
// immerse timeout
|
||||||
|
let immerseTime;
|
||||||
|
|
||||||
document.onmousemove = resetTimer;
|
document.onmousemove = resetTimer;
|
||||||
document.onkeypress = resetTimer;
|
document.onkeypress = resetTimer;
|
||||||
|
|
@ -155,22 +161,26 @@ function resetTimer() {
|
||||||
player.classList.remove('immersed')
|
player.classList.remove('immersed')
|
||||||
immerseTime = setTimeout(immersePlayer, 3000)
|
immerseTime = setTimeout(immersePlayer, 3000)
|
||||||
}
|
}
|
||||||
let islooped;
|
|
||||||
|
|
||||||
|
let islooped;
|
||||||
|
|
||||||
function toTS(sec) {
|
function toTS(sec) {
|
||||||
if (Number.isNaN(sec)) {
|
if (Number.isNaN(sec)) {
|
||||||
return "--:--";
|
return "--:--";
|
||||||
}
|
}
|
||||||
let hours = Math.floor(sec / 3600),
|
|
||||||
minutes = Math.floor((sec - (hours * 3600)) / 60),
|
let hours = Math.floor(sec / 3600)
|
||||||
seconds = Math.floor(sec - (hours * 3600) - (minutes * 60));
|
let minutes = Math.floor((sec - (hours * 3600)) / 60)
|
||||||
|
let seconds = Math.floor(sec - (hours * 3600) - (minutes * 60));
|
||||||
|
|
||||||
if (minutes < 10) {
|
if (minutes < 10) {
|
||||||
minutes = `0${minutes}`;
|
minutes = `0${minutes}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seconds < 10) {
|
if (seconds < 10) {
|
||||||
seconds = `0${seconds}`;
|
seconds = `0${seconds}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
return `${hours}:${minutes}:${seconds}`;
|
return `${hours}:${minutes}:${seconds}`;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -178,7 +188,7 @@ function toTS(sec) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//play/pause button
|
// play/pause button
|
||||||
async function playVideo() {
|
async function playVideo() {
|
||||||
try {
|
try {
|
||||||
await video.play();
|
await video.play();
|
||||||
|
|
@ -187,6 +197,7 @@ async function playVideo() {
|
||||||
btnpp.innerHTML = "play_arrow";
|
btnpp.innerHTML = "play_arrow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bpp() {
|
function bpp() {
|
||||||
if (video.paused) {
|
if (video.paused) {
|
||||||
playVideo();
|
playVideo();
|
||||||
|
|
@ -200,7 +211,7 @@ function bnext() {
|
||||||
nyaaSearch(nowPlaying[0], nowPlaying[1] + 1)
|
nyaaSearch(nowPlaying[0], nowPlaying[1] + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
//volume shit
|
// volume shit
|
||||||
|
|
||||||
let oldlevel;
|
let oldlevel;
|
||||||
|
|
||||||
|
|
@ -228,7 +239,7 @@ function updateVolume(a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//PiP
|
// PiP
|
||||||
|
|
||||||
async function bpip() {
|
async function bpip() {
|
||||||
if (video !== document.pictureInPictureElement) {
|
if (video !== document.pictureInPictureElement) {
|
||||||
|
|
@ -238,13 +249,13 @@ async function bpip() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//theathe mode
|
// theathe mode
|
||||||
|
|
||||||
function btheatre() {
|
function btheatre() {
|
||||||
halfmoon.toggleSidebar();
|
halfmoon.toggleSidebar();
|
||||||
}
|
}
|
||||||
|
|
||||||
//fullscreen
|
// fullscreen
|
||||||
|
|
||||||
function bfull() {
|
function bfull() {
|
||||||
if (!document.fullscreenElement) {
|
if (!document.fullscreenElement) {
|
||||||
|
|
@ -261,7 +272,7 @@ function seek(a) {
|
||||||
video.currentTime += a;
|
video.currentTime += a;
|
||||||
updateDisplay()
|
updateDisplay()
|
||||||
}
|
}
|
||||||
//subtitles button, generates content every single time its opened because fuck knows when the parser will find new shit
|
// subtitles button, generates content every single time its opened because fuck knows when the parser will find new shit
|
||||||
let off
|
let off
|
||||||
function bcap() {
|
function bcap() {
|
||||||
let frag = document.createDocumentFragment()
|
let frag = document.createDocumentFragment()
|
||||||
|
|
@ -304,7 +315,7 @@ function selectLang(lang) {
|
||||||
}
|
}
|
||||||
bcap()
|
bcap()
|
||||||
}
|
}
|
||||||
//keybinds
|
// keybinds
|
||||||
|
|
||||||
document.onkeydown = function (a) {
|
document.onkeydown = function (a) {
|
||||||
if (document.location.href.endsWith("#player")) {
|
if (document.location.href.endsWith("#player")) {
|
||||||
|
|
@ -341,7 +352,8 @@ document.onkeydown = function (a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//media session
|
|
||||||
|
// media session
|
||||||
function nowPlaying(sel) {
|
function nowPlaying(sel) {
|
||||||
nowPlaying = sel
|
nowPlaying = sel
|
||||||
if ('mediaSession' in navigator) {
|
if ('mediaSession' in navigator) {
|
||||||
|
|
@ -359,6 +371,7 @@ function nowPlaying(sel) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePositionState() {
|
function updatePositionState() {
|
||||||
if ('setPositionState' in navigator.mediaSession) {
|
if ('setPositionState' in navigator.mediaSession) {
|
||||||
navigator.mediaSession.setPositionState({
|
navigator.mediaSession.setPositionState({
|
||||||
|
|
@ -368,6 +381,7 @@ function updatePositionState() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('mediaSession' in navigator) {
|
if ('mediaSession' in navigator) {
|
||||||
navigator.mediaSession.setActionHandler('play', bpp);
|
navigator.mediaSession.setActionHandler('play', bpp);
|
||||||
navigator.mediaSession.setActionHandler('pause', bpp);
|
navigator.mediaSession.setActionHandler('pause', bpp);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue