Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var defaultDollarPrice = "";
- var discount_percent = 10;
- var Send_Final_Price = "";
- var Server_Id = "";
- var ChampListArray = [];
- var RoleListArray = [];
- var activeCount = 0;
- $('.roleimg').click(function () {
- var positions = $('#Roles').val();
- //var rolesLength = positions.split(';').length;
- var rolesLength = RoleListArray.length;
- if ($(this).find('img').hasClass("position")) {
- // true
- if (parseInt(rolesLength, 10) > 2 || parseInt(rolesLength, 10) < 2) {
- $(this).find('img').addClass('position active').removeClass('position');
- var roleID = $(this).attr('data-id');
- var image = $(this).find('img').attr('src');
- RoleListArray.push({
- Id: roleID,
- Image: image,
- posName: positionName
- });
- activeCount = parseInt(activeCount) + 1;
- $(this).find('span').text(activeCount);
- }
- else {
- alert("You can't select more or less than two positions");
- }
- }
- else {
- $(this).find('img').addClass('position').removeClass('active');
- //remove role here
- var ID = $(this).attr('data-id');
- $(this).find('span').text('');
- activeCount = parseInt(activeCount) - 1;
- $('.col-right').find('.roleimg').find('img').each(function () {
- if ($(this).hasClass("active")) {
- $(this).closest('.roleimg').find('span').text(activeCount);
- }
- })
- var positionName = $(this).attr('data-name');
- var result = $.grep(RoleListArray, function (e) {
- return e.Id != ID;
- });
- RoleListArray = [];
- $.each(result, function (index, value) {
- RoleListArray.push({
- Id: value.Id,
- Image: value.Image,
- posName: value.positionName
- });
- });
- }
- });
- $('.champion-item').click(function () {
- //$(this).css('opacity', '1');
- if ($(this).css('opacity') == '0.3') {
- $(this).css('opacity', '1');
- var championID = $(this).attr('data-id');
- var image = $(this).find('img').attr('src');
- ChampListArray.push({
- Id: championID,
- Image: image
- });
- }
- else {
- $(this).css('opacity', '0.3');
- var ID = $(this).attr('data-id');
- var result = $.grep(ChampListArray, function (e) {
- return e.Id != ID;
- });
- ChampListArray = [];
- $.each(result, function (index, value) {
- ChampListArray.push({
- Id: value.Id,
- Image: value.Image,
- });
- });
- }
- })
- $('#select_roles').click(function () {
- activeCount = 0;
- $('.roles-list').show();
- $(this).css('background-color', 'rgba(255, 255, 0, 0.19)');
- $('#select_roles_champs').css('background-color', '#fff');
- $('.col-left,.champion-list').fadeOut(1000);
- $('.col-right').find('.roleimg').find('img').each(function () {
- $(this).removeClass('active').addClass('position');
- });
- $('.col-right').find('.roleimg').find('span').each(function () {
- $(this).text('');
- })
- $('#Roles').val('');
- $('.col-right').fadeIn(1000);
- $('#champions').val('');
- ChampListArray = [];
- RoleListArray = [];
- });
- $('#select_roles_champs').click(function () {
- activeCount = 0;
- $(this).css('background-color', 'rgba(255, 255, 0, 0.19)');
- $('#select_roles').css('background-color', '#fff');
- $('.roles-list').show();
- $('.col-right').fadeIn(1000);
- $('#champions').val('');
- $('#Roles').val('');
- $('.col-right').find('.roleimg').find('img').each(function () {
- $(this).removeClass('active').addClass('position');
- })
- $('.col-right').find('.roleimg').find('span').each(function () {
- $(this).text('');
- })
- ChampListArray = [];
- RoleListArray = [];
- $('.champion-list').find('.champion-item').each(function () {
- $(this).css('opacity', 0.3);
- });
- $('.col-left,.champion-list').fadeIn(1000);
- });
- $('#save').click(function () {
- var RoleLIst = "";
- $('#sel_role').css('border', '3px #ddd dotted');
- var roles = $('#Roles').val();
- if (parseInt(RoleListArray.length) >= 2) {
- //$('.roles_div').find('span').text('Roles' + " " + "(+20%)");
- //var role = roles.split(';');
- $('.roles_div').show();
- $('.roles_div').find('li').each(function () {
- $(this).remove();
- })
- $.each(RoleListArray, function (index, value) {
- RoleLIst = RoleLIst + value.Id + ";";
- var count = parseInt(index) + 1;
- $('.roles_div').find('ul').append('<li><img src="' + value.Image + '" alt="role" class="active" /></br>(' + count + ')</li>');
- });
- $('#Roles').val(RoleLIst.slice(0, -1));
- }
- else {
- alert('Please select at least two positions');
- return false;
- }
- var i;
- var list = "";
- $('.roles_champs').hide();
- $('#rolesp').text('');
- $('.champlist').find('li').find('img').each(function () {
- $(this).remove();
- });
- $('.champlist').show();
- $.each(ChampListArray, function (index, value) {
- var percent = "";
- var count = ChampListArray.length;
- if (ChampListArray.length <= 5) {
- percent = 45;
- }
- else if (ChampListArray.length > 5) {
- percent = 30;
- }
- $('.roles_champs').hide();
- $('#rolesp').text('');
- //$('#spnchampions').text('champions (+ ' + percent + '%)');
- $('#spnchampions').text('champions');
- list = list + value.Id + "|";
- $('.champlist').find('li').append('<img src="' + value.Image + '" alt="champion" />');
- });
- if (list != "") {
- $('.champs_div').show();
- if (ChampListArray.length == 0) {
- //$('.roles_div').find('span').text('Roles' + " " + '(+20%)');
- $('.roles_div').find('span').text('Roles');
- }
- else {
- $('.roles_div').find('span').text('Roles');
- }
- }
- else {
- $('.champs_div').hide();
- }
- $('#champions').val(list.slice(0, -1));
- setpricebycheckbox();
- })
- $('#save2').click(function () {
- var RoleLIst = "";
- $('#sel_role').css('border', '3px #ddd dotted');
- var roles = $('#Roles').val();
- if (parseInt(RoleListArray.length) >= 2) {
- //$('.roles_div').find('span').text('Roles' + " " + "(+20%)");
- //var role = roles.split(';');
- $('.roles_div').show();
- $('.roles_div').find('li').each(function () {
- $(this).remove();
- })
- $.each(RoleListArray, function (index, value) {
- RoleLIst = RoleLIst + value.Id + ";";
- var count = parseInt(index) + 1;
- $('.roles_div').find('ul').append('<li><img src="' + value.Image + '" alt="role" class="active" /></br>(' + count + ')</li>');
- });
- $('#Roles').val(RoleLIst.slice(0, -1));
- }
- else {
- alert('Please select at least two positions');
- return false;
- }
- var i;
- var list = "";
- $('.roles_champs').hide();
- $('#rolesp').text('');
- $('.champlist').find('li').find('img').each(function () {
- $(this).remove();
- });
- $('.champlist').show();
- $.each(ChampListArray, function (index, value) {
- var percent = "";
- var count = ChampListArray.length;
- if (ChampListArray.length <= 5) {
- percent = 45;
- }
- else if (ChampListArray.length > 5) {
- percent = 30;
- }
- $('.roles_champs').hide();
- $('#rolesp').text('');
- //$('#spnchampions').text('champions (+ ' + percent + '%)');
- $('#spnchampions').text('champions');
- list = list + value.Id + "|";
- $('.champlist').find('li').append('<img src="' + value.Image + '" alt="champion" />');
- });
- if (list != "") {
- $('.champs_div').show();
- if (ChampListArray.length == 0) {
- //$('.roles_div').find('span').text('Roles' + " " + '(+20%)');
- $('.roles_div').find('span').text('Roles');
- }
- else {
- $('.roles_div').find('span').text('Roles');
- }
- }
- else {
- $('.champs_div').hide();
- }
- $('#champions').val(list.slice(0, -1));
- setpricebycheckbox();
- })
- $(".set").click(function () {
- $('#sel_league').css('border', '3px #ddd dotted');
- var str2 = "";
- var str = $(this).html();
- var leagueid = $(this).attr('data-boostleague-id');
- var divisionid = $(this).attr('data-division-current-fk');
- var serverId = Server_Id;
- var url = $(this).closest("div.boost-type").find("img").attr("src");
- $('.newicon').attr('src', url);
- var ret = str.split(" ");
- var str1 = ret[0];
- if (typeof ret[1] === "undefined") {
- str2 = "League";
- }
- else {
- str2 = ret[1];
- }
- $('.spndiv').text(str1);
- $('.spnleag').text(str2);
- $('#current').val(leagueid + ";" + divisionid);
- $.ajax({
- type: "POST",
- contentType: "application/json",
- url: "/getnetwinprice",
- data: JSON.stringify({ fromleagID: leagueid, serverID: serverId, fromDivID: divisionid }),
- //beforeSend: function () {
- // $(".post_submitting").show().html("<center><img src='images/loading.gif'/></center>");
- //},
- success: function (response) {
- defaultDollarPrice = response;
- $('#hfresponse').val(response);
- setpricebycheckbox();
- }
- });
- });
- $('#no_opt').click(function () {
- $('#sel_role').css('border', '3px #ddd dotted');
- $('#champions').val('');
- $('#Roles').val('');
- $('.champlist').find('li').find('img').each(function () {
- $(this).remove();
- });
- $('#rolesp').text('Any Champs and roles');
- $('.roles_champs').show();
- $('#Extraprice').val('');
- $('.champs_div').hide();
- $('.roles_div').hide();
- RoleListArray = [];
- ChampListArray = [];
- setpricebycheckbox();
- })
- $(".serverid").click(function (e) {
- $('#sel_server').css('border', '3px #ddd dotted');
- $('#servername').text($(this).text());
- var serverId = $(this).attr('data-id');
- $('#GameServerFk').val(serverId);
- Server_Id = serverId;
- var string = $('#current').val();
- var ret = string.split(";");
- var leagueID = ret[0];
- var divisionid = ret[1];
- $.ajax({
- type: "POST",
- contentType: "application/json",
- url: "/getnetwinprice",
- data: JSON.stringify({ fromleagID: leagueID, serverID: serverId, fromDivID: divisionid }),
- //beforeSend: function () {
- // $(".post_submitting").show().html("<center><img src='images/loading.gif'/></center>");
- //},
- success: function (response) {
- defaultDollarPrice = response;
- $('#hfresponse').val(response);
- setpricebycheckbox();
- }
- });
- });
- $('#flatOneRoundedCheckbox').change(function () {
- setpricebycheckbox();
- });
- function setpricebycheckbox() {
- var discountpercentage = parseInt(discount_percent, 10);
- var final_price = "";
- var positions = $('#Roles').val();
- var result = $('#hfresponse').val();
- var number_of_games = parseInt($('#slider-range-max-amount').text(), 10);
- var price_in_dollar = parseFloat(defaultDollarPrice).toFixed(2);
- var currency_rate = parseFloat($('#CurrencyRate').val()).toFixed(2);
- var champions = $('#champions').val();
- //for usd
- if ($('#flatOneRoundedCheckbox').is(':checked')) {
- var dollar_rate = (price_in_dollar * number_of_games).toFixed(2);
- if (ChampListArray.length > 0) {
- var champs = ChampListArray.length;
- if (parseInt(champs) == -1) {
- var new_price = dollar_rate * 20 / 100;
- dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price)).toFixed(2);
- $('#Extraprice').val(new_price);
- }
- else if (parseInt(champs) > 5) {
- var new_price_champs = parseFloat(dollar_rate) * 30 / 100;
- dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price_champs)).toFixed(2);
- $('#Extraprice').val(new_price_champs);
- }
- else if (parseInt(champs) >= 1 && parseInt(champs) <= 5) {
- var new_price_champs_new = parseFloat(dollar_rate) * 45 / 100;
- dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price_champs_new)).toFixed(2);
- $('#Extraprice').val(new_price_champs_new);
- }
- }
- else if (RoleListArray.length > 0) {
- var new_price = dollar_rate * 20 / 100;
- dollar_rate = (parseFloat(dollar_rate) + parseFloat(new_price)).toFixed(2);
- $('#Extraprice').val(new_price);
- }
- else if (RoleListArray.length == 0) {
- dollar_rate = (parseFloat(dollar_rate)).toFixed(2);
- $('#Extraprice').val('');
- }
- if (result != 'False' && result != '') {
- $('#price_div').css('border', '3px dotted #ddd');
- final_price = dollar_rate - (dollar_rate * discountpercentage / 100);
- $('#amount').show();
- $('#temp_price').show();
- $('#price').val(parseFloat(final_price).toFixed(2));
- Send_Final_Price = parseFloat(final_price).toFixed(2);
- $('#temp_price').text("$" + parseFloat(dollar_rate).toFixed(2));
- $('#amount').text("$" + parseFloat(final_price).toFixed(2));
- $('#CurrencyType').val('USD');
- $('#loader').hide();
- }
- }
- //for EURO
- else {
- var euro_rate = "";
- euro_rate = (price_in_dollar * currency_rate * number_of_games).toFixed(2);
- if (ChampListArray.length > 0) {
- var champs = ChampListArray.length;
- if (parseInt(champs) == -1) {
- var new_price = euro_rate * 20 / 100;
- euro_rate = (parseFloat(euro_rate) + parseFloat(new_price)).toFixed(2);
- $('#Extraprice').val(new_price);
- }
- else if (parseInt(champs) > 5) {
- var new_price_champs = parseFloat(euro_rate) * 30 / 100;
- euro_rate = (parseFloat(euro_rate) + parseFloat(new_price_champs)).toFixed(2);
- $('#Extraprice').val(new_price_champs);
- }
- else if (parseInt(champs) >= 1 && parseInt(champs) <= 5) {
- var new_price_champs_new = parseFloat(euro_rate) * 45 / 100;
- euro_rate = (parseFloat(euro_rate) + parseFloat(new_price_champs_new)).toFixed(2);
- $('#Extraprice').val(new_price_champs_new);
- }
- }
- else if (RoleListArray.length > 0) {
- var new_price = euro_rate * 20 / 100;
- euro_rate = (parseFloat(euro_rate) + parseFloat(new_price)).toFixed(2);
- $('#Extraprice').val(new_price);
- }
- else if (RoleListArray.length == "") {
- euro_rate = (parseFloat(euro_rate)).toFixed(2);
- $('#Extraprice').val('');
- }
- if (result != 'False' && result != '') {
- $('#price_div').css('border', '3px dotted #ddd');
- final_price = euro_rate - (euro_rate * discountpercentage / 100);
- $('#amount').show();
- $('#temp_price').show();
- $('#price').val(parseFloat(final_price).toFixed(2));
- Send_Final_Price = parseFloat(final_price).toFixed(2);
- $('#temp_price').text("\u20AC" + parseFloat(euro_rate).toFixed(2));
- $('#amount').text(("\u20AC" + parseFloat(final_price).toFixed(2)));
- $('#CurrencyType').val('EUR');
- $('#loader').hide();
- }
- }
- }
- //-------------checkout--------------
- $('#checkoutNow').click(function () {
- var Price = $('#price').val();
- var amount = $('#amount').text();
- if (Price == "" || amount == "") {
- alert("Please select all the fields");
- return false;
- }
- else if (parseInt(Price) == 0 || amount == "") {
- alert("Please select all the fields");
- return false;
- }
- else {
- $('#logindiv').hide();
- $('#orderdiv').show();
- if ($('#hfAuth').val() == 'True') {
- $('.checkout-msg').html('<label class="btn btn-round btn-success" style="height:25px;padding:2px">Logged in</label>' + " " + 'Logged in as' + " " + $('#hfFullName').val() + " ");
- }
- $('#Gametype1').text('Solo Net Wins');
- var gametype2 = $('.spndiv').text() + " " + $('.spnleag').text() + " " + $('#slider-range-max-amount').text() + " " + "Net Wins";
- $('#Gametype2').text(gametype2);
- $('#priceCheckout').text($('#amount').text());
- }
- });
- //-------------------checkout------------------------------
- $('.payment-right-column').click(function () {
- $(this).closest('.payment-column').find('.payment-left-column').find('.paymentRadio').prop("checked", true);
- })
- $('#backbtn').click(function () {
- $('#logindiv').toggle('slide', { direction: 'right' }, 100);
- $('#orderdiv').toggle('slide', { direction: 'left' }, 100);
- })
- $("#user_name_pop_up, #user_password_pop_up").keyup(function (event) {
- if (event.keyCode == '13') {
- loginnow_pop_up();
- }
- })
- $('#loginbtnmodal_pop_up').click(function () {
- loginnow_pop_up();
- })
- function loginnow_pop_up() {
- $('#loader_pop_up').show();
- var username = $('#user_name_pop_up').val();
- var password = $('#user_password_pop_up').val();
- if (username != '' && password != '') {
- $.ajax({
- type: 'POST',
- url: '/Default/loginmodal_pop_up',
- data: { username: username, password: password },
- success: function (response) {
- if (response == 'error') {
- showToaster('Username/password is not correct', 'error')
- $('#loader_pop_up').hide();
- }
- else {
- $('#loader_pop_up').hide();
- $('#logindiv').toggle('slide', { direction: 'right' }, 100);
- $('.checkout-msg').html('<label class="btn btn-round btn-success" style="height:25px;padding:2px">Logged in</label>' + " " + 'Logged in as' + " " + response + " ");
- $('#orderdiv').toggle('slide', { direction: 'left' }, 100);
- $('#loginLi').hide();
- var li = "<li class='menu-item'> <a class='menu-link' href='/dashboard'>My Account</a></li>" +
- "<li class='menu-item'> <a class='menu-link' href='/account/logout'>Logout</a></li>";
- $('.menu').append(li);
- }
- },
- error: function (response) {
- showToaster('Unknown error occurred', 'error')
- $('#loader_pop_up').hide();
- }
- });
- }
- else {
- showToaster('All fields are required', 'info')
- $('#loader_pop_up').hide();
- }
- }
- $(function () {
- $("#login_popup").click(function () {
- $('#orderdiv').toggle('slide', { direction: 'right' }, 100);
- $('#logindiv').toggle('slide', { direction: 'left' }, 100);
- });
- });
- $('#savetransaction').click(function () {
- var currency_rate = parseFloat($('#CurrencyRate').val(), 10);
- var desired = $('#slider-range-max-amount').text();
- var current = $('#current').val();
- var boosttype = $('#type').val();
- var extraprice = $('#Extraprice').val();
- var champions = $('#champions').val();
- var voice_option = "";
- //var price = $('#price').val();
- var price = Send_Final_Price;
- var currency_type = $('#CurrencyType').val();
- var roles = $('#Roles').val();
- var description = $('#Gametype1').text() + " " + $('#Gametype2').text();
- var serverid = Server_Id;
- var Payment_method = $("input[type='radio'][name='select_payment_method']:checked").val();
- if (Payment_method == "Paypal") {
- var href = "/Payment/orderpaypal";
- }
- else if (Payment_method == "G2a") {
- //return false;
- var href = "/Payment/orderG2A";
- }
- href += "?desired=" + desired + "¤t=" + current + "&boosttype=" + boosttype + "&extraprice=" + extraprice + "&price=" + price + "&champions=" + champions + "¤cy_type=" + currency_type + "&roles=" + roles + "&description=" + description + "&serverid=" + serverid + "&voice_option=" + voice_option;
- //alert(href);
- location.href = href;
- })
RAW Paste Data