-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtmldocument.js
More file actions
49 lines (34 loc) · 925 Bytes
/
htmldocument.js
File metadata and controls
49 lines (34 loc) · 925 Bytes
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
**
** The author disclaims copyright to this source code.
**
*/
var HTMLNode = require('./htmlnode');
function HTMLDocument(options){
var _S = this;
_S.debug = false;
_S.options = null;
_S.rootElement = new HTMLNode({name:"html"});
if(typeof options != 'undefined'){
_S.options = options;
if(typeof options.debug != 'undefined'){
_S.debug = options.debug;
}
}
if(_S.options == null && _S.debug){
console.log("[debug] No HTMLDocument Options Specified");
}
_S.rootElement.debug = _S.debug;
console.log("Debug = " + _S.rootElement.debug);
_S.head = _S.rootElement.addChild("head");
_S.body = _S.rootElement.addChild("body");
_S.toString = function(){
var out = '<!DOCTYPE "html">';
out += _S.rootElement.toString();
if(_S.debug){
console.log("[Debug] " + out);
}
return out;
}
}
module.exports = HTMLDocument;