BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

torrent.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /**
  2. * ChangeCategory
  3. */
  4. function ChangeCategory(catid) {
  5. /*
  6. if (catid == 1) {
  7. $('#split_releasetype').gshow();
  8. $('#split_artist').gshow();
  9. $('#split_year').gshow();
  10. } else if (catid == 4 || catid == 6) {
  11. $('#split_releasetype').ghide();
  12. $('#split_year').gshow();
  13. $('#split_artist').ghide();
  14. } else {
  15. $('#split_releasetype').ghide();
  16. $('#split_artist').ghide();
  17. $('#split_year').ghide();
  18. }
  19. */
  20. }
  21. function ArtistManager() {
  22. var GroupID = window.location.search.match(/[?&]id=(\d+)/);
  23. if (typeof GroupID == 'undefined') {
  24. return;
  25. } else {
  26. GroupID = GroupID[1];
  27. }
  28. var ArtistList;
  29. if (!(ArtistList = $('#artist_list').raw())) {
  30. return false;
  31. } else if ($('#artistmanager').raw()) {
  32. $('#artistmanager').gtoggle();
  33. $('#artist_list').gtoggle();
  34. } else {
  35. MainArtistCount = 0;
  36. var elArtistManager = document.createElement('div');
  37. elArtistManager.id = 'artistmanager';
  38. var elArtistList = ArtistList.cloneNode(true);
  39. elArtistList.id = 'artistmanager_list';
  40. for (var i = 0; i < elArtistList.children.length; i++) {
  41. if (elArtistList.children[i].children[0].tagName.toUpperCase() == 'A') {
  42. var ArtistID = elArtistList.children[i].children[0].href.match(/[?&]id=(\d+)/)[1];
  43. var elBox = document.createElement('input');
  44. elBox.type = 'checkbox';
  45. elBox.name = 'artistmanager_box';
  46. elBox.value = ArtistID;
  47. elBox.onclick = function (e) { SelectArtist(e, this); };
  48. elArtistList.children[i].insertBefore(elBox, elArtistList.children[i].children[0]);
  49. elArtistList.children[i].insertBefore(document.createTextNode(' '), elArtistList.children[i].children[1]);
  50. MainArtistCount++;
  51. }
  52. }
  53. elArtistManager.appendChild(elArtistList);
  54. var elArtistForm = document.createElement('form');
  55. elArtistForm.id = 'artistmanager_form';
  56. elArtistForm.method = 'post';
  57. var elGroupID = document.createElement('input');
  58. elGroupID.type = 'hidden';
  59. elGroupID.name = 'groupid';
  60. elGroupID.value = GroupID;
  61. elArtistForm.appendChild(elGroupID);
  62. var elAction = document.createElement('input');
  63. elAction.type = 'hidden';
  64. elAction.name = 'manager_action';
  65. elAction.id = 'manager_action';
  66. elAction.value = 'manage';
  67. elArtistForm.appendChild(elAction);
  68. var elAction = document.createElement('input');
  69. elAction.type = 'hidden';
  70. elAction.name = 'action';
  71. elAction.value = 'manage_artists';
  72. elArtistForm.appendChild(elAction);
  73. var elAuth = document.createElement('input');
  74. elAuth.type = 'hidden';
  75. elAuth.name = 'auth';
  76. elAuth.value = authkey;
  77. elArtistForm.appendChild(elAuth);
  78. var elSelection = document.createElement('input');
  79. elSelection.type = 'hidden';
  80. elSelection.id = 'artists_selection';
  81. elSelection.name = 'artists';
  82. elArtistForm.appendChild(elSelection);
  83. var elSubmitDiv = document.createElement('div');
  84. elSubmitDiv.appendChild(document.createTextNode(' '));
  85. elSubmitDiv.className = 'body';
  86. var elDelButton = document.createElement('input');
  87. elDelButton.type = 'button';
  88. elDelButton.value = 'Delete';
  89. elDelButton.onclick = ArtistManagerDelete;
  90. elSubmitDiv.appendChild(elDelButton);
  91. elArtistForm.appendChild(elSubmitDiv);
  92. elArtistManager.appendChild(elArtistForm);
  93. ArtistList.parentNode.appendChild(elArtistManager);
  94. $('#artist_list').ghide();
  95. }
  96. }
  97. function SelectArtist(e, obj) {
  98. if (window.event) {
  99. e = window.event;
  100. }
  101. EndBox = Number(obj.id.substr(17));
  102. if (!e.shiftKey || typeof StartBox == 'undefined') {
  103. StartBox = Number(obj.id.substr(17));
  104. }
  105. Dir = (EndBox > StartBox ? 1 : -1);
  106. var checked = obj.checked;
  107. for (var i = StartBox; i != EndBox; i += Dir) {
  108. var key, importance = obj.value.substr(0, 1), id = obj.value.substr(2);
  109. $('#artistmanager_box' + i).raw().checked = checked;
  110. }
  111. StartBox = Number(obj.id.substr(17));
  112. }
  113. function ArtistManagerSubmit() {
  114. var Selection = new Array();
  115. var MainSelectionCount = 0;
  116. for (var i = 0, boxes = $('[name="artistmanager_box"]'); boxes.raw(i); i++) {
  117. if (boxes.raw(i).checked) {
  118. Selection.push(boxes.raw(i).value);
  119. if (boxes.raw(i).value.substr(0, 1) == '1') {
  120. MainSelectionCount++;
  121. }
  122. }
  123. }
  124. if (Selection.length == 0 || ($('#manager_action').raw().value == 'delete' && !confirm('Are you sure you want to delete ' + Selection.length + ' artists from this group?'))) {
  125. return;
  126. }
  127. $('#artists_selection').raw().value = Selection.join(',');
  128. if ((($('#artists_importance').raw().value != 1 && $('#artists_importance').raw().value != 4 && $('#artists_importance').raw().value != 6) || $('#manager_action').raw().value == 'delete') && MainSelectionCount == MainArtistCount) {
  129. if (!$('.error_message').raw()) {
  130. save_message('All groups need to have at least one main artist, composer, or DJ.', true);
  131. }
  132. $('.error_message').raw().scrollIntoView();
  133. return;
  134. }
  135. $('#artistmanager_form').raw().submit();
  136. }
  137. function ArtistManagerDelete() {
  138. $('#manager_action').raw().value = 'delete';
  139. ArtistManagerSubmit();
  140. $('#manager_action').raw().value = 'manage';
  141. }
  142. function Vote(amount, requestid) {
  143. if (typeof amount == 'undefined') {
  144. amount = parseInt($('#amount').raw().value);
  145. }
  146. if (amount == 0) {
  147. amount = 20 * 1024 * 1024;
  148. }
  149. var index;
  150. var votecount;
  151. if (!requestid) {
  152. requestid = $('#requestid').raw().value;
  153. votecount = $('#votecount').raw();
  154. index = false;
  155. } else {
  156. votecount = $('#vote_count_' + requestid).raw();
  157. bounty = $('#bounty_' + requestid).raw();
  158. index = true;
  159. }
  160. ajax.get('requests.php?action=takevote&id=' + requestid + '&auth=' + authkey + '&amount=' + amount, function (response) {
  161. if (response == 'bankrupt') {
  162. save_message("You do not have sufficient upload credit to add " + get_size(amount) + " to this request", true);
  163. return;
  164. } else if (response == 'dupesuccess') {
  165. //No increment
  166. } else if (response == 'success') {
  167. votecount.innerHTML = (parseInt(votecount.innerHTML)) + 1;
  168. }
  169. if ($('#total_bounty').length > 0) {
  170. totalBounty = parseInt($('#total_bounty').raw().value);
  171. totalBounty += (amount * (1 - $('#request_tax').raw().value));
  172. $('#total_bounty').raw().value = totalBounty;
  173. $('#formatted_bounty').raw().innerHTML = get_size(totalBounty);
  174. save_message("Your vote of " + get_size(amount) + ", adding a " + get_size(amount * (1 - $('#request_tax').raw().value)) + " bounty, has been added");
  175. $('#button').raw().disabled = true;
  176. } else {
  177. save_message("Your vote of " + get_size(amount) + " has been added");
  178. }
  179. }
  180. );
  181. }