remodel config to match jellyfin purpose

This commit is contained in:
2021-02-06 16:36:15 +01:00
parent 110baa67d5
commit 6e1067e43e
11 changed files with 390 additions and 471 deletions

View File

@@ -145,7 +145,7 @@ function doAjaxCall(url, elem, reload, form, showMsg, callback) {
dataString = $(formID).serialize();
}
// Loader Image
var loader = $("<div class='msg ajaxLoader-" + url +"'><i class='fa fa-refresh fa-spin'></i>&nbsp; Saving...</div>");
var loader = $("<div class='msg ajaxLoader-" + url + "'><i class='fa fa-refresh fa-spin'></i>&nbsp; Saving...</div>");
// Data Success Message
var dataSucces = $(elem).data('success');
if (typeof dataSucces === "undefined") {
@@ -248,10 +248,10 @@ getBrowsePath = function (key, path, filter_ext) {
path: path,
filter_ext: filter_ext
},
success: function(data) {
success: function (data) {
deferred.resolve(data);
},
error: function() {
error: function () {
deferred.reject();
}
});
@@ -350,13 +350,13 @@ function getPercent(value1, value2) {
function millisecondsToMinutes(ms, roundToMinute) {
if (ms > 0) {
var minutes = Math.floor(ms / 60000);
var seconds = ((ms % 60000) / 1000).toFixed(0);
if (roundToMinute) {
return (seconds >= 30 ? (minutes + 1) : minutes);
} else {
return (seconds == 60 ? (minutes + 1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds);
}
var minutes = Math.floor(ms / 60000);
var seconds = ((ms % 60000) / 1000).toFixed(0);
if (roundToMinute) {
return (seconds >= 30 ? (minutes + 1) : minutes);
} else {
return (seconds == 60 ? (minutes + 1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds);
}
} else {
if (roundToMinute) {
return '0';
@@ -366,7 +366,7 @@ function millisecondsToMinutes(ms, roundToMinute) {
}
}
function humanDuration(ms, sig='dhm', units='ms', return_seconds=300000) {
function humanDuration(ms, sig = 'dhm', units = 'ms', return_seconds = 300000) {
var factors = {
d: 86400000,
h: 3600000,
@@ -385,7 +385,7 @@ function humanDuration(ms, sig='dhm', units='ms', return_seconds=300000) {
ms = ms * factors[units];
h = ms % factors['d'];
h = ms % factors['d'];
d = Math.trunc(ms / factors['d']);
m = h % factors['h'];
@@ -460,6 +460,7 @@ function getCookie(cname) {
}
return "";
}
var Accordion = function (el, multiple, close) {
this.el = el || {};
this.multiple = multiple || false;
@@ -496,6 +497,7 @@ function clearSearchButton(tableName, table) {
table.search('').draw();
});
}
// Taken from https://github.com/Hellowlol/HTPC-Manager
window.onerror = function (message, file, line) {
var e = {
@@ -504,7 +506,8 @@ window.onerror = function (message, file, line) {
'file': file,
'line': line
};
$.post("log_js_errors", e, function (data) { });
$.post("log_js_errors", e, function (data) {
});
};
$('*').on('click', '.refresh_pms_image', function (e) {
@@ -554,14 +557,11 @@ function forceMinMax(elem) {
var default_val = parseInt(elem.data('default'));
if (isNaN(val)) {
elem.val(default_val);
}
else if (min !== undefined && val < min) {
} else if (min !== undefined && val < min) {
elem.val(min);
}
else if (max !== undefined && val > max) {
} else if (max !== undefined && val > max) {
elem.val(max);
}
else {
} else {
elem.val(val);
}
}
@@ -570,14 +570,14 @@ function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
$.fn.slideToggleBool = function(bool, options) {
return bool ? $(this).slideDown(options) : $(this).slideUp(options);
$.fn.slideToggleBool = function (bool, options) {
return bool ? $(this).slideDown(options) : $(this).slideUp(options);
};
function openPlexXML(endpoint, plextv, params) {
var data = $.extend({endpoint: endpoint, plextv: plextv}, params);
$.getJSON('return_plex_xml_url', data, function(xml_url) {
window.open(xml_url, '_blank');
$.getJSON('return_plex_xml_url', data, function (xml_url) {
window.open(xml_url, '_blank');
});
}
@@ -609,6 +609,7 @@ function setLocalStorage(key, value, path) {
}
localStorage.setItem(key_path, value);
}
function getLocalStorage(key, default_value, path) {
var key_path = key;
if (path !== false) {
@@ -624,7 +625,7 @@ function getLocalStorage(key, default_value, path) {
}
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
var cryptoObj = window.crypto || window.msCrypto; // for IE 11
return (c ^ cryptoObj.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
});
@@ -648,44 +649,44 @@ function getPlexHeaders() {
var plex_oauth_window = null;
const plex_oauth_loader = '<style>' +
'.login-loader-container {' +
'font-family: "Open Sans", Arial, sans-serif;' +
'position: absolute;' +
'top: 0;' +
'right: 0;' +
'bottom: 0;' +
'left: 0;' +
'}' +
'.login-loader-message {' +
'color: #282A2D;' +
'text-align: center;' +
'position: absolute;' +
'left: 50%;' +
'top: 25%;' +
'transform: translate(-50%, -50%);' +
'}' +
'.login-loader {' +
'border: 5px solid #ccc;' +
'-webkit-animation: spin 1s linear infinite;' +
'animation: spin 1s linear infinite;' +
'border-top: 5px solid #282A2D;' +
'border-radius: 50%;' +
'width: 50px;' +
'height: 50px;' +
'position: relative;' +
'left: calc(50% - 25px);' +
'}' +
'@keyframes spin {' +
'0% { transform: rotate(0deg); }' +
'100% { transform: rotate(360deg); }' +
'}' +
'.login-loader-container {' +
'font-family: "Open Sans", Arial, sans-serif;' +
'position: absolute;' +
'top: 0;' +
'right: 0;' +
'bottom: 0;' +
'left: 0;' +
'}' +
'.login-loader-message {' +
'color: #282A2D;' +
'text-align: center;' +
'position: absolute;' +
'left: 50%;' +
'top: 25%;' +
'transform: translate(-50%, -50%);' +
'}' +
'.login-loader {' +
'border: 5px solid #ccc;' +
'-webkit-animation: spin 1s linear infinite;' +
'animation: spin 1s linear infinite;' +
'border-top: 5px solid #282A2D;' +
'border-radius: 50%;' +
'width: 50px;' +
'height: 50px;' +
'position: relative;' +
'left: calc(50% - 25px);' +
'}' +
'@keyframes spin {' +
'0% { transform: rotate(0deg); }' +
'100% { transform: rotate(360deg); }' +
'}' +
'</style>' +
'<div class="login-loader-container">' +
'<div class="login-loader-message">' +
'<div class="login-loader"></div>' +
'<br>' +
'Redirecting to the Plex login page...' +
'</div>' +
'<div class="login-loader-message">' +
'<div class="login-loader"></div>' +
'<br>' +
'Redirecting to the Plex login page...' +
'</div>' +
'</div>';
function closePlexOAuthWindow() {
@@ -702,10 +703,10 @@ getPlexOAuthPin = function () {
url: 'https://plex.tv/api/v2/pins?strong=true',
type: 'POST',
headers: x_plex_headers,
success: function(data) {
success: function (data) {
deferred.resolve({pin: data.id, code: data.code});
},
error: function() {
error: function () {
closePlexOAuthWindow();
deferred.reject();
}
@@ -751,7 +752,7 @@ function PlexOAuth(success, error, pre) {
type: 'GET',
headers: x_plex_headers,
success: function (data) {
if (data.authToken){
if (data.authToken) {
closePlexOAuthWindow();
if (typeof success === "function") {
success(data.authToken)
@@ -767,8 +768,10 @@ function PlexOAuth(success, error, pre) {
}
},
complete: function () {
if (!plex_oauth_window.closed && polling === pin){
setTimeout(function() {poll()}, 1000);
if (!plex_oauth_window.closed && polling === pin) {
setTimeout(function () {
poll()
}, 1000);
}
},
timeout: 10000
@@ -783,7 +786,7 @@ function PlexOAuth(success, error, pre) {
}
function encodeData(data) {
return Object.keys(data).map(function(key) {
return Object.keys(data).map(function (key) {
return [key, data[key]].map(encodeURIComponent).join("=");
}).join("&");
}
@@ -808,17 +811,39 @@ function page(endpoint, ...args) {
function pms_image_proxy(img, rating_key, width, height, opacity, background, blur, fallback, refresh, clip, img_format) {
var params = {};
if (img != null) { params.img = img; }
if (rating_key != null) { params.rating_key = rating_key; }
if (width != null) { params.width = width; }
if (height != null) { params.height = height; }
if (opacity != null) { params.opacity = opacity; }
if (background != null) { params.background = background; }
if (blur != null) { params.blur = blur; }
if (fallback != null) { params.fallback = fallback; }
if (refresh != null) { params.refresh = true; }
if (clip != null) { params.clip = true; }
if (img_format != null) { params.img_format = img_format; }
if (img != null) {
params.img = img;
}
if (rating_key != null) {
params.rating_key = rating_key;
}
if (width != null) {
params.width = width;
}
if (height != null) {
params.height = height;
}
if (opacity != null) {
params.opacity = opacity;
}
if (background != null) {
params.background = background;
}
if (blur != null) {
params.blur = blur;
}
if (fallback != null) {
params.fallback = fallback;
}
if (refresh != null) {
params.refresh = true;
}
if (clip != null) {
params.clip = true;
}
if (img_format != null) {
params.img_format = img_format;
}
return params;
}
@@ -832,7 +857,9 @@ function info_page(rating_key, guid, history, live) {
params.rating_key = rating_key;
}
if (history) { params.source = 'history'; }
if (history) {
params.source = 'history';
}
return params;
}
@@ -840,7 +867,9 @@ function info_page(rating_key, guid, history, live) {
function library_page(section_id) {
var params = {};
if (section_id != null) { params.section_id = section_id; }
if (section_id != null) {
params.section_id = section_id;
}
return params;
}
@@ -848,8 +877,12 @@ function library_page(section_id) {
function user_page(user_id, user) {
var params = {};
if (user_id != null) { params.user_id = user_id; }
if (user != null) { params.user = user; }
if (user_id != null) {
params.user_id = user_id;
}
if (user != null) {
params.user = user;
}
return params;
}