1jQuery(document).ready(function($) { 2 //Kode til at hente CVR oplysninger på kasse siden 3 $('#vat_button').on('click', function(e) { 4 e.preventDefault(); 5 var vat_number = $('#get_vat_number').val(); 6 7 if(vat_number !== ''){ 8 cvrapi(vat_number, 'dk'); 9 $('.empty_cvr, .wrong_cvr').remove(); 10 $('#vat_number, #billing_vat_number').css('border', 'none'); 11 } 12 else{ 13 $('.empty_cvr, .wrong_cvr').remove(); 14 $('#get_vat_number').css('border', '1px solid red'); 15 var alert_text = '<p class="empty_cvr" style="color: red;">Indtast venligst et CVR nummer eller firmanavn</p>'; 16 $( alert_text ).insertAfter( $('#get_vat_number_field label') ); 17 } 18 }); 19 20 function cvrapi(vat, country){ 21 jQuery.ajax({ 22 type: 'GET', 23 dataType: 'jsonp', 24 url: 'https://cvrapi.dk/api?search=' + vat + '&country=' + country, 25 success: function (r){ 26 $('.empty_cvr, .wrong_cvr').remove(); 27 //$('#vat_number, #billing_vat_number').css('border', 'none'); 28 $('#billing_company').val( r.name ); 29 $('#vat_number, #billing_vat_number').val(r.vat); 30 $('#billing_address_1').val( r.address ); 31 $('#billing_postcode').val( r.zipcode ); 32 $('#billing_city').val( r.city ); 33 $('#billing_phone').val( r.phone ); 34 $('#billing_email').val( r.email ); 35 36 $('body').trigger('update_checkout'); 37 }, 38 error: function(){ 39 //var alert_text = '<p class="wrong_cvr" style="color: red;">Der kunne ikke findes et gyldigt CVR nummer</p>'; 40 $('.empty_cvr, .wrong_cvr').remove(); 41 42 //$( alert_text ).insertAfter( $('#vat_number_field label, #billing_vat_number label') ); 43 //$('#vat_number, #billing_vat_number').css('border', '1px solid red'); 44 45 $('#billing_company').val( '' ); 46 $('#billing_address_1').val( '' ); 47 $('#billing_postcode').val( '' ); 48 $('#billing_city').val( '' ); 49 $('#billing_phone').val( '' ); 50 $('#billing_email').val( '' ); 51 } 52 }); 53 } 54 55 function toggleVatField() { 56 var selectedValue = $('input[name=billing_company_type]:checked').val(); 57 if(selectedValue === 'company') { 58 $('#vat_number_field_wrapper, #vat_number_field, #billing_vat_number_field_wrapper, #billing_vat_number_field').show(); 59 $('#billing_company_field').show(); 60 } 61 62 else { 63 var cvr_wrapper = $('#vat_number_field_wrapper, #billing_vat_number_field_wrapper'); 64 var button_wrapper = $('.company-type-wrapper'); 65 66 $('#vat_number_field input, #billing_vat_number_field input').val(''); 67 $('#billing_company_field input').val(''); 68 69 $('#vat_number_field_wrapper, #vat_number_field, #billing_vat_number_field_wrapper, #billing_vat_number_field').hide(); 70 71 if(cvr_wrapper.attr('data-hidecompany') === '1' || button_wrapper.attr('data-hidecompany') === '1'){ 72 $('#billing_company_field').hide(); 73 } 74 } 75 } 76 77 if($('#billing_company_type_private').length !== 0 && $('#billing_company_type_company').length !== 0){ 78 toggleVatField(); 79 } 80 81 $('input[name=billing_company_type]').change(function() { 82 toggleVatField(); 83 }); 84});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.