diff --git a/cities/cities-promods-rusmap.js b/cities/cities-promods-rusmap.js
index 95cd9fb6a..0bbc0e483 100644
--- a/cities/cities-promods-rusmap.js
+++ b/cities/cities-promods-rusmap.js
@@ -75,7 +75,7 @@ var cities = [
{
"gameName": "antwerp",
"realName": "Antwerpen",
- "country": "belgium",
+ "country": "belgium-nl",
"x": "-21215.1",
"y": "82",
"z": "-5293.52"
@@ -155,7 +155,7 @@ var cities = [
{
"gameName": "basel",
"realName": "Basel",
- "country": "switzerland",
+ "country": "switzerland-de",
"x": "-11649.5",
"y": "107.949",
"z": "17001.7"
@@ -195,7 +195,7 @@ var cities = [
{
"gameName": "bern",
"realName": "Bern",
- "country": "switzerland",
+ "country": "switzerland-de",
"x": "-12730.8",
"y": "101.68",
"z": "20130.1"
@@ -323,7 +323,7 @@ var cities = [
{
"gameName": "brussel",
"realName": "Brussel",
- "country": "belgium",
+ "country": "belgium-fr",
"x": "-21853.1",
"y": "99.3594",
"z": "-2960.22"
@@ -683,7 +683,7 @@ var cities = [
{
"gameName": "geneve",
"realName": "Genève",
- "country": "switzerland",
+ "country": "switzerland-fr",
"x": "-18099.1",
"y": "101.68",
"z": "23717"
@@ -1227,7 +1227,7 @@ var cities = [
{
"gameName": "liege",
"realName": "Liège",
- "country": "belgium",
+ "country": "belgium-fr",
"x": "-17181.5",
"y": "108.012",
"z": "-1231.25"
@@ -2443,7 +2443,7 @@ var cities = [
{
"gameName": "zurich",
"realName": "Zürich",
- "country": "switzerland",
+ "country": "switzerland-de",
"x": "-8473.81",
"y": "101.953",
"z": "17968.5"
diff --git a/cities/cities-promods.js b/cities/cities-promods.js
index ae96c0785..d628f07a8 100644
--- a/cities/cities-promods.js
+++ b/cities/cities-promods.js
@@ -75,7 +75,7 @@ var cities = [
{
"gameName": "antwerp",
"realName": "Antwerpen",
- "country": "belgium",
+ "country": "belgium-nl",
"x": "-21215.1",
"y": "82",
"z": "-5293.52"
@@ -155,7 +155,7 @@ var cities = [
{
"gameName": "basel",
"realName": "Basel",
- "country": "switzerland",
+ "country": "switzerland-de",
"x": "-11649.5",
"y": "107.949",
"z": "17001.7"
@@ -195,7 +195,7 @@ var cities = [
{
"gameName": "bern",
"realName": "Bern",
- "country": "switzerland",
+ "country": "switzerland-de",
"x": "-12730.8",
"y": "101.68",
"z": "20130.1"
@@ -323,7 +323,7 @@ var cities = [
{
"gameName": "brussel",
"realName": "Brussel",
- "country": "belgium",
+ "country": "belgium-fr",
"x": "-21853.1",
"y": "99.3594",
"z": "-2960.22"
@@ -683,7 +683,7 @@ var cities = [
{
"gameName": "geneve",
"realName": "Genève",
- "country": "switzerland",
+ "country": "switzerland-fr",
"x": "-18099.1",
"y": "101.68",
"z": "23717"
@@ -1227,7 +1227,7 @@ var cities = [
{
"gameName": "liege",
"realName": "Liège",
- "country": "belgium",
+ "country": "belgium-fr",
"x": "-17181.5",
"y": "108.012",
"z": "-1231.25"
@@ -2443,7 +2443,7 @@ var cities = [
{
"gameName": "zurich",
"realName": "Zürich",
- "country": "switzerland",
+ "country": "switzerland-de",
"x": "-8473.81",
"y": "101.953",
"z": "17968.5"
diff --git a/dashboard.css b/dashboard.css
index 2234887c3..f2e68ddbb 100644
--- a/dashboard.css
+++ b/dashboard.css
@@ -66,4 +66,10 @@ body {
font-size: 25px;
width: 100% !important;
text-align: center;
+}
+
+.top-right {
+ position: absolute;
+ top: 1px;
+ right: 16px;
}
\ No newline at end of file
diff --git a/dashboard.html b/dashboard.html
index dcf82b922..5f4446097 100644
--- a/dashboard.html
+++ b/dashboard.html
@@ -98,7 +98,9 @@
Enter the device ID:
function connect(peerID) {
conn = peer.connect(peerID);
conn.on('open', function () {
- conn.send("CONNECT");
+ conn.send(JSON.stringify({
+ type: "connect"
+ }));
console.log("Successfully connected");
controlRemote = true;
connectedPeerID = peerID;
diff --git a/dashboard.js b/dashboard.js
index bcc800bfb..37f48175f 100644
--- a/dashboard.js
+++ b/dashboard.js
@@ -45,16 +45,18 @@ Funbit.Ets.Telemetry.Dashboard.prototype.initialize = function (skinConfig, util
//Receive message logic
peer.on('connection', function (conn) {
conn.on('data', function (data) {
+ var response = JSON.parse(data);
console.log(data);
- if(data == "CONNECT"){
+ if(response.type == "connect"){
//Show connected
console.log("Someone started controlling this player remotely");
$(".remote").show();
}
- if (data.substring(0, 1) == "{") {
- //If an object, set radio
- var obj = JSON.parse(data);
- setRadioStation(obj.url, obj.country, obj.volume);
+ if(response.type == "station"){
+ setRadioStation(response.url, response.country, response.volume);
+ }
+ if(response.type == "favourite"){
+ setFavouriteStation(response.country, response.name);
}
});
});
@@ -62,6 +64,11 @@ Funbit.Ets.Telemetry.Dashboard.prototype.initialize = function (skinConfig, util
g_whitenoise = skinConfig.whitenoise;
+ //Refresh stations every 10 seconds:
+ setInterval(function () {
+ refreshStations();
+ }, 10000);
+
// return to menu by a click
//$(document).add('body').on('click', function () {
//window.history.back();
@@ -77,25 +84,6 @@ Funbit.Ets.Telemetry.Dashboard.prototype.filter = function (data, utils) {
// This filter is used to change telemetry data
// before it is displayed on the dashboard.
// You may convert km/h to mph, kilograms to tons, etc.
-
- // round truck speed
- data.truck.speedRounded = Math.abs(data.truck.speed > 0
- ? Math.floor(data.truck.speed)
- : Math.round(data.truck.speed));
-
- // other examples:
-
- // convert kilometers per hour to miles per hour
- data.truck.speedMph = data.truck.speed * 0.621371;
- // convert kg to t
- data.trailer.mass = (data.trailer.mass / 1000.0) + 't';
- // format odometer data as: 00000.0
- data.truck.odometer = utils.formatFloat(data.truck.odometer, 1);
- // convert gear to readable format
- data.truck.gear = data.truck.gear > 0 ? 'D' + data.truck.gear : (data.truck.gear < 0 ? 'R' : 'N');
- // convert rpm to rpm * 100
- data.truck.engineRpm = data.truck.engineRpm / 100;
- // return changed data to the core for rendering
return data;
};
@@ -158,50 +146,25 @@ Funbit.Ets.Telemetry.Dashboard.prototype.render = function (data, utils) {
g_last_nearest_country != country_lowest_distance)) {
//If current station country is not close enough OR (the distance + treshold is larger than the new country's distance and the last station wasn't set manually.
g_last_nearest_country = country_lowest_distance;
- /*
- setRadioStation(document.getElementById("player").src, country_lowest_distance, available_countries[country_lowest_distance]["whitenoise"]);
-
- g_whitenoise = false;
- $("#player").animate({volume: 0}, 2000, function() {
- $("#player").animate({volume: 1}, 2000, function () {
- g_whitenoise = true;
- });
- });
- */
- setRadioStation(stations[country_lowest_distance][0]["url"], country_lowest_distance, available_countries[country_lowest_distance]["whitenoise"]);
+ //Check if there is a favourite station:
+ var index = 0;
+ if(localStorage.getItem("fav-" + country_lowest_distance) !== null) {
+ index = stations[country_lowest_distance].map(function (e) {
+ return e.name;
+ }).indexOf(localStorage.getItem("fav-" + country_lowest_distance));
+ }
+ setRadioStation(stations[country_lowest_distance][index]["url"], country_lowest_distance, available_countries[country_lowest_distance]["whitenoise"]);
}
if(Object.keys(available_countries).sort().toString() != Object.keys(g_countries).sort().toString()) {
//If they don't contain the same keys (ie. a country update)
g_countries = available_countries;
- var content = "";
- for (var key in available_countries) {
- if (!available_countries.hasOwnProperty(key)) continue;
- if (key == "none") continue;
- if ($.isEmptyObject(stations[key])) continue;
- //console.log(key);
- for (var j = 0; j < stations[key].length; j++) {
- var volume = available_countries[key]["whitenoise"];
- //$("#stationsList").append('' + stations[country_lowest_distance][j]['name'] + '');
- content +=
- '';
- }
- }
- $("#stationsList").html(content);
-
+ refreshStations();
} else {
setWhitenoise(available_countries[g_current_country]["whitenoise"]);
+ g_countries = available_countries;
}
}
};
@@ -215,6 +178,7 @@ function setRadioStation(url, country, volume) {
conn = peer.connect(connectedPeerID);
}
conn.send(JSON.stringify({
+ type: "station",
url: url,
country: country,
volume: volume
@@ -255,3 +219,52 @@ function setWhitenoise(volume) {
document.getElementById("whitenoise").pause();
}
}
+
+function setFavouriteStation(country, name) {
+ if(controlRemote){
+ if(!conn.open){
+ //If connection closed, reconnect
+ conn = peer.connect(connectedPeerID);
+ }
+ conn.send(JSON.stringify({
+ type: "favourite",
+ country: country,
+ name: name
+ }));
+ } else {
+ localStorage.setItem("fav-" + country, name);
+ alert("Favourite for " + country.toUpperCase() + " is now " + name);
+ }
+}
+
+function refreshStations() {
+ var content = "";
+ for (var key in g_countries) {
+ //Check whether country should be checked:
+ if (!g_countries.hasOwnProperty(key)) continue;
+ if (key == "none") continue;
+ if ($.isEmptyObject(stations[key])) continue;
+ //console.log(key);
+
+ for (var j = 0; j < stations[key].length; j++) {
+ //Determine volume:
+ var volume = g_countries[key]["whitenoise"];
+ //Check whether the station distance can reached here:
+ if(typeof stations[key][j]["relative_radius"] === "undefined" || g_countries[key]["distance"] / stations[key][j]["relative_radius"] < g_skinConfig.radius) {
+ content +=
+ '';
+ }
+ }
+ }
+ $("#stationsList").html(content);
+}
\ No newline at end of file
diff --git a/stations/stations-europe.js b/stations/stations-europe.js
index ebdff1cd3..d0a83f8cf 100644
--- a/stations/stations-europe.js
+++ b/stations/stations-europe.js
@@ -1,6 +1,6 @@
var country_properties = {
"andorra": {
- relative_radius: 0.5,
+ relative_radius: 0.1,
},
"austria": {
relative_radius: 1,
@@ -8,12 +8,24 @@ var country_properties = {
"belarus": {
relative_radius: 1,
},
- "belgium": {
+ "belgium-nl": {
+ relative_radius: 1,
+ },
+ "belgium-fr": {
+ relative_radius: 1,
+ },
+ "bosnia": {
relative_radius: 1,
},
"bulgaria": {
relative_radius: 1,
},
+ "croatia": {
+ relative_radius: 1,
+ },
+ "cyprus": {
+ relative_radius: 1,
+ },
"czech": {
relative_radius: 1,
},
@@ -35,6 +47,9 @@ var country_properties = {
"germany": {
relative_radius: 1,
},
+ "greece": {
+ relative_radius: 1,
+ },
"hungary": {
relative_radius: 1,
},
@@ -44,14 +59,20 @@ var country_properties = {
"iom": {
relative_radius: 1,
},
+ "ireland": {
+ relative_radius: 1,
+ },
"italy": {
relative_radius: 1,
},
+ "jersey": {
+ relative_radius: 0.1,
+ },
"latvia": {
relative_radius: 1,
},
"liecht": {
- relative_radius: 0.5,
+ relative_radius: 0.1,
},
"lithuania": {
relative_radius: 1,
@@ -59,16 +80,25 @@ var country_properties = {
"luxembourg": {
relative_radius: 0.5,
},
+ "macedonia": {
+ relative_radius: 1,
+ },
"moldova": {
relative_radius: 1,
},
"netherlands": {
relative_radius: 1,
},
+ "nireland": {
+ relative_radius: 1,
+ },
"norway": {
relative_radius: 1,
},
"poland": {
+ relative_radius: 0.8,
+ },
+ "portugal": {
relative_radius: 1,
},
"romania": {
@@ -77,6 +107,9 @@ var country_properties = {
"russia": {
relative_radius: 1.1,
},
+ "serbia": {
+ relative_radius: 1,
+ },
"slovakia": {
relative_radius: 1,
},
@@ -89,7 +122,13 @@ var country_properties = {
"sweden": {
relative_radius: 1,
},
- "switzerland": {
+ "switzerland-de": {
+ relative_radius: 1,
+ },
+ "switzerland-fr": {
+ relative_radius: 1,
+ },
+ "turkey": {
relative_radius: 1,
},
"uk": {
@@ -98,7 +137,7 @@ var country_properties = {
"ukraine": {
relative_radius: 1,
},
-}
+};
var stations = {
"andorra": [
@@ -133,12 +172,14 @@ var stations = {
url: "http://37.59.18.212:8000/;"
}
],
- "belgium": [
+ "belgium-nl": [
{
name: "VRT Radio 1",
logo: "https://www.muntpunt.be/sites/default/files/Activiteiten/logo_radio1_NIEUW_0.gif",
url: "http://mp3.streampower.be/radio1-high"
},
+ ],
+ "belgium-fr": [
{
name: "RTBF La Première",
logo: "https://ssl-www.static.rtbf.be/radio/radio/images/logo/header/lapremiere.png",
@@ -275,7 +316,12 @@ var stations = {
name: "Radio 2",
logo: "https://www.mp3streams.nl/images/zenderlogo/radio2.png",
url: "http://icecast.omroep.nl/radio2-bb-mp3"
- }
+ },
+ {
+ name: "Radio 538",
+ logo: "http://www.radiodigitaal.nl/channelimages/RADIO_538.png",
+ url: "http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3",
+ },
],
"norway": [
{
@@ -343,7 +389,14 @@ var stations = {
url: "http://http-live.sr.se/p2-mp3-192"
},
],
- "switzerland": [
+ "switzerland-de": [
+ {
+ name: "Radio SRF 1",
+ logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Radio_SRF_1.svg/2000px-Radio_SRF_1.svg.png",
+ url: "http://stream.srg-ssr.ch/m/drs1/mp3_128"
+ },
+ ],
+ "switzerland-fr": [
{
name: "Radio SRF 1",
logo: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Radio_SRF_1.svg/2000px-Radio_SRF_1.svg.png",
@@ -369,4 +422,7 @@ var stations = {
url: "http://nrcu.gov.ua:8000/ur2-mp3"
},
]
-};
\ No newline at end of file
+};
+
+stations["belgium"] = stations["belgium-nl"].concat(stations["belgium-fr"]);
+stations["switzerland"] = stations["switzerland-de"].concat(stations["switzerland-fr"]);
\ No newline at end of file