Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 20 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 20 Rev 37
Línea 1... Línea 1...
1
<html>
1
<html>
2
    <head>
2
    <head>
3
    </head>
3
    </head>
4
    <body>
4
    <body>
5
    <form name="form" id="form" action="https://dev-services.leaderslinked.com/signin" method="post">
5
    <form name="form" id="form" method="post">
6
    <label for="email">Correo</label>
6
    <label for="email">Correo</label>
7
    <input type="text" id="email" name="email" value="santiago.olivera@leaderslinked.com" />
7
    <input type="text" id="email" name="email" value="santiago.olivera@leaderslinked.com" />
8
    <label for="password">Clave</label>
8
    <label for="password">Clave</label>
9
    <input type="password" id="password" name="password" value="**9889CESAMSluz*" />
9
    <input type="password" id="password" name="password" value="**9889CESAMSluz*" />
10
    <input type="submit" value="Enviar" />
10
    <input type="button" id="btnEnviar" value="Enviar" />
Línea 11... Línea 11...
11
    
11
    
-
 
12
    </form>
-
 
13
    <div id="content" style="height: 200px; width: 100%; border: 1px black solid">
-
 
14
		
12
    </form>
15
	</div>
13
    </body>
16
    </body>
14
    <script src="jquery.js"></script>
17
    <script src="jquery.js"></script>
15
    <script>
18
    <script>
-
 
19
    jQuery( document ).ready(function( $ ) {
-
 
20
		var token = '';
-
 
21
		
-
 
22
		$.fn.loadMenu = function() {
-
 
23
			$.ajax({
-
 
24
   				'dataType'  : 'json',
-
 
25
         		'accept'    : 'application/json',
-
 
26
            	'method'    : 'get',
-
 
27
              	'url'       : 'https://dev-services.leaderslinked.com/helpers/menu',
-
 
28
        		'headers'	: { 
-
 
29
					'Authorization': 'Bearer ' + token,
-
 
30
        		}
-
 
31
     		}).done(function(response) {
-
 
32
            	$('#content').html(JSON.stringify(response))
-
 
33
            
-
 
34
         	}).fail(function( jqXHR, textStatus, errorThrown) {
-
 
35
                 $('#content').html(textStatus)
-
 
36
         	});
-
 
37
           	return false;
-
 
38
		}
-
 
39
		
-
 
40
		$.fn.loadToken = function() {
-
 
41
				$.ajax({
-
 
42
   				'dataType'  : 'json',
-
 
43
         		'accept'    : 'application/json',
-
 
44
            	'method'    : 'get',
-
 
45
              	'url'       : 'https://dev-services.leaderslinked.com/signin',
-
 
46
     		}).done(function(response) {
-
 
47
            	
-
 
48
            	if(response.success) {
-
 
49
					token = response.data.jwt;
-
 
50
					console.log('token = ' + token);
-
 
51
				}
-
 
52
            
-
 
53
         	}).fail(function( jqXHR, textStatus, errorThrown) {
-
 
54
                 console.log(textStatus)
-
 
55
         	});
-
 
56
           	return false;
-
 
57
			
Línea 16... Línea 58...
16
    jQuery( document ).ready(function( $ ) {
58
		}
-
 
59
    
-
 
60
        $('#btnEnviar').click(function(e) {
-
 
61
			e.preventDefault();
17
    
62
			
18
        $('form').submit(function(e) {
63
			
19
    
64
 
20
         	$.ajax({
65
         	$.ajax({
21
   				'dataType'  : 'json',
66
   				'dataType'  : 'json',
22
         		'accept'    : 'application/json',
67
         		'accept'    : 'application/json',
23
            	'method'    : 'post',
68
            	'method'    : 'post',
24
              	'url'       : $('#form').attr('action'),
69
              	'url'       : 'https://dev-services.leaderslinked.com/signin',
25
        		'data'      : $('#form').serialize(),
70
        		'data'      : $('#form').serialize(),
26
        		'headers'	: { 
-
 
27
					'Origin': 'dev.leaderslinked.com',
71
        		'headers'	: { 
28
        			'X-CSRF-TOKEN': 'asdasdasd',
72
					'Authorization': 'Bearer ' + token,
29
        		}
73
        		}
-
 
74
     		}).done(function(response) {
-
 
75
            	if(response.success) {
-
 
76
					setTimeout(() => {
-
 
77
					  $.fn.loadMenu();
Línea 30... Línea 78...
30
     		}).done(function(response) {
78
					}, 1000);
31
            	console.log(response);
79
				}
32
            
80
            
33
         	}).fail(function( jqXHR, textStatus, errorThrown) {
81
         	}).fail(function( jqXHR, textStatus, errorThrown) {
34
                 console.log(textStatus)
82
                 console.log(textStatus)
Línea -... Línea 83...
-
 
83
         	});
Línea 35... Línea 84...
35
         	});
84
           	return false;
36
           	return false;
85
        });
37
        });
86
        
38
        
87
        $.fn.loadToken();