Browse Source

system security status colors

raylu 12 years ago
parent
commit
9b824bff65
6 changed files with 41 additions and 6 deletions
  1. 23 1
      db/queries.py
  2. 7 0
      web/static/css/base.ccss
  3. 8 0
      web/static/js/common.js
  4. 1 1
      web/static/js/home.js
  5. 1 1
      web/static/js/kill.js
  6. 1 3
      web/static/js/kill_list.js

+ 23 - 1
db/queries.py

@@ -57,6 +57,7 @@ def kill_list(entity_type, entity_id):
 				entity_name = char[entity_type + '_name']
 		for kill in kills:
 			kill['kill_time'] = _format_kill_time(kill['kill_time'])
+			kill['security_status'] = _security_status(kill['system_name'], kill['security'])
 			chars = characters[kill['kill_id']]
 			kill['victim'] = chars['victim']
 			kill['final_blow'] = chars['final_blow']
@@ -66,12 +67,13 @@ def kill_list(entity_type, entity_id):
 def kill(kill_id):
 	with db.cursor() as c:
 		kill = db.get(c, '''
-			SELECT kill_time, cost, solarSystemName, security FROM kills
+			SELECT kill_time, cost, solarSystemName AS system_name, security FROM kills
 			JOIN kill_costs ON kill_costs.kill_id = kills.kill_id
 			JOIN eve.mapSolarSystems ON solar_system_id = solarSystemID
 			WHERE kills.kill_id = ?
 			''', kill_id)
 		kill['kill_time'] = _format_kill_time(kill['kill_time'])
+		kill['security_status'] = _security_status(kill['system_name'], kill['security'])
 
 		characters = db.query(c, '''
 			SELECT character_id, character_name, damage, victim, final_blow,
@@ -176,7 +178,27 @@ def top_cost():
 			ORDER BY cost DESC
 			LIMIT 25
 			''')
+	for kill in kills:
+		kill['security_status'] = _security_status(kill['system_name'], kill['security'])
 	return kills
 
 def _format_kill_time(kill_time):
 	return kill_time.strftime('%Y-%m-%d %H:%m')
+
+def _security_status(system_name, security):
+		wspace = False
+		if system_name[0] == 'J':
+			try:
+				int(system_name[1:])
+				wspace = True
+			except ValueError:
+				pass
+		if wspace:
+			security_status = '?'
+		elif security >= 0.5:
+			security_status = 'high'
+		elif security > 0.0:
+			security_status = 'low'
+		else:
+			security_status = 'null'
+		return security_status

+ 7 - 0
web/static/css/base.ccss

@@ -36,6 +36,13 @@ table:
 .clear:
 	clear: both
 
+.high:
+	color: #182
+.low:
+	color: #a60
+.null:
+	color: #a11
+
 #topbar:
 	width: 900px
 	margin: 50px auto 2px

+ 8 - 0
web/static/js/common.js

@@ -35,6 +35,14 @@
 		},
 		'format_billions': function(isk) {
 			return ykill.format_millions(isk / 1000);
+		},
+
+		'format_system': function(system, security, security_status) {
+			if (security_status == '?') // placeholder for w-space
+				security = '?';
+			else
+				security = security.toFixed(1);
+			return system + ' <span class="' + security_status + '">' + security + '</span>';
 		}
 	});
 })();

+ 1 - 1
web/static/js/home.js

@@ -5,7 +5,7 @@ window.addEvent('domready', function() {
 			table.grab(new Element('tr').adopt(
 				new Element('td').grab(ykill.portrait(kill['ship_type_id'], kill['ship_name'], 'type', '_32.png')),
 				new Element('td', {'html': kill['ship_name']}),
-				new Element('td', {'html': kill['system_name'] + ' (' + kill['security'].toFixed(1) + ')'}),
+				new Element('td', {'html': ykill.format_system(kill['system_name'], kill['security'], kill['security_status'])}),
 				new Element('td').grab(
 					new Element('a', {
 						'href': '/kill/' + kill['kill_id'],

+ 1 - 1
web/static/js/kill.js

@@ -13,7 +13,7 @@ window.addEvent('domready', function() {
 			),
 			new Element('tr').adopt(
 				new Element('td', {'html': 'system'}),
-				new Element('td', {'html': kill['solarSystemName'] + ' (' + kill['security'].toFixed(1) + ')'})
+				new Element('td', {'html': ykill.format_system(kill['system_name'], kill['security'], kill['security_status'])})
 			),
 			new Element('tr').adopt(
 				new Element('td').grab(

+ 1 - 3
web/static/js/kill_list.js

@@ -18,9 +18,7 @@ window.addEvent('domready', function() {
 			var td = new Element('td').grab(a);
 			tr.grab(td);
 
-			td = new Element('td');
-			td.appendText(kill['system_name'] + ' ');
-			td.grab(new Element('span', {'html': kill['security'].toFixed(1)}));
+			td = new Element('td', {'html': ykill.format_system(kill['system_name'], kill['security'], kill['security_status'])});
 			td.grab(new Element('br'));
 			td.appendText(kill['region']);
 			tr.grab(td);