projects-jenz/RaceTimer/webproject/src/main/webapp/WEB-INF/MapInfo.jsp
2019-03-02 15:17:41 +01:00

206 lines
11 KiB
Plaintext

<%--
Document : Mapdetails
Created on : 23-10-2018, 14:12:31
Author : install1
--%>
<%@page import="FunctionLayer.UserBanners"%>
<%@page import="FunctionLayer.MapBoard"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="java.util.List"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
<%@page import="FunctionLayer.Users"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LeaderBoards</title>
</head>
<body>
<% String AdminName = (String) request.getSession().getAttribute("AdminName");
if (AdminName != null) {
%>
<h1>You are logged in as: <%=AdminName%> </h1>
<%
}
%>
<div class="container">
<div class="row">
<div class="col-sm">
<div align="center">
<button type="button" class="btn btn-info" onclick="GetFrontPage()">Overview</button>
</div>
<br>
<br>
<%
List<UserBanners> UB = (List<UserBanners>) session.getAttribute("UserBanners");
List<MapBoard> mapBoard = (List<MapBoard>) session.getAttribute("MapBoard");
//might not find mapname as parameter
int index = (Integer) request.getAttribute("SpecificMapIndex");
String map = (String) request.getParameter("mapname");
String VerifyAdmins = session.getAttribute("VerifyAdmin") == null ? "0" : String.valueOf(session.getAttribute("VerifyAdmin"));
int VerifyAdmin = Integer.valueOf(VerifyAdmins);
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(1);
out.println("<H2 align=\"center\">" + map + "</h2>");
if (mapBoard != null) {
for (int i = 0; i < mapBoard.get(index).getMapvalues().size(); i++) {
%>
<button id="<%=mapBoard.get(index).getMapvalues().get(i).getUser().getSteamID()%>" style="border: none" onclick="GetplayerPage(this.id);"
class="list-group-item list-group-item-action" >
<span href="#" class="fake-link" >
<div class="row d-flex justify-content-between">
<div> <%out.println(mapBoard.get(index).getMapvalues().get(i).getUser().getSteamID());%></div>
<div> <%out.println(mapBoard.get(index).getMapvalues().get(i).getUser().getName());%></div>
<div><%out.println("Rank: " + mapBoard.get(index).getMapvalues().get(i).getUser().getRank());%></div>
<div>
<%out.println("Points: " + mapBoard.get(index).getMapvalues().get(i).getUser().getPlayerPoints());%>
</div>
<div>
<%out.println("Times: " + mapBoard.get(index).getMapvalues().get(i).getUser().getTimes());%>
</div>
<div>
<%out.println("Map Position: " + (i + 1)); %>
</div>
<div> <%out.println("Time: " + "0" + (long) (mapBoard.get(index).getMapvalues().get(i).getTime())
+ ":" + (df.format((mapBoard.get(index).getMapvalues().get(i).getTime() - (long) (mapBoard.get(index).getMapvalues().get(i).getTime())) * 100)));%>
</div>
<div>
<%out.println("Map Points: " + mapBoard.get(index).getMapvalues().get(i).getMapPoints() + "/100");%>
</div>
</div>
<div align="center">
<img src="<%out.println(mapBoard.get(index).getMapvalues().get(i).getUser().getAvatar()); %>">
</div>
<%
String img = ""; //userlist.indexOf(UserCacheTimeAmount1.entrySet().stream().filter(e -> e.getValue().getSteamID().equals(RTSteamID)).findFirst().get().getValue());
Users user = mapBoard.get(index).getMapvalues().get(i).getUser();
int mbIndex = -1;
for (int j = 0; j < UB.size(); j++) {
if (UB.get(j).getUser().equals(user)) {
mbIndex = j;
break;
}
}
if (mbIndex > 0) {
for (int j = 0; j < UB.get(mbIndex).getUrlBanners().size(); j++) {
switch (UB.get(mbIndex).getUrlBanners().get(j)) {
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 align="center">
<div >
<img src="<%out.println(img);%>">
</div>
</div>
<% }
}
%>
</span> </button>
<%
if (VerifyAdmin > 0) {
%>
<div align="center">
<button value="<%out.print(mapBoard.get(index).getMapName());%>" id="<%=mapBoard.get(index).getMapvalues().get(i).getUser().getSteamID()%>" style="border: none" onclick="removeentry(this.id, this.value);" >
<span href="#" class="fake-link" >
<div class="d-flex justify-content-between">
<div>
<%out.println("Delete Entry");%>
</div>
</div>
</span> </button>
</div>
<%
}
%>
<br>
<br>
<% }
}
%>
</div>
</div>
</div>
<style>
.fake-link {
color: #007bff;
text-decoration: underline;
cursor: pointer;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
function GetplayerPage(count)
{
document.getElementById("playerindex").value = count;
document.getElementById('1111').submit();
}
function GetFrontPage()
{
document.getElementById('1112').submit();
}
function removeentry(steamID, map)
{
document.getElementById("PlayerRelatedMap").value = map;
document.getElementById("SteamID").value = steamID;
document.getElementById('1113').submit();
}
</SCRIPT>
<form id="1111" name="playerinfo" action="FrontController" method="POST">
<input type="hidden" name="command" value="playerinfo">
<input type="hidden" name="player" id='playerindex' value=''>
</form>
<form id="1112" name="SessionAttributeHandler" action="FrontController" method="POST">
<input type="hidden" name="command" value="SessionAttributeHandler">
</form>
<form id="1113" name="DeleteEntry" action="FrontController" method="POST">
<input type="hidden" name="command" value="DeleteEntry">
<input type="hidden" name="DeleteIndexSteamID" id='SteamID' value=''>
<input type="hidden" name="PlayerRelatedMap" id='PlayerRelatedMap' value=''>
</form>
</body>
</html>