Sascha Schulz
2023-04-05 c23799c63bc96a26f277f4d734abedc528f1306e
merge draft
2 Dateien geändert
2 Dateien hinzugefügt
398 ■■■■■ Geänderte Dateien
assets/images/document.write.jpg Patch | Ansicht | Raw | Blame | Historie
assets/images/osi-model.jpg Patch | Ansicht | Raw | Blame | Historie
dist/theme/night-custom.css 9 ●●●● Patch | Ansicht | Raw | Blame | Historie
index.html 389 ●●●●● Patch | Ansicht | Raw | Blame | Historie
assets/images/document.write.jpg
assets/images/osi-model.jpg
dist/theme/night-custom.css
@@ -32,6 +32,7 @@
  --r-heading3-size: 1.55em;
  --r-heading4-size: 1em;
  --r-code-font: monospace;
  --r-code-font-size: 16px;
  --r-link-color: #e7ad52;
  --r-link-color-dark: #d08a1d;
  --r-link-color-hover: #f3d7ac;
@@ -229,6 +230,12 @@
  overflow: auto;
  max-height: 400px;
  word-wrap: normal;
  font-size: var(--r-code-font-size);
}
.reveal em.h {
  font-weight: bold;
  color: red;
}
.reveal .code-wrapper {
@@ -366,4 +373,4 @@
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
}
}
index.html
@@ -27,14 +27,15 @@
                        <h3>Grundlagen</h3>
                        <ul>
                            <li>HTML/CSS/JS</li>
                            <li>JSON</li>
                            <li>HTTP-Protokoll</li>
                            <li>JSON</li>
                            <li>Debugger</li>
                        </ul>
                    </section>
                    <section>
                        <h3>Fortgeschrittenes</h3>
                        <ul>
                            <li>JavaScript</li>
                            <li>NodeJS</li>
                            <li>Responsive Design</li>
                            <li>CSS-Animationen</li>
@@ -498,29 +499,18 @@
                        </table>
                    </section>
                    <section>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                <script type="text/template">
                                    <!DOCTYPE html>
                                    <html lang="de">
                                        <head>
                                            <meta charset="UTF-8">
                                        </head>
                                        <body>
                                            <!-- code -->
                                        </body>
                                    </html>
                                </script>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Code wird zwischen <code>script</code>-Tags geschrieben</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                <script>
                                    ...
                                </script>
                                &lt;!DOCTYPE html>
                                &lt;html lang="de">
                                    &lt;head>
                                        &lt;meta charset="UTF-8">
                                    &lt;/head>
                                    &lt;body>
                                        &lt;script>// code&lt;/script>
                                    &lt;/body>
                                &lt;/html>
                            </code>
                        </pre>
                    </section>
@@ -549,6 +539,363 @@
                        </pre>
                    </section>
                </section>
                <section>
                    <section>
                        <h2>Auslagern in verschiedene Dateien</h2>
                    </section>
                    <section>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                &lt;!DOCTYPE html>
                                &lt;html>
                                    &lt;head>
                                        <!-- CSS -->
                                        <link href="styles.css" rel="stylesheet">
                                    &lt;/head>
                                    &lt;body>
                                        <!-- JS -->
                                        &lt;script src="index.js">&lt;/script>
                                    &lt;/body>
                                &lt;/html>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Parsen eines HTML-Dokuments</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers="1|2|3|4|5|6|7|8|9|10">
                                <script type="text/template">
                                    <!DOCTYPE html>
                                    <html lang="de">
                                        <head>
                                            <meta charset="UTF-8">
                                            <title>Coole Seite 😀</title>
                                        </head>
                                        <body>
                                            <div>Ganz langer Text</div>
                                        </body>
                                    </html>
                                </script>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Verschiedene Varianten, JavaScript erst am Ende auszuführen</p>
                        <p>Damals mit jQuery:</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                &lt;!DOCTYPE html>
                                &lt;html>
                                    &lt;head>
                                        &lt;script>
                                            $(document).ready((event) => {
                                                const element = document.querySelector("#hello");
                                            });
                                        &lt;/script>
                                    &lt;/head>
                                    &lt;body>
                                        <div id="hello">Hello World!</div>
                                    &lt;/body>
                                &lt;/html>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p><code>script</code>-Tag am Ende</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                &lt;!DOCTYPE html>
                                &lt;html>
                                    &lt;head>
                                    &lt;/head>
                                    &lt;body>
                                        <div>Hello World!</div>
                                        ...
                                        &lt;script src="index.js">&lt;/script>
                                    &lt;/body>
                                &lt;/html>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Event-basiert, z.B. per DOMContentLoaded</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                &lt;!DOCTYPE html>
                                &lt;html>
                                    &lt;head>
                                        &lt;script>
                                            document.addEventListener("DOMContentLoaded", (event) => {
                                                // wird ausgeführt, sobald das Dokument geparst wurde
                                                const element = document.querySelector("#hello");
                                            });
                                        &lt;/script>
                                    &lt;/head>
                                    &lt;body>
                                        <div id="hello">Hello World!</div>
                                    &lt;/body>
                                &lt;/html>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Moderne Variante</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                &lt;script src="index.js" defer>&lt;/script>
                            </code>
                        </pre>
                    </section>
                    <section>
                        <h2><code>document</code>-Operationen</h2>
                        <pre>
                            <code class="js" data-trim data-line-numbers>
                                document.open();
                                document.write("<div>Booo!</div>");
                                document.close();
                            </code>
                        </pre>
                    </section>
                    <section>
                        <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/write">
                            <img data-src="/assets/images/document.write.jpg">
                        </a>
                    </section>
                    <section>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                &lt;body>
                                    &lt;script>document.write("<p>Dies ist ein Text.</p>")&lt;/script>
                                    <button>Dunkle Magie</button>
                                    &lt;script>
                                        const button = document.querySelector("button");
                                        button.addEventListener("click", () => {
                                            document.write("Und pfutsch!");
                                        });
                                    &lt;/script>
                                &lt;/body>
                            </code>
                        </pre>
                    </section>
                </section>
                <section>
                    <section>
                        <h2>HTTP-Protokoll</h2>
                    </section>
                    <section>
                        <img data-src="/assets/images/osi-model.jpg">
                    </section>
                    <section>
                        <ul>
                            <li>OSI-Schichten 5, 6 und 7</li>
                            <li>Anfrage-Antwort-Prinzip</li>
                            <li>Basiert auf einfachem Text</li>
                        </ul>
                    </section>
                    <section>
                        <table>
                            <tr><th>Version</th><th>Jahr</th></tr>
                            <tr><th>0.9</th><th>1991</th></tr>
                            <tr><th>1.0</th><th>1996</th></tr>
                            <tr><th>1.1</th><th>1999</th></tr>
                            <tr><th>2.0</th><th>2015</th></tr>
                            <tr><th>3.0</th><th>2022</th></tr>
                        </table>
                    </section>
                    <section>
                        <p>Request an www.google.de</p>
                        <pre>
                            <code class="http" data-trim data-line-numbers>
                                GET / HTTP/1.1
                                Host: www.google.de
                                User-Agent: curl/7.88.1
                                Accept: */*
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Response von www.google.de</p>
                        <pre>
                            <code class="http" data-trim data-line-numbers>
                                HTTP/1.1 200 OK
                                Date: Tue, 04 Apr 2023 15:45:26 GMT
                                Expires: -1
                                Cache-Control: private, max-age=0
                                Content-Type: text/html; charset=ISO-8859-1
                                Content-Security-Policy-Report-Only: [...]
                                Server: gws
                                X-XSS-Protection: 0
                                X-Frame-Options: SAMEORIGIN
                                Set-Cookie: [...]
                                Accept-Ranges: none
                                Vary: Accept-Encoding
                                Transfer-Encoding: chunked
                                &lt;!doctype html&gt;&lt;html&gt;...&lt;/html&gt;
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Einfach mal testen:</p>
                        <pre>
                            <code class="bash" data-trim data-line-numbers>
                                curl -v --http1.0 http://www.google.de
                                curl -v --http1.1 http://www.google.de
                                curl -v --http2 http://www.google.de
                                curl -v --http2-prior-knowledge http://www.google.de
                                curl -v --http3 http://www.google.de
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Verschiedene "Verben" bzw. "Methoden"</p>
                        <ul>
                            <li>GET</li>
                            <li>POST</li>
                            <li>PUT</li>
                            <li>PATCH</li>
                            <li>DELETE</li>
                            <li>...</li>
                        </ul>
                    </section>
                    <section>
                        <p>Beispiel:</p>
                        <pre>
                            <code class="bash" data-trim data-line-numbers>
                                git clone https://git.furnco.de/r/public/web-development/examples.git
                                cd examples/templates/005-http-rest
                                node index.js
                            </code>
                        </pre>
                    </section>
                    <section>
                        <pre>
                            <code class="text" data-trim data-line-numbers>
                                curl -X GET -is http://localhost:3000/todo
                                curl -X POST -H "Content-Type: application/json" -d '{"name": "Einkaufen"}' -is http://localhost:3000/todo
                                curl -X POST -H "Content-Type: application/json" -d '{"name": "Putzen"}' -is http://localhost:3000/todo
                                curl -X PUT -H "Content-Type: application/json" -d '{"name": "Schlafen"}' -is http://localhost:3000/todo/1
                                curl -X DELETE -is http://localhost:3000/todo/0
                            </code>
                        </pre>
                    </section>
                    <section>
                        <pre>
                            <code class="text" data-trim data-line-numbers>
                                HTTP/1.1 200 OK
                                X-Powered-By: Express
                                Content-Type: application/json; charset=utf-8
                                Content-Length: 13
                                ETag: W/"d-KMmUcQ1kigqtwzZnU+jVDkYP3Co"
                                Date: Wed, 05 Apr 2023 12:05:05 GMT
                                Connection: keep-alive
                                Keep-Alive: timeout=5
                                ["Einkaufen"]
                            </code>
                        </pre>
                    </section>
                    <section>
                        <pre>
                            <code class="js" data-trim data-line-numbers="">
                                app.get("/todo", (req, res) => {
                                    return res.json(todos);
                                });
                                // [...]
                                app.post("/todo", (req, res) => {
                                    // [...]
                                        return res.json(todos);
                                    // [...]
                                });
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p><code>GET</code> und <code>POST</code> auf klassischen Webseiten</p>
                        <pre>
                            <code class="html" data-trim data-line-numbers>
                                <form method="post" action="/todo">
                                    <input name="todo"><button>add</button>
                                </form>
                            </code>
                        </pre>
                        <p>Beispiel:</p>
                        <pre>
                            <code class="bash" data-trim data-line-numbers>
                                cd examples/templates/006-http-web
                                node index.js
                            </code>
                        </pre>
                    </section>
                </section>
                <section>
                    <section>
                        <h3>JSON</h3>
                    </section>
                    <section>
                        <ul>
                            <li><em class="h">J</em>ava<em class="h">S</em>cript <em class="h">O</em>bject <em class="h">N</em>otation</li>
                            <li>Basiert auf reinem Text</li>
                            <li>Format zur strukturierten Speicherung von Daten</li>
                            <li>Attribute müssen immer in doppelte Anführungsstriche (<code>"</code>) gesetzt werden</li>
                        </ul>
                    </section>
                    <section>
                        <p>Definition eines einfachen Objekts in JS</p>
                        <pre>
                            <code class="js" data-trim data-line-numbers>
                                const o = {
                                    x: 1,
                                    y: 2
                                };
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Entsprechung in JSON</p>
                        <pre>
                            <code class="js" data-trim data-line-numbers>
                                {
                                    "x": 1,
                                    "y": 2
                                }
                            </code>
                        </pre>
                    </section>
                    <section>
                        <p>Mögliche Typen</p>
                        <p>
                            <ul>
                                <li>Number (bzw. Integer / Float)</li>
                                <li>Boolean</li>
                                <li>String</li>
                                <li>Array</li>
                                <li>Object</li>
                            </ul>
                        </p>
                    </section>
                    <section>
                        <p>Der äußere Container kann ein Array oder ein Object sein</p>
                        <pre>
                            <code class="js" data-trim data-line-numbers>
                                {
                                    "key": "value",
                                }
                            </code>
                        </pre>
                        <pre>
                            <code class="js" data-trim data-line-numbers>
                                [
                                    "foo",
                                    "bar"
                                ]
                            </code>
                        </pre>
                    </section>
                </section>
            </div>
        </div>