mirror of
https://github.com/danieladov/jellyfin-plugin-skin-manager.git
synced 2026-03-18 21:30:33 +01:00
Add JSON maker
This commit is contained in:
30
src/html/skin__request.html
Normal file
30
src/html/skin__request.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.js" integrity="sha512-n/4gHW3atM3QqRcbCn6ewmpxcLAHGaDjpEBu4xZd47N0W2oQ+6q7oc3PXstrJYXcbNU1OHdQ1T7pAP+gi5Yu8g==" crossorigin="anonymous"></script>
|
||||
<script src="../js/json__compile.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<form>
|
||||
<input type="text" id="name" name="name">
|
||||
<input type="text" id="author" name="author">
|
||||
<input type=" text " id="desc" name="desc">
|
||||
<input type=" text " id="css" name="css">
|
||||
<h2>Images</h2>
|
||||
<input type=" text " id="login" name="login">
|
||||
<input type=" text " id="home" name="home">
|
||||
<input type=" text " id="lib" name="lib">
|
||||
<input type=" text " id="title" name="title">
|
||||
<h2>Categories</h2>
|
||||
<input type="button" id="add" value="Add a foryour options categorie" onclick="add__option()">
|
||||
<input type="button" id="no_op" value="Don't have any options/addons?" onclick="no__option()">
|
||||
<div id="cat"></div>
|
||||
<input type="hidden" value="1" id="total_chq">
|
||||
<input type="button" onclick="createJSON()" value="save" />
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
88
src/js/json__compile.js
Normal file
88
src/js/json__compile.js
Normal file
@@ -0,0 +1,88 @@
|
||||
function add__option() {
|
||||
window.new_chq_no = parseInt($('#total_chq').val()) + 1;
|
||||
window.new_input = "<h3>Categorie Name</h3><input type='text' id='cat_name'><div id='op_cont'><div class='inner'><h4>option name</h4><input type='text' id='op_name'><h4>option type</h4><input type='text' id='op_type'><h4>option description</h4><input type='text' id='op_desc'><h4>option css</h4><input type='text' id='op_css'></div><input type='button' value='Add a new option'></div>";
|
||||
|
||||
$('#cat').append(new_input);
|
||||
|
||||
$('#total_chq').val(new_chq_no);
|
||||
}
|
||||
|
||||
function create_option_json() {
|
||||
var option__name = document.querySelectorAll('#op_name');
|
||||
option__name.forEach(option__name => function() {
|
||||
var json__options = {
|
||||
"categories": [{
|
||||
"name": "Default",
|
||||
"options": [{
|
||||
"name": name
|
||||
}]
|
||||
}]
|
||||
}
|
||||
})
|
||||
|
||||
var categories = {}
|
||||
}
|
||||
|
||||
function no__option() {
|
||||
$('#no_op').on('click', function() {
|
||||
var json__options = {
|
||||
"categories": [{
|
||||
"name": "Default",
|
||||
"options": []
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function createJSON() {
|
||||
var name = document.getElementById("name").value;
|
||||
var author = document.getElementById("author").value;
|
||||
var desc = document.getElementById("desc").value;
|
||||
var CSS = document.getElementById("css").value;
|
||||
var login = document.getElementById("login").value;
|
||||
var home = document.getElementById("home").value;
|
||||
var lib = document.getElementById("lib").value;
|
||||
var title = document.getElementById("title").value;
|
||||
var json__compiled = {
|
||||
"name ": name,
|
||||
"author ": author,
|
||||
"description ": desc,
|
||||
"defaultCss ": CSS,
|
||||
"previews ": [{
|
||||
"name ": "Login Page ",
|
||||
"url ": login
|
||||
},
|
||||
{
|
||||
"name ": "Home/Index Page ",
|
||||
"url ": home
|
||||
},
|
||||
{
|
||||
"name ": "Library Page ",
|
||||
"url ": lib
|
||||
},
|
||||
{
|
||||
"name ": "Title page ",
|
||||
"url ": title
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
var json = JSON.stringify(json__compiled, null, 4);
|
||||
|
||||
json = [json];
|
||||
var json__blob = new Blob(json, { type: "text/plain;charset=utf-8" });
|
||||
|
||||
var isIE = false || !!document.documentMode;
|
||||
if (isIE) {
|
||||
window.navigator.msSaveBlob(json__blob, name + ".json");
|
||||
} else {
|
||||
var url = window.URL || window.webkitURL;
|
||||
link = url.createObjectURL(json__blob);
|
||||
var a = document.createElement("a");
|
||||
a.download = name + ".json";
|
||||
a.href = link;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user