Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var TRUE = true;
- var loading = '<div style="text-align: center"><h2>Loading..</h2></div>';
- var mostRecentAjax;
- var timeDiff = 0;
- function initTimeOffset(){
- var curTime = new Date;
- //mconsole('JS time: ' + curTime.getTime() + ' Server time: ' + (pageVars.server_time * 1000));
- timeDiff = curTime.getTime() - (pageVars.server_time * 1000);
- }
- initTimeOffset();
- function goto(path){
- top.location = pageVars.app_path + '/' + path;
- }
- function hashLink(){
- if(window.location != window.parent.location && $(this).attr('reddir')){
- if(pageVars.signed_request){
- var hasQuery = new RegExp("\\?", "g");
- var append = ($(this).attr('reddir').search(hasQuery) != -1 ? '&' : '?') + "signed_request=" + encodeURIComponent(pageVars.signed_request);
- document.location = $(this).attr('reddir') + append;
- } else {
- document.location = $(this).attr('reddir');
- }
- top.location.hash = '/' + pageVars.fb_path + $(this).attr('reddir');
- return false;
- }
- }
- function reloadFrame(){
- document.location = document.location;
- }
- var initIng = false;
- $(document).ready(function() { //TODO: Move some of these to proapps.js + obfuscate
- if(!initIng){
- initIng = true;
- setInterval('adjust();', 1000);
- start_load();
- $(document).ajaxSend(function(event, request, settings) { //COOKIE FIXER?
- start_load();
- mconsole('appending auth to ajax request');
- if (typeof(pageVars.proapps_hash) == "undefined") return;
- // settings.data is a serialized string like "foo=bar&baz=boink" (ornull)
- settings.data = settings.data || "";
- settings.data += (settings.data ? "&" : "") + "proapps_hash=" + encodeURIComponent(pageVars.proapps_hash);
- settings.data += (settings.data ? "&" : "") + "proapps_uid=" + encodeURIComponent(pageVars.proapps_uid);
- //if there's a urlparam for code/state
- if(pageVars.signed_request){
- settings.data += (settings.data ? "&" : "") + "signed_request=" + encodeURIComponent(pageVars.signed_request);
- }
- });
- $('body').ajaxSuccess(function(event, request, options){
- if (options.dataType == 'json') {
- var data = eval('(' + request.responseText + ')');
- // i has teh datas!
- //Global listeners--- commands to pass along with any ajax JSON response
- mconsole('Logging AJAXRESPONSE');
- if(data.drupal_messages){
- $.each(data.drupal_messages.status, function(inx, msgtxt){
- mconsole('System: ' + msgtxt);
- popupMessage('<div class="system-message">' + msgtxt + '</span>', true, 'opaque');
- });
- }
- if(data.authlink){
- console.log('authlink');
- top.location = data.authlink;
- }
- mostRecentAjax = data; //for debugging
- if(data.goto){
- console.log('goto');
- goto(data.goto);
- }
- if(data.nextpage){
- document.location = + '/' + data.nextpage;
- }
- if(data.money){
- updateMoney(data.money);
- }
- if(data.user_unlocked){
- pageVars.user_unlocked = data.user_unlocked;
- }
- if(data.message){
- messageInsert(data.message);
- }
- if(data.refresh_page){
- mconsole('Whattttt');
- document.location.reload();
- }
- if(data.div1){
- $('#' + data.div1).html(data.fbml_div1_content);
- }
- if(data.div2){
- $('#' + data.div2).html(data.fbml_div2_content);
- }
- if(data.div3){
- $('#' + data.div3).html(data.fbml_div3_content);
- }
- if(data.div4){
- $('#' + data.div4).html(data.fbml_div4_content);
- }
- if(data.div5){
- $('#' + data.div5).html(data.fbml_div5_content);
- }
- if(data.div6){
- $('#' + data.div6).html(data.fbml_div6_content);
- }
- if(data.div7){
- $('#' + data.div7).html(data.fbml_div7_content);
- }
- if(data.div8){
- $('#' + data.div8).html(data.fbml_div8_content);
- }
- $('.racebutton').unbind('click').click(raceClick);
- $('.garage_car, .garage_top_current_image').unbind('click').click(carMenu);
- FB.XFBML.parse();
- fixtimezones();
- end_load();
- }
- });
- if(pageVars.drupal_user){
- mconsole('Drupal user logged in, uid: ' + pageVars.drupal_user);
- }
- initPopups();
- end_load();
- }
- });
- function initPopups(){
- $('.popuplink').unbind('click').click(hiddenPopUp);
- }
- function hiddenPopUp(evt){
- var popupKey = $(this).attr('key');
- $('.popup_main_container').hide();
- if(popupKey){
- $(this).parents('div').eq(0).after($('#'+popupKey));
- var popup = $('#'+popupKey).show();
- var pheight = popup.find('.popup_advanced').height();
- var top = evt.pageY - parseInt(pheight/2);
- if(top + pheight > $(document).height()){
- top = $(document).height() - pheight - 30;
- }
- console.log(top + ' ' + $(document).height() + ' ' + pheight)
- popup.css('top', top);
- }
- adjust();
- return false;
- }
- function updateMoney(money){
- var diff = parseInt(money) - parseInt($('.money').text().replace('$', '').replace(/\,/g, ''));
- mconsole('Money changed by ' + diff);
- $('.money').text('$' + number_format(money, 0, '.', ','));
- $('.money').textUp('$' + number_format(Math.abs(diff), 0, '.', ','), diff > 0 ? '#228622' : '#ff0000');
- pageVars.money = money;
- }
- //Single notification message
- function popupMessage(message, modal, extraclass){
- var msgPopup = $('<div class="popupmsg ' + extraclass + '"></div>');
- msgPopup.html(message);
- $('.content-area').append(msgPopup);
- var closeButton = $('<div class="message-close">X</div>');
- msgPopup.append(closeButton);
- msgPopup.css('height', '1px');
- closeButton.click(closeParentPopup);
- msgPopup.find('.closeme').click(closeParentPopup);
- msgPopup.animate({'height' : Math.max(msgPopup.children().height(), 100) +'px' , 'opacity' : 1});
- if(!modal){
- //add timer to close/fade
- msgPopup.oneTime(6000, 'popupclose', closePopUp);
- } //otherwise user will have to X out of it
- }
- function closeParentPopup(){
- $(this).parents('.popupmsg').animate({'height' : '1px', 'opacity' : .1}, 700, null, function(){
- $(this).remove();
- });
- }
- function closePopUp(){
- $(this).animate({'height' : '1px', 'opacity' : .1}, 700, null, function(){
- $(this).remove();
- });
- }
- function theme_image_remote(path){
- return '<img src="' + pageVars.image_root + '/' + path +'" />';
- }
- function captionTip(evt){
- showHTip(evt, $('<div>' + $(this).attr('caption') + '</div>'), $(this));
- }
- function theme_like_button(pageurl){
- if(pageurl){
- return '<div class="littlelike"><fb:like href="' + pageurl + '" send="false" layout="button_count" width="150" show_faces="false" font="lucida grande"></fb:like></div>';
- } else {
- return '';
- }
- }
- function number_format( number, decimals, dec_point, thousands_sep ) {
- var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
- var d = dec_point == undefined ? "," : dec_point;
- var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
- var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
- 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) : "");
- }
- function countProperties(obj) {
- var prop;
- var propCount = 0;
- for (prop in obj) {
- propCount++;
- }
- return propCount;
- }
- jQuery.fn.blink = function(times) {
- $(this).each(function(key, val){
- $(val).everyTime(500, function(){
- $(this).toggleClass('active');
- }, times);
- });
- return this;
- };
- jQuery.fn.textUp = function(text, color) {
- $(this).each(function(key, val){
- //get current item
- var sourceBlock = $(val);
- var container = sourceBlock.parent();
- container.css('overflow', 'visible'); //DANGEROUS
- var newThing = $('<span class="popblock">' + (text ? text : sourceBlock.text()) + '</span>');
- $(container).append(newThing);
- 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() });
- });
- return this;
- };
- //Mouse tooltip showers and controllers
- var hTip;
- function showHTip(evt, content, thisAlt){
- var targetEl = thisAlt ? thisAlt : $(this);
- //mconsole('hovertooltip init');
- $('.tooltip').remove();
- if(content){
- targetEl.click(hoverOut);
- hTip = $('<div class="tooltip"></div>');
- hTip.append($(content));
- $('body').append(hTip);
- hTip.attr('hTip', 'true');
- hTip.css('left', parseInt(evt.pageX) + 2);
- hTip.css('top', parseInt(evt.pageY) + 2);
- hTip.css('opacity', '0.9');
- hTip.css('display', 'none');
- hTip.attr('parentCell', targetEl.attr('id'));
- hTip.show();
- //hTip.fadeIn(100); //Maybe this is slow
- targetEl.mousemove(tipfollow);
- //mconsole('htip finish');
- }
- }
- function tipfollow(evt){
- //there already is one.. let's just make it follow the mouse
- hTip.css('left', parseInt(evt.pageX) + 2);
- hTip.css('top', parseInt(evt.pageY) + 2);
- }
- function hoverOut(){
- if(hTip){
- //mconsole('Out');
- $('#' + hTip.attr('parentCell')).unbind('mousemove').unbind('click', hoverOut);
- hTip.remove();
- }
- }
- function bucket_refillfp(){
- $.ajax({
- type: "POST",
- url: "/ajax/bucketrefillfp",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function agent(){
- $.ajax({
- type: "POST",
- url: "/ajax/agent",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function rpgetmoney(){
- $.ajax({
- type: "POST",
- url: "/ajax/rpgetmoney",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function rpbuycar(ctid){
- $.ajax({
- type: "POST",
- url: "/ajax/rpbuycar",
- dataType : 'json',
- data : {'ctid':ctid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function rpbuycarverify(ctid){
- $.ajax({
- type: "POST",
- url: "/ajax/rpbuycarverify",
- dataType : 'json',
- data : {'ctid':ctid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function bucket_perm(){
- $.ajax({
- type: "POST",
- url: "/ajax/bucketperm",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function teamcommentbox(tid){
- $.ajax({
- type: "POST",
- url: "/ajax/teamcommentbox",
- dataType : 'json',
- data : {'tid' : tid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function bucket_temp(cat,cost){
- $.ajax({
- type: "POST",
- url: "/ajax/buckettemp",
- dataType : 'json',
- data : {'cat' : cat, 'cost' : cost},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function output_news(uid){
- $.ajax({
- type: "POST",
- url: "/ajax/loadnews",
- dataType : 'json',
- data : {'uid' : uid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function gplatestraces(){
- $.ajax({
- type: "POST",
- url: "/ajax/gplatestraces",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function rendermodsection(mod,cid){
- $.ajax({
- type: "POST",
- url: "/ajax/rendermodsection",
- dataType : 'json',
- data : {'mod' : mod, 'cid' : cid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function grandprixrace(){
- $.ajax({
- type: "POST",
- url: "/ajax/grandprixrace",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- $('#' + 'racebutton').css('display', 'block');
- }
- });
- }
- function userprofiledisplay(typed,uid){
- $.ajax({
- type: "POST",
- url: "/ajax/userprofiledisplay",
- dataType : 'json',
- data : {'typed' : typed, 'uid' : uid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function refreshStatsgp(){
- $.ajax({
- type: "POST",
- url: "/ajax/gpstats",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function refreshgpcountdown(){
- $.ajax({
- type: "POST",
- url: "/ajax/gpcountdown",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function refreshStats(){
- $.ajax({
- type: "POST",
- url: "/ajax/stats",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function racingselectionbox(fcid,fuid){
- $.ajax({
- type: "POST",
- url: "/ajax/racingselectionbox",
- dataType : 'json',
- data : {'fcid' : fcid, 'fuid' : fuid },
- success : function(data) {
- loaderStop();
- $('#' + data.div1).show();
- }
- });
- }
- var is_racing = false;
- function chooseoppapply(ouid,ocid,typed){
- if(!is_racing){
- is_racing = true;
- $.ajax({
- type: "POST",
- url: "/ajax/chooseoppapply",
- dataType : 'json',
- data : { 'ouid' : ouid, 'ocid' : ocid, 'typed' : typed },
- success : function(data) {
- loaderStop();
- $('#' + data.div1).show();
- is_racing = false;
- }
- });
- }
- }
- function raceClick(){
- var typed = $(this).attr('racetype');
- var ouid = $(this).parent().attr('ouid');
- var ocid = $(this).parent().attr('ocid');
- $(this).css('opacity', .1).css('cursor', 'default');
- $(this).siblings().css('cursor', 'default').unbind('click').css('opacity', 0.2);
- console.log(ocid);
- console.log(ouid);
- console.log(typed);
- chooseoppapply(ouid, ocid, typed);
- }
- function trainskill(skill){
- $.ajax({
- type: "POST",
- url: "/ajax/skilltrain",
- dataType : 'json',
- data : {'skill' : skill},
- success : function(data) {
- loaderStop();
- $('#' + 'special_skill_pluses').css('display', 'block');
- }
- });
- }
- function markraceregister(uid){
- $.ajax({
- type: "POST",
- url: "ajax/markraceregister",
- dataType : 'json',
- data : {'uid' : uid},
- success : function(data) {
- loaderStop();
- //$('#' + 'markrace_output_box').css('display', 'block');
- }
- });
- }
- function markraceunregister(uid){
- $.ajax({
- type: "POST",
- url: "ajax/markraceunregister",
- dataType : 'json',
- data : {'uid' : uid},
- success : function(data) {
- loaderStop();
- //$('#' + 'markrace_output_box').css('display', 'block');
- }
- });
- }
- function trainskillfifty(skill){
- $.ajax({
- type: "POST",
- url: "/ajax/skilltrainfifty",
- dataType : 'json',
- data : {'skill' : skill},
- success : function(data) {
- loaderStop();
- $('#' + 'special_skill_pluses_fifty').css('display', 'block');
- }
- });
- }
- function modifycarcolor(cid,image,ctid,iii){
- $.ajax({
- type: "POST",
- url: "/ajax/modifycarcolor",
- dataType : 'json',
- data : {'cid' : cid, 'image' : image, 'ctid' : ctid, 'iii' : iii},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buynewcarbutton(ctid){
- $.ajax({
- type: "POST",
- url: "/ajax/buynewcar",
- dataType : 'json',
- data : {'ctid' : ctid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buynewcarbuttonverify(ctid,price){
- $.ajax({
- type: "POST",
- url: "/ajax/buynewcarverify",
- dataType : 'json',
- data : {'ctid' : ctid, 'price' : price},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buyluxuryverify(iid){
- $.ajax({
- type: "POST",
- url: "/ajax/buyluxuryverify",
- dataType : 'json',
- data : {'iid' : iid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buyluxury(iid){
- $.ajax({
- type: "POST",
- url: "/ajax/buyluxury",
- dataType : 'json',
- data : {'iid' : iid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buymissionaccess(tid,cid,sid){
- $.ajax({
- type: "POST",
- url: "/ajax/buymissionaccess",
- dataType : 'json',
- data : {'tid' : tid, 'cid' : cid, 'sid' : sid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function selltodealer(cid,last){
- $.ajax({
- type: "POST",
- url: "/ajax/sellcardealer",
- dataType : 'json',
- data : {'cid' : cid, 'last' : last},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function tuneupgradebuy(cid,fid){
- $.ajax({
- type: "POST",
- url: "/ajax/tuneupgradebuy",
- dataType : 'json',
- data : {'cid' : cid, 'fid' : fid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function tuneupgradesell(cid,fid){
- $.ajax({
- type: "POST",
- url: "/ajax/tuneupgradesell",
- dataType : 'json',
- data : {'cid' : cid, 'fid' : fid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function selltodealerverify(cid,last,valued){
- $.ajax({
- type: "POST",
- url: "/ajax/sellcardealerverify",
- dataType : 'json',
- data : {'cid' : cid, 'last' : last, 'valued' : valued},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function marketlistcar(cid){
- var price = $('#price').val();
- $.ajax({
- type: "POST",
- url: "/ajax/marketlistcar",
- dataType : 'json',
- data : {'cid' : cid, 'price' : price },
- success : function(data) {
- loaderStop();
- }
- });
- }
- function teambankdonate(tid,money){
- $.ajax({
- type: "POST",
- url: "/ajax/teambankdonate",
- dataType : 'json',
- data : {'tid' : tid, 'money' : money },
- success : function(data) {
- loaderStop();
- }
- });
- }
- function rpmarketlistcar(cid){
- var price = $('#rpprice').val();
- $.ajax({
- type: "POST",
- url: "/ajax/rpmarketlistcar",
- dataType : 'json',
- data : {'cid' : cid, 'price' : price },
- success : function(data) {
- loaderStop();
- }
- });
- }
- function removefrommarket(cid){
- $.ajax({
- type: "POST",
- url: "/ajax/removefrommarket",
- dataType : 'json',
- data : {'cid' : cid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buyrpmarket(cid,price){
- $.ajax({
- type: "POST",
- url: "/ajax/buyrpmarket",
- dataType : 'json',
- data : {'cid' : cid, 'price' : price},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function buymarket(cid,price){
- $.ajax({
- type: "POST",
- url: "/ajax/buymarket",
- dataType : 'json',
- data : {'cid' : cid, 'price' : price},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function untrainskill(skill){
- $.ajax({
- type: "POST",
- url: "/ajax/skilluntrain",
- dataType : 'json',
- data : {'skill' : skill},
- success : function(data) {
- loaderStop();
- $('#' + 'special_skill_minuses').show();
- }
- });
- }
- function untrainskillfifty(skill){
- $.ajax({
- type: "POST",
- url: "/ajax/skilluntrainfifty",
- dataType : 'json',
- data : {'skill' : skill},
- success : function(data) {
- loaderStop();
- $('#' + 'special_skill_minuses_fifty').show();
- }
- });
- }
- function garagerendercars(section){
- $.ajax({
- type: "POST",
- url: "/ajax/garagerendercars",
- dataType : 'json',
- data : {'section' : section},
- success : function(data) {
- loaderStop();
- $('#garageloaderimage').hide();
- $('#garagecontent').show();
- }
- });
- }
- function fbPop(content){
- $('#jspopup').remove();
- 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>');
- $('body').append(popUp);
- }
- function contextMenu(options, position){
- $('.context-menu').remove();
- var menu = $('<div class="context-menu"><ul class="context-list"></ul></div>');
- var list = menu.children('ul');
- $.each(options, function(inx, val){
- var newLI = $('<li></li>');
- newLI.append($(val));
- list.append(newLI);
- });
- $('body').append(menu);
- if(position){
- menu.css(position);
- }
- return menu;
- }
- function carMenu(){
- var cid = $(this).attr('cid');
- var ctid = $(this).attr('ctid');
- var status = parseInt($(this).attr('status'));
- var menuOptions = [];
- 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>');
- 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>');
- 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>');
- 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>');
- 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>');
- if(status == 0){
- var tourneylink = $('#popuplink-useintourneys-' + cid).clone();
- menuOptions.push(tourneylink);
- var gplink = $('#popuplink-useingrandprix-' + cid).clone();
- menuOptions.push(gplink);
- var uselink = $('#popuplink-usecar-' + cid).clone();
- menuOptions.push(uselink);
- }
- var menu = contextMenu(menuOptions, $(this).offset());
- initPopups();
- }
- function teambuyluxuryverify(tid,iid,tier,named){
- $.ajax({
- type: "POST",
- url: "/ajax/teambuyluxuryverify",
- dataType : 'json',
- data : {'tid' : tid, 'iid' : iid, 'tier' : tier, 'named' : named},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function teambuyluxury(tid,iid,tier,named){
- $.ajax({
- type: "POST",
- url: "/ajax/teambuyluxury",
- dataType : 'json',
- data : {'tid' : tid, 'iid' : iid, 'tier' : tier, 'named' : named},
- success : function(data) {
- loaderStop();
- }
- });
- }
- //george help
- function loaderInit(){
- $('body').addClass('wait');
- }
- function loaderStop(){
- $('body').removeClass('wait');
- }
- function gpcountdown_counter(id, time_left, totaltime, restart, callback){
- var targetobj = $('#' + id);
- if(!targetobj.hasClass('running')){ //prevents it from running 2 different timers
- setTimeout(function(){rungpProgressCounter(targetobj, time_left - 1, totaltime, restart, callback); }, 1000);
- targetobj.addClass('running');
- }
- }
- function rungpProgressCounter(iObj, time, totaltime, reset, callback) {
- var displaytime = Math.max(time, 0);
- var hours = displaytime/3600;
- var minutes = Math.floor((displaytime % 3600) / 60);
- var timeLeft = parseInt(hours)+':'+parseInt(minutes)+':'+numPad(parseInt(displaytime%60), 2);
- iObj.text(timeLeft);
- if(iObj.hasClass('running')){
- if(time >= 0) {
- setTimeout(function() { rungpProgressCounter(iObj, time-1, totaltime, reset, callback); }, 1000);
- } else if(totaltime && reset){
- if(callback){
- callback();
- }
- iObj.removeClassName('running');
- //setTimeout(function() { runProgressCounter(iObj, totaltime, totaltime, reset, callback) }, 1000);
- }
- }
- }
- function ttHide(tooltipKey){
- $.ajax({
- type: 'POST',
- url: '/ajax/ttHide/' + tooltipKey,
- data: {},
- success : function(){
- console.log('Tooltip got hid');
- }
- });
- $('#' + tooltipKey).animate({'height' : '0px', 'opacity': 0});
- }
- function usecar(cid,ctid){
- $.ajax({
- type: "POST",
- url: "/ajax/usecar",
- dataType : 'json',
- data : {'cid' : cid, 'ctid' : ctid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function usecargp(cid){
- $.ajax({
- type: "POST",
- url: "/ajax/usecargp",
- dataType : 'json',
- data : {'cid' : cid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function usecartourney(cid){
- $.ajax({
- type: "POST",
- url: "/ajax/usecartourney",
- dataType : 'json',
- data : {'cid' : cid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function enabledisablerace(cid,racetype,actions){
- $.ajax({
- type: "POST",
- url: "/ajax/enabledisablerace",
- dataType : 'json',
- data : {'cid' : cid, 'racetype' : racetype, 'actions' : actions},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function propcollectrent(){
- $.ajax({
- type: "POST",
- url: "/ajax/propcollectrent",
- dataType : 'json',
- data : {'proracer' : true},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function removerpmarket(cid,locations){
- $.ajax({
- type: "POST",
- url: "/ajax/removerpmarket",
- dataType : 'json',
- data : {'cid' : cid,'locations' : locations},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function propertyupgrade(pid){
- $.ajax({
- type: "POST",
- url: "/ajax/propertyupgrade",
- dataType : 'json',
- data : {'pid' : pid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function propbuy(pid){
- $.ajax({
- type: "POST",
- url: "/ajax/propbuy",
- dataType : 'json',
- data : {'pid' : pid},
- success : function(data) {
- loaderStop();
- }
- });
- }
- function postBuy(ctid)
- {
- FB.api('/me/proracer:buy' +
- '?car=http://apps.facebook.com/proracer/car/profile/' + ctid,'post',
- function(response) {
- if (!response || response.error) {
- alert('Error occured');
- } else {
- alert('Post was successful! Action ID: ' + response.id);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement