Skip to content

Commit c0fca5f

Browse files
committed
Translating further into Vue and commenting out main part for now
1 parent da6fc7e commit c0fca5f

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

src/components/days/individual_days/Day10.vue

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
:class="checkbox.class"
55
v-for="checkbox in checkboxes"
66
:key="checkbox.id"
7+
@click="checkShift($event)"
78
>
8-
<input :type="checkbox.type" />
9+
<input :type="checkbox.type" :id="checkbox.id" />
910
<p>{{ checkbox.paragraphContent }}</p>
1011
</div>
1112
</div>
@@ -72,41 +73,44 @@ export default {
7273
id: 9,
7374
},
7475
],
76+
inBetween: false,
77+
shiftKey: false,
78+
lastChecked: false,
7579
};
7680
},
77-
};
78-
const checkboxes = document.querySelectorAll("input[type=checkbox]");
79-
80-
let lastChecked;
81+
methods: {
82+
checkShift(event) {
83+
// variable to store the shift key boolean value
84+
this.shiftKey = event.shiftKey;
8185
82-
function checkShift(e) {
83-
// variable to store the shift key boolean value
84-
let shiftKey = e.shiftKey;
85-
// Flag to help us determine if a checkbox is inBetween two checkboxes
86-
let inBetween = false;
87-
88-
// Checking if the shiftKey is pressed and that the current checkbox is checked
89-
if (shiftKey && this.checked) {
90-
// Iterating over the checkboxes
91-
checkboxes.forEach((checkbox) => {
92-
// Check if the current checkbox is one the 'begin' or the 'end'
93-
if (checkbox === this || checkbox === lastChecked) {
94-
// Reverse the value of inBetween since it's not inBetween the start and end
95-
inBetween = !inBetween;
96-
}
97-
// if the current checkbox is inBetween, check it.
98-
if (inBetween) {
99-
checkbox.checked = true;
86+
// Checking if the shiftKey is pressed and that the current checkbox is checked
87+
if (this.shiftKey && this.checked) {
88+
// Iterating over the checkboxes
89+
// Need to translate that later
90+
// checkboxes.forEach((checkbox) => {
91+
// // Check if the current checkbox is one the 'begin' or the 'end'
92+
// if (checkbox === this || checkbox === this.lastChecked) {
93+
// // Reverse the value of inBetween since it's not inBetween the start and end
94+
// this.inBetween = !this.inBetween;
95+
// }
96+
// // if the current checkbox is inBetween, check it.
97+
// if (this.inBetween) {
98+
// checkbox.checked = true;
99+
// }
100+
// });
101+
//TODO = Find a way to reverse this in a way that when the shift key is pressed on a checked box, it will make them all unchecked
100102
}
101-
});
103+
this.lastChecked = this;
104+
},
105+
},
106+
};
107+
// const checkboxes = document.querySelectorAll("input[type=checkbox]");
102108
103-
//TODO = Find a way to reverse this in a way that when the shift key is pressed on a checked box, it will make them all unchecked
104-
}
105-
lastChecked = this;
106-
}
107-
checkboxes.forEach((checkbox) =>
108-
checkbox.addEventListener("click", checkShift)
109-
);
109+
// let lastChecked;
110+
111+
// checkboxes.forEach((checkbox) =>
112+
// checkbox.addEventListener("click", checkShift)
113+
// );
110114
</script>
111115

112116
<style scoped>

0 commit comments

Comments
 (0)