If strong bad code?

I have 10 lines written to the system events.
Events.Add("PageSkeleton", function (data) {
 if (!data) {
 Page.Load('logo', '/page/incl/logoNotAuth.html');
 Page.Load('footermenu', '/page/incl/footerNotAuth.html');
 } else {
 Page.Load('logo', '/page/incl/logo.html');
 Page.Load('footermenu', '/page/incl/footer.html');
//load the start page
Events.Call("PageSkeleton", false)
Page.Load('page', '/page/index.html');

I create all the events in 1 place, and then call them anywhere in your code. Instead of intercept a click on the link (for the url) I stupidly hang onclick which cause an event, and some events cause other events, etc. the Code is expressive yet (perhaps the situation will worsen when a couple of thousand events).

What do you say?

My auditre 80% of bricks that can't trendit spa frameworks for this have done so.
July 9th 19 at 13:38
2 answers
July 9th 19 at 13:40
This would work sooooo slow. View in the direction of the client salanization, which initially considers all of the logic, and then 1(!) the passage will stick on the page all that is needed. How to understand the role salanization, look in the direction of the client libraries to implement the SPA, like a Backbone, and there you look and to the serious frameworks (Ember, Angular) close.
all that stuff does not work in all opera mini... And it 80% with bricks - Reta76 commented on July 9th 19 at 13:43
: well, take what is easier, backbone. There it will work. - Rex.Bayer90 commented on July 9th 19 at 13:46
: Also, you put the wrong priority. First of all you have to ensure the normal experience people in normal browsers, and only then, make some mini stripped-down version for users of Opera mini. - Rex.Bayer90 commented on July 9th 19 at 13:49
: I have 80% of Opera mini. backbone not working there "normal" - Reta76 commented on July 9th 19 at 13:52
: now optimized code. Loader pages in a template can replace the variables (using regexps) - Reta76 commented on July 9th 19 at 13:55
July 9th 19 at 13:42
1. Create a state diagram based on the SPA data and page block.
2. Form the dependency tree for these conditions.
3. Create a "brain" ("router") on the basis of this tree in json format: URL, event list, and so on.
4. Put him in the main container SPA and make the transition to the next state SPA, json: current => one of the following or previous (for "tree")
Thus, You have the immediate formation of the desired pattern with the events, etc.
thank you - Reta76 commented on July 9th 19 at 13:45

Find more questions by tags JavaScript