2012-02-23 19:16:11 +00:00
|
|
|
@model NzbDrone.Web.Models.NotificationSettingsModel
|
|
|
|
@{ Layout = null; }
|
|
|
|
<style>
|
|
|
|
.notifier
|
|
|
|
{
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.notifier h4
|
|
|
|
{
|
|
|
|
font-weight: bold;
|
|
|
|
margin-bottom: 0px;
|
|
|
|
padding-left: 5px;
|
|
|
|
padding-top: 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#save_button
|
|
|
|
{
|
|
|
|
margin-top: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#smtpTest
|
|
|
|
{
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
margin-left: 220px;
|
|
|
|
}
|
|
|
|
</style>
|
2011-12-01 05:04:44 +00:00
|
|
|
<div id="stylized">
|
2011-12-01 06:39:11 +00:00
|
|
|
@using (Html.BeginForm("SaveNotifications", "Settings", FormMethod.Post, new { id = "NotificationForm", name = "NotificationForm", @class = "settingsForm" }))
|
2011-12-01 05:04:44 +00:00
|
|
|
{
|
2011-12-08 05:30:47 +00:00
|
|
|
<div class="jquery-accordion">
|
2012-02-23 19:16:11 +00:00
|
|
|
<h3>
|
|
|
|
<a href="#">XBMC</a></h3>
|
2011-12-01 05:04:44 +00:00
|
|
|
@{Html.RenderPartial("Xbmc", Model);}
|
2012-02-23 19:16:11 +00:00
|
|
|
<h3>
|
2012-02-27 01:54:55 +00:00
|
|
|
<a href="#">Plex</a></h3>
|
|
|
|
@{Html.RenderPartial("Plex", Model);}
|
2012-02-23 19:16:11 +00:00
|
|
|
<h3>
|
|
|
|
<a href="#">Growl</a></h3>
|
2011-12-01 05:04:44 +00:00
|
|
|
@{Html.RenderPartial("Growl", Model);}
|
2012-02-23 19:16:11 +00:00
|
|
|
<h3>
|
|
|
|
<a href="#">Prowl</a></h3>
|
2011-12-01 05:04:44 +00:00
|
|
|
@{Html.RenderPartial("Prowl", Model);}
|
2012-02-23 19:16:11 +00:00
|
|
|
<h3>
|
2012-02-27 01:54:55 +00:00
|
|
|
<a href="#">Email</a></h3>
|
|
|
|
@{Html.RenderPartial("Smtp", Model);}
|
|
|
|
<h3>
|
|
|
|
<a href="#">Twitter</a></h3>
|
|
|
|
@{Html.RenderPartial("Twitter", Model);}
|
2011-12-01 05:04:44 +00:00
|
|
|
</div>
|
2011-07-01 20:33:03 +00:00
|
|
|
|
2011-12-01 06:39:11 +00:00
|
|
|
<button type="submit" class="save_button" disabled="disabled">
|
2011-12-01 05:04:44 +00:00
|
|
|
Save</button>
|
|
|
|
}
|
|
|
|
</div>
|
2012-02-23 19:16:11 +00:00
|
|
|
<script type="text/javascript">
|
2012-02-25 21:21:41 +00:00
|
|
|
$(document).ready(function () {
|
|
|
|
//Allow unobstrusive validation of the AJAX loaded form
|
|
|
|
$.validator.unobtrusive.parse('#NotificationForm');
|
|
|
|
|
|
|
|
//Validator Settings
|
|
|
|
var settings = $.data($('#NotificationForm')[0], 'validator').settings;
|
|
|
|
settings.ignore = [];
|
|
|
|
settings.focusInvalid = false;
|
|
|
|
settings.onfocusout = function (element) { $(element).valid(); };
|
|
|
|
|
|
|
|
var oldHighlight = settings.highlight;
|
|
|
|
var oldUnhighlight = settings.unhighlight;
|
|
|
|
|
|
|
|
settings.highlight = function (element, errorClass, validClass) {
|
|
|
|
oldHighlight(element, errorClass, validClass);
|
|
|
|
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
|
|
|
|
};
|
|
|
|
settings.unhighlight = function (element, errorClass, validClass) {
|
|
|
|
oldUnhighlight(element, errorClass, validClass);
|
|
|
|
|
|
|
|
var container = $(element).parents('div.ui-accordion-content');
|
|
|
|
if ($(container).children('.' + errorClass).length == 0)
|
|
|
|
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('change', '.checkClass', function () {
|
|
|
|
$("#NotificationForm").validate().form();
|
|
|
|
|
|
|
|
var container = $('div.ui-accordion-content');
|
|
|
|
if ($(container).children('.input-validation-error').length == 0)
|
|
|
|
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
|
|
|
});
|
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
//Twitter
|
|
|
|
getAuthorizationUrl = '../Command/GetTwitterAuthorization';
|
|
|
|
verifyAuthorizationUrl = '../Command/VerifyTwitterAuthorization';
|
2011-11-30 00:45:45 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
function requestTwitterAuthorization() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: getAuthorizationUrl,
|
|
|
|
error: function (req, status, error) {
|
|
|
|
alert("Sorry! We could get Twitter Authorization at this time. " + error);
|
|
|
|
},
|
|
|
|
success: function (data, textStatus, jqXHR) {
|
|
|
|
if (data.IsMessage)
|
|
|
|
return false;
|
2011-12-01 05:04:44 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
$('#authorizationRequestToken').val(data.Token);
|
|
|
|
window.open(data.Url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-11-30 00:45:45 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
function verifyTwitterAuthorization() {
|
|
|
|
var token = $('#authorizationRequestToken').val();
|
|
|
|
var verifier = $('#twitterVerification').val();
|
2011-11-30 00:45:45 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: verifyAuthorizationUrl,
|
|
|
|
data: jQuery.param({ token: token, verifier: verifier }),
|
|
|
|
error: function (req, status, error) {
|
|
|
|
alert("Sorry! We could verify Twitter Authorization at this time. " + error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2011-11-30 00:45:45 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
//SMTP
|
|
|
|
function testSmtpSettings() {
|
|
|
|
//Get the variables
|
|
|
|
var server = $('#SmtpServer').val();
|
|
|
|
var port = $('#SmtpPort').val();
|
|
|
|
var ssl = $('#SmtpUseSsl').val();
|
|
|
|
var username = $('#SmtpUsername').val();
|
|
|
|
var password = $('#SmtpPassword').val();
|
|
|
|
var fromAddress = $('#SmtpFromAddress').val();
|
|
|
|
var toAddresses = $('#SmtpToAddresses').val();
|
2011-12-01 05:04:44 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
//Send the data!
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: '../Command/SendTestEmail',
|
|
|
|
data: jQuery.param({
|
|
|
|
server: server,
|
|
|
|
port: port,
|
|
|
|
ssl: ssl,
|
|
|
|
username: username,
|
|
|
|
password: password,
|
|
|
|
fromAddress: fromAddress,
|
|
|
|
toAddresses: toAddresses
|
|
|
|
}),
|
|
|
|
error: function (req, status, error) {
|
|
|
|
alert("Sorry! We could send a test email at this time. " + error);
|
|
|
|
}
|
|
|
|
});
|
2011-11-30 00:45:45 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-07 08:12:37 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
//Growl
|
|
|
|
function registerGrowl() {
|
|
|
|
//Get the variables
|
|
|
|
var host = $('#GrowlHost').val();
|
|
|
|
var password = $('#GrowlPassword').val();
|
2012-02-07 08:12:37 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
//Send the data!
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: '../Command/RegisterGrowl',
|
|
|
|
data: jQuery.param({
|
|
|
|
host: host,
|
|
|
|
password: password
|
|
|
|
}),
|
|
|
|
error: function (req, status, error) {
|
|
|
|
alert("Sorry! We could send a test email at this time. " + error);
|
|
|
|
}
|
|
|
|
});
|
2012-02-07 08:12:37 +00:00
|
|
|
|
2012-02-23 19:16:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
</script>
|