2021-03-08 19:45:06 +01:00
function time _days ( seconds _input ) {
var seconds = Number ( seconds _input ) ;
var days = seconds * 1.15741 E - 5 ;
var hours = String ( days ) . split ( "." ) ;
var hours _str = "0." + hours [ 1 ] ;
var hours _int = Number ( hours _str ) * 24.0 ;
var minutes = String ( hours _int ) . split ( "." ) ;
var minutes _str = "0." + minutes [ 1 ] ;
var minutes _int = Number ( minutes _str ) * 60.0 ;
var days _form = String ( days ) . split ( "." ) ;
var hours _form = String ( hours _int ) . split ( "." ) ;
var minutes _form = String ( minutes _int ) . split ( "." ) ;
var final = [ Number ( days _form [ 0 ] ) , Number ( hours _form [ 0 ] ) , Number ( minutes _form [ 0 ] ) ] ;
return final ;
}
function time _hours ( seconds _input ) {
var seconds = Number ( seconds _input ) ;
var hours _int = Number ( seconds ) * 0.0002777778 ;
var minutes = String ( hours _int ) . split ( "." ) ;
var minutes _str = "0." + minutes [ 1 ] ;
var minutes _int = Number ( minutes _str ) * 60.0 ;
var hours _form = String ( hours _int ) . split ( "." ) ;
var minutes _form = String ( minutes _int ) . split ( "." ) ;
var final = [ Number ( hours _form [ 0 ] ) , Number ( minutes _form [ 0 ] ) ] ;
return final ;
}
function makeRequest ( method , url , data ) {
return new Promise ( function ( resolve , reject ) {
var xhr = new XMLHttpRequest ( ) ;
xhr . open ( method , url ) ;
xhr . onload = function ( ) {
if ( this . status >= 200 && this . status < 300 ) {
resolve ( xhr . response ) ;
} else {
reject ( {
status : this . status ,
statusText : xhr . statusText
} ) ;
}
} ;
xhr . onerror = function ( ) {
reject ( {
status : this . status ,
statusText : xhr . statusText
} ) ;
} ;
if ( method == "POST" && data ) {
xhr . send ( data ) ;
} else {
xhr . send ( ) ;
}
} ) ;
}
function topFunction ( ) {
document . body . scrollTop = 0 ; // For Safari
document . documentElement . scrollTop = 0 ; // For Chrome, Firefox, IE and Opera
}
function login _menu ( ) {
topFunction ( ) ;
var html = '<form id="password_login_form" onsubmit="get_config();return false">'
2021-10-04 14:26:50 +02:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="username" title="The username chosen during first-time setup.">Username:</label>' ;
html += '<input type="text" class="form-control" id="username" value="" placeholder="" minlength=4 autocomplete="on" required />' ;
2021-10-04 14:26:50 +02:00
html += '</div>' ;
2021-03-08 19:45:06 +01:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="password" title="The password chosen during first-time setup.">Password:</label>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="password" class="form-control" id="password" value="" autocomplete="off" required />' ;
html += '</div>' ;
html += '<div class="form-group">' ;
html += '<input type="submit" class="form-control btn" id="password_button" value="Log in" required />' ;
html += '</div>' ;
html += '</form>' ;
document . getElementById ( "setup" ) . innerHTML = html ;
}
function set _password ( back ) {
topFunction ( ) ;
var html = '<form id="password_form" onsubmit="set_tautulli(false);return false">'
2021-10-04 14:26:50 +02:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="username" title="The username needed to log in as administrator and change the config-file remotely.">Set an admin username:</label>' ;
html += '<input type="text" class="form-control" id="username" value="' + username + '" placeholder="" minlength=4 autocomplete="on" required />' ;
2021-10-04 14:26:50 +02:00
html += '</div>' ;
2021-03-08 19:45:06 +01:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="password" title="The password needed to change the config-file remotely.">Set an admin password:</label>' ;
html += '<input type="password" class="form-control" id="password" value="' + password + '" placeholder="" autocomplete="off" required />' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="password_2" title="The password needed to change the config-file remotely.">Repeat the password:</label>' ;
html += '<input type="password" class="form-control" id="password_2" value="' + password + '" placeholder="" autocomplete="off" required />' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '<div class="form-group">' ;
html += '<input type="submit" class="form-control btn" id="password_button" value="Save" required />' ;
html += '</div>' ;
html += '</form>' ;
document . getElementById ( "setup" ) . innerHTML = html ;
}
function set _tautulli ( back ) {
2021-03-13 23:55:08 +01:00
2021-03-08 19:45:06 +01:00
topFunction ( ) ;
if ( ! back ) {
2021-10-04 14:26:50 +02:00
if ( document . getElementById ( 'password' ) . value != document . getElementById ( 'password_2' ) . value ) {
alert ( "The passwords must match." ) ;
document . getElementById ( 'password' ) . value = "" ;
document . getElementById ( 'password_2' ) . value = "" ;
document . getElementById ( 'password' ) . focus ( ) ;
return false ;
2021-03-08 19:45:06 +01:00
} else {
2021-10-04 14:26:50 +02:00
password = document . getElementById ( 'password' ) . value ;
username = document . getElementById ( 'username' ) . value ;
2021-03-08 19:45:06 +01:00
}
}
var html = '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<button class="form-control btn" onclick="set_password(true)"><img src="../assets/config.svg" class="btn_logo"><p2>Change admin password</p2></button>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
2021-12-12 17:31:15 +01:00
html += '<hr>' ;
2021-03-08 19:45:06 +01:00
html += '<form id="tautulli_form" onsubmit="set_tautulli_details(false);return false">'
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="tautulli_apikey" title="The API key is needed for Plex-Wrapped to interact with Tautulli. Commonly found at Tautulli->Settings->Web Interface->API Key.">Tautulli API key:</label>' ;
html += '<input type="text" class="form-control" id="tautulli_apikey" value="' + tautulli _apikey + '" autocomplete="off" required placeholder="" /><br>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="tautulli_ip" title="The IP address or domain that connects to Tautulli. No subfolders, as this is another setting, but subdomains can be defined.">IP or domain for Tautulli connection:</label>' ;
html += '<input type="text" class="form-control" id="tautulli_ip" value="' + tautulli _ip + '" required placeholder="" /><br>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="tautulli_port" title="The port Tautulli uses for connections. Typically empty if a domain is used.">Port for Tautulli: (Optional)</label>' ;
html += '<input type="text" class="form-control" id="tautulli_port" value="' + tautulli _port + '" placeholder="" /><br>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="tautulli_length" title="The max amount of entries Tautulli responds with during API calls. Typically doesn\'t need to be changed, but if you have more than 5000 entries in a day, they won\'t be loaded.">Tautlli item length:</label>' ;
html += '<input type="number" min="0" class="form-control" id="tautulli_length" value="' + tautulli _length + '" autocomplete="off" placeholder="" required /><br>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="tautulli_root" title="Subfolder for Tautulli, no slashes needed at the beginning or end. It is the folder accessed after the main IP/domain. For example: \'tautulli.com/subfolder\' would mean you enter \'subfolder\' here.">Root for Tautulli: (Optional)</label>' ;
html += '<input type="text" class="form-control" id="tautulli_root" value="' + tautulli _root + '" autocomplete="off" placeholder=""/><br>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
2021-10-04 22:21:43 +02:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="tautulli_libraries" title="Comma seprated list of ID\'s to use for statistics. If none are given, it will search all.">Libraries ID\'s to use: (Optional)</label>' ;
html += '<input type="text" class="form-control" id="tautulli_libraries" value="' + tautulli _libraries + '" autocomplete="off" placeholder=""/><br>' ;
2021-10-04 22:21:43 +02:00
html += '</div>' ;
2021-03-08 19:45:06 +01:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="timezone" title="The timezone the data is located in, like \'Europe/Oslo\'. Type it exactly as it is specified in the PHP documentation.">Timezone: <a href="https://www.php.net/manual/en/timezones.php" target="_blank">(List)</a></label>' ;
html += '<input type="text" class="form-control" id="timezone" value="' + timezone + '" autocomplete="off" placeholder="" required /><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
html += '<label for="ssl" title="Enable if your connection uses HTTPS.">Use HTTPS:</label>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="checkbox" class="form-control" id="ssl" ' ;
if ( ssl ) {
html += 'checked="' + ssl + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
2021-03-12 23:45:44 +01:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<button style="background-color: lightgrey;" type="button" class="form-control btn" id="test_connection" onclick="test_tautulli_connection()"><img src="../assets/synchronize.svg" class="btn_logo"><p2 id="test_tautulli_text">Test Tautulli connection</p2></button>' ;
2021-03-12 23:45:44 +01:00
html += '</div>' ;
2021-03-08 19:45:06 +01:00
html += '<div class="form-group">' ;
html += '<input type="submit" class="form-control btn" id="form_button" value="Save" required />' ;
html += '</div>' ;
html += '</form>' ;
document . getElementById ( "setup" ) . innerHTML = html ;
}
function set _tautulli _details ( back ) {
topFunction ( ) ;
if ( ! back ) {
tautulli _apikey = document . getElementById ( 'tautulli_apikey' ) . value ;
tautulli _ip = document . getElementById ( 'tautulli_ip' ) . value ;
tautulli _port = document . getElementById ( 'tautulli_port' ) . value ;
tautulli _length = document . getElementById ( 'tautulli_length' ) . value ;
tautulli _root = document . getElementById ( 'tautulli_root' ) . value ;
2021-12-12 17:31:15 +01:00
tautulli _libraries = document . getElementById ( 'tautulli_libraries' ) . value ;
2021-10-04 22:21:43 +02:00
timezone = document . getElementById ( 'timezone' ) . value ;
2021-03-08 19:45:06 +01:00
ssl = document . getElementById ( 'ssl' ) . checked ;
}
var html = '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<button class="form-control btn" onclick="set_tautulli(true, false)"><img src="../assets/config.svg" class="btn_logo"><p2>Tautulli settings</p2></button>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
2021-12-12 17:31:15 +01:00
html += '<hr>' ;
2021-03-08 19:45:06 +01:00
html += '<form id="tautulli_details_form" onsubmit="set_tautulli_last(false);return false">'
2021-12-12 17:31:15 +01:00
html += '<div class="form-group">' ;
html += '<label for="plex_wrapped_root" title="Subfolder for Plex-Wrapped, no slashes needed at the beginning or end. It is the folder accessed after the main IP/domain. For example: \'mycooldomain.com/wrapped\' would mean you enter \'wrapped\' here.">Root for Plex-Wrapped: (Optional)</label>' ;
html += '<input type="text" class="form-control" id="plex_wrapped_root" value="' + plex _wrapped _root + '" autocomplete="off" placeholder=""/><br>' ;
html += '</div>' ;
2021-03-08 19:45:06 +01:00
var temp _date = wrapped _start . toLocaleDateString ( "en-GB" , { // you can skip the first argument
year : "numeric" ,
month : "2-digit" ,
day : "2-digit" ,
hour : "2-digit" ,
minute : "2-digit" ,
second : "2-digit" ,
timezone : "Europe/London" ,
} ) ;
var temp _date = temp _date . split ( ',' ) ;
var temp _date _first = temp _date [ 0 ] . split ( '/' ) ;
var temp _date _second = temp _date [ 1 ] . split ( ':' ) ;
html += '<div class="form-group">' ;
2021-10-07 18:44:27 +02:00
html += '<div class="warning">!<br>Load time for long wrapped periods are extensive. Consider enabling caching and performing pre-caching once.</div>' ;
2021-12-12 17:31:15 +01:00
html += '<label for="wrapped_start" title="The start of the period you want wrapped.">Start of wrapped period:</label>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="datetime-local" class="form-control" id="wrapped_start" value="' + temp _date _first [ 2 ] . trim ( ) + '-' + temp _date _first [ 1 ] . trim ( ) + '-' + temp _date _first [ 0 ] . trim ( ) + 'T' + temp _date _second [ 0 ] . trim ( ) + ':' + temp _date _second [ 1 ] . trim ( ) + '" required /><br>' ;
html += '</div>' ;
var temp _date = wrapped _end . toLocaleDateString ( "en-GB" , { // you can skip the first argument
year : "numeric" ,
month : "2-digit" ,
day : "2-digit" ,
hour : "2-digit" ,
minute : "2-digit" ,
second : "2-digit" ,
timezone : "Europe/London" ,
} ) ;
var temp _date = temp _date . split ( ',' ) ;
var temp _date _first = temp _date [ 0 ] . split ( '/' ) ;
var temp _date _second = temp _date [ 1 ] . split ( ':' ) ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="wrapped_end" title="The end of your wrapped period. All data until this point is viable.">End of wrapped period:<br>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="datetime-local" class="form-control" id="wrapped_end" value="' + temp _date _first [ 2 ] . trim ( ) + '-' + temp _date _first [ 1 ] . trim ( ) + '-' + temp _date _first [ 0 ] . trim ( ) + 'T' + temp _date _second [ 0 ] . trim ( ) + ':' + temp _date _second [ 1 ] . trim ( ) + '" required /></label>' ;
html += '</div>' ;
2021-10-12 14:38:54 +02:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="stats_intro" title="Introduction text that is shown when the statistics are done loading. Could be used to inform about chosen timeframe. HTML allowed.">Introduction for statistics page:<br>' ;
2021-10-17 13:47:58 +02:00
html += '<textarea cols="40" rows="5" class="form-control" style="overflow-x: hidden;resize:vertical;min-height: 5em;" id="stats_intro" name="stats_intro" value="" autocomplete="off" placeholder="New year, new page of statistics..."></textarea></label>' ;
2021-10-12 14:38:54 +02:00
html += '</div>' ;
2021-12-12 17:31:15 +01:00
html += '<div class="form-group">' ;
html += '<label for="create_share_links" title="Grants users the ability to create a URL for sharing. Valid for 7 days.">Allow shareable URL creation:<br>' ;
html += '<input type="checkbox" class="form-control" id="create_share_links" ' ;
if ( create _share _links ) {
html += 'checked="' + create _share _links + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
2021-10-04 14:57:28 +02:00
html += '<hr>' ;
2021-03-08 19:45:06 +01:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_user_movie_stats" title="Includes movie statistics in your wrapped period.">Get users movie statistics:<br>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="checkbox" class="form-control" id="get_user_movie_stats" ' ;
if ( get _user _movie _stats ) {
html += 'checked="' + get _user _movie _stats + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_user_show_stats" title="Includes show statistics in your wrapped period.">Get users show statistics:<br>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="checkbox" class="form-control" id="get_user_show_stats" ' ;
if ( get _user _show _stats ) {
html += 'checked="' + get _user _show _stats + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_user_show_buddy" title="Includes the users top show-buddy in your wrapped period. Requires show stats.">Get users show-buddy:<br>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="checkbox" class="form-control" id="get_user_show_buddy" ' ;
if ( get _user _show _buddy ) {
html += 'checked="' + get _user _show _buddy + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_user_music_stats" title="Includes music statistics in your wrapped period.">Get users music statistics:<br>' ;
2021-10-02 01:21:18 +02:00
html += '<input type="checkbox" class="form-control" id="get_user_music_stats" ' ;
if ( get _user _music _stats ) {
html += 'checked="' + get _user _music _stats + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
2021-10-04 14:57:28 +02:00
html += '<hr>' ;
2021-10-02 01:21:18 +02:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_year_stats_movies" title="Includes server-wide movie statistics in your wrapped period.">Get server-wide movie statistics:<br>' ;
2021-10-02 01:21:18 +02:00
html += '<input type="checkbox" class="form-control" id="get_year_stats_movies" ' ;
if ( get _year _stats _movies ) {
html += 'checked="' + get _year _stats _movies + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_year_stats_shows" title="Includes server-wide show statistics in your wrapped period.">Get server-wide show statistics:<br>' ;
2021-10-02 01:21:18 +02:00
html += '<input type="checkbox" class="form-control" id="get_year_stats_shows" ' ;
if ( get _year _stats _shows ) {
html += 'checked="' + get _year _stats _shows + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_year_stats_music" title="Includes server-wide music statistics in your wrapped period.">Get server-wide music statistics:<br>' ;
2021-10-02 01:21:18 +02:00
html += '<input type="checkbox" class="form-control" id="get_year_stats_music" ' ;
if ( get _year _stats _music ) {
html += 'checked="' + get _year _stats _music + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="get_year_stats_leaderboard" title="Creates a user leaderboard based on the server-wide statistics in your wrapped period.">Get server-wide leaderboard rankings:<br>' ;
2021-10-02 01:21:18 +02:00
html += '<input type="checkbox" class="form-control" id="get_year_stats_leaderboard" ' ;
if ( get _year _stats _leaderboard ) {
html += 'checked="' + get _year _stats _leaderboard + '" ' ;
2021-03-08 19:45:06 +01:00
}
html += '/><br>' ;
2021-09-21 15:01:14 +02:00
html += '</div>' ;
2021-10-04 14:57:28 +02:00
html += '<hr>' ;
2021-09-21 15:01:14 +02:00
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="use_logs" title="Logs every API request into a log-file in the config folder. ID for Wrapped request included.">Log API calls:<br>' ;
2021-09-21 15:01:14 +02:00
html += '<input type="checkbox" class="form-control" id="use_logs" ' ;
if ( use _logs ) {
html += 'checked="' + use _logs + '" ' ;
}
html += '/><br>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
2021-10-07 18:44:27 +02:00
2021-03-08 19:45:06 +01:00
html += '<div class="form-group">' ;
2021-10-13 17:37:19 +02:00
html += '<div class="warning">!<br>If your wrapped period is long and no results are cached, the wait time can be extensive. Using the cache feature and <a href="../caching" target="_blank">pre-caching</a> once is recommended.</div>' ;
2021-12-12 17:31:15 +01:00
html += '<label for="use_cache" title="Caches your results in cache.json for later use.">Cache results for later use:<br>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="checkbox" class="form-control" id="use_cache" ' ;
if ( use _cache ) {
html += 'checked="' + use _cache + '" ' ;
}
html += '/><br>' ;
html += '</div>' ;
2021-09-21 12:40:54 +02:00
html += '<div class="form-group" title="Clear the cache now to include the newest settings.">' ;
2021-12-12 17:31:15 +01:00
html += '<label for="clear_cache">Clear cache now:<br>' ;
2021-03-08 19:45:06 +01:00
html += '<input type="checkbox" class="form-control" id="clear_cache" checked /></label>' ;
html += '</div>' ;
html += '<div class="form-group">' ;
2021-12-12 17:31:15 +01:00
html += '<button type="submit" class="form-control btn" id="form_button"><img src="../assets/done.svg" class="btn_logo"><p2>Finish</p2></button>' ;
2021-03-08 19:45:06 +01:00
html += '</div>' ;
html += '</form>' ;
document . getElementById ( "setup" ) . innerHTML = html ;
2021-10-12 14:38:54 +02:00
document . getElementById ( "stats_intro" ) . value = stats _intro ;
2021-03-08 19:45:06 +01:00
}
2021-03-12 23:45:44 +01:00
function test _tautulli _connection ( ) {
2021-12-12 17:31:15 +01:00
document . getElementById ( "test_connection" ) . disabled = true ;
document . getElementById ( "test_connection" ) . style . opacity = '0.5' ;
2021-03-12 23:45:44 +01:00
var button = document . getElementById ( 'test_connection' ) ;
button . style . backgroundColor = 'lightgrey' ;
ssl _temp = document . getElementById ( 'ssl' ) . checked ;
ip _temp = document . getElementById ( 'tautulli_ip' ) . value ;
root _temp = document . getElementById ( 'tautulli_root' ) . value ;
port _temp = document . getElementById ( 'tautulli_port' ) . value ;
api _temp = document . getElementById ( 'tautulli_apikey' ) . value ;
if ( ssl _temp ) {
var prefix = 'https://' ;
} else {
var prefix = 'http://' ;
}
if ( root _temp == "" ) {
var suffix = '' ;
} else {
var suffix = '/' + root _temp + '/' ;
}
if ( port _temp == "" ) {
url = prefix + ip _temp + suffix + '/api/v2' ;
} else {
url = prefix + ip _temp + ':' + port _temp + suffix + '/api/v2' ;
}
config _form = { "url" : url , "ssl" : ssl _temp , "apikey" : api _temp } ;
var config _data = JSON . stringify ( config _form ) ;
var xhttp = new XMLHttpRequest ( ) ;
xhttp . onreadystatechange = function ( ) {
if ( this . readyState == 4 && this . status == 200 ) {
var result = JSON . parse ( this . responseText ) ;
if ( ! result . error ) {
button . style . backgroundColor = '#79A04F' ;
2021-12-12 17:31:15 +01:00
document . getElementById ( "test_connection" ) . disabled = false ;
document . getElementById ( "test_connection" ) . style . opacity = '1' ;
2021-03-12 23:45:44 +01:00
} else {
button . style . backgroundColor = '#F1909C' ;
2021-12-12 17:31:15 +01:00
document . getElementById ( "test_connection" ) . disabled = false ;
document . getElementById ( "test_connection" ) . style . opacity = '1' ;
alert ( result . message ) ;
2021-03-12 23:45:44 +01:00
}
}
} ;
xhttp . withCredentials = true ;
2021-10-11 14:25:19 +02:00
xhttp . open ( "post" , root + 'api/get_connection.php' ) ;
2021-03-12 23:45:44 +01:00
xhttp . send ( config _data ) ;
}
2021-03-08 19:45:06 +01:00
function set _tautulli _last ( back ) {
if ( ! back ) {
2021-12-12 17:31:15 +01:00
plex _wrapped _root = document . getElementById ( 'plex_wrapped_root' ) . value ;
2021-03-08 19:45:06 +01:00
wrapped _start = new Date ( document . getElementById ( 'wrapped_start' ) . value ) ;
wrapped _end = new Date ( document . getElementById ( 'wrapped_end' ) . value ) ;
if ( wrapped _end < wrapped _start ) {
alert ( "The wrapped end period must be later than the wrapped start period." ) ;
return ;
}
2021-10-12 14:38:54 +02:00
stats _intro = document . getElementById ( 'stats_intro' ) . value ;
2021-12-12 17:31:15 +01:00
create _share _links = document . getElementById ( 'create_share_links' ) . checked ;
2021-03-08 19:45:06 +01:00
get _user _movie _stats = document . getElementById ( 'get_user_movie_stats' ) . checked ;
get _user _show _stats = document . getElementById ( 'get_user_show_stats' ) . checked ;
get _user _show _buddy = document . getElementById ( 'get_user_show_buddy' ) . checked ;
2021-10-02 01:21:18 +02:00
get _user _music _stats = document . getElementById ( 'get_user_music_stats' ) . checked ;
get _year _stats _movies = document . getElementById ( 'get_year_stats_movies' ) . checked ;
get _year _stats _shows = document . getElementById ( 'get_year_stats_shows' ) . checked ;
get _year _stats _music = document . getElementById ( 'get_year_stats_music' ) . checked ;
get _year _stats _leaderboard = document . getElementById ( 'get_year_stats_leaderboard' ) . checked ;
2021-03-08 19:45:06 +01:00
use _cache = document . getElementById ( 'use_cache' ) . checked ;
2021-09-21 15:01:14 +02:00
use _logs = document . getElementById ( 'use_logs' ) . checked ;
2021-03-08 19:45:06 +01:00
set _config ( ) ;
}
2021-10-17 13:47:58 +02:00
}
2021-12-12 17:31:15 +01:00
function get _plex _wrapped _version ( ) {
var xhttp = new XMLHttpRequest ( ) ;
xhttp . onreadystatechange = function ( ) {
if ( this . readyState == 4 && this . status == 200 ) {
try {
var result = JSON . parse ( this . responseText ) ;
} catch ( error ) {
console . log ( 'Failed to parse Plex-Wrapped version. Response: ' + this . responseText )
}
if ( ! result . error ) {
document . getElementById ( 'github_link' ) . innerHTML = 'GitHub (' + result . plex _wrapped _version + ')' ;
}
}
} ;
xhttp . withCredentials = true ;
xhttp . open ( "post" , "../api/get_plex_wrapped_version.php" ) ;
xhttp . send ( ) ;
return ;
}