configPage.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Trailers</title>
  5. </head>
  6. <body>
  7. <div id="trailersConfigurationPage" data-role="page" class="page type-interior pluginConfigurationPage">
  8. <div data-role="content">
  9. <div class="content-primary">
  10. <form id="trailersConfigurationForm">
  11. <ul class="ulForm" data-role="listview">
  12. <li>
  13. <label for="txtFolderName">
  14. Trailer collection name:
  15. </label>
  16. <input id="txtFolderName" name="txtFolderName" />
  17. </li>
  18. <li>
  19. <label for="txtMaxTrailerAge">
  20. Max trailer age (days):
  21. </label>
  22. <input type="number" id="txtMaxTrailerAge" name="txtMaxTrailerAge" pattern="[0-9]*" min="1" />
  23. <div class="fieldDescription">
  24. If specified, trailers older than this will not be downloaded
  25. </div>
  26. </li>
  27. <li>
  28. <input type="checkbox" id="chkDeleteOldTrailers" name="chkDeleteOldTrailers" />
  29. <label for="chkDeleteOldTrailers">Delete trailers older than the max age</label>
  30. </li>
  31. <li>
  32. <label for="txtDownloadPath">
  33. Download path:
  34. </label>
  35. <div style="display: inline-block; width:92%;">
  36. <input id="txtDownloadPath" name="txtDownloadPath" data-inline="true" />
  37. </div>
  38. <button type="button" data-icon="folder-close" data-iconpos="notext" data-inline="true" onclick="TrailersConfigurationPage.selectDirectory();">Select Directory</button>
  39. <div class="fieldDescription">
  40. By default, trailers are downloaded to an internal data directory. Using a different location may make it easier to share over your network.
  41. </div>
  42. </li>
  43. <li>
  44. <button type="submit" data-theme="b">Save</button>
  45. <button type="button" onclick="history.back();">Cancel</button>
  46. </li>
  47. </ul>
  48. </form>
  49. </div>
  50. </div>
  51. <script type="text/javascript">
  52. var TrailersConfigurationPage = {
  53. pluginUniqueId: "986a7283-205a-4436-862d-23135c067f8a",
  54. selectDirectory: function () {
  55. Dashboard.selectDirectory({
  56. callback: function (path) {
  57. if (path) {
  58. $('#txtDownloadPath', $.mobile.activePage).val(path);
  59. }
  60. $('#popupDirectoryPicker', $.mobile.activePage).popup("close");
  61. },
  62. header: "Select Trailer Path"
  63. });
  64. }
  65. };
  66. $('#trailersConfigurationPage').on('pageshow', function (event) {
  67. Dashboard.showLoadingMsg();
  68. var page = this;
  69. ApiClient.getPluginConfiguration(TrailersConfigurationPage.pluginUniqueId).done(function (config) {
  70. $('#txtDownloadPath', page).val(config.DownloadPath);
  71. $('#txtFolderName', page).val(config.FolderName);
  72. $('#txtMaxTrailerAge', page).val(config.MaxTrailerAge || "");
  73. $('#chkDeleteOldTrailers', page).checked(config.DeleteOldTrailers).checkboxradio("refresh");
  74. Dashboard.hideLoadingMsg();
  75. });
  76. });
  77. $('#trailersConfigurationForm').on('submit', function (e) {
  78. Dashboard.showLoadingMsg();
  79. var form = this;
  80. ApiClient.getPluginConfiguration(TrailersConfigurationPage.pluginUniqueId).done(function (config) {
  81. config.DownloadPath = $('#txtDownloadPath', form).val();
  82. config.FolderName = $('#txtFolderName', form).val();
  83. var maxTrailerAge = $('#txtMaxTrailerAge', form).val();
  84. config.MaxTrailerAge = maxTrailerAge ? maxTrailerAge : null;
  85. config.DeleteOldTrailers = $('#chkDeleteOldTrailers', form).checked();
  86. ApiClient.updatePluginConfiguration(TrailersConfigurationPage.pluginUniqueId, config).done(Dashboard.processPluginConfigurationUpdateResult);
  87. });
  88. // Disable default form submission
  89. return false;
  90. });
  91. </script>
  92. </div>
  93. </body>
  94. </html>