1function findUser(){ 2 return { 3 query: '', 4 loading: false, 5 users: [], 6 current_user_email : '', 7 current_user_id : '', 8 current_user_name : '', 9 optionsVisible: false, 10 createButton: false, 11 errorMessage: "", 12 search: function() { 13 this.errorMessage = ""; 14 this.createButton = false; 15 if( this.query.length < 3 ) return; 16 this.loading = true; 17 18 let data = new FormData(); 19 20 data.append( 'action', search_user_switching_api.action); 21 data.append( 'remote_action', 'find_user' ); 22 data.append( 'nonce', search_user_switching_api.search_user_forms_ajax_nonce ); 23 data.append( 'search_term',this.query ); 24 25 fetch(search_user_switching_api.fetchUrl, { 26 method: 'POST', 27 body: data, 28 }) 29 .then((response) => response.json()) 30 .then((result) => { 31 if(result.status){ 32 if(result.value.length) { 33 this.users = result.value; 34 this.optionsVisible = true; 35 } else { 36 this.createButton = true; 37 this.optionsVisible = false; 38 } 39 } 40 41 this.loading = false; 42 }) 43 .catch((error) => { 44 console.log(error); 45 }) 46 .finally(() => { 47 this.loading = false; 48 }) 49 50 }, 51 create_user() { 52 this.errorMessage = ""; 53 this.createButton = false; 54 if( this.query.length < 3 ) return; 55 this.loading = true; 56 57 let data = new FormData(); 58 59 data.append( 'action', search_user_switching_api.action); 60 data.append( 'remote_action', 'create_user' ); 61 data.append( 'nonce', search_user_switching_api.search_user_forms_ajax_nonce ); 62 data.append( 'email',this.query ); 63 64 fetch(search_user_switching_api.fetchUrl, { 65 method: 'POST', 66 body: data, 67 }) 68 .then((response) => response.json()) 69 .then((result) => { 70 if(result.status){ 71 const api_response = result.value; 72 if(api_response.error) { 73 this.errorMessage = api_response.message; 74 this.createButton = true; 75 } else { 76 window.location = api_response.link; 77 } 78 } 79 }) 80 .catch((error) => { 81 console.log(error); 82 }) 83 .finally(() => { 84 this.loading = false; 85 }) 86 } 87 } 88} 89 90function addDiscount() { 91 return { 92 discount: function () { 93 const discount = $("#search_user_switch_discount_fee").val; 94 console.log(discount) 95 if(discount < 1) 96 return; 97 98 let data = new FormData(); 99 100 data.append('action', search_user_switching_api.action); 101 data.append('remote_action', 'add_discount'); 102 data.append('nonce', search_user_switching_api.search_user_forms_ajax_nonce); 103 data.append('discount', discount); 104 105 fetch(search_user_switching_api.fetchUrl, { 106 method: 'POST', 107 body: data, 108 }) 109 .then((response) => response.json()) 110 .then((result) => { 111 if(result.status){ 112 document.body.trigger('update_checkout'); 113 } 114 }) 115 .catch((error) => { 116 console.log(error); 117 }) 118 .finally(() => { 119 this.loading = false; 120 }) 121 } 122 } 123}
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.