2014-03-10 05:18:05 +00:00
|
|
|
$(document).ready(function(){
|
2015-02-13 05:28:03 +00:00
|
|
|
var loading = '<img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif" height="16" width="16" />';
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testGrowl').click(function () {
|
|
|
|
var growl_host = $.trim($('#growl_host').val());
|
|
|
|
var growl_password = $.trim($('#growl_password').val());
|
|
|
|
if (!growl_host) {
|
|
|
|
$('#testGrowl-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#growl_host').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#growl_host').removeClass('warning');
|
2014-10-28 00:51:55 +00:00
|
|
|
$(this).prop('disabled', true);
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testGrowl-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testGrowl', {'host': growl_host, 'password': growl_password})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testGrowl-result').html(data);
|
|
|
|
$('#testGrowl').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testProwl').click(function () {
|
|
|
|
var prowl_api = $.trim($('#prowl_api').val());
|
|
|
|
var prowl_priority = $('#prowl_priority').val();
|
|
|
|
if (!prowl_api) {
|
|
|
|
$('#testProwl-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#prowl_api').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#prowl_api').removeClass('warning');
|
2014-10-28 00:51:55 +00:00
|
|
|
$(this).prop('disabled', true);
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testProwl-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testProwl', {'prowl_api': prowl_api, 'prowl_priority': prowl_priority})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testProwl-result').html(data);
|
|
|
|
$('#testProwl').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#testXBMC').click(function () {
|
|
|
|
var xbmc_host = $.trim($('#xbmc_host').val());
|
|
|
|
var xbmc_username = $.trim($('#xbmc_username').val());
|
|
|
|
var xbmc_password = $.trim($('#xbmc_password').val());
|
|
|
|
if (!xbmc_host) {
|
|
|
|
$('#testXBMC-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#xbmc_host').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#xbmc_host').removeClass('warning');
|
2014-10-28 00:51:55 +00:00
|
|
|
$(this).prop('disabled', true);
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testXBMC-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testXBMC', {'host': xbmc_host, 'username': xbmc_username, 'password': xbmc_password})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testXBMC-result').html(data);
|
|
|
|
$('#testXBMC').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-25 12:33:40 +00:00
|
|
|
$('#testKODI').click(function () {
|
|
|
|
var kodi_host = $.trim($('#kodi_host').val());
|
|
|
|
var kodi_username = $.trim($('#kodi_username').val());
|
|
|
|
var kodi_password = $.trim($('#kodi_password').val());
|
|
|
|
if (!kodi_host) {
|
|
|
|
$('#testKODI-result').html('Please fill out the necessary fields above.');
|
|
|
|
$('#kodi_host').addClass('warning');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#kodi_host').removeClass('warning');
|
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testKODI-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testKODI', {'host': kodi_host, 'username': kodi_username, 'password': kodi_password})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testKODI-result').html(data);
|
|
|
|
$('#testKODI').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-02-14 02:28:24 +00:00
|
|
|
$('#testPMC').click(function () {
|
2015-02-13 05:28:03 +00:00
|
|
|
var plex_host = $.trim($('#plex_host').val());
|
|
|
|
var plex_username = $.trim($('#plex_username').val());
|
|
|
|
var plex_password = $.trim($('#plex_password').val());
|
|
|
|
if (!plex_host) {
|
2015-02-14 02:28:24 +00:00
|
|
|
$('#testPMC-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#plex_host').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#plex_host').removeClass('warning');
|
2014-10-28 00:51:55 +00:00
|
|
|
$(this).prop('disabled', true);
|
2015-02-14 02:28:24 +00:00
|
|
|
$('#testPMC-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testPMC', {'host': plex_host, 'username': plex_username, 'password': plex_password})
|
2015-02-13 05:28:03 +00:00
|
|
|
.done(function (data) {
|
2015-02-14 02:28:24 +00:00
|
|
|
$('#testPMC-result').html(data);
|
|
|
|
$('#testPMC').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#testPMS').click(function () {
|
|
|
|
var plex_server_host = $.trim($('#plex_server_host').val());
|
|
|
|
var plex_username = $.trim($('#plex_username').val());
|
|
|
|
var plex_password = $.trim($('#plex_password').val());
|
|
|
|
if (!plex_server_host) {
|
|
|
|
$('#testPMS-result').html('Please fill out the necessary fields above.');
|
|
|
|
$('#plex_server_host').addClass('warning');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#plex_server_host').removeClass('warning');
|
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testPMS-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testPMS', {'host': plex_server_host, 'username': plex_username, 'password': plex_password})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testPMS-result').html(data);
|
|
|
|
$('#testPMS').prop('disabled', false);
|
2015-02-13 05:28:03 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#testBoxcar2').click(function () {
|
|
|
|
var boxcar2_accesstoken = $.trim($('#boxcar2_accesstoken').val());
|
|
|
|
var boxcar2_sound = $('#boxcar2_sound').val() || 'default';
|
|
|
|
if (!boxcar2_accesstoken) {
|
|
|
|
$('#testBoxcar2-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#boxcar2_accesstoken').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#boxcar2_accesstoken').removeClass('warning');
|
2014-10-28 00:51:55 +00:00
|
|
|
$(this).prop('disabled', true);
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testBoxcar2-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testBoxcar2', {'accesstoken': boxcar2_accesstoken, 'sound': boxcar2_sound})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testBoxcar2-result').html(data);
|
|
|
|
$('#testBoxcar2').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testPushover').click(function () {
|
|
|
|
var pushover_userkey = $('#pushover_userkey').val();
|
|
|
|
var pushover_apikey = $('#pushover_apikey').val();
|
|
|
|
if (!pushover_userkey || !pushover_apikey) {
|
|
|
|
$('#testPushover-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
if (!pushover_userkey) {
|
|
|
|
$('#pushover_userkey').addClass('warning');
|
|
|
|
} else {
|
|
|
|
$('#pushover_userkey').removeClass('warning');
|
|
|
|
}
|
|
|
|
if (!pushover_apikey) {
|
|
|
|
$('#pushover_apikey').addClass('warning');
|
|
|
|
} else {
|
|
|
|
$('#pushover_apikey').removeClass('warning');
|
|
|
|
}
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#pushover_userkey,#pushover_apikey').removeClass('warning');
|
|
|
|
$(this).prop('disabled', true);
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testPushover-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testPushover', {'userKey': pushover_userkey, 'apiKey': pushover_apikey})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testPushover-result').html(data);
|
|
|
|
$('#testPushover').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testLibnotify').click(function() {
|
|
|
|
$('#testLibnotify-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testLibnotify',
|
|
|
|
function (data) { $('#testLibnotify-result').html(data); });
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#twitterStep1').click(function() {
|
|
|
|
$('#testTwitter-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/twitterStep1', function (data) {window.open(data); })
|
|
|
|
.done(function () { $('#testTwitter-result').html('<b>Step1:</b> Confirm Authorization'); });
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#twitterStep2').click(function () {
|
|
|
|
var twitter_key = $.trim($('#twitter_key').val());
|
|
|
|
if (!twitter_key) {
|
|
|
|
$('#testTwitter-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#twitter_key').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#twitter_key').removeClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testTwitter-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/twitterStep2', {'key': twitter_key},
|
|
|
|
function (data) { $('#testTwitter-result').html(data); });
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testTwitter').click(function() {
|
|
|
|
$.get(sbRoot + '/home/testTwitter',
|
|
|
|
function (data) { $('#testTwitter-result').html(data); });
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#settingsNMJ').click(function() {
|
|
|
|
if (!$('#nmj_host').val()) {
|
|
|
|
alert('Please fill in the Popcorn IP address');
|
|
|
|
$('#nmj_host').focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#testNMJ-result').html(loading);
|
|
|
|
var nmj_host = $('#nmj_host').val();
|
2015-02-14 02:28:24 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$.get(sbRoot + '/home/settingsNMJ', {'host': nmj_host},
|
|
|
|
function (data) {
|
|
|
|
if (data === null) {
|
|
|
|
$('#nmj_database').removeAttr('readonly');
|
|
|
|
$('#nmj_mount').removeAttr('readonly');
|
|
|
|
}
|
|
|
|
var JSONData = $.parseJSON(data);
|
|
|
|
$('#testNMJ-result').html(JSONData.message);
|
|
|
|
$('#nmj_database').val(JSONData.database);
|
|
|
|
$('#nmj_mount').val(JSONData.mount);
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
if (JSONData.database) {
|
|
|
|
$('#nmj_database').attr('readonly', true);
|
|
|
|
} else {
|
|
|
|
$('#nmj_database').removeAttr('readonly');
|
|
|
|
}
|
|
|
|
if (JSONData.mount) {
|
|
|
|
$('#nmj_mount').attr('readonly', true);
|
|
|
|
} else {
|
|
|
|
$('#nmj_mount').removeAttr('readonly');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testNMJ').click(function () {
|
|
|
|
var nmj_host = $.trim($('#nmj_host').val());
|
|
|
|
var nmj_database = $('#nmj_database').val();
|
|
|
|
var nmj_mount = $('#nmj_mount').val();
|
|
|
|
if (!nmj_host) {
|
|
|
|
$('#testNMJ-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#nmj_host').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#nmj_host').removeClass('warning');
|
2014-10-28 00:51:55 +00:00
|
|
|
$(this).prop('disabled', true);
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testNMJ-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testNMJ', {'host': nmj_host, 'database': nmj_database, 'mount': nmj_mount})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testNMJ-result').html(data);
|
|
|
|
$('#testNMJ').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
$('#settingsNMJv2').click(function() {
|
2015-02-13 05:28:03 +00:00
|
|
|
if (!$('#nmjv2_host').val()) {
|
|
|
|
alert('Please fill in the Popcorn IP address');
|
|
|
|
$('#nmjv2_host').focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#testNMJv2-result').html(loading);
|
|
|
|
var nmjv2_host = $('#nmjv2_host').val();
|
2014-03-10 05:18:05 +00:00
|
|
|
var nmjv2_dbloc;
|
2014-10-28 00:51:55 +00:00
|
|
|
var radios = document.getElementsByName('nmjv2_dbloc');
|
2014-03-10 05:18:05 +00:00
|
|
|
for (var i = 0; i < radios.length; i++) {
|
|
|
|
if (radios[i].checked) {
|
|
|
|
nmjv2_dbloc=radios[i].value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
var nmjv2_dbinstance=$('#NMJv2db_instance').val();
|
2015-02-14 02:28:24 +00:00
|
|
|
$.get(sbRoot + '/home/settingsNMJv2', {'host': nmjv2_host,'dbloc': nmjv2_dbloc,'instance': nmjv2_dbinstance},
|
2015-02-13 05:28:03 +00:00
|
|
|
function (data){
|
|
|
|
if (data == null) {
|
|
|
|
$('#nmjv2_database').removeAttr('readonly');
|
|
|
|
}
|
|
|
|
var JSONData = $.parseJSON(data);
|
|
|
|
$('#testNMJv2-result').html(JSONData.message);
|
|
|
|
$('#nmjv2_database').val(JSONData.database);
|
2015-02-14 02:28:24 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
if (JSONData.database)
|
|
|
|
$('#nmjv2_database').attr('readonly', true);
|
|
|
|
else
|
|
|
|
$('#nmjv2_database').removeAttr('readonly');
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testNMJv2').click(function () {
|
|
|
|
var nmjv2_host = $.trim($('#nmjv2_host').val());
|
|
|
|
if (!nmjv2_host) {
|
|
|
|
$('#testNMJv2-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#nmjv2_host').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#nmjv2_host').removeClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testNMJv2-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testNMJv2', {'host': nmjv2_host})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testNMJv2-result').html(data);
|
|
|
|
$('#testNMJv2').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#testTrakt').click(function () {
|
|
|
|
var trakt_api = $.trim($('#trakt_api').val());
|
|
|
|
var trakt_username = $.trim($('#trakt_username').val());
|
|
|
|
var trakt_password = $.trim($('#trakt_password').val());
|
|
|
|
if (!trakt_api || !trakt_username || !trakt_password) {
|
|
|
|
$('#testTrakt-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
if (!trakt_api) {
|
|
|
|
$('#trakt_api').addClass('warning');
|
|
|
|
} else {
|
|
|
|
$('#trakt_api').removeClass('warning');
|
|
|
|
}
|
|
|
|
if (!trakt_username) {
|
|
|
|
$('#trakt_username').addClass('warning');
|
|
|
|
} else {
|
|
|
|
$('#trakt_username').removeClass('warning');
|
|
|
|
}
|
|
|
|
if (!trakt_password) {
|
|
|
|
$('#trakt_password').addClass('warning');
|
|
|
|
} else {
|
|
|
|
$('#trakt_password').removeClass('warning');
|
|
|
|
}
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#trakt_api,#trakt_username,#trakt_password').removeClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testTrakt-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testTrakt', {'api': trakt_api, 'username': trakt_username, 'password': trakt_password})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testTrakt-result').html(data);
|
|
|
|
$('#testTrakt').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testEmail').click(function () {
|
|
|
|
var status, host, port, tls, from, user, pwd, err, to;
|
|
|
|
status = $('#testEmail-result');
|
|
|
|
status.html(loading);
|
|
|
|
host = $('#email_host').val();
|
|
|
|
host = host.length > 0 ? host : null;
|
|
|
|
port = $('#email_port').val();
|
|
|
|
port = port.length > 0 ? port : null;
|
|
|
|
tls = $('#email_tls').attr('checked') !== undefined ? 1 : 0;
|
|
|
|
from = $('#email_from').val();
|
|
|
|
from = from.length > 0 ? from : 'root@localhost';
|
|
|
|
user = $('#email_user').val().trim();
|
|
|
|
pwd = $('#email_password').val();
|
|
|
|
err = '';
|
|
|
|
if (host === null) {
|
|
|
|
err += '<li style="color: red;">You must specify an SMTP hostname!</li>';
|
|
|
|
}
|
|
|
|
if (port === null) {
|
|
|
|
err += '<li style="color: red;">You must specify an SMTP port!</li>';
|
|
|
|
} else if (port.match(/^\d+$/) === null || parseInt(port, 10) > 65535) {
|
|
|
|
err += '<li style="color: red;">SMTP port must be between 0 and 65535!</li>';
|
|
|
|
}
|
|
|
|
if (err.length > 0) {
|
|
|
|
err = '<ol>' + err + '</ol>';
|
|
|
|
status.html(err);
|
|
|
|
} else {
|
|
|
|
to = prompt('Enter an email address to send the test to:', null);
|
|
|
|
if (to === null || to.length === 0 || to.match(/.*@.*/) === null) {
|
|
|
|
status.html('<p style="color: red;">You must provide a recipient email address!</p>');
|
|
|
|
} else {
|
|
|
|
$.get(sbRoot + '/home/testEmail', {host: host, port: port, smtp_from: from, use_tls: tls, user: user, pwd: pwd, to: to},
|
|
|
|
function (msg) { $('#testEmail-result').html(msg); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testNMA').click(function () {
|
|
|
|
var nma_api = $.trim($('#nma_api').val());
|
|
|
|
var nma_priority = $('#nma_priority').val();
|
|
|
|
if (!nma_api) {
|
|
|
|
$('#testNMA-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#nma_api').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#nma_api').removeClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testNMA-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testNMA', {'nma_api': nma_api, 'nma_priority': nma_priority})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testNMA-result').html(data);
|
|
|
|
$('#testNMA').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testPushalot').click(function () {
|
|
|
|
var pushalot_authorizationtoken = $.trim($('#pushalot_authorizationtoken').val());
|
|
|
|
if (!pushalot_authorizationtoken) {
|
|
|
|
$('#testPushalot-result').html('Please fill out the necessary fields above.');
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#pushalot_authorizationtoken').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#pushalot_authorizationtoken').removeClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testPushalot-result').html(loading);
|
|
|
|
$.get(sbRoot + '/home/testPushalot', {'authorizationToken': pushalot_authorizationtoken})
|
|
|
|
.done(function (data) {
|
|
|
|
$('#testPushalot-result').html(data);
|
|
|
|
$('#testPushalot').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-10-28 00:51:55 +00:00
|
|
|
$('#testPushbullet').click(function () {
|
2015-02-17 06:39:35 +00:00
|
|
|
var pushbullet_access_token = $.trim($('#pushbullet_access_token').val());
|
|
|
|
var pushbullet_device_iden = $('#pushbullet_device_iden').val();
|
|
|
|
if (!pushbullet_access_token) {
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testPushbullet-result').html('Please fill out the necessary fields above.');
|
2015-02-17 06:39:35 +00:00
|
|
|
$('#pushbullet_access_token').addClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-02-17 06:39:35 +00:00
|
|
|
$('#pushbullet_access_token').removeClass('warning');
|
2015-02-13 05:28:03 +00:00
|
|
|
$(this).prop('disabled', true);
|
|
|
|
$('#testPushbullet-result').html(loading);
|
2015-02-17 06:39:35 +00:00
|
|
|
$.get(sbRoot + '/home/testPushbullet', {'accessToken': pushbullet_access_token, 'device_iden': pushbullet_device_iden})
|
2015-02-13 05:28:03 +00:00
|
|
|
.done(function (data) {
|
|
|
|
$('#testPushbullet-result').html(data);
|
|
|
|
$('#testPushbullet').prop('disabled', false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-17 06:39:35 +00:00
|
|
|
function get_pushbullet_devices (msg) {
|
|
|
|
var pushbullet_access_token = $.trim($('#pushbullet_access_token').val());
|
|
|
|
if (!pushbullet_access_token) {
|
|
|
|
$('#testPushbullet-result').html('Please fill out the necessary fields above.');
|
|
|
|
$('#pushbullet_access_token').addClass('warning');
|
|
|
|
return;
|
2015-02-13 05:28:03 +00:00
|
|
|
}
|
2015-02-17 06:39:35 +00:00
|
|
|
$(this).prop("disabled", true);
|
|
|
|
if (msg) {
|
|
|
|
$('#testPushbullet-result').html(loading);
|
2015-02-13 05:28:03 +00:00
|
|
|
}
|
2015-02-17 06:39:35 +00:00
|
|
|
var current_pushbullet_device = $('#pushbullet_device_iden').val();
|
|
|
|
$.get(sbRoot + '/home/getPushbulletDevices', {'accessToken': pushbullet_access_token})
|
|
|
|
.done(function (data) {
|
|
|
|
var devices = jQuery.parseJSON(data || '{}').devices;
|
|
|
|
$('#pushbullet_device_list').html('');
|
|
|
|
// add default option to send to all devices
|
|
|
|
$('#pushbullet_device_list').append('<option value="" selected="selected">-- All Devices --</option>');
|
|
|
|
if (devices) {
|
|
|
|
for (var i = 0; i < devices.length; i++) {
|
|
|
|
// only list active device targets
|
|
|
|
if (devices[i].active == true) {
|
|
|
|
// if a device in the list matches our current iden, select it
|
|
|
|
if (current_pushbullet_device == devices[i].iden) {
|
|
|
|
$('#pushbullet_device_list').append('<option value="' + devices[i].iden + '" selected="selected">' + devices[i].manufacturer + ' ' + devices[i].nickname + '</option>');
|
|
|
|
} else {
|
|
|
|
$('#pushbullet_device_list').append('<option value="' + devices[i].iden + '">' + devices[i].manufacturer + ' ' + devices[i].nickname + '</option>');
|
|
|
|
}
|
2015-02-13 05:28:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-17 06:39:35 +00:00
|
|
|
$('#getPushbulletDevices').prop('disabled', false);
|
|
|
|
if (msg) {
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#testPushbullet-result').html(msg);
|
|
|
|
}
|
2015-02-17 06:39:35 +00:00
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-17 06:39:35 +00:00
|
|
|
$('#pushbullet_device_list').change(function () {
|
|
|
|
$('#pushbullet_device_iden').val($('#pushbullet_device_list').val());
|
|
|
|
$('#testPushbullet-result').html('Don\'t forget to save your new Pushbullet settings.');
|
2015-02-13 05:28:03 +00:00
|
|
|
});
|
2015-02-17 06:39:35 +00:00
|
|
|
}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-17 06:39:35 +00:00
|
|
|
$('#getPushbulletDevices').click(function () {
|
|
|
|
get_pushbullet_devices('Device list updated. Select specific device to use.');
|
2015-02-13 05:28:03 +00:00
|
|
|
});
|
2015-02-14 02:28:24 +00:00
|
|
|
|
2015-02-17 06:39:35 +00:00
|
|
|
if ($('#use_pushbullet').prop('checked')) {
|
|
|
|
get_pushbullet_devices();
|
|
|
|
}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
$('#email_show').change(function () {
|
|
|
|
var key = parseInt($('#email_show').val(), 10);
|
|
|
|
$('#email_show_list').val(key >= 0 ? notify_data[key.toString()].list : '');
|
2014-03-10 05:18:05 +00:00
|
|
|
});
|
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
// Update the internal data struct anytime settings are saved to the server
|
|
|
|
$('#email_show').bind('notify', function () { load_show_notify_lists(); });
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
function load_show_notify_lists() {
|
|
|
|
$.get(sbRoot + "/home/loadShowNotifyLists", function (data) {
|
|
|
|
var list, html, s;
|
|
|
|
list = $.parseJSON(data);
|
|
|
|
notify_data = list;
|
|
|
|
if (list._size === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
html = '<option value="-1">-- Select --</option>';
|
|
|
|
for (s in list) {
|
|
|
|
if (s.charAt(0) !== '_') {
|
|
|
|
html += '<option value="' + list[s].id + '">' + $('<div/>').text(list[s].name).html() + '</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#email_show').html(html);
|
|
|
|
$('#email_show_list').val('');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// Load the per show notify lists everytime this page is loaded
|
|
|
|
load_show_notify_lists();
|
2014-10-28 00:51:55 +00:00
|
|
|
|
2015-02-13 05:28:03 +00:00
|
|
|
// show instructions for plex when enabled
|
|
|
|
$('#use_plex').click(function() {
|
|
|
|
if ( $(this).is(':checked') ) {
|
|
|
|
$('.plexinfo').removeClass('hide');
|
|
|
|
} else {
|
|
|
|
$('.plexinfo').addClass('hide');
|
|
|
|
}
|
|
|
|
});
|
2015-02-14 02:28:24 +00:00
|
|
|
if ($('input[id="use_plex"]').is(':checked')) {$('.plexinfo').removeClass('hide')}
|
2014-03-10 05:18:05 +00:00
|
|
|
});
|