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.

user.js 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. 'use strict';
  2. function ChangeTo(to) {
  3. if (to == "text") {
  4. $('#admincommentlinks').ghide();
  5. $('#admincomment').gshow();
  6. resize('admincomment');
  7. var buttons = document.getElementsByName('admincommentbutton');
  8. for (var i = 0; i < buttons.length; i++) {
  9. buttons[i].setAttribute('onclick', "ChangeTo('links'); return false;");
  10. }
  11. } else if (to == "links") {
  12. ajax.post("api.php?action=preview", "form", function (response) {
  13. $('#admincommentlinks').raw().innerHTML = response;
  14. $('#admincomment').ghide();
  15. $('#admincommentlinks').gshow();
  16. var buttons = document.getElementsByName('admincommentbutton');
  17. for (var i = 0; i < buttons.length; i++) {
  18. buttons[i].setAttribute('onclick', "ChangeTo('text'); return false;");
  19. }
  20. })
  21. }
  22. }
  23. function UncheckIfDisabled(checkbox) {
  24. if (checkbox.disabled) {
  25. checkbox.checked = false;
  26. }
  27. }
  28. function AlterParanoia() {
  29. // Required Ratio is almost deducible from downloaded, the count of seeding and the count of snatched
  30. // we will "warn" the user by automatically checking the required ratio box when they are
  31. // revealing that information elsewhere
  32. if (!$('input[name=p_ratio]').raw()) {
  33. return;
  34. }
  35. var showDownload = $('input[name=p_downloaded]').raw().checked || ($('input[name=p_uploaded]').raw().checked && $('input[name=p_ratio]').raw().checked);
  36. if (($('input[name=p_seeding_c]').raw().checked) && ($('input[name=p_snatched_c]').raw().checked) && showDownload) {
  37. $('input[type=checkbox][name=p_requiredratio]').raw().checked = true;
  38. $('input[type=checkbox][name=p_requiredratio]').raw().disabled = true;
  39. } else {
  40. $('input[type=checkbox][name=p_requiredratio]').raw().disabled = false;
  41. }
  42. $('input[name=p_torrentcomments_l]').raw().disabled = !$('input[name=p_torrentcomments_c]').raw().checked;
  43. $('input[name=p_collagecontribs_l]').raw().disabled = !$('input[name=p_collagecontribs_c]').raw().checked;
  44. $('input[name=p_requestsfilled_list]').raw().disabled = !($('input[name=p_requestsfilled_count]').raw().checked && $('input[name=p_requestsfilled_bounty]').raw().checked);
  45. $('input[name=p_requestsvoted_list]').raw().disabled = !($('input[name=p_requestsvoted_count]').raw().checked && $('input[name=p_requestsvoted_bounty]').raw().checked);
  46. $('input[name=p_uploads_l]').raw().disabled = !$('input[name=p_uploads_c]').raw().checked;
  47. $('input[name=p_uniquegroups_l]').raw().disabled = !$('input[name=p_uniquegroups_c]').raw().checked;
  48. $('input[name=p_seeding_l]').raw().disabled = !$('input[name=p_seeding_c]').raw().checked;
  49. $('input[name=p_leeching_l]').raw().disabled = !$('input[name=p_leeching_c]').raw().checked;
  50. $('input[name=p_snatched_l]').raw().disabled = !$('input[name=p_snatched_c]').raw().checked;
  51. UncheckIfDisabled($('input[name=p_torrentcomments_l]').raw());
  52. UncheckIfDisabled($('input[name=p_collagecontribs_l]').raw());
  53. UncheckIfDisabled($('input[name=p_requestsfilled_list]').raw());
  54. UncheckIfDisabled($('input[name=p_requestsvoted_list]').raw());
  55. UncheckIfDisabled($('input[name=p_uploads_l]').raw());
  56. UncheckIfDisabled($('input[name=p_uniquegroups_l]').raw());
  57. UncheckIfDisabled($('input[name=p_seeding_l]').raw());
  58. UncheckIfDisabled($('input[name=p_leeching_l]').raw());
  59. UncheckIfDisabled($('input[name=p_snatched_l]').raw());
  60. // Unique groups, "Perfect" FLACs and artists added are deducible from the list of uploads
  61. if ($('input[name=p_uploads_l]').raw().checked) {
  62. $('input[name=p_uniquegroups_c]').raw().checked = true;
  63. $('input[name=p_uniquegroups_l]').raw().checked = true;
  64. $('input[name=p_uniquegroups_c]').raw().disabled = true;
  65. $('input[name=p_uniquegroups_l]').raw().disabled = true;
  66. $('input[type=checkbox][name=p_artistsadded]').raw().checked = true;
  67. $('input[type=checkbox][name=p_artistsadded]').raw().disabled = true;
  68. } else {
  69. $('input[name=p_uniquegroups_c]').raw().disabled = false;
  70. $('input[name=p_uniquegroups_l]').raw().checked = false;
  71. $('input[name=p_uniquegroups_l]').raw().disabled = true;
  72. $('input[type=checkbox][name=p_artistsadded]').raw().disabled = false;
  73. }
  74. if ($('input[name=p_collagecontribs_l]').raw().checked) {
  75. $('input[name=p_collages_c]').raw().disabled = true;
  76. $('input[name=p_collages_l]').raw().disabled = true;
  77. $('input[name=p_collages_c]').raw().checked = true;
  78. $('input[name=p_collages_l]').raw().checked = true;
  79. } else {
  80. $('input[name=p_collages_c]').raw().disabled = false;
  81. $('input[name=p_collages_l]').raw().disabled = !$('input[name=p_collages_c]').raw().checked;
  82. UncheckIfDisabled($('input[name=p_collages_l]').raw());
  83. }
  84. }
  85. function ParanoiaReset(checkbox, drops) {
  86. var selects = $('select');
  87. for (var i = 0; i < selects.length; i++) {
  88. if (selects.raw(i).name.match(/^p_/)) {
  89. if (drops == 0) {
  90. selects.raw(i).selectedIndex = 0;
  91. } else if (drops == 1) {
  92. selects.raw(i).selectedIndex = selects.raw(i).options.length - 2;
  93. } else if (drops == 2) {
  94. selects.raw(i).selectedIndex = selects.raw(i).options.length - 1;
  95. }
  96. AlterParanoia();
  97. }
  98. }
  99. var checkboxes = $(':checkbox');
  100. for (var i = 0; i < checkboxes.length; i++) {
  101. if (checkboxes.raw(i).name.match(/^p_/) && (checkboxes.raw(i).name != 'p_lastseen')) {
  102. if (checkbox == 3) {
  103. checkboxes.raw(i).checked = !(checkboxes.raw(i).name.match(/_list$/) || checkboxes.raw(i).name.match(/_l$/));
  104. } else {
  105. checkboxes.raw(i).checked = checkbox;
  106. }
  107. AlterParanoia();
  108. }
  109. }
  110. }
  111. function ParanoiaResetOff() {
  112. ParanoiaReset(true, 0);
  113. }
  114. function ParanoiaResetStats() {
  115. ParanoiaReset(3, 0);
  116. $('input[name=p_collages_l]').raw().checked = false;
  117. }
  118. function ParanoiaResetOn() {
  119. ParanoiaReset(false, 0);
  120. $('input[name=p_collages_c]').raw().checked = false;
  121. $('input[name=p_collages_l]').raw().checked = false;
  122. }
  123. document.addEventListener("DOMContentLoaded", AlterParanoia);
  124. function ToggleWarningAdjust(selector) {
  125. if (selector.options[selector.selectedIndex].value == '---') {
  126. $('#ReduceWarningTR').gshow();
  127. $('#ReduceWarning').raw().disabled = false;
  128. } else {
  129. $('#ReduceWarningTR').ghide();
  130. $('#ReduceWarning').raw().disabled = true;
  131. }
  132. }
  133. document.addEventListener("DOMContentLoaded", ToggleIdenticons);
  134. function ToggleIdenticons() {
  135. var disableAvatars = $('#disableavatars');
  136. if (disableAvatars.length) {
  137. var selected = disableAvatars[0].selectedIndex;
  138. if (selected == 2 || selected == 3) {
  139. $('#identicons').gshow();
  140. } else {
  141. $('#identicons').ghide();
  142. }
  143. }
  144. }
  145. function userform_submit() {
  146. if ($('#resetpasskey').is(':checked')) {
  147. if (!confirm('Are you sure you want to reset your passkey?')) {
  148. return false;
  149. }
  150. }
  151. return formVal();
  152. }
  153. function togglePassKey(key) {
  154. if ($('#passkey').raw().innerHTML == 'View') {
  155. $('#passkey').raw().innerHTML = key;
  156. } else {
  157. $('#passkey').raw().innerHTML = 'View';
  158. }
  159. }
  160. function commStats(userid) {
  161. $('.user_commstats').html('Loading&hellip;');
  162. console.log(userid);
  163. ajax.get('api.php?action=community_stats&userid=' + userid, function (JSONresponse) {
  164. var response = JSON.parse(JSONresponse) || false;
  165. console.log(response);
  166. if (!response || response.status == 'failure') {
  167. $('.user_commstats').html('An error occurred');
  168. return;
  169. }
  170. displayCommStats(response.response);
  171. });
  172. }
  173. function displayCommStats(stats) {
  174. var baseid = '#user_commstats_';
  175. for (x in stats) {
  176. if (stats[x] === false) {
  177. continue;
  178. }
  179. switch (x) {
  180. case 'leeching':
  181. $(baseid + x).html(stats[x]);
  182. break;
  183. case 'seeding':
  184. $(baseid + x).html(stats[x]);
  185. break;
  186. case 'downloaded':
  187. $(baseid + x).html(stats[x]);
  188. break;
  189. case 'snatched':
  190. $(baseid + x).html(stats[x]);
  191. break;
  192. case 'usnatched':
  193. $(baseid + x).html('(' + stats[x] + ')');
  194. break;
  195. case 'udownloaded':
  196. $(baseid + x).html('(' + stats[x] + ')');
  197. break;
  198. case 'seedingperc':
  199. $(baseid + x).html('(' + stats[x] + '%)');
  200. break;
  201. }
  202. }
  203. }
  204. // Generate random passwords
  205. function pwgen(field) {
  206. $.ajax({
  207. url: '/sections/pwgen/diceware.php',
  208. data: {},
  209. type: 'post',
  210. success: function (output) {
  211. $('#' + field).val(output);
  212. }
  213. });
  214. }