From 4d882e6d16036c99055cfb8df0bf8c25bcbb8d8c Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sun, 14 May 2017 22:21:25 +0000
Subject: [PATCH] Change alert view and add top menu

---
 map.js |   49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/map.js b/map.js
index f791391..5a8c6bf 100644
--- a/map.js
+++ b/map.js
@@ -23,12 +23,11 @@
 
 var map = null;
 var map_sphere = null;
-var fail_element = document.getElementById('fail');
 
 var ignore_hashchange = false;
 
 var Panel = {
-	element: document.getElementById('popup'),
+	element: document.getElementById('panel'),
 	closeCallback: undefined,
 	
 	callCloseCallback: function() {
@@ -63,10 +62,19 @@
 	},
 };
 
-function fail(msg) {
-	setText(fail_element, msg);
-	fail_element.style.top = '0.5em';
-}
+var Alert = {
+	element: document.getElementById('alert'),
+	
+	show: function(message) {
+		setText(this.element, message);
+		this.element.className = '';
+	},
+	
+	fail: function(message) {
+		this.show(message);
+		this.element.className = 'error';
+	},
+};
 
 function fail_ajax_generic(data, fnc) {
 	// abort() is not a failure
@@ -82,11 +90,11 @@
 }
 
 function fail_ajax(data) {
-	fail_ajax_generic(data, fail);
+	fail_ajax_generic(data, Alert.fail.bind(Alert));
 }
 
 function fail_ajax_popup(data) {
-	fail_ajax_generic(data, Panel.fail);
+	fail_ajax_generic(data, Panel.fail.bind(Panel));
 }
 
 function getGeometry(object) {
@@ -588,7 +596,7 @@
 
 function init() {
 	if(!window.jQuery) {
-		fail(lang.jquery_not_loaded);
+		Alert.show(lang.jquery_not_loaded);
 		return;
 	}
 	
@@ -602,6 +610,7 @@
 	});
 	stops_layer = new ol.layer.Vector({
 		source: stops_source,
+		
 	});
 	
 	stop_points_source = new ol.source.Vector({
@@ -614,6 +623,7 @@
 	
 	vehicles_source = new ol.source.Vector({
 		features: [],
+		attributions: lang.copy_zikit,
 	});
 	vehicles_layer = new ol.layer.Vector({
 		source: vehicles_source,
@@ -621,6 +631,7 @@
 	
 	route_source = new ol.source.Vector({
 		features: [],
+		attributions: lang.copy_jacekk,
 	});
 	route_layer = new ol.layer.Vector({
 		source: route_source,
@@ -633,7 +644,9 @@
 		target: 'map',
 		layers: [
 			new ol.layer.Tile({
-				source: new ol.source.OSM()
+				source: new ol.source.OSM({
+					attributions: lang.copy_osm,
+				})
 			}),
 			route_layer,
 			stops_layer,
@@ -648,14 +661,7 @@
 			attributionOptions: ({
 				collapsible: false,
 			})
-		}).extend([
-			new ol.control.Control({
-				element: document.getElementById('title'),
-			}),
-			new ol.control.Control({
-				element: fail_element,
-			})
-		]),
+		}),
 		loadTilesWhileAnimating: true,
 	});
 	map_sphere = new ol.Sphere(6378137);
@@ -725,10 +731,6 @@
 		
 		featureClicked(feature);
 	});
-	
-	fail_element.addEventListener('click', function() {
-		fail_element.style.top = '-10em';
-	});
 
 	// Change mouse cursor when over marker
 	map.on('pointermove', function(e) {
@@ -756,8 +758,9 @@
 		if(vehicles_xhr) vehicles_xhr.abort();
 		if(vehicles_timer) clearTimeout(vehicles_timer);
 		  
-		fail(lang.error_refresh);
+		Alert.show(lang.error_refresh);
 	}, 1800000);
 }
 
 init();
+checkVersion();

--
Gitblit v1.9.1