Add info button
This commit is contained in:
parent
3435f0d8be
commit
b7c7853a98
1 changed files with 86 additions and 28 deletions
|
|
@ -29,6 +29,89 @@
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => (apiKey = data.AccessToken)); // Store AccessToken
|
.then((data) => (apiKey = data.AccessToken)); // Store AccessToken
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Button to refresh the metadata of an item
|
||||||
|
function refreshButton() {
|
||||||
|
let el = document.createElement("button");
|
||||||
|
el.className = "listItemButton paper-icon-button-light emby-button";
|
||||||
|
let el2 = document.createElement("span");
|
||||||
|
|
||||||
|
// Set icon and color
|
||||||
|
el2.className = "material-icons refresh";
|
||||||
|
el2.style.color = "#83a598";
|
||||||
|
el.style.position = "relative";
|
||||||
|
el.style.overflow = "hidden";
|
||||||
|
|
||||||
|
el.appendChild(el2);
|
||||||
|
|
||||||
|
// Bind refresh function
|
||||||
|
el.onclick = function () {
|
||||||
|
let url = `${window.origin}/Items/${this.parentElement.dataset.id}/Refresh?Recursive=true&ImageRefreshMode=FullRefresh&MetadataRefreshMode=FullRefresh&ReplaceAllImages=true&ReplaceAllMetadata=true`;
|
||||||
|
console.log(`Refreshing ${url}`);
|
||||||
|
|
||||||
|
// Send refresh request
|
||||||
|
fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"X-Emby-Authorization": `MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="${apiKey}"`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// Replace empty image with rotating spinner
|
||||||
|
this.parentElement.firstChild.firstChild.classList.remove("audiotrack")
|
||||||
|
this.parentElement.firstChild.firstChild.classList.add("sync", "rotating")
|
||||||
|
var style = document.createElement('style');
|
||||||
|
style.innerHTML = `
|
||||||
|
.rotating {
|
||||||
|
animation: rotate 1s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes rotate {
|
||||||
|
from { transform: rotate(0deg); }
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}`;
|
||||||
|
// Add style element to document head
|
||||||
|
document.head.appendChild(style);
|
||||||
|
};
|
||||||
|
//Return complete element
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Button to display bitrate of item
|
||||||
|
function infoButton() {
|
||||||
|
let el = document.createElement("button");
|
||||||
|
el.className = "listItemButton paper-icon-button-light emby-button";
|
||||||
|
let el2 = document.createElement("span");
|
||||||
|
|
||||||
|
// Set icon and color
|
||||||
|
el2.className = "material-icons info";
|
||||||
|
el2.style.color = "#fbf1c7";
|
||||||
|
el.appendChild(el2);
|
||||||
|
|
||||||
|
// Bind get function
|
||||||
|
el.onclick = function () {
|
||||||
|
let bitrate;
|
||||||
|
let url = `${window.origin}/Users/${userid}/Items/${this.parentElement.dataset.id}`;
|
||||||
|
console.log(`Fetching ${url}`);
|
||||||
|
|
||||||
|
// Send deletion request
|
||||||
|
fetch(url, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"X-Emby-Authorization": `MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="${apiKey}"`,
|
||||||
|
},
|
||||||
|
}).then((response) => response.json())
|
||||||
|
.then((data) => (bitrate = data.MediaSources[0].MediaStreams[0].BitRate.toString().substring(0, 3)));;
|
||||||
|
console.log(bitrate)
|
||||||
|
// Remove parent to provide feedback and prevent double deletion
|
||||||
|
alert(`Bitrate: ${bitrate}`)
|
||||||
|
};
|
||||||
|
//Return complete element
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper function to create delete button
|
// Helper function to create delete button
|
||||||
function delButton() {
|
function delButton() {
|
||||||
let el = document.createElement("button");
|
let el = document.createElement("button");
|
||||||
|
|
@ -57,33 +140,7 @@
|
||||||
this.parentElement.remove();
|
this.parentElement.remove();
|
||||||
};
|
};
|
||||||
//Return complete element
|
//Return complete element
|
||||||
return el2;
|
return el;
|
||||||
}
|
|
||||||
|
|
||||||
// Button to refresh the metadata of an item
|
|
||||||
function refreshButton() {
|
|
||||||
let el = document.createElement("button");
|
|
||||||
el.className = "listItemButton paper-icon-button-light emby-button";
|
|
||||||
let el2 = document.createElement("span");
|
|
||||||
|
|
||||||
// Set icon and color
|
|
||||||
el2.className = "material-icons refresh";
|
|
||||||
el2.style.color = "#83a598";
|
|
||||||
el.appendChild(el2);
|
|
||||||
|
|
||||||
el.onclick = function () {
|
|
||||||
let url = `${window.origin}/Items/${this.parentElement.dataset.id}/Refresh?Recursive=true&ImageRefreshMode=FullRefresh&MetadataRefreshMode=FullRefresh&ReplaceAllImages=true&ReplaceAllMetadata=true`;
|
|
||||||
console.log(`Deleting ${url}`);
|
|
||||||
|
|
||||||
// Send deletion request
|
|
||||||
fetch(url, {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"X-Emby-Authorization": `MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="${apiKey}"`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return el2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert buttons
|
// Insert buttons
|
||||||
|
|
@ -95,6 +152,7 @@
|
||||||
|
|
||||||
// Append buttons to list
|
// Append buttons to list
|
||||||
curr.appendChild(refreshButton());
|
curr.appendChild(refreshButton());
|
||||||
|
curr.appendChild(infoButton());
|
||||||
curr.appendChild(delButton());
|
curr.appendChild(delButton());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,4 +165,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.addEventListener("keydown", onKeydown, true);
|
document.addEventListener("keydown", onKeydown, true);
|
||||||
})();
|
})();
|
||||||
Loading…
Add table
Reference in a new issue