feat: colorpicker
This commit is contained in:
parent
8850924f19
commit
a39d06a405
|
@ -92,7 +92,7 @@ public class PixelService {
|
|||
@Path("{id}/modify/")
|
||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
public void modify(@PathParam("id") Long id, @CookieParam("JSESSIONID") Cookie cookie,
|
||||
@FormParam("red") int red, @FormParam("green") int green, @FormParam("blue") int blue,
|
||||
@FormParam("red") int red, @FormParam("green") int green, @FormParam("blue") int blue,@FormParam("color") String color,
|
||||
@FormParam("price") int price, @FormParam("description") String description) {
|
||||
// on récupère le pixel de la db via son id
|
||||
Pixel pixel = em.find(Pixel.class, id);
|
||||
|
@ -103,7 +103,9 @@ public class PixelService {
|
|||
if (user.equals(pixel.getOwner())) {
|
||||
pixel.setPrice(price);
|
||||
pixel.setDescription(description);
|
||||
pixel.setColor(String.format("%02X%02X%02X", red, green, blue));
|
||||
//pixel.setColor(String.format("%02X%02X%02X", red, green, blue));
|
||||
String colorDisplay = color.substring(1,color.length());
|
||||
pixel.setColor(colorDisplay);
|
||||
|
||||
// on ajoute la transaction
|
||||
Date now = new Date(System.currentTimeMillis());
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<script src="js/pixels.js"></script>
|
||||
<script src="js/user.js"></script>
|
||||
<script src="js/loaded.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.css"/>
|
||||
<script src="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body onload="pageLoaded();">
|
||||
|
@ -179,6 +181,8 @@
|
|||
/>
|
||||
</div>
|
||||
|
||||
<input type="text" name="color" id="colorpicker" data-coloris>
|
||||
|
||||
<div>
|
||||
<label>Description</label>
|
||||
<input
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
// fonction qui s'execute quand la page a finie de charger
|
||||
function pageLoaded() {
|
||||
|
||||
Coloris({
|
||||
alpha: false
|
||||
});
|
||||
|
||||
// document.addEventListener('coloris:pick', event => {
|
||||
// console.log('New color', event.detail.color);
|
||||
// });
|
||||
|
||||
|
||||
document.forms["pay-form"].addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
fetch(event.target.action, {
|
||||
|
@ -74,4 +84,4 @@ function pageLoaded() {
|
|||
} else {
|
||||
localStorage.setItem("logged", "false");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -80,6 +80,9 @@ function updateModifyForm(pixel) {
|
|||
let price = document.getElementById("modify-price");
|
||||
price.value = pixel.price;
|
||||
|
||||
let colorpicker = document.getElementById("colorpicker")
|
||||
colorpicker.value = "#" + pixel.color
|
||||
|
||||
let color = hexToRgb(pixel.color);
|
||||
|
||||
let red = document.getElementById("modify-red");
|
||||
|
|
Loading…
Reference in a new issue