Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Commit 618bc39

Browse files
committed
refactor: update files to use new config.json file
1 parent 9b4bf83 commit 618bc39

File tree

7 files changed

+159
-269
lines changed

7 files changed

+159
-269
lines changed

index.php

Lines changed: 9 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030

3131
Update::getCurrentVersion();
3232

33-
$config = Config::getConfig();
33+
$debug = true;
34+
3435
$parser = ParamParser::getParser();
3536

3637
if(ISSET($_GET["server"])){
38+
/*
3739
$name = $_GET["server"];
3840
3941
if(array_key_exists($name, Config::$servers)){
@@ -42,32 +44,13 @@
4244
$name = key(Config::$servers); // get the first server in array
4345
$srv = Config::$servers[$name];
4446
}
47+
*/
4548

4649
unset($_GET["server"]);
4750
}else{
4851
$name = key(Config::$servers); // get the first server in array
4952
$srv = Config::$servers[$name];
5053
}
51-
52-
// Update the config for the new server
53-
if(array_key_exists("ip", $srv)){
54-
$config->fivemIP = $srv["ip"];
55-
}
56-
if(array_key_exists("fivemPort", $srv)){
57-
$config->fivemPort = $srv["fivemPort"];
58-
}
59-
if(array_key_exists("socketPort", $srv)){
60-
$config->socketPort = $srv["socketPort"];
61-
}
62-
if(array_key_exists("liveMapName", $srv)){
63-
$config->liveMapName = $srv["liveMapName"];
64-
}
65-
if(array_key_exists("reverseProxy", $srv)){
66-
$config->reverseProxy = $srv["reverseProxy"];
67-
}
68-
69-
$config->currentServer = $name;
70-
7154
?>
7255

7356
<html>
@@ -104,7 +87,7 @@
10487
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
10588
<?php
10689
// Print the CSS stuff for the webapp. This will either print the minfied version or, links to the CSS filees
107-
Minifier::printCss($config->debug);
90+
Minifier::printCss($debug);
10891
?>
10992
<link type="text/css" rel="stylesheet" href="style/fontawesome-all.min.css" />
11093

@@ -115,50 +98,12 @@
11598
<script src="js/bootstrap.bundle.min.js"></script>
11699
<script src="js/bootstrap.min.js"></script>
117100
<script src="js/bootstrap-notify.min.js"></script>
118-
101+
119102
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
120103
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js" integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==" crossorigin=""></script>
121104

122-
123-
<script>
124-
125-
///////////////////////////////////////////////////////////////////////////
126-
// PLEASE CHNAGE THE VAUES INSIDE THE CONFIG FILE
127-
///////////////////////////////////////////////////////////////////////////
128-
var _MAP_tileURL = "<?php echo $config->mapTileUrl; ?>";
129-
var _MAP_iconURL = "<?php echo $config->mapIconUrl; ?>";
130-
131-
var _MAP_currentUri = "<?php echo $_SERVER["REQUEST_URI"]; ?>";
132-
133-
// Sets whether it should showSets whether it should show Atlas map (WARNING: REQUIRES "atlas" TILE DIRECTORY)
134-
var _MAP_atlasMap = <?php echo json_encode($config->atlasEnabled); ?>;
135-
136-
// Sets whether it should show Satellite map (WARNING: REQUIRES "satellite" TILE DIRECTORY)
137-
var _MAP_satelliteMap = <?php echo json_encode($config->satelliteEnabled); ?>;
138-
139-
// Sets whether it should show Road map (WARNING: REQUIRES "road" TILE DIRECTORY)
140-
var _MAP_roadMap = <?php echo json_encode($config->roadEnabled); ?>;
141-
142-
// Sets whether it should show UV Invert map (WARNING: REQUIRES "uv-invert" TILE DIRECTORY)
143-
var _MAP_UVInvMap = <?php echo json_encode($config->uvInveredEnabled); ?>;
144-
145-
// Sets whether it should show Postcode map (WARNING: REQUIRES "postcode" TILE DIRECTORY)
146-
var _MAP_PostcodeMap = <?php echo json_encode($config->postcodeEnabled); ?>;
147-
148-
// Set to the IP of the GTA server running "live_map" and change the port to the
149-
// number that is set
150-
var _SETTINGS_socketUrl = "<?php echo $config->socketUrl(); ?>";
151-
152-
// Set to false if you don't want to show the player's identifiers (this may be their IP)
153-
var _SETTINGS_showIdentifiers = <?php echo json_encode($config->showIdentifiers); ?>;
154-
155-
// show debug information in the console
156-
var _SETTINGS_debug = <?php echo json_encode($config->debug); ?>;
157-
158-
var _SETTINGS_blipUrl = "<?php echo $config->blipUrl(); ?>";
159-
</script>
160105
<?php
161-
Minifier::printFirstJs($config->debug);
106+
Minifier::printFirstJs($debug);
162107
?>
163108

