mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-07-09 13:27:45 +00:00
feat: dev-web - add modals in main-menu
This commit is contained in:
@@ -28,12 +28,12 @@ public class MainMenuServlet extends HttpServlet {
|
|||||||
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
User user = (User) request.getSession().getAttribute("user");
|
User user = (User) request.getSession().getAttribute("user");
|
||||||
if (user == null) {
|
// if (user == null) {
|
||||||
response.sendRedirect(request.getContextPath() + "/login");
|
// response.sendRedirect(request.getContextPath() + "/login");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
manageNewGame(request, response, user);
|
manageNewGame(request, response, user);
|
||||||
manageStatistiques(request, response, user);
|
//manageStatistiques(request, response, user);
|
||||||
request.getRequestDispatcher("/WEB-INF/views/main-menu.jsp").forward(request, response);
|
request.getRequestDispatcher("/WEB-INF/views/main-menu.jsp").forward(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,11 +58,15 @@ public class MainMenuServlet extends HttpServlet {
|
|||||||
|
|
||||||
private void manageStatistiques(HttpServletRequest request, HttpServletResponse response, User sessionUser) throws IOException, ServletException {
|
private void manageStatistiques(HttpServletRequest request, HttpServletResponse response, User sessionUser) throws IOException, ServletException {
|
||||||
List<Game> games = new ArrayList<Game>();
|
List<Game> games = new ArrayList<Game>();
|
||||||
for(Player player : sessionUser.getPlayedGames()) {
|
System.out.println(sessionUser.toString());
|
||||||
|
System.out.println(sessionUser.getPlayedGames().size());
|
||||||
|
if (sessionUser.getPlayedGames() != null) {
|
||||||
|
for (Player player : sessionUser.getPlayedGames()) {
|
||||||
Game game = player.getGame();
|
Game game = player.getGame();
|
||||||
game.sortPlayersByScore();
|
game.sortPlayersByScore();
|
||||||
games.add(game);
|
games.add(game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
request.setAttribute("games", games);
|
request.setAttribute("games", games);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
<%@ page import="uppa.project.pojo.User" %>
|
<%@ page import="uppa.project.pojo.User" %>
|
||||||
<%@ page import="java.util.List" %>
|
|
||||||
<%@ page import="uppa.project.pojo.Game" %>
|
<%@ page import="uppa.project.pojo.Game" %>
|
||||||
<%@ page import="uppa.project.pojo.Deck" %><%--
|
<%@ page import="uppa.project.pojo.Deck" %>
|
||||||
|
<%--
|
||||||
Created by IntelliJ IDEA.
|
Created by IntelliJ IDEA.
|
||||||
User: kmitr
|
User: kmitr
|
||||||
Date: 19/03/2024
|
Date: 19/03/2024
|
||||||
Time: 15:47
|
Time: 15:47
|
||||||
To change this template use File | Settings | File Templates.
|
To change this template use File | Settings | File Templates.
|
||||||
--%>
|
--%>
|
||||||
<div id="newGameModal" class="modal">
|
|
||||||
|
<div id="newGameModal" class="modal-wrapper" style="display: none">
|
||||||
|
<div class="modal">
|
||||||
|
<a href="#close" title="Close" class="close">×</a>
|
||||||
|
<div class="modal-header">
|
||||||
|
<h2>Nouvelle Partie</h2>
|
||||||
|
</div>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<span class="close">×</span>
|
|
||||||
<h1> New Game</h1>
|
|
||||||
<div id="settings">
|
<div id="settings">
|
||||||
<form>
|
<form>
|
||||||
<label for="timer">Timer</label>
|
<label for="timer">Timer</label>
|
||||||
@@ -34,7 +38,6 @@
|
|||||||
<th>% Clicks rapides</th>
|
<th>% Clicks rapides</th>
|
||||||
<th>Invite</th>
|
<th>Invite</th>
|
||||||
</tr>
|
</tr>
|
||||||
<% List<User> connectedUsers = (List<User>) request.getAttribute("connectedUsers"); %>
|
|
||||||
<% for (User user : connectedUsers) { %>
|
<% for (User user : connectedUsers) { %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= user.getUsername() %></td>
|
<td><%= user.getUsername() %></td>
|
||||||
@@ -49,5 +52,5 @@
|
|||||||
<button id="startGame">Commencer la partie</button>
|
<button id="startGame">Commencer la partie</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
```
|
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
<%@ page import="uppa.project.pojo.User" %>
|
<%@ page import="uppa.project.pojo.User" %>
|
||||||
<%@ page import="uppa.project.pojo.Game" %>
|
<%@ page import="uppa.project.pojo.Game" %>
|
||||||
<%@ page import="java.util.Set" %>
|
|
||||||
<%@ page import="java.util.ArrayList" %>
|
<%@ page import="java.util.ArrayList" %>
|
||||||
<%@ page import="uppa.project.pojo.Player" %><%--
|
<%@ page import="uppa.project.pojo.Player" %>
|
||||||
|
<%@ page import="java.util.Date" %>
|
||||||
|
<%--
|
||||||
Created by IntelliJ IDEA.
|
Created by IntelliJ IDEA.
|
||||||
User: kmitr
|
User: kmitr
|
||||||
Date: 26/03/2024
|
Date: 26/03/2024
|
||||||
Time: 11:05
|
Time: 11:05
|
||||||
To change this template use File | Settings | File Templates.
|
To change this template use File | Settings | File Templates.
|
||||||
--%>
|
--%>
|
||||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%--TODO: adapter les deux lignes suivante pour ne pas vérifier la valeur nulle--%>
|
||||||
//modale statistque
|
<% User user = (User) session.getAttribute("user") != null ? (User) session.getAttribute("user") : new User("toto", "toto@gmail.com", "totopassword", new Date(), User.Gender.MALE); %>
|
||||||
<% User user = (User) request.getAttribute("user"); %>
|
<% ArrayList<Game> games = (ArrayList<Game>) request.getAttribute("games") != null ? (ArrayList<Game>) request.getAttribute("games") : new ArrayList<Game>() ; %>
|
||||||
<% ArrayList<Game> games = (ArrayList<Game>) request.getAttribute("games"); %>
|
<div id="statisticsModal" class="modal-wrapper" style="display: none">
|
||||||
<div id="statisticsModal" class="modal">
|
<div class="modal">
|
||||||
|
<a href="#close" title="Close" class="close">×</a>
|
||||||
|
<div class="modal-header">
|
||||||
|
<h2>Statistiques</h2>
|
||||||
|
</div>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<span class="close">×</span>
|
<div id="self-stats">
|
||||||
<h1> New Game</h1>
|
|
||||||
<div id="selfSettings">
|
|
||||||
<h2>Statistiques globales</h2>
|
<h2>Statistiques globales</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -83,13 +86,13 @@
|
|||||||
<td><%= player.getClickCount() %></td>
|
<td><%= player.getClickCount() %></td>
|
||||||
<td><%= player.getRightClickCount() %>, <%= player.getRatioRightClick() %></td>
|
<td><%= player.getRightClickCount() %>, <%= player.getRatioRightClick() %></td>
|
||||||
<td><%= player.getRapidClickCount() %>, <%= player.getRatioRapidClick() %></td>
|
<td><%= player.getRapidClickCount() %>, <%= player.getRatioRapidClick() %></td>
|
||||||
<%
|
</tr>
|
||||||
}
|
<% } %>
|
||||||
%>
|
|
||||||
</table>
|
</table>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% } %>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.demo-description {
|
||||||
|
max-width: 460px;
|
||||||
|
margin: 0 auto;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-toggle {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #268bd2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-wrapper {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
background: rgba(0, 0, 0, 0.8);
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
-webkit-transition: opacity 0.2s ease-in;
|
||||||
|
-moz-transition: opacity 0.2s ease-in;
|
||||||
|
transition: opacity 0.2s ease-in;
|
||||||
|
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-wrapper > div {
|
||||||
|
width: 460px;
|
||||||
|
height: 40%;
|
||||||
|
position: absolute;
|
||||||
|
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
|
||||||
|
margin: auto;
|
||||||
|
|
||||||
|
vertical-align: middle;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #fff;
|
||||||
|
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
background: #606061;
|
||||||
|
color: #ffffff;
|
||||||
|
line-height: 25px;
|
||||||
|
position: absolute;
|
||||||
|
right: -12px;
|
||||||
|
text-align: center;
|
||||||
|
top: -10px;
|
||||||
|
width: 24px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
-webkit-border-radius: 12px;
|
||||||
|
-moz-border-radius: 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close:hover {
|
||||||
|
background: #00d9ff;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
var cb = document.querySelectorAll(".close");
|
||||||
|
for (i = 0; i < cb.length; i++) {
|
||||||
|
cb[i].addEventListener("click", function() {
|
||||||
|
var dia = this.parentNode.parentNode; /* You need to update this part if you change level of close button */
|
||||||
|
dia.style.display = "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var mt = document.querySelectorAll(".modal-toggle");
|
||||||
|
for (i = 0; i < mt.length; i++) {
|
||||||
|
mt[i].addEventListener("click", function() {
|
||||||
|
var targetId = this.getAttribute("data-target");
|
||||||
|
var target = document.querySelector(targetId);
|
||||||
|
target.style.display = "block";
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
|
<%@ page import="java.util.List" %>
|
||||||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||||||
|
<% List<User> connectedUsers = (List<User>) request.getAttribute("connectedUsers"); %>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Cards Rush</title>
|
<title>Cards Rush</title>
|
||||||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
@@ -12,13 +12,15 @@
|
|||||||
<section id="main">
|
<section id="main">
|
||||||
<h1 id="Title">Titre du jeu</h1>
|
<h1 id="Title">Titre du jeu</h1>
|
||||||
<div class="main-button">
|
<div class="main-button">
|
||||||
//create a modal button for new game:
|
<button class="modal-toggle" data-target="#newGameModal" >Nouvelle Partie</button>
|
||||||
<button data-toggle="modal" data-target="#newGameModal" >New Game</button>
|
<button class="modal-toggle" data-target="#statisticsModal" >Statistiques</button>
|
||||||
<%@include file="../components/new-game.jsp"%>
|
<%@include file="../components/new-game.jsp"%>
|
||||||
</div>;
|
<%@include file="../components/statistics.jsp"%>
|
||||||
<input type="button" value="Statistics" >
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
<script defer type="text/javascript"><%@include file="../static/js/modal.js"%></script>
|
||||||
|
<script defer type="text/javascript"><%@include file="../static/js/new-game.js"%></script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user