Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener("menubutton", showSwipPanel, false);
- $( "#app" ).on( "swiperight", showSwipPanel);
- $.event.special.swipe.horizontalDistanceThreshold = 15;
- var currentSwipPanel = -1;
- $( "#leftpanelSettings" ).on( "panelbeforeclose", function( event, ui ) {currentSwipPanel = -1} );
- $( "#leftpanelOnlineList" ).on( "panelbeforeclose", function( event, ui ) {currentSwipPanel = -1} );
- $( "#leftpanelBuyCredits" ).on( "panelbeforeclose", function( event, ui ) {currentSwipPanel = -1} );
- function showSwipPanel()
- {
- if(currentMenu == 0)
- {
- if(currentSwipPanel != 0)
- {
- currentSwipPanel = 0;
- showSettings();
- }
- else
- {
- hideSettings();
- }
- }
- else if(currentMenu == 1)
- {
- if(currentSwipPanel != 1)
- {
- currentSwipPanel = 1;
- showOnlineList();
- }
- else
- {
- hideOnlineList();
- }
- }
- else if(currentMenu == 2 && userName != null)
- {
- if(currentSwipPanel != 2)
- {
- currentSwipPanel = 2;
- showCreditsBuy();
- }
- else
- {
- hideCreditsBuy();
- }
- }
- }
- function showSettings()
- {
- $("#leftpanelSettings").panel("open");
- }
- function hideSettings()
- {
- $("#leftpanelSettings").panel("close");
- }
- function showCreditsBuy()
- {
- $("#leftpanelBuyCredits").panel("open");
- }
- function hideCreditsBuy()
- {
- $("#leftpanelBuyCredits").panel("close");
- }
- var showOnlineListTime;
- function hideOnlineList()
- {
- $("#leftpanelOnlineList").panel("close");
- }
- function showOnlineList()
- {
- if(!isInternetConnection)
- {
- noInternetAlert();
- return;
- }
- if(showOnlineListTime >= Math.floor((new Date()).getTime() / 1000))
- {
- $("#leftpanelOnlineList").panel("open");
- }
- else
- {
- showOnlineListTime = Math.floor((new Date()).getTime() / 1000)+30;
- $.post("http://sarg.lt/app/get_online.php", {code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
- {
- var value = parseINIString(data);
- var output = '<ul style="list-style-image: url('+"images/online.png"+')">';
- for(i = 1; i <= value["size"]; i++)
- {
- output += '<li onClick="showOtherUserProfile(\'' + value["name" + i + ""] + '\', \'' + value["avatar" + i + ""] + '\')">' + value["name" + i] + '</li>';
- }
- output += '</ul>';
- document.getElementById("onlineList").innerHTML = output;
- document.getElementById("onlineNumber").innerHTML = value["size"];
- $("#leftpanelOnlineList").panel("open");
- }
- );
- }
- }
- // Chat sidemenu
- var lastPrivateMsgDate = 0;
- var unreaded_private = 0;
- var privateChatList = {};
- function loadChatList()
- {
- if(!isInternetConnection || (isPaused && !alertPrivateVibration) || (isPaused && currentMenu != 1))
- return;
- var output = '';
- $.post("http://sarg.lt/app/get_private_chat_list.php", {date: lastPrivateMsgDate, name: userName, token: userData["token"], code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
- {
- if(data == "0")
- {
- return;
- }
- var value = parseINIString(data);
- if(value["size"] == 0)
- {
- if(ignore_alert_private)
- ignore_alert_private = false;
- return;
- }
- else if(value["size"] == 1)
- {
- if(current_chat_id == value["name1"])
- return;
- }
- if(lastPrivateMsgDate != value["max_date"]) // naujos žinutės
- {
- unreaded_private = 0;
- lastPrivateMsgDate = value["max_date"];
- output += '<fieldset data-role="controlgroup">';
- if(current_chat_id == "0")
- output += '<a href="#" data-icon="forward" style="text-align: left;" id="startChat_0" data-role="button" onClick="loadChat(\'0\')" data-iconpos="left" class="ui-btn-active">Bendras</a>';
- else
- output += '<a href="#" data-icon="forward" style="text-align: left;" id="startChat_0" data-role="button" onClick="loadChat(\'0\')" data-iconpos="left">Bendras</a>';
- for(i = 1; i <= value["size"]; i++)
- {
- if (current_chat_id != value["name" + i])
- {
- unreaded_private += parseInt(value["unread" + i]);
- /*if(!ignore_alert_private)
- {
- if(alertPrivateText)
- showMsg("<span class='glyphicon glyphicon-envelope'></span> Nauja žinutė nuo " + value["name" + i]);
- }*/
- output += '<a href="#" data-icon="forward" style="text-align: left;" id="startChat_'+value["name" + i]+'" data-role="button" onClick="loadChat(\''+value["name" + i]+'\')" data-iconpos="left">'+value["name" + i]+'';
- }
- else
- {
- output += '<a href="#" data-icon="forward" style="text-align: left;" id="startChat_'+value["name" + i]+'" data-role="button" onClick="loadChat(\''+value["name" + i]+'\')" class="ui-btn-active" data-iconpos="left">'+value["name" + i]+'';
- }
- if(value["unread" + i] > 0)
- output += '<span id="unreaded_'+value["name" + i]+'" class="ui-li-count">'+value["unread" + i]+'</span>';
- output += '</a>';
- }
- output += '</fieldset>';
- document.getElementById("chatList").innerHTML = output;
- $('#chatList').css("border", "none");
- $('#chatList').css("text-align", "left");
- $('#chatList').trigger('create');
- if(unreaded_private > 0)
- {
- document.getElementById("leftPanelIconUnreaded").innerHTML = '<span class="badge">'+unreaded_private+'</span>';
- if(!ignore_alert_private)
- {
- if(alertPrivateVibration)
- navigator.notification.vibrate(100);
- }
- else
- ignore_alert_private = false;
- }
- }
- }
- );
- }
- var close_side_menu = false;
- function loadChat(name)
- {
- if(userName == null)
- {
- showMsg("Prisijunk!");
- }
- if(current_chat_id != name)
- {
- $('#startChat_' + current_chat_id).removeClass('ui-btn-active');
- $('#startChat_' + name).addClass('ui-btn-active');
- unreaded_msgs = parseInt($( '#unreaded_' + name ).text());
- if(unreaded_msgs > 0)
- {
- document.getElementById('unreaded_' + name).innerHTML = '';
- $( '#unreaded_' + name ).removeClass( "ui-li-count" );
- unreaded_private -= unreaded_msgs;
- if(unreaded_private > 0)
- document.getElementById("leftPanelIconUnreaded").innerHTML = '<span class="badge">'+unreaded_private+'</span>';
- else
- document.getElementById("leftPanelIconUnreaded").innerHTML = '';
- }
- $.mobile.loading('show');
- current_chat_id = name;
- load_all_msg = true;
- close_side_menu = true;
- msgList = {};
- loadMsg();
- }
- }
- function startChat()
- {
- if(userName != null)
- {
- showMsg("Pradėtas pokalbis su " + lastShowOtherUserProfile);
- loadChat(lastShowOtherUserProfile);
- }
- else
- {
- showMsg("Prisijunk!");
- }
- }
- function showOtherUserProfile(name, avatar) // profile in sidemenu
- {
- if(name == current_chat_id || name == userName)
- {
- $('#startChatButton').hide();
- }
- else
- {
- $('#startChatButton').show();
- }
- if(lastShowOtherUserProfile == name)
- {
- $("#leftpanelUserProfile").panel("open");
- return;
- }
- lastShowOtherUserProfile = name;
- document.getElementById("otherUserAvatar").src = avatar;
- document.getElementById("otherUserProfileName").innerHTML = name;
- document.getElementById("otherUserProfile").innerHTML = "";
- $.mobile.loading('show');
- var delay = 0;
- if(showOtherUserProfileTime > Math.floor((new Date()).getTime() / 1000))
- delay = 3000;
- showOtherUserProfileTime = Math.floor((new Date()).getTime() / 1000)+5;
- window.setTimeout(function()
- {
- $.post("http://sarg.lt/app/user_profile.php", {name: name, code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
- {
- if(data == "0")
- {
- showWarningMsg("Serveris nepasiekiamas!");
- }
- else
- {
- otherUserData = parseINIString(data);
- output = 'Pinigai: '+otherUserData["money"]+'<br>\
- Uždarbis: '+otherUserData["uzdirbo"]+'<br>\
- XP: '+otherUserData["xp"]+'<br>\
- VIP: '+otherUserData["vip"]+'<br>\
- Admin: '+otherUserData["admin"]+'<br>\
- Šiandien pražaidė: '+otherUserData["prazaide"]+' min.<br>\
- Darbas: '+otherUserData["job"]+'<br>';
- if(otherUserData["vehicle_model0"] >= 400 || otherUserData["vehicle_model1"] >= 400)
- {
- output += '<div class="ui-grid ui-responsive" style="text-align: center;">\
- <h3><b>Transportas</b></h3>';
- if(otherUserData["vehicle_model0"] >= 400)
- {
- output += '<div class="ui-block">\
- <div class="ui-bar ui-bar">\
- <center><img src="images/vehicles/'+otherUserData["vehicle_model0"]+'.png" class="img-responsive"></center>\
- '+otherUserData["vehicle_km0"]+' km\
- </div>\
- </div>';
- }
- if(otherUserData["vehicle_model1"] >= 400)
- {
- output += '<div class="ui-block">\
- <div class="ui-bar ui-bar">\
- <center><img src="images/vehicles/'+otherUserData["vehicle_model1"]+'.png" class="img-responsive"></center>\
- '+otherUserData["vehicle_km1"]+' km\
- </div>\
- </div>';
- }
- output +='</div>';
- }
- document.getElementById("otherUserProfile").innerHTML = output;
- }
- $.mobile.loading('hide');
- }
- );
- }
- , delay);
- $("#leftpanelUserProfile").panel("open");
- }
- // Profile sidemenu
- var SMS = new Array(
- new Array("Lietuva", "sarg", "1398", "1,45 EUR", "100", " Bitė, Omnitel, Tele2"),
- new Array("Didžioji Britanija", "PIP sarg", "80876", "1,5 GBP", "100", "O2, Orange, Three, Tmobile, Vodafone, Virgin"),
- new Array("Airija", "PJPJ sarg", "57599", "2,5 EUR", "160", "Vodafone, O2, Meteor, 3"),
- new Array("Norvegija", "PJP sarg", "2333", "10 NOK", "100", "Telenor, NetCom, Network Norway, Tele2, TDC, Ventelo"),
- new Array("Švedija", "PJP sarg", "72104 ", "15.00 SEK", "100", "Telia, Tre, TDC, Tele2, Telenor, Ventelo"),
- new Array("Danija", "PJP sarg", "1961", "10 DKK", "100", "TDC, Telia, Telenor, Tre"),
- new Array("Vokietija", "PJP1 sarg", "82555", "2,99 EUR", "200", "T-Mobile, Vodafone, E-Plus, O2, Mobilcom-Debitel"),
- new Array("Latvija", "PJ100 sarg", "1863", "1,42 EUR", "100", "Tele2, LMT, Bite")
- );
- var paymentCountry = 0;
- if(window.localStorage.getItem("paymentCountry") != null)
- paymentCountry = window.localStorage.getItem("paymentCountry");
- else
- paymentCountry = 0;
- $("#selectCountry").val(paymentCountry).change();
- function onPaymentCountryChange()
- {
- paymentCountry = $("#selectCountry").val();
- window.localStorage.setItem("paymentCountry", paymentCountry);
- document.getElementById("credit_price").innerHTML = SMS[paymentCountry][3];
- document.getElementById("credit_amount").innerHTML = SMS[paymentCountry][4];
- document.getElementById("credit_operators").innerHTML = SMS[paymentCountry][5];
- document.getElementById("credit_sms").href = "sms://"+SMS[paymentCountry][2]+"?body="+SMS[paymentCountry][1]+" "+userName;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement