@@ -4,11 +4,11 @@ var p = {
4
4
name : 'Unknown' ,
5
5
version : 'Unknown' ,
6
6
os : 'Unknown'
7
- }
7
+ } ;
8
8
if ( typeof platform !== 'undefined' ) {
9
- p . name = platform . name
10
- p . version = platform . version
11
- p . os = platform . os . toString ( )
9
+ p . name = platform . name ;
10
+ p . version = platform . version ;
11
+ p . os = platform . os . toString ( ) ;
12
12
}
13
13
14
14
function getPlexHeaders ( clientID ) {
@@ -24,16 +24,16 @@ function getPlexHeaders(clientID) {
24
24
'X-Plex-Device-Name' : p . name + ' (Themerr)' ,
25
25
'X-Plex-Device-Screen-Resolution' : window . screen . width + 'x' + window . screen . height ,
26
26
'X-Plex-Language' : 'en'
27
- }
27
+ } ;
28
28
}
29
29
30
30
function encodeData ( data ) {
31
31
return Object . keys ( data ) . map ( function ( key ) {
32
- return [ key , data [ key ] ] . map ( encodeURIComponent ) . join ( "=" )
33
- } ) . join ( "&" )
32
+ return [ key , data [ key ] ] . map ( encodeURIComponent ) . join ( "=" ) ;
33
+ } ) . join ( "&" ) ;
34
34
}
35
35
36
- var plex_oauth_window = null
36
+ var plex_oauth_window = null ;
37
37
const plex_oauth_loader = '<style>' +
38
38
'.login-loader-container {' +
39
39
'font-family: "Open Sans", Arial, sans-serif;' +
@@ -73,98 +73,98 @@ const plex_oauth_loader = '<style>' +
73
73
'<br>' +
74
74
'Redirecting to the Plex login page...' +
75
75
'</div>' +
76
- '</div>'
76
+ '</div>' ;
77
77
78
78
function closePlexOAuthWindow ( ) {
79
79
if ( plex_oauth_window ) {
80
- plex_oauth_window . close ( )
80
+ plex_oauth_window . close ( ) ;
81
81
}
82
82
}
83
83
84
84
function getKeyPath ( key , path ) {
85
- var key_path = key
85
+ var key_path = key ;
86
86
if ( path !== false ) {
87
- key_path = `${ key_path } _${ window . location . pathname } `
87
+ key_path = `${ key_path } _${ window . location . pathname } ` ;
88
88
}
89
- return key_path
89
+ return key_path ;
90
90
}
91
91
92
92
function setLocalStorage ( key , value , path ) {
93
- var key_path = getKeyPath ( key , path )
94
- localStorage . setItem ( key_path , value )
93
+ var key_path = getKeyPath ( key , path ) ;
94
+ localStorage . setItem ( key_path , value ) ;
95
95
}
96
96
97
97
function getLocalStorage ( key , default_value , path ) {
98
- var key_path = getKeyPath ( key , path )
99
- var value = localStorage . getItem ( key_path )
98
+ var key_path = getKeyPath ( key , path ) ;
99
+ var value = localStorage . getItem ( key_path ) ;
100
100
if ( value !== null ) {
101
- return value
101
+ return value ;
102
102
} else if ( default_value !== undefined ) {
103
- setLocalStorage ( key , default_value , path )
104
- return default_value
103
+ setLocalStorage ( key , default_value , path ) ;
104
+ return default_value ;
105
105
}
106
106
}
107
107
108
108
function uuidv4 ( ) {
109
109
return ( [ 1e7 ] + - 1e3 + - 4e3 + - 8e3 + - 1e11 ) . replace ( / [ 0 1 8 ] / g, function ( c ) {
110
- var cryptoObj = window . crypto || window . msCrypto // for IE 11
111
- return ( c ^ cryptoObj . getRandomValues ( new Uint8Array ( 1 ) ) [ 0 ] & 15 >> c / 4 ) . toString ( 16 )
112
- } )
110
+ var cryptoObj = window . crypto || window . msCrypto ; // for IE 11
111
+ return ( c ^ cryptoObj . getRandomValues ( new Uint8Array ( 1 ) ) [ 0 ] & 15 >> c / 4 ) . toString ( 16 ) ;
112
+ } ) ;
113
113
}
114
114
115
115
getPlexOAuthPin = function ( clientID ) {
116
- var x_plex_headers = getPlexHeaders ( clientID )
117
- var deferred = $ . Deferred ( )
116
+ var x_plex_headers = getPlexHeaders ( clientID ) ;
117
+ var deferred = $ . Deferred ( ) ;
118
118
119
119
$ . ajax ( {
120
120
url : 'https://plex.tv/api/v2/pins?strong=true' ,
121
121
type : 'POST' ,
122
122
headers : x_plex_headers ,
123
123
success : function ( data ) {
124
- deferred . resolve ( { pin : data . id , code : data . code } )
124
+ deferred . resolve ( { pin : data . id , code : data . code } ) ;
125
125
} ,
126
126
error : function ( ) {
127
- closePlexOAuthWindow ( )
128
- deferred . reject ( )
127
+ closePlexOAuthWindow ( ) ;
128
+ deferred . reject ( ) ;
129
129
}
130
- } )
131
- return deferred
132
- }
130
+ } ) ;
131
+ return deferred ;
132
+ } ;
133
133
134
134
function PopupCenter ( url , title , w , h ) {
135
135
// Fixes dual-screen position Most browsers Firefox
136
- var dualScreenLeft = window . screenLeft != undefined ? window . screenLeft : window . screenX
137
- var dualScreenTop = window . screenTop != undefined ? window . screenTop : window . screenY
136
+ var dualScreenLeft = window . screenLeft != undefined ? window . screenLeft : window . screenX ;
137
+ var dualScreenTop = window . screenTop != undefined ? window . screenTop : window . screenY ;
138
138
139
- var width = window . innerWidth ? window . innerWidth : document . documentElement . clientWidth ? document . documentElement . clientWidth : screen . width
140
- var height = window . innerHeight ? window . innerHeight : document . documentElement . clientHeight ? document . documentElement . clientHeight : screen . height
139
+ var width = window . innerWidth ? window . innerWidth : document . documentElement . clientWidth ? document . documentElement . clientWidth : screen . width ;
140
+ var height = window . innerHeight ? window . innerHeight : document . documentElement . clientHeight ? document . documentElement . clientHeight : screen . height ;
141
141
142
- var left = ( ( width / 2 ) - ( w / 2 ) ) + dualScreenLeft
143
- var top = ( ( height / 2 ) - ( h / 2 ) ) + dualScreenTop
144
- var newWindow = window . open ( url , title , `scrollbars=yes, width=${ w } , height=${ h } , top=${ top } , left=${ left } ` )
142
+ var left = ( ( width / 2 ) - ( w / 2 ) ) + dualScreenLeft ;
143
+ var top = ( ( height / 2 ) - ( h / 2 ) ) + dualScreenTop ;
144
+ var newWindow = window . open ( url , title , `scrollbars=yes, width=${ w } , height=${ h } , top=${ top } , left=${ left } ` ) ;
145
145
146
146
// Puts focus on the newWindow
147
147
if ( window . focus ) {
148
- newWindow . focus ( )
148
+ newWindow . focus ( ) ;
149
149
}
150
150
151
- return newWindow
151
+ return newWindow ;
152
152
}
153
153
154
- var polling = null
154
+ var polling = null ;
155
155
156
156
function PlexOAuth ( success , error , pre , clientID ) {
157
157
if ( typeof pre === "function" ) {
158
- pre ( )
158
+ pre ( ) ;
159
159
}
160
- closePlexOAuthWindow ( )
161
- plex_oauth_window = PopupCenter ( '' , 'Plex-OAuth' , 600 , 700 )
162
- $ ( plex_oauth_window . document . body ) . html ( plex_oauth_loader )
160
+ closePlexOAuthWindow ( ) ;
161
+ plex_oauth_window = PopupCenter ( '' , 'Plex-OAuth' , 600 , 700 ) ;
162
+ $ ( plex_oauth_window . document . body ) . html ( plex_oauth_loader ) ;
163
163
164
164
getPlexOAuthPin ( clientID ) . then ( function ( data ) {
165
- var x_plex_headers = getPlexHeaders ( clientID )
166
- const pin = data . pin
167
- const code = data . code
165
+ var x_plex_headers = getPlexHeaders ( clientID ) ;
166
+ const pin = data . pin ;
167
+ const code = data . code ;
168
168
169
169
var oauth_params = {
170
170
'clientID' : x_plex_headers [ 'X-Plex-Client-Identifier' ] ,
@@ -178,9 +178,9 @@ function PlexOAuth(success, error, pre, clientID) {
178
178
'context[device][screenResolution]' : x_plex_headers [ 'X-Plex-Device-Screen-Resolution' ] ,
179
179
'context[device][layout]' : 'desktop' ,
180
180
'code' : code
181
- }
181
+ } ;
182
182
183
- plex_oauth_window . location = `https://app.plex.tv/auth/#!?${ encodeData ( oauth_params ) } `
183
+ plex_oauth_window . location = `https://app.plex.tv/auth/#!?${ encodeData ( oauth_params ) } ` ;
184
184
polling = pin ;
185
185
186
186
( function poll ( ) {
@@ -190,32 +190,32 @@ function PlexOAuth(success, error, pre, clientID) {
190
190
headers : x_plex_headers ,
191
191
success : function ( data ) {
192
192
if ( data . authToken ) {
193
- closePlexOAuthWindow ( )
193
+ closePlexOAuthWindow ( ) ;
194
194
if ( typeof success === "function" ) {
195
- success ( data . authToken )
195
+ success ( data . authToken ) ;
196
196
}
197
197
}
198
198
} ,
199
199
error : function ( jqXHR , textStatus , errorThrown ) {
200
200
if ( textStatus !== "timeout" ) {
201
- closePlexOAuthWindow ( )
201
+ closePlexOAuthWindow ( ) ;
202
202
if ( typeof error === "function" ) {
203
- error ( )
203
+ error ( ) ;
204
204
}
205
205
}
206
206
} ,
207
207
complete : function ( ) {
208
208
if ( ! plex_oauth_window . closed && polling === pin ) {
209
- setTimeout ( function ( ) { poll ( ) } , 1000 )
209
+ setTimeout ( function ( ) { poll ( ) ; } , 1000 ) ;
210
210
}
211
211
} ,
212
212
timeout : 10000
213
- } )
214
- } ) ( )
213
+ } ) ;
214
+ } ) ( ) ;
215
215
} , function ( ) {
216
- closePlexOAuthWindow ( )
216
+ closePlexOAuthWindow ( ) ;
217
217
if ( typeof error === "function" ) {
218
- error ( )
218
+ error ( ) ;
219
219
}
220
- } )
220
+ } ) ;
221
221
}
0 commit comments