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.6KB

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