This repository was archived by the owner on Aug 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloading.js
More file actions
77 lines (72 loc) · 2.58 KB
/
Copy pathloading.js
File metadata and controls
77 lines (72 loc) · 2.58 KB
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
var mapName = "";
var gameModes = ["slayer","ctf","slayer","oddball","koth","forge","vip","juggernaut","territories","assault","infection"];
function updateProgress(progress) {
$("#progressbar").attr('value', progress);
}
dew.on("show", function (event) {
mapName = event.data.map || "";
if (mapName != "mainmenu") {
$("body").css("background-image","url('maps/"+mapName+".png')");
dew.getMapVariantInfo(function (info) {
$("#title").text(info.name);
$("#desc").text(info.description);
});
dew.getGameVariantInfo(function (info) {
$("#gametypeicon").attr("src","gametypes/"+gameModes[info.mode]+".png");
$("#gametype").text(info.name);
if(info.rounds > 0){
$("#gamerounds").text(info.rounds);
} else {
$("#gamerounds").text("Unlimited");
}
if(info.scoreToWin > -1){
$("#gamescore").text(info.scoreToWin);
} else {
$("#gamescore").text("Unlimited");
}
if(info.timeLimit > 0){
$("#timelimit").text(timeConvert(info.timeLimit));
} else {
$("#timelimit").text("Unlimited");
}
});
dew.command("Server.NameClient", { internal: true }, function (name) {
$(".serverName").text(name);
});
dew.command("Server.MessageClient", { internal: true }, function (message) {
if(message.length > 0){
$(".serverMessage").show();
$(".serverMessage").html(textWithNewLines(message));
} else {
$(".serverMessage").hide();
}
});
$(".header").show();
$(".footer").show();
} else {
$("body").css("background-image","url('background.png')");
$(".serverMessage").hide();
$(".header").hide();
$(".footer").hide();
}
updateProgress(0);
});
dew.on("loadprogress", function (event) {
var progress = event.data.currentBytes / event.data.totalBytes * 100;
updateProgress(progress);
});
function textWithNewLines(text) {
var htmls = [];
var lines = text.split("\\n");
var tmpDiv = jQuery(document.createElement('div'));
for (var i = 0 ; i < lines.length ; i++) {
htmls.push(tmpDiv.text(lines[i].trim()).html());
}
return htmls.join("<br>");
}
function timeConvert(mins){
var hours = Math.trunc(mins/60);
var minutes = mins % 60;
if (minutes <= 9) { minutes = "0" + minutes; };
return hours +":"+ minutes;
}