Object Oriented JavaScript Set up (HTML/CSS)
Although we will be working with DreamWeaver it really doesn't mater you should work with what ever tool you feel comfortable working with. This title isn't intended for totally new users but instead its intended for students that completed our getting started with JavaScript titles. If you are totally new to JavaScript you should stop right now and move to our earlier titles. In this first video we will build out the basic html file we will be working with for the remainder of our class. By the end of this video we will have a HTML page with CSS and our linked JavaScript files.
Video Transcript
00:00All right, so let's get started and build right away.
00:04I'm going to be working inside of Dreamweaver CS6
00:07in this project, but you could work
00:09with whatever editor of your choice.
00:12It really doesn't matter.
00:14The only advantage is that we're going to get
00:16a lot of quick hints and making it a bit easier,
00:20but not necessary.
00:21You could even use a standard notepad,
00:24whatever is your preferred environment.
00:26After all, this is not a beginner title.
00:28This is a title for people who already know JavaScript,
00:31but are weak with the object-oriented part
00:33and want to explore it and become better at it.
00:35If you need to know JavaScript in general,
00:38I really recommend you check out our earlier titles
00:41on zero2geek.com, which will help you gain
00:43that base knowledge that you need
00:45in coding slash JavaScript before you can take this title.
00:48But let's jump right in.
00:49We're going to start with the HTML
00:50and we're really just going to do a few modifications
00:52to this really, really basic initial page.
00:55So you can see that we have our doc type,
00:57which is in the HTML5 format.
00:59We have our HTML, we have our header, we have our body.
01:03And what we're going to do is let's start
01:05with our head itself.
01:06I want to start adding, well, let's start with our body
01:09because let's add inside a new div layer
01:11and we're going to give that div layer an ID of map.
01:15And inside of this div layer, literally,
01:17we're going to be keeping our Google map.
01:19Now, all I really want to do to this
01:21before we start actually building it now
01:22is setting up the CSS or our map will take the full screen.
01:26All right, so right now, obviously, there's nothing in it,
01:28but that's exactly what's going to be our next step.
01:31We're going to set up our styles
01:33directly inside of our HTML.
01:36So I'm going to write there in the header, add a new style.
01:39I'm going to start with my HTML property itself
01:41and I'm just going to set the height itself
01:43of my HTML to be 100%.
01:46I'm going to do the same for my body
01:48and this is really mainly for security,
01:49making sure that different browsers will align
01:53and behave the way we want them to.
01:54So we're going to set that to 100%.
01:56We want to make sure that our margin is going to be 0 pixels,
01:590 in general.
02:01And so same thing we want for our padding.
02:05We want to have no padding.
02:08And it's time for us to set up our map ID itself.
02:11And inside of our map, we want to set up a height as well,
02:14making sure that the height is 100%.
02:16We want to set a width this time around as well.
02:18And in our width, we're going to set that to be 100% as well.
02:24Almost last but not least is we want
02:26to set our position of our map to be absolute
02:28so we could lock it into the top corner, top left corner.
02:32And we'll set our top to be 0 pixels
02:34and our left to be 0 pixels.
02:38So that really covers our CSS.
02:40And again, this title is not about CSS,
02:42but these are the basic stuff that you'll
02:43need for this project.
02:45If you're not comfortable with CSS,
02:46you could just grab the source code directly
02:49from our downloadable area.
02:52And really, this covers our core, core, core stuff
02:54that we want to do in our HTML.
02:56We're really not going to touch any more HTML
02:58besides another two more things.
02:59And these two things are literally,
03:01let's start with the easier part.
03:03The first part is we want to actually load in our local file.
03:07And our local file, its name is going
03:10to change every exercise.
03:14So notice that because our script, we're
03:17going to each time update the name.
03:19For now, as our first, first sample,
03:21we're going to call our first sample 00001.start.js.
03:30And we're going to close that script tag as well.
03:33And that's all we have to do to set up our HTML.
03:36Really our, oh, we have your little typo.
03:38It's not that.
03:38It's source, S-R-C. Going to save that.
03:42And there we go.
03:43So that's all we needed to basically get us
03:45started with our basic HTML.
03:47Now, we're only missing one thing
03:49because we actually also want to add in our Google API access
03:54for us to be able to load in a map.
03:56And to do that, we're going to call in the source
03:59file of the Google map.
04:00But we won't be able to actually complete this
04:02without taking a small break and completing this.
04:08So I'm just going to start it off,
04:10and I'm going to leave it open.
04:11And then we're going to finish it up.
04:12So first of all, we're going to type HTTP maps.googleapis.com.
04:19slash maps slash API slash JS.
04:24Question mark, key equals, and literally, we're
04:27going to put here your key.
04:31And we're going to set it to be with the sensor equals true.
04:38Now, the sensor equals true is really
04:40to accommodate mobile devices.
04:42You don't really have to set this up.
04:44But really, this day and age, almost everything
04:46is set to be true.
04:47So we're just going to set it to be true
04:49because that's also the recommended approach
04:51in the Google documentation itself.
04:53Now, in the area where we said key equals your key,
04:55this is exactly where we have to put our own unique key.
04:59I'm going to show you how to produce the key,
05:01but you're going to have to create your own key
05:03for your maps to actually work.
05:05So this is going to be the end of our HTML part
05:07before we move now into a browser to create our own key
05:10because we're going to have to sign
05:12a few agreements with Google.
05:14And once we're done with that, we'll
05:15be able to establish a key, which will enable us to then
05:18continue on working on our project.
