|
|
@ -75,6 +75,16 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// show instructions for plex when enabled
|
|
|
|
$('#use_plex').click(function() { |
|
|
|
if ( $(this).is(':checked') ) { |
|
|
|
$('.plexinfo').removeClass('hide'); |
|
|
|
} else { |
|
|
|
$('.plexinfo').addClass('hide'); |
|
|
|
} |
|
|
|
}); |
|
|
|
if ($('input[id="use_plex"]').is(':checked')) {$('.plexinfo').removeClass('hide')} |
|
|
|
|
|
|
|
$('#testPMC').click(function () { |
|
|
|
var plex_host = $.trim($('#plex_host').val()); |
|
|
|
var plex_username = $.trim($('#plex_username').val()); |
|
|
@ -225,30 +235,6 @@ |
|
|
|
function (data) { $('#testLibnotify-result').html(data); }); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#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'); }); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#twitterStep2').click(function () { |
|
|
|
var twitter_key = $.trim($('#twitter_key').val()); |
|
|
|
if (!twitter_key) { |
|
|
|
$('#testTwitter-result').html('Please fill out the necessary fields above.'); |
|
|
|
$('#twitter_key').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#twitter_key').removeClass('warning'); |
|
|
|
$('#testTwitter-result').html(loading); |
|
|
|
$.get(sbRoot + '/home/twitterStep2', {'key': twitter_key}, |
|
|
|
function (data) { $('#testTwitter-result').html(data); }); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#testTwitter').click(function() { |
|
|
|
$.get(sbRoot + '/home/testTwitter', |
|
|
|
function (data) { $('#testTwitter-result').html(data); }); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#settingsNMJ').click(function() { |
|
|
|
if (!$('#nmj_host').val()) { |
|
|
|
alert('Please fill in the Popcorn IP address'); |
|
|
@ -352,6 +338,139 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#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.'); |
|
|
|
$('#nma_api').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#nma_api').removeClass('warning'); |
|
|
|
$(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); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#testPushalot').click(function () { |
|
|
|
var pushalot_authorizationtoken = $.trim($('#pushalot_authorizationtoken').val()); |
|
|
|
if (!pushalot_authorizationtoken) { |
|
|
|
$('#testPushalot-result').html('Please fill out the necessary fields above.'); |
|
|
|
$('#pushalot_authorizationtoken').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#pushalot_authorizationtoken').removeClass('warning'); |
|
|
|
$(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); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#testPushbullet').click(function () { |
|
|
|
var pushbullet_access_token = $.trim($('#pushbullet_access_token').val()); |
|
|
|
var pushbullet_device_iden = $('#pushbullet_device_iden').val(); |
|
|
|
if (!pushbullet_access_token) { |
|
|
|
$('#testPushbullet-result').html('Please fill out the necessary fields above.'); |
|
|
|
$('#pushbullet_access_token').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#pushbullet_access_token').removeClass('warning'); |
|
|
|
$(this).prop('disabled', true); |
|
|
|
$('#testPushbullet-result').html(loading); |
|
|
|
$.get(sbRoot + '/home/testPushbullet', {'accessToken': pushbullet_access_token, 'device_iden': pushbullet_device_iden}) |
|
|
|
.done(function (data) { |
|
|
|
$('#testPushbullet-result').html(data); |
|
|
|
$('#testPushbullet').prop('disabled', false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
$(this).prop("disabled", true); |
|
|
|
if (msg) { |
|
|
|
$('#testPushbullet-result').html(loading); |
|
|
|
} |
|
|
|
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; |
|
|
|
var error = jQuery.parseJSON(data || '{}').error; |
|
|
|
$('#pushbullet_device_list').html(''); |
|
|
|
if (devices) { |
|
|
|
// add default option to send to all devices
|
|
|
|
$('#pushbullet_device_list').append('<option value="" selected="selected">-- All Devices --</option>'); |
|
|
|
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>'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$('#getPushbulletDevices').prop('disabled', false); |
|
|
|
if (msg) { |
|
|
|
if (error.message) { |
|
|
|
$('#testPushbullet-result').html(error.message); |
|
|
|
} else { |
|
|
|
$('#testPushbullet-result').html(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$('#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.'); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
$('#getPushbulletDevices').click(function () { |
|
|
|
get_pushbullet_devices('Device list updated. Select specific device to use.'); |
|
|
|
}); |
|
|
|
|
|
|
|
if ($('#use_pushbullet').prop('checked')) { |
|
|
|
get_pushbullet_devices(); |
|
|
|
} |
|
|
|
|
|
|
|
$('#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'); }); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#twitterStep2').click(function () { |
|
|
|
var twitter_key = $.trim($('#twitter_key').val()); |
|
|
|
if (!twitter_key) { |
|
|
|
$('#testTwitter-result').html('Please fill out the necessary fields above.'); |
|
|
|
$('#twitter_key').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#twitter_key').removeClass('warning'); |
|
|
|
$('#testTwitter-result').html(loading); |
|
|
|
$.get(sbRoot + '/home/twitterStep2', {'key': twitter_key}, |
|
|
|
function (data) { $('#testTwitter-result').html(data); }); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#testTwitter').click(function() { |
|
|
|
$.get(sbRoot + '/home/testTwitter', |
|
|
|
function (data) { $('#testTwitter-result').html(data); }); |
|
|
|
}); |
|
|
|
|
|
|
|
var elTraktAuth = $('#trakt-authenticate'), elTraktAuthResult = $('#trakt-authentication-result'); |
|
|
|
|
|
|
|
function trakt_send_auth(){ |
|
|
@ -510,187 +629,101 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#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); }); |
|
|
|
function load_show_notify_lists() { |
|
|
|
$.get(sbRoot + '/home/loadShowNotifyLists', function (data) { |
|
|
|
var list, html, item, len= 0, el; |
|
|
|
list = $.parseJSON(data); |
|
|
|
html = []; |
|
|
|
for (item in list) { |
|
|
|
for (var k in list[item]) { |
|
|
|
if ($.isArray(list[item][k])) { |
|
|
|
len += list[item][k].length; |
|
|
|
html.push('\t<optgroup label="' + k + '">'); |
|
|
|
for (var show in list[item][k]) { |
|
|
|
html.push('\t\t<option value="' + list[item][k][show].id + '"' |
|
|
|
+ ' data="' + list[item][k][show].list + '"' |
|
|
|
+ '>' + list[item][k][show].name + '</option>'); |
|
|
|
} |
|
|
|
html.push('\t</optgroup>'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$('#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.'); |
|
|
|
$('#nma_api').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#nma_api').removeClass('warning'); |
|
|
|
$(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); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#testPushalot').click(function () { |
|
|
|
var pushalot_authorizationtoken = $.trim($('#pushalot_authorizationtoken').val()); |
|
|
|
if (!pushalot_authorizationtoken) { |
|
|
|
$('#testPushalot-result').html('Please fill out the necessary fields above.'); |
|
|
|
$('#pushalot_authorizationtoken').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#pushalot_authorizationtoken').removeClass('warning'); |
|
|
|
$(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); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#testPushbullet').click(function () { |
|
|
|
var pushbullet_access_token = $.trim($('#pushbullet_access_token').val()); |
|
|
|
var pushbullet_device_iden = $('#pushbullet_device_iden').val(); |
|
|
|
if (!pushbullet_access_token) { |
|
|
|
$('#testPushbullet-result').html('Please fill out the necessary fields above.'); |
|
|
|
$('#pushbullet_access_token').addClass('warning'); |
|
|
|
return; |
|
|
|
} |
|
|
|
$('#pushbullet_access_token').removeClass('warning'); |
|
|
|
$(this).prop('disabled', true); |
|
|
|
$('#testPushbullet-result').html(loading); |
|
|
|
$.get(sbRoot + '/home/testPushbullet', {'accessToken': pushbullet_access_token, 'device_iden': pushbullet_device_iden}) |
|
|
|
.done(function (data) { |
|
|
|
$('#testPushbullet-result').html(data); |
|
|
|
$('#testPushbullet').prop('disabled', false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (len) { |
|
|
|
el = $('#email_show'); |
|
|
|
el.html('<option value="-1">-- Select show --</option>' |
|
|
|
+ html.join('\n')); |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
$(this).prop("disabled", true); |
|
|
|
if (msg) { |
|
|
|
$('#testPushbullet-result').html(loading); |
|
|
|
} |
|
|
|
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; |
|
|
|
var error = jQuery.parseJSON(data || '{}').error; |
|
|
|
$('#pushbullet_device_list').html(''); |
|
|
|
if (devices) { |
|
|
|
// add default option to send to all devices
|
|
|
|
$('#pushbullet_device_list').append('<option value="" selected="selected">-- All Devices --</option>'); |
|
|
|
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>'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$('#getPushbulletDevices').prop('disabled', false); |
|
|
|
if (msg) { |
|
|
|
if (error.message) { |
|
|
|
$('#testPushbullet-result').html(error.message); |
|
|
|
} else { |
|
|
|
$('#testPushbullet-result').html(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
$('#show_email_list').val(''); |
|
|
|
|
|
|
|
$('#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.'); |
|
|
|
el.change(function () { |
|
|
|
$('#show_email_list').val( |
|
|
|
$(this).find('option[value="' + $(this).val() + '"]').attr('data')) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
$('#getPushbulletDevices').click(function () { |
|
|
|
get_pushbullet_devices('Device list updated. Select specific device to use.'); |
|
|
|
}); |
|
|
|
|
|
|
|
if ($('#use_pushbullet').prop('checked')) { |
|
|
|
get_pushbullet_devices(); |
|
|
|
} |
|
|
|
|
|
|
|
$('#email_show').change(function () { |
|
|
|
var key = parseInt($('#email_show').val(), 10); |
|
|
|
$('#email_show_list').val(key >= 0 ? notify_data[key.toString()].list : ''); |
|
|
|
}); |
|
|
|
// Load the per show notify lists everytime this page is loaded
|
|
|
|
load_show_notify_lists(); |
|
|
|
|
|
|
|
// Update the internal data struct anytime settings are saved to the server
|
|
|
|
$('#email_show').bind('notify', function () { load_show_notify_lists(); }); |
|
|
|
|
|
|
|
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(''); |
|
|
|
}); |
|
|
|
$('#save_show_email').click( |
|
|
|
function(){ |
|
|
|
var show = $('#email_show').val(); |
|
|
|
if ('-1' == show) { |
|
|
|
$('#testEmail-result').html('No show selected for save.'); |
|
|
|
return |
|
|
|
} |
|
|
|
// Load the per show notify lists everytime this page is loaded
|
|
|
|
$.post(sbRoot + '/home/save_show_email', { |
|
|
|
show: show, |
|
|
|
emails: $('#show_email_list').val()}, |
|
|
|
function (data){ |
|
|
|
// Reload the per show notify lists to reflect changes
|
|
|
|
load_show_notify_lists(); |
|
|
|
var result = $.parseJSON(data), |
|
|
|
show = $('#email_show').find('option[value="' + result.id + '"]').text(); |
|
|
|
$('#testEmail-result').html(result.success |
|
|
|
? 'Success. Notify list updated for show "' + show + '". Click below to test.' |
|
|
|
: 'Error saving notify list for show %s' % show); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// show instructions for plex when enabled
|
|
|
|
$('#use_plex').click(function() { |
|
|
|
if ( $(this).is(':checked') ) { |
|
|
|
$('.plexinfo').removeClass('hide'); |
|
|
|
$('#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 (null == host) { |
|
|
|
err.push('SMTP server hostname'); |
|
|
|
} |
|
|
|
if (null == port) { |
|
|
|
err.push('SMTP server host port'); |
|
|
|
} else if (null == port.match(/^\d+$/) || parseInt(port, 10) > 65535) { |
|
|
|
err.push('SMTP server host port must be between 0 and 65535'); |
|
|
|
} |
|
|
|
if (0 < err.length) { |
|
|
|
status.html('Required: ' + err.join(', ')); |
|
|
|
} else { |
|
|
|
$('.plexinfo').addClass('hide'); |
|
|
|
to = prompt('Enter an email address to send the test to:', ''); |
|
|
|
if (null == to || 0 == to.length || null == to.match(/.*@.*/)) { |
|
|
|
status.html('Required: A valid address for email test'); |
|
|
|
} 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);}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
if ($('input[id="use_plex"]').is(':checked')) {$('.plexinfo').removeClass('hide')} |
|
|
|
|
|
|
|
}); |
|
|
|