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.

collage.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. function Add(input) {
  2. if (input.checked == false) {
  3. Cancel();
  4. } else {
  5. if (document.getElementById("choices").raw().value == "") {
  6. document.getElementById("choices").raw().value += input.name;
  7. } else {
  8. document.getElementById("choices").raw().value += "|" + input.name;
  9. }
  10. }
  11. }
  12. function Cancel() {
  13. var e = document.getElementsByTagName("input");
  14. for (i = 0; i < e.length; i++) {
  15. if (e[i].type == "checkbox") {
  16. e[i].checked = false;
  17. }
  18. }
  19. document.getElementById("choices").raw().value = "";
  20. }
  21. function CollageSubscribe(collageid) {
  22. ajax.get("userhistory.php?action=collage_subscribe&collageid=" + collageid + "&auth=" + authkey, function () {
  23. var subscribeLink = $("#subscribelink" + collageid).raw();
  24. if (subscribeLink) {
  25. subscribeLink.firstChild.nodeValue = subscribeLink.firstChild.nodeValue.charAt(0) == 'U'
  26. ? "Subscribe"
  27. : "Unsubscribe";
  28. }
  29. });
  30. }
  31. var collageShow = {
  32. pg: 0,
  33. pages: false,
  34. wrap: false,
  35. init: function (collagePages) {
  36. this.wrap = document.getElementById('coverart');
  37. this.pages = collagePages;
  38. this.max = this.pages.length - 1;
  39. },
  40. selected: function () {
  41. return $('.linkbox .selected').raw();
  42. },
  43. createUL: function (data) {
  44. var ul = document.createElement('div');
  45. $(ul).add_class('collage_images');
  46. ul.id = 'collage_page' + this.pg;
  47. $(ul).html(data);
  48. $('.tooltip_interactive', ul).each(function () {
  49. if ($(this).data('title-plain')) {
  50. $(this).attr('title', $(this).data('title-plain')).removeData('title-plain');
  51. }
  52. });
  53. this.wrap.appendChild(ul);
  54. return ul;
  55. },
  56. page: function (num, el) {
  57. var ul = $('#collage_page' + num).raw(), s = this.selected(), covers, lists, i;
  58. this.pg = num;
  59. if (!ul) {
  60. covers = this.pages[num];
  61. if (covers) {
  62. ul = this.createUL(covers);
  63. }
  64. }
  65. $('.collage_images').ghide();
  66. $(ul).gshow();
  67. if (s) {
  68. $(s).remove_class('selected');
  69. }
  70. if (el) {
  71. $(el.parentNode).add_class('selected');
  72. }
  73. $('.collage_image img').on('load', function () {
  74. var test = true;
  75. $('.collage_image img').toArray().forEach(function (el) {
  76. if (!el.complete) test = false
  77. })
  78. if (test) wall('.collage_images', '.collage_image', 4)
  79. })
  80. wall('.collage_images', '.collage_image', 4)
  81. // Toggle the page number links
  82. first = Math.max(0, this.pg - 2);
  83. if (this.max - this.pg < 2) {
  84. first = Math.max(this.max - 4, 0);
  85. }
  86. last = Math.min(first + 4, this.max);
  87. for (i = 0; i < first; i++) {
  88. $('#pagelink' + i).ghide();
  89. }
  90. for (i = first; i <= last; i++) {
  91. $('#pagelink' + i).gshow();
  92. }
  93. for (i = last + 1; i <= this.max; i++) {
  94. $('#pagelink' + i).ghide();
  95. }
  96. // Toggle the first, prev, next, and last links
  97. if (this.pg > 0) {
  98. $('#prevpage').remove_class('invisible');
  99. } else {
  100. $('#prevpage').add_class('invisible');
  101. }
  102. if (this.pg > 1) {
  103. $('#firstpage').remove_class('invisible');
  104. } else {
  105. $('#firstpage').add_class('invisible');
  106. }
  107. if (this.pg < this.max) {
  108. $('#nextpage').remove_class('invisible');
  109. } else {
  110. $('#nextpage').add_class('invisible');
  111. }
  112. if (this.pg < this.max - 1) {
  113. $('#lastpage').remove_class('invisible');
  114. } else {
  115. $('#lastpage').add_class('invisible');
  116. }
  117. // Toggle the bar
  118. if ((last == this.max) && (this.pg != this.max)) {
  119. $('#nextbar').gshow();
  120. } else {
  121. $('#nextbar').ghide();
  122. }
  123. },
  124. nextPage: function () {
  125. this.pg = this.pg < this.max ? this.pg + 1 : this.pg;
  126. this.pager();
  127. },
  128. prevPage: function () {
  129. this.pg = this.pg > 0 ? this.pg - 1 : this.pg;
  130. this.pager();
  131. },
  132. pager: function () {
  133. this.page(this.pg, $('#pagelink' + this.pg).raw().firstChild);
  134. }
  135. };