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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<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 utente:<br>
		<input type="text" name="user_cell">
		<br>
		Email utente:<br>
		<input type="text" name="user_email">
		<br>
		<input type="hidden" name="action" value="upload" />
            <label>Avatar:</label>
            <input type="file" name="avatar_file" />
            <br />
		<br>
		Nome locale:<br>
		<input type="text" name="nomelocale">
		<br>
		Descrizione:<br>
		<input type="textarea" name="descrizione">
		<br>
		Tipologia:<br>
		<input type="text" name="tipologia">
		<br>
		Email locale:<br>
		<input type="text" name="local_email">
		<br>
		Numero telefono locale:<br>
		<input type="text" name="local_phone">
		<br>
		Sito internet locale:<br>
		<input type="text" name="local_website">
		<br>

		<input type="submit" value="Lancia!">

	</form>

	<form id="submit_image">
			<input type="hidden" name="action" value="upload" />
            <label>Carica immagine locale:</label>
            <input type="file" name="image_file" />
            <br />
            <input type="submit" value="Carica immagine">
		</form>

	<br>

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

	<div id="output_submit"></div>

	<div id="output_submit_image"></div>

	<script>
		var imgs = new Array();
		var token;

		$(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 user_cell 		= $("#submit input[name='user_cell']").val();
				var user_email 		= $("#submit input[name='user_email']").val();
				var avatar 			= $("#submit input[name='avatar_file']").val();


				var nomelocale 		= $("#submit input[name='nomelocale']").val();
				var descrizione		= $("#submit input[name='descrizione']").val();
				var tipologia		= $("#submit input[name='tipologia']").val();
				var local_email 	= $("#submit input[name='local_email']").val();
				var local_phone		= $("#submit input[name='local_phone']").val();
				var local_website	= $("#submit input[name='local_website']").val();

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

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

				params = JSON.stringify(params);

				function ajaxResRegisterLocal(data) {
					var json_output = JSON.stringify(data);
					imgs = [];
					$("#output").append(json_output);
				}

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

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

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

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

					$("#output").append(json_output);

					var params = {
						user_id: data.id,
						nomelocale: nomelocale,
						descrizione: descrizione,
						tipologia: tipologia,
						telefono: local_phone,
						email: local_email,
						sito: local_website,
						imgs: imgs,
						token: token
					}

					params = JSON.stringify(params);

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

				}

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

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

			})
			
			$("#submit_image").submit(function(e) {

				e.preventDefault();

				var formData = new FormData();
				var image_file = $("#submit_image input[name='image_file']")[0].files[0]
				formData.append("image_file", image_file);

				function ajaxResUploadImage(data) {
					//var json_output = JSON.stringify(data);
					var jsonObj = JSON.parse(data);
					imgs.push(jsonObj.image_file);
					$("#output_submit_image").append(data);
				}

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

		});
	</script>

	</body>
</html>

Commits for Nextrek/Android/SmartCharging/endPoints/examples/registrazione_locale.html

Diff revisions: vs.
Revision Author Commited Message
510 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 12:50:58 +0000

Merge ramo stable con la nightly.

507 Diff Diff FSallustio picture FSallustio Thu 20 Aug, 2015 07:51:22 +0000

Merge ramo stable con la nightly.

354 Diff Diff FSallustio picture FSallustio Thu 16 Jul, 2015 10:20:42 +0000

Prima versione della login.php (effettua per ora solo il check dello username/password)

310 Diff Diff FSallustio picture FSallustio Tue 14 Jul, 2015 07:27:01 +0000
309 Diff Diff FSallustio picture FSallustio Mon 13 Jul, 2015 16:08:26 +0000
300 FSallustio picture FSallustio Mon 13 Jul, 2015 15:15:58 +0000