Browse Source

list all saloons

AR 11 months ago
parent
commit
fb2cb7c85e
4 changed files with 34 additions and 6 deletions
  1. 4 0
      functions.php
  2. 0 1
      history/index.php
  3. 27 5
      index.php
  4. 3 0
      style.css

+ 4 - 0
functions.php

@@ -124,6 +124,8 @@ function update_sessions_status($json_sessions)
124 124
 	$delete_ids = array();
125 125
 	foreach ($json_sessions as $session_id => $session)
126 126
 	{
127
+		if($session_id == "all_saloons") continue;
128
+		
127 129
 		$delta_second = time() - $session['last_update'];
128 130
 
129 131
 		$session['idle'] = ($delta_second > getSetup('warning_idle_session_seconds', 20))?'true':'false';
@@ -132,6 +134,8 @@ function update_sessions_status($json_sessions)
132 134
 		{
133 135
 			$delete_ids [] = $session_id;
134 136
 		}
137
+		
138
+		$json_sessions['all_saloons'][$session['saloon']] = '';
135 139
 	}
136 140
 
137 141
 	foreach($delete_ids as $delete_id)

+ 0 - 1
history/index.php

@@ -1 +0,0 @@
1
-<?php //Silence ?>

+ 27 - 5
index.php

@@ -76,6 +76,10 @@ if (!isset($_SESSION['name'])) {
76 76
 			<b>Autres Fameux</b>
77 77
 			<div id="usrs_others"></div>
78 78
 
79
+			<br><br>
80
+			<b>Salons</b>
81
+			<div id="all_saloons"></div>
82
+
79 83
 			<br><br>
80 84
 			<b>Nouveau saloon</b>
81 85
 			<div id="div_new_saloon">
@@ -163,7 +167,7 @@ if (!isset($_SESSION['name'])) {
163 167
 		}
164 168
 		else
165 169
 		{
166
-			date_string = evt_date.toLocaleDateString() + ' ';
170
+			date_string = evt_date.toLocaleDateString('fr-FR') + ' ';
167 171
 		}
168 172
 
169 173
 		date_string += pad00(evt_date.getHours()) + ':' + pad00(evt_date.getMinutes());
@@ -235,7 +239,9 @@ if (!isset($_SESSION['name'])) {
235 239
 		audio.volume = 0.05;
236 240
 		
237 241
 		$("#submit_new_saloon").click(function(){
242
+			if(!$("#text_new_saloon").val()) return false;
238 243
 			change_saloon($("#text_new_saloon").val());
244
+			$("#text_new_saloon").val('');
239 245
 			return false;
240 246
 		});
241 247
 		
@@ -282,16 +288,32 @@ if (!isset($_SESSION['name'])) {
282 288
 					var html_others = '';
283 289
 					$("#usrs").html('');
284 290
 					$("#usrs_others").html('');
291
+					$("#all_saloons").html('');
292
+
293
+					var add_handler = function(link, saloon_id) { link.click(function(){change_saloon(saloon_id);}) }; 
294
+
285 295
 					for (var usr in data) {
286
-						if(data[usr].saloon == saloon_id)
296
+						if(usr == "all_saloons")
297
+						{
298
+							var saloon_ids = Object.keys(data[usr]).sort();
299
+							
300
+							for(var i in saloon_ids)
301
+							{
302
+								var link = $("<a><span class='saloon_id'><em>"+ saloon_ids[i] + "</em></span></a>");
303
+								add_handler(link, saloon_ids[i]);
304
+								$("#all_saloons").append(link);
305
+							}
306
+							continue;
307
+						}
308
+						else if(data[usr].saloon == saloon_id)
287 309
 						{
288
-							$("#usrs").append("<div class='msgln' style='color:" + color_from_login(data[usr].login) + "'><em>"+data[usr].login+"</em></div>");
310
+							$("#usrs").append("<div class='user_id' style='color:" + color_from_login(data[usr].login) + "'><em>"+data[usr].login+"</em></div>");
289 311
 						}
290 312
 						else
291 313
 						{
292
-							var link = $("<a><div class='msgln' style='color:" + color_from_login(data[usr].login) + "'><em>"+data[usr].login + " (" + data[usr].saloon + ")</em></div></a>");
314
+							var link = $("<a><div class='user_id' style='color:" + color_from_login(data[usr].login) + "'><em>"+data[usr].login + " (" + data[usr].saloon + ")</em></div></a>");
293 315
 							var saloon = data[usr].saloon;
294
-							link.click(function(){change_saloon(saloon);});
316
+							add_handler(link, saloon);
295 317
 							$("#usrs_others").append(link);
296 318
 						}
297 319
 					}

+ 3 - 0
style.css

@@ -91,3 +91,6 @@ a:hover { text-decoration: underline; }
91 91
 .logout { float: right; }
92 92
 
93 93
 .msgln { margin:0 0 2px 0; }
94
+
95
+.saloon_id { margin-right: 5px; }
96
+.user_id { margin-right: 5px; }