File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
-
2
1
( function ( ) {
3
-
4
2
// add more files here if needed
5
- var files = [ 'javascript.json' , 'text-editors.json' , 'jquery.json' , 'node.json' ]
3
+ var files = [ 'javascript.json' , 'node.json' , 'jquery.json' , 'text-editors.json' ]
4
+
5
+ files . forEach ( function ( filename ) {
6
+ // create placeholder divs to enforce topic order
7
+ var el = getTargetElement ( filename . split ( '.' ) [ 0 ] )
8
+ document . getElementById ( 'content' ) . appendChild ( el )
6
9
7
- . forEach ( function ( filename ) {
8
10
getFile ( filename ) . then ( function ( data ) {
9
11
render ( data )
10
12
} )
13
15
function render ( data ) {
14
16
var template = Handlebars . compile ( document . getElementById ( 'main_template' ) . text )
15
17
var html = template ( data )
16
- var el = document . createElement ( 'div' )
18
+
19
+ var id = 'topic-' + data . title . replace ( / / g, '-' )
20
+ var el = document . getElementById ( id )
17
21
el . innerHTML = html
18
- document . getElementById ( 'content' ) . appendChild ( el )
19
22
}
20
23
21
24
function getFile ( filename ) {
26
29
} )
27
30
}
28
31
32
+ function getTargetElement ( id ) {
33
+ var el = document . createElement ( 'div' )
34
+ el . setAttribute ( 'id' , 'topic-' + id )
35
+ return el
36
+ }
29
37
} ) ( )
You can’t perform that action at this time.
0 commit comments