Oppaitime'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 8.8KB

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