@@ -9,22 +9,54 @@ if (! document.getElementById('debugbar_loader')) {
99 return ;
1010 }
1111
12- localStorage . setItem ( 'debugbar-time' , time ) ;
13- localStorage . setItem ( 'debugbar-time-new' , time ) ;
1412 window . location . href = ciSiteURL + '?debugbar_time=' + time ;
1513 } ;
1614 }
1715
1816 ( function ( ) {
17+ function ensureToolbarContainer ( icon , toolbar ) {
18+ let toolbarContainer = document . getElementById ( 'toolbarContainer' ) ;
19+
20+ if ( toolbarContainer ) {
21+ return ;
22+ }
23+
24+ toolbarContainer = document . createElement ( 'div' ) ;
25+ toolbarContainer . setAttribute ( 'id' , 'toolbarContainer' ) ;
26+
27+ if ( icon ) {
28+ toolbarContainer . appendChild ( icon ) ;
29+ }
30+
31+ if ( toolbar ) {
32+ toolbarContainer . appendChild ( toolbar ) ;
33+ }
34+
35+ document . body . appendChild ( toolbarContainer ) ;
36+ }
37+
1938 function initStandaloneToolbar ( ) {
2039 if ( typeof ciDebugBar !== 'object' ) {
2140 return ;
2241 }
2342
24- if ( ! document . getElementById ( 'debug-bar' ) || ! document . getElementById ( 'debug-icon' ) ) {
43+ const icon = document . getElementById ( 'debug-icon' ) ;
44+ const toolbar = document . getElementById ( 'debug-bar' ) ;
45+
46+ if ( ! toolbar || ! icon ) {
2547 return ;
2648 }
2749
50+ const currentTime = new URLSearchParams ( window . location . search ) . get ( 'debugbar_time' ) ;
51+
52+ if ( currentTime && ! isNaN ( currentTime ) ) {
53+ if ( ! localStorage . getItem ( 'debugbar-time' ) ) {
54+ localStorage . setItem ( 'debugbar-time' , currentTime ) ;
55+ }
56+ localStorage . setItem ( 'debugbar-time-new' , currentTime ) ;
57+ }
58+
59+ ensureToolbarContainer ( icon , toolbar ) ;
2860 ciDebugBar . init ( ) ;
2961 }
3062
0 commit comments