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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
function openTextareaComment(comment_object) {
	var comment_content = comment_object.parent().find(".comment-content").html();
	comment_object.parent().hide(); //nascondo il corpo del commento

	htmlToPut = "<div class='comment-textarea-body'>";
	htmlToPut += "<textarea class='comment-textarea'>"+comment_content+"</textarea>"
	htmlToPut += "<div><button value='modifica-2' class='modify-button'>Modifica</button>";
	htmlToPut += "<button value='annulla' class='remove-button'>Annulla</button>";
	htmlToPut += "</div></div></div>";

	comment_object.parent().parent().append(htmlToPut);

	$(".modify-button[value='modifica-2']").click(function() {
		var that = $(this);
		$("#confirm-comment-dialog").data("el", that.closest(".comment")).dialog("open");
	});

	$(".remove-button[value='annulla']").click(function() {
		comment_object.parent().show();
		$(this).parent().parent().empty();
	})

}

function fetchComments(local_id, startIndex) {
	params = {
		id: local_id,
		startIndex: startIndex,
		length: 10,
		token: Cookies.get("token")
	};

	params = JSON.stringify(params);

	$.ajax({
		url: "../get_commenti.php",
		data: params,
		cache: false,
		contentType: false,
		processData: false,
		type: 'POST',
		success: function(data) {
			if (data.comments) {
				if (data.comments.length > 0) {

					for (var i = 0; i<data.comments.length; i++) {
						//per ora test
						//$("#comment-list").append(JSON.stringify(data.comments[i]));

						var htmlToPut = "<div comment-id='"+data.comments[i].id+"' class='comment'>";
						htmlToPut += "<div class='comment-header'><b>"+data.comments[i].username+"</b> " + data.comments[i].data + "</div>";
						htmlToPut += "<div class='comment-body'>";
						htmlToPut += "<div id='comment-id-"+data.comments[i].id+"-content' class='comment-content'>"+data.comments[i].descrizione+"</div>"
						htmlToPut += "<button value='modifica-1' class='modify-button'>Modifica</button>";
						htmlToPut += "<button value='rimuovi' class='remove-button'>Rimuovi</button></div>";
						htmlToPut += "</div>"

						$("#comment-list").append(htmlToPut);

						$("div[comment-id='"+data.comments[i].id+"'] .modify-button[value='modifica-1']").click(function() {
							openTextareaComment($(this));
						});

						$("div[comment-id='"+data.comments[i].id+"'] .remove-button[value='rimuovi']").click(function() {
							var that = $(this);
							$("#remove-comment-dialog").data("el", that.closest(".comment")).dialog("open");
						});

					}

					params = JSON.parse(this.data);

					if (data.count < params.startIndex+10) {
						$("#more-comments-button").hide();
					} else {
						$("#more-comments-button").click(function() {
							fetchComments(local_id, startIndex+10);
						});

						$("#more-comments-button").show();
					}

				} else {
					$("#comment-list").html("Non ci sono commenti al locale.");	
				}
			} else {
				alert("Errore nel caricare i commenti");
			}
		},
		error: function() {
			alert("Errore nel caricare i commenti");
		}
	});

}

function showComments(local_id) {
	if ($("#comments").is(":visible")) {
		$("#comments").hide();
		$("#comments-button").html("Show comments!!!");
	} else {
		$("#comments").show();
		$("#comments-button").html("Hide comments!!!");

		if (isEmpty($("#comment-list"))) {
			fetchComments(local_id, 0);
		}
	}
}

