1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Simple Chat Web App Idea

Discussion in 'Programming' started by Web_Dev_Chris, Jun 11, 2019.

  1. #1
    Hi,

    The idea is to get a fully functional chat app using nothing but a text file on a server, AJAX and localStorage.

    This is my idea:

    Simple Chat App
    SEMrush
    Https connection
    Server: text file.

    Code:
    Ajax to update the text file.

    On send execute a function

    Function

    • Override the contents of the text file.
    • Pull the contents of the text file onto the webpage.
    • Store the content to localStorage.


    Would this work?

    Regards,
    Chris
     
    Web_Dev_Chris, Jun 11, 2019 IP
    SEMrush
  2. NetStar

    NetStar Notable Member

    Messages:
    2,169
    Likes Received:
    443
    Best Answers:
    21
    Trophy Points:
    215
    #2
    So basically instead of using a database like mySQL you will be using a flat file database system.. sure it will work... It will require your script to open/read/write/lock a text file over and over and over again. And there's certainly room for quirks if it ever gets busy however I wouldn't advise doing so. The amount of code and complexity would be the same to do it a more efficient way with a database like mySQL. And faster. Why this approach if I may ask?
     
    NetStar, Jun 15, 2019 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    24,964
    Likes Received:
    3,392
    Best Answers:
    99
    Trophy Points:
    615
    #3
    Why?
    Interesting programming exercise but I don't see the point. Web only, for communicating with customers?

    There's always room for competition, we can't let zendesk etc have complete control, but what is it that they don't do that you need?
     
    sarahk, Jun 15, 2019 IP
  4. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #4
    I guess the idea is to keep it as simple as possible. I’m quite new to programming wth few projects up my sleeve and I’m really just doing it for fun and to mess around.

    I realised I couldn’t use AJAX to write to the server. It will have to either be PHP or NodeJS.

    nguess the
     
    Web_Dev_Chris, Jun 16, 2019 IP
  5. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #5
    Well as a web developer I am quite ambitious and would not like to use other peoples products including zen desk.

    I’ve got some good ideas. Including to build a better wysiwyg editor than CKEDITOR.

    - One that incorporate the google font api so there is a limitless selection of fonts with real time preview through AJAX.
    - More customised features such as ability to colour very specific such as a colour picker or ability to add hex code or rgb ect...
    - More of a Microsoft word interface.

    But yeah that’s down the road...But yeah that’s out of context.

    Basically I wouldn’t use a system like this to communicate with customers. Maybe just a fun chat room on the web or something if it work well or to chat with friends.

    I can fiddle with it or test it. Because I’m new to programming. It’s more of a curious thing and project to put my skills to the test.



     
    Web_Dev_Chris, Jun 16, 2019 IP
  6. NetStar

    NetStar Notable Member

    Messages:
    2,169
    Likes Received:
    443
    Best Answers:
    21
    Trophy Points:
    215
    #6
    As a web developer you should recognize when you are reinventing the wheel... especially if you are new and that wheel will look more like a square.... It's best to find a solution that exists and make the necessary changes.
     
    NetStar, Jun 16, 2019 IP
    sarahk likes this.
  7. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #7
    Yeah, good point. However, I’m keen on using what other people have build to help. For example the Elemental JS library is fantastic. Also Perch CMS is fantastic.
     
    Web_Dev_Chris, Jun 16, 2019 IP
  8. sarahk

    sarahk iTamer Staff

    Messages:
    24,964
    Likes Received:
    3,392
    Best Answers:
    99
    Trophy Points:
    615
    #8
    That's good, that's how you become a better coder and system analyst
    You get the irony, right?
     
    sarahk, Jun 16, 2019 IP
  9. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #9
    Lol
     
    Web_Dev_Chris, Jun 16, 2019 IP
  10. gunsnro

    gunsnro Greenhorn

    Messages:
    23
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    8
    #10
    Is this just as an exercise or do you plan to use it somewhere?
     
    gunsnro, Jun 17, 2019 IP
  11. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #11
    Well, it is an exercise but I’ll still deploy it on my project page so I would expect good performance out of it.

    I will use NodeJS for the backend.
     
    Web_Dev_Chris, Jun 19, 2019 IP
  12. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #12
    Ok this is just a thought but I’m going to need feedback.

    Instead of writing to the server with NodeJS what if I could do it all through JavaScript by storing to data in a rest api and have JavaScript access and delete the data. Obviously there would be a lot of thought into the algorithm but would this work.

    It’s like a a hybrid server less solution.
     
    Web_Dev_Chris, Jun 21, 2019 at 1:42 AM IP
  13. sarahk

    sarahk iTamer Staff

    Messages:
    24,964
    Likes Received:
    3,392
    Best Answers:
    99
    Trophy Points:
    615
    #13
    Where's the javascript going to save it to?
    If it's on the server it needs some sort of script to "catch" it - perl, python, php, ruby...

    Local storage saves it in your browser but won't pass it to the other person's browser.
     
    sarahk, Jun 22, 2019 at 3:32 AM IP
  14. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #14
    Ok so this is what I was thinking.

    I have to put more thought into it, but the JavaScript will push it to a rest api which is stored in JSON format. Than in that script AJAX accesses the api JSON object and pulls it into the browser

    Because through JavaScript you can directly modify, post and delete to a rest api correct?

    Every time a message is posted:
    • When user puts there name into chat app - new object is created which is to be pushed through to a rest API. to store name and message.
    • JavaScript posts message to REST api as a JSON object
    • Ajax to pull object to the screen - since screen is updated real-time all users will see.
    • the message is then saved to local storage - for future history ect… or when re-visiting chat app.
    • The next message posted updates that JSON object through javascript - repeat from step two.
    • when user session is finished the javascript object is deleted and javscript will remove the JSON object from the rest API

    Each user on the chat can have their own random javscript object and it being update as explained above. And on exiting of the session the particular JSON object is destroyed and when reconnecting the chat app a new one is created for the user.

    Just a thought. Would it work without getting NodeJS involved?

    I haven't tested this yet because I haven't yet deployed my REST API. But really keen on experimenting.

    Regards,
    Chris
     
    Web_Dev_Chris, Jun 22, 2019 at 8:02 AM IP
  15. sarahk

    sarahk iTamer Staff

    Messages:
    24,964
    Likes Received:
    3,392
    Best Answers:
    99
    Trophy Points:
    615
    #15
    REST is a concept, it's not actually a script doing anything.
    Something has to be doing some work on the server.
     
    sarahk, Jun 23, 2019 at 3:52 PM IP
  16. Web_Dev_Chris

    Web_Dev_Chris Active Member

    Messages:
    164
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    78
    #16
    Hi even if it’s a concept wouldn’t the app still work if the data is being posted to rest api and then retrieved back on the page through AJAX?

    We’re still storing the data outside the webpage and retrieving it. Wouldn’t it be similar to writing to a file on the server and then retrieving the contents to be displayed on the webpage.

    Correct me if I’m wrong.
     
    Web_Dev_Chris, Jun 23, 2019 at 4:18 PM IP