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.

browse.js 9.1KB

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