Skip to content

Commit

Permalink
fix: command debug: jquery deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tardo committed May 1, 2024
1 parent 218b847 commit f714c27
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/js/page/odoo/commands/common/debug.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,23 @@ import {ARG} from '@trash/constants';
import type {CMDCallbackArgs, CMDCallbackContext, CMDDef} from '@trash/interpreter';

async function cmdSetDebugMode(kwargs: CMDCallbackArgs, ctx: CMDCallbackContext) {
let location = '';
let location_search = false;
let location_search = '';
if (kwargs.mode === 0) {
ctx.screen.print(i18n.t('cmdDebug.result.disabled', 'Debug mode <strong>disabled</strong>'));
const qs = $.deparam.querystring();
delete qs.debug;
location_search = true;
location = `?${$.param(qs)}`;
location_search = window.location.search.replace(/debug=[^&]+/, '');
} else if (kwargs.mode === 1) {
ctx.screen.print(i18n.t('cmdDebug.result.enabled', 'Debug mode <strong>enabled</strong>'));
location = $.param.querystring(window.location.href, 'debug=1');
location_search = window.location.search.replace(/debug=[^&]+/, '');
location_search += 'debug=1';
} else if (kwargs.mode === 2) {
ctx.screen.print(i18n.t('cmdDebug.result.enabledAssets', 'Debug mode with assets <strong>enabled</strong>'));
location = $.param.querystring(window.location.href, 'debug=assets');
location_search = window.location.search.replace(/debug=[^&]+/, '');
location_search += 'debug=assets';
}

if (location) {
if (location_search) {
ctx.screen.print(i18n.t('cmdDebug.result.reload', 'Reloading page...'));
if (location_search) {
window.location.search = location;
} else {
window.location = location;
}
window.location.search = location_search;
} else {
throw new Error(i18n.t('cmdDebug.error.invalidDebugMode', 'Invalid debug mode'));
}
Expand Down

0 comments on commit f714c27

Please sign in to comment.