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

    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
  2. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #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:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #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 Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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 Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #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 Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #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 Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #9
    Lol
     
    Web_Dev_Chris, Jun 16, 2019 IP
  10. gunsnro

    gunsnro Greenhorn

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    13
    #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 Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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 Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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 IP
  13. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #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 IP
  14. Web_Dev_Chris

    Web_Dev_Chris Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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 IP
  15. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #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 IP
  16. Web_Dev_Chris

    Web_Dev_Chris Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #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 IP
  17. Web_Dev_Chris

    Web_Dev_Chris Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #17
    Sorry for my ignorance. I have realised now that a rest api takes a lot of backend work to setup and can writes to a json / file when requests are made by the web server. But this seems like a better option than just writing to a file directly as a rest api will probably be a lot quicker
     
    Web_Dev_Chris, Jun 30, 2019 IP
  18. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #18
    I think you are focusing on the wrong thing. Why are you avoiding using a server side method? Why don't you want to use a database? What do you think are your limitations? I'm not understanding why you are wasting time, brain cells, and energy on focusing on doing something a non-traditional way with absolutely no known benefit or reasoning....
     
    NetStar, Jul 2, 2019 IP