-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalerts.js
77 lines (63 loc) · 2.65 KB
/
alerts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* jslint browser: true, white: true, sloppy: true, maxerr: 1000 */
/* global $ */
/**
* Alerts built on the idea by lgal
* see http://stackoverflow.com/a/33662720/2842348
* License MIT
*/
// TODO remove jquery
var alerts = ( function () {
'use strict';
var _strings = [
"You cannot delete features you did not create", // 0
"Sorry, something went wrong with the server",
"The request was not handled properly by the server",
"Please log in to do that",
"Something went wrong, HTTP error ",
"Something went wrong while fetching the data", // 5
"Failed to remove this feature",
"Feature deleted successfully",
"You are not on the players list and can't look at this data",
"You cannot edit feature created by others",
"Sorry, something went wrong", // 10
"The editing system isn't currently functional",
"Failed to login anonymously. Reload the page and try again",
"You are now logged in",
"Drawing on mobile is still in development, expect issues",
"Zoom in closer to create features", // 15
"Couldn't find your position",
'Account successfully deleted',
'You cannot delete soft accounts',
'Sorry. Key not recognized',
'Welcome back, anonymous', // 20
'Session expired. Please log in again',
'You are logged out',
'No active session',
'Failed to log in',
'Map feature saved successfully', // 25
'Cleaning event saved successfully',
'Litter saved successfully',
'Area saved successfully',
'No data in the current area',
'Fill in all the required fields', // 30
'Zoom in closer to do that',
'Garbagepla.net uses cookies. By using this website you agree to our <a href="#privacy-policy" class="alert-link sidebar-link"> use of cookies </a>.',
'Layer not found on the map',
'Please provide a link'
];
function showAlert(errorCode, errorType, closeDelay, errorText) {
// default to alert-info
if ( !errorType || typeof errorType === 'undefined' ) {
errorType = "info";
}
var errorMessage = errorText || _strings[errorCode];
var alertMessage = $('<div class="alert alert-' + errorType + ' fade in">');
alertMessage.append(errorMessage);
$(".alert-container").prepend(alertMessage);
// if closeDelay was passed - set a timeout to close the alert
if ( closeDelay ) {
window.setTimeout(function () { alertMessage.alert("close"); }, closeDelay);
}
}
return { showAlert : showAlert }
}());