1'use strict'; 2 3function TrainingSystemProfile(element) { 4 const $ = jQuery, 5 $mainElement = $(element), 6 $memberDataInputs = $mainElement.find('input'), 7 functions = new TrainingSystemFunctions(); 8 9 $memberDataInputs.on('change', handleInputChange); 10 11 // ------------------------------------- 12 // Methods 13 // ------------------------------------- 14 15 function updateMemberData(data) { 16 17 showWaiting(); 18 19 functions.updateMemberData( 20 data, 21 // Success 22 (response) => { 23 setTimeout(() => hideWaiting(), 100); 24 25 let name = response.data.name, 26 value = parseInt(response.data.value); 27 if (isNaN(value)) 28 value = 0; 29 30 }, 31 // Failed 32 (response) => { 33 setTimeout(() => hideWaiting(), 500); 34 } 35 ); 36 } 37 38 function adjustStaticField($input, value) { 39 var staticField = $input.parents('.field-wrapper').find('.static-field'); 40 if ($input.data('type') === 'email') { 41 var a = staticField.find('a'); 42 a.attr('href', 'mailto:' + value); 43 a.html(value); 44 } else { 45 $('#' + $input.attr('name')).html(value); 46 } 47 } 48 49 function showWaiting() { 50 $mainElement.append('<div class="tsNotificationWaiting"></div>') 51 } 52 53 function hideWaiting() { 54 $mainElement.find('.tsNotificationWaiting').remove(); 55 } 56 57 // ------------------------------------- 58 // Events 59 // ------------------------------------- 60 61 function handleInputChange(e) { 62 e.preventDefault(); 63 64 const $input = $(this); 65 $input.attr('disabled', true); 66 console.log($input); 67 68 let data = { 69 type: 'memberData', 70 name: $input.attr('name'), 71 value: $input.val(), 72 }; 73 74 updateMemberData(data); 75 adjustStaticField($input, data.value) 76 $input.attr('disabled', false); 77 } 78} 79function toggle() { 80 jQuery('.dynamic-field').toggleClass('hidden'); 81 jQuery('.static-field').toggleClass('hidden'); 82}
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.