-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (32 loc) · 1.23 KB
/
Copy pathscript.js
File metadata and controls
38 lines (32 loc) · 1.23 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
document.addEventListener('DOMContentLoaded', function() {
const cells = document.querySelectorAll('.editable-cell');
// Initialize selectedCell as null
let selectedCell = null;
cells.forEach(cell => {
cell.contentEditable = 'true';
// Ensure only integers are entered
cell.addEventListener('input', function() {
this.textContent = this.textContent.replace(/[^0-9]/g, '');
});
// Handle double click to highlight/unhighlight a cell
cell.addEventListener('dblclick', function() {
if (selectedCell === this) {
this.classList.remove('highlight');
selectedCell = null;
} else {
if (selectedCell) {
selectedCell.classList.remove('highlight');
}
this.classList.add('highlight');
selectedCell = this;
// Call the pivot function with the new selected cell
pivot(this);
}
});
});
// Define the pivot function
function pivot(cell) {
console.log(`Pivot cell value: ${cell.textContent}`);
// Add any further logic you want to define for the pivot function here.
}
});