projects-jenz/RaceTimer/webproject/target/racetimer_web-1.0-SNAPSHOT/WEB-INF/Content.jsp
2019-03-02 15:17:41 +01:00

260 lines
14 KiB
Plaintext

<%--
Document : index
Created on : 21-10-2018, 14:28:06
Author : install1
--%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="FunctionLayer.RecentTimes"%>
<%@page import="java.util.Collections"%>
<%@page import="FunctionLayer.UserBanners"%>
<%@page import="FunctionLayer.MapBoard"%>
<%@page import="FunctionLayer.Users"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Maptimers</title>
</head>
<body>
<% String AdminName = (String) session.getAttribute("AdminName");
if (AdminName != null) {
%>
<h1>You are logged in as: <%=AdminName%> </h1>
<%
}
%>
<button type="button" class="btn btn-warning" onclick="AdminLogin()">Admin login</button>
<div class="row">
<div class="col-sm-12">
<div class="text-center">
<button type="button" class="btn btn-primary" onclick="DisplayMaps()">Maps</button>
<button type="button" class="btn btn-success" onclick="DisplayPlayers()">Players</button>
<button type="button" class="btn btn-secondary" onclick="RecentTimes()">Recent Times</button>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="text-center">
<div id="MapDiv">
<%
List<MapBoard> AllMapColoumns = (List<MapBoard>) session.getAttribute("MapBoard");
if (AllMapColoumns != null) {
for (int i = 0; i < AllMapColoumns.size(); i++) {
%>
<button id="<%=AllMapColoumns.get(i).getMapName()%>" class="list-group-item list-group-item-action" onclick="GetMapPage(this.id);" style="border: none" > <span href="#" class="fake-link" ><%out.print(AllMapColoumns.get(i).getMapName());%></span>
</button>
<%
}
} else { %>
<li class="list-group-item disabled">No map Entries, call jenz!</li>
<% } %>
</div>
<div id="RecentDiv">
<%
List<RecentTimes> recentTimes = (List<RecentTimes>) session.getAttribute("RecentTimes");
if (recentTimes != null) {
for (int i = 0; i < recentTimes.size(); i++) {
%>
<button class="list-group-item list-group-item-action" id="<%=recentTimes.get(i).getUser().getSteamID()%>" style="border: none" onclick="GetplayerPage(this.id);">
<span href="#" class="fake-link" >
<div>
<%out.print(recentTimes.get(i).getUser().getSteamID());%>
</div>
<div>
<%out.print(recentTimes.get(i).getUser().getName());%>
</div>
<div>
<img src="<%out.println(recentTimes.get(i).getUser().getAvatar()); %>">
</div>
<div>
<%out.print(recentTimes.get(i).getMYSQLStage());%>
</div>
<div>
<%
float fdefault = recentTimes.get(i).getImprovedTime();
int MinuteAdjusterImproved = (int) fdefault;
float secondsAdjusterImproved = Float.valueOf(String.format("%.2f", (fdefault - MinuteAdjusterImproved) * 100));
out.print("\nImproved by: 0" + MinuteAdjusterImproved + ":"
+ secondsAdjusterImproved);
%>
</div>
<div>
<%
//00:56.4
float newAdjustedTime = (((int) recentTimes.get(i).getMYSQLOldTime()) * 60
+ ((recentTimes.get(i).getMYSQLOldTime() - (int) recentTimes.get(i).getMYSQLOldTime()) * 100))
- (MinuteAdjusterImproved * 60 + secondsAdjusterImproved);
int newMinuteTime = (int) newAdjustedTime / 60;
float SecondsAdjusterNewTime = Float.valueOf(String.format("%.2f", newAdjustedTime - (newMinuteTime * 60)));
out.print("New Time: 0" + newMinuteTime + ":" + SecondsAdjusterNewTime);
%>
</div>
</span>
</button>
<% }
}
%>
</div>
</div>
</div>
</div>
<div id="PlayerDiv">
<% List<UserBanners> UB = (List<UserBanners>) session.getAttribute("UserBanners");
List<Users> PlayerLeaderBoard = (List<Users>) session.getAttribute("LeaderBoard");
int UBIndex = 0;
if (PlayerLeaderBoard != null && UB != null) {
// out.println("UB size: " + UB.size());
for (int j = 0; j < PlayerLeaderBoard.size(); j++) {
%>
<button class="list-group-item list-group-item-action" id="<%=PlayerLeaderBoard.get(j).getSteamID()%>" style="border: none" onclick="GetplayerPage(this.id);"><span href="#" class="fake-link" >
<div class="container" id="Players">
<div class="row d-flex justify-content-between">
<div>
<%out.print(PlayerLeaderBoard.get(j).getSteamID());%>
</div>
<div>
<%out.print(PlayerLeaderBoard.get(j).getName());%>
</div>
<div>
<%out.print("Rank: " + PlayerLeaderBoard.get(j).getRank());%>
</div>
<div>
<%out.print("Points: " + PlayerLeaderBoard.get(j).getPlayerPoints());%>
</div>
<div>
<%out.print("Times: " + PlayerLeaderBoard.get(j).getTimes());%>
</div>
</div>
<div class="row d-flex justify-content-between">
<div>
<div class="d-flex justify-content-between" id="Players">
<%
String img = "";
if (UBIndex < UB.size() && UB.get(UBIndex).getUser().equals(PlayerLeaderBoard.get(j))) {
for (int i = 0; i < UB.get(UBIndex).getUrlBanners().size(); i++) {
switch (UB.get(UBIndex).getUrlBanners().get(i)) {
case 25: {
img = "https://unloze.com/images/badges/Event-Manager.png";
break;
}
case 19: {
img = "https://unloze.com/images/badges/Discord-Manager.png";
break;
}
case 15: {
img = "https://unloze.com/images/badges/Event-Winner.png";
break;
}
case 12: {
img = "https://unloze.com/images/badges/VIP.png";
break;
}
case 11: {
img = "https://unloze.com/images/badges/Global-Admin.png";
break;
}
case 10: {
img = "https://unloze.com/images/badges/Leader.png";
break;
}
case 8: {
img = "https://unloze.com/images/badges/Tech-Staff.png";
break;
}
case 7: {
img = "https://unloze.com/images/badges/Admin.png";
break;
}
case 6: {
img = "https://unloze.com/images/badges/Mapper.png";
break;
}
}
%>
<div >
<img src="<%out.println(img); %>">
</div>
<%
}
UBIndex++;
}
%>
</div>
</div>
<div class="float-right" >
<img src="<%out.println(PlayerLeaderBoard.get(j).getAvatar()); %>">
</div>
</div>
</div>
</span> </button>
<% }
} else {
%>
<li class="list-group-item disabled">No Player Entries</li>
<% }%>
</div>
<SCRIPT LANGUAGE="JavaScript">
function GetMapPage(count)
{
document.getElementById("mapindexes").value = count;
document.getElementById('1111').submit();
}
function GetplayerPage(count)
{
document.getElementById("playerindex").value = count;
document.getElementById('1112').submit();
}
function AdminLogin()
{
document.getElementById('1113').submit();
}
$('#PlayerDiv').hide();
function DisplayMaps() {
$('#PlayerDiv').hide();
$('#RecentDiv').hide();
$('#MapDiv').show();
}
function DisplayPlayers()
{
$('#PlayerDiv').show();
$('#MapDiv').hide();
$('#RecentDiv').hide();
}
function RecentTimes()
{
$('#PlayerDiv').hide();
$('#MapDiv').hide();
$('#RecentDiv').show();
}
</SCRIPT>
<form id="1111" name="mapfnfo" action="FrontController" method="POST">
<input type="hidden" name="command" value="mapfnfo">
<input type="hidden" name="mapname" id='mapindexes' value=''>
</form>
<form id="1112" name="playerinfo" action="FrontController" method="POST">
<input type="hidden" name="command" value="playerinfo">
<input type="hidden" name="player" id='playerindex' value=''>
</form>
<form id="1113" name="adminLogin" action="FrontController" method="POST">
<input type="hidden" name="command" value="adminLogin">
</form>
<style>
.fake-link {
color: #007bff;
text-decoration: underline;
cursor: pointer;
}
</style>
</body>
</html>