1app.addModule('create-partner',function(){ 2 3 4 var selectorModalForm = '#create-partner'; 5 var selectorModalResult = '#result-modal'; 6 7 var selectorBtnSend = ' .send-form'; 8 var selectorInputs = ' input.spec-input'; 9 10 var createUrl = '/api/form'; 11 12 13 14 var validateInputs = function(inputs){ 15 16 var check = true; 17 for(var i in inputs){ 18 19 var input = $(inputs[i]); 20 21 var value = input.val(); 22 var name = input.attr('name'); 23 24 input.css('border',''); 25 26 if(value != ''){ 27 if(name == 'phone'){ 28 if(value.length >= 5 && value.length < 18)continue; 29 }else if(name == 'name'){ 30 if(value.length >= 3 && value.length < 45)continue; 31 }else if(name == 'form_id'){ 32 if(value.length > 0)continue; 33 }else{ 34 if(value.length >= 2 && value.length < 100)continue; 35 } 36 } 37 38 input.css('border','1px solid red'); 39 check = false; 40 } 41 42 return check; 43 44 }; 45 46 this.main = function(e){ 47 48 var inputs = $(selectorModalForm + selectorInputs).toArray(); 49 if(validateInputs(inputs)){ 50 51 if(app.hasModule('ajax')){ 52 53 var request = {}; 54 55 for(var i in inputs){ 56 request[$(inputs[i]).attr('name')] = $(inputs[i]).val(); 57 } 58 var ajax = app.getModule('ajax'); 59 ajax.post(createUrl,request,function(data){ 60 61 if(data != false){ 62 if(typeof data.status != 'undefined'){ 63 if(data.status == 'success'){ 64 $(selectorModalForm).modal('hide'); 65 $(selectorModalResult).modal('show'); 66 }else if(data.status == 'error'){ 67 if(typeof data.errors != 'undefined'){ 68 for(var e in data.errors){ 69 $(selectorModalForm + selectorInputs + '[name="' + e + '"]') 70 .css('border','1px solid red') ; 71 } 72 } 73 } 74 } 75 } 76 }, function(err){ 77 console.error(err); 78 }, $(selectorModalForm)); 79 80 } 81 82 83 } 84 85 }; 86 87 this.bind = function(){ 88 $(selectorModalForm + selectorBtnSend).on('click',this.main) 89 }; 90 91 this.init = function(){ 92 this.bind(); 93 console.log('init create-partner module'); 94 }; 95});
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.