function loadLocalInfo(html_data, local_data) {
	$("#cp_workarea").empty();
	$("#cp_workarea").append(html_data);

	$("#full_local_info #nomelocale")
	.html(local_data.nomelocale);
	$("#full_local_info #username_owner")
	.html(local_data.username_owner);
	$("#full_local_info #descrizione")
	.html(local_data.descrizione);
	$("#full_local_info #tipologia")
	.html(local_data.tipologia);
	$("#full_local_info #lat")
	.html(local_data.lat);
	$("#full_local_info #lon")
	.html(local_data.lon);
	$("#full_local_info #indirizzo")
	.html(local_data.indirizzo);
	$("#full_local_info #email")
	.html(local_data.email);
	$("#full_local_info #telefono")
	.html(local_data.telefono);
	$("#full_local_info #sito")
	.html(local_data.sito);
	$("#full_local_info #n_punti_ricarica")
	.html(local_data.n_punti_ricarica);

	//$("#full_local_info").styleTable();

	$("#comments-button").click(function() {
		showComments(local_data.id);
	});

	$("#confirm-comment-dialog").dialog({
		autoOpen: false,
		buttons: [{
			text: "Sì",
			click: function() {
				var el = $(this).data('el');
				$(this).dialog( "close" );

				var comment_id = el.attr("comment-id");
				var content = el.find("textarea").val();

				params = {
					comment_id: comment_id,
					content: content,
					token: Cookies.get("token")
				};

				params = JSON.stringify(params);

				$.ajax({
					url: "../edit_commento.php",
					data: params,
					cache: false,
					contentType: false,
					processData: false,
					type: 'POST',
					success: function(data) {
						el.find(".comment-textarea-body").remove();
						el.find(".comment-body .comment-content").html(data.content);
						el.find(".comment-body").show();
					},
					error: function() {
						alert("Errore nel modificare il commento");
					}
				});

			}
		},
		{
			text: "No",
			click: function() {
				$(this).dialog( "close" );
			}
		}]
	});

	$("#remove-comment-dialog").dialog({
		autoOpen: false,
		buttons: [{
			text: "Sì",
			click: function() {
				var el = $(this).data('el');
				$(this).dialog( "close" );

				var comment_id = el.attr("comment-id");

				params = {
					comment_id: comment_id,
					token: Cookies.get("token")
				};

				params = JSON.stringify(params);

				$.ajax({
					url: "../delete_commento.php",
					data: params,
					cache: false,
					contentType: false,
					processData: false,
					type: 'POST',
					success: function(data) {
						el.remove();
					},
					error: function() {
						alert("Errore nel modificare il commento");
					}
				});

			}
		},
		{
			text: "No",
			click: function() {
				$(this).dialog( "close" );
			}
		}]
	});
}

function showLocalInfo(local_id) {
	params = {
		id: local_id,
		token: Cookies.get("token")
	};

	params = JSON.stringify(params);

	$.ajax({
		url: "../get_info_full_locale.php",
		data: params,
		cache: false,
		contentType: false,
		processData: false,
		type: 'POST',
		success: function(local_data) {
			getHtmlPage("./skeletons/full_local_info.html", function(html_data) {
				loadLocalInfo(html_data, local_data);
			});
		},
		error: function() {
			alert("Errore nel caricare le info del locale");
		}
	});
}

function showLocalTable(data) {
	$("#cp_workarea").append(data);

	var localTable = $('#dt_locallist').DataTable( {
		"processing": true,
		"serverSide": true,
		"ajax": "dt_locallist.php",
		"columns": [
		{ "data": "nomelocale" },
		{ "data": "descrizione" },
		{ "data": "tipologia" },
		{ "data": "indirizzo" },
		{ "data": "email" },
		{ "data": "telefono" },
		{ "data": "sito" },
		{ "data": "n_punti_ricarica" },
		{ "data": "hidden" },
		{
			"data": function(row) {
				return "<button value='modifica'>Modifica</button>"
			}
		}
		]
	} );


	$('#dt_locallist').on( 'click', 'button', function () {
		var data = localTable.row( $(this).parents('tr') ).data();
		var value = $(this).attr("value");

		var local_id = $(this).parents('tr').attr("id").replace("row_", "");
		showLocalInfo(local_id);

	} );
}

function showLocalList() {
	$("#cp_workarea").empty();
	getHtmlPage("./skeletons/locallist.html", showLocalTable);
}

Commits for Nextrek/Android/SmartCharging/endPoints/nightly/control_panel/js/locals.js

Diff revisions: vs.
Revision Author Commited Message
612 Diff Diff FSallustio picture FSallustio Mon 31 Aug, 2015 08:38:16 +0000

Locali nascosti quando l’utente proprietario viene “rimosso”/disabilitato.

602 Diff Diff FSallustio picture FSallustio Fri 28 Aug, 2015 10:49:31 +0000
594 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 15:20:17 +0000
592 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 14:35:49 +0000
591 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 14:28:30 +0000
590 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 13:54:17 +0000
589 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 13:52:26 +0000
587 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 13:28:12 +0000
586 Diff Diff FSallustio picture FSallustio Thu 27 Aug, 2015 10:32:34 +0000
580 FSallustio picture FSallustio Thu 27 Aug, 2015 08:45:02 +0000