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.

requests.js 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. function Vote(amount, requestid) {
  2. if (typeof amount == 'undefined') {
  3. amount = parseInt($('#amount').raw().value);
  4. }
  5. if (amount == 0) {
  6. amount = 20 * 1024 * 1024;
  7. }
  8. var index;
  9. var votecount;
  10. if (!requestid) {
  11. requestid = $('#requestid').raw().value;
  12. votecount = $('#votecount').raw();
  13. index = false;
  14. } else {
  15. votecount = $('#vote_count_' + requestid).raw();
  16. bounty = $('#bounty_' + requestid).raw();
  17. index = true;
  18. }
  19. if (amount > 20 * 1024 * 1024) {
  20. upload = $('#current_uploaded').raw().value;
  21. download = $('#current_downloaded').raw().value;
  22. rr = $('#current_rr').raw().value;
  23. if (amount > 0.3 * (upload - rr * download)) {
  24. if (!confirm('This vote is more than 30% of your buffer. Please confirm that you wish to place this large of a vote.')) {
  25. return false;
  26. }
  27. }
  28. }
  29. ajax.get('requests.php?action=takevote&id=' + requestid + '&auth=' + authkey + '&amount=' + amount, function (response) {
  30. if (response == 'bankrupt') {
  31. save_message("You do not have sufficient upload credit to add " + get_size(amount) + " to this request", true);
  32. return;
  33. } else if (response == 'dupesuccess') {
  34. //No increment
  35. } else if (response == 'success') {
  36. votecount.innerHTML = (parseInt(votecount.innerHTML)) + 1;
  37. }
  38. if ($('#total_bounty').length > 0) {
  39. totalBounty = parseInt($('#total_bounty').raw().value);
  40. totalBounty += (amount * (1 - $('#request_tax').raw().value));
  41. $('#total_bounty').raw().value = totalBounty;
  42. $('#formatted_bounty').raw().innerHTML = get_size(totalBounty);
  43. save_message("Your vote of " + get_size(amount) + ", adding a " + get_size(amount * (1 - $('#request_tax').raw().value)) + " bounty, has been added");
  44. $('#button').raw().disabled = true;
  45. } else {
  46. save_message("Your vote of " + get_size(amount) + " has been added");
  47. }
  48. }
  49. );
  50. }
  51. function Calculate() {
  52. if (!$('#unit').raw()) { return; }
  53. var mul = (($('#unit').raw().options[$('#unit').raw().selectedIndex].value == 'mb') ? (1024 * 1024) : (1024 * 1024 * 1024));
  54. var amt = Math.floor($('#amount_box').raw().value * mul);
  55. if (amt > $('#current_uploaded').raw().value) {
  56. $('#new_uploaded').raw().innerHTML = "You can't afford that request!";
  57. $('#new_bounty').raw().innerHTML = "0.00 MB";
  58. $('#bounty_after_tax').raw().innerHTML = "0.00 MB";
  59. $('#button').raw().disabled = true;
  60. } else if (isNaN($('#amount_box').raw().value)
  61. || (window.location.search.indexOf('action=new') != -1 && $('#amount_box').raw().value * mul < 100 * 1024 * 1024)
  62. || (window.location.search.indexOf('action=view') != -1 && $('#amount_box').raw().value * mul < 20 * 1024 * 1024)) {
  63. $('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value));
  64. $('#new_bounty').raw().innerHTML = "0.00 MB";
  65. $('#bounty_after_tax').raw().innerHTML = "0.00 MB";
  66. $('#button').raw().disabled = true;
  67. } else {
  68. $('#button').raw().disabled = false;
  69. $('#amount').raw().value = amt;
  70. $('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value) - amt);
  71. $('#new_ratio').raw().innerHTML = ratio($('#current_uploaded').raw().value - amt, $('#current_downloaded').raw().value);
  72. $('#new_bounty').raw().innerHTML = get_size(mul * $('#amount_box').raw().value);
  73. $('#bounty_after_tax').raw().innerHTML = get_size(mul * 0.9 * $('#amount_box').raw().value);
  74. }
  75. }
  76. var ArtistCount = 1;
  77. function AddArtistField() {
  78. window.getSelection().removeAllRanges()
  79. ArtistCount = $('input[name="artists[]"]').length;
  80. if (ArtistCount >= 200) {
  81. return;
  82. }
  83. var ArtistField = document.createElement("input");
  84. ArtistField.type = "text";
  85. ArtistField.id = "artists_" + ArtistCount;
  86. ArtistField.name = "artists[]";
  87. ArtistField.size = 45;
  88. var x = $('#artistfields').raw();
  89. x.appendChild(document.createElement("br"));
  90. x.appendChild(ArtistField);
  91. x.appendChild(document.createTextNode('\n'));
  92. if ($("#artists_0").data("gazelle-autocomplete")) {
  93. $(ArtistField).on('focus', function () {
  94. $(ArtistField).autocomplete({
  95. deferRequestBy: 300,
  96. serviceUrl: ARTIST_AUTOCOMPLETE_URL
  97. });
  98. });
  99. }
  100. ArtistCount++;
  101. }
  102. function RemoveArtistField() {
  103. window.getSelection().removeAllRanges()
  104. ArtistCount = $('input[name="artists[]"]').length;
  105. if (ArtistCount == 1) {
  106. return;
  107. }
  108. var x = $('#artistfields').raw();
  109. for (i = 0; i < 3; i++) {
  110. x.removeChild(x.lastChild);
  111. }
  112. ArtistCount--;
  113. }
  114. function Categories() {
  115. /*
  116. var cat = $('#categories').raw() ? $('#categories').raw().options[$('#categories').raw().selectedIndex].value : '';
  117. if (cat == "Movies") {
  118. $('#artist_tr').gshow();
  119. $('#cataloguenumber_tr').gshow();
  120. $('#dlsiteid_tr').ghide();
  121. } else if (cat == "Anime") {
  122. $('#artist_tr').gshow();
  123. $('#cataloguenumber_tr').ghide();
  124. $('#dlsiteid_tr').ghide();
  125. } else if (cat == "Manga") {
  126. $('#artist_tr').gshow();
  127. $('#cataloguenumber_tr').ghide();
  128. $('#dlsiteid_tr').ghide();
  129. } else if (cat == "Games") {
  130. $('#artist_tr').gshow();
  131. $('#dlsiteid_tr').gshow();
  132. $('#cataloguenumber_tr').ghide();
  133. } else if (cat == "Audio") {
  134. $('#artist_tr').gshow();
  135. $('#dlsiteid_tr').ghide();
  136. $('#cataloguenumber_tr').ghide();
  137. } else {
  138. $('#artist_tr').ghide();
  139. $('#cataloguenumber_tr').ghide();
  140. $('#dlsiteid_tr').ghide();
  141. }
  142. */
  143. }
  144. function add_tag() {
  145. if ($('#tags').raw().value == "") {
  146. $('#tags').raw().value = $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
  147. } else if ($('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value == "---") {
  148. } else {
  149. $('#tags').raw().value = $('#tags').raw().value + ", " + $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
  150. }
  151. }
  152. function Toggle(id, disable) {
  153. var arr = document.getElementsByName(id + '[]');
  154. var master = $('#toggle_' + id).raw().checked;
  155. for (var x in arr) {
  156. arr[x].checked = master;
  157. if (disable == 1) {
  158. arr[x].disabled = master;
  159. }
  160. }
  161. if (id == "formats") {
  162. ToggleLogCue();
  163. }
  164. }
  165. function ToggleLogCue() {
  166. var formats = document.getElementsByName('formats[]');
  167. var flac = false;
  168. if (formats[1].checked) {
  169. flac = true;
  170. }
  171. if (flac) {
  172. $('#logcue_tr').gshow();
  173. } else {
  174. $('#logcue_tr').ghide();
  175. }
  176. ToggleLogScore();
  177. }
  178. function ToggleLogScore() {
  179. if ($('#needlog').raw().checked) {
  180. $('#minlogscore_span').gshow();
  181. } else {
  182. $('#minlogscore_span').ghide();
  183. }
  184. }
  185. function JavAutofill() {
  186. var map = {
  187. cn: 'javdb',
  188. idols: 'artist',
  189. title: 'title',
  190. title_jp: 'title_jp',
  191. image: 'image',
  192. tags: 'tags',
  193. description: 'req_desc'
  194. }
  195. var cn = $('#catalogue').raw().value.toUpperCase()
  196. $.getJSON('/ajax.php?action=javfill&cn=' + cn, function (data) {
  197. if (data.status != "success") {
  198. $('#catalogue').raw().value = 'Failed'
  199. return
  200. } else {
  201. $('#catalogue').raw().value = data.response.cn
  202. }
  203. for (i in data.response) {
  204. if (Array.isArray(data.response[i])) {
  205. for (j in data.response[i]) {
  206. if (i == 'idols') {
  207. if (!($('#' + map[i] + '_' + j).raw())) {
  208. AddArtistField()
  209. }
  210. $('#' + map[i] + '_' + j).raw().value = data.response[i][j]
  211. }
  212. if (map[i] == 'tags' && !($('#' + map[i]).raw().value)) {
  213. $('#' + map[i]).raw().value = data.response[i].join(', ')
  214. }
  215. }
  216. }
  217. if (map[i] && $('#' + map[i]).raw() && !($('#' + map[i]).raw().value)) {
  218. $('#' + map[i]).raw().value = data.response[i]
  219. }
  220. }
  221. })
  222. }
  223. $(function () {
  224. Categories()
  225. Calculate()
  226. document.querySelectorAll('[autofill]').forEach(function (el) {
  227. el.addEventListener('click', function (event) {
  228. ({ 'jav': JavAutofill })[el.attributes['autofill'].value]()
  229. })
  230. })
  231. $(document).on('click', '.add_artist_button', AddArtistField);
  232. $(document).on('click', '.remove_artist_button', RemoveArtistField);
  233. })