New function : shortenLink
This commit is contained in:
@ -95,16 +95,6 @@ $(function () {
|
||||
$('.resultsRandomQuote').html(getRandomQuote());
|
||||
}
|
||||
|
||||
/* Permet d'afficher la liste des citations/proverbes */
|
||||
if(chemin === "/views/quote-list.php") {
|
||||
window.onload = $('.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);
|
||||
}
|
||||
|
||||
$("#submitConvertCurrency").click(() => {
|
||||
let value = $('#value').val();
|
||||
const currencyOfTheValue = $("#currencyOfTheValue option:selected").val();
|
||||
@ -212,4 +202,21 @@ $(function () {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -158,4 +158,26 @@ function isValidDate(verifyDate, currentDate) {
|
||||
*/
|
||||
function createSessionCookie(name, value) {
|
||||
document.cookie = escape(name) + "=" + escape(value) + " ; path=/";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @function getCookieValue
|
||||
* @description Récupère la valeur d'un cookie.
|
||||
* @param {string} name Nom du cookie
|
||||
* @param {string} value Valeur du cookie
|
||||
*/
|
||||
function getCookieValue(cname) {
|
||||
const name = cname + "=";
|
||||
const decodedCookie = decodeURIComponent(document.cookie);
|
||||
const ca = decodedCookie.split(';');
|
||||
for(let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
@ -34,6 +34,29 @@ $(function () {
|
||||
/* Permet d'afficher l'heure en temps réel sur le footer */
|
||||
realDateTime('realDateTime');
|
||||
|
||||
/* Permet d'afficher la liste des citations/proverbes */
|
||||
if(chemin === "/views/quote-list.php") {
|
||||
window.onload = $('.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 */
|
||||
const $btnScrollTop = $('.scroll-top-arrow');
|
||||
$btnScrollTop.on('click', function () {
|
||||
@ -41,6 +64,18 @@ $(function () {
|
||||
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"],
|
||||
|
Reference in New Issue
Block a user