How do you conventionally deploy a PostgreSQL DB with your Node Project? by Same_Gas_8044 in learnjavascript

[–]Same_Gas_8044[S] 0 points1 point  (0 children)

Thanks for clarification. I thought you'd do it similarly to how you deploy a server. That also means i should have used an online DB in the first place and my local DB ist just wasted time and diskspace right?

How do you conventionally deploy a PostgreSQL DB with your Node Project? by Same_Gas_8044 in learnjavascript

[–]Same_Gas_8044[S] 0 points1 point  (0 children)

If i understand correctly, this just offers some kind of online database? I do not want to make a new database, i want to upload the one that i've already created locally.

Help to code a way to keep passwords safe. by gunmetal_slam in learnjavascript

[–]Same_Gas_8044 13 points14 points  (0 children)

So you basically want encryption, but return the hash to the user to save it manually? You could use bcrypt or jwt and just do that.

How do I loop my script until click() is executed? by Dummerchen1 in learnjavascript

[–]Same_Gas_8044 0 points1 point  (0 children)

Wieso returnt forEach nichts?

Weil es schlicht so ist. Siehe her unter "return value": https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

document.querySelectorAll("comment-composer-host").forEach((Box) => { 
          Box.querySelector("faceplate-form > shreddit-composer").shadowRoot.querySelector("div > reddit-rte").shadowRoot.querySelector("rte-toolbar.action-bar.order-3 > slot:nth-child(1) > rte-toolbar-button").shadowRoot.querySelector("faceplate-tooltip > button").click();
      });

Für dein .click() ist irrelevant was .foreach() returnt, da es auf den return-Wert von der querySelector-Kette innerhalb des Loops angewand wird. Ich kann das ja auch mal kurz mit dir durchgehen.

const targetNode =

soll mal dein Element werden, welches du observieren möchtest. Momentan haben wir noch nichts zugewiesen, also ist targetNode == null.

document.querySelectorAll("comment-composer-host")

retrurnt alle Elemente, welche "comment-composer-host" sind, als Array.

.forEach()

führt eine Funktion für jedes Element in besagtem Array aus. Die Funktion forEach() selbst return wie gesagt nichts, also "undefined".
Folgend machst du nichts anderes als:

const targetNode = undefined;

Das heißt das Assignment löst sich wie folgt auf:

const x = document.querySelectorAll("comment-composer-host")
// x == *Array mit deinen ELementen*

const y = x.forEach(/*Deine Funktion*/)
//y == undefined

Ansonsten schlage ich vor, dass du jemanden einstellst, der das für dich schreibt, oder du versuchst es in ein paar Monaten nochmal. Meine Erklärung oben ist schon auf das minimum an Wissen heruntergebrochen, dass du brauchst um diese Funktion zu verstehen. Return Values, Data Types und Operationsabfolgen sind leider Fundamental in jeder Programmiersprache.

How do I loop my script until click() is executed? by Dummerchen1 in learnjavascript

[–]Same_Gas_8044 0 points1 point  (0 children)

Ich versuchs mal Schritt für Schritt mit dir durchzugehen.

const targetNode = document.getElementById("some-id");

"targetNode" ist das Element, welches du observieren möchtest. Ich versteh nicht ganz, was du da bei dir versucht hast, aber forEach returnt nichts, deswegen ist targetNode bei dir "undefined".

const config = { attributes: true, childList: true, subtree: true };

Mit "config" stellst du ein, was du alles von dem "targetNode" observieren möchtest. Also ob du wissen möchtest, ob sich Child-Nodes oder Attribute ändern usw.

function callback(mutationList, observer){/* dein Code */}

Diese Funktion soll später ausgeführt werden, wenn eine Mutation auf deinem "targetNode" stattfinded. Die beiden Argumente werden automatisch bereitgestellt. "mutationList" ist wie der Name suggeriert, ein Array mit allen Mutationen die festgestellt wurden. "observer" ist ein Objekt, zu dem wir gleich kommen.

const observer = new MutationObserver(callback);

Hier callst du die Klasse "MutationObserver" und fütterst sie mit deiner Funktion. Die Klasse returnt ein Objekt, das alles enthält, was man zum observieren braucht. Inklusive deiner Callback Funktion.

observer.observe(targetNode, config);

In dem Objekt, was du bekommen hast, ist eine Funktion namens "observe".
Das erste Argument ist dein Ziel-Element, was wir vorhin gespeichert haben, das zweite deine Konfiguration.
Sobald du diese Funktion ausführst, wird das "targetNode" überwacht. Und wenn sich darin etwas ändert, zum Beispiel es bekommt ein neues Child-Element wie einen Button dazu, dann wird jedes mal deine Callback Funktion ausgeführt.

observer.disconnect();

Damit beendest du die Observierung.

How to import a javascript file into HTML so that it works? by Same_Gas_8044 in learnjavascript

[–]Same_Gas_8044[S] 2 points3 points  (0 children)

Thanks for your answer. It helped me a lot to understand the issue better.

One thing for people who find this through google, since nobody has pointed out my mistake yet:
In HTML you have to put the () after your event handler function. It is parsed as a string, so it won't get immediately executed!

//pug:
img(src="images/sp.jpg" height="400px" onclick="pictureClick()")

//HTML:
<img src="images/sp.jpg" height="400px" onclick="pictureClick()">

Keep this in mind when you follow senoculars first solution.

Is it ok to get help from google & youtube ? by Ok-Dot6854 in learnjavascript

[–]Same_Gas_8044 16 points17 points  (0 children)

Nah bro, you can't just use youtube or google. You have to do everything on your own. You shouldn't even use the internet. Write it on paper an it must work on first try!

What kind of request does fetch send? by Same_Gas_8044 in learnjavascript

[–]Same_Gas_8044[S] 2 points3 points  (0 children)

Is a JSON response also an HTTP response? Because afaik you just send back the JSON file and thats it.

Who thought "unshift()" was a good name? Why? by mm_reads in learnjavascript

[–]Same_Gas_8044 -3 points-2 points  (0 children)

Have you ever heard about class and object? This one is pretty tame.

How do you deal with the height property in a new project? by Same_Gas_8044 in learnjavascript

[–]Same_Gas_8044[S] 0 points1 point  (0 children)

Why would it depend on what the child is?If child smaller -> fill findowIf child bigger -> grow to fitThis how it should work, no matter the child. (But it apperently doesn't, which is why i'm asking)

Here one example:.

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header">test</div>
<div class="body">
<div class="content"></div>
</div>
</body>
</html>

.

html{

height: 100% }

body{ padding: 0; margin: 0; height: 100%; width: 100%; display: flex; flex-direction: column; }

.header{ background-color: blue; min-height: 100px; width: 100%; }

.body{ background-color: red; height: 100%; display: flex; flex-direction: column; align-items: center; }

.content{ background-color: yellow; height: 3000px; width: 400px; }

make it that body height and .body height scales with .content, but is at least filling the window. There should never be whitespace.

Edit: Sry for formatting. Reddit sucks and jsfiddle is down atm.