164109
</head>
@@ -182,14 +127,7 @@
182127
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
183128
Select a server
184129
</a>
185-
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
186-
<?php
187-
$srvs = Config::$servers;
188-
foreach ($srvs as $key => $value) {
189-
$uri = urlencode($key);
190-
echo "<a class='dropdown-item' href='?server=$uri'>$key</a>";
191-
}
192-
?>
130+
<div id="server_menu" class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
193131
</div>
194132
</li>
195133

@@ -252,7 +190,6 @@
252190

253191
<a class="list-group-item d-inline-block collapsed">Currently viewing:
254192
<p id="server_name" style="white-space: normal; color: #17A2B8">
255-
<?php echo $config->currentServer; ?>
256193
</p>
257194
</a>
258195

@@ -289,19 +226,14 @@
289226
</div>
290227

291228
<?php
292-
Minifier::printLastJs($config->debug);
229+
Minifier::printLastJs($debug);
293230
$parser->printJsForParams();
294231
if(!Update::latestVersion()){
295232
echo Update::alertJs();
296233
}
297234
?>
298235

299236
<script>
300-
var _MAP_currentMarker;
301-
var _MAP_markerStore;
302-
var _MAP_map;
303-
304-
305237
var greenIcon = L.icon({
306238
iconUrl: 'images/icons/debug.png',
307239

@@ -316,35 +248,6 @@
316248
iconAnchor: [23, 32/2], // point of the icon which will correspond to marker's location
317249
popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor
318250
});
319-
320-
function drawRect(sw, ne){
321-
return L.rectangle(new L.LatLngBounds(
322-
_MAP_map.unproject(sw, _MAP_map.getMaxZoom()),
323-
_MAP_map.unproject(ne, _MAP_map.getMaxZoom())
324-
)).addTo(_MAP_map);
325-
}
326-
327-
function drawRectAroundTile(x, y){
328-
var scaleMulti = 1024 / 256;
329-
330-
var currentTileXStart = 512 * x;
331-
var currentTileYStart = 512 * y;
332-
333-
var currentTileXEnd = currentTileXStart + (512);
334-
var currentTileYEnd = currentTileYStart + (512);
335-
336-
337-
return drawRect(
338-
[currentTileXStart * scaleMulti, currentTileYEnd * scaleMulti],
339-
[currentTileXEnd* scaleMulti, currentTileYStart* scaleMulti]
340-
)
341-
}
342-
343-
function debugMarker(){
344-
var ltln = convertToMap(0,0);
345-
L.marker(ltln, {icon: greenIcon, title:"Test"}).addTo(_MAP_map);
346-
_MAP_map.panTo(ltln);
347-
}
348251
</script>
349252
</body>
350253

js/src/alerter.js

Lines changed: 10 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -16,78 +16,6 @@
1616
// along with this program in the file "LICENSE". If not, see <http://www.gnu.org/licenses/>.
1717
// ************************************************************************** //
1818

