diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index bd8438864..2547789bb 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -384,6 +384,7 @@ + diff --git a/NzbDrone.Web/Scripts/NzbDrone/settings.js b/NzbDrone.Web/Scripts/NzbDrone/settings.js new file mode 100644 index 000000000..a831a5770 --- /dev/null +++ b/NzbDrone.Web/Scripts/NzbDrone/settings.js @@ -0,0 +1,105 @@ +$('#SeriesName').live('change', function () { createExamples(); }); +$('#EpisodeName').live('change', function () { createExamples(); }); +$('#ReplaceSpaces').live('change', function () { createExamples(); }); +$('#AppendQuality').live('change', function () { createExamples(); }); +$('#SeparatorStyle').live('change', function () { createExamples(); }); +$('#NumberStyle').live('change', function () { createExamples(); }); +$('#MultiEpisodeStyle').live('change', function () { createExamples(); }); + +function createExamples() { + createSingleEpisodeExample(); + createMultiEpisodeExample(); +} + +function createSingleEpisodeExample() { + var result = ''; + + var separator = ' - '; + + if ($("#SeparatorStyle option:selected").val() == 1) + separator = ' '; + + if ($('#SeriesName').attr('checked')) { + result += 'Series Name'; + result += separator; + } + + result += $("#NumberStyle option:selected").text(); + + if ($('#EpisodeName').attr('checked')) { + result += separator; + result += 'Episode Name'; + } + + var appQual = $('#AppendQuality'); + if ($('#AppendQuality').attr('checked')) + result += ' [TV]'; + + if ($('#ReplaceSpaces').attr('checked')) + result = result.replace(/\s/g, '.'); + + $('#singleEpisodeExample').children('.result').text(result); +} + +function createMultiEpisodeExample() { + var result = ''; + + var separator = ' - '; + + if ($("#SeparatorStyle option:selected").val() == 1) + separator = ' '; + + if ($('#SeriesName').attr('checked')) { + result += 'Series Name'; + result += separator; + } + + var numberStyle = $("#NumberStyle option:selected").text(); + var numberId = $("#NumberStyle option:selected").val(); + var style = $("#MultiEpisodeStyle option:selected").val(); + + result += numberStyle; + + if (style == 0) + result += '-06'; + + if (style == 1) { + result += separator; + result += numberStyle.replace('5', '6'); + } + + if (style == 2) { + if (numberId <= 1) + result += 'x06'; + + if (numberId == 2) + result += 'E06'; + + if (numberId == 3) + result += 'e06'; + } + + if (style == 3) { + if (numberId <= 1) + result += '-x06'; + + if (numberId == 2) + result += '-E06'; + + if (numberId == 3) + result += '-e06'; + } + + if ($('#EpisodeName').attr('checked')) { + result += separator; + result += 'Episode Name'; + } + + if ($('#AppendQuality').attr('checked')) + result += ' [TV]'; + + if ($('#ReplaceSpaces').attr('checked')) + result = result.replace(/\s/g, '.'); + + $('#multiEpisodeExample').children('.result').text(result); +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Index.cshtml b/NzbDrone.Web/Views/Settings/Index.cshtml index 59989f74a..363e61e27 100644 --- a/NzbDrone.Web/Views/Settings/Index.cshtml +++ b/NzbDrone.Web/Views/Settings/Index.cshtml @@ -1,4 +1,5 @@ -@{ViewBag.Title = "Settings";} +@using NzbDrone.Web.Helpers +@{ViewBag.Title = "Settings";}
    @@ -9,4 +10,8 @@
  • @Html.ActionLink("Notifications", "Notifications", "Settings")
  • @Html.ActionLink("System", "System", "Settings")
-
\ No newline at end of file + + +@section Scripts{ + @Html.IncludeScript("NzbDrone/settings.js") +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Naming.cshtml b/NzbDrone.Web/Views/Settings/Naming.cshtml index 9658e4815..492277b0d 100644 --- a/NzbDrone.Web/Views/Settings/Naming.cshtml +++ b/NzbDrone.Web/Views/Settings/Naming.cshtml @@ -77,114 +77,5 @@ $(document).ready(function () { createExamples(); }); - - $('#SeriesName').live('change', function () { createExamples(); }); - $('#EpisodeName').live('change', function () { createExamples(); }); - $('#ReplaceSpaces').live('change', function () { createExamples(); }); - $('#AppendQuality').live('change', function () { createExamples(); }); - $('#SeparatorStyle').live('change', function () { createExamples(); }); - $('#NumberStyle').live('change', function () { createExamples(); }); - $('#MultiEpisodeStyle').live('change', function () { createExamples(); }); - - function createExamples() { - createSingleEpisodeExample(); - createMultiEpisodeExample(); - } - - function createSingleEpisodeExample() { - var result = ''; - - var separator = ' - '; - - if ($("#SeparatorStyle option:selected").val() == 1) - separator = ' '; - - if ($('#SeriesName').attr('checked')) { - result += 'Series Name'; - result += separator; - } - - result += $("#NumberStyle option:selected").text(); - - if ($('#EpisodeName').attr('checked')) { - result += separator; - result += 'Episode Name'; - } - - if ($('#AppendQuality').attr('checked')) - result += ' [TV]'; - - if ($('#ReplaceSpaces').attr('checked')) - result = result.replace(/\s/g, '.'); - - //result = 'Single Episode Example: ' + result; - - $('#singleEpisodeExample').children('.result').text(result); - } - - function createMultiEpisodeExample() { - var result = ''; - - var separator = ' - '; - - if ($("#SeparatorStyle option:selected").val() == 1) - separator = ' '; - - if ($('#SeriesName').attr('checked')) { - result += 'Series Name'; - result += separator; - } - - var numberStyle = $("#NumberStyle option:selected").text(); - var numberId = $("#NumberStyle option:selected").val(); - var style = $("#MultiEpisodeStyle option:selected").val(); - - result += numberStyle; - - if (style == 0) - result += '-06'; - - if (style == 1) { - result += separator; - result += numberStyle.replace('5', '6'); - } - - if (style == 2) { - if (numberId <= 1) - result += 'x06'; - - if (numberId == 2) - result += 'E06'; - - if (numberId == 3) - result += 'e06'; - } - - if (style == 3) { - if (numberId <= 1) - result += '-x06'; - - if (numberId == 2) - result += '-E06'; - - if (numberId == 3) - result += '-e06'; - } - - if ($('#EpisodeName').attr('checked')) { - result += separator; - result += 'Episode Name'; - } - - if ($('#AppendQuality').attr('checked')) - result += ' [TV]'; - - if ($('#ReplaceSpaces').attr('checked')) - result = result.replace(/\s/g, '.'); - - //result = 'Multi-Episode Example: ' + result; - - $('#multiEpisodeExample').children('.result').text(result); - } }