PageSourceSearch

https://www.noteboardapp.com/js/loginRegister.js?v=9

js noteboardapp.com collected 2026-10-01 13:01:25 UTC 14,758 bytes, 417 lines download raw bytes

1
2// Identificadores de los widgets de reCAPTCHA (login y registro).
3// Se renderizan de forma explícita mediante el callback onloadRecaptcha,
4// que reCAPTCHA invoca automáticamente al cargar su script (api.js).
5var RECAPTCHA_SITEKEY = '6LdA6d4cAAAAAEMaLE6I9ijf5OoRkSO1UtAfoGiZ';
6var widgetLogin = null;
7var widgetRegistro = null;
8
9function onloadRecaptcha() {
10  if (document.getElementById('recaptcha-login')) {
11    widgetLogin = grecaptcha.render('recaptcha-login', { sitekey: RECAPTCHA_SITEKEY });
12  }
13  if (document.getElementById('recaptcha-registro')) {
14    widgetRegistro = grecaptcha.render('recaptcha-registro', { sitekey: RECAPTCHA_SITEKEY });
15  }
16}
17
18// Devuelve la respuesta del captcha del widget indicado ('' si no está listo).
19function respuestaCaptcha(widgetId) {
20  if (typeof grecaptcha === 'undefined' || widgetId === null) return '';
21  try {
22    return grecaptcha.getResponse(widgetId);
23  } catch (e) {
24    return '';
25  }
26}
27
28$(document).ready(function() {
29  var registro = document.URL.indexOf('register') > -1;
30
31  if (registro) {
32    muestraRegistro();
33  } else {
34    muestraLogin();
35  }
36
37  $(window).on('hashchange', function() {
38    registro = document.URL.indexOf('register') > -1;
39
40    if (registro) {
41      muestraRegistro(true);
42    } else {
43      muestraLogin(true);
44    }
45  });
46
47  $('#formLogin').on("submit", function (event) {
48    event.preventDefault();
49
50    if ($('#campos-log').is(':visible')) {
51      loginUsuario();
52    } else {
53      registraUsuario();
54    }
55
56    return false;
57  });
58
59  $('.buttonLoginRegistro').off().on("click", function (evt) {
60    evt.preventDefault()
61
62    muestraMensajeModal('')
63    if (!$('#campos-reg').is(':visible')) {
64      muestraRegistro(true);
65    } else {
66      muestraLogin(true);
67    }
68
69    return false;
70  });
71
72  $('#fb-login').attr('title', getMessage("facebookLoginAviso"));
73
74
75  // $('#fb-login').tooltipster({
76  //   theme: ['tooltipster-noir', 'tooltipster-noir-customized'],
77  //   side: 'top',
78  //   delay: 100,
79  //   zIndex: 1000000000
80  // });
81  // $('input[type=text], input[type=password], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=search], input[type=date], input[type=time], textarea').each(function (element, i) {
82  //     if ((element.value !== undefined && element.value.length > 0) || $(this).attr('placeholder') !== null) {
83  //         $(this).siblings('label').addClass('active');
84  //     }
85  //     else {
86  //         $(this).siblings('label').removeClass('active');
87  //     }
88  // });
89});
90
91function muestraRegistro(slide) {
92  if (slide) {
93    $('#campos-log').slideUp();
94    $('#campos-reg').slideDown();
95  } else {
96    $('#campos-log').hide();
97    $('#campos-reg').show();
98  }
99  $("#buttonRegistro").text(getMessage("irLogin"));
100  $('#buttonSubmit span').text(getMessage("registro"));
101}
102
103function muestraLogin(slide) {
104  if (slide) {
105    $('#campos-log').slideDown();
106    $('#campos-reg').slideUp();
107  } else {
108    $('#campos-log').show();
109    $('#campos-reg').hide();
110  }
111  $('#buttonSubmit span').text('Login');
112  $("#buttonRegistro").text(getMessage("irRegistro"));
113}
114
115function loginUsuario() {
116
117  if (document.getElementById('nick').value == '') {
118    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta informar nombre de usuario');
119    else muestraMensajeModal('Username empty');
120    document.getElementById('nick').focus();
121    return false;
122  }
123  if (HayEspacios(document.getElementById('nick').value)) {
124    if (idiomaEsp(navigator.language)) muestraMensajeModal('No se permiten espacios en el nombre de usuario');
125    else muestraMensajeModal('Username without spaces please');
126    document.getElementById('nick').focus();
127    return false;
128  }
129  if (document.getElementById('pwd').value == '') {
130    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta informar password');
131    else muestraMensajeModal('Password empty');
132    document.getElementById('pwd').focus();
133    return false;
134  }
135  if (HayEspacios(document.getElementById('pwd').value)) {
136    if (idiomaEsp(navigator.language)) muestraMensajeModal('Hay espacios en el password');
137    else muestraMensajeModal('Password without spaces please');
138    document.getElementById('pwd').focus();
139    return false;
140  }
141
142  if (!document.URL.startsWith('http://localhost') && !respuestaCaptcha(widgetLogin)) {
143    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta comprobar que no eres un robot');
144    else muestraMensajeModal('Verify that you are not a robot ');
145    return false;
146  }
147
148  $('#mensaje-modal').html("");
149
150
151  login();
152
153}
154
155function login() {
156  $('#buttonSubmit i').addClass('loader');
157
158  var url = 'userLogin.php';
159  var param = 'nick=' + encodeURIComponent(document.getElementById('nick').value);
160  param += '&password=' + encodeURIComponent(document.getElementById('pwd').value);
161  param += '&g-recaptcha-response= ' + respuestaCaptcha(widgetLogin);
162  param += '&rememberme=' + document.getElementById('rememberme').checked;
163
164  $.ajax({
165    type: "POST",
166    url: url,
167    data: param,
168    cache: false,
169    success: function (answer) {
170      var resp = JSON.parse(answer);
171
172      if (resp.isSuccess) {
173        decidePantallaAlLoguearse(resp);
174      } else {
175        muestraMensajeModal('ERROR! ' + resp.message);
176      }
177    },
178    error: function (objeto, quepaso, otroobj) {
179      muestraMensajeModal("ERROR " + quepaso);
180    },
181    complete: function () {
182      $('#buttonSubmit i').removeClass('loader');
183    }
184  });
185}
186
187
188var registrando;
189function registraUsuario() {
190
191  if (document.getElementById('signup').value == '') {
192    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta informar nombre de usuario');
193    else muestraMensajeModal('Username empty');
194    document.getElementById('signup').focus();
195    return false;
196  }
197  if (HayEspacios(document.getElementById('signup').value)) {
198    if (idiomaEsp(navigator.language)) muestraMensajeModal('No se permiten espacios en el nombre de usuario');
199    else muestraMensajeModal('Username without spaces please');
200    document.getElementById('signup').focus();
201    return false;
202  }
203  if (document.getElementById('signup').value.indexOf('@') != -1) {
204    if (idiomaEsp(navigator.language)) muestraMensajeModal("No puedes usar '@' en el nombre de usuario");
205    else muestraMensajeModal("Don't use '@' in username please");
206    document.getElementById('signup').focus();
207    return false;
208  }
209  if (document.getElementById('pwds').value == '') {
210    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta informar password');
211    else muestraMensajeModal('Password empty');
212    document.getElementById('pwds').focus();
213    return false;
214  }
215  if (HayEspacios(document.getElementById('pwds').value)) {
216    if (idiomaEsp(navigator.language)) muestraMensajeModal('Hay espacios en el password');
217    else muestraMensajeModal('Password without spaces please');
218    document.getElementById('pwds').focus();
219    return false;
220  }
221
222  if (document.getElementById('pwds2').value == '') {
223    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta informar confirmacion de password');
224    else muestraMensajeModal('Password confirmation empty');
225    document.getElementById('pwds2').focus();
226    return false;
227  }
228  if (document.getElementById('pwds').value != document.getElementById('pwds2').value) {
229    if (idiomaEsp(navigator.language)) muestraMensajeModal('Passwords diferentes');
230    else muestraMensajeModal('Passwords not equal');
231    document.getElementById('pwds2').focus();
232    return false;
233  }
234  if (document.getElementById('email').value == '') {
235    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta informar email');
236    else muestraMensajeModal('Mail empty');
237    document.getElementById('email').focus();
238    return false;
239  }
240  if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\D{2,4})+$/.test(document.getElementById('email').value)) {
241    if (idiomaEsp(navigator.language)) muestraMensajeModal('Mail incorrecto');
242    else muestraMensajeModal('Mail not correct');
243    document.getElementById('email').focus();
244    return false;
245  }
246
247  if (!$( "#leida-politica").is(':checked')) {
248    if (idiomaEsp(navigator.language)) muestraMensajeModal('No has leido la política de privacidad');
249    else muestraMensajeModal('You have not read the privacy policy');
250    document.getElementById('leida-politica').focus();
251    return false;
252  }
253
254  if (!document.URL.startsWith('http://localhost') && !respuestaCaptcha(widgetRegistro)) {
255    if (idiomaEsp(navigator.language)) muestraMensajeModal('Falta comprobar que no eres un robot');
256    else muestraMensajeModal('Verify that you are not a robot ');
257    return false;
258  }
259
260  $('#buttonSubmit i').addClass('loader');
261
262  var param = 'nick=' + encodeURIComponent(document.getElementById('signup').value);
263  param += '&password=' + encodeURIComponent(document.getElementById('pwds').value);
264  param += '&email=' + encodeURIComponent(document.getElementById('email').value);
265  param += '&g-recaptcha-response=' + respuestaCaptcha(widgetRegistro);
266
267  $.ajax({
268    type: "POST",
269    url: 'registraUsuario.php',
270    data: param,
271    timeout: 20000,
272    cache: false,
273    success: function (answer) {
274      if ($.trim(answer) != 'OK')  muestraMensajeModal('ERROR! ' + answer);
275      else {
276          localStorage.clear();
277          decidePantallaAlRegistrarse(answer)
278      }
279    },
280    error: function (objeto, quepaso, otroobj) {
281      console.log(quepaso);
282    },
283    complete: function () {
284      $('#buttonSubmit i').removeClass('loader');
285      if (widgetRegistro !== null && typeof grecaptcha !== 'undefined') grecaptcha.reset(widgetRegistro);
286    }
287  });
288}
289
290function enviaPassword() {
291  if (document.getElementById('nick').value == '') {
292    if (idiomaEsp(navigator.language)) muestraMensajeModal('Informa el nombre de usuario o mail');
293    else muestraMensajeModal('Fill username or mail please');
294    document.getElementById('nick').focus();
295    return false;
296  }
297  var param = 'nick=' + encodeURIComponent(document.getElementById('nick').value);
298
299  $.ajax({
300    type: "POST",
301    url: 'cambiaPass.php',
302    data: param,
303    timeout: 20000,
304    cache: false,
305    success: function (answer) {
306      if ($.trim(answer) != 'OK') muestraMensajeModal('ERROR! ' + answer);
307      else {
308        if (idiomaEsp(navigator.language)) muestraMensajeModal("Mail enviado para cambiar el password");
309        else muestraMensajeModal("Mail sent to change the password");
310      }
311    },
312    error: function (objeto, quepaso, otroobj) {
313      console.log(quepaso);
314    },
315  });
316}
317
318
319function onFailure(error) {
320  console.log(error);
321}
322
323function handleCredentialResponse(response) {
324  const idToken = response.credential;
325  const payload = JSON.parse(atob(idToken.split('.')[1]));
326  const userId = payload.sub;
327  const name = payload.name;
328  const email = payload.email;
329  const googleImage = payload.picture;
330
331var url = 'https://www.noteboardapp.com/api/loginGoogle2.php';
332// var url = 'http://localhost:8080/noteboardapp/api/loginGoogle.php';
333var param = 'id_token=' + encodeURIComponent(idToken);
334param += '&rememberme=' + document.getElementById('rememberme').checked;
335
336$.ajax({
337  type: "POST",
338  url: url,
339  cache: false,
340  data: param,
341  success: function (answer) {
342    if (answer[0] != '<') {
343      var resp = JSON.parse(answer);
344      if (resp.isSuccess) {
345        localStorage["id_usuario"] = resp.id_usuario;
346        localStorage["token"] = resp.token;
347        localStorage["nick"] = resp.nick;
348        localStorage["nickPublico"] = resp.nickPublico;
349        localStorage["confirmado"] = resp.confirmado;
350        localStorage["nuevoReg"] = resp.nuevoReg;
351        localStorage["sessionId"] = resp.sessionId;
352        localStorage["googleId"] = userId;
353        localStorage["profilePicture"] = googleImage;
354
355        if (document.getElementById('rememberme').checked) {
356          var expires = new Date();
357          expires.setTime(expires.getTime() + (3600 * 24 * 30 * 1000));
358          var contentCookie = encodeURIComponent(`usr=${name}&fbId=g-${userId}`);
359          document.cookie = 'Recordarme=' + contentCookie + '; expires=' + expires.toUTCString() + '; path=/';
360        }
361
362        if (resp.nuevoReg && resp.email && resp.email.indexOf('_repe') > -1) {
363          if (idiomaEsp(navigator.language)) {
364            var warningMessage = `Se ha creado una cuenta nueva con el login de Google. Ya tenías una cuenta con password asociada a tu gmail con
365            el usuario <b>${resp.id_usuario_repe}</b>. <br>Si en realidad querias acceder a la otra cuenta identificate con ese usuario y tu password.
366             Haz click <a href="remindPassword">aquí</a> sino recuerdas el password`;
367            var acceptMessage = 'Aceptar';
368          } else {
369            var warningMessage = `A new account has been created with the Google login. You already had an account with password and
370            your gmail with the user <b>${resp.id_usuario_repe}</b>, <br>If you really wanted to access to the other account, login with
371            that username and your password. Click <a href="remindPassword"> here </a> if you don't remember the password`;
372            var acceptMessage = 'Accept';
373          }
374
375          Swal.fire({
376            type: 'warning',
377            html: warningMessage,
378            confirmButtonText: acceptMessage,
379            confirmButtonClass: 'btn waves-effect waves-light grey darken-1',
380            backdrop: 'rgba(0,0,0,0.7)',
381            buttonsStyling: false
382          }).then(() => {
383            decidePantallaAlRegistrarse(resp);
384          })
385        } else {
386          decidePantallaAlRegistrarse(resp);
387        }
388
389      }
390    }
391  },
392  error: function (objeto, quepaso, otroobj) {
393    console.log(quepaso);
394    document.getElementById('capaContenedora').innerHTML = "ERROR " + quepaso;
395  },
396});
397}
398
399function decidePantallaAlRegistrarse(resp) {
400  if (document.URL.indexOf('registerSubs') > -1) {
401    document.location.href="subscribe.php#subscription";
402  } else{
403    if (resp.nuevoReg || resp == "OK") {
404      document.location.href = "subscribe.php";
405    } else {
406      document.location.href = "board";
407    }
408  }
409}
410
411function decidePantallaAlLoguearse(resp) {
412  if (document.URL.indexOf('registerSubs') > -1 && resp.confirmado == "0") {
413    document.location.href="subscribe.php#subscription";
414  } else{
415    document.location.href = "board";
416  }
417}

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.