diff --git a/Contents/Resources/web/js/plexauth.js b/Contents/Resources/web/js/plexauth.js
index a725d170..54275898 100644
--- a/Contents/Resources/web/js/plexauth.js
+++ b/Contents/Resources/web/js/plexauth.js
@@ -4,11 +4,11 @@ var p = {
name: 'Unknown',
version: 'Unknown',
os: 'Unknown'
-};
+}
if (typeof platform !== 'undefined') {
- p.name = platform.name;
- p.version = platform.version;
- p.os = platform.os.toString();
+ p.name = platform.name
+ p.version = platform.version
+ p.os = platform.os.toString()
}
function getPlexHeaders(clientID) {
@@ -16,7 +16,7 @@ function getPlexHeaders(clientID) {
'Accept': 'application/json',
'X-Plex-Product': 'Themerr',
'X-Plex-Version': 'Plex OAuth',
- 'X-Plex-Client-Identifier': clientID ? clientID : getLocalStorage('Tautulli_ClientID', uuidv4(), false),
+ 'X-Plex-Client-Identifier': clientID ? clientID : getLocalStorage('Themerr_ClientID', uuidv4(), false),
'X-Plex-Platform': p.name,
'X-Plex-Platform-Version': p.version,
'X-Plex-Model': 'Plex OAuth',
@@ -24,144 +24,147 @@ function getPlexHeaders(clientID) {
'X-Plex-Device-Name': p.name + ' (Themerr)',
'X-Plex-Device-Screen-Resolution': window.screen.width + 'x' + window.screen.height,
'X-Plex-Language': 'en'
- };
+ }
}
function encodeData(data) {
- return Object.keys(data).map(function(key) {
- return [key, data[key]].map(encodeURIComponent).join("=");
- }).join("&");
+ return Object.keys(data).map(function (key) {
+ return [key, data[key]].map(encodeURIComponent).join("=")
+ }).join("&")
}
-var plex_oauth_window = null;
+var plex_oauth_window = null
const plex_oauth_loader = '' +
'
' +
- '
' +
- '
' +
- '
' +
- 'Redirecting to the Plex login page...' +
- '
' +
- '
';
+ '' +
+ '
' +
+ '
' +
+ 'Redirecting to the Plex login page...' +
+ '
' +
+ ''
function closePlexOAuthWindow() {
if (plex_oauth_window) {
- plex_oauth_window.close();
+ plex_oauth_window.close()
}
}
-function setLocalStorage(key, value, path) {
- var key_path = key;
+function getKeyPath(key, path) {
+ var key_path = key
if (path !== false) {
- key_path = key_path + '_' + window.location.pathname;
+ key_path = `${key_path}_${window.location.pathname}`
}
- localStorage.setItem(key_path, value);
+ return key_path
+}
+
+function setLocalStorage(key, value, path) {
+ var key_path = getKeyPath(key, path)
+ localStorage.setItem(key_path, value)
}
+
function getLocalStorage(key, default_value, path) {
- var key_path = key;
- if (path !== false) {
- key_path = key_path + '_' + window.location.pathname;
- }
- var value = localStorage.getItem(key_path);
+ var key_path = getKeyPath(key, path)
+ var value = localStorage.getItem(key_path)
if (value !== null) {
return value
} else if (default_value !== undefined) {
- setLocalStorage(key, default_value, path);
+ setLocalStorage(key, default_value, path)
return default_value
}
}
function uuidv4() {
- return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c) {
- var cryptoObj = window.crypto || window.msCrypto; // for IE 11
+ 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)
- });
+ })
}
getPlexOAuthPin = function (clientID) {
- var x_plex_headers = getPlexHeaders(clientID);
- var deferred = $.Deferred();
+ var x_plex_headers = getPlexHeaders(clientID)
+ var deferred = $.Deferred()
$.ajax({
url: 'https://plex.tv/api/v2/pins?strong=true',
type: 'POST',
headers: x_plex_headers,
- success: function(data) {
- deferred.resolve({pin: data.id, code: data.code});
+ success: function (data) {
+ deferred.resolve({ pin: data.id, code: data.code })
},
- error: function() {
- closePlexOAuthWindow();
- deferred.reject();
+ error: function () {
+ closePlexOAuthWindow()
+ deferred.reject()
}
- });
- return deferred;
-};
+ })
+ return deferred
+}
function PopupCenter(url, title, w, h) {
- // Fixes dual-screen position Most browsers Firefox
- var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
- var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
+ // Fixes dual-screen position Most browsers Firefox
+ var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX
+ var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY
- var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
- var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
+ var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width
+ var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height
- var left = ((width / 2) - (w / 2)) + dualScreenLeft;
- var top = ((height / 2) - (h / 2)) + dualScreenTop;
- var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
+ var left = ((width / 2) - (w / 2)) + dualScreenLeft
+ var top = ((height / 2) - (h / 2)) + dualScreenTop
+ var newWindow = window.open(url, title, `scrollbars=yes, width=${w}, height=${h}, top=${top}, left=${left}`)
// Puts focus on the newWindow
if (window.focus) {
- newWindow.focus();
+ newWindow.focus()
}
- return newWindow;
+ return newWindow
}
-var polling = null;
+var polling = null
function PlexOAuth(success, error, pre, clientID) {
if (typeof pre === "function") {
pre()
}
- closePlexOAuthWindow();
- plex_oauth_window = PopupCenter('', 'Plex-OAuth', 600, 700);
- $(plex_oauth_window.document.body).html(plex_oauth_loader);
+ closePlexOAuthWindow()
+ plex_oauth_window = PopupCenter('', 'Plex-OAuth', 600, 700)
+ $(plex_oauth_window.document.body).html(plex_oauth_loader)
getPlexOAuthPin(clientID).then(function (data) {
- var x_plex_headers = getPlexHeaders(clientID);
- const pin = data.pin;
- const code = data.code;
+ var x_plex_headers = getPlexHeaders(clientID)
+ const pin = data.pin
+ const code = data.code
var oauth_params = {
'clientID': x_plex_headers['X-Plex-Client-Identifier'],
@@ -177,17 +180,17 @@ function PlexOAuth(success, error, pre, clientID) {
'code': code
}
- plex_oauth_window.location = 'https://app.plex.tv/auth/#!?' + encodeData(oauth_params);
+ plex_oauth_window.location = `https://app.plex.tv/auth/#!?${encodeData(oauth_params)}`
polling = pin;
(function poll() {
$.ajax({
- url: 'https://plex.tv/api/v2/pins/' + pin,
+ url: `https://plex.tv/api/v2/pins/${pin}`,
type: 'GET',
headers: x_plex_headers,
success: function (data) {
- if (data.authToken){
- closePlexOAuthWindow();
+ if (data.authToken) {
+ closePlexOAuthWindow()
if (typeof success === "function") {
success(data.authToken)
}
@@ -195,24 +198,24 @@ function PlexOAuth(success, error, pre, clientID) {
},
error: function (jqXHR, textStatus, errorThrown) {
if (textStatus !== "timeout") {
- closePlexOAuthWindow();
+ closePlexOAuthWindow()
if (typeof error === "function") {
error()
}
}
},
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
- });
- })();
+ })
+ })()
}, function () {
- closePlexOAuthWindow();
+ closePlexOAuthWindow()
if (typeof error === "function") {
error()
}
- });
-}
\ No newline at end of file
+ })
+}
diff --git a/Contents/Resources/web/templates/login.html b/Contents/Resources/web/templates/login.html
index f8b7ede8..93e9a2d0 100644
--- a/Contents/Resources/web/templates/login.html
+++ b/Contents/Resources/web/templates/login.html
@@ -15,7 +15,8 @@
-
+
@@ -27,25 +28,25 @@
-{% endblock scripts %}
+{% endblock scripts %}
\ No newline at end of file