numerous updates

This commit is contained in:
Ross
2022-05-20 20:26:02 +01:00
parent 0373b22e78
commit 77ccdbc92a
246 changed files with 22615 additions and 2409 deletions
+24 -1
View File
@@ -1,4 +1,4 @@
import { $$, ajax } from "./utils.js";
import { $$, ajax, replaceToolbarState, debounce } from "./utils.js";
function onKeyDown(event) {
if (event.keyCode === 27) {
@@ -200,6 +200,9 @@ const djdt = {
} else {
djdt.hide_toolbar();
}
if (djDebug.dataset.sidebarUrl !== undefined) {
djdt.update_on_ajax();
}
},
hide_panels() {
const djDebug = document.getElementById("djDebug");
@@ -253,6 +256,26 @@ const djdt = {
localStorage.setItem("djdt.show", "true");
window.removeEventListener("resize", djdt.ensure_handle_visibility);
},
update_on_ajax() {
const sidebar_url =
document.getElementById("djDebug").dataset.sidebarUrl;
const slowjax = debounce(ajax, 200);
const origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
this.addEventListener("load", function () {
let store_id = this.getResponseHeader("djdt-store-id");
if (store_id !== null) {
store_id = encodeURIComponent(store_id);
const dest = `${sidebar_url}?store_id=${store_id}`;
slowjax(dest).then(function (data) {
replaceToolbarState(store_id, data);
});
}
});
origOpen.apply(this, arguments);
};
},
cookie: {
get(key) {
if (!document.cookie.includes(key)) {