19-
/*
20-
Creates an alert and displays it the user
21-
22-
type = Alert type, "info", "warning", "success", etc (see bootstrap alerts)
23-
title = Message to show in <strong> tags
24-
message = A string to show or, an array for multi-lined alert
25-
*/
26-
function createAlert_DEPRECATED(type, title, message, fadeOut){
27-
if(type == undefined || type == null){
28-
type = "info";
29-
}
30-
if(fadeOut == undefined || fadeOut == null){
31-
fadeOut = false;
32-
}
33-
34-
if(title == undefined || title == null){
35-
title = "Debug Alert";
36-
}
37-
38-
if(message == undefined || message == null){
39-
console.log("Please provide a message to the createAlert function. kthx.");
40-
return;
41-
}
42-
43-
var msg = "";
44-
var multiLine = false;
45-
if(typeof(message) == "object"){
46-
multiLine = true;
47-
var length = message.length;
48-
49-
for(var i = 0; i < length; i++){
50-
var msgHtml = "<p" + (i == length -1 ? " class=\"mb-0\"" : "") + ">";
51-
msgHtml += message[i];
52-
msgHtml += "</p>\n";
53-
54-
msg += msgHtml;
55-
}
56-
57-
}else if(typeof(message) == "string"){
58-
msg = message
59-
}else{
60-
console.log("Message must be an array or string, not a \"%s\"", typeof(message));
61-
return;
62-
}
63-
64-
// Create the alert
65-
// Set the type
66-
var id = makeid(5);
67-
var html = "<div id=\""+id+"\" class=\"alert alert-"+type+" alert-dismissible fade show\" role=\"alert\">";
68-
69-
//Add the button
70-
html += "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>";
71-
72-
if(multiLine){
73-
html += "<h4 class=\"alert-heading\">"+ title + "</h4>\n" + msg;
74-
}else{
75-
html += "<strong>" + title + "</strong>\n" + msg;
76-
}
77-
78-
// End the div
79-
html += "</div>";
80-
81-
$("#alert-holder").append(html);
82-
83-
if(fadeOut != false){
84-
// Auto-close the alert after 10 seconds
85-
$("#"+ id).slideDown("slow").delay(fadeOut * 1000).fadeOut(1000, function(){
86-
$(this).remove();
87-
});
88-
}
89-
}
90-
9119
function createAlert(data, settings){
9220
if(data == undefined || data == null){
9321
console.error("Data needs to be set");
@@ -109,34 +37,18 @@ function createAlert(data, settings){
10937
data.title = "<strong>Warning!</strong>";
11038
}
11139

112-
if(settings == undefined || settings == null || typeof(settings) != "object"){
113-
settings = {
114-
newsest_on_top: true,
115-
placement: {
116-
from: "bottom",
117-
align: "left"
118-
},
119-
delay: 10000,
120-
type: "warning"
121-
};
122-
}
123-
124-
// Defaults if they're not set
125-
if(typeof(settings.placement) == "undefined"){
126-
settings.placement = { from: "bottom", align: "left"};
127-
}
128-
if(typeof(settings.newsest_on_top) == "undefined"){
129-
settings.newsest_on_top = true;
130-
}
131-
if(typeof(settings.delay) == "undefined"){
132-
settings.delay = 5000;
133-
}
134-
if(typeof(settings.type) == "undefined"){
135-
settings.type = "warning";
136-
}
40+
settings = Object.assign(settings, {
41+
newsest_on_top: true,
42+
placement: {
43+
from: "bottom",
44+
align: "left"
45+
},
46+
delay: 10000,
47+
type: "warning"
48+
});
13749

13850
//console.log(JSON.stringify(data));
13951
//console.log(JSON.stringify(settings));
140-
52+
14153
return $.notify(data, settings);; // Incase I need this in future for shit like prgress bars or, if i need to update the alert
14254
}

js/src/controls.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ function toggleBlips(){
4747

4848
$(document).ready(function(){
4949
globalInit();
50-
connect();
5150

5251
$("#playerSelect").on("change", function(){
5352
if (this.value == ""){
@@ -67,6 +66,11 @@ $(document).ready(function(){
6766
}
6867
});
6968

69+
$("#server_menu").on("click", ".serverMenuItem", function(e){
70+
console.log($(this).text());
71+
changeServer($(this).text());
72+
});
73+
7074
$("#showBlips").click(function(e){
7175
e.preventDefault();
7276

0 commit comments

Comments
 (0)