ganz viel geiler scheiss gemacht!
This commit is contained in:
1 parent
a3a6cbe329
commit
f365ca3592
10 files changed
+249
-35
No files matched your search
+147
-9
@@ -28,7 +28,20 @@ fetch(url,
|
||||
|
||||
*/
|
||||
|
||||
// submit kommentar nicht seite neu laden
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#kommentarform").submit(function(e) {
|
||||
console.log("Submitted")
|
||||
e.preventDefault(); // avoid to execute the actual submit of the form.
|
||||
});
|
||||
})
|
||||
|
||||
// idee laden
|
||||
|
||||
function ideeAnzeigen(data) {
|
||||
|
||||
document.getElementById("idee").innerHTML = "";
|
||||
document.querySelectorAll('.loeschen').forEach(e => e.remove());
|
||||
let titelErstellen = document.createElement("h1");
|
||||
let titelInhalt = document.createTextNode(data.titel);
|
||||
@@ -56,6 +69,8 @@ function ideeAnzeigen(data) {
|
||||
console.log(data);
|
||||
|
||||
|
||||
|
||||
|
||||
let herz = document.createElement("img");
|
||||
herz.src= "../images/herz-0.png";
|
||||
herz.classList.add("herz");
|
||||
@@ -64,17 +79,138 @@ function ideeAnzeigen(data) {
|
||||
herz.addEventListener('click', function() {
|
||||
herz.src= "../images/herz-1.png";
|
||||
|
||||
$.post('system/addLike.php/?id=' + data.id, {}).done(function(response){
|
||||
$("#mypar").html(response.amount);
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
kommentarErstellen(data.id);
|
||||
|
||||
let kommentare_container = document.createElement("div")
|
||||
kommentare_container.setAttribute("id", "kommentare_container");
|
||||
document.getElementById('idee').appendChild(kommentare_container);
|
||||
|
||||
|
||||
|
||||
kommentareAnzeigen(data.id);
|
||||
|
||||
function kommentareAnzeigen(kommentarId){
|
||||
|
||||
let url = "system/alleKommentareHolen.php";
|
||||
};
|
||||
|
||||
|
||||
// kommentar formular likesErstellen
|
||||
|
||||
function kommentarErstellen(idee_id) {
|
||||
console.log(idee_id);
|
||||
|
||||
|
||||
let formular = document.createElement("form");
|
||||
formular.classList.add("formular");
|
||||
formular.setAttribute("action", "https://751068-4.web.fhgr.ch/system/kommentarSpeichern.php");
|
||||
formular.setAttribute("method", "post");
|
||||
formular.setAttribute("id", "kommentarform");
|
||||
document.getElementById("idee").appendChild(formular);
|
||||
|
||||
let text_label = document.createElement("label");
|
||||
text_label.setAttribute("for", "text");
|
||||
|
||||
let text_input = document.createElement("input");
|
||||
text_input.setAttribute("type", "text");
|
||||
text_input.setAttribute("name", "text")
|
||||
|
||||
let submit_input = document.createElement("input");
|
||||
submit_input.setAttribute("type", "submit");
|
||||
submit_input.setAttribute("value", "Kommentar posten");
|
||||
|
||||
let id = document.createElement("input");
|
||||
id.setAttribute("type", "hidden");
|
||||
id.setAttribute("name", "idee_id")
|
||||
id.value = idee_id;
|
||||
|
||||
document.getElementById("kommentarform").appendChild(text_label);
|
||||
document.getElementById("kommentarform").appendChild(text_input);
|
||||
document.getElementById("kommentarform").appendChild(submit_input);
|
||||
document.getElementById("kommentarform").appendChild(id);
|
||||
|
||||
$("#kommentarform").submit(function(e){
|
||||
|
||||
let form = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "https://751068-4.web.fhgr.ch/system/kommentarSpeichern.php",
|
||||
data: form.serialize(),
|
||||
})
|
||||
e.preventDefault();
|
||||
document.getElementById("kommentare_container").innerHTML = "";
|
||||
|
||||
kommentareAnzeigen(idee_id);
|
||||
});
|
||||
};
|
||||
|
||||
// Idee formular erstellen
|
||||
function formularErstellen(koordianten) {
|
||||
|
||||
document.getElementById("idee").innerHTML = "";
|
||||
|
||||
|
||||
let formular = document.createElement("form");
|
||||
formular.classList.add("formular");
|
||||
formular.setAttribute("action", "https://751068-4.web.fhgr.ch/system/ideeSpeichern.php");
|
||||
formular.setAttribute("method", "post");
|
||||
formular.setAttribute("id", "form");
|
||||
document.getElementById("idee").appendChild(formular);
|
||||
|
||||
let koordinaten_lng = document.createElement("input");
|
||||
koordinaten_lng.setAttribute("type", "hidden");
|
||||
koordinaten_lng.setAttribute("name", "lng")
|
||||
koordinaten_lng.value = koordianten.toJSON().lng;
|
||||
|
||||
let koordinaten_lat = document.createElement("input");
|
||||
koordinaten_lat.setAttribute("type", "hidden");
|
||||
koordinaten_lat.setAttribute("name", "lat")
|
||||
koordinaten_lat.value = koordianten.toJSON().lat;
|
||||
|
||||
let titel_label = document.createElement("label");
|
||||
titel_label.setAttribute("for", "titel");
|
||||
titel_label.innerHTML = "Titel:";
|
||||
|
||||
let titel_input = document.createElement("input");
|
||||
titel_input.setAttribute("type", "text");
|
||||
titel_input.setAttribute("name", "titel")
|
||||
|
||||
let text_label = document.createElement("label");
|
||||
text_label.setAttribute("for", "text");
|
||||
text_label.innerHTML = "Text:";
|
||||
|
||||
let text_input = document.createElement("input");
|
||||
text_input.setAttribute("type", "text");
|
||||
text_input.setAttribute("name", "text")
|
||||
|
||||
let submit_input = document.createElement("input");
|
||||
submit_input.setAttribute("type", "submit");
|
||||
submit_input.setAttribute("value", "Formular Absenden");
|
||||
|
||||
|
||||
document.getElementById("form").appendChild(titel_label);
|
||||
document.getElementById("form").appendChild(titel_input);
|
||||
document.getElementById("form").appendChild(text_label);
|
||||
document.getElementById("form").appendChild(text_input);
|
||||
document.getElementById("form").appendChild(submit_input);
|
||||
document.getElementById("form").appendChild(koordinaten_lat);
|
||||
document.getElementById("form").appendChild(koordinaten_lng);
|
||||
};
|
||||
|
||||
|
||||
|
||||
function kommentareAnzeigen(idee_id){
|
||||
|
||||
document.getElementById("kommentare_container").innerHTML = "";
|
||||
|
||||
let url = "system/alleKommentareHolen.php/?id=" + idee_id;
|
||||
fetch(url)
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
@@ -84,13 +220,15 @@ function kommentareAnzeigen(kommentarId){
|
||||
let k_text = document.createTextNode("Kommentare:");
|
||||
k.appendChild(k_text);
|
||||
k.classList.add("loeschen")
|
||||
document.getElementById('idee').appendChild(k);
|
||||
document.getElementById('kommentare_container').appendChild(k);
|
||||
|
||||
let kommentarErstellen = document.createElement("p");
|
||||
let kommentar = document.createTextNode(data[kommentarId].k_text);
|
||||
kommentarErstellen.appendChild(kommentar);
|
||||
kommentarErstellen.classList.add("loeschen");
|
||||
document.getElementById('idee').appendChild(kommentarErstellen);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
let kommentarErstellen = document.createElement("p");
|
||||
let kommentar = document.createTextNode(data[i].k_text);
|
||||
kommentarErstellen.appendChild(kommentar);
|
||||
kommentarErstellen.classList.add("loeschen");
|
||||
document.getElementById('kommentare_container').appendChild(kommentarErstellen);
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log('Error!: ' + error.message);
|
||||
|
||||
Reference in new issue
Block a user