This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/scripts/main.js

116 lines
4.5 KiB
JavaScript
Raw Normal View History

2019-08-16 12:05:56 +02:00
$(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();
2019-10-24 18:57:39 +02:00
/* 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 */
function widthWindowChange() {
const windowWidth = $(window).width();
if(windowWidth < 463){
$('#logo-header').attr('src', '/img/FunctionProject_icon.png');
$('#logo-header').attr('style', 'display: inline-block;width: 80%;');
$('.navbar-brand').attr('style', 'width: 30%;');
}
else {
$('#logo-header').attr('src', '/img/FunctionProject_brand-logo.png');
$('#logo-header').removeAttr('style');
$('.navbar-brand').removeAttr('style');
}
}
$(window).resize(widthWindowChange);
widthWindowChange();
2019-10-11 21:30:05 +02:00
2019-08-18 20:06:06 +02:00
/* Permet d'afficher l'heure en temps réel sur le footer */
realDateTime('realDateTime');
2019-12-11 20:46:57 +01:00
/* Permet d'afficher la liste des citations/proverbes */
if(chemin === "/views/quote-list.php") {
2019-12-11 22:05:15 +01:00
$('.totalLengthQuote').html('Total de ' + quotes.length + ' citations.');
2019-12-11 20:46:57 +01:00
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) {}
}
2019-08-23 20:23:57 +02:00
/* Window Scroll Top Button */
2019-10-18 09:55:35 +02:00
const $btnScrollTop = $('.scroll-top-arrow');
2019-08-23 20:23:57 +02:00
$btnScrollTop.on('click', function () {
$('html, body').animate({scrollTop: 0}, 800);
return false;
});
2019-12-11 20:46:57 +01:00
// 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();
}
});
}
2019-08-29 22:33:07 +02:00
/* Date Picker */
$.fn.datepicker.dates['fr'] = {
2019-10-18 09:55:35 +02:00
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"
2019-08-29 22:33:07 +02:00
};
$('.datepicker').datepicker({
2019-10-18 09:55:35 +02:00
language: 'fr',
2019-10-18 20:35:03 +02:00
autoclose: false,
2019-10-18 09:55:35 +02:00
todayHighlight: true
2019-10-24 18:57:39 +02:00
});
window.addEventListener('load', () => {
document.querySelector('body').classList.remove('loading');
document.getElementById('preloader').remove();
});
2019-10-24 18:57:39 +02:00
});