forked from aimacode/aima-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (26 loc) · 1.24 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* Load the scripts, html, and css needed for the chapter pages.
The project uses Bootstrap 3, which requires JQuery 1. We load
Bootstrap JS, a common header menu, and a common footer.
The individual pages don't need to load these.
*/
(function() {
var head = document.getElementsByTagName('head')[0];
var bootstrapScript = document.createElement('script');
bootstrapScript.setAttribute('src', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js');
head.append(bootstrapScript);
$(function() {
var body = document.getElementsByTagName('body')[0];
var header = document.createElement('header');
body.insertBefore(header, body.firstChild);
var footer = document.createElement('footer');
footer.setAttribute('class', 'text-center');
footer.innerHTML = '<img src="http://aima.cs.berkeley.edu/aima_logo.png">';
body.append(footer);
if (document.location.protocol === 'file:') {
// file: urls don't allow ajax calls needed to load the header, so load from main site instead
$('header').load("http://aimacode.github.io/aima-javascript/header.html");
} else {
$('header').load("../header.html");
}
});
})();