First Commit

This commit is contained in:
mrtoine 2025-09-12 11:11:44 +02:00
commit ce0758fbbb
496 changed files with 52062 additions and 0 deletions

View file

@ -0,0 +1,32 @@
<div class="bbcode-bar">
<ul>
<li><button class="bbcode-bar-item" type="button" style="font-weight: 900;" data-tag="[b][/b]">B</button></li>
<li><button class="bbcode-bar-item" type="button" style="font-style: italic;" data-tag="[i][/i]">I</button></li>
<li><button class="bbcode-bar-item" type="button" style="text-decoration: underline;" data-tag="[u][/u]">U</button></li>
<li><button class="bbcode-bar-item" type="button" style="text-decoration: line-through;" data-tag="[s][/s]">S</button></li>
<li><button class="bbcode-bar-button-colors" type="button" id="colors">Couleur</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[img][/img]">Image</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[url][/url]">Lien</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[list][/list]">Liste</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[citation][/citation]">Citation</button></li>
<li><button class="bbcode-bar-button-gallery" type="button" id="gallery">Galerie</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[t1][/t1]">Titre 1</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[t2][/t2]">Titre 2</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[t3][/t3]">Titre 3</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[size=][/size]">Taille</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[p][/p]">Paragraphe</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[center][/center]">Centré</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[right][/right]">Droite</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[block][/block]">Block</button></li>
<li><button class="bbcode-bar-item" type="button" data-tag="[code][/code]">Code</button></li>
</ul>
</div>
<div id="draggable-window" class="draggable">
<div class="header">
<span>Ma Galerie</span>
<button type="button" id="close-window" class="close-button">&times;</button>
</div>
<div class="content-gallery">
</div>
</div>

View file

