@@ -56,16 +56,21 @@ function attachAllListeners() {
56
56
$ . get ( href , function ( data ) {
57
57
const html = $ . parseHTML ( data )
58
58
const title = html . find ( node => node . nodeName === "TITLE" ) . innerText
59
- const divHtml = html . find ( node => node . nodeName === "DIV" ) . innerHTML
59
+ const bodyDiv = html . find ( node => node . nodeName === "DIV" )
60
+ const { children } = document . body . firstChild
60
61
if ( window . history . state === null ) {
61
62
window . history . replaceState ( {
62
- html : document . body . firstChild . innerHTML ,
63
+ leftColumn : children [ 3 ] . innerHTML ,
64
+ mainDiv : children [ 6 ] . innerHTML ,
63
65
title : window . title ,
64
66
} , '' )
65
67
}
66
68
window . title = title
67
- window . history . pushState ( { html : divHtml , title } , '' , href )
68
- document . body . firstChild . innerHTML = divHtml
69
+ const leftColumn = bodyDiv . children [ 3 ] . innerHTML
70
+ const mainDiv = bodyDiv . children [ 6 ] . innerHTML
71
+ window . history . pushState ( { leftColumn, mainDiv, title } , '' , href )
72
+ children [ 3 ] . innerHTML = leftColumn
73
+ children [ 6 ] . innerHTML = mainDiv
69
74
attachAllListeners ( )
70
75
} )
71
76
} )
@@ -192,9 +197,11 @@ window.addEventListener("DOMContentLoaded", () => {
192
197
} ) ;
193
198
194
199
window . addEventListener ( 'popstate' , e => {
195
- const { html , title } = e . state
200
+ const { leftColumn , mainDiv , title } = e . state
196
201
window . title = title
197
- document . body . firstChild . innerHTML = html
202
+ const { children } = document . body . firstChild
203
+ children [ 3 ] . innerHTML = leftColumn
204
+ children [ 6 ] . innerHTML = mainDiv
198
205
attachAllListeners ( )
199
206
} )
200
207
0 commit comments