<commit_before>const workerUrl = "https://getrandomnewssnippet.lucienbill.workers.dev/"
const pageInfo = "<details><summary>A propos de cette page</summary><p>Cette page affiche un extrait aléatoire, pioché dans ma newsletter.</p></details>"

function findGetParameter(parameterName) {
    const url = location.toString().split("?")
    if (url.length < 2){
        return null
    }
    const param = url[1].split("&")

    for (p of param){
        const pair = p.split("=")
        if (pair[0] == parameterName){
            return decodeURIComponent(pair[1])
        }
    }
    return null
}

async function displaySnippet(fetchkey=null){
    // Display an element from the database: a specific key, or random
    let response = null
    if (fetchkey != null){
        const options = {
            headers: {
                key: `${fetchkey}`
            }
        }
        response = await fetch(workerUrl, options)
    } else {
        response = await fetch(workerUrl)
    }
    const key = response.headers.get("key")
    let footer = ""
    if (key != null){
        footer = `<hr><p>Cet extrait vous plait ? <a title="lien vers cet extrait" href="${location.toString().split("?")[0]}?key=${key}" target:blank>Partagez-le</a> !<p>`
    }
    document.getElementById("dynamicContent").innerHTML = pageInfo + await response.json() + footer

    setRandomElementColor();
    setColorHoverListener();
}

displaySnippet(findGetParameter("key"))<commit_msg>getRandomNewsSnippet : footer add a "get nex random" link<commit_after>const workerUrl = "https://getrandomnewssnippet.lucienbill.workers.dev/"
const pageInfo = "<details><summary>A propos de cette page</summary><p>Cette page affiche un extrait aléatoire, pioché dans ma newsletter.</p></details>"

function findGetParameter(parameterName) {
    const url = location.toString().split("?")
    if (url.length < 2){
        return null
    }
    const param = url[1].split("&")

    for (p of param){
        const pair = p.split("=")
        if (pair[0] == parameterName){
            return decodeURIComponent(pair[1])
        }
    }
    return null
}

async function displaySnippet(fetchkey=null){
    // Display an element from the database: a specific key, or random
    let response = null
    if (fetchkey != null){
        const options = {
            headers: {
                key: `${fetchkey}`
            }
        }
        response = await fetch(workerUrl, options)
    } else {
        response = await fetch(workerUrl)
    }
    const key = response.headers.get("key")
    let footer = ""
    if (key != null){
        footer = `<hr><p>Cet extrait vous plait ? <a title="lien vers cet\
 extrait" href="${location.toString().split("?")[0]}?key=${key}" target:\
 blank>Partagez-le</a> !<br>Vous pouvez aussi cliquer <a onclick=\
 'displaySnippet()' title='afficher un autre extrait' href='#'>ici</a> pour\
  afficher un autre extrait.<p>`
    }
    document.getElementById("dynamicContent").innerHTML = pageInfo + await response.json() + footer

    setRandomElementColor();
    setColorHoverListener();
}

displaySnippet(findGetParameter("key"))
{'fraction_non_alphanumeric': 0.13984, 'fraction_numerical': 0.0032, 'mean_word_length': 2.9821656050955414, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3358882', 'n_tokens_mistral': 937, 'n_tokens_neox': 924, 'n_words': 239}