@ -0,0 +1,276 @@
document.addEventListener('DOMContentLoaded', () => {
let textarea = document.querySelector('textarea');
const quoteButtons = document.querySelectorAll('#quote');
console.log(quoteButtons);
quoteButtons.forEach((elem) =>{
const post_id = elem.target;
elem.addEventListener('click', event => {
const author = document.querySelector(`#author-post-${post_id}`).textContent;
const content = document.querySelector(`#post-${post_id}`).textContent;
textarea.value = `[citation=${author}]${content}[/citation]`;
textarea.focus();
});
});
let colorBarVisible = false;
let existingColorBar = null;
fetch('/static/js/utils/bbcode-bar.html')
.then(response => {
if (response.ok) {
return response.text();
} else {
throw new Error('Impossible de charger le fichier HTML');
}
})
.then(html => {
textarea.insertAdjacentHTML('beforebegin', html);
const bbcodeBar = document.querySelector('.bbcode-bar');
bbcodeBar.addEventListener('click', event => {
if (event.target.tagName === 'BUTTON' && event.target.classList.contains('bbcode-bar-item')) {
const tag = event.target.getAttribute('data-tag');
if (tag.includes('][')) {
const [openTag, closeTag] = tag.split('][');
let startTag = openTag + ']';
if(tag === '[list][/list]') {
startTag = openTag + '][*]';
}
const endTag = '[' + closeTag;
const startPos = textarea.selectionStart;
const endPos = textarea.selectionEnd;
const text = textarea.value;
textarea.value =
text.slice(0, startPos) +
startTag +
text.slice(startPos, endPos) +
endTag +
text.slice(endPos);
textarea.selectionStart = startPos + startTag.length;
textarea.selectionEnd = startPos + startTag.length;
textarea.focus();
} else {
console.error('Format de balise incorrect :', tag);
}
} else if (event.target.tagName === 'BUTTON' && event.target.classList.contains('bbcode-bar-button-gallery')) {
let draggableWindows = document.querySelector('.draggable');
let header = draggableWindows.querySelector('.header');
const contentArea = document.querySelector('.content-gallery')
fetch('/gallery/')
.then(response => {
if(response.ok) {
return response.text();
} else {
throw new Error('Impossible de charger le fichier html de la galerie');
}
})
.then(html => {
contentArea.innerHTML = html;
draggableWindows.style.display = 'block';
})
.catch(error => {
contentArea.innerHTML = '<h4 style="color:red;">Erreur lors du chargement de la galerie</h4>';
draggableWindows.style.display = 'block';
})
if (draggableWindows) {
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const modalWidth = draggableWindows.offsetWidth;
const modalHeight = draggableWindows.offsetHeight;
// Centre la fenêtre au milieu de l'écran
draggableWindows.style.left = `${(windowWidth - modalWidth) / 2}px`;
draggableWindows.style.top = `${(windowHeight - modalHeight) / 2}px`;
// Assure que la fenêtre soit positionnée en mode absolu
draggableWindows.style.position = 'fixed';
}
if (draggableWindows) {
if (header) {
header.addEventListener('mousedown', (e) => {
e.preventDefault();
let offsetX = e.clientX - draggableWindows.offsetLeft;
let offsetY = e.clientY - draggableWindows.offsetTop;
function onMouseMove(e) {
draggableWindows.style.left = e.clientX - offsetX + 'px';
draggableWindows.style.top = e.clientY - offsetY + 'px';
}
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', () => {
document.removeEventListener('mousemove', onMouseMove);
}, { once: true });
});
}
const closeButton = document.querySelector('#close-window');
if (closeButton) {
closeButton.addEventListener('click', () => {
console.log("test fermeture")
draggableWindows.style.display = 'none';
});
}
}
} else if (event.target.tagName === 'BUTTON' && event.target.classList.contains('bbcode-bar-button-colors')) {
event.preventDefault();
if (existingColorBar) {
// Si la barre existe déjà, on bascule sa visibilité
existingColorBar.style.display = colorBarVisible ? 'none' : 'block';
colorBarVisible = !colorBarVisible;
return;
}
// Si la barre n'existe pas encore, on la crée
const colors = [
// Basiques
'black',
'white',
// Gris
'gray',
'darkgray',
'silver',
// Rouges
'red',
'darkred',
'maroon',
'crimson',
'coral',
// Roses/Violets
'pink',
'hotpink',
'fuchsia',
'purple',
'blueviolet',
'darkmagenta',
// Bleus
'blue',
'navy',
'darkblue',
'royalblue',
'cornflowerblue',
'skyblue',
'aqua',
'cyan',
'darkcyan',
'teal',
// Verts
'green',
'darkgreen',
'lime',
'limegreen',
'springgreen',
'aquamarine',
'chartreuse',
// Jaunes/Oranges
'yellow',
'gold',
'orange',
'darkorange',
// Marrons
'brown',
'chocolate',
'saddlebrown',
'burlywood',
// Tons pastel
'aliceblue',
'antiquewhite',
'azure',
'beige',
'bisque',
'blanchedalmond',
'cornsilk',
'darkkhaki',
'olive'
];
const colorBar = document.createElement('div');
colorBar.classList.add('bbcode-bar-colors');
colorBar.style.display = 'block';
const colorButtons = colors.map(color => {
const link = document.createElement('a');
link.classList.add('bbcode-bar-item-color');
link.style.backgroundColor = color;
link.style.width = '20px';
link.style.height = '20px';
link.style.display = 'inline-block';
link.style.margin = '2px';
link.setAttribute('data-color', color);
link.href = '#';
return link;
});
colorButtons.forEach(link => colorBar.appendChild(link));
bbcodeBar.appendChild(colorBar);
existingColorBar = colorBar;
colorBarVisible = true;
} else if (event.target.tagName === 'A' && event.target.classList.contains('bbcode-bar-item-color')) {
event.preventDefault();
const color = event.target.getAttribute('data-color');
if (color) {
insertBBCode(`[color=${color}]`, `[/color]`);
}
}
});
})
.catch(error => console.error('Erreur: ', error));
});
function insertBBCode(openTag, closeTag) {
const textarea = document.querySelector('textarea'); // Assurez-vous de sélectionner le bon textarea
if (!textarea) return;
const start = textarea.selectionStart;
const end = textarea.selectionEnd;
const text = textarea.value;
const before = text.substring(0, start);
const selected = text.substring(start, end);
const after = text.substring(end);
textarea.value = `${before}${openTag}${selected}${closeTag}${after}`;
textarea.focus();
textarea.selectionStart = start + openTag.length;
textarea.selectionEnd = end + openTag.length;
}
function load_gallery() {
const contentArea = document.querySelector('.content-gallery')
fetch('/gallery/')
.then(response => {
if(response.ok) {
return response.text();
} else {
throw new Error('Impossible de charger le fichier html de la galerie');
}
})
.then(html => {
contentArea.innerHTML = html;
draggableWindows.style.display = 'block';
})
.catch(error => {
contentArea.innerHTML = '<p>Erreur lors du chargement de la galerie</p>';
draggableWindows.style.display = 'block';
})
}

