-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
130 lines (104 loc) · 4.31 KB
/
script.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const slideValue = document.querySelector("span");
const inputSlider = document.querySelector("input");
inputSlider.oninput = (()=>{
let value = inputSlider.value;
slideValue.textContent = value;
slideValue.style.left = (value/2) + "%";
slideValue.classList.add("show");
});
inputSlider.onblur = (()=>{
slideValue.classList.remove("show");
});
document.querySelectorAll('.scroll-trigger').forEach(function(element) {
element.addEventListener('click', function (event) {
event.preventDefault();
window.scrollTo({
top: document.body.scrollHeight,
behavior: 'smooth'
});
});
});
let navbar = document.querySelector('.navbar');
let landing = document.querySelector('.landing');
window.addEventListener('scroll', () => {
if (window.scrollY > landing.offsetHeight) {
navbar.classList.add('fixed-navbar');
} else {
navbar.classList.remove('fixed-navbar');
}
});
let toggleColor = document.getElementById('toggle-color')
let onButton = document.getElementById('on-btn')
let offButton = document.getElementById('off-btn')
function onClick() {
toggleColor.style.left = '-4px'
toggleColor.style.backgroundColor = '#64BA40'
onButton.style.color = 'white';
offButton.style.color = 'black';
}
function offClick() {
toggleColor.style.left = '76px'
toggleColor.style.backgroundColor = '#E84C3D'
onButton.style.color='black';
offButton.style.color = 'white';
}
let speakerNameAreas = document.querySelectorAll('.speaker-name-textbox');
function resizeTextArea(speakerNameArea) {
const measureWidth = speakerNameArea.nextElementSibling;
measureWidth.textContent = speakerNameArea.value;
speakerNameArea.style.width = `${measureWidth.offsetWidth - 30}px`;
}
speakerNameAreas.forEach((speakerNameArea) => {
speakerNameArea.addEventListener("input", () => resizeTextArea(speakerNameArea));
});
let crossIcons = document.querySelectorAll('#cross-icon');
const plusIcon = document.getElementById('plus-icon');
plusIcon.addEventListener('click', function() {
const container = document.querySelector('.speakers-container');
const index = document.querySelectorAll('.speaker-name-textbox').length;
const newSpeakerName = document.createElement('textarea');
newSpeakerName.classList.add('speaker-name-textbox');
newSpeakerName.placeholder = "Enter Name";
const newMeasureWidth = document.createElement('span');
newMeasureWidth.classList.add('width-measure');
newMeasureWidth.style.visibility = 'hidden';
const newCrossIcon = document.createElement('i');
newCrossIcon.classList.add('fa-solid', 'fa-xmark');
newCrossIcon.id = 'cross-icon';
container.appendChild(newSpeakerName);
container.appendChild(newMeasureWidth);
container.appendChild(newCrossIcon);
newSpeakerName.addEventListener("input", () => resizeTextArea(newSpeakerName));
newCrossIcon.addEventListener("click", () => {
localStorage.setItem(`removedElement${index}`, true);
newSpeakerName.remove();
newMeasureWidth.remove();
newCrossIcon.remove();
});
container.appendChild(plusIcon);
});
const plusIconHashtags = document.getElementById('plus-icon-hashtags');
plusIconHashtags.addEventListener('click', function() {
const container = document.querySelector('.hashtags-container');
const index = document.querySelectorAll('.hashtag-textbox').length;
const newHashtag = document.createElement('textarea');
newHashtag.classList.add('hashtag-textbox');
newHashtag.placeholder = "Enter Hashtag";
const newMeasureWidth = document.createElement('span');
newMeasureWidth.classList.add('width-measure');
newMeasureWidth.style.visibility = 'hidden';
const newCrossIcon = document.createElement('i');
newCrossIcon.classList.add('fa-solid', 'fa-xmark');
newCrossIcon.id = `cross-icon-hashtag`; // Ensure unique ID for each cross icon
container.appendChild(newHashtag);
container.appendChild(newMeasureWidth);
container.appendChild(newCrossIcon);
newHashtag.addEventListener("input", () => resizeTextArea(newHashtag));
newCrossIcon.addEventListener("click", () => {
localStorage.setItem(`removedHashtagElement${index}`, true);
newHashtag.remove();
newMeasureWidth.remove();
newCrossIcon.remove();
});
container.appendChild(plusIconHashtags);
});