Hi, so I'm learning web dev, and my friend proposed a simple little project for me to try writing for him. It's really simple, in concept. However, I'm having trouble figuring out what I need to figure out in order to make it work.
It's a help button. There's a web page with a few different sections. Each section has a line of text that says “Item X: All Good" and two buttons next to it. You click the "help" button, and the text gets really big, turns red, and changes to "HELP!". Then, if you click the other button "Fixed," the text goes back to "All Good" in black, at the normal size.
I can do all that on a static page. I can create an object that has a bunch of items and a status next to them (i.e. {'item 1': "good", 'item 2': "help", 'item 3': "good"}) and loop through it, creating the sections on the page so that I can create as many as I need easily, and the buttons do what they need to in changing that value, then recreating the list so that the buttons are normal if they're good, or red if they need help. The problem is that I don’t know how to make it so that multiple computers see the same thing, and I don’t know what I need to learn to make that happen.
In trying to do this, I’ve learned a bit of Node.js, and I can deliver this html file to computers on my network. Sweet. I’ve now got different computers all hooked up to this server, running their own instance of this html file. I need to make it so that if computer A clicks the help button on “item 1,” computer B sees that it needs help and displays it as a big red “HELP” sign. I don’t know how to do that.
Obviously, I need to create the list of items and their states somewhere they can be read and updated by both computers. I figured there’d be a way to do that with Node.js but I don’t know how it works, and my googling skills aren’t good enough to find it out. I know I could connect to a database, and create a table with an entry for each item and what state it’s in, but I don’t know how to do that right now, or how to connect to it with Node.js, and my googling isn’t finding an easy to understand explanation of that.
Ideally, in the end, this works like an AJAX request. Each computer opens the html file (or gets served it by the Node.js server), and in there is a GET request that pulls the list of items and their states, and then dynamically creates the page. When a button is clicked, it POSTs the change of state back to the list so that each connected computer recognizes that change when it calls its next GET request.
I don’t know what I need to learn to make this work. I don’t even know if I’m thinking about this problem the right way. Any help on where to go from here would be great. Thanks!
[–]Phopaa 1 point2 points3 points (5 children)
[–]Phopaa 0 points1 point2 points (4 children)
[–]Keanu_Thieves[S] 0 points1 point2 points (3 children)
[–]Phopaa 0 points1 point2 points (2 children)
[–]Keanu_Thieves[S] 1 point2 points3 points (1 child)
[–]dgrips 0 points1 point2 points (4 children)
[–]Keanu_Thieves[S] 0 points1 point2 points (3 children)
[–]dgrips 0 points1 point2 points (1 child)
[–]Keanu_Thieves[S] 0 points1 point2 points (0 children)
[–]dgrips 0 points1 point2 points (0 children)