|
|
|
@ -35,7 +35,7 @@ PleromaModPlayer = function (attachment) {
|
|
|
|
|
const audio = this.attachment.querySelector("audio");
|
|
|
|
|
this.songName = document.createElement("a");
|
|
|
|
|
this.songName.href = this.file;
|
|
|
|
|
audio.style.visibility = "collapse";
|
|
|
|
|
audio.style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
this.songName.setAttribute("class", "mod-title");
|
|
|
|
|
|
|
|
|
@ -45,12 +45,16 @@ PleromaModPlayer = function (attachment) {
|
|
|
|
|
this.playButton = document.createElement("button");
|
|
|
|
|
this.playButton.onclick = () => { this.play() };
|
|
|
|
|
this.playButton.innerText = " ▶ ";
|
|
|
|
|
this.playButton.classList.add("btn");
|
|
|
|
|
this.playButton.classList.add("button-default");
|
|
|
|
|
this.playButton.disabled = !window.CompatAudioContext;
|
|
|
|
|
controls.appendChild(this.playButton);
|
|
|
|
|
|
|
|
|
|
this.stopButton = document.createElement("button");
|
|
|
|
|
this.stopButton.onclick = () => { this.stop() };
|
|
|
|
|
this.stopButton.innerText = " ■ ";
|
|
|
|
|
this.stopButton.classList.add("btn");
|
|
|
|
|
this.stopButton.classList.add("button-default");
|
|
|
|
|
controls.appendChild(this.stopButton);
|
|
|
|
|
|
|
|
|
|
this.seekBar = document.createElement("input");
|
|
|
|
@ -72,6 +76,8 @@ PleromaModPlayer = function (attachment) {
|
|
|
|
|
this.volumeBar.onmousemove = () => { PleromaModTracker.player.setVolume(this.volumeBar.value / 100) };
|
|
|
|
|
|
|
|
|
|
this.volumeButton = document.createElement("button");
|
|
|
|
|
this.volumeButton.classList.add("btn");
|
|
|
|
|
this.volumeButton.classList.add("button-default");
|
|
|
|
|
this.volumeButton.onclick = () => {
|
|
|
|
|
if (this.volumeBar.classList.contains("hidden")) {
|
|
|
|
|
this.volumeBar.classList.remove("hidden");
|
|
|
|
@ -194,48 +200,34 @@ PleromaModTracker = function () {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
function onReady () {
|
|
|
|
|
const posts = document.querySelectorAll(".status");
|
|
|
|
|
const posts = document.querySelectorAll(".StatusContent");
|
|
|
|
|
for (const post of posts) {
|
|
|
|
|
this.handlePost(post);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
function handlePost (postElement) {
|
|
|
|
|
if (
|
|
|
|
|
postElement.querySelectorAll &&
|
|
|
|
|
postElement.querySelectorAll(".attachments .non-gallery").length > 0
|
|
|
|
|
) {
|
|
|
|
|
const attachments = this.getModuleAttachments(postElement);
|
|
|
|
|
for (const attachment of attachments) {
|
|
|
|
|
if (this.ready) {
|
|
|
|
|
new PleromaModPlayer(attachment);
|
|
|
|
|
} else {
|
|
|
|
|
this.toUpdate.push(attachment);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!postElement.querySelector) {
|
|
|
|
|
console.warn("element?", postElement);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
function getModuleAttachments (postElement) {
|
|
|
|
|
console.log(postElement);
|
|
|
|
|
const result = [];
|
|
|
|
|
const nonGalleryElements = postElement.querySelectorAll(".non-gallery");
|
|
|
|
|
const regex = new RegExp(this.config.pattern, "i");
|
|
|
|
|
for (const nonGalleryElement of nonGalleryElements) {
|
|
|
|
|
const subElement = nonGalleryElement.querySelector(":first-child");
|
|
|
|
|
let src = "";
|
|
|
|
|
if (subElement.tagName === "A") {
|
|
|
|
|
src = subElement.href;
|
|
|
|
|
} else if (subElement.tagName === "AUDIO") {
|
|
|
|
|
src = subElement.src;
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
regex.test(src)
|
|
|
|
|
) {
|
|
|
|
|
result.push(nonGalleryElement);
|
|
|
|
|
const vueScope = PleromaModLoader.getVueScope(postElement.querySelector(".StatusContent"));
|
|
|
|
|
if (!vueScope || !vueScope._props.status) {
|
|
|
|
|
console.warn("vueScope?", vueScope);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const attachments = vueScope.$children;
|
|
|
|
|
for (const attachment of attachments) {
|
|
|
|
|
if (attachment.$vnode.componentOptions.tag === "attachment") {
|
|
|
|
|
if (attachment._props.attachment.mimetype === "audio/x-mod") {
|
|
|
|
|
if (this.ready) {
|
|
|
|
|
new PleromaModPlayer(attachment.$el);
|
|
|
|
|
} else {
|
|
|
|
|
this.toUpdate.push(attachment.$el);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
function catchUp () {
|
|
|
|
|