1
00:00:00,300 --> 00:00:05,880
So our task this time around is to make this button check availability on the major sweep page work

2
00:00:05,880 --> 00:00:08,800
the same way that it does on the generals quarters page.

3
00:00:08,820 --> 00:00:09,690
And that's really easy.

4
00:00:09,750 --> 00:00:10,560
So let's get started.

5
00:00:11,880 --> 00:00:16,470
So the simplest thing to do, I'm going to look at the Generals Quarters page, which is right here.

6
00:00:16,950 --> 00:00:21,000
This has a section at the very bottom of the template called Defined Jass.

7
00:00:21,150 --> 00:00:26,790
If you think about it, everything I have in here, with the exception of one character, is exactly

8
00:00:26,820 --> 00:00:29,820
what I need on the major, major sweet page.

9
00:00:30,090 --> 00:00:35,670
And the one character that has to change is this number one, where we append room ID to our form data

10
00:00:35,700 --> 00:00:36,680
that needs to be a two.

11
00:00:37,200 --> 00:00:37,980
So this will work.

12
00:00:38,130 --> 00:00:45,810
I can go over here now to the Majors page, major story page tampoe and replace what's there by pasting

13
00:00:45,810 --> 00:00:46,590
over top of it.

14
00:00:46,620 --> 00:00:49,650
What I just copied from looks that I get it all.

15
00:00:49,650 --> 00:00:54,490
I get an extra character up here that I missed that when I selected it to replace it.

16
00:00:55,080 --> 00:00:59,550
So now this is correct, except for this one, which becomes a two.

17
00:00:59,880 --> 00:01:06,030
So if I save that and go back over to my major sweep page, reload the page and check availability,

18
00:01:06,060 --> 00:01:06,810
this should work now.

19
00:01:06,810 --> 00:01:13,700
So I'll choose from the 27th to the 28th, which is a date I have verified beforehand is available.

20
00:01:13,740 --> 00:01:17,580
This should show rooms available and it does.

21
00:01:17,820 --> 00:01:18,680
And that works really well.

22
00:01:19,380 --> 00:01:26,310
Now, at least some of you, at least hopefully some of you have thought about this in this page Meijers

23
00:01:26,310 --> 00:01:26,670
page.

24
00:01:26,670 --> 00:01:32,970
I have all this JavaScript, which is pretty much identical except for one character to what I have

25
00:01:32,970 --> 00:01:35,790
here on the majors, on the general page.

26
00:01:36,420 --> 00:01:42,150
Wouldn't it make more sense to take the contents of this, everything from say here all the way down

27
00:01:42,150 --> 00:01:47,970
to here and create a function just by wrapping all of that with a function tag, giving it a name,

28
00:01:48,330 --> 00:01:53,700
putting it somewhere where it's available to all of the pages that need it and then just call that function.

29
00:01:53,700 --> 00:01:58,140
And when I'm calling it from the generals page, I could call it with an idea of one one I'm calling

30
00:01:58,140 --> 00:02:00,750
it from the majors page, I can call it with a remedy of two.

31
00:02:00,750 --> 00:02:02,400
And that is absolutely right.

32
00:02:02,400 --> 00:02:03,840
And I encourage you to do that.

33
00:02:04,110 --> 00:02:06,870
As a matter of fact, I'm going to leave that as an exercise for you.

34
00:02:07,230 --> 00:02:11,250
But to get you started, there is one change I'm going to make right now, and this will point you in

35
00:02:11,250 --> 00:02:11,940
the right direction.

36
00:02:13,050 --> 00:02:20,220
This is my base layout and base layout has this prompt I'm going to add prompt doesn't need to be part

37
00:02:20,220 --> 00:02:20,880
of the layout.

38
00:02:20,880 --> 00:02:23,960
I said a while ago you typically import JavaScript modules.

39
00:02:24,150 --> 00:02:26,550
This is quite a while ago when we were talking about JavaScript.

40
00:02:27,240 --> 00:02:32,160
What I'm going to do now is I'm going to create over in my static folder a new directory.

41
00:02:32,560 --> 00:02:35,250
I'm going to call that JS for JavaScript.

42
00:02:35,610 --> 00:02:42,960
Inside of that, I'll create a new file, which I will call Abdah Jazz, OK, and I will add that to

43
00:02:42,960 --> 00:02:45,930
my git repository and I'm going to paste in.

44
00:02:46,410 --> 00:02:48,090
Oops, I got the wrong thing there.

45
00:02:48,390 --> 00:02:53,670
I am going to copy my entire prompt JavaScript module.

46
00:02:53,820 --> 00:02:54,600
I'll cut it out of there.

47
00:02:54,780 --> 00:02:56,500
I'll cut it out of my base layout.

48
00:02:56,640 --> 00:03:02,430
I don't want to copy it and only two versions of it and paste it into ABC's and save this.

49
00:03:02,580 --> 00:03:07,890
And then instead of having it written right into the base template, I'll just import it like I do.

50
00:03:07,890 --> 00:03:19,500
All these other JavaScript libraries script source equals and it's static jazz act jazz and close my

51
00:03:19,500 --> 00:03:20,070
script tag.

52
00:03:20,670 --> 00:03:27,900
And if I did everything right, when I go back to my web browser, I can reload this page and it should

53
00:03:27,900 --> 00:03:33,720
work and it appears to so 27 to 28 and the room is available.

54
00:03:33,720 --> 00:03:34,260
Perfect.

55
00:03:35,400 --> 00:03:40,590
So what I've given you or what I've pointed you in the direction of is application javascript that I

56
00:03:40,590 --> 00:03:44,250
want available to every page of my application, at least every public page.

57
00:03:44,250 --> 00:03:46,170
We might have a different one for a back end.

58
00:03:46,170 --> 00:03:48,240
When we get to the back end, we'll look at that.

59
00:03:48,240 --> 00:03:54,780
But right now, here is a place where you could take this everything that you see at the bottom of the

60
00:03:55,170 --> 00:04:01,020
page and everything that you see at the bottom of the majors page starting right after the opening script

61
00:04:01,020 --> 00:04:01,380
tag.

62
00:04:01,770 --> 00:04:09,960
Take that and or at least as much of it as you need and create a function that you can call in a much

63
00:04:09,960 --> 00:04:14,370
smaller amount of JavaScript from the majors page and from the generals page.

64
00:04:14,550 --> 00:04:21,210
And since everything is the same on these two pages, except for this one character right here, it's

65
00:04:21,210 --> 00:04:24,150
a one four generals quarters and a two for the major suite.

66
00:04:24,750 --> 00:04:26,430
You know, you only have to pass one parameter.

67
00:04:26,640 --> 00:04:28,740
So if you want to do that, I encourage you to do it.

68
00:04:28,740 --> 00:04:31,320
It will be great practice and great exercise.

69
00:04:31,470 --> 00:04:33,210
I'm not going to do it for you right now.

70
00:04:33,360 --> 00:04:34,770
I might do it later in the course.

71
00:04:34,950 --> 00:04:40,530
But at the moment, I think it's time to move on and work on our testing a bit more to update our tests

72
00:04:40,830 --> 00:04:42,750
because they are starting to get out of date.
