alikwelyn

js-netwins

Dec 7th, 2016
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var defaultDollarPrice = "";
  3. var discount_percent = 10;
  4. var Send_Final_Price = "";
  5. var Server_Id = "";
  6.  
  7. var ChampListArray = [];
  8. var RoleListArray = [];
  9. var activeCount = 0;
  10. $('.roleimg').click(function () {
  11. var positions = $('#Roles').val();
  12. //var rolesLength = positions.split(';').length;
  13. var rolesLength = RoleListArray.length;
  14.  
  15. if ($(this).find('img').hasClass("position")) {
  16. // true
  17. if (parseInt(rolesLength, 10) > 2 || parseInt(rolesLength, 10) < 2) {
  18. $(this).find('img').addClass('position active').removeClass('position');
  19. var roleID = $(this).attr('data-id');
  20. var image = $(this).find('img').attr('src');
  21. RoleListArray.push({
  22. Id: roleID,
  23. Image: image,
  24. posName: positionName
  25. });
  26. activeCount = parseInt(activeCount) + 1;
  27. $(this).find('span').text(activeCount);
  28. }
  29. else {
  30. alert("You can't select more or less than two positions");
  31. }
  32. }
  33. else {
  34. $(this).find('img').addClass('position').removeClass('active');
  35. //remove role here
  36. var ID = $(this).attr('data-id');
  37. $(this).find('span').text('');
  38. activeCount = parseInt(activeCount) - 1;
  39. $('.col-right').find('.roleimg').find('img').each(function () {
  40. if ($(this).hasClass("active")) {
  41. $(this).closest('.roleimg').find('span').text(activeCount);
  42. }
  43. })
  44. var positionName = $(this).attr('data-name');
  45. var result = $.grep(RoleListArray, function (e) {
  46. return e.Id != ID;
  47. });
  48. RoleListArray = [];
  49. $.each(result, function (index, value) {
  50. RoleListArray.push({
  51. Id: value.Id,
  52. Image: value.Image,
  53. posName: value.positionName
  54. });
  55. });
  56. }
  57. });
  58.  
  59.  
  60. $('.champion-item').click(function () {
  61. //$(this).css('opacity', '1');
  62. if ($(this).css('opacity') == '0.3') {
  63. $(this).css('opacity', '1');
  64. var championID = $(this).attr('data-id');
  65. var image = $(this).find('img').attr('src');
  66. ChampListArray.push({
  67. Id: championID,
  68. Image: image
  69. });
  70. }
  71. else {
  72. $(this).css('opacity', '0.3');
  73. var ID = $(this).attr('data-id');
  74. var result = $.grep(ChampListArray, function (e) {
  75. return e.Id != ID;
  76. });
  77. ChampListArray = [];
  78. $.each(result, function (index, value) {
  79. ChampListArray.push({
  80. Id: value.Id,
  81. Image: value.Image,
  82. });
  83. });
  84. }
  85. })
  86.  
  87. $('#select_roles').click(function () {
  88. activeCount = 0;
  89. $('.roles-list').show();
  90. $(this).css('background-color', 'rgba(255, 255, 0, 0.19)');
  91. $('#select_roles_champs').css('background-color', '#fff');
  92. $('.col-left,.champion-list').fadeOut(1000);
  93. $('.col-right').find('.roleimg').find('img').each(function () {
  94. $(this).removeClass('active').addClass('position');
  95. });
  96. $('.col-right').find('.roleimg').find('span').each(function () {
  97. $(this).text('');
  98. })
  99. $('#Roles').val('');
  100. $('.col-right').fadeIn(1000);
  101. $('#champions').val('');
  102. ChampListArray = [];
  103. RoleListArray = [];
  104. });
  105.  
  106. $('#select_roles_champs').click(function () {
  107. activeCount = 0;
  108. $(this).css('background-color', 'rgba(255, 255, 0, 0.19)');
  109. $('#select_roles').css('background-color', '#fff');
  110. $('.roles-list').show();
  111. $('.col-right').fadeIn(1000);
  112. $('#champions').val('');
  113. $('#Roles').val('');
  114. $('.col-right').find('.roleimg').find('img').each(function () {
  115. $(this).removeClass('active').addClass('position');
  116. })
  117. $('.col-right').find('.roleimg').find('span').each(function () {
  118. $(this).text('');
  119. })
  120. ChampListArray = [];
  121. RoleListArray = [];
  122. $('.champion-list').find('.champion-item').each(function () {
  123. $(this).css('opacity', 0.3);
  124. });
  125. $('.col-left,.champion-list').fadeIn(1000);
  126. });
  127.  
  128. $('#save').click(function () {
  129. var RoleLIst = "";
  130. $('#sel_role').css('border', '3px #ddd dotted');
  131. var roles = $('#Roles').val();
  132. if (parseInt(RoleListArray.length) >= 2) {
  133. //$('.roles_div').find('span').text('Roles' + " " + "(+20%)");
  134. //var role = roles.split(';');
  135. $('.roles_div').show();
  136. $('.roles_div').find('li').each(function () {
  137. $(this).remove();
  138. })
  139. $.each(RoleListArray, function (index, value) {
  140. RoleLIst = RoleLIst + value.Id + ";";
  141. var count = parseInt(index) + 1;
  142. $('.roles_div').find('ul').append('<li><img src="' + value.Image + '" alt="role" class="active" /></br>(' + count + ')</li>');
  143. });
  144. $('#Roles').val(RoleLIst.slice(0, -1));
  145. }
  146. else {
  147. alert('Please select at least two positions');
  148. return false;
  149. }
  150. var i;
  151. var list = "";
  152. $('.roles_champs').hide();
  153. $('#rolesp').text('');
  154. $('.champlist').find('li').find('img').each(function () {
  155. $(this).remove();
  156. });
  157. $('.champlist').show();
  158. $.each(ChampListArray, function (index, value) {
  159. var percent = "";
  160. var count = ChampListArray.length;
  161. if (ChampListArray.length <= 5) {
  162. percent = 45;
  163. }
  164. else if (ChampListArray.length > 5) {
  165. percent = 30;
  166. }
  167. $('.roles_champs').hide();
  168. $('#rolesp').text('');
  169. //$('#spnchampions').text('champions (+ ' + percent + '%)');
  170. $('#spnchampions').text('champions');
  171. list = list + value.Id + "|";
  172. $('.champlist').find('li').append('<img src="' + value.Image + '" alt="champion" />');
  173. });
  174. if (list != "") {
  175. $('.champs_div').show();
  176. if (ChampListArray.length == 0) {
  177. //$('.roles_div').find('span').text('Roles' + " " + '(+20%)');
  178. $('.roles_div').find('span').text('Roles');
  179. }
  180. else {
  181. $('.roles_div').find('span').text('Roles');
  182. }
  183. }
  184. else {
  185. $('.champs_div').hide();
  186. }
  187. $('#champions').val(list.slice(0, -1));
  188. setpricebycheckbox();
  189. })
  190.  
  191. $('#save2').click(function () {
  192. var RoleLIst = "";
  193. $('#sel_role').css('border', '3px #ddd dotted');
  194. var roles = $('#Roles').val();
  195. if (parseInt(RoleListArray.length) >= 2) {
  196. //$('.roles_div').find('span').text('Roles' + " " + "(+20%)");
  197. //var role = roles.split(';');
  198. $('.roles_div').show();
  199. $('.roles_div').find('li').each(function () {
  200. $(this).remove();
  201. })
  202. $.each(RoleListArray, function (index, value) {
  203. RoleLIst = RoleLIst + value.Id + ";";
  204. var count = parseInt(index) + 1;
  205. $('.roles_div').find('ul').append('<li><img src="' + value.Image + '" alt="role" class="active" /></br>(' + count + ')</li>');
  206. });
  207. $('#Roles').val(RoleLIst.slice(0, -1));
  208. }
  209. else {
  210. alert('Please select at least two positions');
  211. return false;
  212. }
  213. var i;
  214. var list = "";
  215. $('.roles_champs').hide();
  216. $('#rolesp').text('');
  217. $('.champlist').find('li').find('img').each(function () {
  218. $(this).remove();
  219. });
  220. $('.champlist').show();
  221. $.each(ChampListArray, function (index, value) {
  222. var percent = "";
  223. var count = ChampListArray.length;
  224. if (ChampListArray.length <= 5) {
  225. percent = 45;
  226. }
  227. else if (ChampListArray.length > 5) {
  228. percent = 30;
  229. }
  230. $('.roles_champs').hide();
  231. $('#rolesp').text('');
  232. //$('#spnchampions').text('champions (+ ' + percent + '%)');
  233. $('#spnchampions').text('champions');
  234. list = list + value.Id + "|";
  235. $('.champlist').find('li').append('<img src="' + value.Image + '" alt="champion" />');
  236. });
  237. if (list != "") {
  238. $('.champs_div').show();
  239. if (ChampListArray.length == 0) {
  240. //$('.roles_div').find('span').text('Roles' + " " + '(+20%)');
  241. $('.roles_div').find('span').text('Roles');
  242. }
  243. else {
  244. $('.roles_div').find('span').text('Roles');
  245. }
  246. }
  247. else {
  248. $('.champs_div').hide();
  249. }
  250. $('#champions').val(list.slice(0, -1));
  251. setpricebycheckbox();
  252. })
  253.  
  254.  
  255. $(".set").click(function () {
  256. $('#sel_league').css('border', '3px #ddd dotted');
  257. var str2 = "";
  258. var str = $(this).html();
  259. var leagueid = $(this).attr('data-boostleague-id');
  260. var divisionid = $(this).attr('data-division-current-fk');
  261. var serverId = Server_Id;
  262. var url = $(this).closest("div.boost-type").find("img").attr("src");
  263. $('.newicon').attr('src', url);
  264. var ret = str.split(" ");
  265. var str1 = ret[0];
  266. if (typeof ret[1] === "undefined") {
  267. str2 = "League";
  268. }
  269. else {
  270. str2 = ret[1];
  271. }
  272. $('.spndiv').text(str1);
  273. $('.spnleag').text(str2);
  274. $('#current').val(leagueid + ";" + divisionid);
  275. $.ajax({
  276. type: "POST",
  277. contentType: "application/json",
  278. url: "/getnetwinprice",
  279. data: JSON.stringify({ fromleagID: leagueid, serverID: serverId, fromDivID: divisionid }),
  280. //beforeSend: function () {
  281. // $(".post_submitting").show().html("<center><img src='images/loading.gif'/></center>");
  282. //},
  283. success: function (response) {
  284. defaultDollarPrice = response;
  285. $('#hfresponse').val(response);
  286. setpricebycheckbox();
  287. }
  288. });
  289. });
  290.  
  291.  
  292. $('#no_opt').click(function () {
  293. $('#sel_role').css('border', '3px #ddd dotted');
  294. $('#champions').val('');
  295. $('#Roles').val('');
  296. $('.champlist').find('li').find('img').each(function () {
  297. $(this).remove();
  298. });
  299. $('#rolesp').text('Any Champs and roles');
  300. $('.roles_champs').show();
  301. $('#Extraprice').val('');
  302. $('.champs_div').hide();
  303. $('.roles_div').hide();
  304. RoleListArray = [];
  305. ChampListArray = [];
  306. setpricebycheckbox();
  307. })
  308.  
  309.  
  310. $(".serverid").click(function (e) {
  311. $('#sel_server').css('border', '3px #ddd dotted');
  312. $('#servername').text($(this).text());
  313. var serverId = $(this).attr('data-id');
  314. $('#GameServerFk').val(serverId);
  315. Server_Id = serverId;
  316. var string = $('#current').val();
  317. var ret = string.split(";");
  318. var leagueID = ret[0];
  319. var divisionid = ret[1];
  320. $.ajax({
  321. type: "POST",
  322. contentType: "application/json",
  323. url: "/getnetwinprice",
  324. data: JSON.stringify({ fromleagID: leagueID, serverID: serverId, fromDivID: divisionid }),
  325. //beforeSend: function () {
  326. // $(".post_submitting").show().html("<center><img src='images/loading.gif'/></center>");
  327. //},
  328. success: function (response) {
  329. defaultDollarPrice = response;
  330. $('#hfresponse').val(response);
  331. setpricebycheckbox();
  332. }
  333. });
  334. });
  335.  
  336. $('#flatOneRoundedCheckbox').change(function () {
  337. setpricebycheckbox();
  338. });
  339. function setpricebycheckbox() {
  340. var discountpercentage = parseInt(discount_percent, 10);
  341. var final_price = "";
  342. var positions = $('#Roles').val();
  343. var result = $('#hfresponse').val();
  344. var number_of_games = parseInt($('#slider-range-max-amount').text(), 10);
  345. var price_in_dollar = parseFloat(defaultDollarPrice).toFixed(2);
  346. var currency_rate = parseFloat($('#CurrencyRate').val()).toFixed(2);
  347. var champions = $('#champions').val();
  348. //for usd
  349. if ($('#flatOneRoundedCheckbox').is(':checked')) {
  350. var dollar_rate = (price_in_dollar * number_of_games).toFixed(2);
  351.  
  352. if (ChampListArray.length > 0) {
  353. var champs = ChampListArray.length;
  354. if (parseInt(champs) == -1) {
  355. var new_price = dollar_rate * 20 / 100;
  356. dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price)).toFixed(2);
  357. $('#Extraprice').val(new_price);
  358. }
  359. else if (parseInt(champs) > 5) {
  360. var new_price_champs = parseFloat(dollar_rate) * 30 / 100;
  361. dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price_champs)).toFixed(2);
  362. $('#Extraprice').val(new_price_champs);
  363. }
  364. else if (parseInt(champs) >= 1 && parseInt(champs) <= 5) {
  365. var new_price_champs_new = parseFloat(dollar_rate) * 45 / 100;
  366. dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price_champs_new)).toFixed(2);
  367. $('#Extraprice').val(new_price_champs_new);
  368. }
  369. }
  370. else if (RoleListArray.length > 0) {
  371. var new_price = dollar_rate * 20 / 100;
  372. dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price)).toFixed(2);
  373. $('#Extraprice').val(new_price);
  374. }
  375. else if (RoleListArray.length == 0) {
  376. dollar_rate = (parseFloat(dollar_rate)).toFixed(2);
  377. $('#Extraprice').val('');
  378. }
  379. if (result != 'False' && result != '') {
  380. $('#price_div').css('border', '3px dotted #ddd');
  381. final_price = dollar_rate - (dollar_rate * discountpercentage / 100);
  382. $('#amount').show();
  383. $('#temp_price').show();
  384. $('#price').val(parseFloat(final_price).toFixed(2));
  385. Send_Final_Price = parseFloat(final_price).toFixed(2);
  386. $('#temp_price').text("$" + parseFloat(dollar_rate).toFixed(2));
  387. $('#amount').text("$" + parseFloat(final_price).toFixed(2));
  388. $('#CurrencyType').val('USD');
  389. $('#loader').hide();
  390. }
  391. }
  392. //for EURO
  393. else {
  394. var euro_rate = "";
  395. euro_rate = (price_in_dollar * currency_rate * number_of_games).toFixed(2);
  396. if (ChampListArray.length > 0) {
  397. var champs = ChampListArray.length;
  398. if (parseInt(champs) == -1) {
  399. var new_price = euro_rate * 20 / 100;
  400. euro_rate = (parseFloat(euro_rate) + parseFloat(new_price)).toFixed(2);
  401. $('#Extraprice').val(new_price);
  402. }
  403. else if (parseInt(champs) > 5) {
  404. var new_price_champs = parseFloat(euro_rate) * 30 / 100;
  405. euro_rate = (parseFloat(euro_rate) + parseFloat(new_price_champs)).toFixed(2);
  406. $('#Extraprice').val(new_price_champs);
  407. }
  408. else if (parseInt(champs) >= 1 && parseInt(champs) <= 5) {
  409. var new_price_champs_new = parseFloat(euro_rate) * 45 / 100;
  410. euro_rate = (parseFloat(euro_rate) + parseFloat(new_price_champs_new)).toFixed(2);
  411. $('#Extraprice').val(new_price_champs_new);
  412. }
  413. }
  414. else if (RoleListArray.length > 0) {
  415. var new_price = euro_rate * 20 / 100;
  416. euro_rate = (parseFloat(euro_rate) + parseFloat(new_price)).toFixed(2);
  417. $('#Extraprice').val(new_price);
  418. }
  419. else if (RoleListArray.length == "") {
  420. euro_rate = (parseFloat(euro_rate)).toFixed(2);
  421. $('#Extraprice').val('');
  422. }
  423. if (result != 'False' && result != '') {
  424. $('#price_div').css('border', '3px dotted #ddd');
  425. final_price = euro_rate - (euro_rate * discountpercentage / 100);
  426. $('#amount').show();
  427. $('#temp_price').show();
  428. $('#price').val(parseFloat(final_price).toFixed(2));
  429. Send_Final_Price = parseFloat(final_price).toFixed(2);
  430. $('#temp_price').text("\u20AC" + parseFloat(euro_rate).toFixed(2));
  431. $('#amount').text(("\u20AC" + parseFloat(final_price).toFixed(2)));
  432. $('#CurrencyType').val('EUR');
  433. $('#loader').hide();
  434. }
  435. }
  436. }
  437.  
  438. //-------------checkout--------------
  439.  
  440. $('#checkoutNow').click(function () {
  441. var Price = $('#price').val();
  442. var amount = $('#amount').text();
  443. if (Price == "" || amount == "") {
  444. alert("Please select all the fields");
  445. return false;
  446. }
  447. else if (parseInt(Price) == 0 || amount == "") {
  448. alert("Please select all the fields");
  449. return false;
  450. }
  451. else {
  452. $('#logindiv').hide();
  453. $('#orderdiv').show();
  454. if ($('#hfAuth').val() == 'True') {
  455. $('.checkout-msg').html('<label class="btn btn-round btn-success" style="height:25px;padding:2px">Logged in</label>' + " " + 'Logged in as' + " " + $('#hfFullName').val() + " ");
  456. }
  457. $('#Gametype1').text('Solo Net Wins');
  458. var gametype2 = $('.spndiv').text() + " " + $('.spnleag').text() + " " + $('#slider-range-max-amount').text() + " " + "Net Wins";
  459. $('#Gametype2').text(gametype2);
  460. $('#priceCheckout').text($('#amount').text());
  461. }
  462. });
  463.  
  464. //-------------------checkout------------------------------
  465.  
  466.  
  467. $('.payment-right-column').click(function () {
  468. $(this).closest('.payment-column').find('.payment-left-column').find('.paymentRadio').prop("checked", true);
  469. })
  470.  
  471. $('#backbtn').click(function () {
  472. $('#logindiv').toggle('slide', { direction: 'right' }, 100);
  473. $('#orderdiv').toggle('slide', { direction: 'left' }, 100);
  474. })
  475.  
  476. $("#user_name_pop_up, #user_password_pop_up").keyup(function (event) {
  477. if (event.keyCode == '13') {
  478. loginnow_pop_up();
  479. }
  480. })
  481.  
  482. $('#loginbtnmodal_pop_up').click(function () {
  483. loginnow_pop_up();
  484. })
  485.  
  486. function loginnow_pop_up() {
  487. $('#loader_pop_up').show();
  488. var username = $('#user_name_pop_up').val();
  489. var password = $('#user_password_pop_up').val();
  490. if (username != '' && password != '') {
  491. $.ajax({
  492. type: 'POST',
  493. url: '/Default/loginmodal_pop_up',
  494. data: { username: username, password: password },
  495. success: function (response) {
  496. if (response == 'error') {
  497. showToaster('Username/password is not correct', 'error')
  498. $('#loader_pop_up').hide();
  499. }
  500. else {
  501. $('#loader_pop_up').hide();
  502. $('#logindiv').toggle('slide', { direction: 'right' }, 100);
  503. $('.checkout-msg').html('<label class="btn btn-round btn-success" style="height:25px;padding:2px">Logged in</label>' + " " + 'Logged in as' + " " + response + " ");
  504.  
  505. $('#orderdiv').toggle('slide', { direction: 'left' }, 100);
  506. $('#loginLi').hide();
  507. var li = "<li class='menu-item'> <a class='menu-link' href='/dashboard'>My Account</a></li>" +
  508. "<li class='menu-item'> <a class='menu-link' href='/account/logout'>Logout</a></li>";
  509. $('.menu').append(li);
  510. }
  511. },
  512. error: function (response) {
  513. showToaster('Unknown error occurred', 'error')
  514. $('#loader_pop_up').hide();
  515. }
  516. });
  517. }
  518. else {
  519. showToaster('All fields are required', 'info')
  520. $('#loader_pop_up').hide();
  521. }
  522. }
  523.  
  524. $(function () {
  525. $("#login_popup").click(function () {
  526. $('#orderdiv').toggle('slide', { direction: 'right' }, 100);
  527. $('#logindiv').toggle('slide', { direction: 'left' }, 100);
  528. });
  529. });
  530.  
  531. $('#savetransaction').click(function () {
  532. var currency_rate = parseFloat($('#CurrencyRate').val(), 10);
  533. var desired = $('#slider-range-max-amount').text();
  534. var current = $('#current').val();
  535. var boosttype = $('#type').val();
  536. var extraprice = $('#Extraprice').val();
  537. var champions = $('#champions').val();
  538. var voice_option = "";
  539. //var price = $('#price').val();
  540. var price = Send_Final_Price;
  541. var currency_type = $('#CurrencyType').val();
  542. var roles = $('#Roles').val();
  543. var description = $('#Gametype1').text() + " " + $('#Gametype2').text();
  544. var serverid = Server_Id;
  545. var Payment_method = $("input[type='radio'][name='select_payment_method']:checked").val();
  546. if (Payment_method == "Paypal") {
  547. var href = "/Payment/orderpaypal";
  548. }
  549. else if (Payment_method == "G2a") {
  550. //return false;
  551. var href = "/Payment/orderG2A";
  552. }
  553. href += "?desired=" + desired + "&current=" + current + "&boosttype=" + boosttype + "&extraprice=" + extraprice + "&price=" + price + "&champions=" + champions + "&currency_type=" + currency_type + "&roles=" + roles + "&description=" + description + "&serverid=" + serverid + "&voice_option=" + voice_option;
  554. //alert(href);
  555. location.href = href;
  556. })
RAW Paste Data