function checkImgExists(imgSrc) {
var ImgObj = new Image();
ImgObj.src = imgSrc;
if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
return true;
} else {
return false;
}
}
function Refresh() {
// Artwork types: "front", "back", "disc", "icon", "artist"
var coverDefaultURI = "../Spin Disc's/images/no cover.png";
var coverURI = chrome.webview.hostObjects.sync.foo_uie_webview.getArtwork("front");
document.getElementById("CoverBg").src = (coverURI.length != 0) ? coverURI : coverDefaultURI;
document.getElementById("Cover").src = (coverURI.length != 0) ? coverURI : coverDefaultURI;
var backDefaultURI = "../Spin Disc's/images/no back.png";
var backURI = chrome.webview.hostObjects.sync.foo_uie_webview.getArtwork("back");
if (backURI.length != 0) {
document.getElementById("Back").src = backURI;
} else {
if (back_sw.checked) {
document.getElementById("Back").src = document.getElementById("Cover").src;
} else {
document.getElementById("Back").src = backDefaultURI;
}
}
document.getElementById("Mask").src = "../Spin Disc's/images/no mask.png";
var discDefaultURI = "../Spin Disc's/images/no disc.png";
var discURI = chrome.webview.hostObjects.sync.foo_uie_webview.getArtwork("disc");
if (discURI.length != 0) {
document.getElementById("Disc").src = discURI;
} else {
if (disc_sw.checked) {
document.getElementById("Disc").src = document.getElementById("Cover").src;
Mask.style.display = "block"; // Mantieni il mask visibile se era visibile
} else {
document.getElementById("Disc").src = discDefaultURI;
}
}
var artistDefaultURI = "../Spin Disc's/images/no artist.png";
var artistURI = chrome.webview.hostObjects.sync.foo_uie_webview.getArtwork("artist");
if (artistURI.length != 0) {
document.getElementById("Artist").src = artistURI;
} else {
if (artist_sw.checked) {
document.getElementById("Artist").src = document.getElementById("Cover").src;
} else {
document.getElementById("Artist").src = artistDefaultURI;
}
}
var iconDataURI = "../Spin Disc's/images/no icon.png";
var iconURI = chrome.webview.hostObjects.sync.foo_uie_webview.getArtwork("front");
var imgPath = chrome.webview.hostObjects.sync.foo_uie_webview.getFormattedText("[$directory_path(%path%)]");
if (checkImgExists(imgPath + "/icon.png")) {
document.getElementById("Icon").src = imgPath + "/icon.png";
} else if (checkImgExists(imgPath + "/icon.jpg")) {
document.getElementById("Icon").src = imgPath + "/icon.jpg";
} else if (checkImgExists(imgPath + "/icon.gif")) {
document.getElementById("Icon").src = imgPath + "/icon.gif";
} else if (checkImgExists(imgPath + "/icon.webp")) {
document.getElementById("Icon").src = imgPath + "/icon.webp";
} else if (checkImgExists(imgPath + "/icon.jpeg")) {
document.getElementById("Icon").src = imgPath + "/icon.jpeg";
} else {
document.getElementById("Icon").src = (iconURI.length != 0) ? iconURI : iconDataURI;
}
if (audio_sw.checked) {
Spectrum.style.display = "block";
} else {
Spectrum.style.display = "none";
}
}
function changeColor() {
if (document.getElementsByName("isColor")[0].checked) {
bgCover.style.display = "none";
document.body.style.backgroundColor = "#212121";
} else if (document.getElementsByName("isColor")[1].checked) {
bgCover.style.display = "none";
document.body.style.backgroundColor = "transparent";
} else if (document.getElementsByName("isColor")[2].checked) {
bgCover.style.display = "block";
document.body.style.backgroundColor = "transparent";
} else if (document.getElementsByName("isColor")[3].checked) {
bgCover.style.display = "none";
document.body.style.backgroundColor = Col_P.value;
}
}
/****The following is the expansion of the taste-resolving stone****/
Refresh();
var Mask_element = document.getElementById("Mask");
Mask_element.addEventListener("dblclick", function(event) {
Mask.style.display = "none";
});
var Disc_element = document.getElementById("Disc");
Disc_element.addEventListener("dblclick", function(event) {
Mask.style.display = "block";
});
var cover_element = document.getElementById("slideshow");
cover_element.addEventListener("dblclick", function(event) {
if (lun_time > 0) {
opacity_jsq -= 0.1;
if (opacity_jsq <= 0.1) opacity_jsq = 1;
if (Cover.style.opacity > 0) Cover.style.opacity = opacity_jsq.toFixed(1);
if (Back.style.opacity > 0) Back.style.opacity = opacity_jsq.toFixed(1);
if (Artist.style.opacity > 0) Artist.style.opacity = opacity_jsq.toFixed(1);
document.getElementById("Cal_y").value = opacity_jsq.toFixed(1);
} else {
images[currentImage].style.opacity = 0;
currentImage = (currentImage + 1) % images.length;
images[currentImage].style.opacity = cover_opacity; // opacity_jsq.toFixed(1);
}
});
var icon_element = document.getElementById("Icon");
var icon_jsq = 0;
icon_element.addEventListener("click", function(event) {
icon_jsq += 1;
if (icon_jsq == 2) icon_jsq = 0;
if (icon_jsq == 1) config.style.display = "block";
else config.style.display = "none";
});