-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
153 lines (130 loc) · 4.88 KB
/
app.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
let projects = [
{
name: 'Memorial eOpen House',
thumbnail: './images/html-css-js.jpeg',
url: 'noneyet',
highlight: true,
},
{
name: 'Quality Metrics for OSF ECIEMS',
thumbnail: './images/html-js.png',
url: 'noneyet',
highlight: true,
},
{
name: 'Undetermined Project',
thumbnail: 'images/work-in-progress.png',
url: 'noneyet',
highlight: true,
},
{
name: 'Undetermined Project',
thumbnail: 'images/500x300.jpg',
url: 'noneyet',
highlight: false,
},
{
name: 'Undetermined Project',
thumbnail: 'images/500x300.jpg',
url: 'noneyet',
highlight: false,
}
]
// Places projects marked as highlight on the main page.
const projectsDiv = document.getElementById('projects')
const projectRead = () => {
projectsDiv.innerHTML = ''
for (let i = 0; i < projects.length; i++) {
if ( projects[i].highlight == false){
continue
}
else {
let projectContainer = document.createElement('div')
let projectItem = document.createElement('div')
projectItem.setAttribute('class', 'project')
let link = document.createElement('a')
link.setAttribute('href', projects[i].url)
let image = document.createElement('img')
image.setAttribute('class', 'projectImage')
image.setAttribute('src', projects[i].thumbnail)
link.append(image)
projectItem.appendChild(link)
projectContainer.appendChild(projectItem)
let title = document.createElement('h4')
title.innerText = projects[i].name
projectContainer.appendChild(title)
projectsDiv.appendChild(projectContainer)
}
}
}
projectRead ()
//Modal for projects, inclides carosel
const projectURL = document.querySelector('#projectURL')
const mainProject = document.querySelector('#mainProject')
const projectDescription = document.querySelector('#description')
const next = document.querySelector('.next')
const previous =document.querySelector('.prev')
let currentProjectIndex = 0
projectURL.setAttribute('href', projects[currentProjectIndex].url)
mainProject.setAttribute('src', projects[currentProjectIndex].thumbnail)
projectDescription.innertext = projects[currentProjectIndex].name
next.addEventListener('click', () => {
if (currentProjectIndex >= projects.length - 1) {
currentProjectIndex = 0
} else (
currentProjectIndex += 1
)
mainProject.setAttribute('src', projects[currentProjectIndex].thumbnail)
})
previous.addEventListener('click', () => {
if (currentProjectIndex <= 0) {
currentProjectIndex = projects.length - 1
} else (
currentProjectIndex -= 1
)
projectURL.setAttribute('src', projects[currentProjectIndex].url)
mainProject.setAttribute('src', projects[currentProjectIndex].thumbnail)
})
//Modal for contact box
const contactModal = document.querySelector('.modal-contact')
const contactBtn = document.querySelector('#contactBtn')
const projectsModal = document.querySelector('.modal-projects')
const projectsBtn = document.querySelector('#projectsBtn')
const close1 = document.querySelector(".close")
const close2 = document.querySelector(".project-close")
contactBtn.onclick = () => {
contactModal.style.display = 'block'
}
projectsBtn.onclick = () => {
projectsModal.style.display = 'block'
}
close1.onclick = () => {
contactModal.style.display = 'none'
}
close2.onclick = () => {
projectsModal.style.display = 'none'
}
window.onclick = (event) => {
if (event.target == contactModal){
contactModal.style.display = 'none'
projectsModal.style.display = 'none'
}
}
const scriptURL = 'https://script.google.com/macros/s/AKfycbwQ1jUaAvCJD1MRf8HvOwaCIipjB5ObEW4mhO5yZfVezIbVM8M/exec'
const form = document.querySelector('form')
form.addEventListener('submit', (e) => {
e.preventDefault()
fetch(scriptURL, { method: 'POST', body: new FormData(form)})
.then(response => console.log('Success!', response))
.then(() => {
thanks.style.display = "block"
})
.catch(error => console.error('Error!', error.message))
})
//Clickable social links
const twitter = document.getElementById('tw')
const github = document.getElementById('gh')
const discord = document.getElementById('dc')
twitter.onclick = () => {window.open('https://twitter.com/NateGorm91','_blank','resizable=yes')}
github.onclick = () => {window.open('https://github.com/georgie91','_blank','resizable=yes')}
discord.onclick = () => {window.open('https://discord.gg/spQnjf','_blank','resizable=yes')}