generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
251 lines (222 loc) · 9.22 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/* **************** *
* GENERAL VARIABLES *
****************** */
const pCloseBtn = document.querySelector('.p-cross-btn');
const popUp = document.querySelector('.section-popup');
const body = document.querySelector('body');
const overlay = document.querySelector('.overlay2');
// THERE IS SCRIPT FOR POP UP MENU
const hiddenMenu = document.querySelector('.hidden-menu');
const hamburguer = document.querySelector('#hamburguer-menu');
const colseTag = document.querySelector('.cancel-img');
const portfolioItem = document.querySelectorAll('.hidden-item');
hamburguer.addEventListener('click', function () {
hiddenMenu.style.display = 'flex';
});
colseTag.addEventListener('click', function () {
hiddenMenu.style.display = 'none';
});
portfolioItem.forEach(element => {
element.addEventListener('click', () => {
hiddenMenu.style.display = 'none';
});
});
pCloseBtn.addEventListener('click', () => {
popUp.classList.add('hidden');
overlay.classList.add('hidden');
body.classList.remove('hide-scroll');
});
//============ Sticky navigation ===============//
document.addEventListener('DOMContentLoaded', function () {
const header = document.querySelector('.section-navbar');
window.addEventListener('scroll', function () {
if (window.scrollY > 50) {
header.classList.add('sticky');
} else {
header.classList.remove('sticky');
}
});
});
// ========= Add cards dynamically ==========
function addhtml() {
var dynamichtml = `
`;
var section = document.createElement('section');
var div = document.createElement('div');
div.innerHTML = dynamichtml;
section.appendChild(div);
var targetelement = document.getElementById('targetelemenet');
while (targetelement.firstChild) {
targetelement.removeChild(targetelement.firstChild);
}
var clonedDiv = div.cloneNode(true);
targetelement.appendChild(clonedDiv);
// targetelement.appendChild(section);
}
window.addEventListener('load', addhtml);
// ====================== cards objext ================
const allProjectInfo = [
{
name: 'Afghanistan Tourism Portal',
description: [
'Afghanistan Tourism Portal which is developed is comprehensive web application. We considered many aspects of a tourism portal for example hotel, transport, tour guide and so on. The application is developed using Laravel and React.',
],
imageSrc: './img/tourismportalimage/first.jpeg',
technologies: ['React', 'Laravel', 'Tailwind', 'CSS3'],
liveDemo: 'https://www.linkedin.com/in/najibullahjafari/details/projects/',
sourceLink: '#',
},
// Project 1
{
name: 'My Crypto',
description: [
'My Crypto is a cutting-edge and responsive web application that offers real-time updates on the current prices of the most popular cryptocurrencies. Developed with a combination of modern technologies, this dynamic platform leverages the power of React and Redux, complemented by CSS3 for a sleek and intuitive design.',
],
imageSrc: './img/mycrypto1.png',
technologies: ['React', 'Redux', 'Bootstrap', 'CSS3'],
liveDemo: 'https://tiny-sfogliatella-1f3791.netlify.app/',
sourceLink: 'https://github.com/najibullahjafari/My-crypto',
},
// Project 2
{
name: 'Worl Vista',
description: [
'World Vista, the JavaScript Capstone project, is an extensive and enlightening web application that serves as an invaluable resource for exploring information on approximately 250 countries around the world. This impressive project offers a comprehensive look into the diverse cultures, economies, geographies, and demographics of nations spanning the globe.',
],
imageSrc: './img/worldvista.png',
technologies: ['JavaScript', 'CSS', 'Bootstrap', 'Html'],
liveDemo: 'https://gregarious-cupcake-5d65a2.netlify.app/',
sourceLink: 'https://github.com/najibullahjafari/World-vistas',
},
// Project 3
{
name: 'Leaderboard',
description: [
'Leaderboard is a web page that saves your score and name online. Developed using HTML, CSS, JavaScript, Git flow, and API, it provides a platform to store and display user scores.',
],
imageSrc: './img/leader-board.png',
technologies: ['HTML', 'CSS', 'Bootstrap', 'Ruby on Rails'],
liveDemo: 'https://najiblearderboard.netlify.app/',
sourceLink: 'https://github.com/najibullahjafari/Leaderboard',
},
// Project 4
{
name: 'BudgetPro',
description: [
'BudgetPro, the Ruby on Rails capstone project, involves building a mobile web application for efficient budget management. Users can track transactions associated with specific categories to visualize their spending habits and monitor their budget.',
],
imageSrc: 'img/budgetpro.png',
technologies: ['Ruby', 'Rails', 'Bootstrap', 'CSS3'],
liveDemo: 'https://railsbudgetapp-3bf39d51a2ed.herokuapp.com',
sourceLink: 'https://github.com/najibullahjafari/BudgetPro',
},
// Project 4
{
name: 'Todo List',
description: [
'To-do list is a simple and effective tool used to organize tasks and manage time efficiently. It serves as a personal task manager, helping users keep track of their daily, weekly, or long-term tasks and goals.',
],
imageSrc: 'img/todolist.png',
technologies: ['JavaScript', 'HTML', 'Bootstrap', 'CSS3'],
liveDemo: 'https://gleaming-rabanadas-7c9e4b.netlify.app/',
sourceLink: 'https://github.com/najibullahjafari/To-do-list',
},
{
name: 'Gharb Online Store',
description: [
'Gharb Online Shopping is a complete MIS system which customer can buy products, The admin can add new products, categories and etc..',
],
imageSrc: 'img/onlinestoreimage/first.jpeg',
technologies: ['Laravel', 'JavaScript', 'Bootstrap', 'CSS3'],
liveDemo: '#',
sourceLink: '#',
},
];
const projectBtns = document.querySelectorAll('.btn-project');
// ====================== VALIDATION ==============
/* ****************
* EVENT LISTENERS *
**************/
for (let i = 0; i < projectBtns.length; i += 1) {
const currentProject = allProjectInfo[i];
projectBtns[i].addEventListener('click', event => {
// Clear any existing content
const popup = document.querySelector('.section-popup');
popup.querySelector('.p-heading-primary').textContent = currentProject.name;
const techBox = popup.querySelector('.p-tech-box');
techBox.innerHTML = ''; // Clear the existing technologies
for (let k = 0; k < currentProject.technologies.length; k += 1) {
const curTech = document.createElement('li');
curTech.className = 'p-tech-item';
curTech.textContent = currentProject.technologies[k];
techBox.appendChild(curTech);
}
const descriptionBox = popup.querySelector('.p-description-box');
descriptionBox.innerHTML = ''; // Clear the existing description
for (let k = 0; k < currentProject.description.length; k += 1) {
const curDesc = document.createElement('p');
curDesc.className = 'p-description';
curDesc.textContent = currentProject.description[k];
descriptionBox.appendChild(curDesc);
}
// Set the live demo link
const liveDemoLink = popup.querySelector('.p-live-demo');
liveDemoLink.href = currentProject.liveDemo;
// Set the source link
const sourceLink = popup.querySelector('.sourcelink');
if (currentProject.sourceLink) {
sourceLink.href = currentProject.sourceLink;
sourceLink.style.display = 'inline';
} else {
sourceLink.style.display = 'none';
}
// Set the image source based on the current project
const primaryImage = popup.querySelector('.p-primary-image');
if (Array.isArray(currentProject.imageSrc)) {
primaryImage.src = currentProject.imageSrc[0]; // Set the first image initially
const imageContainer = popup.querySelector('.p-image-container');
imageContainer.innerHTML = ''; // Clear existing images
currentProject.imageSrc.forEach((src, index) => {
if (index > 0) {
// Skip the first image as it's already set
const img = document.createElement('img');
img.className = 'p-secondary-image';
img.src = src;
imageContainer.appendChild(img);
}
});
} else {
primaryImage.src = currentProject.imageSrc;
}
primaryImage.src = currentProject.imageSrc;
event.preventDefault();
popup.classList.remove('hidden');
overlay.classList.remove('hidden');
body.classList.add('hide-scroll');
});
}
// =============== save data ===================
const nameInput = document.getElementById('firstname');
const emailInput = document.getElementById('email');
const textInput = document.querySelector('textarea');
function saveToStorage() {
const saveData = {
name: nameInput.value,
email: emailInput.value,
text: textInput.value,
};
localStorage.setItem('contactFormData', JSON.stringify(saveData));
}
nameInput.addEventListener('input', saveToStorage);
emailInput.addEventListener('input', saveToStorage);
textInput.addEventListener('input', saveToStorage);
document.addEventListener('DOMContentLoaded', () => {
const dataSaved = localStorage.getItem('contactFormData');
if (dataSaved) {
const data = JSON.parse(dataSaved);
nameInput.value = data.name;
emailInput.value = data.email;
textInput.value = data.text;
}
});
/////////////// updae hover effects //////////////////