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.

browse.js 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. function show_peers (TorrentID, Page) {
  2. if (Page > 0) {
  3. ajax.get('torrents.php?action=peerlist&page=' + Page + '&torrentid=' + TorrentID, function(response) {
  4. $('#peers_' + TorrentID).gshow().raw().innerHTML = response;
  5. });
  6. } else {
  7. if ($('#peers_' + TorrentID).raw().innerHTML === '') {
  8. $('#peers_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
  9. ajax.get('torrents.php?action=peerlist&torrentid=' + TorrentID, function(response) {
  10. $('#peers_' + TorrentID).gshow().raw().innerHTML = response;
  11. });
  12. } else {
  13. $('#peers_' + TorrentID).gtoggle();
  14. }
  15. }
  16. $('#snatches_' + TorrentID).ghide();
  17. $('#downloads_' + TorrentID).ghide();
  18. $('#files_' + TorrentID).ghide();
  19. $('#reported_' + TorrentID).ghide();
  20. }
  21. function show_snatches (TorrentID, Page) {
  22. if (Page > 0) {
  23. ajax.get('torrents.php?action=snatchlist&page=' + Page + '&torrentid=' + TorrentID, function(response) {
  24. $('#snatches_' + TorrentID).gshow().raw().innerHTML = response;
  25. });
  26. } else {
  27. if ($('#snatches_' + TorrentID).raw().innerHTML === '') {
  28. $('#snatches_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
  29. ajax.get('torrents.php?action=snatchlist&torrentid=' + TorrentID, function(response) {
  30. $('#snatches_' + TorrentID).gshow().raw().innerHTML = response;
  31. });
  32. } else {
  33. $('#snatches_' + TorrentID).gtoggle();
  34. }
  35. }
  36. $('#peers_' + TorrentID).ghide();
  37. $('#downloads_' + TorrentID).ghide();
  38. $('#files_' + TorrentID).ghide();
  39. $('#reported_' + TorrentID).ghide();
  40. }
  41. function show_downloads (TorrentID, Page) {
  42. if (Page > 0) {
  43. ajax.get('torrents.php?action=downloadlist&page=' + Page + '&torrentid=' + TorrentID, function(response) {
  44. $('#downloads_' + TorrentID).gshow().raw().innerHTML = response;
  45. });
  46. } else {
  47. if ($('#downloads_' + TorrentID).raw().innerHTML === '') {
  48. $('#downloads_' + TorrentID).gshow().raw().innerHTML = '<h4>Loading...</h4>';
  49. ajax.get('torrents.php?action=downloadlist&torrentid=' + TorrentID, function(response) {
  50. $('#downloads_' + TorrentID).raw().innerHTML = response;
  51. });
  52. } else {
  53. $('#downloads_' + TorrentID).gtoggle();
  54. }
  55. }
  56. $('#peers_' + TorrentID).ghide();
  57. $('#snatches_' + TorrentID).ghide();
  58. $('#files_' + TorrentID).ghide();
  59. $('#reported_' + TorrentID).ghide();
  60. }
  61. function show_files(TorrentID) {
  62. $('#files_' + TorrentID).gtoggle();
  63. $('#peers_' + TorrentID).ghide();
  64. $('#snatches_' + TorrentID).ghide();
  65. $('#downloads_' + TorrentID).ghide();
  66. $('#reported_' + TorrentID).ghide();
  67. }
  68. function show_reported(TorrentID) {
  69. $('#files_' + TorrentID).ghide();
  70. $('#peers_' + TorrentID).ghide();
  71. $('#snatches_' + TorrentID).ghide();
  72. $('#downloads_' + TorrentID).ghide();
  73. $('#reported_' + TorrentID).gtoggle();
  74. }
  75. function add_tag(tag) {
  76. if ($('#tags').raw().value == "") {
  77. $('#tags').raw().value = tag;
  78. } else {
  79. $('#tags').raw().value = $('#tags').raw().value + ", " + tag;
  80. }
  81. }
  82. function toggle_group(groupid, link, event) {
  83. window.getSelection().removeAllRanges()
  84. var toToggle = (event.shiftKey) ? $('.group_torrent') : $('.groupid_'+groupid)
  85. var toReButton = (event.shiftKey) ? $('.hide_torrents, .show_torrents') : [link.parentNode]
  86. if (link.parentNode.className == "hide_torrents") {
  87. for (var i = 0; i < toToggle.length; i++) {
  88. toToggle[i].classList.add('hidden')
  89. }
  90. for (var i = 0; i < toReButton.length; i++) {
  91. toReButton[i].className = "show_torrents"
  92. }
  93. } else {
  94. for (var i = 0; i < toToggle.length; i++) {
  95. toToggle[i].classList.remove('hidden')
  96. }
  97. for (var i = 0; i < toReButton.length; i++) {
  98. toReButton[i].className = "hide_torrents"
  99. }
  100. }
  101. }
  102. /*
  103. function toggle_group(groupid, link, event) {
  104. var clickedRow = link;
  105. while (clickedRow.nodeName != 'TR') {
  106. clickedRow = clickedRow.parentNode;
  107. }
  108. var group_rows = clickedRow.parentNode.children;
  109. var showing = $(clickedRow).nextElementSibling().has_class('hidden');
  110. var allGroups = event.ctrlKey;
  111. // for dealing with Mac OS X
  112. // http://stackoverflow.com/a/3922353
  113. var allGroupsMac = (
  114. event.keyCode == 91 // WebKit (left apple)
  115. || event.keyCode == 93 // WebKit (right apple)
  116. || event.keyCode == 224 // Firefox
  117. || event.keyCode == 17 // Opera
  118. ) ? 91 : null;
  119. for (var i = 0; i < group_rows.length; i++) {
  120. var row = $(group_rows[i]);
  121. if (row.has_class('colhead_dark')) {
  122. continue;
  123. }
  124. if (row.has_class('colhead')) {
  125. continue;
  126. }
  127. var relevantRow = row.has_class('group') ? $(group_rows[i + 1]) : row;
  128. if (allGroups || allGroupsMac || relevantRow.has_class('groupid_' + groupid)) {
  129. row = $(group_rows[i]); // idk why we need this :S
  130. if (row.has_class('group')) {
  131. var section;
  132. if (location.pathname.search('/artist.php$') !== -1) {
  133. section = 'in this release type.';
  134. } else {
  135. section = 'on this page.';
  136. }
  137. var tooltip = showing
  138. ? 'Collapse this group. Hold "Ctrl" while clicking to collapse all groups '+section
  139. : 'Expand this group. Hold "Ctrl" while clicking to expand all groups '+section;
  140. $('a.show_torrents_link', row).updateTooltip(tooltip);
  141. $('a.show_torrents_link', row).raw().parentNode.className = (showing) ? 'hide_torrents' : 'show_torrents';
  142. } else {
  143. if (showing) {
  144. // show the row depending on whether the edition it's in is collapsed or not
  145. if (row.has_class('edition')) {
  146. row.gshow();
  147. var showRow = ($('a', row.raw()).raw().innerHTML != '+');
  148. } else {
  149. if (showRow) {
  150. row.gshow();
  151. } else {
  152. row.ghide();
  153. }
  154. }
  155. } else {
  156. row.ghide();
  157. }
  158. }
  159. }
  160. }
  161. if (event.preventDefault) {
  162. event.preventDefault();
  163. } else {
  164. // for IE < 9 support
  165. event.returnValue = false;
  166. }
  167. }
  168. */
  169. function toggle_edition(groupid, editionid, lnk, event) {
  170. var clickedRow = lnk;
  171. while (clickedRow.nodeName != 'TR') {
  172. clickedRow = clickedRow.parentNode;
  173. }
  174. //var showing = has_class(nextElementSibling(clickedRow), 'hidden');
  175. var showing = $(clickedRow).nextElementSibling().has_class('hidden');
  176. var allEditions = event.ctrlKey;
  177. var group_rows = $('tr.groupid_' + groupid);
  178. for (var i = 0; i < group_rows.length; i++) {
  179. var row = $(group_rows.raw(i));
  180. if (row.has_class('edition') && (allEditions || row.raw(0) == clickedRow)) {
  181. var tooltip = showing
  182. ? 'Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.'
  183. : 'Expand this edition. Hold "Ctrl" while clicking to expand all editions in this torrent group.';
  184. $('a', row).raw().innerHTML = (showing) ? '&minus;' : '+';
  185. $('a', row).updateTooltip(tooltip);
  186. continue;
  187. }
  188. if (allEditions || row.has_class('edition_' + editionid)) {
  189. if (showing && !row.has_class('torrentdetails')) {
  190. row.gshow();
  191. } else {
  192. row.ghide();
  193. }
  194. }
  195. }
  196. if (event.preventDefault) {
  197. event.preventDefault();
  198. } else {
  199. // for IE < 9 support
  200. event.returnValue = false;
  201. }
  202. }
  203. function toggleTorrentSearch(mode) {
  204. if (mode == 0) {
  205. var link = $('#ft_toggle').raw();
  206. $('#ft_container').gtoggle();
  207. link.innerHTML = link.textContent == 'Hide' ? 'Show' : 'Hide';
  208. }
  209. if (mode == 'basic') {
  210. $('.fti_advanced').disable();
  211. $('.fti_basic').enable();
  212. $('.ftr_advanced').ghide(true);
  213. $('.ftr_basic').gshow();
  214. $('#ft_advanced').ghide();
  215. $('#ft_basic').gshow();
  216. $('#ft_type').raw().value = 'basic';
  217. } else if (mode == 'advanced') {
  218. $('.fti_advanced').enable();
  219. $('.fti_basic').disable();
  220. $('.ftr_advanced').gshow();
  221. $('.ftr_basic').ghide();
  222. $('#ft_advanced').gshow();
  223. $('#ft_basic').ghide();
  224. $('#ft_type').raw().value = 'advanced';
  225. }
  226. return false;
  227. }
  228. var coverFieldCount = 0;
  229. var hasCoverAddButton = false;
  230. function addCoverField() {
  231. if (coverFieldCount >= 100) {
  232. return;
  233. }
  234. var x = $('#add_cover').raw();
  235. x.appendChild(document.createElement("br"));
  236. var field = document.createElement("input");
  237. field.type = "text";
  238. field.name = "image[]";
  239. field.placeholder = "URL";
  240. x.appendChild(field);
  241. x.appendChild(document.createTextNode(' '));
  242. var summary = document.createElement("input");
  243. summary.type = "text";
  244. summary.name = "summary[]";
  245. summary.placeholder = "Summary";
  246. x.appendChild(summary);
  247. coverFieldCount++;
  248. if (!hasCoverAddButton) {
  249. x = $('#add_covers_form').raw();
  250. field = document.createElement("input");
  251. field.type = "submit";
  252. field.value = "Add";
  253. x.appendChild(field);
  254. hasCoverAddButton = true;
  255. }
  256. }
  257. function ToggleEditionRows() {
  258. $('#edition_title').gtoggle();
  259. $('#edition_label').gtoggle();
  260. $('#edition_catalogue').gtoggle();
  261. }