forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoolbarstandalone.js
More file actions
69 lines (54 loc) · 1.99 KB
/
toolbarstandalone.js
File metadata and controls
69 lines (54 loc) · 1.99 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Bootstrap for standalone Debug Toolbar pages (?debugbar_time=...).
*/
if (! document.getElementById('debugbar_loader')) {
if (typeof loadDoc !== 'function') {
window.loadDoc = function (time) {
if (isNaN(time)) {
return;
}
window.location.href = ciSiteURL + '?debugbar_time=' + time;
};
}
(function () {
function ensureToolbarContainer(icon, toolbar) {
let toolbarContainer = document.getElementById('toolbarContainer');
if (toolbarContainer) {
return;
}
toolbarContainer = document.createElement('div');
toolbarContainer.setAttribute('id', 'toolbarContainer');
if (icon) {
toolbarContainer.appendChild(icon);
}
if (toolbar) {
toolbarContainer.appendChild(toolbar);
}
document.body.appendChild(toolbarContainer);
}
function initStandaloneToolbar() {
if (typeof ciDebugBar !== 'object') {
return;
}
const icon = document.getElementById('debug-icon');
const toolbar = document.getElementById('debug-bar');
if (! toolbar || ! icon) {
return;
}
const currentTime = new URLSearchParams(window.location.search).get('debugbar_time');
if (currentTime && ! isNaN(currentTime)) {
if (! localStorage.getItem('debugbar-time')) {
localStorage.setItem('debugbar-time', currentTime);
}
localStorage.setItem('debugbar-time-new', currentTime);
}
ensureToolbarContainer(icon, toolbar);
ciDebugBar.init();
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initStandaloneToolbar, false);
} else {
initStandaloneToolbar();
}
})();
}