Advertisement
dcomicboy

proracer.js?342342

Jan 26th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.54 KB | None | 0 0
  1. var TRUE = true;
  2. var loading = '<div style="text-align: center"><h2>Loading..</h2></div>';
  3. var mostRecentAjax;
  4. var timeDiff = 0;
  5.  
  6. function initTimeOffset(){
  7. var curTime = new Date;
  8. //mconsole('JS time: ' + curTime.getTime() + ' Server time: ' + (pageVars.server_time * 1000));
  9. timeDiff = curTime.getTime() - (pageVars.server_time * 1000);
  10. }
  11.  
  12. initTimeOffset();
  13. function goto(path){
  14. top.location = pageVars.app_path + '/' + path;
  15. }
  16.  
  17. function hashLink(){
  18. if(window.location != window.parent.location && $(this).attr('reddir')){
  19. if(pageVars.signed_request){
  20. var hasQuery = new RegExp("\\?", "g");
  21. var append = ($(this).attr('reddir').search(hasQuery) != -1 ? '&' : '?') + "signed_request=" + encodeURIComponent(pageVars.signed_request);
  22. document.location = $(this).attr('reddir') + append;
  23. } else {
  24. document.location = $(this).attr('reddir');
  25. }
  26. top.location.hash = '/' + pageVars.fb_path + $(this).attr('reddir');
  27. return false;
  28. }
  29. }
  30.  
  31. function reloadFrame(){
  32. document.location = document.location;
  33. }
  34. var initIng = false;
  35. $(document).ready(function() { //TODO: Move some of these to proapps.js + obfuscate
  36. if(!initIng){
  37. initIng = true;
  38. setInterval('adjust();', 1000);
  39. start_load();
  40. $(document).ajaxSend(function(event, request, settings) { //COOKIE FIXER?
  41. start_load();
  42. mconsole('appending auth to ajax request');
  43. if (typeof(pageVars.proapps_hash) == "undefined") return;
  44. // settings.data is a serialized string like "foo=bar&baz=boink" (ornull)
  45. settings.data = settings.data || "";
  46. settings.data += (settings.data ? "&" : "") + "proapps_hash=" + encodeURIComponent(pageVars.proapps_hash);
  47. settings.data += (settings.data ? "&" : "") + "proapps_uid=" + encodeURIComponent(pageVars.proapps_uid);
  48. //if there's a urlparam for code/state
  49. if(pageVars.signed_request){
  50. settings.data += (settings.data ? "&" : "") + "signed_request=" + encodeURIComponent(pageVars.signed_request);
  51. }
  52. });
  53.  
  54. $('body').ajaxSuccess(function(event, request, options){
  55. if (options.dataType == 'json') {
  56. var data = eval('(' + request.responseText + ')');
  57. // i has teh datas!
  58. //Global listeners--- commands to pass along with any ajax JSON response
  59. mconsole('Logging AJAXRESPONSE');
  60. if(data.drupal_messages){
  61. $.each(data.drupal_messages.status, function(inx, msgtxt){
  62. mconsole('System: ' + msgtxt);
  63. popupMessage('<div class="system-message">' + msgtxt + '</span>', true, 'opaque');
  64. });
  65.  
  66. }
  67. if(data.authlink){
  68. console.log('authlink');
  69. top.location = data.authlink;
  70. }
  71. mostRecentAjax = data; //for debugging
  72. if(data.goto){
  73. console.log('goto');
  74. goto(data.goto);
  75. }
  76. if(data.nextpage){
  77. document.location = + '/' + data.nextpage;
  78. }
  79. if(data.money){
  80. updateMoney(data.money);
  81. }
  82. if(data.user_unlocked){
  83. pageVars.user_unlocked = data.user_unlocked;
  84. }
  85. if(data.message){
  86. messageInsert(data.message);
  87. }
  88. if(data.refresh_page){
  89. mconsole('Whattttt');
  90. document.location.reload();
  91. }
  92. if(data.div1){
  93. $('#' + data.div1).html(data.fbml_div1_content);
  94. }
  95. if(data.div2){
  96. $('#' + data.div2).html(data.fbml_div2_content);
  97. }
  98. if(data.div3){
  99. $('#' + data.div3).html(data.fbml_div3_content);
  100. }
  101. if(data.div4){
  102. $('#' + data.div4).html(data.fbml_div4_content);
  103. }
  104. if(data.div5){
  105. $('#' + data.div5).html(data.fbml_div5_content);
  106. }
  107. if(data.div6){
  108. $('#' + data.div6).html(data.fbml_div6_content);
  109. }
  110. if(data.div7){
  111. $('#' + data.div7).html(data.fbml_div7_content);
  112. }
  113. if(data.div8){
  114. $('#' + data.div8).html(data.fbml_div8_content);
  115. }
  116. $('.racebutton').unbind('click').click(raceClick);
  117. $('.garage_car, .garage_top_current_image').unbind('click').click(carMenu);
  118. FB.XFBML.parse();
  119. fixtimezones();
  120. end_load();
  121. }
  122. });
  123. if(pageVars.drupal_user){
  124. mconsole('Drupal user logged in, uid: ' + pageVars.drupal_user);
  125. }
  126.  
  127. initPopups();
  128. end_load();
  129. }
  130. });
  131.  
  132. function initPopups(){
  133. $('.popuplink').unbind('click').click(hiddenPopUp);
  134. }
  135.  
  136. function hiddenPopUp(evt){
  137. var popupKey = $(this).attr('key');
  138. $('.popup_main_container').hide();
  139. if(popupKey){
  140. $(this).parents('div').eq(0).after($('#'+popupKey));
  141. var popup = $('#'+popupKey).show();
  142.  
  143. var pheight = popup.find('.popup_advanced').height();
  144. var top = evt.pageY - parseInt(pheight/2);
  145. if(top + pheight > $(document).height()){
  146. top = $(document).height() - pheight - 30;
  147. }
  148. console.log(top + ' ' + $(document).height() + ' ' + pheight)
  149. popup.css('top', top);
  150. }
  151. adjust();
  152. return false;
  153. }
  154.  
  155.  
  156. function updateMoney(money){
  157. var diff = parseInt(money) - parseInt($('.money').text().replace('$', '').replace(/\,/g, ''));
  158. mconsole('Money changed by ' + diff);
  159. $('.money').text('$' + number_format(money, 0, '.', ','));
  160. $('.money').textUp('$' + number_format(Math.abs(diff), 0, '.', ','), diff > 0 ? '#228622' : '#ff0000');
  161.  
  162. pageVars.money = money;
  163. }
  164.  
  165. //Single notification message
  166. function popupMessage(message, modal, extraclass){
  167. var msgPopup = $('<div class="popupmsg ' + extraclass + '"></div>');
  168. msgPopup.html(message);
  169. $('.content-area').append(msgPopup);
  170. var closeButton = $('<div class="message-close">X</div>');
  171. msgPopup.append(closeButton);
  172. msgPopup.css('height', '1px');
  173. closeButton.click(closeParentPopup);
  174. msgPopup.find('.closeme').click(closeParentPopup);
  175. msgPopup.animate({'height' : Math.max(msgPopup.children().height(), 100) +'px' , 'opacity' : 1});
  176.  
  177. if(!modal){
  178. //add timer to close/fade
  179. msgPopup.oneTime(6000, 'popupclose', closePopUp);
  180. } //otherwise user will have to X out of it
  181.  
  182. }
  183.  
  184. function closeParentPopup(){
  185. $(this).parents('.popupmsg').animate({'height' : '1px', 'opacity' : .1}, 700, null, function(){
  186. $(this).remove();
  187. });
  188. }
  189.  
  190. function closePopUp(){
  191.  
  192. $(this).animate({'height' : '1px', 'opacity' : .1}, 700, null, function(){
  193. $(this).remove();
  194. });
  195. }
  196.  
  197. function theme_image_remote(path){
  198. return '<img src="' + pageVars.image_root + '/' + path +'" />';
  199. }
  200.  
  201. function captionTip(evt){
  202. showHTip(evt, $('<div>' + $(this).attr('caption') + '</div>'), $(this));
  203. }
  204.  
  205.  
  206.  
  207.  
  208. function theme_like_button(pageurl){
  209. if(pageurl){
  210. return '<div class="littlelike"><fb:like href="' + pageurl + '" send="false" layout="button_count" width="150" show_faces="false" font="lucida grande"></fb:like></div>';
  211. } else {
  212. return '';
  213. }
  214. }
  215.  
  216. function number_format( number, decimals, dec_point, thousands_sep ) {
  217.  
  218.  
  219. var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
  220. var d = dec_point == undefined ? "," : dec_point;
  221. var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
  222. var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
  223.  
  224. return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
  225. }
  226.  
  227.  
  228. function countProperties(obj) {
  229. var prop;
  230. var propCount = 0;
  231.  
  232. for (prop in obj) {
  233. propCount++;
  234. }
  235. return propCount;
  236. }
  237.  
  238. jQuery.fn.blink = function(times) {
  239.  
  240. $(this).each(function(key, val){
  241. $(val).everyTime(500, function(){
  242. $(this).toggleClass('active');
  243. }, times);
  244. });
  245. return this;
  246. };
  247.  
  248. jQuery.fn.textUp = function(text, color) {
  249. $(this).each(function(key, val){
  250. //get current item
  251. var sourceBlock = $(val);
  252. var container = sourceBlock.parent();
  253. container.css('overflow', 'visible'); //DANGEROUS
  254. var newThing = $('<span class="popblock">' + (text ? text : sourceBlock.text()) + '</span>');
  255. $(container).append(newThing);
  256. newThing.css(sourceBlock.position()).css({'z-index' : 100, 'opacity' : 1, 'margin-left' : '0em', 'color' : color ? color : '#ffffff'}).animate({'top' : sourceBlock.position().top - 40, 'opacity' : 0 }, 1300, 'linear', function(){$(this).remove() });
  257.  
  258. });
  259. return this;
  260. };
  261.  
  262. //Mouse tooltip showers and controllers
  263.  
  264.  
  265.  
  266. var hTip;
  267. function showHTip(evt, content, thisAlt){
  268. var targetEl = thisAlt ? thisAlt : $(this);
  269. //mconsole('hovertooltip init');
  270. $('.tooltip').remove();
  271. if(content){
  272. targetEl.click(hoverOut);
  273. hTip = $('<div class="tooltip"></div>');
  274. hTip.append($(content));
  275. $('body').append(hTip);
  276. hTip.attr('hTip', 'true');
  277. hTip.css('left', parseInt(evt.pageX) + 2);
  278. hTip.css('top', parseInt(evt.pageY) + 2);
  279. hTip.css('opacity', '0.9');
  280. hTip.css('display', 'none');
  281. hTip.attr('parentCell', targetEl.attr('id'));
  282. hTip.show();
  283. //hTip.fadeIn(100); //Maybe this is slow
  284.  
  285. targetEl.mousemove(tipfollow);
  286.  
  287. //mconsole('htip finish');
  288. }
  289. }
  290.  
  291. function tipfollow(evt){
  292.  
  293. //there already is one.. let's just make it follow the mouse
  294. hTip.css('left', parseInt(evt.pageX) + 2);
  295. hTip.css('top', parseInt(evt.pageY) + 2);
  296. }
  297.  
  298. function hoverOut(){
  299. if(hTip){
  300. //mconsole('Out');
  301. $('#' + hTip.attr('parentCell')).unbind('mousemove').unbind('click', hoverOut);
  302. hTip.remove();
  303. }
  304. }
  305.  
  306. function bucket_refillfp(){
  307. $.ajax({
  308. type: "POST",
  309. url: "/ajax/bucketrefillfp",
  310. dataType : 'json',
  311. data : {'proracer' : true},
  312. success : function(data) {
  313. loaderStop();
  314. }
  315. });
  316. }
  317.  
  318. function agent(){
  319. $.ajax({
  320. type: "POST",
  321. url: "/ajax/agent",
  322. dataType : 'json',
  323. data : {'proracer' : true},
  324. success : function(data) {
  325. loaderStop();
  326. }
  327. });
  328. }
  329.  
  330. function rpgetmoney(){
  331. $.ajax({
  332. type: "POST",
  333. url: "/ajax/rpgetmoney",
  334. dataType : 'json',
  335. data : {'proracer' : true},
  336. success : function(data) {
  337. loaderStop();
  338. }
  339. });
  340. }
  341.  
  342. function rpbuycar(ctid){
  343. $.ajax({
  344. type: "POST",
  345. url: "/ajax/rpbuycar",
  346. dataType : 'json',
  347. data : {'ctid':ctid},
  348. success : function(data) {
  349. loaderStop();
  350. }
  351. });
  352. }
  353.  
  354. function rpbuycarverify(ctid){
  355. $.ajax({
  356. type: "POST",
  357. url: "/ajax/rpbuycarverify",
  358. dataType : 'json',
  359. data : {'ctid':ctid},
  360. success : function(data) {
  361. loaderStop();
  362. }
  363. });
  364. }
  365.  
  366. function bucket_perm(){
  367. $.ajax({
  368. type: "POST",
  369. url: "/ajax/bucketperm",
  370. dataType : 'json',
  371. data : {'proracer' : true},
  372. success : function(data) {
  373. loaderStop();
  374. }
  375. });
  376. }
  377.  
  378. function teamcommentbox(tid){
  379. $.ajax({
  380. type: "POST",
  381. url: "/ajax/teamcommentbox",
  382. dataType : 'json',
  383. data : {'tid' : tid},
  384. success : function(data) {
  385. loaderStop();
  386. }
  387. });
  388. }
  389.  
  390. function bucket_temp(cat,cost){
  391. $.ajax({
  392. type: "POST",
  393. url: "/ajax/buckettemp",
  394. dataType : 'json',
  395. data : {'cat' : cat, 'cost' : cost},
  396. success : function(data) {
  397. loaderStop();
  398. }
  399. });
  400. }
  401.  
  402. function output_news(uid){
  403. $.ajax({
  404. type: "POST",
  405. url: "/ajax/loadnews",
  406. dataType : 'json',
  407. data : {'uid' : uid},
  408. success : function(data) {
  409. loaderStop();
  410. }
  411. });
  412. }
  413.  
  414. function gplatestraces(){
  415. $.ajax({
  416. type: "POST",
  417. url: "/ajax/gplatestraces",
  418. dataType : 'json',
  419. data : {'proracer' : true},
  420. success : function(data) {
  421. loaderStop();
  422. }
  423. });
  424. }
  425.  
  426. function rendermodsection(mod,cid){
  427. $.ajax({
  428. type: "POST",
  429. url: "/ajax/rendermodsection",
  430. dataType : 'json',
  431. data : {'mod' : mod, 'cid' : cid},
  432. success : function(data) {
  433. loaderStop();
  434. }
  435. });
  436. }
  437.  
  438. function grandprixrace(){
  439. $.ajax({
  440. type: "POST",
  441. url: "/ajax/grandprixrace",
  442. dataType : 'json',
  443. data : {'proracer' : true},
  444. success : function(data) {
  445. loaderStop();
  446. $('#' + 'racebutton').css('display', 'block');
  447. }
  448. });
  449. }
  450.  
  451. function userprofiledisplay(typed,uid){
  452. $.ajax({
  453. type: "POST",
  454. url: "/ajax/userprofiledisplay",
  455. dataType : 'json',
  456. data : {'typed' : typed, 'uid' : uid},
  457. success : function(data) {
  458. loaderStop();
  459. }
  460. });
  461. }
  462.  
  463. function refreshStatsgp(){
  464. $.ajax({
  465. type: "POST",
  466. url: "/ajax/gpstats",
  467. dataType : 'json',
  468. data : {'proracer' : true},
  469. success : function(data) {
  470. loaderStop();
  471. }
  472. });
  473. }
  474.  
  475. function refreshgpcountdown(){
  476. $.ajax({
  477. type: "POST",
  478. url: "/ajax/gpcountdown",
  479. dataType : 'json',
  480. data : {'proracer' : true},
  481. success : function(data) {
  482. loaderStop();
  483. }
  484. });
  485. }
  486. function refreshStats(){
  487. $.ajax({
  488. type: "POST",
  489. url: "/ajax/stats",
  490. dataType : 'json',
  491. data : {'proracer' : true},
  492. success : function(data) {
  493. loaderStop();
  494. }
  495. });
  496. }
  497.  
  498. function racingselectionbox(fcid,fuid){
  499. $.ajax({
  500. type: "POST",
  501. url: "/ajax/racingselectionbox",
  502. dataType : 'json',
  503. data : {'fcid' : fcid, 'fuid' : fuid },
  504. success : function(data) {
  505. loaderStop();
  506. $('#' + data.div1).show();
  507. }
  508.  
  509. });
  510. }
  511.  
  512. var is_racing = false;
  513. function chooseoppapply(ouid,ocid,typed){
  514. if(!is_racing){
  515. is_racing = true;
  516. $.ajax({
  517. type: "POST",
  518. url: "/ajax/chooseoppapply",
  519. dataType : 'json',
  520. data : { 'ouid' : ouid, 'ocid' : ocid, 'typed' : typed },
  521. success : function(data) {
  522. loaderStop();
  523. $('#' + data.div1).show();
  524. is_racing = false;
  525. }
  526. });
  527. }
  528.  
  529.  
  530. }
  531.  
  532. function raceClick(){
  533. var typed = $(this).attr('racetype');
  534. var ouid = $(this).parent().attr('ouid');
  535. var ocid = $(this).parent().attr('ocid');
  536. $(this).css('opacity', .1).css('cursor', 'default');
  537. $(this).siblings().css('cursor', 'default').unbind('click').css('opacity', 0.2);
  538. console.log(ocid);
  539. console.log(ouid);
  540. console.log(typed);
  541. chooseoppapply(ouid, ocid, typed);
  542. }
  543.  
  544. function trainskill(skill){
  545. $.ajax({
  546. type: "POST",
  547. url: "/ajax/skilltrain",
  548. dataType : 'json',
  549. data : {'skill' : skill},
  550. success : function(data) {
  551. loaderStop();
  552. $('#' + 'special_skill_pluses').css('display', 'block');
  553. }
  554. });
  555. }
  556.  
  557. function markraceregister(uid){
  558. $.ajax({
  559. type: "POST",
  560. url: "ajax/markraceregister",
  561. dataType : 'json',
  562. data : {'uid' : uid},
  563. success : function(data) {
  564. loaderStop();
  565. //$('#' + 'markrace_output_box').css('display', 'block');
  566. }
  567. });
  568. }
  569.  
  570. function markraceunregister(uid){
  571. $.ajax({
  572. type: "POST",
  573. url: "ajax/markraceunregister",
  574. dataType : 'json',
  575. data : {'uid' : uid},
  576. success : function(data) {
  577. loaderStop();
  578. //$('#' + 'markrace_output_box').css('display', 'block');
  579. }
  580. });
  581. }
  582.  
  583.  
  584.  
  585. function trainskillfifty(skill){
  586. $.ajax({
  587. type: "POST",
  588. url: "/ajax/skilltrainfifty",
  589. dataType : 'json',
  590. data : {'skill' : skill},
  591. success : function(data) {
  592. loaderStop();
  593. $('#' + 'special_skill_pluses_fifty').css('display', 'block');
  594. }
  595. });
  596. }
  597.  
  598. function modifycarcolor(cid,image,ctid,iii){
  599. $.ajax({
  600. type: "POST",
  601. url: "/ajax/modifycarcolor",
  602. dataType : 'json',
  603. data : {'cid' : cid, 'image' : image, 'ctid' : ctid, 'iii' : iii},
  604. success : function(data) {
  605. loaderStop();
  606. }
  607. });
  608. }
  609.  
  610. function buynewcarbutton(ctid){
  611. $.ajax({
  612. type: "POST",
  613. url: "/ajax/buynewcar",
  614. dataType : 'json',
  615. data : {'ctid' : ctid},
  616. success : function(data) {
  617. loaderStop();
  618. }
  619. });
  620. }
  621.  
  622. function buynewcarbuttonverify(ctid,price){
  623. $.ajax({
  624. type: "POST",
  625. url: "/ajax/buynewcarverify",
  626. dataType : 'json',
  627. data : {'ctid' : ctid, 'price' : price},
  628. success : function(data) {
  629. loaderStop();
  630. }
  631. });
  632. }
  633.  
  634. function buyluxuryverify(iid){
  635. $.ajax({
  636. type: "POST",
  637. url: "/ajax/buyluxuryverify",
  638. dataType : 'json',
  639. data : {'iid' : iid},
  640. success : function(data) {
  641. loaderStop();
  642. }
  643. });
  644. }
  645.  
  646. function buyluxury(iid){
  647. $.ajax({
  648. type: "POST",
  649. url: "/ajax/buyluxury",
  650. dataType : 'json',
  651. data : {'iid' : iid},
  652. success : function(data) {
  653. loaderStop();
  654. }
  655. });
  656. }
  657.  
  658. function buymissionaccess(tid,cid,sid){
  659. $.ajax({
  660. type: "POST",
  661. url: "/ajax/buymissionaccess",
  662. dataType : 'json',
  663. data : {'tid' : tid, 'cid' : cid, 'sid' : sid},
  664. success : function(data) {
  665. loaderStop();
  666. }
  667. });
  668. }
  669.  
  670. function selltodealer(cid,last){
  671. $.ajax({
  672. type: "POST",
  673. url: "/ajax/sellcardealer",
  674. dataType : 'json',
  675. data : {'cid' : cid, 'last' : last},
  676. success : function(data) {
  677. loaderStop();
  678. }
  679. });
  680. }
  681.  
  682. function tuneupgradebuy(cid,fid){
  683. $.ajax({
  684. type: "POST",
  685. url: "/ajax/tuneupgradebuy",
  686. dataType : 'json',
  687. data : {'cid' : cid, 'fid' : fid},
  688. success : function(data) {
  689. loaderStop();
  690. }
  691. });
  692. }
  693.  
  694. function tuneupgradesell(cid,fid){
  695. $.ajax({
  696. type: "POST",
  697. url: "/ajax/tuneupgradesell",
  698. dataType : 'json',
  699. data : {'cid' : cid, 'fid' : fid},
  700. success : function(data) {
  701. loaderStop();
  702. }
  703. });
  704. }
  705.  
  706. function selltodealerverify(cid,last,valued){
  707. $.ajax({
  708. type: "POST",
  709. url: "/ajax/sellcardealerverify",
  710. dataType : 'json',
  711. data : {'cid' : cid, 'last' : last, 'valued' : valued},
  712. success : function(data) {
  713. loaderStop();
  714. }
  715. });
  716. }
  717.  
  718. function marketlistcar(cid){
  719. var price = $('#price').val();
  720. $.ajax({
  721. type: "POST",
  722. url: "/ajax/marketlistcar",
  723. dataType : 'json',
  724.  
  725. data : {'cid' : cid, 'price' : price },
  726. success : function(data) {
  727. loaderStop();
  728. }
  729. });
  730. }
  731.  
  732. function teambankdonate(tid,money){
  733. $.ajax({
  734. type: "POST",
  735. url: "/ajax/teambankdonate",
  736. dataType : 'json',
  737. data : {'tid' : tid, 'money' : money },
  738. success : function(data) {
  739. loaderStop();
  740. }
  741. });
  742. }
  743.  
  744. function rpmarketlistcar(cid){
  745. var price = $('#rpprice').val();
  746. $.ajax({
  747. type: "POST",
  748. url: "/ajax/rpmarketlistcar",
  749. dataType : 'json',
  750.  
  751. data : {'cid' : cid, 'price' : price },
  752. success : function(data) {
  753. loaderStop();
  754. }
  755. });
  756. }
  757.  
  758. function removefrommarket(cid){
  759. $.ajax({
  760. type: "POST",
  761. url: "/ajax/removefrommarket",
  762. dataType : 'json',
  763. data : {'cid' : cid},
  764. success : function(data) {
  765. loaderStop();
  766. }
  767. });
  768. }
  769.  
  770. function buyrpmarket(cid,price){
  771. $.ajax({
  772. type: "POST",
  773. url: "/ajax/buyrpmarket",
  774. dataType : 'json',
  775. data : {'cid' : cid, 'price' : price},
  776. success : function(data) {
  777. loaderStop();
  778. }
  779. });
  780. }
  781.  
  782. function buymarket(cid,price){
  783. $.ajax({
  784. type: "POST",
  785. url: "/ajax/buymarket",
  786. dataType : 'json',
  787. data : {'cid' : cid, 'price' : price},
  788. success : function(data) {
  789. loaderStop();
  790. }
  791. });
  792. }
  793.  
  794. function untrainskill(skill){
  795. $.ajax({
  796. type: "POST",
  797. url: "/ajax/skilluntrain",
  798. dataType : 'json',
  799. data : {'skill' : skill},
  800. success : function(data) {
  801. loaderStop();
  802. $('#' + 'special_skill_minuses').show();
  803. }
  804. });
  805. }
  806.  
  807. function untrainskillfifty(skill){
  808. $.ajax({
  809. type: "POST",
  810. url: "/ajax/skilluntrainfifty",
  811. dataType : 'json',
  812. data : {'skill' : skill},
  813. success : function(data) {
  814. loaderStop();
  815. $('#' + 'special_skill_minuses_fifty').show();
  816. }
  817. });
  818. }
  819.  
  820. function garagerendercars(section){
  821. $.ajax({
  822. type: "POST",
  823. url: "/ajax/garagerendercars",
  824. dataType : 'json',
  825. data : {'section' : section},
  826. success : function(data) {
  827. loaderStop();
  828. $('#garageloaderimage').hide();
  829. $('#garagecontent').show();
  830.  
  831.  
  832. }
  833. });
  834. }
  835.  
  836. function fbPop(content){
  837. $('#jspopup').remove();
  838. var popUp = $('<div class="popup_main_container" id="jspopup"><div class="popup_generic" style="width: 500px;"> <div class="popup_advanced"><div style="direction: ltr; outline: medium none;"><h2 class="popup_header"><span>' + title + '</span></h2><div class="popup_main_content"><div class="popup_body_content"><div>' + content + '</div></div> <div class="popup_bottom_container"><label class="popup_close_button_label"><input class="popup_button cancel" type="button" name="button1" value="Cancel"></label></div></div></div></div></div></div>');
  839.  
  840. $('body').append(popUp);
  841.  
  842. }
  843.  
  844. function contextMenu(options, position){
  845. $('.context-menu').remove();
  846. var menu = $('<div class="context-menu"><ul class="context-list"></ul></div>');
  847. var list = menu.children('ul');
  848. $.each(options, function(inx, val){
  849. var newLI = $('<li></li>');
  850. newLI.append($(val));
  851. list.append(newLI);
  852. });
  853. $('body').append(menu);
  854. if(position){
  855. menu.css(position);
  856. }
  857. return menu;
  858. }
  859.  
  860. function carMenu(){
  861. var cid = $(this).attr('cid');
  862. var ctid = $(this).attr('ctid');
  863. var status = parseInt($(this).attr('status'));
  864. var menuOptions = [];
  865. menuOptions.push('<a href="'+ pageVars.app_path +'/modcar/body/' + cid +'" target="_top"><img class="action-icon" src="http://img.grgventures.com/PRicons/BodyShopIcon.png" title="Body Shop"> Body Shop</a>');
  866. menuOptions.push('<a href="'+ pageVars.app_path +'/modcar/tune/' + cid +'" target="_top"><img class="action-icon" src="http://img.grgventures.com/PRicons/UpgradeIcon.png" title="Tune Shop"> Tune Shop</a>');
  867. menuOptions.push('<a href="'+ pageVars.app_path +'/marketplace/ctid/' + ctid + '" target="_top"><img class="action-icon" src="http://img.grgventures.com/proracer/SellOnMarketIcon.png" title="Check Market"> Check Market</a>');
  868. menuOptions.push('<a href="'+ pageVars.app_path +'/carselect/' + cid +'" target="_top"><img class="action-icon" src="http://img.grgventures.com/PRicons/CarDetailIcon.png" title="Car Details"> Car Details</a>');
  869. menuOptions.push('<a href="'+ pageVars.app_path +'/car/profile/' + ctid + '" target="_top"><img class="action-icon" src="http://img.grgventures.com/PRicons/cardetailsIcon.png"> Car Profile</a>');
  870. if(status == 0){
  871. var tourneylink = $('#popuplink-useintourneys-' + cid).clone();
  872. menuOptions.push(tourneylink);
  873. var gplink = $('#popuplink-useingrandprix-' + cid).clone();
  874. menuOptions.push(gplink);
  875. var uselink = $('#popuplink-usecar-' + cid).clone();
  876. menuOptions.push(uselink);
  877. }
  878.  
  879. var menu = contextMenu(menuOptions, $(this).offset());
  880.  
  881. initPopups();
  882. }
  883.  
  884. function teambuyluxuryverify(tid,iid,tier,named){
  885. $.ajax({
  886. type: "POST",
  887. url: "/ajax/teambuyluxuryverify",
  888. dataType : 'json',
  889. data : {'tid' : tid, 'iid' : iid, 'tier' : tier, 'named' : named},
  890. success : function(data) {
  891. loaderStop();
  892. }
  893. });
  894. }
  895.  
  896. function teambuyluxury(tid,iid,tier,named){
  897. $.ajax({
  898. type: "POST",
  899. url: "/ajax/teambuyluxury",
  900. dataType : 'json',
  901. data : {'tid' : tid, 'iid' : iid, 'tier' : tier, 'named' : named},
  902. success : function(data) {
  903. loaderStop();
  904. }
  905. });
  906. }
  907.  
  908. //george help
  909. function loaderInit(){
  910. $('body').addClass('wait');
  911. }
  912. function loaderStop(){
  913. $('body').removeClass('wait');
  914. }
  915. function gpcountdown_counter(id, time_left, totaltime, restart, callback){
  916. var targetobj = $('#' + id);
  917. if(!targetobj.hasClass('running')){ //prevents it from running 2 different timers
  918. setTimeout(function(){rungpProgressCounter(targetobj, time_left - 1, totaltime, restart, callback); }, 1000);
  919. targetobj.addClass('running');
  920. }
  921. }
  922. function rungpProgressCounter(iObj, time, totaltime, reset, callback) {
  923. var displaytime = Math.max(time, 0);
  924. var hours = displaytime/3600;
  925. var minutes = Math.floor((displaytime % 3600) / 60);
  926. var timeLeft = parseInt(hours)+':'+parseInt(minutes)+':'+numPad(parseInt(displaytime%60), 2);
  927. iObj.text(timeLeft);
  928. if(iObj.hasClass('running')){
  929. if(time >= 0) {
  930. setTimeout(function() { rungpProgressCounter(iObj, time-1, totaltime, reset, callback); }, 1000);
  931. } else if(totaltime && reset){
  932. if(callback){
  933. callback();
  934. }
  935. iObj.removeClassName('running');
  936. //setTimeout(function() { runProgressCounter(iObj, totaltime, totaltime, reset, callback) }, 1000);
  937. }
  938. }
  939. }
  940. function ttHide(tooltipKey){
  941. $.ajax({
  942. type: 'POST',
  943. url: '/ajax/ttHide/' + tooltipKey,
  944. data: {},
  945. success : function(){
  946. console.log('Tooltip got hid');
  947. }
  948. });
  949. $('#' + tooltipKey).animate({'height' : '0px', 'opacity': 0});
  950. }
  951.  
  952.  
  953. function usecar(cid,ctid){
  954. $.ajax({
  955. type: "POST",
  956. url: "/ajax/usecar",
  957. dataType : 'json',
  958. data : {'cid' : cid, 'ctid' : ctid},
  959. success : function(data) {
  960. loaderStop();
  961. }
  962.  
  963. });
  964. }
  965.  
  966.  
  967. function usecargp(cid){
  968. $.ajax({
  969. type: "POST",
  970. url: "/ajax/usecargp",
  971. dataType : 'json',
  972. data : {'cid' : cid},
  973. success : function(data) {
  974. loaderStop();
  975. }
  976.  
  977. });
  978. }
  979.  
  980. function usecartourney(cid){
  981. $.ajax({
  982. type: "POST",
  983. url: "/ajax/usecartourney",
  984. dataType : 'json',
  985. data : {'cid' : cid},
  986. success : function(data) {
  987. loaderStop();
  988. }
  989.  
  990. });
  991. }
  992.  
  993. function enabledisablerace(cid,racetype,actions){
  994. $.ajax({
  995. type: "POST",
  996. url: "/ajax/enabledisablerace",
  997. dataType : 'json',
  998. data : {'cid' : cid, 'racetype' : racetype, 'actions' : actions},
  999. success : function(data) {
  1000. loaderStop();
  1001. }
  1002.  
  1003. });
  1004. }
  1005.  
  1006. function propcollectrent(){
  1007. $.ajax({
  1008. type: "POST",
  1009. url: "/ajax/propcollectrent",
  1010. dataType : 'json',
  1011. data : {'proracer' : true},
  1012. success : function(data) {
  1013. loaderStop();
  1014. }
  1015. });
  1016. }
  1017.  
  1018. function removerpmarket(cid,locations){
  1019. $.ajax({
  1020. type: "POST",
  1021. url: "/ajax/removerpmarket",
  1022. dataType : 'json',
  1023. data : {'cid' : cid,'locations' : locations},
  1024. success : function(data) {
  1025. loaderStop();
  1026. }
  1027.  
  1028. });
  1029. }
  1030.  
  1031. function propertyupgrade(pid){
  1032. $.ajax({
  1033. type: "POST",
  1034. url: "/ajax/propertyupgrade",
  1035. dataType : 'json',
  1036. data : {'pid' : pid},
  1037. success : function(data) {
  1038. loaderStop();
  1039. }
  1040.  
  1041. });
  1042. }
  1043.  
  1044. function propbuy(pid){
  1045. $.ajax({
  1046. type: "POST",
  1047. url: "/ajax/propbuy",
  1048. dataType : 'json',
  1049. data : {'pid' : pid},
  1050. success : function(data) {
  1051. loaderStop();
  1052. }
  1053.  
  1054. });
  1055. }
  1056.  
  1057. function postBuy(ctid)
  1058. {
  1059.  
  1060. FB.api('/me/proracer:buy' +
  1061. '?car=http://apps.facebook.com/proracer/car/profile/' + ctid,'post',
  1062. function(response) {
  1063. if (!response || response.error) {
  1064. alert('Error occured');
  1065. } else {
  1066. alert('Post was successful! Action ID: ' + response.id);
  1067. }
  1068. });
  1069. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement