musicdirs.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. function setWatchedDirEvents() {
  2. $('#storageFolder-selection').serverBrowser({
  3. onSelect: function(path) {
  4. $('#storageFolder').val(path);
  5. },
  6. onLoad: function() {
  7. return $('#storageFolder').val();
  8. },
  9. width: 500,
  10. height: 250,
  11. position: ['center', 'center'],
  12. //knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
  13. knownPaths: [],
  14. imageUrl: 'img/icons/',
  15. systemImageUrl: baseUrl+'css/img/',
  16. handlerUrl: baseUrl+'Preference/server-browse/format/json',
  17. title: $.i18n._('Choose Storage Folder'),
  18. basePath: '',
  19. requestMethod: 'POST',
  20. });
  21. $('#watchedFolder-selection').serverBrowser({
  22. onSelect: function(path) {
  23. $('#watchedFolder').val(path);
  24. },
  25. onLoad: function() {
  26. return $('#watchedFolder').val();
  27. },
  28. width: 500,
  29. height: 250,
  30. position: ['center', 'center'],
  31. //knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
  32. knownPaths: [],
  33. imageUrl: 'img/icons/',
  34. systemImageUrl: baseUrl+'css/img/',
  35. handlerUrl: baseUrl+'Preference/server-browse/format/json',
  36. title: $.i18n._('Choose Folder to Watch'),
  37. basePath: '',
  38. requestMethod: 'POST',
  39. });
  40. $('#storageFolder-ok').click(function(){
  41. var url, chosen;
  42. if(confirm(sprintf($.i18n._("Are you sure you want to change the storage folder?\nThis will remove the files from your %s library!"), PRODUCT_NAME))){
  43. url = baseUrl+"Preference/change-stor-directory";
  44. chosen = $('#storageFolder').val();
  45. $.post(url,
  46. {format: "json", dir: chosen, element: "storageFolder"},
  47. function(json) {
  48. $("#watched-folder-section").empty();
  49. $("#watched-folder-section").append(json.subform);
  50. setWatchedDirEvents();
  51. });
  52. }
  53. else {
  54. $('#storageFolder').val("");
  55. }
  56. });
  57. $('#watchedFolder-ok').click(function(){
  58. var url, chosen;
  59. url = baseUrl+"Preference/reload-watch-directory";
  60. chosen = $('#watchedFolder').val();
  61. $.post(url,
  62. {format: "json", dir: chosen, element: "watchedFolder"},
  63. function(json) {
  64. $("#watched-folder-section").empty();
  65. $("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>");
  66. $("#watched-folder-section").append(json.subform);
  67. setWatchedDirEvents();
  68. });
  69. });
  70. $('.selected-item').find('.ui-icon-refresh').click(function(){
  71. var folder = $(this).prev().text();
  72. $.get(baseUrl+"Preference/rescan-watch-directory", {format: "json", dir: folder});
  73. });
  74. $('.selected-item').find('.ui-icon-close').click(function(){
  75. if(confirm($.i18n._("Are you sure you want to remove the watched folder?"))){
  76. var row = $(this).parent();
  77. var folder = row.find('#folderPath').text();
  78. url = baseUrl+"Preference/remove-watch-directory";
  79. $.post(url,
  80. {format: "json", dir: folder},
  81. function(json) {
  82. $("#watched-folder-section").empty();
  83. $("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>");
  84. $("#watched-folder-section").append(json.subform);
  85. setWatchedDirEvents();
  86. });
  87. }
  88. });
  89. }
  90. $(document).ready(function() {
  91. setWatchedDirEvents();
  92. $(".ui-icon-alert").qtip({
  93. content: {
  94. text: $.i18n._("This path is currently not accessible.")
  95. },
  96. position:{
  97. adjust: {
  98. resize: true,
  99. method: "flip flip"
  100. },
  101. at: "right center",
  102. my: "left top",
  103. viewport: $(window)
  104. },
  105. style: {
  106. classes: "ui-tooltip-dark"
  107. },
  108. show: 'mouseover',
  109. hide: 'mouseout'
  110. });
  111. });