-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditLocalStorage.js
More file actions
27 lines (23 loc) · 1009 Bytes
/
Copy patheditLocalStorage.js
File metadata and controls
27 lines (23 loc) · 1009 Bytes
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
export function editLocalStorage(radioLanguageChecked, radioWeekChecked, inputMaxLessons) {
if (JSON.parse(localStorage.getItem('tableValue')) == []) {
localStorage.setItem('table', '[]');
}
const table = document.querySelector('table');
const tdTable = table.querySelectorAll('td');
let localStorageFormRadio = {
radioLanguageChecked: radioLanguageChecked.value,
radioWeekChecked: radioWeekChecked.value,
inputMaxLessons: inputMaxLessons.value
};
localStorage.setItem('tableFormRadio', JSON.stringify(localStorageFormRadio));
let arrLocalStorageTableValue = [];
tdTable.forEach(trItem => {
const trTable = trItem.querySelectorAll('tr');
let tempArr = [];
trTable.forEach((trItem, index) => {
tempArr[index] = trItem.querySelector("input").value;
});
arrLocalStorageTableValue.push(tempArr);
});
localStorage.setItem('tableValue', JSON.stringify(arrLocalStorageTableValue));
}