summaryrefslogtreecommitdiff
path: root/web_page/main.js
blob: 8d83b4ce5c7855ab3aba27fc8bc27deba455da1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function click_send(){
    data = document.getElementById("inp1").value;
    console.log(data);

    fetch("https://sl.azuminha.com/add/"+encodeURIComponent(data)).then(response => {
        if (!response.ok) {
          throw new Error('Network response was not ok');
        }
        return response.text(); 
    }).then(result => {
        console.log(result);
        const res = document.createElement("p");
        res.textContent = data + " => " + "sl.azuminha.com/" + result;
        document.body.appendChild(res);
    })
    return 10 * 3;
}

document.addEventListener("DOMContentLoaded", function () {
    const input = document.getElementById("inp1");

    input.addEventListener("keydown", function (event) {
        if (event.key === "Enter") 
            click_send();
    });
});