2018-05-26 14:33:15 +02:00
|
|
|
window.addEventListener('load', async () => {
|
|
|
|
console.log("Seite geladen");
|
2018-06-11 17:44:54 +02:00
|
|
|
//getNewUniqueLink();
|
|
|
|
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
|
2018-05-26 14:33:15 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
async function getNewUniqueLink() {
|
|
|
|
try {
|
|
|
|
var firstFetch = await fetch('php/generateLink.php');
|
|
|
|
var jsonFirstFetch = await firstFetch.json();
|
|
|
|
var content = document.getElementById('content');
|
|
|
|
content.innerHTML = `${jsonFirstFetch.html}`;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Server nicht erreichbar.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-06-11 18:15:21 +02:00
|
|
|
|
|
|
|
//<!--Register-->
|
|
|
|
document.getElementById('btnCreate').addEventListener("click" , async (event) => {
|
|
|
|
const formData = new FormData(document.getElementById('create-form'));
|
|
|
|
try {
|
2018-06-17 18:24:56 +02:00
|
|
|
const response = await fetch('php/signup.php', {
|
2018-06-11 18:15:21 +02:00
|
|
|
method: 'post',
|
|
|
|
body: formData
|
|
|
|
});
|
2018-06-13 19:46:32 +02:00
|
|
|
const jsonData = await response.json();
|
|
|
|
console.log(jsonData);
|
|
|
|
|
2018-06-11 18:15:21 +02:00
|
|
|
} catch (e) {
|
|
|
|
console.log("Abschicken der Daten fehlerhaft!");
|
|
|
|
}
|
|
|
|
})
|