Skip to content

Commit 69a9d96

Browse files
committed
refactor: update various files to use new alerts
Socket errors are now displayed in a alert (if debug is abled). If the interface gets an error when trying to get blips, it's shown in an error.
1 parent 0cb72c5 commit 69a9d96

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

js/src/alerter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ function createAlert(type, title, message, fadeOut){
9090

9191
$("#alert-holder").append(html);
9292

93-
if(fadeOut){
93+
if(fadeOut != false){
9494
// Auto-close the alert after 10 seconds
95-
$("#"+ id).slideDown("slow").delay(10000).fadeOut(1000, function(){
95+
$("#"+ id).slideDown("slow").delay(fadeOut * 1000).fadeOut(1000, function(){
9696
$(this).remove();
9797
});
9898
}

js/src/controls.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ function toggleBlips(){
2222

2323
for(var spriteId in _blips){
2424
var blipArray = _blips[spriteId];
25-
25+
2626
for(var i in blipArray){
2727
var blip = blipArray[i];
2828

2929
var obj = new MarkerObject(blip.name, new Coordinates(blip.pos.x, blip.pos.y, blip.pos.z), MarkerTypes[blip.type], blip.description, "", "");
3030
blip.markerId = createMarker(false, false, obj, "") - 1;
31-
3231
}
3332
}
3433

js/src/init.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function createBlip(blip){
9393
}
9494

9595
blip.markerId = createMarker(false, false, obj, "") - 1;
96-
96+
9797
_blips[blip.type].push(blip);
9898
_blipCount++;
9999
}
@@ -102,6 +102,7 @@ function blipSuccess(data, textStatus){
102102
if (data.error){
103103
//Do something about the error i guess.
104104
console.error("Error: " + data.error);
105+
createAlert("warning", "Error getting blips!", data.error);
105106
return;
106107
}
107108

@@ -130,7 +131,7 @@ function blipSuccess(data, textStatus){
130131
}
131132

132133
function blipError( textStatus, errorThrown){
133-
console.error("Error \"" + textStatus + "\": " + errorThrown);
134+
console.error("Error \"" + JSON.stringify(textStatus) + "\": " + errorThrown);
134135
}
135136

136137
function initBlips(){

js/src/socket.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function onOpen(e) {
5656
function sorter(plr1, plr2){
5757
var str1 = plr1["name"];
5858
var str2 = plr2["name"];
59-
59+
6060
return (str1 < str2) ? -1 : (str1 > str2) ? 1 : 0;
6161
}
6262

@@ -138,6 +138,9 @@ function onError(e) {
138138

139139
//$("#socket_error").text(reason);
140140
console.error("Socket error: " + reason);
141+
if(_SETTINGS_debug){
142+
createAlert("warning", "Socket error", ["There was an error with the socket connnection", reason], 2);
143+
}
141144
}
142145

143146
function onClose(e) {

0 commit comments

Comments
 (0)