Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Directly export functions
  • Loading branch information
codingjoe committed Apr 22, 2026
commit 769fb26264685df49ff58265a47f5f591118e22b
12 changes: 5 additions & 7 deletions debug_toolbar/static/debug_toolbar/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const $$ = {
export const $$ = {
on(root, eventName, selector, fn) {
root.removeEventListener(eventName, fn);
root.addEventListener(eventName, (event) => {
Expand Down Expand Up @@ -70,7 +70,7 @@ const $$ = {
},
};

async function ajax(url, init) {
export async function ajax(url, init) {
Comment thread
tim-schilling marked this conversation as resolved.
try {
const response = await fetch(url, {
credentials: "same-origin",
Expand All @@ -81,7 +81,7 @@ async function ajax(url, init) {
return response.json();
} catch (error) {
throw new Error(
u`The response is a invalid Json object : ${error}`
`The response is a invalid Json object : ${error}`
);
}
}
Expand All @@ -94,7 +94,7 @@ async function ajax(url, init) {
}
}

function ajaxForm(element) {
export function ajaxForm(element) {
const form = element.closest("form");
const url = new URL(form.action);
const formData = new FormData(form);
Expand All @@ -107,7 +107,7 @@ function ajaxForm(element) {
return ajax(url, ajaxData);
}

function replaceToolbarState(newRequestId, data) {
export function replaceToolbarState(newRequestId, data) {
const djDebug = document.getElementById("djDebug");
djDebug.setAttribute("data-request-id", newRequestId);
// Check if response is empty, it could be due to an expired requestId.
Expand Down Expand Up @@ -137,5 +137,3 @@ export function debounce(func, timeout) {
timer = setTimeout(() => Promise.try(func, ...args), timeout);
};
}

export { $$, ajax, ajaxForm, replaceToolbarState };
Loading