-
Notifications
You must be signed in to change notification settings - Fork 0
/
portfolio.js
157 lines (139 loc) · 5.24 KB
/
portfolio.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
'use strict';
let projectNo = 0;
/*listen for clicks on portfolio and about me links at menu bar*/
function menuBar() {
$('.nav').on('click', '.portfolioLink', function (event) {
portfolioPage();
})
$('.nav').on('click', '.aboutLink', function (event) {
aboutPage();
})
}
/*listens for any clicks on the sunny logo*/
function logoClick() {
$('.nav').on('click', '.navImage', function (event) {
$('.portfolioSection').hide();
$('.aboutMe').hide();
$('.nav').hide();
$('.start').show();
})
}
/*listening and checking for portfolio page button clicks*/
function portfolioButtonClick() {
$('.portfolioSection').on('click', '.next', function (event) {
event.preventDefault();
projectNo++;
$('.portfolioBox').empty();
return createProjects(projectNo);
})
$('.portfolioSection').on('click', '.prev', function (event) {
event.preventDefault();
projectNo--;
$('.portfolioBox').empty();
return createProjects(projectNo);
})
}
/*displaying the project info*/
function createProjects(pNumber) {
//enable buttons before check
$('.next').attr('disabled', false);
$('.prev').attr('disabled', false);
//disabling buttons
if (pNumber <= 0) {
$('.prev').attr('disabled', true);
} else if (pNumber >= (PROJECTS.length - 1)) {
$('.next').attr('disabled', true);
}
//matching shown project with number
$('.pNumber').html(`${PROJECTS[pNumber].number}`);
//printing project info to box
$('.portfolioBox').append(`
<section class="portfolioSS">
<h1 class ="pHeading">${PROJECTS[pNumber].title}</h1>
<figure class="tList${pNumber} techList"></figure>
<p class="technologyList">${PROJECTS[pNumber].techlist}</p>
<img src="${PROJECTS[pNumber].screenshot}" alt="${PROJECTS[pNumber].alt}" class="ssImage">
<p class="portfolioDescription tab">${PROJECTS[pNumber].description}</p>
<div class="pageLinks">
<a href="${PROJECTS[pNumber].repo}" target='_blank'>Code</a><span> | </span>
<a href="${PROJECTS[pNumber].livepage}" target='_blank'>Live Page</a>
</div>
</section>`);
//add technologies to each project
for (let i = 0; i < PROJECTS[pNumber].tech.length; i++) {
if (PROJECTS[pNumber].tech[i] === "html5") {
$('.tList' + pNumber).append(`<img src="images/tinyHTML5Logo.png" alt="HTML5 logo">`);
} else if (PROJECTS[pNumber].tech[i] === "css3") {
$('.tList' + pNumber).append(`<img src="images/tinycsslogo.png" alt="CSS3 logo">`);
} else if (PROJECTS[pNumber].tech[i] === "javascript") {
$('.tList' + pNumber).append(`<img src="images/tinyjavascriptlogo.png" alt="JavaScript logo">`);
} else if (PROJECTS[pNumber].tech[i] === "jquery") {
$('.tList' + pNumber).append(`<img src="images/tinyjquerylogo.png" alt="JQuery Logo">`);
} else if (PROJECTS[pNumber].tech[i] === "react") {
$('.tList' + pNumber).append(`<img src="images/tinyReactlogo.png" alt="React Logo">`);
} else if (PROJECTS[pNumber].tech[i] === "node") {
$('.tList' + pNumber).append(`<img src="images/tinynodelogo.png" alt="Node.js Logo">`);
} else if (PROJECTS[pNumber].tech[i] === "express") {
$('.tList' + pNumber).append(`<img src="images/tinyexpress.jpg" alt="Express Logo">`);
} else if (PROJECTS[pNumber].tech[i] === "postgresql") {
$('.tList' + pNumber).append(`<img src="images/tinypostgresql.png" alt="PostgreSQL Logo">`);
} else if (PROJECTS[pNumber].tech[i] === "android") {
$('.tList' + pNumber).append(`<img src="images/AndroidRobot.png" alt="PostgreSQL Logo">`);
}
};
}
/*actions to show portfolio page*/
function portfolioPage() {
$('.start').hide();
$('.aboutMe').hide();
$('.portfolioSection').show();
$('.nav').show();
$('.portfolioLink').addClass('activePage');
$('.aboutLink').removeClass('activePage');
$('footer').show();
projectNo = 0;
$('.portfolioBox').empty();
//refresh page if window gets resized
$(window).resize(function () {
portfolioPage();
});
//layout change depending on screen size
if ($(window).width() >= 800) {
for (let i = 0; i < PROJECTS.length; i++) {
createProjects(i);
}
} else {
$('.total').html(`${PROJECTS.length}`);
$('.pNumber').html('1');
createProjects(0);
}
}
/*actions to show about me page*/
function aboutPage() {
$('.start').hide();
$('.aboutMe').show();
$('.portfolioSection').hide();
$('.nav').show();
$('.aboutLink').addClass('activePage');
$('.portfolioLink').removeClass('activePage');
$('footer').hide();
}
/*start page and event listeners*/
function startPage() {
/*portfolio button click*/
$('.start').on('click', '.portfolioButton', function (event) {
portfolioPage();
})
/*about me button click*/
$('.start').on('click', '.aboutButton', function (event) {
aboutPage();
})
}
//Javascript Functions to run
function begin() {
startPage();
logoClick();
menuBar();
portfolioButtonClick();
}
$(begin);