Advertisement
Guest User

Untitled

a guest
Feb 17th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.03 KB | None | 0 0
  1. document.addEventListener("menubutton", showSwipPanel, false);
  2. $( "#app" ).on( "swiperight", showSwipPanel);
  3. $.event.special.swipe.horizontalDistanceThreshold = 15;
  4.  
  5. var currentSwipPanel = -1;
  6. $( "#leftpanelSettings" ).on( "panelbeforeclose", function( event, ui ) {currentSwipPanel = -1} );
  7. $( "#leftpanelOnlineList" ).on( "panelbeforeclose", function( event, ui ) {currentSwipPanel = -1} );
  8. $( "#leftpanelBuyCredits" ).on( "panelbeforeclose", function( event, ui ) {currentSwipPanel = -1} );
  9. function showSwipPanel()
  10. {
  11. if(currentMenu == 0)
  12. {
  13. if(currentSwipPanel != 0)
  14. {
  15. currentSwipPanel = 0;
  16. showSettings();
  17. }
  18. else
  19. {
  20. hideSettings();
  21. }
  22. }
  23. else if(currentMenu == 1)
  24. {
  25. if(currentSwipPanel != 1)
  26. {
  27. currentSwipPanel = 1;
  28. showOnlineList();
  29. }
  30. else
  31. {
  32. hideOnlineList();
  33. }
  34. }
  35. else if(currentMenu == 2 && userName != null)
  36. {
  37. if(currentSwipPanel != 2)
  38. {
  39. currentSwipPanel = 2;
  40. showCreditsBuy();
  41. }
  42. else
  43. {
  44. hideCreditsBuy();
  45. }
  46. }
  47. }
  48. function showSettings()
  49. {
  50. $("#leftpanelSettings").panel("open");
  51. }
  52. function hideSettings()
  53. {
  54. $("#leftpanelSettings").panel("close");
  55. }
  56. function showCreditsBuy()
  57. {
  58. $("#leftpanelBuyCredits").panel("open");
  59. }
  60. function hideCreditsBuy()
  61. {
  62. $("#leftpanelBuyCredits").panel("close");
  63. }
  64.  
  65. var showOnlineListTime;
  66. function hideOnlineList()
  67. {
  68. $("#leftpanelOnlineList").panel("close");
  69. }
  70. function showOnlineList()
  71. {
  72. if(!isInternetConnection)
  73. {
  74. noInternetAlert();
  75. return;
  76. }
  77. if(showOnlineListTime >= Math.floor((new Date()).getTime() / 1000))
  78. {
  79. $("#leftpanelOnlineList").panel("open");
  80. }
  81. else
  82. {
  83. showOnlineListTime = Math.floor((new Date()).getTime() / 1000)+30;
  84. $.post("http://sarg.lt/app/get_online.php", {code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
  85. {
  86. var value = parseINIString(data);
  87. var output = '<ul style="list-style-image: url('+"images/online.png"+')">';
  88. for(i = 1; i <= value["size"]; i++)
  89. {
  90. output += '<li onClick="showOtherUserProfile(\'' + value["name" + i + ""] + '\', \'' + value["avatar" + i + ""] + '\')">' + value["name" + i] + '</li>';
  91. }
  92. output += '</ul>';
  93. document.getElementById("onlineList").innerHTML = output;
  94. document.getElementById("onlineNumber").innerHTML = value["size"];
  95.  
  96. $("#leftpanelOnlineList").panel("open");
  97. }
  98.  
  99. );
  100. }
  101. }
  102.  
  103.  
  104. // Chat sidemenu
  105. var lastPrivateMsgDate = 0;
  106. var unreaded_private = 0;
  107. var privateChatList = {};
  108. function loadChatList()
  109. {
  110. if(!isInternetConnection || (isPaused && !alertPrivateVibration) || (isPaused && currentMenu != 1))
  111. return;
  112. var output = '';
  113. $.post("http://sarg.lt/app/get_private_chat_list.php", {date: lastPrivateMsgDate, name: userName, token: userData["token"], code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
  114. {
  115. if(data == "0")
  116. {
  117. return;
  118. }
  119.  
  120. var value = parseINIString(data);
  121. if(value["size"] == 0)
  122. {
  123. if(ignore_alert_private)
  124. ignore_alert_private = false;
  125. return;
  126. }
  127. else if(value["size"] == 1)
  128. {
  129. if(current_chat_id == value["name1"])
  130. return;
  131. }
  132. if(lastPrivateMsgDate != value["max_date"]) // naujos žinutės
  133. {
  134. unreaded_private = 0;
  135. lastPrivateMsgDate = value["max_date"];
  136. output += '<fieldset data-role="controlgroup">';
  137. if(current_chat_id == "0")
  138. 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>';
  139. else
  140. output += '<a href="#" data-icon="forward" style="text-align: left;" id="startChat_0" data-role="button" onClick="loadChat(\'0\')" data-iconpos="left">Bendras</a>';
  141. for(i = 1; i <= value["size"]; i++)
  142. {
  143. if (current_chat_id != value["name" + i])
  144. {
  145. unreaded_private += parseInt(value["unread" + i]);
  146. /*if(!ignore_alert_private)
  147. {
  148. if(alertPrivateText)
  149. showMsg("<span class='glyphicon glyphicon-envelope'></span> Nauja žinutė nuo " + value["name" + i]);
  150. }*/
  151. 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]+'';
  152. }
  153. else
  154. {
  155. 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]+'';
  156. }
  157. if(value["unread" + i] > 0)
  158. output += '<span id="unreaded_'+value["name" + i]+'" class="ui-li-count">'+value["unread" + i]+'</span>';
  159. output += '</a>';
  160. }
  161. output += '</fieldset>';
  162. document.getElementById("chatList").innerHTML = output;
  163. $('#chatList').css("border", "none");
  164. $('#chatList').css("text-align", "left");
  165. $('#chatList').trigger('create');
  166.  
  167. if(unreaded_private > 0)
  168. {
  169. document.getElementById("leftPanelIconUnreaded").innerHTML = '<span class="badge">'+unreaded_private+'</span>';
  170. if(!ignore_alert_private)
  171. {
  172. if(alertPrivateVibration)
  173. navigator.notification.vibrate(100);
  174. }
  175. else
  176. ignore_alert_private = false;
  177. }
  178.  
  179. }
  180. }
  181. );
  182. }
  183. var close_side_menu = false;
  184. function loadChat(name)
  185. {
  186. if(userName == null)
  187. {
  188. showMsg("Prisijunk!");
  189. }
  190. if(current_chat_id != name)
  191. {
  192. $('#startChat_' + current_chat_id).removeClass('ui-btn-active');
  193. $('#startChat_' + name).addClass('ui-btn-active');
  194.  
  195. unreaded_msgs = parseInt($( '#unreaded_' + name ).text());
  196. if(unreaded_msgs > 0)
  197. {
  198. document.getElementById('unreaded_' + name).innerHTML = '';
  199. $( '#unreaded_' + name ).removeClass( "ui-li-count" );
  200. unreaded_private -= unreaded_msgs;
  201. if(unreaded_private > 0)
  202. document.getElementById("leftPanelIconUnreaded").innerHTML = '<span class="badge">'+unreaded_private+'</span>';
  203. else
  204. document.getElementById("leftPanelIconUnreaded").innerHTML = '';
  205. }
  206.  
  207. $.mobile.loading('show');
  208. current_chat_id = name;
  209. load_all_msg = true;
  210. close_side_menu = true;
  211. msgList = {};
  212. loadMsg();
  213. }
  214. }
  215. function startChat()
  216. {
  217. if(userName != null)
  218. {
  219. showMsg("Pradėtas pokalbis su " + lastShowOtherUserProfile);
  220. loadChat(lastShowOtherUserProfile);
  221. }
  222. else
  223. {
  224. showMsg("Prisijunk!");
  225. }
  226. }
  227.  
  228. function showOtherUserProfile(name, avatar) // profile in sidemenu
  229. {
  230. if(name == current_chat_id || name == userName)
  231. {
  232. $('#startChatButton').hide();
  233. }
  234. else
  235. {
  236. $('#startChatButton').show();
  237. }
  238. if(lastShowOtherUserProfile == name)
  239. {
  240. $("#leftpanelUserProfile").panel("open");
  241. return;
  242. }
  243. lastShowOtherUserProfile = name;
  244. document.getElementById("otherUserAvatar").src = avatar;
  245. document.getElementById("otherUserProfileName").innerHTML = name;
  246. document.getElementById("otherUserProfile").innerHTML = "";
  247. $.mobile.loading('show');
  248. var delay = 0;
  249. if(showOtherUserProfileTime > Math.floor((new Date()).getTime() / 1000))
  250. delay = 3000;
  251. showOtherUserProfileTime = Math.floor((new Date()).getTime() / 1000)+5;
  252. window.setTimeout(function()
  253. {
  254. $.post("http://sarg.lt/app/user_profile.php", {name: name, code: "0ay3j5as1Zua55f9T9s2upo"}, function( data )
  255. {
  256. if(data == "0")
  257. {
  258. showWarningMsg("Serveris nepasiekiamas!");
  259. }
  260. else
  261. {
  262. otherUserData = parseINIString(data);
  263. output = 'Pinigai: '+otherUserData["money"]+'<br>\
  264. Uždarbis: '+otherUserData["uzdirbo"]+'<br>\
  265. XP: '+otherUserData["xp"]+'<br>\
  266. VIP: '+otherUserData["vip"]+'<br>\
  267. Admin: '+otherUserData["admin"]+'<br>\
  268. Šiandien pražaidė: '+otherUserData["prazaide"]+' min.<br>\
  269. Darbas: '+otherUserData["job"]+'<br>';
  270. if(otherUserData["vehicle_model0"] >= 400 || otherUserData["vehicle_model1"] >= 400)
  271. {
  272. output += '<div class="ui-grid ui-responsive" style="text-align: center;">\
  273. <h3><b>Transportas</b></h3>';
  274. if(otherUserData["vehicle_model0"] >= 400)
  275. {
  276. output += '<div class="ui-block">\
  277. <div class="ui-bar ui-bar">\
  278. <center><img src="images/vehicles/'+otherUserData["vehicle_model0"]+'.png" class="img-responsive"></center>\
  279. '+otherUserData["vehicle_km0"]+' km\
  280. </div>\
  281. </div>';
  282. }
  283. if(otherUserData["vehicle_model1"] >= 400)
  284. {
  285. output += '<div class="ui-block">\
  286. <div class="ui-bar ui-bar">\
  287. <center><img src="images/vehicles/'+otherUserData["vehicle_model1"]+'.png" class="img-responsive"></center>\
  288. '+otherUserData["vehicle_km1"]+' km\
  289. </div>\
  290. </div>';
  291. }
  292. output +='</div>';
  293. }
  294. document.getElementById("otherUserProfile").innerHTML = output;
  295. }
  296. $.mobile.loading('hide');
  297. }
  298. );
  299. }
  300. , delay);
  301. $("#leftpanelUserProfile").panel("open");
  302. }
  303. // Profile sidemenu
  304.  
  305. var SMS = new Array(
  306. new Array("Lietuva", "sarg", "1398", "1,45 EUR", "100", " Bitė, Omnitel, Tele2"),
  307. new Array("Didžioji Britanija", "PIP sarg", "80876", "1,5 GBP", "100", "O2, Orange, Three, Tmobile, Vodafone, Virgin"),
  308. new Array("Airija", "PJPJ sarg", "57599", "2,5 EUR", "160", "Vodafone, O2, Meteor, 3"),
  309. new Array("Norvegija", "PJP sarg", "2333", "10 NOK", "100", "Telenor, NetCom, Network Norway, Tele2, TDC, Ventelo"),
  310. new Array("Švedija", "PJP sarg", "72104 ", "15.00 SEK", "100", "Telia, Tre, TDC, Tele2, Telenor, Ventelo"),
  311. new Array("Danija", "PJP sarg", "1961", "10 DKK", "100", "TDC, Telia, Telenor, Tre"),
  312. new Array("Vokietija", "PJP1 sarg", "82555", "2,99 EUR", "200", "T-Mobile, Vodafone, E-Plus, O2, Mobilcom-Debitel"),
  313. new Array("Latvija", "PJ100 sarg", "1863", "1,42 EUR", "100", "Tele2, LMT, Bite")
  314. );
  315.  
  316. var paymentCountry = 0;
  317.  
  318. if(window.localStorage.getItem("paymentCountry") != null)
  319. paymentCountry = window.localStorage.getItem("paymentCountry");
  320. else
  321. paymentCountry = 0;
  322. $("#selectCountry").val(paymentCountry).change();
  323.  
  324. function onPaymentCountryChange()
  325. {
  326. paymentCountry = $("#selectCountry").val();
  327. window.localStorage.setItem("paymentCountry", paymentCountry);
  328. document.getElementById("credit_price").innerHTML = SMS[paymentCountry][3];
  329. document.getElementById("credit_amount").innerHTML = SMS[paymentCountry][4];
  330. document.getElementById("credit_operators").innerHTML = SMS[paymentCountry][5];
  331. document.getElementById("credit_sms").href = "sms://"+SMS[paymentCountry][2]+"?body="+SMS[paymentCountry][1]+" "+userName;
  332. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement