Popup window for Plex OAuth
This commit is contained in:
@@ -470,3 +470,23 @@ function openPlexXML(endpoint, plextv, params) {
|
|||||||
window.open(xml_url, '_blank');
|
window.open(xml_url, '_blank');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Puts focus on the newWindow
|
||||||
|
if (window.focus) {
|
||||||
|
newWindow.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return newWindow;
|
||||||
|
}
|
@@ -163,7 +163,9 @@
|
|||||||
const code = data.code;
|
const code = data.code;
|
||||||
var keep_polling = true;
|
var keep_polling = true;
|
||||||
|
|
||||||
window.open('https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + code);
|
var plex_oauth_window = PopupCenter(
|
||||||
|
'https://app.plex.tv/auth/#!?clientID=' + x_plex_headers['X-Plex-Client-Identifier'] + '&code=' + code,
|
||||||
|
'Plex-OAuth', 600, 700);
|
||||||
|
|
||||||
(function poll() {
|
(function poll() {
|
||||||
polling = setTimeout(function () {
|
polling = setTimeout(function () {
|
||||||
@@ -174,6 +176,9 @@
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.authToken){
|
if (data.authToken){
|
||||||
keep_polling = false;
|
keep_polling = false;
|
||||||
|
if (plex_oauth_window) {
|
||||||
|
plex_oauth_window.close();
|
||||||
|
}
|
||||||
signIn(true, data.authToken);
|
signIn(true, data.authToken);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user