Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<html>
	<head>
	<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
	</head>

	<body>
	<form id="submit">
		Username:<br>
		<input type="text" name="username">
		<br>
		Password:<br>
		<input type="password" name="password">
		<br>
		Nome:<br>
		<input type="text" name="nome">
		<br>
		Cognome:<br>
		<input type="text" name="cognome">
		<br>
		Cellulare:<br>
		<input type="text" name="cell">
		<br>
		Email:<br>
		<input type="text" name="email">
		<br>
		<input type="hidden" name="action" value="upload" />
            <label>Avatar:</label>
            <input type="file" name="avatar_file" />
            <br />
		<br>
		<input type="submit" value="Lancia!">

	</form>

	<br>

	<div id="output"></div>

	<script>
		$(document).ready(function() {
			$("#submit").submit(function(e) {
				e.preventDefault();

				var username 	= $("#submit input[name='username']").val();
				var password 	= $("#submit input[name='password']").val();
				var nome 		= $("#submit input[name='nome']").val();
				var cognome 	= $("#submit input[name='cognome']").val();
				var cell 		= $("#submit input[name='cell']").val();
				var email 		= $("#submit input[name='email']").val();
				var avatar 		= $("#submit input[name='avatar_file']").val();

				avatar = avatar.replace(/.*(\/|\\)/, '');

				var params = {
					username: username,
					password: password,
					nome: nome,
					cognome: cognome,
					cell: cell,
					email: email,
					avatar: avatar
				}

				params = JSON.stringify(params);

				function ajaxResRegisterUser(data) {
					var json_output = JSON.stringify(data);

					var image_file = $("#submit input[name='avatar_file']")[0].files[0];

					if (data.return == 0 && image_file) {
						var formData = new FormData();
						formData.append("avatar_file", image_file);
						formData.append("user_id", data.id);
						formData.append("avatar_name", data.avatar_name);
						formData.append("token", data.token);

						$.ajax({
						    url: '../upload_avatar.php',
						    data: formData,
						    cache: false,
						    contentType: false,
						    processData: false,
						    type: 'POST',
						    success: ajaxResUploadAvatar
						});
					};

				}

				function ajaxResUploadAvatar(data) {
					var json_output = JSON.stringify(data);
					$("#output").append(json_output);					
				}

				$.ajax({
					url: "../registrazione_utente.php",
					success: ajaxResRegisterUser,
					method: "POST",
					data: params
				});

			})
		})
	</script>

	</body>
</html>

Commits for Nextrek/Android/SmartCharging/endPoints/nightly/examples/registrazione_utente.html

Diff revisions: vs.
Revision Author Commited Message
508 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 08:43:10 +0000
424 Diff Diff FSallustio picture FSallustio Wed 22 Jul, 2015 14:40:43 +0000

Aggiunto supporto token ad alcune chiamate.

399 Diff Diff FSallustio picture FSallustio Mon 20 Jul, 2015 10:08:43 +0000

Ora la upload_avatar.php e la upload_image.php puntano a una directory esterna.

374 FSallustio picture FSallustio Fri 17 Jul, 2015 08:20:18 +0000

Creazione “branch” nightly