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