Files
jellyfin-plugin-skin-manager/Jellyfin.Plugin.SkinManager/Configuration/configurationpage.html
2020-12-09 13:43:13 +01:00

191 lines
6.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Skin Manager</title>
</head>
<body>
<div data-role="page" class="page type-interior pluginConfigurationPage tbsConfigurationPage"
data-require="emby-input,emby-button">
<div data-role="content">
<div class="content-primary">
<form class="tbsConfigurationPage">
<div class="sectionTitleContainer flex align-items-center">
<h2 class="sectionTitle">Skin Manager</h2>
<a is="emby-linkbutton" class="raised button-alt headerHelpButton emby-button" target="_blank"
href="https://github.com/danieladov/jellyfin-plugin-skin-manager">Help</a>
</div>
<div class="verticalSection">
<p>
Select the skin you want to install and press Set Skin
</p>
<br />
</div>
<div class="selectContainer">
<label for="css">css</label>
<select is="emby-select" id="cssOptions" onchange="updateVersions()">
</select>
<label for="Version">Version</label>
<select is="emby-select" id="skinVersions" onchange="updateDescription()">
</select>
<p id="description"></p>
<br />
<button is="emby-button" type="button" class="raised block" id="refresh-library"
onclick=setSkin()>
<span>Set Skin</span>
</button>
</form>
</div>
</div>
<script type="text/javascript">
function loadSkins(){
$.getJSON('https://raw.githubusercontent.com/danieladov/jellyfin-plugin-skin-manager/master/skins-2.0.json', function(data) {
var cssOptions = document.getElementById("cssOptions");
var skinVersions = document.getElementById("skinVersions");
var versionDescription = document.getElementById("versionDescription");
data.forEach(element => {
var opt = document.createElement("option");
opt.appendChild(document.createTextNode(element.name));
opt.value=element.name;
cssOptions.appendChild(opt);
element.versions.forEach(version =>{
})
});
updateVersions()
});
}
loadSkins();
function updateVersions(){
var selected = $('#cssOptions').val();
var skinVersions = document.getElementById("skinVersions");
//clear selector
for (i = skinVersions.options.length-1; i >= 0; i--) {
skinVersions.options[i] = null;
}
$.getJSON('https://raw.githubusercontent.com/danieladov/jellyfin-plugin-skin-manager/master/skins-2.0.json', function(data) {
var skinVersions = document.getElementById("skinVersions");
data.forEach(element => {
if(selected == element.name){
element.versions.forEach(version =>{
var opt = document.createElement("option");
opt.appendChild(document.createTextNode(version.name));
opt.value=version.css;
skinVersions.appendChild(opt);
description.innerHTML=version.description;
})
}
});
updateDescription()
});
}
function updateDescription( ){
var description = document.getElementById("description");
var selected = $('#skinVersions').val();
$.getJSON('https://raw.githubusercontent.com/danieladov/jellyfin-plugin-skin-manager/master/skins-2.0.json', function(data) {
data.forEach(element => {
element.versions.forEach(version => {
if(version.css == selected){
description.innerHTML=version.description;
}
});
})
})
}
function setSkin() {
ApiClient.getServerConfiguration().then(function (config) {
ApiClient.updateServerConfiguration(config).then(function() {
ApiClient.getNamedConfiguration('branding').then(function(brandingConfig) {
brandingConfig.CustomCss = $('#skinVersions').val();
ApiClient.updateNamedConfiguration('branding', brandingConfig).then(function () {
Dashboard.processServerConfigurationUpdateResult();
window.location.reload(true);
});
});
});
});
}
</script>
<script type="text/javascript">
var plugin = {
guid: 'e9ca8b8e-ca6d-40e7-85dc-58e536df8eb3'
};
$('#configPage').on('pageshow', function () {
Dashboard.showLoadingMsg();
loadSavedConfig();
ApiClient.getPluginConfiguration(plugin.guid).then(function (config) {
$('#cssOptions').val(config.selectedCss).change();
Dashboard.hideLoadingMsg();
});
});
$('#configForm').on('submit', function () {
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(plugin.guid).then(function (config) {
config.selectedCss = $('#cssOptions').val();
ApiClient.updatePluginConfiguration(plugin.guid, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
});
return false;
});
</script>
</div>
</body>
</html>