make modplayer more better
This commit is contained in:
parent
36967ae5db
commit
452ac2bccb
|
@ -1,5 +1,10 @@
|
|||
PleromaModPlayer = function (attachment) {
|
||||
this.file = attachment.querySelector("a").href;
|
||||
this.file = "";
|
||||
if (attachment.querySelector("a")) {
|
||||
this.file = attachment.querySelector("a").href;
|
||||
} else if (attachment.querySelector("audio")) {
|
||||
this.file = attachment.querySelector("audio").src;
|
||||
}
|
||||
this.attachment = attachment.cloneNode(true);
|
||||
this.attachment.setAttribute("class", "mod-player");
|
||||
attachment.parentNode.replaceChild(this.attachment, attachment);
|
||||
|
@ -26,6 +31,12 @@ PleromaModPlayer = function (attachment) {
|
|||
}
|
||||
|
||||
this.songName = this.attachment.querySelector("a");
|
||||
if (!this.songName) {
|
||||
const audio = this.attachment.querySelector("audio");
|
||||
this.songName = document.createElement("a");
|
||||
this.songName.href = this.file;
|
||||
audio.style.visibility = "collapse";
|
||||
}
|
||||
this.songName.setAttribute("class", "mod-title");
|
||||
|
||||
const controls = document.createElement("div");
|
||||
|
@ -206,12 +217,20 @@ PleromaModTracker = function () {
|
|||
},
|
||||
|
||||
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(nonGalleryElement.querySelector("a").href)
|
||||
regex.test(src)
|
||||
) {
|
||||
result.push(nonGalleryElement);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue