299; } if(total == 0 || PAY_SEM) { $('#payson-submit').prop('disabled', true); } else { $('#payson-submit').prop('disabled', false); } if($('#swish').is(':visible')) $('#payment-loader').hide(); }, 100); setInterval(function() { if(!$('input[name=pay_email]').is(':checked') && $('input[name=pay_phone]').is(':disabled')) { $('#pay-phone-title').css({opacity: '0.4'}); $('#pay-phone-container').css({opacity: '0.4'}); } else { $('#pay-phone-title').css({opacity: '1'}); $('#pay-phone-container').css({opacity: '1'}); } }, 100); $('form').submit(function() { PAY_SEM = true; }); }); $(function() { var updateFontSize = function() { var width = $('body').width(); var apad = 30; var a = 20; var b = 14; if(width <= 320) { var apad = 20; a = 11; b = 10; } else if(width <= 360) { var apad = 20; a = 13; b = 11; } else if(width <= 380) { var apad = 20; a = 14; b = 12; } else if(width <= 600) { var apad = 20; a = 15; b = 12; } else if(width <= 800) { var apad = 20; a = 20; b = 14; } else if(width <= 1400) { var apad = 20; a = 20; b = 14; } else { var apad = 30; a = 20; b = 15; } //alert(a + " " + b); $('.price-right').css({'fontSize': "" + a + 'px', 'paddingTop': apad + "px"}); $('.buy-label').css({'fontSize': "" + b + 'px'}); }; updateFontSize(); $(window).resize(function() { updateFontSize(); }); }); $(function() { PAY_SEM = 0; $('#pay-email-container').click(function() { if(PAY_SEM) return; //$('#pay_email') //.prop('checked', 1); //.trigger('change'); }) $('#pay-phone-container').click(function() { if(PAY_SEM || $('#pay_phone').is(':disabled')) return; $('#pay_phone').prop('checked', !$('#pay_phone') .prop('checked')) .trigger('change'); }); $('#pay-email-container').click(function() { if(PAY_SEM || $('#pay_email').is(':disabled')) return; $('#pay_email').prop('checked', !$('#pay_email') .prop('checked')) .trigger('change'); }); $('#pay_phone, #pay_email').click(function() { PAY_SEM = 1; setTimeout(function() { PAY_SEM = 0; }, 100); }) }); } else if(false) { //currentFileName === 'aktivera-min-bevakning') { /*$(function() { PAY_SEM = false; var createOrder = function() { $('#payment-loader').hide(); if(!$('input[name=pay_email]').is(':checked') && !$('input[name=pay_phone]').is(':checked')) { $('#klarna-snippet').html(''); $('#swish').hide(); return; } $('#swish').show(); var loaderHTML = ''; loaderHTML += '
'; loaderHTML += ''; loaderHTML += ''; loaderHTML += ''; loaderHTML += ''; loaderHTML += ''; if(!$('input[name=pay_email]').is(':checked') && !$('input[name=pay_phone]').is(':checked')) { $('#klarna-snippet').html(''); return; } if(!$('#swish').is(':visible')) $('#payment-loader').show(); $('#klarna-snippet').html(""); $.post('/users/klarna_checkout?' + Math.random() + '&' + '0', {pay_email: ($('input[name=pay_email]').is(':checked') ? $('input[name=pay_email]').val() : 0), pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { $('#klarna-snippet').append(' '); setTimeout(function() { $('#payment-loader').hide(); if($('#klarna-snippet:visible').length) { $('#klarna-container-snippet').show(); } }, 1000); }, 'json'); }; $('.show-swish').click(); $('input[name=pay_email]').change(function() { var defaultSMSDays = $('input[name=pay_phone]').attr('data-default'); console.log(defaultSMSDays); if($(this).is(':checked')) { $('input[name=pay_phone]').prop('disabled', false); $('input[name=pay_phone]').val(30); $('.num-sms-days').html(30); $('.sms-price').html(99); } else if(defaultSMSDays) { $('input[name=pay_phone]').val(defaultSMSDays); $('.num-sms-days').html(defaultSMSDays); //$('.sms-price').html(Math.ceil(defaultSMSDays * 99 / 30)); setTimeout(function() { $('.sms-price').parent().html('' + Math.ceil(defaultSMSDays * 99 / 30) + ' kr'); }, 1); } else { $('input[name=pay_phone]').prop('disabled', true); $('input[name=pay_phone]').prop('checked', false); } createOrder(); }); $('input[name=pay_phone]').change(function() { createOrder(); }); createOrder(); setInterval(function() { var total = 0; if($('input[name=pay_phone]').prop('checked')) { total += parseInt($('.sms-price').html()); } if($('input[name=pay_email]').prop('checked')) { total += 299; } if(total == 0 || PAY_SEM) { $('#payson-submit').prop('disabled', true); } else { $('#payson-submit').prop('disabled', false); } if($('#swish').is(':visible')) $('#payment-loader').hide(); }, 100); setInterval(function() { if(!$('input[name=pay_email]').is(':checked') && $('input[name=pay_phone]').is(':disabled')) { $('#pay-phone-title').css({opacity: '0.4'}); $('#pay-phone-container').css({opacity: '0.4'}); } else { $('#pay-phone-title').css({opacity: '1'}); $('#pay-phone-container').css({opacity: '1'}); } }, 100); $('form').submit(function() { PAY_SEM = true; }); });*/ /* $(function() { var updateFontSize = function() { var width = $('body').width(); var a = 30; var b = 14; if(width <= 320) { a = 11; b = 10; } else if(width <= 360) { a = 13; b = 11; } else if(width <= 380) { a = 14; b = 12; } else if(width <= 600) { a = 15; b = 12; } else if(width <= 800) { a = 20; b = 14; } else if(width <= 1400) { a = 20; b = 14; } else { a = 30; b = 15; } //alert(a + " " + b); $('.price-right').css({'fontSize': "" + a + 'px'}); $('.buy-label').css({'fontSize': "" + b + 'px'}); }; updateFontSize(); $(window).resize(function() { updateFontSize(); }); }); */ /*$(function() { $('#swish').submit(function() { $('#swish-invalid-phone-number').hide(); $('#swish-noexists-phone-number').hide(); $('#swish-invalid-dupe').hide(); $('#swish-error').hide(); $('#swish-declined').hide(); $('input[name=pay_email]').prop('disabled', true); $('input[name=pay_phone]').prop('disabled', true); console.log('DISABLED'); var swishOrderId = null; $.post('/users/swish_pay?' + Math.random(), {phone_number: $('#phone_number').val(), pay_email: ($('input[name=pay_email]').is(':checked') ? $('input[name=pay_phone]').val() : 0), pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { if(data.error) { if(data.error === 'phone') $('#swish-invalid-phone-number').show(); if(data.error === 'noexists') $('#swish-noexists-phone-number').show(); if(data.error === 'dupe') $('#swish-invalid-dupe').show(); $('input[name=pay_email]').prop('disabled', false); $('input[name=pay_phone]').prop('disabled', false); } else { swishOrderId = data.order.id; $('#swish-loading').show(); $('#swish').hide(); $('.cost').html(data.cost); $('.phone-number').html('0' + data.phone_number.substring(2)); } }, 'json'); var interval = setInterval(function() { if(!swishOrderId) return; $.getJSON('/users/swish_check', {order_id: swishOrderId}, function(data) { if(data.status === 'PAID') { window.location = '?success=1'; } else if(data.status === 'ERROR') { clearInterval(interval); $('#swish-loading').hide(); $('#swish-error').show(); $('#swish').show(); $('input[name=pay_email]').prop('disabled', false); $('input[name=pay_phone]').prop('disabled', false); } else if(data.status === "DECLINED") { clearInterval(interval); $('#swish-loading').hide(); $('#swish-declined').show(); $('#swish').show(); $('input[name=pay_email]').prop('disabled', false); $('input[name=pay_phone]').prop('disabled', false); } console.log(data.status); }); }, 2000); return false; }); }); */ /*$(function() { PAY_SEM = 0; $('#pay-email-container').click(function() { if(PAY_SEM) return; //$('#pay_email') //.prop('checked', 1); //.trigger('change'); }) $('#pay-phone-container').click(function() { if(PAY_SEM || $('#pay_phone').is(':disabled')) return; $('#pay_phone').prop('checked', !$('#pay_phone') .prop('checked')) .trigger('change'); }); $('#pay-email-container').click(function() { if(PAY_SEM || $('#pay_email').is(':disabled')) return; $('#pay_email').prop('checked', !$('#pay_email') .prop('checked')) .trigger('change'); }); $('#pay_phone, #pay_email').click(function() { PAY_SEM = 1; setTimeout(function() { PAY_SEM = 0; }, 100); }) });*/ } else if(currentFileName === 'payson') { $(function() { var updateFontSize = function() { var width = $('body').width(); var a = 30; var b = 14; if(width <= 320) { a = 11; b = 10; } else if(width <= 360) { a = 13; b = 11; } else if(width <= 380) { a = 14; b = 12; } else if(width <= 600) { a = 15; b = 12; } else if(width <= 800) { a = 20; b = 14; } else if(width <= 1400) { a = 20; b = 14; } else { a = 30; b = 15; } $('.price-right').css({'font-size': "" + a + 'px'}); $('.buy-label').css({'font-size': "" + b + 'px'}); }; updateFontSize(); $(window).resize(function() { updateFontSize(); }); $('.show-klarna').click(); //$('#payson-snippet').hide(); PAY_SEM = false; var createOrder = function() { if(!$('input[name=pay_email]').is(':checked') && !$('input[name=pay_phone]').is(':checked')) { $('#klarna-snippet').html(''); $('#payson-snippet').html(''); return; } $('#payment-loader').show(); $('#klarna-snippet').html(""); $('#payson-snippet').html(""); $.post('/users/klarna_checkout?' + Math.random() + '&' + '0', {pay_email: ($('input[name=pay_email]').is(':checked') ? $('input[name=pay_email]').val() : 0), pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { $('#klarna-snippet').append(' '); setTimeout(function() { $('#payment-loader').hide(); if($('#klarna-snippet:visible').length) { $('#klarna-container-snippet').show(); } }, 1000); }, 'json'); $.post('/users/payit_create_order?' + Math.random() + '&' + '0', {pay_email: ($('input[name=pay_email]').is(':checked') ? $('input[name=pay_email]').val() : 0), pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { $('#payson-snippet').append(' '); setTimeout(function() { $('#payment-loader').hide(); if($('#payson-snippet:visible').length) { $('#payson-container-snippet').show(); } }, 1000); }, 'json'); }; $('input[name=pay_email]').change(function() { var defaultSMSDays = $('input[name=pay_phone]').attr('data-default'); console.log(defaultSMSDays); if($(this).is(':checked')) { $('input[name=pay_phone]').prop('disabled', false); $('input[name=pay_phone]').val(30); $('.num-sms-days').html(30); $('.sms-price').html(99); } else if(defaultSMSDays) { $('input[name=pay_phone]').val(defaultSMSDays); $('.num-sms-days').html(defaultSMSDays); //$('.sms-price').html(Math.ceil(defaultSMSDays * 99 / 30)); setTimeout(function() { $('.sms-price').parent().html('' + Math.ceil(defaultSMSDays * 99 / 30) + ' kr'); }, 1); } else { $('input[name=pay_phone]').prop('disabled', true); $('input[name=pay_phone]').prop('checked', false); } createOrder(); }); $('input[name=pay_phone]').change(function() { createOrder(); }); createOrder(); setInterval(function() { var total = 0; if($('input[name=pay_phone]').prop('checked')) { total += parseInt($('.sms-price').html()); } if($('input[name=pay_email]').prop('checked')) { total += 299; } if(total == 0 || PAY_SEM) { $('#payson-submit').prop('disabled', true); } else { $('#payson-submit').prop('disabled', false); } }, 100); setInterval(function() { if(!$('input[name=pay_email]').is(':checked') && $('input[name=pay_phone]').is(':disabled')) { $('#pay-phone-title').css({opacity: '0.4'}); $('#pay-phone-container').css({opacity: '0.4'}); } else { $('#pay-phone-title').css({opacity: '1'}); $('#pay-phone-container').css({opacity: '1'}); } }, 100); $('form').submit(function() { PAY_SEM = true; }); }); $(function() { $('#swish').submit(function() { $('#swish-invalid-phone-number').hide(); $('#swish-invalid-dupe').hide(); $('#swish-error').hide(); $('#swish-declined').hide(); var swishOrderId = null; $.post('/users/swish_pay?' + Math.random(), {phone_number: $('#phone_number').val(), email_days: 30, pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { if(data.error) { if(data.error === 'phone') $('#swish-invalid-phone-number').show(); if(data.error === 'dupe') $('#swish-invalid-dupe').show(); } else { swishOrderId = data.order.id; $('#swish-loading').show(); $('#swish').hide(); $('.cost').html(data.cost); $('.phone-number').html('0' + data.phone_number.substring(2)); } }, 'json'); var interval = setInterval(function() { if(!swishOrderId) return; $.getJSON('/users/swish_check', {order_id: swishOrderId}, function(data) { if(data.status === 'PAID') { window.location = '?success=1'; } else if(data.status === 'ERROR') { clearInterval(interval); $('#swish-loading').hide(); $('#swish-error').show(); $('#swish').show(); } else if(data.status === "DECLINED") { clearInterval(interval); $('#swish-loading').hide(); $('#swish-declined').show(); $('#swish').show(); } console.log(data.status); }); }, 2000); return false; }); }); $(function() { PAY_SEM = 0; $('#pay-email-container').click(function() { if(PAY_SEM) return; /*$('#pay_email') .prop('checked', 1); .trigger('change');*/ }) $('#pay-phone-container').click(function() { if(PAY_SEM || $('#pay_phone').is(':disabled')) return; $('#pay_phone').prop('checked', !$('#pay_phone') .prop('checked')) .trigger('change'); }); $('#pay-email-container').click(function() { if(PAY_SEM || $('#pay_email').is(':disabled')) return; $('#pay_email').prop('checked', !$('#pay_email') .prop('checked')) .trigger('change'); }); $('#pay_phone, #pay_email').click(function() { PAY_SEM = 1; setTimeout(function() { PAY_SEM = 0; }, 100); }) }); } else if(currentFileName === 'old_old_aktivera-min-bevakning') { /*$(function() { var updateFontSize = function() { var width = $('body').width(); var a = 30; var b = 14; if(width <= 320) { a = 11; b = 10; } else if(width <= 360) { a = 13; b = 11; } else if(width <= 380) { a = 14; b = 12; } else if(width <= 600) { a = 15; b = 12; } else if(width <= 800) { a = 20; b = 14; } else if(width <= 1400) { a = 20; b = 14; } else { a = 30; b = 15; } $('.price-right').css({'font-size': "" + a + 'px'}); $('.buy-label').css({'font-size': "" + b + 'px'}); }; updateFontSize(); $(window).resize(function() { updateFontSize(); }); $('.show-klarna').click(); //$('#payson-snippet').hide(); PAY_SEM = false; var createOrder = function() { if(!$('input[name=pay_email]').is(':checked') && !$('input[name=pay_phone]').is(':checked')) { $('#klarna-snippet').html(''); $('#payson-snippet').html(''); return; } $('#payment-loader').show(); $('#klarna-snippet').html(""); $('#payson-snippet').html(""); $.post('/users/klarna_checkout?' + Math.random() + '&' + '0', {pay_email: ($('input[name=pay_email]').is(':checked') ? $('input[name=pay_email]').val() : 0), pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { $('#klarna-snippet').append(' '); setTimeout(function() { $('#payment-loader').hide(); if($('#klarna-snippet:visible').length) { $('#klarna-container-snippet').show(); } }, 1000); }, 'json'); $.post('/users/payit_create_order?' + Math.random() + '&' + '0', {pay_email: ($('input[name=pay_email]').is(':checked') ? $('input[name=pay_email]').val() : 0), pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { $('#payson-snippet').append(' '); setTimeout(function() { $('#payment-loader').hide(); if($('#payson-snippet:visible').length) { $('#payson-container-snippet').show(); } }, 1000); }, 'json'); }; $('input[name=pay_email]').change(function() { var defaultSMSDays = $('input[name=pay_phone]').attr('data-default'); console.log(defaultSMSDays); if($(this).is(':checked')) { $('input[name=pay_phone]').prop('disabled', false); $('input[name=pay_phone]').val(30); $('.num-sms-days').html(30); $('.sms-price').html(99); } else if(defaultSMSDays) { $('input[name=pay_phone]').val(defaultSMSDays); $('.num-sms-days').html(defaultSMSDays); //$('.sms-price').html(Math.ceil(defaultSMSDays * 99 / 30)); setTimeout(function() { $('.sms-price').parent().html('' + Math.ceil(defaultSMSDays * 99 / 30) + ' kr'); }, 1); } else { $('input[name=pay_phone]').prop('disabled', true); $('input[name=pay_phone]').prop('checked', false); } createOrder(); }); $('input[name=pay_phone]').change(function() { createOrder(); }); createOrder(); setInterval(function() { var total = 0; if($('input[name=pay_phone]').prop('checked')) { total += parseInt($('.sms-price').html()); } if($('input[name=pay_email]').prop('checked')) { total += 299; } if(total == 0 || PAY_SEM) { $('#payson-submit').prop('disabled', true); } else { $('#payson-submit').prop('disabled', false); } }, 100); setInterval(function() { if(!$('input[name=pay_email]').is(':checked') && $('input[name=pay_phone]').is(':disabled')) { $('#pay-phone-title').css({opacity: '0.4'}); $('#pay-phone-container').css({opacity: '0.4'}); } else { $('#pay-phone-title').css({opacity: '1'}); $('#pay-phone-container').css({opacity: '1'}); } }, 100); $('form').submit(function() { PAY_SEM = true; }); }); $(function() { $('#swish').submit(function() { $('#swish-invalid-phone-number').hide(); $('#swish-invalid-dupe').hide(); $('#swish-error').hide(); $('#swish-declined').hide(); var swishOrderId = null; $.post('/users/swish_pay?' + Math.random(), {phone_number: $('#phone_number').val(), email_days: 30, pay_phone: ($('input[name=pay_phone]').is(':checked') ? $('input[name=pay_phone]').val() : 0)}, function(data) { if(data.error) { if(data.error === 'phone') $('#swish-invalid-phone-number').show(); if(data.error === 'dupe') $('#swish-invalid-dupe').show(); } else { swishOrderId = data.order.id; $('#swish-loading').show(); $('#swish').hide(); $('.cost').html(data.cost); $('.phone-number').html('0' + data.phone_number.substring(2)); } }, 'json'); var interval = setInterval(function() { if(!swishOrderId) return; $.getJSON('/users/swish_check', {order_id: swishOrderId}, function(data) { if(data.status === 'PAID') { window.location = '?success=1'; } else if(data.status === 'ERROR') { clearInterval(interval); $('#swish-loading').hide(); $('#swish-error').show(); $('#swish').show(); } else if(data.status === "DECLINED") { clearInterval(interval); $('#swish-loading').hide(); $('#swish-declined').show(); $('#swish').show(); } console.log(data.status); }); }, 2000); return false; }); }); $(function() { PAY_SEM = 0; $('#pay-email-container').click(function() { if(PAY_SEM) return; //$('#pay_email') //.prop('checked', 1); //.trigger('change'); }) $('#pay-phone-container').click(function() { if(PAY_SEM || $('#pay_phone').is(':disabled')) return; $('#pay_phone').prop('checked', !$('#pay_phone') .prop('checked')) .trigger('change'); }); $('#pay-email-container').click(function() { if(PAY_SEM || $('#pay_email').is(':disabled')) return; $('#pay_email').prop('checked', !$('#pay_email') .prop('checked')) .trigger('change'); }); $('#pay_phone, #pay_email').click(function() { PAY_SEM = 1; setTimeout(function() { PAY_SEM = 0; }, 100); }) }); */ } else if(currentFileName === 'payment') { /*$(function() { PAY_SEM = false; $('input[name=pay_email]').change(function() { var defaultSMSDays = $('input[name=pay_phone]').attr('data-default'); if($(this).is(':checked')) { $('input[name=pay_phone]').prop('disabled', false); $('input[name=pay_phone]').val(30); $('.num-sms-days').html(30); $('.sms-price').html(99 * 1); } else if($('input[name=pay_phone]').attr('data-default')) { $('input[name=pay_phone]').val(defaultSMSDays); $('.num-sms-days').html(defaultSMSDays); $('.sms-price').html(Math.ceil(defaultSMSDays * 99 / 30)); } else { $('input[name=pay_phone]').prop('disabled', true); $('input[name=pay_phone]').prop('checked', false); } }); setInterval(function() { var total = 0; if($('input[name=pay_phone]').prop('checked')) { total += parseInt($('.sms-price').html()); } if($('input[name=pay_email]').prop('checked')) { total += 299; } if(total == 0 || PAY_SEM) { $('#payson-submit').prop('disabled', true); } else { $('#payson-submit').prop('disabled', false); } }, 100); setInterval(function() { if(!$('input[name=pay_email]').is(':checked') && $('input[name=pay_phone]').is(':disabled')) { $('#pay-phone-title').css({opacity: '0.4'}); $('#pay-phone-container').css({opacity: '0.4'}); } else { $('#pay-phone-title').css({opacity: '1'}); $('#pay-phone-container').css({opacity: '1'}); } }, 100); $('form').submit(function() { PAY_SEM = true; }); }); $(function() { var width = $('body').width(); var a = 30; var b = 14; if(width <= 320) { a = 11; b = 10; } else if(width <= 360) { a = 13; b = 11; } else if(width <= 380) { a = 15; b = 12; } else if(width <= 600) { a = 16; b = 12; } else if(width <= 800) { a = 22; b = 14; } else if(width <= 1400) { a = 20; b = 14; } else { a = 30; b = 15; } $('.price-right').css({'font-size': "" + a + 'px'}); $('.buy-label').css({'font-size': "" + b + 'px'}); }); $(function() { PAY_SEM = 0; $('#pay-email-container').click(function() { if(PAY_SEM) return; $('#pay_email') .prop('checked', !$('#pay_email').prop('checked')) .trigger('change'); }) $('#pay-phone-container').click(function() { if(PAY_SEM || $('#pay_phone').is(':disabled')) return; $('#pay_phone').prop('checked', !$('#pay_phone') .prop('checked')) .trigger('change'); }); $('#pay_phone, #pay_email').click(function() { PAY_SEM = 1; setTimeout(function() { PAY_SEM = 0; }, 100); }) });*/ }