Blame view
resources/views/js/modals.blade.php
8.71 KB
a9dfa8c95 Обновление на 7 м... |
1 |
<script> |
ac8b91cfd Обновление системы. |
2 3 4 5 6 7 |
var code; var code2; function createCaptcha() { //clear the contents of captcha div first var captha1 = $('#captcha1').html(); |
ac8b91cfd Обновление системы. |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
document.getElementById('captcha1').innerHTML = ""; document.getElementById('captcha2').innerHTML = ""; var charsArray = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@!#$%^&*"; var lengthOtp = 6; var captcha = []; for (var i = 0; i < lengthOtp; i++) { //below code will not allow Repetition of Characters var index = Math.floor(Math.random() * charsArray.length + 1); //get the next character from the array if (captcha.indexOf(charsArray[index]) == -1) captcha.push(charsArray[index]); else i--; } var canv = document.createElement("canvas"); canv.id = "captcha"; canv.width = 100; canv.height = 50; var ctx = canv.getContext("2d"); ctx.font = "25px Georgia"; ctx.strokeText(captcha.join(""), 0, 30); //storing captcha so that can validate you can save it somewhere else according to your specific requirements code = captcha.join(""); document.getElementById("captcha1").appendChild(canv); // adds the canvas to the body element createCaptcha2() } function createCaptcha2() { //clear the contents of captcha div first document.getElementById('captcha2').innerHTML = ""; var captha2 = $('#captcha2').html(); var charsArray = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@!#$%^&*"; var lengthOtp = 6; var captcha = []; for (var i = 0; i < lengthOtp; i++) { //below code will not allow Repetition of Characters var index = Math.floor(Math.random() * charsArray.length + 1); //get the next character from the array if (captcha.indexOf(charsArray[index]) == -1) captcha.push(charsArray[index]); else i--; } var canv = document.createElement("canvas"); canv.id = "captcha"; canv.width = 100; canv.height = 50; var ctx = canv.getContext("2d"); ctx.font = "25px Georgia"; ctx.strokeText(captcha.join(""), 0, 30); //storing captcha so that can validate you can save it somewhere else according to your specific requirements code2 = captcha.join(""); document.getElementById("captcha2").appendChild(canv); // adds the canvas to the body element } function validateCaptcha() { if (document.getElementById("cpatchaTextBox").value == code) { console.log('Валидная капча 1!'); }else{ alert("Неверная капча! Повторите вновь"); createCaptcha(); } } function validateCaptcha2() { if (document.getElementById("cpatchaTextBox2").value == code2) { console.log('Валидная капча 2!'); }else{ alert("Неверная капча! Повторите вновь"); createCaptcha(); } } |
f9f2078d8 add popup for emp... |
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
function successfulRegistrationWorker() { $.fancybox.close(); $('#email_worker').val(''); $('#password_worker').val(''); $('#password_confirmation_worker').val(''); $('#politik').prop('checked', false); $('#telephone_worker').val(''); $('#job_titles_worker').val('').trigger('change'); $('#surname_worker').val(''); $('#name_man_worker').val(''); $('#surname2_worker').val(''); $('#cpatchaTextBox1').val(''); $('#block-info').hide(); $('#messages_error_reg').html(''); $.fancybox.open({ |
947d970ad fixes |
104 |
src: '#successful-registration-worker', |
f9f2078d8 add popup for emp... |
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
type: 'inline', opts: {touch: false} }); } function successfulRegistrationEmployer() { $.fancybox.close(); $('#email_employer').val(''); $('#password_employer').val(''); $('#password_confirmation_employer').val(''); $('#politik').prop('checked', false); $('#telephone_employer').val(''); $('#surname_employer').val(''); $('#name_man_employer').val(''); $('#surname2_employer').val(''); $('#company_employer').val(''); $('#cpatchaTextBox1').val(''); $('#block-info').hide(); $('#messages_error_reg').html(''); $.fancybox.open({ |
947d970ad fixes |
128 |
src: '#successful-registration-employer', |
f9f2078d8 add popup for emp... |
129 130 131 132 |
type: 'inline', opts: {touch: false} }); } |
a9dfa8c95 Обновление на 7 м... |
133 |
$(document).on('click', '#button_send', function() { |
ad20c698a Результаты на вос... |
134 |
var field_login = $('#email_input'); |
a9dfa8c95 Обновление на 7 м... |
135 136 137 138 139 140 141 142 143 144 145 146 |
var field_pwd = $('#password'); var login_val = field_login.val(); var pwd_val = field_pwd.val(); console.log('login: '+login_val+' password: '+pwd_val); $.ajax({ type: "GET", url: "{{ route('login') }}", data: "email="+login_val+"&password="+pwd_val, success: function (data) { console.log('Вход в систему'); |
ad20c698a Результаты на вос... |
147 |
console.log(data); |
a9dfa8c95 Обновление на 7 м... |
148 149 150 151 152 153 154 155 156 |
let d = JSON.parse(data); if(typeof d['REDIRECT'] !== "undefined") { location.href = d['REDIRECT']; console.log(d['REDIRECT']); } if (typeof d['ERROR'] !== "undefined") { console.log(d['ERROR']); $('#message_error').html(d['ERROR']); } |
ad20c698a Результаты на вос... |
157 |
//console.log(d['REDIRECT']); |
a9dfa8c95 Обновление на 7 м... |
158 159 160 161 162 163 164 165 166 167 168 |
//$('#block_1').html(data); }, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, error: function (data) { data = JSON.stringify(data); console.log('Error: ' + data); } }); }); |
ef73d19b1 worker/amployer r... |
169 170 |
$('#form1').on('submit', function (e) { e.preventDefault(); |
a9dfa8c95 Обновление на 7 м... |
171 |
|
ac8b91cfd Обновление системы. |
172 |
if (document.getElementById("cpatchaTextBox1").value == code) { |
ef73d19b1 worker/amployer r... |
173 |
console.log('Валидная капча'); |
ac8b91cfd Обновление системы. |
174 |
} else { |
ef73d19b1 worker/amployer r... |
175 |
$('#captcha_error').text('Капча неверная!'); |
ac8b91cfd Обновление системы. |
176 177 |
return false; } |
ef73d19b1 worker/amployer r... |
178 179 180 |
$('.error-message').text(''); let formData = $(this).serialize(); |
31fe4e458 Показ проекта зак... |
181 |
|
a9dfa8c95 Обновление на 7 м... |
182 |
$.ajax({ |
ef73d19b1 worker/amployer r... |
183 184 185 186 187 |
url: $(this).attr('action'), method: $(this).attr('method'), data: formData, success: function (response) { if (response.REDIRECT) { |
f9f2078d8 add popup for emp... |
188 |
successfulRegistrationWorker() |
a9dfa8c95 Обновление на 7 м... |
189 |
} |
a9dfa8c95 Обновление на 7 м... |
190 |
}, |
ef73d19b1 worker/amployer r... |
191 192 193 194 195 196 197 198 199 200 201 202 |
error: function (jqXHR) { if (jqXHR.status === 422) { let errors = jqXHR.responseJSON.ERRORS; for (let field in errors) { if (errors.hasOwnProperty(field)) { $('#' + field + '_error').text(errors[field][0]); } } } else { alert('Произошла ошибка при регистрации. Попробуйте снова.'); } |
a9dfa8c95 Обновление на 7 м... |
203 204 |
} }); |
a9dfa8c95 Обновление на 7 м... |
205 |
}); |
6408200e4 register form popups |
206 207 208 209 210 211 212 213 214 |
$(document).on('click', '.open-login-modal', function(e) { e.preventDefault(); $.fancybox.close(); $.fancybox.open({ src: '#sign', type: 'inline', opts: {touch: false} }); }); |
ef73d19b1 worker/amployer r... |
215 216 |
$('#form2').on('submit', function (e) { e.preventDefault(); |
a9dfa8c95 Обновление на 7 м... |
217 |
|
ac8b91cfd Обновление системы. |
218 |
if (document.getElementById("cpatchaTextBox2").value == code2) { |
ef73d19b1 worker/amployer r... |
219 |
console.log('Валидная капча'); |
ac8b91cfd Обновление системы. |
220 |
} else { |
ef73d19b1 worker/amployer r... |
221 |
$('#captcha_employer_error').text('Капча неверная!'); |
ac8b91cfd Обновление системы. |
222 223 |
return false; } |
a9dfa8c95 Обновление на 7 м... |
224 |
|
ef73d19b1 worker/amployer r... |
225 226 227 |
$('.employer_error-message').text(''); let formData = $(this).serialize(); |
ac8b91cfd Обновление системы. |
228 |
|
a9dfa8c95 Обновление на 7 м... |
229 |
$.ajax({ |
ef73d19b1 worker/amployer r... |
230 231 232 233 234 235 |
url: $(this).attr('action'), method: $(this).attr('method'), data: formData, success: function (response) { if (response.REDIRECT) { successfulRegistrationEmployer(); |
a9dfa8c95 Обновление на 7 м... |
236 |
} |
a9dfa8c95 Обновление на 7 м... |
237 |
}, |
ef73d19b1 worker/amployer r... |
238 239 240 241 242 243 244 245 246 247 248 249 |
error: function (jqXHR) { if (jqXHR.status === 422) { let errors = jqXHR.responseJSON.ERRORS; for (let field in errors) { if (errors.hasOwnProperty(field)) { $('#' + field + '_employer_error').text(errors[field][0]); } } } else { alert('Произошла ошибка при регистрации. Попробуйте снова.'); } |
a9dfa8c95 Обновление на 7 м... |
250 251 |
} }); |
a9dfa8c95 Обновление на 7 м... |
252 |
}); |
a9dfa8c95 Обновление на 7 м... |
253 |
</script> |