fix: colorpicker

This commit is contained in:
gdamms 2022-06-01 15:22:50 +02:00
parent a39d06a405
commit 7719b8c2a0
4 changed files with 8 additions and 66 deletions

View file

@ -92,7 +92,7 @@ public class PixelService {
@Path("{id}/modify/") @Path("{id}/modify/")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void modify(@PathParam("id") Long id, @CookieParam("JSESSIONID") Cookie cookie, public void modify(@PathParam("id") Long id, @CookieParam("JSESSIONID") Cookie cookie,
@FormParam("red") int red, @FormParam("green") int green, @FormParam("blue") int blue,@FormParam("color") String color, @FormParam("color") String color,
@FormParam("price") int price, @FormParam("description") String description) { @FormParam("price") int price, @FormParam("description") String description) {
// on récupère le pixel de la db via son id // on récupère le pixel de la db via son id
Pixel pixel = em.find(Pixel.class, id); Pixel pixel = em.find(Pixel.class, id);
@ -103,7 +103,7 @@ public class PixelService {
if (user.equals(pixel.getOwner())) { if (user.equals(pixel.getOwner())) {
pixel.setPrice(price); pixel.setPrice(price);
pixel.setDescription(description); pixel.setDescription(description);
//pixel.setColor(String.format("%02X%02X%02X", red, green, blue));
String colorDisplay = color.substring(1,color.length()); String colorDisplay = color.substring(1,color.length());
pixel.setColor(colorDisplay); pixel.setColor(colorDisplay);

View file

@ -10,8 +10,6 @@
<script src="js/pixels.js"></script> <script src="js/pixels.js"></script>
<script src="js/user.js"></script> <script src="js/user.js"></script>
<script src="js/loaded.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> </head>
<body onload="pageLoaded();"> <body onload="pageLoaded();">
@ -142,47 +140,11 @@
/> />
</div> </div>
<div> <div class="data">
<label>Red</label> <label>Color</label>
<input <input type="color" name="color" id="colorpicker" >
type="range"
min="0"
max="255"
step="1"
name="red"
id="modify-red"
required
/>
</div> </div>
<div>
<label>Green</label>
<input
type="range"
min="0"
max="255"
step="1"
name="green"
id="modify-green"
required
/>
</div>
<div>
<label>Blue</label>
<input
type="range"
min="0"
max="255"
step="1"
name="blue"
id="modify-blue"
required
/>
</div>
<input type="text" name="color" id="colorpicker" data-coloris>
<div> <div>
<label>Description</label> <label>Description</label>
<input <input

View file

@ -1,15 +1,6 @@
// fonction qui s'execute quand la page a finie de charger // fonction qui s'execute quand la page a finie de charger
function pageLoaded() { function pageLoaded() {
Coloris({
alpha: false
});
// document.addEventListener('coloris:pick', event => {
// console.log('New color', event.detail.color);
// });
document.forms["pay-form"].addEventListener("submit", (event) => { document.forms["pay-form"].addEventListener("submit", (event) => {
event.preventDefault(); event.preventDefault();
fetch(event.target.action, { fetch(event.target.action, {

View file

@ -80,19 +80,8 @@ function updateModifyForm(pixel) {
let price = document.getElementById("modify-price"); let price = document.getElementById("modify-price");
price.value = pixel.price; price.value = pixel.price;
let colorpicker = document.getElementById("colorpicker") let colorpicker = document.getElementById("colorpicker");
colorpicker.value = "#" + pixel.color colorpicker.value = "#" + pixel.color;
let color = hexToRgb(pixel.color);
let red = document.getElementById("modify-red");
red.value = color.r;
let green = document.getElementById("modify-green");
green.value = color.g;
let blue = document.getElementById("modify-blue");
blue.value = color.b;
let description = document.getElementById("modify-description"); let description = document.getElementById("modify-description");
description.value = pixel.description; description.value = pixel.description;