Hello. Recently I made a small application, but it was on several pages, but at the same time I thought that it would be more practical if it was on the same page and the scripts were just synchronously launched and the content in the body changed through

document.body.innerHTML = newBody; 

I have already set up one page out of 2, but since how soon are I going to try to work with the project, is it worth exploring angular and rewriting it? What do you advise on this? is it worth it all the same to leave the replacement body, and podlyuchenie to the contents of the desired script, or angular like will be many times shorter and more practical? The project is in the form of a quick authorization to the site (without registration) and, in the future, the choice of a partner for chatting. thank

  • on the first angular, yes, you can try. On the second anguly, such an unpretentious application to undertake to write does not really make sense, because freyivorki (including angulyar) are intended to simplify the development of medium / large projects - embarq

1 answer 1

Yes, there are no problems. I would make a router (server, not Angulyarovsky), which would give a static index page with connected scripts and angulyar, as well as other routers that accept REST requests, and respond with information in JSON, for example POST requests like /newmessage?receiver=user123344&text=hello+world . And you can make a chat on sockets.

  • I have it on the sockets) everything is there on the sockets) - Horchynskyi
  • If authorization is tied, you can notice% $% # @ c with them, since the server’s default sockets are all the same, they are not defined in the request object req, since this is not the http protocol, but your own over HTTP. You need to know the id of the necessary connections. I can tell you how, if necessary, I have already passed this test. - larrymacbarry
  • for me if it is clear that while experience is not enough and I do not understand much yet) well, look like it is implemented so far. I have one page, when publishing, I immediately ask him a random ID from the server (the server checks for IDs that are already on the date and returns a unique one) then this object flies to the server and is added to the json file — into an array. Then I work cleanly with ID. Someone decided to send a request for a chat - his ID will be cast onto the server (which is initially stored in a variable). Then from the server comes a response with the same ID that is sent, the variable ID and ID are checked from the server, if not the same - return - Horchynskyi
  • and so with all the functionality I have - Horchynskyi
  • Well, this is a simple solution, not protected from the client's point of view. Any client has access to their id, can send a message under the guise of anyone. In addition, when the page is reloaded, another is opened the same or when the page is closed, the session is not saved. As an adult, it would be possible to do it with full authorization and with a database (for example, mongo), instead of a json file. Well, it depends on what task. I myself first wanted to do as you do. - larrymacbarry