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/")
@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("color") String color,
@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,7 @@ public class PixelService {
if (user.equals(pixel.getOwner())) {
pixel.setPrice(price);
pixel.setDescription(description);
//pixel.setColor(String.format("%02X%02X%02X", red, green, blue));
String colorDisplay = color.substring(1,color.length());
pixel.setColor(colorDisplay);

View file

@ -10,8 +10,6 @@
<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();">
@ -141,48 +139,12 @@
required
/>
</div>
<div>
<label>Red</label>
<input
type="range"
min="0"
max="255"
step="1"
name="red"
id="modify-red"
required
/>
<div class="data">
<label>Color</label>
<input type="color" name="color" id="colorpicker" >
</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>
<label>Description</label>
<input

View file

@ -1,15 +1,6 @@
// 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, {

View file

@ -80,19 +80,8 @@ 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");
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 colorpicker = document.getElementById("colorpicker");
colorpicker.value = "#" + pixel.color;
let description = document.getElementById("modify-description");
description.value = pixel.description;