View file

@ -0,0 +1,57 @@
function openPopup(url) {
window.open(
url,
'PopupWindow',
'width=400,height=400,scrollbars=no,resizable=no'
);
}
function copyToClipboard(event) {
// Récupère le bouton qui a déclenché l'événement
const button = event.target;
// Récupère la valeur de l'attribut data-tag
const tag = button.getAttribute('data-tag');
// Utilise l'API Clipboard pour copier dans le presse-papiers
navigator.clipboard.writeText(tag)
}
function modal(id, price) {
const modal = document.querySelector('.modal');
if (modal) {
modal.style.display = 'block';
const close = document.querySelector('.modal-close');
const accept = modal.querySelector('#accept');
accept.innerHTML = `Payer <span class="money">${price}</span>`;
const decline = modal.querySelector('#decline');
accept.addEventListener('click', () => {
window.location.href = `/shop/buy/${id}`;
});
decline.addEventListener('click', () => {
modal.style.display = 'none';
});
close.addEventListener('click', () => {
modal.style.display = 'none';
});
}
}
document.addEventListener('DOMContentLoaded', () => {
const avatars = document.querySelectorAll('.cadre-retro-gameboy');
avatars.forEach(avatar => {
console.log("on a trouvé l'avatar");
const divButtons = document.createElement('div');
const divCross = document.createElement('div');
const divStartSelect = document.createElement('div');
divButtons.classList.add('buttons');
divCross.classList.add('controls');
divStartSelect.classList.add('start-select');
avatar.appendChild(divButtons);
avatar.appendChild(divCross);
avatar.appendChild(divStartSelect);
});
});

View file

@ -0,0 +1,87 @@
const selectPostType = document.querySelector('#post_type');
if (selectPostType) {
let postsList = [];
let divChildForm = null;
const container = document.querySelector('form');
const buttonSubmit = document.querySelector('#submit-button');
const divSubmit = document.querySelector('#submit');
const addPostButton = document.createElement('a');
addPostButton.className = 'btn btn-add';
addPostButton.textContent = "Ajouter un article";
selectPostType.addEventListener('change', (event) => {
const selectedValue = event.target.value;
if (selectedValue === 'solo') {
// Supprime le bouton si présent
buttonSubmit.textContent = 'Créer';
if (divSubmit.contains(addPostButton)) {
divSubmit.removeChild(addPostButton);
}
// Supprime le conteneur des articles, s'il existe
if (divChildForm) {
container.removeChild(divChildForm);
divChildForm = null; // Réinitialise pour éviter des doublons
}
} else if (selectedValue === 'multiple') {
// Crée le conteneur des articles si non encore créé
buttonSubmit.textContent = 'Créer mon ensemble d\'articles';
if (!divChildForm) {
const hiddenForm = document.createElement('input');
hiddenForm.type = 'hidden';
hiddenForm.name = 'type_form';
hiddenForm.value = 'multiple';
container.appendChild(hiddenForm);
divChildForm = document.createElement('div');
container.appendChild(divChildForm);
}
// Ajoute le bouton si non encore ajouté
if (!divSubmit.contains(addPostButton)) {
divSubmit.appendChild(addPostButton);
}
// Évite les doublons d'écouteurs avec "onclick"
addPostButton.onclick = () => {
// Ajoute un numéro d'article à la liste
const articleNumber = postsList.length + 1;
postsList.push(articleNumber);
// Crée un titre pour l'article
const title = document.createElement('h3');
title.textContent = `Article enfant #${articleNumber}`;
const form = document.createElement('form');
form.method = "POST";
form.action = "";
const formTitle = document.createElement('input');
formTitle.type = 'text';
formTitle.name = `title-post-${articleNumber}`;
formTitle.placeholder = `Titre article #${articleNumber}`;
formTitle.required = true;
const formContent = document.createElement('textarea');
formContent.name = `content-post-${articleNumber}`;
formContent.placeholder = `Contenu article #${articleNumber}`;
formContent.rows = 10;
formContent.cols = 40;
formContent.required = true;
const formPostType = document.createElement('input');
formPostType.type = 'hidden';
formPostType.name = `post-type-${articleNumber}`;
formPostType.value = 'child';
divChildForm.appendChild(title);
// divChildForm.appendChild(form);
divChildForm.appendChild(formTitle);
divChildForm.appendChild(formContent);
divChildForm.appendChild(formPostType);
};
}
});
}