Repository navigation
Expand file tree
/
Copy pathpatch_selected6.js
More file actions
36 lines (32 loc) · 1.49 KB
/
Copy pathpatch_selected6.js
File metadata and controls
36 lines (32 loc) · 1.49 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
const fs = require('fs');
const ejsPath = 'E:/Antigravity/TaskWhite/views/pages/dashboard.ejs';
let content = fs.readFileSync(ejsPath, 'utf8');
const regex = /const isAnyModalOpen = document\.querySelector\('\.modal\.show'\) !== null;\s+if \(isAnyModalOpen\) \{\s+if \(\(e\.ctrlKey \|\| e\.metaKey\) && e\.key === 'Enter'\) \{\s+const activeModal = document\.querySelector\('\.modal\.show'\);/;
const replace = ` const isAnyModalOpen = document.querySelector('.modal.show') !== null;
if (isAnyModalOpen) {
if (e.key === 'Enter') {
// Do not intercept Enter for SELECT elements so they can open dropdowns natively
if (e.target.tagName === 'SELECT' || e.target.id === 'tagInputField') {
// just let it fall through
} else {
const activeModal = document.querySelector('.modal.show');
if (activeModal) {
e.preventDefault();
const form = activeModal.querySelector('form');
if (form) {
const submitBtn = form.querySelector('button[type="submit"]');
if (submitBtn) submitBtn.click();
}
}
return;
}
}
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
const activeModal = document.querySelector('.modal.show');`;
if (regex.test(content)) {
content = content.replace(regex, replace);
fs.writeFileSync(ejsPath, content);
console.log("Patched Enter logic correctly!");
} else {
console.log("Could not find search string via regex.");
}