Hotfix: Réorganisation fichiers JS pour les Pages
This commit is contained in:
parent
d80ab61be4
commit
f43158c773
@ -29,12 +29,12 @@
|
|||||||
<script defer src="/scripts/variables.js"></script>
|
<script defer src="/scripts/variables.js"></script>
|
||||||
<script defer src="/scripts/fonctions_annexes.js"></script>
|
<script defer src="/scripts/fonctions_annexes.js"></script>
|
||||||
<script defer src="/scripts/main.js"></script>
|
<script defer src="/scripts/main.js"></script>
|
||||||
<script defer src="/scripts/executeFunction.js"></script>
|
|
||||||
<?php
|
<?php
|
||||||
// Ajouts des scripts personnalisés pour chaque page
|
// Ajouts des scripts personnalisés pour chaque page
|
||||||
foreach ($scripts as $script) {
|
foreach ($scripts as $script) {
|
||||||
echo $script;
|
echo $script;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -14,18 +14,21 @@ switch ($currentpage) {
|
|||||||
$description = 'FunctionProject est un projet créé par Divlo qui a pour but de rassembler plein de mini-programme permettant de faire plusieurs choses comme savoir la météo, générer un nombre aléatoire, etc.';
|
$description = 'FunctionProject est un projet créé par Divlo qui a pour but de rassembler plein de mini-programme permettant de faire plusieurs choses comme savoir la météo, générer un nombre aléatoire, etc.';
|
||||||
$image = 'https://function.divlo.fr/img/FunctionProject_icon.png';
|
$image = 'https://function.divlo.fr/img/FunctionProject_icon.png';
|
||||||
$indexActive = 'active';
|
$indexActive = 'active';
|
||||||
|
$scripts = array('<script defer src="/scripts/pagesJS/home-page.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/function-list.php':
|
case '/views/function-list.php':
|
||||||
$title = 'Liste des fonctions';
|
$title = 'Liste des fonctions';
|
||||||
$description = 'La liste des mini-programmes.';
|
$description = 'La liste des mini-programmes.';
|
||||||
$image = 'https://function.divlo.fr/img/FunctionProject_icon.png';
|
$image = 'https://function.divlo.fr/img/FunctionProject_icon.png';
|
||||||
$functionlistActive = 'active';
|
$functionlistActive = 'active';
|
||||||
|
$scripts = array('<script defer src="/scripts/pagesJS/functions-list.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/feedback-form_view.php':
|
case '/views/feedback-form_view.php':
|
||||||
$title = 'Feedback Formulaire';
|
$title = 'Feedback Formulaire';
|
||||||
$description = "Vous pouvez m'envoyer votre avis sur le projet grâce à ce formulaire 📝.";
|
$description = "Vous pouvez m'envoyer votre avis sur le projet grâce à ce formulaire 📝.";
|
||||||
$image = 'https://function.divlo.fr/img/Feedback-Formulaire.png';
|
$image = 'https://function.divlo.fr/img/Feedback-Formulaire.png';
|
||||||
$feedbackActive = 'active';
|
$feedbackActive = 'active';
|
||||||
|
$scripts = array('<script defer src="/scripts/execute-function/feedbackForm_DOM.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/feedback-list.php':
|
case '/views/feedback-list.php':
|
||||||
$title = 'Liste des feedback';
|
$title = 'Liste des feedback';
|
||||||
@ -78,6 +81,7 @@ switch ($currentpage) {
|
|||||||
$title = 'Liste des citations';
|
$title = 'Liste des citations';
|
||||||
$description = "La liste de toutes les citations ou proverbes (aimé par Divlo).";
|
$description = "La liste de toutes les citations ou proverbes (aimé par Divlo).";
|
||||||
$image = 'https://function.divlo.fr/img/function-image/randomQuote.png';
|
$image = 'https://function.divlo.fr/img/function-image/randomQuote.png';
|
||||||
|
$scripts = array('<script defer src="/scripts/pagesJS/quote-list.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/function-views/convertCurrency.php':
|
case '/views/function-views/convertCurrency.php':
|
||||||
$title = 'Conversion de devise';
|
$title = 'Conversion de devise';
|
||||||
@ -113,22 +117,26 @@ switch ($currentpage) {
|
|||||||
$title = "Markdown";
|
$title = "Markdown";
|
||||||
$description = "Convertis du Markdown en HTML.";
|
$description = "Convertis du Markdown en HTML.";
|
||||||
$image = 'https://function.divlo.fr/img/function-image/convertMarkdown.png';
|
$image = 'https://function.divlo.fr/img/function-image/convertMarkdown.png';
|
||||||
|
$scripts = array('<script type="module" defer src="/scripts/execute-function/convertMarkdown_DOM.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/function-views/linkShortener.php':
|
case '/views/function-views/linkShortener.php':
|
||||||
$title = "Raccourcisseurs de liens";
|
$title = "Raccourcisseurs de liens";
|
||||||
$description = "Une URL trop longue ? Raccourcissez-là !";
|
$description = "Une URL trop longue ? Raccourcissez-là !";
|
||||||
$image = 'https://function.divlo.fr/img/function-image/linkShortener.png';
|
$image = 'https://function.divlo.fr/img/function-image/linkShortener.png';
|
||||||
|
$scripts = array('<script defer src="/scripts/execute-function/linkShortener_DOM.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/short_links-list.php':
|
case '/views/short_links-list.php':
|
||||||
$title = 'Liste des liens récemment raccourcit';
|
$title = 'Liste des liens récemment raccourcit';
|
||||||
$description = "La liste de vos liens raccourcit les plus récents.";
|
$description = "La liste de vos liens raccourcit les plus récents.";
|
||||||
$image = 'https://function.divlo.fr/img/function-image/linkShortener.png';
|
$image = 'https://function.divlo.fr/img/function-image/linkShortener.png';
|
||||||
|
$scripts = array('<script defer src="/scripts/pagesJS/short_links-list.js"></script>');
|
||||||
break;
|
break;
|
||||||
case '/views/function-views/toDoList.php':
|
case '/views/function-views/toDoList.php':
|
||||||
$title = 'Liste de choses à faire';
|
$title = 'Liste de choses à faire';
|
||||||
$description = "La liste des choses à faire.";
|
$description = "La liste des choses à faire.";
|
||||||
$image = 'https://function.divlo.fr/img/function-image/toDoList.png';
|
$image = 'https://function.divlo.fr/img/function-image/toDoList.png';
|
||||||
$toDoListCSS = true;
|
$toDoListCSS = true;
|
||||||
|
$scripts = array('<script defer src="/scripts/execute-function/toDoList_DOM.js"></script>');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$title = 'Erreur 404';
|
$title = 'Erreur 404';
|
||||||
|
@ -4,4 +4,23 @@ $(function () {
|
|||||||
$("#birthDateValue").bind("keyup change", () => {
|
$("#birthDateValue").bind("keyup change", () => {
|
||||||
$('.results').html(calculateAge($('#birthDateValue').val()));
|
$('.results').html(calculateAge($('#birthDateValue').val()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Date Picker */
|
||||||
|
$.fn.datepicker.dates['fr'] = {
|
||||||
|
days: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
|
||||||
|
daysShort: ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."],
|
||||||
|
daysMin: ["d", "l", "ma", "me", "j", "v", "s"],
|
||||||
|
months: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
|
||||||
|
monthsShort: ["janv.", "févr.", "mars", "avril", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."],
|
||||||
|
today: "Aujourd'hui",
|
||||||
|
monthsTitle: "Mois",
|
||||||
|
clear: "Effacer",
|
||||||
|
weekStart: 1,
|
||||||
|
format: "dd/mm/yyyy"
|
||||||
|
};
|
||||||
|
$('.datepicker').datepicker({
|
||||||
|
language: 'fr',
|
||||||
|
autoclose: false,
|
||||||
|
todayHighlight: true
|
||||||
|
});
|
||||||
});
|
});
|
13
scripts/execute-function/convertMarkdown_DOM.js
Normal file
13
scripts/execute-function/convertMarkdown_DOM.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
$(function () {
|
||||||
|
if (localStorage.getItem('convertedHTML') && localStorage.getItem('texteMarkdown')) {
|
||||||
|
$('.results').html(localStorage.getItem('convertedHTML'));
|
||||||
|
$('#texteMarkdown').val(localStorage.getItem('texteMarkdown'));
|
||||||
|
}
|
||||||
|
$("#texteMarkdown").bind("keyup change", () => {
|
||||||
|
const textMarkdown = $('#texteMarkdown').val();
|
||||||
|
const convertedHTML = marked(textMarkdown);
|
||||||
|
localStorage.setItem("convertedHTML", convertedHTML);
|
||||||
|
localStorage.setItem("texteMarkdown", textMarkdown);
|
||||||
|
$('.results').html(convertedHTML);
|
||||||
|
});
|
||||||
|
});
|
18
scripts/execute-function/feedbackForm_DOM.js
Normal file
18
scripts/execute-function/feedbackForm_DOM.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
$(function () {
|
||||||
|
$('#formLinkShortener').submit((event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const postdata = $('#formLinkShortener').serialize();
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '../../php/shortenLink.php',
|
||||||
|
data: postdata,
|
||||||
|
success: (text) => {
|
||||||
|
try {
|
||||||
|
$(".results").html(JSON.parse(text).message);
|
||||||
|
} catch (error) {
|
||||||
|
$(".results").html("URL invalide.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
28
scripts/execute-function/linkShortener_DOM.js
Normal file
28
scripts/execute-function/linkShortener_DOM.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
$(function () {
|
||||||
|
$('#formLinkShortener').submit((event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const postdata = $('#formLinkShortener').serialize();
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '../../php/shortenLink.php',
|
||||||
|
data: postdata,
|
||||||
|
success: (text) => {
|
||||||
|
try {
|
||||||
|
$(".results").html(JSON.parse(text).message);
|
||||||
|
} catch (error) {
|
||||||
|
$(".results").html("URL invalide.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Affiche l'input selon le choix de l'utilisateur sur la page linkShortener
|
||||||
|
$('.hideUserShortcut').hide();
|
||||||
|
$("#option").bind("keyup change", () => {
|
||||||
|
if ($("#option").val() == "userShortcut") {
|
||||||
|
$('.hideUserShortcut').show();
|
||||||
|
} else {
|
||||||
|
$('.hideUserShortcut').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,57 +0,0 @@
|
|||||||
$(function () {
|
|
||||||
/* ÉXECUTION DES FONCTONS */
|
|
||||||
|
|
||||||
// Touche entrer génère un clique sur les classes .btn à part sur la page convertEncoding
|
|
||||||
$("body").keydown(function(e){
|
|
||||||
if(e.which === 13 && chemin !== '/views/function-views/convertEncoding.php'){
|
|
||||||
$(".btn").click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (chemin === "/views/function-views/convertMarkdown.php" && localStorage.getItem('convertedHTML') && localStorage.getItem('texteMarkdown')) {
|
|
||||||
$('.results').html(localStorage.getItem('convertedHTML'));
|
|
||||||
$('#texteMarkdown').val(localStorage.getItem('texteMarkdown'));
|
|
||||||
}
|
|
||||||
$("#texteMarkdown").bind("keyup change", () => {
|
|
||||||
const textMarkdown = $('#texteMarkdown').val();
|
|
||||||
const convertedHTML = marked(textMarkdown);
|
|
||||||
localStorage.setItem("convertedHTML", convertedHTML);
|
|
||||||
localStorage.setItem("texteMarkdown", textMarkdown);
|
|
||||||
$('.results').html(convertedHTML);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#formLinkShortener').submit((e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const postdata = $('#formLinkShortener').serialize();
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '../../php/shortenLink.php',
|
|
||||||
data: postdata,
|
|
||||||
success: (text) => {
|
|
||||||
try {
|
|
||||||
$(".results").html(JSON.parse(text).message);
|
|
||||||
} catch (error) {
|
|
||||||
$(".results").html("URL invalide.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#feedbackForm').submit((e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const postdata = $('#feedbackForm').serialize();
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '../../php/feedbackForm.php',
|
|
||||||
data: postdata,
|
|
||||||
success: (response) => {
|
|
||||||
const result = JSON.parse(response);
|
|
||||||
$(".results").html(result.message);
|
|
||||||
if(result.isSuccess) {
|
|
||||||
$("#feedbackForm")[0].reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,33 +1,4 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
/* Apparition au défilement avec animation */
|
|
||||||
function setWindowScrollAppear() {
|
|
||||||
var $animate = $('.animate-up, .animate-down, .animate-left, .animate-right');
|
|
||||||
$animate.appear();
|
|
||||||
$animate.on('appear', function (event, affected) {
|
|
||||||
for (var i = 0; i < affected.length; i++) {
|
|
||||||
$(affected[i]).addClass('animated');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$.force_appear();
|
|
||||||
}
|
|
||||||
setWindowScrollAppear();
|
|
||||||
|
|
||||||
/* Changement du texte accueil (exemples de fonction) */
|
|
||||||
if(chemin === "/" || chemin === '/index.php') {
|
|
||||||
let index=-1;
|
|
||||||
function change() {
|
|
||||||
if(index === texteFonctionChange.length-1) {
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
document.getElementById("change").innerHTML = texteFonctionChange[index];
|
|
||||||
}
|
|
||||||
setInterval(change,10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Changement du logo du header selon la largeur de la fenêtre */
|
/* Changement du logo du header selon la largeur de la fenêtre */
|
||||||
function widthWindowChange() {
|
function widthWindowChange() {
|
||||||
const windowWidth = $(window).width();
|
const windowWidth = $(window).width();
|
||||||
@ -48,64 +19,10 @@ $(function () {
|
|||||||
/* Permet d'afficher l'heure en temps réel sur le footer */
|
/* Permet d'afficher l'heure en temps réel sur le footer */
|
||||||
realDateTime('realDateTime');
|
realDateTime('realDateTime');
|
||||||
|
|
||||||
/* Permet d'afficher la liste des citations/proverbes */
|
|
||||||
if(chemin === "/views/quote-list.php") {
|
|
||||||
$('.totalLengthQuote').html('Total de ' + quotes.length + ' citations.');
|
|
||||||
let resultat = "";
|
|
||||||
for (index in quotes) {
|
|
||||||
resultat = resultat + `<tr> <td class="quote-element-list important">${quotes[index]["source"]}</td> <td class="quote-element-list">${quotes[index]["quote"]}</td> </tr>`;
|
|
||||||
}
|
|
||||||
$(".quote-list").append(resultat);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Permet d'afficher la liste des liens récemment raccourcit */
|
|
||||||
if(chemin === "/views/short_links-list.php") {
|
|
||||||
try {
|
|
||||||
const shortcuts = JSON.parse(getCookieValue("shortcuts"));
|
|
||||||
window.onload = $('.totalLengthLinksList').html(`Total de ${shortcuts.length} lien(s) raccourcit récemment.`);
|
|
||||||
let resultat = "";
|
|
||||||
for (element of shortcuts) {
|
|
||||||
resultat += `<tr> <td class="original-link-list"><a href="${element["url"]}" target="_blank">${element["url"]}</a></td> <td class="link-list"><a href="${element["shortcut"]}" target="_blank">${element["shortcut"]}</a></td> </tr>`;
|
|
||||||
}
|
|
||||||
$(".links-list").append(resultat);
|
|
||||||
} catch(error) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Window Scroll Top Button */
|
/* Window Scroll Top Button */
|
||||||
const $btnScrollTop = $('.scroll-top-arrow');
|
const $btnScrollTop = $('.scroll-top-arrow');
|
||||||
$btnScrollTop.on('click', function () {
|
$btnScrollTop.on('click', function () {
|
||||||
$('html, body').animate({scrollTop: 0}, 800);
|
$('html, body').animate({scrollTop: 0}, 800);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Affiche l'input selon le choix de l'utilisateur sur la page linkShortener
|
|
||||||
if(chemin === '/views/function-views/linkShortener.php') {
|
|
||||||
$('.hideUserShortcut').hide();
|
|
||||||
$("#option").bind("keyup change", () => {
|
|
||||||
if ($("#option").val() == "userShortcut") {
|
|
||||||
$('.hideUserShortcut').show();
|
|
||||||
} else {
|
|
||||||
$('.hideUserShortcut').hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Date Picker */
|
|
||||||
$.fn.datepicker.dates['fr'] = {
|
|
||||||
days: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
|
|
||||||
daysShort: ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."],
|
|
||||||
daysMin: ["d", "l", "ma", "me", "j", "v", "s"],
|
|
||||||
months: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
|
|
||||||
monthsShort: ["janv.", "févr.", "mars", "avril", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."],
|
|
||||||
today: "Aujourd'hui",
|
|
||||||
monthsTitle: "Mois",
|
|
||||||
clear: "Effacer",
|
|
||||||
weekStart: 1,
|
|
||||||
format: "dd/mm/yyyy"
|
|
||||||
};
|
|
||||||
$('.datepicker').datepicker({
|
|
||||||
language: 'fr',
|
|
||||||
autoclose: false,
|
|
||||||
todayHighlight: true
|
|
||||||
});
|
|
||||||
});
|
});
|
14
scripts/pagesJS/functions-list.js
Normal file
14
scripts/pagesJS/functions-list.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
$(function () {
|
||||||
|
/* Apparition au défilement avec animation */
|
||||||
|
function setWindowScrollAppear() {
|
||||||
|
var $animate = $('.animate-up, .animate-down, .animate-left, .animate-right');
|
||||||
|
$animate.appear();
|
||||||
|
$animate.on('appear', function (event, affected) {
|
||||||
|
for (var i = 0; i < affected.length; i++) {
|
||||||
|
$(affected[i]).addClass('animated');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.force_appear();
|
||||||
|
}
|
||||||
|
setWindowScrollAppear();
|
||||||
|
});
|
14
scripts/pagesJS/home-page.js
Normal file
14
scripts/pagesJS/home-page.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
$(function () {
|
||||||
|
/* Changement du texte accueil (exemples de fonction) */
|
||||||
|
let index=-1;
|
||||||
|
function change() {
|
||||||
|
if(index === texteFonctionChange.length-1) {
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
document.getElementById("change").innerHTML = texteFonctionChange[index];
|
||||||
|
}
|
||||||
|
setInterval(change, 10000);
|
||||||
|
});
|
9
scripts/pagesJS/quote-list.js
Normal file
9
scripts/pagesJS/quote-list.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
$(function () {
|
||||||
|
/* Permet d'afficher la liste des citations/proverbes */
|
||||||
|
$('.totalLengthQuote').html('Total de ' + quotes.length + ' citations.');
|
||||||
|
let resultat = "";
|
||||||
|
for (index in quotes) {
|
||||||
|
resultat = resultat + `<tr> <td class="quote-element-list important">${quotes[index]["source"]}</td> <td class="quote-element-list">${quotes[index]["quote"]}</td> </tr>`;
|
||||||
|
}
|
||||||
|
$(".quote-list").append(resultat);
|
||||||
|
});
|
12
scripts/pagesJS/short_links-list.js
Normal file
12
scripts/pagesJS/short_links-list.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
$(function () {
|
||||||
|
/* Permet d'afficher la liste des liens récemment raccourcit */
|
||||||
|
try {
|
||||||
|
const shortcuts = JSON.parse(getCookieValue("shortcuts"));
|
||||||
|
window.onload = $('.totalLengthLinksList').html(`Total de ${shortcuts.length} lien(s) raccourcit récemment.`);
|
||||||
|
let resultat = "";
|
||||||
|
for (element of shortcuts) {
|
||||||
|
resultat += `<tr> <td class="original-link-list"><a href="${element["url"]}" target="_blank">${element["url"]}</a></td> <td class="link-list"><a href="${element["shortcut"]}" target="_blank">${element["shortcut"]}</a></td> </tr>`;
|
||||||
|
}
|
||||||
|
$(".links-list").append(resultat);
|
||||||
|
} catch(error) {}
|
||||||
|
});
|
@ -40,7 +40,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script defer src="/scripts/toDoList.js"></script>
|
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<?php include("../../incl/footer.php");?>
|
<?php include("../../incl/footer.php");?>
|
Reference in New Issue
Block a user