Welcome back, my friends, to another lecture today, we're going to limit organize the code, we're
going to clean the code, we're going to write some comments.
We are going to group saw me then listeners, because that's more logical to be like that.
Now, for us to do this, just going to show you, we need to add some comments, what we have done
in like the last lecture.
So because here we are not comments.
It's not I don't want to leave you like that without comments, because with the comments, it's easier
for someone to jump.
Like if you don't work for a week, if you finish it or if somebody else look at you call it will be
a little bit better.
Now, let's write the comments here and I'm going to write the comments here.
I'm going to see each HTML cyesis class names, private OBJ stands for Object right here.
I'm going to put it like this public because this is a public and this is a public method that will
return.
Now, this here return what object with your field data or values
here, it's saying return class name, object, object.
Write this one from top.
How cool is this.
Nice.
Now mean module controller.
We're going to change it to mean module controller.
Same same name just I'm going to be adding capital.
It's looks more organized right at event.
So I'm going to say at the event listener, an event listener and we can just shorten this little bit
witchetty and button call we're going to say at four but we didn't call.
Call now these I will change it to what you said will change it to keep Rense keep RESPA event listener
for a return slash what and Turkey is a Dorji man.
Do this now calling the calories.
I'm not going to do.
You don't need it anymore.
It is now I'm going to see read.
So in actually the calories I'm going to read input data here and here.
I will say add calories.
Function.
Function Fien.
Now as I told you, we need to do something here.
I'm just going to I'm just going to cut this one here.
All of this.
Right.
Just going to cut it and I'm going to create a private function here.
Were making like this war group event.
So I'm going to group the event listeners.
So in future, if we add more, we're going to put it in this group.
So he's going to be a function, no parameters and semicolon there.
And I'm going to paste everything there.
I'm just going to make it a little bit more nicer like that because it wasn't good.
Now we need to call this function from somewhere.
Right, because that is actually not going to work for us.
If it's like this now.
I mean, main controller, this function is a private.
So remember that always everything that is for public, we should return it.
Right.
So I'm going to say return it here.
I'm going to return this function, initialize.
Initialize function and we're going to return this function and it's misspelled initialize.
Now you put it with acid, going to give me a warning.
In Australia we use ask, but you can use Z because that's American English and you will not have that.
Not learning that word correction right now here.
What I want to do is I want to call this one.
I want to return or actually call group event listeners.
I can do that without anything because it's from this function.
Here it is now it's being used.
So console log in.
Let's say Guiseppe.
He's initiated and I'm going to save it now.
We have this function that will call this group the event listeners and let's see what will happen.
It's not going to work, but I just want to show you, all right, it's not going to work.
And this year keeps coming.
Now, it's not going to work.
Why?
It's not going to work because we need this app controller, main main controller.
We need to call it outside.
Remember how we did it before?
So the main app control or actually didn't need to call this function outside, and that is pretty much
it.
Now I want to see.
So if I save it, I haven't save it yet.
So when I say I want here to say the app is initiated, I'm going to save it.
And here it is.
The app is initiated.
Let's check everything if it's working or not.
So I'm just going to go for food.
I'm going to say two to fifty six to fifty enter.
So this is working.
How cool is this exercise.
Burn burn calories like five hundred and fifty.
I'm going to hit.
I'm not going to enter, I'm going to check in here now cuz everything is working so far.
What we have done it is working now.
Let's change this calories module controller.
Module controller and how cool is this UI module controller
controller and what else we can just make it UI like this because it's not professional.
I've done a mistake now where we call this guy here.
Do you remember in the first one.
Oops.
You I controller.
Now this is going to be OK, but let's change this one as well UI.
And here we call it I think we call it again here now I changed the capital I it's better now let's
refresh the AP started.
Let's hope it's not going to crash.
Yeah.
One one working with exercise is going to work.
OK, that's it.
So we've clean up a little bit ago.
We add more meaningful, more meaningful comments, module controller module module pattern and that's
pretty much it.
Next lecture.
We will continue working.
Now, so far we have done a couple of things.
We are able to grab the fields from the form and just show it displayed, return it as an object.
Where was it?
Right.
So if I put it like this, we're going to return it as object.
Also, we group the event listeners.
We initiate the program, same as we did with the starting function for the dice game.
Right now it's better.
So I hope I'm going to see you in the next one.
Enjoy and stay safe.