Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.54 KB | None | 0 0
  1. var WebCall = {
  2. updateText: function(element_id, text, animate) {
  3. if (animate) {
  4. $('#' + element_id).fadeOut();
  5. }
  6. $('#' + element_id).html(text);
  7. if (animate) {
  8. $('#' + element_id).fadeIn('slow');
  9. }
  10. },
  11. updateBalance: function(response) {
  12. if ($('#balance').length > 0 && response) {
  13. var balance = parseInt(response.calculated_balance);
  14. balance = (Math.round(balance / 1000)) / 100;
  15. var fbalance = "";
  16. var balancestr = new String(balance);
  17. var balancearr = balancestr.split(".");
  18. if (balancearr.length == 1) fbalancestr = balancestr + "." + "00";
  19. else if (balancearr.length == 2) {
  20. if (balancearr[1].length == 1) fbalancestr = balancestr + "0";
  21. else if (balancearr[1].length == 2) fbalancestr = balancestr;
  22. }
  23. if (fbalancestr != "") {
  24. WebCall.updateText('balance', locale.currency_symbol + " " + fbalancestr);
  25. }
  26. }
  27. }
  28. };
  29.  
  30. var errormessages = new Array();
  31. errormessages.push("");
  32. errormessages.push("Sorry, you do not have enough credit to complete this call. Visit your account page to buy credit!");
  33. errormessages.push("The call ended due to an unknown error");
  34. errormessages.push("The other party ended the call");
  35. errormessages.push("The call ended due to an unknown error");
  36. errormessages.push("You ended the call");
  37. errormessages.push("The other party ended the call");
  38. errormessages.push("an error has occurred- code {err-id}");
  39. errormessages.push("You were busy with another call");
  40. errormessages.push("The other party was busy");
  41. errormessages.push("You did not answer your call");
  42. errormessages.push("The other party did not answer your call");
  43. errormessages.push("Sorry, a local network problem ended this call");
  44. errormessages.push("Sorry, a remote network problem ended this call");
  45. errormessages.push("The number you are trying to call is not supported. Please check the number and try again.");
  46. errormessages.push("an error has occurred- code {err-id}");
  47. errormessages.push("<b>Sorry, this destination is not free</b><br><br>Please buy credit or log in. Or call only the <a href='\"/freetrial_rates\"'>free</a> destinations.");
  48. errormessages.push("The time limit for this call has been reached. Buy credit and make unlimited calls!");
  49. errormessages.push("Sorry, you are not allowed to make this call");
  50. errormessages.push("The number you called is invalid. Please check the number and try again.");
  51. errormessages.push("Your own number is invalid");
  52. errormessages.push("The number you called is invalid. Please check the number and try again.");
  53. errormessages.push("There is a problem with your account, please go to your account page.");
  54. errormessages.push("The maximum number of free calls has been reached or you did not click the link in your signup email.");
  55. errormessages.push("You rejected the call");
  56. errormessages.push("The other party rejected the call");
  57.  
  58. var timenow = -1;
  59. var starttime = -1;
  60. var timeprice = "";
  61. var intervalid;
  62.  
  63. var locale = {
  64. "connection_time": "connection time",
  65. "rate_cents": "Ct\/min",
  66. "free": "Free",
  67. "setup_fee": "setup fee",
  68. "cents": "Ct",
  69. "dialing": "dialing",
  70. "the_total_price_for_call_is": "The total price for this call is",
  71. "pickup": "Pick up your phone...",
  72. "ringing": "Ringing...",
  73. "picked_up": "Picked up",
  74. "waiting_other_party": "Waiting for other party to pick up the telephone",
  75. "call_disconnected": "The call was disconnected",
  76. "call_connected": "Call connected",
  77. "an_error_occured": "An unknown error has occured",
  78. "currency_symbol": "&euro;",
  79. "no_longer_available": "<div>Our Phone-to-phone service is no longer available in your country.<\/div>",
  80. "technical_error": "A technical error has occured please try again later. If the problem persists please contact customer service.",
  81. "qs_error_message": "<div><\/div>"
  82. };
  83.  
  84. $.ajax({
  85. type: "POST",
  86. url: "https://www.voipstunt.com/x_status/p2p",
  87. dataType: "json",
  88. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&_xwccs=M25coTScMTR%253D&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6",
  89. success: function(response) {
  90. if (response.error == "reload_page") {
  91. window.setTimeout('location.href=\'https://www.voipstunt.com/warning.html\';', 1000);
  92. } else {
  93. callBack(response);
  94. }
  95. }
  96. });
  97. var ASideSetupCharge = 0;
  98. var ASideTariff = 0;
  99. var ASideTariffIntervall = 0;
  100. var BSideSetupCharge = 0;
  101. var BSideTariff = 0;
  102. var BSideTariffIntervall = 0;
  103. var totalcpm = 0;
  104.  
  105. var isconnected = false;
  106. var isdisconnecting = false;
  107.  
  108. var disconnectoption = '<iframe id="disconnect-iframe" scrolling="no" frameborder="0" height="20" width="100%" border="0" style="overflow: hidden; background: transparent;" src="https://www.voipstunt.com/x_status/p2p_x?_xwcci=AQRjBQp4AmRlBD%3D%3D"></iframe>';
  109.  
  110. var creditlink = {
  111. "data": "Click <a href=\"https:\/\/www.voipstunt.com\/buy_credit\/\">here<\/a> to buy more credits"
  112. };
  113. var redial_new_call_form = {
  114. "data": "<form style=\"display: inline;\" action=\"https:\/\/www.voipstunt.com\/phone_to_phone\/\" method=\"POST\">\n <input type=\"hidden\" name=\"phonenumber_from\" value=\"478061501\" \/>\n <input type=\"hidden\" name=\"phonenumber_to\" value=\"413218428\" \/>\n <input type=\"hidden\" name=\"prefix_from\" value=\"+61\" \/>\n <input type=\"hidden\" name=\"prefix_to\" value=\"+61\" \/>\n <input type=\"hidden\" name=\"action\" value=\"redial\" \/>\n <input type=\"submit\" class=\"button\" value=\"Redial\" \/>\n <input type=\"hidden\" id=\"31d35abc82f90f7ac71d1c5aa235380f\" name=\"31d35abc82f90f7ac71d1c5aa235380f\" value=\"2c0b27ac6c1beaa90575db1e229702d6\" \/><\/form>\n&nbsp;\n<form style=\"display: inline;\" action=\"https:\/\/www.voipstunt.com\/phone_to_phone\/\" method=\"POST\">\n <input type=\"hidden\" name=\"action\" value=\"makenewcall\" \/>\n <input type=\"submit\" class=\"button\" value=\"Make another call\" \/>\n <input type=\"hidden\" id=\"31d35abc82f90f7ac71d1c5aa235380f\" name=\"31d35abc82f90f7ac71d1c5aa235380f\" value=\"2c0b27ac6c1beaa90575db1e229702d6\" \/><\/form>"
  115. };
  116. var buy_credit_form = {
  117. "data": "<form><\/form>\n<form action=\"https:\/\/www.voipstunt.com\/buy_credit\/\" method=\"POST\" target=\"_parent\" style=\"display: inline;\">\n <input type=\"submit\" class=\"button\" value=\"Buy Credit\">\n <input type=\"hidden\" id=\"31d35abc82f90f7ac71d1c5aa235380f\" name=\"31d35abc82f90f7ac71d1c5aa235380f\" value=\"2c0b27ac6c1beaa90575db1e229702d6\" \/><\/form>"
  118. };
  119.  
  120. function displayConnectionTime() {
  121. if (isconnected) {
  122. timenow = new Date();
  123. timenow = parseInt(timenow.getTime() / 1000);
  124.  
  125. var conntime = timenow - starttime;
  126. var timestring = "";
  127. var connhours = Math.floor(conntime / 3600);
  128. var connminutes = Math.floor((conntime - (connhours * 3600)) / 60);
  129. var connseconds = ((conntime % 60) % 60);
  130.  
  131. if (starttime == -1) {
  132. starttime = timenow;
  133. }
  134.  
  135. if (connhours == 0) {
  136. connhours = "00";
  137. } else if (connhours < 10) {
  138. connhours = "0" + connhours;
  139. }
  140.  
  141. if (connminutes == 0) {
  142. connminutes = "00";
  143. } else if (connminutes < 10) {
  144. connminutes = "0" + connminutes;
  145. }
  146.  
  147. if (connseconds == 0) {
  148. connseconds = "00";
  149. } else if (connseconds < 10) {
  150. connseconds = "0" + connseconds;
  151. }
  152.  
  153. conntime = connhours + ":" + connminutes + ":" + connseconds;
  154.  
  155. var setupcharge = (ASideSetupCharge / 10000) + (BSideSetupCharge / 10000);
  156. var total = 0;
  157. total += (ASideTariff / 10000) * Math.ceil((timenow - starttime) / ASideTariffIntervall);
  158. total += (BSideTariff / 10000) * Math.ceil((timenow - starttime) / BSideTariffIntervall);
  159.  
  160. if (ASideTariffIntervall == 0 || BSideTariffIntervall == 0) {
  161. total = 0;
  162. }
  163.  
  164. totalcpm = parseFloat(ASideTariff / 10000) + parseFloat(BSideTariff / 10000);
  165. totalcpm = parseFloat(ASideTariff / 10000) + parseFloat(BSideTariff / 10000) + 5.0;
  166.  
  167. timeprice = '' +
  168. '<div class="connection-time">(' + locale.connection_time + ': ' +
  169. (conntime) +
  170. ')' +
  171. '</div><div class="total-price"> ' + locale.the_total_price_for_call_is +
  172. " " + total +
  173. " " + locale.cents;
  174. if (setupcharge > 0) {
  175. timeprice = timeprice +
  176. ' + ' + setupcharge + " " + locale.setup_fee;
  177. }
  178. timeprice = timeprice +
  179. '.' +
  180. '</font>';
  181. WebCall.updateText('connection-message', timeprice);
  182. } else {
  183. window.clearInterval(intervalid);
  184. }
  185. }
  186.  
  187. function callBack(response) {
  188. var original_response = response;
  189. var errorid = -1;
  190.  
  191. if (response.endcause) {
  192. errorid = response.endcause;
  193. }
  194.  
  195. if (response.ASideSetupCharge) {
  196. ASideSetupCharge = parseInt(response.ASideSetupCharge);
  197. ASideTariff = parseInt(response.ASideTariff);
  198. ASideTariffIntervall = parseInt(response.ASideTariffIntervall);
  199. BSideSetupCharge = parseInt(response.BSideSetupCharge);
  200. BSideTariff = parseInt(response.BSideTariff);
  201. BSideTariffIntervall = parseInt(response.BSideTariffIntervall);
  202. }
  203.  
  204. if (response.callstate) {
  205. if (response.callstate == "connected") {
  206. displayConnectionTime();
  207. }
  208. }
  209.  
  210. var additional_to = "";
  211. var additional_from = "";
  212.  
  213. callstate = response.callstate;
  214. callstate_code = response.code;
  215.  
  216. if (response.status) {
  217. if (response.status == "disconnected") {
  218. callstate = "disconnected";
  219. }
  220. }
  221.  
  222. if ((callstate == "adialing" || callstate == "aringing" || callstate == "aanswered" || callstate == "bdialing" || callstate == "bringing" || callstate == "banswered" || callstate == "connected")) {
  223. if (!document.getElementById('disconnect-iframe')) {
  224. WebCall.updateText('disconnect-option', disconnectoption);
  225. }
  226. additional_from = '<div class="connection-fee">';
  227. if (ASideTariff != 0) {
  228. additional_from += parseFloat(ASideTariff / 10000) + " " + locale.rate_cents;
  229. } else {
  230. additional_from += locale.free;
  231. }
  232.  
  233. additional_from += '</div>';
  234.  
  235. additional_to = '<div class="connection-fee">';
  236. if (BSideTariff != 0) {
  237. additional_to += parseFloat(BSideTariff / 10000) + " " + locale.rate_cents;
  238. } else {
  239. additional_to += locale.free;
  240. }
  241.  
  242. additional_to += '</div>';
  243. }
  244.  
  245. if (callstate == "banswered") {
  246.  
  247. WebCall.updateText('connection-message', '');
  248. WebCall.updateText('from-status', additional_from);
  249.  
  250.  
  251. createNewConnection(6);
  252. isconnected = false;
  253. } else if (callstate == "dialing") {
  254.  
  255. WebCall.updateText('connection-message', locale.dialing);
  256.  
  257.  
  258. createNewConnection(1);
  259. isconnected = false;
  260. } else if (callstate == "adialing") {
  261.  
  262. WebCall.updateText('connection-message', locale.dialing);
  263. WebCall.updateText('from-status', locale.pickup + additional_from);
  264. WebCall.updateText('to-status', '&nbsp;' + additional_to);
  265.  
  266.  
  267. createNewConnection(2);
  268. isconnected = false;
  269. } else if (callstate == "aringing") {
  270.  
  271. WebCall.updateText('connection-message', '');
  272. WebCall.updateText('from-status', locale.pickup + additional_from);
  273. WebCall.updateText('to-status', '&nbsp;' + additional_to);
  274.  
  275.  
  276. createNewConnection(2);
  277. isconnected = false;
  278. } else if (callstate == "aanswered") {
  279.  
  280. WebCall.updateText('connection-message', '');
  281. WebCall.updateText('from-status', additional_from);
  282.  
  283.  
  284. createNewConnection(3);
  285. isconnected = false;
  286. } else if (callstate == "bdialing") {
  287.  
  288. WebCall.updateText('connection-message', locale.waiting_other_party);
  289. WebCall.updateText('from-status', locale.picked_up + additional_from);
  290. WebCall.updateText('to-status', locale.dialing + additional_to);
  291.  
  292.  
  293. createNewConnection(4);
  294. isconnected = false;
  295. } else if (callstate == "bringing") {
  296.  
  297. WebCall.updateText('connection-message', locale.waiting_other_party);
  298. WebCall.updateText('from-status', locale.picked_up + additional_from);
  299. WebCall.updateText('to-status', locale.ringing + additional_to);
  300.  
  301.  
  302. createNewConnection(5);
  303. isconnected = false;
  304. } else if (callstate == "disconnected") {
  305. isconnected = false;
  306. var cause = "";
  307. if (errorid != -1 && errorid != 0) {
  308. cause = getErrorDisplay(response, errormessages[errorid]);
  309. if (errorid == 1 || errorid == 16) cause += "&nbsp;" + creditlink.data;
  310. if (errorid == 26) {
  311. cause = '' + locale.technical_error;
  312. }
  313. cause += "";
  314. }
  315. $('#connection-message').addClass('notification');
  316. $('#connection-message').addClass('error');
  317. $('#connection-message').addClass('png_bg');
  318. WebCall.updateText('connection-message', '<div>' + cause + '</div>');
  319. if (errorid == 1 || errorid == 16) {
  320. WebCall.updateText('calloptions', buy_credit_form.data);
  321. } else if (errorid == 27) {
  322. WebCall.updateText('connection-message', locale.no_longer_available);
  323. } else {
  324. WebCall.updateText('calloptions', redial_new_call_form.data);
  325. }
  326. WebCall.updateText('disconnect-option', '');
  327. WebCall.updateText('from-status', locale.call_disconnected);
  328. WebCall.updateText('to-status', locale.call_disconnected);
  329. createFinalConnection();
  330. } else if (callstate == "disconnecting") {
  331. isconnected = false;
  332. var cause = "";
  333. if (errorid != -1 && errorid != 0) {
  334. cause = getErrorDisplay(response, errormessages[errorid]);
  335. if (errorid == 1 || errorid == 16) {
  336. cause += '&nbsp;' + creditlink.data;
  337. }
  338. }
  339. WebCall.updateText('connection-message', cause);
  340. if (errorid == 1 || errorid == 16) {
  341. WebCall.updateText('calloptions', buy_credit_form.data);
  342. } else {
  343. WebCall.updateText('calloptions', redial_new_call_form.data);
  344. }
  345. WebCall.updateText('from-status', locale.call_disconnected);
  346. WebCall.updateText('to-status', locale.call_disconnected);
  347. WebCall.updateText('disconnect-option', '');
  348. } else if (callstate == "connected") {
  349. if (!isconnected) {
  350. WebCall.updateText('from-status', locale.call_connected + additional_from);
  351. WebCall.updateText('to-status', locale.call_connected + additional_to);
  352. }
  353.  
  354.  
  355. createNewConnection(6);
  356. isconnected = true;
  357. intervalid = window.setInterval('displayConnectionTime()', 1000);
  358. } else if (callstate == "error" || callstate == "unknown") {
  359. isconnected = false;
  360. WebCall.updateText('calloptions', redial_new_call_form.data);
  361. if (errorid == 27) {
  362. WebCall.updateText('connection-message', locale.no_longer_available);
  363. } else {
  364. WebCall.updateText('disconnect-option', '');
  365. }
  366. WebCall.updateText('from-status', locale.call_disconnected);
  367. WebCall.updateText('to-status', locale.call_disconnected);
  368.  
  369. } else if (callstate == "missedstatus") {
  370.  
  371. createNewConnection(callstate_code);
  372.  
  373. WebCall.updateText('disconnect-option', '');
  374. } else {
  375. isconnected = false;
  376. if (original_response) {
  377. WebCall.updateText('calloptions', locale.an_error_occured);
  378. WebCall.updateText('from-status', locale.call_disconnected);
  379. WebCall.updateText('to-status', locale.call_disconnected);
  380. WebCall.updateText('disconnect-option', '');
  381. }
  382. }
  383. }
  384.  
  385. function getErrorDisplay(response, localemessage) {
  386.  
  387. var errormessage =
  388. (response.Error.Long != '') ? response.Error.Long :
  389. (response.Error.Medium != '') ? response.Error.Medium :
  390. (response.Error.Short != '') ? response.Error.Short :
  391. localemessage;
  392.  
  393. var displaymessage = '<h5>' + response.Error.Header + '</h5>' + errormessage;
  394.  
  395. return displaymessage;
  396. }
  397.  
  398. function createFinalConnection() {
  399. $.ajax({
  400. type: "POST",
  401. url: "https://www.voipstunt.com/x_status/p2p_balance",
  402. dataType: "json",
  403. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6",
  404. success: function(response) {
  405. if (response.error == "reload_page") {
  406. window.setTimeout('location.href=\'https://www.voipstunt.com/warning.html\';', 1000);
  407. } else {
  408. WebCall.updateBalance(response);
  409. }
  410. }
  411. });
  412. }
  413.  
  414. function createNewConnection(connstatus) {
  415. if (isdisconnecting) return;
  416. if (connstatus == 2) {
  417. $.ajax({
  418. type: "POST",
  419. url: "https://www.voipstunt.com/x_status/p2p",
  420. dataType: "json",
  421. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6&_xwccs=M25cM25cpzR%253D",
  422. success: function(response) {
  423. callBack(response);
  424. }
  425. });
  426. }
  427. if (connstatus == 3) {
  428. $.ajax({
  429. type: "POST",
  430. url: "https://www.voipstunt.com/x_status/p2p",
  431. dataType: "json",
  432. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6&_xwccs=MTIlMKqmozSu",
  433. success: function(response) {
  434. callBack(response);
  435. }
  436. });
  437. }
  438. if (connstatus == 4) {
  439. $.ajax({
  440. type: "POST",
  441. url: "https://www.voipstunt.com/x_status/p2p",
  442. dataType: "json",
  443. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6&_xwccs=M25cM25cpzV%253D",
  444. success: function(response) {
  445. callBack(response);
  446. }
  447. });
  448. }
  449. if (connstatus == 5) {
  450. $.ajax({
  451. type: "POST",
  452. url: "https://www.voipstunt.com/x_status/p2p",
  453. dataType: "json",
  454. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6&_xwccs=MTI0L2Ihoz9w",
  455. success: function(response) {
  456. callBack(response);
  457. }
  458. });
  459. }
  460. if (connstatus == 6 || connstatus == 7) {
  461. $.ajax({
  462. type: "POST",
  463. url: "https://www.voipstunt.com/x_status/p2p",
  464. dataType: "json",
  465. data: "_xwcun=L2ImMKW1L2Im&_xwcup=ZKWyn2AunTEyn2SB&_xwcci=AQRjBQp4AmRlBD%253D%253D&_xwcwx=AGVlAQN4ZmR5&_xwcip=ZQNkYwxhZwtkYwx0&31d35abc82f90f7ac71d1c5aa235380f=2c0b27ac6c1beaa90575db1e229702d6&_xwccs=MTI0L2Ihoz9wp2yx",
  466. success: function(response) {
  467. callBack(response);
  468. }
  469. });
  470. }
  471. }
  472.  
  473.  
  474.  
  475. $(document).ready(function() {
  476.  
  477. $('#search_keyword').keyup(function() {
  478. var keyword = $('#search_keyword').val();
  479. $.ajax({
  480. url: "https://www.voipstunt.com/component_loader/",
  481. data: "module=contacts&component=ajax_search&update_id=&" + $(this).closest('form').serialize(),
  482. async: true,
  483. success: function(response) {
  484. $('#contact_list_block').html(response);
  485.  
  486. $('.toggle').click(
  487. function() {
  488. if ($(this).next().attr('class') == 'hide-details') {
  489. $(this).next().fadeTo(0, 400, function() { // next container will be shown
  490. $(this).slideDown(400);
  491. });
  492. $(this).removeClass('hr');
  493. $(this).next().removeClass('hide-details');
  494. $(this).next().addClass('show-details');
  495. } else {
  496. $(this).next().fadeTo(400, 0, function() { // next container will be hidden
  497. $(this).slideUp(400);
  498. });
  499. if ($(this).hasClass('contacts')) {
  500. $(this).addClass('hr');
  501. }
  502. $(this).next().removeClass('show-details');
  503. $(this).next().addClass('hide-details');
  504. }
  505. return false;
  506. }
  507. );
  508.  
  509. },
  510. type: "POST"
  511. });
  512. });
  513.  
  514. });
  515.  
  516.  
  517. $('.main-nav-phone_to_phone-index').addClass('active');
  518. $('#nav_phone_to_phone_index').addClass('active_nav');
  519.  
  520.  
  521.  
  522. var more_position = $('.main-nav-more-menu').position();
  523. var hide = false;
  524.  
  525. function more_menu(show) {
  526. if (show) {
  527. hide = true
  528. $('.footer-nav .more_menu').removeClass('not-visible').addClass('visible');
  529. $('.more_menu.visible').css('top', more_position.top).css('left', more_position.left + 50);
  530. } else if (hide == false) {
  531. $('.footer-nav .more_menu').removeClass('visible').addClass('not-visible');
  532. }
  533. }
  534.  
  535. $(document).ready(function() {
  536.  
  537. $('.main-nav-more-menu').hover(
  538. function() {
  539. more_menu(true);
  540. },
  541. function() {
  542. hide = false;
  543. setTimeout(function() {
  544. more_menu(false)
  545. }, 1000);
  546. }
  547. );
  548. $('.more_menu').hover(
  549. function() {
  550. more_menu(true);
  551. },
  552. function() {
  553. hide = false;
  554. setTimeout(function() {
  555. more_menu(false)
  556. }, 1000);
  557. }
  558. );
  559. });
  560.  
  561. $('#dialogBtn').click(function() {
  562. openBrowserCall();
  563. });
  564.  
  565. if (typeof WebSocket == 'undefined') {
  566. $('#webcall-dialog').hide();
  567. }
  568.  
  569. function addHashLinkToAction(wc_page) {
  570. $('form').each(function() {
  571. var cur_action = $(this).attr('action');
  572. var new_action = '';
  573. if (cur_action.substr(cur_action.length - 1) == '/') {
  574. cur_action = cur_action.substr(0, cur_action.length - 1);
  575. }
  576. if (wc_page != '') {
  577. new_action = cur_action + wc_page;
  578. $(this).attr('action', new_action);
  579. } else {
  580. var n = cur_action.lastIndexOf('#');
  581. $(this).attr('action', cur_action.substr(0, n));
  582. }
  583.  
  584. })
  585. }
  586.  
  587. function openBrowserCall() {
  588. var isAuth = 1;
  589. var webcall_pages = new Array('#/login', '#/call', '#/sms', '#/phonebook');
  590. if ($.inArray(window.location.hash, webcall_pages) < 0 || window.location.protocol != 'https:') {
  591. window.location.href = 'https://www.voipstunt.com/phone_to_phone/#/phonebook';
  592. setCookie('open_browsercall', 1, 0, '/');;
  593. if ($.inArray(window.location.hash, webcall_pages) > -1) {
  594. $('#webcall-dialog').slideToggle();
  595. $('#dialogButtons').hide();
  596. addHashLinkToAction('/#/phonebook');
  597. }
  598. } else {
  599. addHashLinkToAction('/#/phonebook');
  600. $('#webcall-dialog').slideToggle();
  601. $('#dialogButtons').hide();
  602. }
  603. return false;
  604. }
  605.  
  606. function minimizeBrowserCall() {
  607. addHashLinkToAction('');
  608. setCookie('open_browsercall', 0, 0, '/');
  609. $('#webcall-dialog').slideUp(function() {
  610. $('#dialogButtons').show();
  611. return false;
  612. });
  613. }
  614.  
  615. $('#minimize-widget').click(function() {
  616. minimizeBrowserCall();
  617. });
  618.  
  619. $('.close-widget').click(function() {
  620.  
  621. var closeconfirm = confirm('Are you sure you want to close the "Make a Call" function?');
  622.  
  623. if (closeconfirm) {
  624. $('#webcall-dialog-container').hide();
  625. setCookie('disable_makeacall_widget', 1, 3600);
  626. }
  627.  
  628. return false;
  629. });
  630.  
  631. if (retrieveCookie('open_browsercall') == 1) {
  632. openBrowserCall();
  633. setCookie('open_browsercall', 0, 'delete');
  634. }
  635.  
  636. window.addEventListener('message', function(event) {
  637. if (event.origin === 'https://webclient.directwebconnect.com') {
  638. var location = (document.URL).replace(/#(.*)/, '#');
  639. switch (event.data.message) {
  640. case 'new_call':
  641. window.location.href = location + '/call/';
  642. break;
  643. case 'save_contact':
  644. window.postMessage({
  645. message: 'saveContact',
  646. number: event.data.params.number
  647. }, '*');
  648. window.location.href = location + '/phonebook/';
  649.  
  650. break;
  651. case 'buy_credit':
  652. window.location.href = '/buy_credit2';
  653. break;
  654. }
  655. }
  656.  
  657. }, false);
  658.  
  659.  
  660. var trackPm = new Array('Carte Bleue', 'Dankort DK', 'ChinaUnionPay', 'MBNet', 'Cartes Bancaires');
  661. $('#payment-method-list li').each(function() {
  662.  
  663. $('a').click(function() {
  664. page_label = $(this).text();
  665.  
  666. if ($.inArray(page_label, trackPm) > -1) {
  667. _gaq.push(['_trackEvent', 'Hard coded payment method clicks', 'click', page_label])
  668. }
  669. });
  670.  
  671. $('input:image').click(function() {
  672.  
  673. page_label = $(this).attr('value');
  674.  
  675. if ($.inArray(page_label, trackPm) > -1) {
  676. _gaq.push(['_trackEvent', 'Hard coded payment method clicks', 'click', page_label])
  677. }
  678. });
  679. });
  680. (function() {
  681. function requireJs(file, callback) {
  682. var script = document.createElement('script');
  683. script.src = file;
  684. script.type = 'text/javascript';
  685. script.onload = callback;
  686.  
  687. script.onreadystatechange = function() {
  688. if (this.readyState == 'complete') {
  689. callback();
  690. }
  691. }
  692.  
  693. var s = document.getElementsByTagName('script')[0];
  694. s.parentNode.insertBefore(script, s);
  695. }
  696.  
  697. var baOnload = function() {
  698. /*{DEBUG}*/
  699. ba.trackView();
  700. ba.trackClicks();
  701. ba.trackSubmits();
  702. };
  703.  
  704. requireJs('/resource/ba/dist/ba.min.js', function() {
  705. baOnload();
  706. });
  707.  
  708. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement