- [Instructor] So let's work on our project
a little bit more.
And what I'm going to show you is a couple of little
tips and tricks.
I'm going to show you how to start up a window
after a certain amount of time
and then automatically close it.
And I'll show you how to also maximize a window.
So in addition to all the goodness that you get
when creating a browser window there's actually
additional methods that you can use to control
what the windows are doing.
So you've seen one here.
We can say that a window needs to load a specific file.
But we can execute additional commands
at different points in our application.
So what I'm going to show you is how first
to maximize a window.
So right now if I execute my project you can see
that this window appears at whatever size
I specified with the width and height.
But sometimes you want this window
to be maximized to the full size of the screen
so there is actually a method that allows you
to take care of that.
So let's go ahead and add that when we're showing
the window right here for the application
we can choose to maximize that window as well.
So let's take a look at that app window
and then we'll run the maximize method.
And I'll try again running the NPM start command.
And you can see that now the window maximizes
to the size of the screen.
You did get a little bit of an animation
and sometimes you don't really want that animation.
So what you can do is actually pre-maximize the window.
So let me go ahead and get out of there
and let's close the terminal for right now.
So what I can do is actually put the maximize
method before the window shows and then I'm going
to run that command again.
And you can see that now the window appears
and it's already maximized.
So, you know, either way I think is fine
depending on whether or not you want
the animation to play.
So the next thing I want to show you is how
to create a sort of timer so that this
about BinaryVille doesn't appear right away
but it waits until the one window loads,
and then it appears a few seconds afterwards
and then it goes away.
You've seen that in a lot of applications,
you know, a window will pop up and kind of show you
something and then it will hide itself.
So let's take a look at that.
Let's kind of close this out.
And to do that it's actually going to be pretty
much straight-up JavaScript.
We're going to ask, after we show
the regular window, we're going to ask
this application to set a timeout.
And we're going to show this about window
after that timeout takes place.
So we're going to add maybe a second for that timeout.
So now that window is not going to show up
and after a second, and you could make that.
So let's check that out.
Let's pull up this again.
Let's clear this out.
Run NPM start.
And now you can see that the window appeared
kind of in the background and then
it sort of disappeared, and then it showed again.
So that means that our window is actually
not showing when it first gets created.
So remember we issued this show false command here.
We'll need to do that as well right here
so that window doesn't show.
Let's test that out.
Now the window doesn't show, a second passes
and then this other window shows.
And now what I want to do is get rid of that window
after a few seconds.
So let's go ahead and quit again, close this out.
And all we need to do for that is set up
another timeout inside here.
So I'm just going to copy this one and then
what I'll do is set another timeout in here.
And instead of showing that I will hide it.
And we'll let people have enough time to read
what's in the about window.
So we'll go ahead and put three seconds,
so 3,000 milliseconds.
Timeouts are always in milliseconds.
So let's go ahead and save that.
Clear this out, NPM start.
And you'll wait a second, that window appears,
gives you enough time to hopefully read that,
and then after a period of time it disappears.
So there are a lot of different methods
and things that you can do with windows.
In addition to using browser window to sort
of control how windows look, you have the ability
to create methods that at any point in time
control what the window is doing.
So it's events, browser windows, and methods
that's going to make your application appear very rich.