Advertisement
Guest User

RP

a guest
Apr 27th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.05 KB | None | 0 0
  1. // ==UserScript==
  2. // @name [743049] Easier way to send Items/Money to people! (RESPO)
  3. // @namespace http://www.torn.com/profiles.php?XID=743049
  4. // @description Quickly send items/money to multiple people. Press Shift+S to start the sending!
  5. // @updateURL http://userscripts.org/scripts/source/151357.user.js
  6. // @include https://www.torn.com/*
  7. // @include http://www.torn.com/*
  8. // @version 2.0.4
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /*
  13. This script is released for users of #Playground.
  14. Other users are welcome... but they MUST agree that #Playground is awesome!
  15. */
  16. var $ = jQuery;
  17. var storage = localStorage;
  18.  
  19. function QuickSendMoneyAndItems() {
  20. function timoutForDonators() {
  21. var n = $('#announceWrapper #announce .announceTextSubtle a[href^="donator.php?b="] > span').length;
  22. if (n > 0) return 10000; // Non-donator
  23. else return 5000; // Donator
  24. }
  25. timoutForDonators()
  26. function readSettings() {
  27. var json = storage["XORScriptSending"];
  28. var theData;
  29. if(!json) {
  30. theData =
  31. {
  32. message: []
  33. };
  34. }
  35. else {
  36. theData = eval("(" + json + ")");
  37. }
  38. return theData;
  39. }
  40. function saveSettings(theMessage) {
  41. var newData =
  42. {
  43. message: theMessage
  44. };
  45. storage["XORScriptSending"] = JSON.stringify(newData);
  46. }
  47. function readMsgHistory() {
  48. var json = storage["XORScriptSendingMsgHistory"];
  49. var theData;
  50. if(!json) {
  51. theData = [];
  52. }
  53. else {
  54. theData = eval("(" + json + ")");
  55. }
  56. return theData;
  57. }
  58. function saveMsgHistory(theMessage) {
  59. var oldData = readMsgHistory();
  60. if (!inArray(theMessage, oldData)) {
  61. oldData.splice(0,0,theMessage);
  62. if (oldData.length > 15) {
  63. oldData.splice(15,1);
  64. }
  65. }
  66. storage["XORScriptSendingMsgHistory"] = JSON.stringify(oldData);
  67. readMessageHistory();
  68. }
  69. function inArray(needle, haystack) {
  70. var length = haystack.length;
  71. for(var i = 0; i < length; i++) {
  72. if(haystack[i] == needle) return true;
  73. }
  74. return false;
  75. }
  76. function ShowHideOverlay() {
  77. if ($('#XORScriptSendingOverlayBG').length == 0) {
  78. $('body').append($(document.createElement('div')).attr("id","XORScriptSendingOverlayBG").css({background:'#000000',position:'fixed',opacity:'0.8',zIndex:'100'}));
  79. $('#XORScriptSendingOverlayBG').css({width:'0px',height:'0px',left:'50%',top:'10%'}).animate({ width:'100%', height:'100%', left:'0px', top:'0px' });
  80. $('body').append($(document.createElement('div')).attr("id","XORScriptSendingOverlayFG").css({background:'#CCC url(/images/v2/main/bg_regular.jpg) left top repeat',position:'fixed',zIndex:'102',padding:'5px'}));
  81. $('#XORScriptSendingOverlayFG').css({width:'0px',height:'0px',left:'50%',top:'10%', overflow:'auto'}).animate({ width:'80%', height:'80%', left:'10%', top:'10%' });
  82. $('#XORScriptSendingOverlayBG').bind('click', function () { ShowHideOverlay(); });
  83. updateContents()
  84. } else {
  85. $('#XORScriptSendingOverlayBG').remove();
  86. $('#XORScriptSendingOverlayFG').remove();
  87. }
  88. }
  89. function addCommas(nStr) {
  90. nStr += '';
  91. x = nStr.split('.');
  92. x1 = x[0];
  93. x2 = x.length > 1 ? '.' + x[1] : '';
  94. var rgx = /(\d+)(\d{3})/;
  95. while (rgx.test(x1)) {
  96. x1 = x1.replace(rgx, '$1' + ',' + '$2');
  97. }
  98. return x1 + x2;
  99. }
  100. var getTextNodesIn = function(el) {
  101. return $(el).find(":not(iframe)").andSelf().contents().filter(function() {
  102. return this.nodeType == 3;
  103. });
  104. };
  105. function updatePropertyList() {
  106. $.get(addRFC('properties.php?step=properties'), function (data) {
  107. var properties = new Array();
  108. $('#XORScriptMoneySendPropertyList').children().remove();
  109. $('a[title="Give this property to someone"]',$(data)).each(function () {
  110. var td = $(this).parent().parent().parent();
  111. var propName = $('p[class="title"]',$(td)).text();
  112. var propHappy = $('ul[class="info"] li:eq(3)',$(td)).text();
  113. var found=false;
  114. for (var i=0; i<properties.length; i++) {
  115. if (properties[i][0] == propName && properties[i][1] == propHappy) {
  116. properties[i][2]++;
  117. found=true;
  118. }
  119. }
  120. if (found==false) {
  121. properties[properties.length]=[propName,propHappy,1];
  122. }
  123. });
  124. // All done...
  125. $('#XORScriptMoneySendItemList,#XORScriptMoneySendItemLabel').css({display:'none'});
  126. $('#XORScriptMoneySendPropertyList,#XORScriptMoneySendPropertyLabel').css({display:'block'});
  127. for (var i=0; i<properties.length; i++) {
  128. $('#XORScriptMoneySendPropertyList').append($(document.createElement('option'))
  129. .attr({
  130. value:properties[i][1]+"-"+properties[i][0],
  131. name:properties[i][0],
  132. qty:properties[i][2]
  133. })
  134. .append($(document.createTextNode(properties[i][1] +" "+ properties[i][0] +" - "+ properties[i][2])))
  135. );
  136. }
  137.  
  138. });
  139. }
  140. function updateItemList() {
  141. $('#XORScriptMoneySendItemList').children().remove();
  142. var steps = new Array('getAllCategoryList');
  143. for (var i=0; i<steps.length; i++) {
  144. $.post(addRFC('item.php'),{'step':steps[i]}, function (data) {
  145. $('span[class="m-left10"]',$(data)).each(function () {
  146. if ($('span', this).length = 0 || $('span', this).text() == '') {
  147. var itemName = $(this).text();
  148. var itemQty = 'x1';
  149. }
  150. else {
  151. var itemQty = $('span[class="qty bold t-hide"]', $(this)).text();
  152. $('span', $(this)).remove();
  153. var itemName = $(this).text();
  154. }
  155. var itemVal = $('img',$(this).prev()).attr('src').split('?')[0].replace(/[^0-9]/g,'');
  156. $('#XORScriptMoneySendItemList').append($(document.createElement('option'))
  157. .attr({
  158. value:itemVal,
  159. name:itemName,
  160. qty:itemQty
  161. })
  162. .append($(document.createTextNode(itemName + " " + itemQty)))
  163. );
  164. });
  165. $('#XORScriptMoneySendItemList,#XORScriptMoneySendItemLabel').css({display:'block'});
  166. $('#XORScriptMoneySendPropertyList,#XORScriptMoneySendPropertyLabel').css({display:'none'});
  167. });
  168. }
  169. }
  170. function updateContents() {
  171. var storedMessage = readSettings();
  172. $('#XORScriptSendingOverlayFG').append($(document.createElement('div'))
  173. .attr('class','title-gray top-round')
  174. .append($(document.createElement('span')).text('Easily send Money, Items, or Properties - v2.0.3'))
  175. )
  176. .append($(document.createElement('div'))
  177. .attr('class','bottom-round cont-gray p10')
  178. .append($(document.createElement('p'))
  179. .text('You can easily send money, items, or properties, with this script. Simply provide the IDs of the people to send to, and the money, item, or property, that is being sent, and press the send button. Pretty easy, right? Any questions, mail ')
  180. .append($(document.createElement('a')).text('XOR').attr('href','/profiles.php?XID=743049')).append('.')
  181. )
  182. )
  183. .append('<!--div class="clear"></div-->')
  184. .append($(document.createElement('br')))
  185.  
  186. .append($(document.createElement('div')).attr('class','title-black top-round').text('Available Settings'))
  187. .append($(document.createElement('div')).attr('class','profile-container')
  188. .append($(document.createElement('table'))
  189. .css({width:'100%', height:'100%'})
  190. .attr({cellPadding:'0', cellSpacing:'0'})
  191. .append($(document.createElement('thead'))
  192. .append($(document.createElement('tr'))
  193. .append($(document.createElement('th')).css({'padding':'5px',width:'25%',textAlign:'center',verticalAlign:'top','font-weight':'bold'}).text('IDs section'))
  194. .append($(document.createElement('th')).css({'padding':'5px',width:'25%',textAlign:'center',verticalAlign:'top','font-weight':'bold'}).text('Medium to send'))
  195. .append($(document.createElement('th')).css({'padding':'5px',width:'25%',textAlign:'center',verticalAlign:'top','font-weight':'bold'}).text('Send Message'))
  196. .append($(document.createElement('th')).css({'padding':'5px',width:'25%',textAlign:'center',verticalAlign:'top','font-weight':'bold'}).text('Start sending!'))
  197. )
  198. )
  199. .append($(document.createElement('tbody'))
  200. .append($(document.createElement('tr'))
  201. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  202. .append($(document.createElement('textarea'))
  203. .css({width:'100%',height:'120px',border:'1px solid #666666',})
  204. .attr({id:'XORScriptMoneySendIDsBox'})
  205. )
  206. )
  207. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  208. .append($(document.createElement('select'))
  209. .css({width:'100%',border:'1px solid #666666'})
  210. .attr({id:'XORScriptMoneySendMoIBox'})
  211. .append($(document.createElement('option')).attr({value:'-1', selected:true }).html('Select Money OR Item...'))
  212. .append($(document.createElement('option')).attr({value:'M', selected:false}).html('Money'))
  213. .append($(document.createElement('option')).attr({value:'I', selected:false}).html('Item'))
  214. .append($(document.createElement('option')).attr({value:'P', selected:false}).html('Property'))
  215. .bind('change', function () {
  216. if ($(this).val() == "P") { updatePropertyList(); }
  217. if ($(this).val() == "I") { updateItemList(); }
  218. })
  219. )
  220. .append($(document.createElement('div'))
  221. .css({margin:'15px 0px 0px 0px'})
  222. .html('Money Value')
  223. )
  224. .append($(document.createElement('input'))
  225. .css({width:'72%',padding:'3px',margin:'1px 0px 0px 0px',border:'1px solid #666666'})
  226. .attr({id:'XORScriptMoneySendMnyBox'})
  227. )
  228. .append($(document.createElement('select'))
  229. .css({width:'24%',margin:'1px 0px 0px 0px',border:'1px solid #666666',fontSize:'140%',float:'right'})
  230. .append($(document.createElement('option')).attr({value:'-1', selected:true }).html('Quick List'))
  231. .append($(document.createElement('option')).attr({value:'100000' }).html('$100,000'))
  232. .append($(document.createElement('option')).attr({value:'150000' }).html('$150,000'))
  233. .append($(document.createElement('option')).attr({value:'200000' }).html('$200,000'))
  234. .append($(document.createElement('option')).attr({value:'250000' }).html('$250,000'))
  235. .append($(document.createElement('option')).attr({value:'300000' }).html('$300,000'))
  236. .append($(document.createElement('option')).attr({value:'500000' }).html('$500,000'))
  237. .append($(document.createElement('option')).attr({value:'750000' }).html('$750,000'))
  238. .append($(document.createElement('option')).attr({value:'1000000' }).html('$1,000,000'))
  239. .append($(document.createElement('option')).attr({value:'1500000' }).html('$1,500,000'))
  240. .append($(document.createElement('option')).attr({value:'2000000' }).html('$2,000,000'))
  241. .append($(document.createElement('option')).attr({value:'2500000' }).html('$2,500,000'))
  242. .append($(document.createElement('option')).attr({value:'3000000' }).html('$3,000,000'))
  243. .append($(document.createElement('option')).attr({value:'5000000' }).html('$5,000,000'))
  244. .append($(document.createElement('option')).attr({value:'7500000' }).html('$7,500,000'))
  245. .append($(document.createElement('option')).attr({value:'10000000' }).html('$10,000,000'))
  246. .append($(document.createElement('option')).attr({value:'15000000' }).html('$15,000,000'))
  247. .append($(document.createElement('option')).attr({value:'20000000' }).html('$20,000,000'))
  248. .append($(document.createElement('option')).attr({value:'25000000' }).html('$25,000,000'))
  249. .append($(document.createElement('option')).attr({value:'50000000' }).html('$50,000,000'))
  250. .append($(document.createElement('option')).attr({value:'100000000'}).html('$100,000,000'))
  251. .append($(document.createElement('option')).attr({value:'250000000'}).html('$250,000,000'))
  252. .append($(document.createElement('option')).attr({value:'500000000'}).html('$500,000,000'))
  253. .bind('change', function () {
  254. if ($(this).val() != '-1') { $('#XORScriptMoneySendMnyBox').val($(this).val()); }
  255. })
  256. )
  257. .append($(document.createElement('div'))
  258. .css({margin:'10px 0px 0px 0px'})
  259. .attr({id:'XORScriptMoneySendItemLabel'})
  260. .html('Possible Items')
  261. )
  262. .append($(document.createElement('select'))
  263. .css({width:'100%',margin:'1px 0px 0px 0px',border:'1px solid #666666'})
  264. .attr({id:'XORScriptMoneySendItemList'})
  265. .append($(document.createElement('option')).attr({value:'-1', selected:true }).html('Loading...'))
  266. )
  267. .append($(document.createElement('div'))
  268. .css({margin:'10px 0px 0px 0px',display:'none'})
  269. .attr({id:'XORScriptMoneySendPropertyLabel'})
  270. .html('Possible Properties')
  271. )
  272. .append($(document.createElement('select'))
  273. .css({width:'100%',margin:'1px 0px 0px 0px',border:'1px solid #666666',display:'none'})
  274. .attr({id:'XORScriptMoneySendPropertyList'})
  275. .append($(document.createElement('option')).attr({value:'-1', selected:true }).html('Loading...'))
  276. )
  277. )
  278. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  279. .append($(document.createElement('textarea'))
  280. .css({width:'100%',height:'98px',border:'1px solid #666666'})
  281. .attr({id:'XORScriptMoneySendMsgBox',value:storedMessage.message})
  282. .bind('keyup', function () { saveSettings($(this).val()); } )
  283. )
  284. .append($(document.createElement('select'))
  285. .css({width:'100%',margin:'1px 0px 0px 0px',border:'1px solid #666666'})
  286. .attr({id:'XORScriptMoneySendMsgHistory'})
  287. .append($(document.createElement('option'))
  288. .attr({value:'-1', selected:true })
  289. .html('Message History')
  290. )
  291. .bind('change', function () {
  292. if ($(this).val() != '-1') { $('#XORScriptMoneySendMsgBox').val($(this).val()); }
  293. })
  294. )
  295. )
  296. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  297. .append($(document.createElement('input'))
  298. .css({width:'100%',height:'60px','background':'#fff','border':'1px solid #666666'})
  299. .attr({value:'Start Sending',type:'submit'})
  300. .attr({id:'XORScriptMoneySendButton'})
  301. .bind('click', function () { createRowsForSending() })
  302. )
  303. .append($(document.createElement('p')).html('<br>Click the button to start sending.<br>Watch the progress below!'))
  304. .append($(document.createElement('p')).html('<br>This is re-enabled after all money/items are sent!'))
  305. )
  306. )
  307. .append($(document.createElement('tr'))
  308. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  309. .html('Type each ID on a seperate line.<br>Anything not a number [0-9] is auto-deleted.')
  310. )
  311. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  312. .html('Select money, item or property.<br>Then type money or select item/property to send!')
  313. )
  314. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  315. .html('Type the message to send with item/money.<br>This will be sent to every ID listed!')
  316. )
  317. .append($(document.createElement('td')).css({'padding':'5px','text-align':'center','vertical-align':'top'})
  318. .html('Time between sending items: '+(timoutForDonators()/1000)+' seconds')
  319. )
  320. )
  321. )
  322. )
  323. ).append($(document.createElement('br')))
  324. .append($(document.createElement('table'))
  325. .css({width:'100%'})
  326. .attr({class:'data', cellPadding:'0', cellSpacing:'1'})
  327. .append($(document.createElement('thead'))
  328. .append($(document.createElement('tr'))
  329. .attr({class:'title-black top-round'})
  330. .append($(document.createElement('th')).html('User ID').css({width:'80px'}))
  331. .append($(document.createElement('th')).html('Sending'))
  332. .append($(document.createElement('th')).html('Message'))
  333. .append($(document.createElement('th')).html('Status').css({width:'100px'}))
  334. )
  335. )
  336. .append($(document.createElement('tbody'))
  337. .attr({id:'XORScriptSendingMoneyQueue'})
  338. )
  339. )
  340. readMessageHistory();
  341. updateItemList();
  342. }
  343. function readMessageHistory() {
  344. var history = readMsgHistory();
  345. $('#XORScriptMoneySendMsgHistory').empty().append($(document.createElement('option')).attr({value:'-1', selected:true }).html('Message History'));
  346. for (var i=0; i<history.length; i++) {
  347. $('#XORScriptMoneySendMsgHistory').append('<option>'+history[i]+'</option>');
  348. }
  349. }
  350. function createRowsForSending() {
  351. $('#XORScriptMoneySendIDsBox').val($('#XORScriptMoneySendIDsBox').val().replace(/[^0-9\n]/g, '').replace(/\n\n/g, "\n"));
  352. while ($('#XORScriptMoneySendIDsBox').val().indexOf("\n\n") != -1) {
  353. $('#XORScriptMoneySendIDsBox').val($('#XORScriptMoneySendIDsBox').val().replace(/[^0-9\n]/g, '').replace(/\n\n/g, "\n"));
  354. }
  355. if ($('#XORScriptMoneySendMoIBox').val() == '-1') {
  356. alert('Please select Money or Item to be sent!');
  357. } else {
  358. // Save the message to history
  359. saveMsgHistory($('#XORScriptMoneySendMsgBox').val());
  360. if ($('#XORScriptMoneySendMoIBox').val() == 'M') {
  361. var sending = '$'+addCommas($('#XORScriptMoneySendMnyBox').val().replace(/[^0-9]/g, ''));
  362. } else if ($('#XORScriptMoneySendMoIBox').val() == 'I') {
  363. var sending = $('#XORScriptMoneySendItemList option[value="'+$('#XORScriptMoneySendItemList').val()+'"]').attr('name');
  364. } else if ($('#XORScriptMoneySendMoIBox').val() == 'P') {
  365. var sending = $('#XORScriptMoneySendPropertyList option[value="'+$('#XORScriptMoneySendPropertyList').val()+'"]').attr('name');
  366. }
  367. $('#XORScriptSendingMoneyQueue').prepend($(document.createElement('tr'))
  368. .attr({class:'bgNewsPaper'})
  369. .append($(document.createElement('td')).html('Processing above IDs...').attr({colSpan:'4'}))
  370. );
  371. var userIDs = $('#XORScriptMoneySendIDsBox').val().split('\n');
  372. for (var i=(userIDs.length-1); i>=0; i--) {
  373. if (userIDs[i] != "") {
  374. $('#XORScriptSendingMoneyQueue').prepend($(document.createElement('tr'))
  375. .attr({class:'bgAlt'+((i%2)+1)})
  376. .append($(document.createElement('td')).html(userIDs[i]))
  377. .append($(document.createElement('td')).html(sending))
  378. .append($(document.createElement('td')).html($('#XORScriptMoneySendMsgBox').val()))
  379. .append($(document.createElement('td')).html('Queued'))
  380. .append($(document.createElement('div'))
  381. .css({display:'none'})
  382. .attr({
  383. 'userid':userIDs[i],
  384. 'MyorIt':$('#XORScriptMoneySendMoIBox').val(),
  385. 'money':$('#XORScriptMoneySendMnyBox').val().replace(/[^0-9]/g, ''),
  386. 'itemID':$('#XORScriptMoneySendItemList').val(),
  387. 'propID':$('#XORScriptMoneySendPropertyList').val(),
  388. 'msg':$('#XORScriptMoneySendMsgBox').val()
  389. })
  390. )
  391. );
  392. }
  393. }
  394. $('#XORScriptMoneySendIDsBox').attr({disabled:true});
  395. $('#XORScriptMoneySendButton').attr({disabled:true});
  396. $('#XORScriptSendingMoneyQueue div').each(function () {
  397. if ($(this).attr('MyorIt') == 'M') {
  398. saveMoney($(this).attr('userid'), $(this).attr('money'), $(this).attr('msg'), $(this).parent());
  399. } else if ($(this).attr('MyorIt') == 'P') {
  400. saveProp($(this).attr('userid'), $(this).attr('propID'), $(this).attr('msg'), $(this).parent());
  401. } else {
  402. saveItem($(this).attr('userid'), $(this).attr('itemID'), $(this).attr('msg'), $(this).parent());
  403. }
  404. });
  405. sendProp(0);
  406. }
  407. }
  408. var moneyToSend = new Array();
  409. var itemsToSend = new Array();
  410. var propsToSend = new Array();
  411. function saveMoney(userID, money, msg, TR) {
  412. moneyToSend[moneyToSend.length] = new Array(userID, money, msg, TR);
  413. }
  414. function saveItem (userID, itemID, msg, TR) {
  415. itemsToSend[itemsToSend.length] = new Array(userID, itemID, msg, TR);
  416. }
  417. function saveProp (userID, propID, msg, TR) {
  418. propsToSend[propsToSend.length] = new Array(userID, propID, msg, TR);
  419. }
  420.  
  421. function sendProp(arrayInc) {
  422. if (propsToSend.length > arrayInc) {
  423. userID = propsToSend[arrayInc][0];
  424. property = propsToSend[arrayInc][1];
  425. message = propsToSend[arrayInc][2];
  426. TR = propsToSend[arrayInc][3];
  427. updateQueuedItemStatusSending(TR);
  428. $.get(addRFC('properties.php?step=properties'), function (data) {
  429. var found=false;
  430. $('#XORScriptMoneySendPropertyList').children().remove();
  431. $('a[title="Give this property to someone"]',$(data)).each(function () {
  432. var td = $(this).parent().parent().parent();
  433. var propName = $('p[class="title"]',$(td)).text();
  434. var propHappy = $('ul[class="info"] li:eq(3)',$(td)).text();
  435.  
  436. if (found==false) {
  437. if (property == (propHappy+"-"+propName)) {
  438. // Start sending item.
  439. $.post(addRFC('properties.php'),{'userID':userID,'ID':$(this).attr('href').replace(/[^0-9]/g,''),'step':'giveProperty'}, function (str) {
  440. var msg = JSON.parse(str);
  441. if (msg.success == false)
  442. msg.text="ERROR: "+userID+" - "+msg.text;
  443. updateQueuedItemResult(TR, msg.text)
  444. if (propsToSend.length > (arrayInc+1)) { updateQueuedItemStatusProcessing(propsToSend[arrayInc+1][3]); }
  445. setTimeout(function () { sendProp(arrayInc+1); }, timoutForDonators());
  446. });
  447. found=true;
  448. }
  449. }
  450. });
  451. });
  452. } else {
  453. sendMoney(0);
  454. }
  455. }
  456. function sendMoney(arrayInc) {
  457. if (moneyToSend.length > arrayInc) {
  458. userID = moneyToSend[arrayInc][0];
  459. money = moneyToSend[arrayInc][1];
  460. message = moneyToSend[arrayInc][2];
  461. TR = moneyToSend[arrayInc][3];
  462. updateQueuedItemStatusSending(TR);
  463. // getAction is a Torn coded function. No torn, no function, but also no need to run this script.
  464. getAction({
  465. type: "post",
  466. action: 'sendcash.php',
  467. data: [{name:'money',value:money},{name:'tag',value:message},{name:'ID',value:userID},{name:'send',value:'SEND'},{name:'theanon',value:'0'},{name: 'step', value: 'cash'}],
  468. success: function(str) {
  469. getAction({
  470. type: "post",
  471. action: 'sendcash.php',
  472. data: [{name:'money',value:money},{name:'tag',value:message},{name:'ID',value:userID},{name:'send',value:'SEND'},{name:'theanon',value:'0'},{name: 'step', value: 'cash1'}],
  473. success: function(str) {
  474. var msg = JSON.parse(str);
  475. if (msg.success == false)
  476. msg.text="ERROR: "+userID+" - "+msg.text;
  477. updateQueuedItemResult(TR, msg.text)
  478. if (moneyToSend.length > (arrayInc+1)) { updateQueuedItemStatusProcessing(moneyToSend[arrayInc+1][3]); }
  479. setTimeout(function () { sendMoney(arrayInc+1); }, timoutForDonators());
  480. }
  481. });
  482. }
  483. });
  484. } else {
  485. sendItem(0);
  486. }
  487. }
  488. function sendItem(arrayInc) {
  489. if (itemsToSend.length > arrayInc) {
  490. userID = itemsToSend[arrayInc][0];
  491. itemID = itemsToSend[arrayInc][1];
  492. message = itemsToSend[arrayInc][2];
  493. TR = itemsToSend[arrayInc][3];
  494. updateQueuedItemStatusSending(TR);
  495. $.post(addRFC('item.php'),{'step':'actionForm','id':itemID,'type':'item','action':'send'}, function (data) {
  496. getAction({
  497. type: "post",
  498. action: '/item.php',
  499. data: {'itemID': itemID, 'tag': message, 'userID': userID, 'step':'sendItemAction', 'confirm':'1' },
  500. success: function(str) {
  501. var msg = JSON.parse(str);
  502. if (msg.success == false)
  503. msg.text="ERROR: "+userID+" - "+msg.text;
  504. updateQueuedItemResult(TR, msg.text)
  505. if (itemsToSend.length > (arrayInc+1)) { updateQueuedItemStatusProcessing(itemsToSend[arrayInc+1][3]); }
  506. setTimeout(function () { sendItem(arrayInc+1); }, timoutForDonators());
  507. }
  508. });
  509. });
  510. } else {
  511. // All done!
  512. $('#XORScriptMoneySendIDsBox').attr({disabled:false});
  513. $('#XORScriptMoneySendButton').attr({disabled:false});
  514. $('#XORScriptMoneySendIDsBox').val('');
  515. moneyToSend = new Array();
  516. itemsToSend = new Array();
  517. propsToSend = new Array();
  518. }
  519. }
  520. function updateQueuedItemResult(TR, msg) {
  521. $(TR).html('<td colspan="4">'+msg+'</td>');
  522. }
  523. function updateQueuedItemStatusProcessing(TR) {
  524. $('td:nth-child(4)', $(TR)).html('Processing').fadeTo(timoutForDonators()/3, 0.3, function() {
  525. $(this).attr('class', 'bgAlt5');
  526. }).fadeTo(timoutForDonators()/3, 1);
  527. }
  528. function updateQueuedItemStatusSending(TR) {
  529. $('td:nth-child(4)', $(TR)).html('Sending');
  530. }
  531. function awaitOverlayPrompt() {
  532. $('body').keypress(function(key) {
  533. if (key.which == 83 && key.shiftKey == true) {
  534. if (key.target.tagName.toLowerCase() != "textarea" && key.target.tagName.toLowerCase() != "input")
  535. ShowHideOverlay();
  536. }
  537. });
  538. }
  539. awaitOverlayPrompt();
  540. }
  541. $(document).ready(function () {
  542. QuickSendMoneyAndItems();
  543. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement