Guest User

Untitled

a guest
Jul 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.84 KB | None | 0 0
  1.  
  2.  
  3. See sample attached.
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. function submitTicketXml() {
  12.  
  13. trace("submitTicketXml");
  14.  
  15. //compose Ticket xml file send to server receive response
  16.  
  17. resetTicketTextFields();
  18.  
  19. runners = runnerSelect;
  20.  
  21. //Test this
  22.  
  23. //bet = amountSelect;
  24.  
  25. trace("_level0.bet_screen_mc.amounts_mc.amountText :"+_level0.bet_screen_mc.amounts_mc.amountText);
  26.  
  27. bet = _level0.bet_screen_mc.amounts_mc.amountText;
  28.  
  29.  
  30.  
  31.  
  32.  
  33. race_id = raceIdSelect;
  34.  
  35. //verify ticket info
  36.  
  37. if (verifyTicketInfo()) {
  38.  
  39. //generate Ticket xml to send to validateTicket
  40.  
  41. _global.myXML = new XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  42.  
  43. // var xmlVernode:XMLNode = _global.myXML.createElement("<?xml version=""1.0"" encoding=""UTF-8""?>");
  44.  
  45. var wagernode:XMLNode = _global.myXML.createElement("wager");
  46.  
  47. //
  48.  
  49. var license_accountnode:XMLNode = _global.myXML.createElement("license_account");
  50.  
  51. var license_playernode:XMLNode = _global.myXML.createElement("license_player");
  52.  
  53. var wager_profilenode:XMLNode = _global.myXML.createElement("wager_profile");
  54.  
  55. var ticketnode:XMLNode = _global.myXML.createElement("ticket");
  56.  
  57. var textnode:XMLNode = _global.myXML.createTextNode("descr here");
  58.  
  59. //
  60.  
  61. //_global.myXML.appendChild(xmlVernode);
  62.  
  63. _global.myXML.appendChild(wagernode);
  64.  
  65. wagernode.appendChild(license_accountnode);
  66.  
  67. wagernode.appendChild(license_playernode);
  68.  
  69. wagernode.appendChild(wager_profilenode);
  70.  
  71. wagernode.appendChild(ticketnode);
  72.  
  73. ticketnode.appendChild(textnode);
  74.  
  75. //
  76.  
  77. _global.myXML.firstChild.attributes.id = "2";
  78.  
  79. _global.myXML.firstChild.attributes.license_reference = "1";
  80.  
  81. _global.myXML.firstChild.firstChild.attributes.password = "gertner";
  82.  
  83. _global.myXML.firstChild.firstChild.attributes.username = "rgertner";
  84.  
  85. _global.myXML.firstChild.firstChild.nextSibling.attributes.id = "xxxx";
  86.  
  87. _global.myXML.firstChild.firstChild.nextSibling.attributes.balance = "99.00";
  88.  
  89. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.attributes.id = "1";
  90.  
  91. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.boxed = boxed;
  92.  
  93. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.bet = Math.round(bet);
  94.  
  95. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.runners = runners;
  96.  
  97. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.bet_type = _global.bet_type;
  98.  
  99. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.race_id = race_id;
  100.  
  101. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.cost_discounted = "-";
  102.  
  103. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.cost_actual = "-";
  104.  
  105. _global.myXML.firstChild.firstChild.nextSibling.nextSibling.nextSibling.attributes.cost_estimated = "-";
  106.  
  107. trace("myXML to send is : "+myXML);
  108.  
  109. //trace("*****************************");
  110.  
  111. /*
  112.  
  113. <?xml version="1.0"?>
  114.  
  115. <wager id="1" license_reference="1">
  116.  
  117. <license_account username="rgertner" password="rgertner"/>
  118.  
  119. <license_player id="xxxx" balance="99.00"/>
  120.  
  121. <wager_profile id="1"/>
  122.  
  123. <ticket cost_estimated="999.0" cost_actual="0.00" cost_discounted="0.00" race_id="1" bet_type="2" runners="1,2" bet="2" boxed="0">descr here</ticket>
  124.  
  125. </wager>
  126.  
  127.  
  128.  
  129. reply:
  130.  
  131. <?xml version="1.0" encoding="UTF-8"?>
  132.  
  133. <wager_response page_id="1175101304234">
  134.  
  135. <balance license="0" player="99.0" />
  136.  
  137. <ticket id="0" status="0">
  138.  
  139. <description>Rainbow 2007-03-28 Race 1 100.0 Win 1,2</description>
  140.  
  141. <ticket_cost actual="200.0" estimated="200.0" />
  142.  
  143. <ticket_parts>
  144.  
  145. <part bet_type="1" cost="100.0" id="0" runners="1" status="0" />
  146.  
  147. <part bet_type="1" cost="100.0" id="0" runners="2" status="0" />
  148.  
  149. </ticket_parts>
  150.  
  151. </ticket>
  152.  
  153. </wager_response>
  154.  
  155. */
  156.  
  157.  
  158.  
  159. _global.myReply_xml = new XML();
  160.  
  161. _global.myReply_xml.ignoreWhite = true;
  162.  
  163. _global.myReply_xml.onLoad = function(success) {
  164.  
  165. //trace("_global.myReplyOnLoad running");
  166.  
  167. if (success) {
  168.  
  169. //trace(myReply_xml);
  170.  
  171. //test = "THIS IS RESPONSE : "+_global.myReply_xml;
  172.  
  173. _level0.ticket_mc.confirm_btn.enabled = true;
  174.  
  175. _level0.ticket_mc.confirm_btn.useHandCursor = true;
  176.  
  177. _root.xmlLoading._visible = false;
  178.  
  179. //switching because we are calling this from two different places
  180.  
  181. switch (_global.ticketConfirm) {
  182.  
  183. case true :
  184.  
  185. _level0.ticket_mc.gotoAndStop(2);
  186.  
  187. _global.ticketConfirm = false;
  188.  
  189. break;
  190.  
  191. case false :
  192.  
  193. _level0.ticket_mc._visible = true;
  194.  
  195. _level0.ticket_mc.gotoAndStop(1);
  196.  
  197. break;
  198.  
  199. default :
  200.  
  201. trace("Specify _global.ticketConfirm");
  202.  
  203. break;
  204.  
  205. }
  206.  
  207. for (var n = 0; n<myReply_xml.firstChild.childNodes.length; n++) {
  208.  
  209. if (myReply_xml.firstChild.childNodes[n].nodeName == "msg") {
  210.  
  211. wagMessage = myReply_xml.firstChild.childNodes[n].firstChild;
  212.  
  213. _level0.ticket_mc.wagMessage = wagMessage;
  214.  
  215. }
  216.  
  217.  
  218.  
  219. //
  220.  
  221. if (myReply_xml.firstChild.childNodes[n].nodeName == "balance") {
  222.  
  223. balance = myReply_xml.firstChild.childNodes[n].attributes.player;
  224.  
  225. _level0.ticket_mc.balance = balance;
  226.  
  227. }
  228.  
  229. if (myReply_xml.firstChild.childNodes[n].nodeName == "ticket") {
  230.  
  231. ticket_status = myReply_xml.firstChild.childNodes[n].attributes.status;
  232.  
  233. if (ticket_status != 0) {
  234.  
  235. //ticket has a problem , disable confirm
  236.  
  237. _level0.ticket_mc.confirm_btn.enabled = false;
  238.  
  239. }
  240.  
  241. //reformat ticket
  242.  
  243. ticket_bet_amount = myReply_xml.firstChild.childNodes[n].attributes.bet_amount;
  244.  
  245. ticket_bet_type = myReply_xml.firstChild.childNodes[n].attributes.bet_type;
  246.  
  247. ticket_runners = myReply_xml.firstChild.childNodes[n].attributes.runners;
  248.  
  249. _level0.ticket_mc.runners=ticket_runners;
  250.  
  251. _level0.ticket_mc.bet_type=ticket_bet_type;
  252.  
  253. _level0.ticket_mc.bet_amount=ticket_bet_amount;
  254.  
  255.  
  256.  
  257. //////////////////
  258.  
  259. license_reference = myReply_xml.firstChild.childNodes[n].attributes.license_reference;
  260.  
  261. _level0.ticket_mc.reference = license_reference;
  262.  
  263.  
  264.  
  265. race = myReply_xml.firstChild.childNodes[n].firstChild;
  266.  
  267. if (race != null) {
  268.  
  269. track_name = race.attributes.track_name;
  270.  
  271.  
  272.  
  273. date = race.attributes.date;
  274.  
  275. card_no = race.attributes.card_no;
  276.  
  277. race_no = race.attributes.race_no;
  278.  
  279. _level0.ticket_mc.date = date;
  280.  
  281. _level0.ticket_mc.card_no=card_no;
  282.  
  283. _level0.ticket_mc.race_no=race_no;
  284.  
  285. _level0.ticket_mc.track_name=track_name;
  286.  
  287.  
  288.  
  289. }
  290.  
  291.  
  292.  
  293. description = myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.firstChild;
  294.  
  295. if (description != null) {
  296.  
  297. _level0.ticket_mc.description = description;
  298.  
  299. }
  300.  
  301. cost_estimated = myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.attributes.estimated;
  302.  
  303. _level0.ticket_mc.cost = cost_estimated;
  304.  
  305. //number of bets:
  306.  
  307. if (myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nodeName=="ticket_parts")
  308.  
  309. {
  310.  
  311. bet_num=myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.childNodes.length;
  312.  
  313. _level0.ticket_mc.bet_num = bet_num;
  314.  
  315.  
  316.  
  317.  
  318.  
  319. }
  320.  
  321. else {
  322.  
  323. trace("Ticket_Parts not found in xml");
  324.  
  325. _level0.ticket_mc.confirm_btn.enabled = false;
  326.  
  327.  
  328.  
  329. // bet_num=myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.childNodes.length;
  330.  
  331.  
  332.  
  333.  
  334.  
  335. _level0.ticket_mc.bet_num = "0";
  336.  
  337.  
  338.  
  339. }
  340.  
  341. //tcktMessage = myReply_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.firstChild;
  342.  
  343. //_level0.ticket_mc.tcktMessage = tcktMessage;
  344.  
  345.  
  346.  
  347. referenceNo = myReply_xml.firstChild.childNodes[n].attributes.id;
  348.  
  349. _level0.ticket_mc.reference = referenceNo;
  350.  
  351.  
  352.  
  353. //messages
  354.  
  355. for (var j = 0; j<myReply_xml.firstChild.childNodes[n].childNodes.length; j++) {
  356.  
  357. if (myReply_xml.firstChild.childNodes[n].childNodes[j].nodeName == "msg") {
  358.  
  359. //trace("msg "+myReply_xml.firstChild.childNodes[n].childNodes[j].firstChild);
  360.  
  361. tcktMessage = myReply_xml.firstChild.childNodes[n].childNodes[j].firstChild;
  362.  
  363. //fixing multiline
  364.  
  365. tcktMessage=String(tcktMessage).split("\n").join("");
  366.  
  367. tcktMessage=String(tcktMessage).split(" ").join(" ");
  368.  
  369. _level0.ticket_mc.tcktMessage = tcktMessage;
  370.  
  371. }
  372.  
  373. }
  374.  
  375. }
  376.  
  377. //if (myReply_xml.firstChild.childNodes[n].nodeName == "wager_profile"){
  378.  
  379. // referenceNo = myReply_xml.firstChild.childNodes[n].attributes.id;
  380.  
  381. // _level0.ticket_mc.reference = referenceNo;
  382.  
  383. // trace("referenceNo"+referenceNo);
  384.  
  385. //}
  386.  
  387. //fix it
  388.  
  389. ///////////////////////////////////////_root.blockmc._visible = true;
  390.  
  391. }
  392.  
  393. } else {
  394.  
  395.  
  396.  
  397. displayError("submitTicketXml - can not load myReply_xml - URL:"+_global.validateWagerUrl);
  398.  
  399.  
  400.  
  401. }
  402.  
  403. };
  404.  
  405. _global.myXML.sendAndLoad(_global.validateWagerUrl, _global.myReply_xml);
  406.  
  407. }
  408.  
  409. }
Add Comment
Please, Sign In to add comment