Oppaitime'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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. error_message("You do not have sufficient upload credit to add " + get_size(amount) + " to this request");
  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').results() > 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. var mul = (($('#unit').raw().options[$('#unit').raw().selectedIndex].value == 'mb') ? (1024*1024) : (1024*1024*1024));
  53. var amt = Math.floor($('#amount_box').raw().value * mul);
  54. if (amt > $('#current_uploaded').raw().value) {
  55. $('#new_uploaded').raw().innerHTML = "You can't afford that request!";
  56. $('#new_bounty').raw().innerHTML = "0.00 MB";
  57. $('#bounty_after_tax').raw().innerHTML = "0.00 MB";
  58. $('#button').raw().disabled = true;
  59. } else if (isNaN($('#amount_box').raw().value)
  60. || (window.location.search.indexOf('action=new') != -1 && $('#amount_box').raw().value * mul < 100 * 1024 * 1024)
  61. || (window.location.search.indexOf('action=view') != -1 && $('#amount_box').raw().value * mul < 20 * 1024 * 1024)) {
  62. $('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value));
  63. $('#new_bounty').raw().innerHTML = "0.00 MB";
  64. $('#bounty_after_tax').raw().innerHTML = "0.00 MB";
  65. $('#button').raw().disabled = true;
  66. } else {
  67. $('#button').raw().disabled = false;
  68. $('#amount').raw().value = amt;
  69. $('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value) - amt);
  70. $('#new_ratio').raw().innerHTML = ratio($('#current_uploaded').raw().value - amt, $('#current_downloaded').raw().value);
  71. $('#new_bounty').raw().innerHTML = get_size(mul * $('#amount_box').raw().value);
  72. $('#bounty_after_tax').raw().innerHTML = get_size(mul * 0.9 * $('#amount_box').raw().value);
  73. }
  74. }
  75. function AddArtistField() {
  76. var ArtistCount = document.getElementsByName("artists[]").length;
  77. if (ArtistCount >= 200) {
  78. return;
  79. }
  80. var ArtistField = document.createElement("input");
  81. ArtistField.type = "text";
  82. ArtistField.id = "artist_" + ArtistCount;
  83. ArtistField.name = "artists[]";
  84. ArtistField.size = 45;
  85. var x = $('#artistfields').raw();
  86. x.appendChild(document.createElement("br"));
  87. x.appendChild(ArtistField);
  88. if ($("#artist").data("gazelle-autocomplete")) {
  89. $(ArtistField).live('focus', function() {
  90. $(ArtistField).autocomplete({
  91. serviceUrl : 'artist.php?action=autocomplete'
  92. });
  93. });
  94. }
  95. ArtistCount++;
  96. }
  97. function RemoveArtistField() {
  98. var ArtistCount = document.getElementsByName("artists[]").length;
  99. if (ArtistCount == 1) {
  100. return;
  101. }
  102. var x = $('#artistfields').raw();
  103. while (x.lastChild.tagName != "INPUT") {
  104. x.removeChild(x.lastChild);
  105. }
  106. x.removeChild(x.lastChild);
  107. x.removeChild(x.lastChild); //Remove trailing new line.
  108. ArtistCount--;
  109. }
  110. function Categories() {
  111. var cat = $('#categories').raw() ? $('#categories').raw().options[$('#categories').raw().selectedIndex].value : '';
  112. if (cat == "Movies") {
  113. $('#artist_tr').gshow();
  114. $('#cataloguenumber_tr').gshow();
  115. $('#dlsiteid_tr').ghide();
  116. } else if (cat == "Anime") {
  117. $('#artist_tr').gshow();
  118. $('#cataloguenumber_tr').ghide();
  119. $('#dlsiteid_tr').ghide();
  120. } else if (cat == "Manga") {
  121. $('#artist_tr').gshow();
  122. $('#cataloguenumber_tr').ghide();
  123. $('#dlsiteid_tr').ghide();
  124. } else if (cat == "Games") {
  125. $('#artist_tr').gshow();
  126. $('#dlsiteid_tr').gshow();
  127. $('#cataloguenumber_tr').ghide();
  128. } else {
  129. $('#artist_tr').ghide();
  130. $('#cataloguenumber_tr').ghide();
  131. $('#dlsiteid_tr').ghide();
  132. }
  133. }
  134. function add_tag() {
  135. if ($('#tags').raw().value == "") {
  136. $('#tags').raw().value = $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
  137. } else if ($('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value == "---") {
  138. } else {
  139. $('#tags').raw().value = $('#tags').raw().value + ", " + $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
  140. }
  141. }
  142. function Toggle(id, disable) {
  143. var arr = document.getElementsByName(id + '[]');
  144. var master = $('#toggle_' + id).raw().checked;
  145. for (var x in arr) {
  146. arr[x].checked = master;
  147. if (disable == 1) {
  148. arr[x].disabled = master;
  149. }
  150. }
  151. if (id == "formats") {
  152. ToggleLogCue();
  153. }
  154. }
  155. function ToggleLogCue() {
  156. var formats = document.getElementsByName('formats[]');
  157. var flac = false;
  158. if (formats[1].checked) {
  159. flac = true;
  160. }
  161. if (flac) {
  162. $('#logcue_tr').gshow();
  163. } else {
  164. $('#logcue_tr').ghide();
  165. }
  166. ToggleLogScore();
  167. }
  168. function ToggleLogScore() {
  169. if ($('#needlog').raw().checked) {
  170. $('#minlogscore_span').gshow();
  171. } else {
  172. $('#minlogscore_span').ghide();
  173. }
  174. }
  175. function JavAutofill() {
  176. var map = { cn: 'javdb',
  177. idols: 'artist',
  178. title: 'title',
  179. title_jp: 'title_jp',
  180. image: 'image',
  181. tags: 'tags',
  182. description: 'req_desc' }
  183. var cn = $('#catalogue').raw().value.toUpperCase()
  184. $.getJSON('/ajax.php?action=javfill&cn='+cn, function(data) {
  185. if (data.status != "success") {
  186. $('#catalogue').raw().value = 'Failed'
  187. return
  188. } else {
  189. $('#catalogue').raw().value = data.response.cn
  190. }
  191. for (i in data.response) {
  192. if (Array.isArray(data.response[i])) {
  193. for (j in data.response[i]) {
  194. if (i == 'idols') {
  195. if (!($('#'+map[i]+'_'+j).raw())) {
  196. AddArtistField()
  197. }
  198. $('#'+map[i]+'_'+j).raw().value = data.response[i][j]
  199. }
  200. if (map[i] == 'tags' && !($('#'+map[i]).raw().value)) {
  201. $('#'+map[i]).raw().value = data.response[i].join(', ')
  202. }
  203. }
  204. }
  205. if (map[i] && $('#'+map[i]).raw() && !($('#'+map[i]).raw().value)) {
  206. $('#'+map[i]).raw().value = data.response[i]
  207. }
  208. }
  209. })
  210. }
  211. $(document).ready(function() { Categories(); });