Skip to content
Snippets Groups Projects
Select Git revision
  • 13136376ee6e39c4fdc393b32b71dfcf61807faf
  • 2.0.x default protected
  • 2.0.9.2
  • 2.0.9.1
  • 2.0.9
  • 2.0.8.2
  • 2.0.8.1
  • 2.0.8
  • 2.0.7.2
  • 2.0.7.1
  • 2.0.7
  • 2.0.6.1
  • 2.0.6
  • 2.0.5.4
  • 1.1.9.1
  • 2.0.5.3
  • 2.0.5.2
  • 2.0.5.1
  • 2.0.5
  • 2.0.4.4
  • 2.0.4.3
  • 2.0.4.2
22 results

gcode.cpp

Blame
  • commentsDisplay.js 1.99 KiB
    class commentsDisplay extends HTMLElement {
        constructor() {
            super();
            let path = window.location.pathname;
            let pageName = path.split("/").pop();
    
            let xhr = new XMLHttpRequest();
            xhr.onreadystatechange = () => {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        let comments = JSON.parse(xhr.responseText);
                        comments.forEach((element) => {
                            const h3 = document.createElement("h3");
                            h3.classList.add("commentTitle");
                            h3.innerText = element["name"];
                            this.appendChild(h3);
    
                            const commentDiv = document.createElement("div");
                            commentDiv.classList.add("comment");
                            this.appendChild(commentDiv);
    
                            const image = document.createElement("img");
                            image.src = element["gravatarURL"];
                            commentDiv.appendChild(image);
    
                            const article = document.createElement("article");
                            article.classList.add("commentArticle");
                            commentDiv.appendChild(article);
    
                            const commentText = document.createElement("p");
                            commentText.classList.add("commentText");
                            commentText.innerText = element["comment"];
                            article.appendChild(commentText);
    
                        });
                    } else {
                        let p = document.createElement("p");
                        p.innerText = "Leider konnte dieser Inhalt nicht geladen werden, bitte versuche die Seite neu zu laden oder komme später wieder zurück.";
                        this.appendChild(p);
    
                    }
                }
            }
            xhr.open("GET", "/API/projectComments.php?article=" + pageName);
            xhr.send();
        }
    }
    
    customElements.define("jl-comments_display", commentsDisplay);