-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
62 lines (56 loc) · 1.64 KB
/
main.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
const myRequest = new Request("https://api.github.com/users/jose-manuel-silva/repos");
fetch(myRequest)
.then((res) => {
if (res.status === 200) {
const json = res.json().then((data) => {
data.forEach((project) => {
addCard(project.name, project.description, project.html_url);
});
});
} else {
throw new Error("An Error occured contacting the GitHub API");
}
})
.catch((err) => {
console.error(err);
});
function addCard(name, description, link) {
if (description === null) {
description = "No description found.";
}
var card_html = `<div class="card">
<h1 class="title">${name}</h1>
<h2 class="description">${description} <a class="parenthesis" href="${link}">(</a><a class="more" href="${link}">Go to Repo</a><a class="parenthesis" href="${link}">)</a></h2>
</div>`;
$(".cards")
.append(card_html)
.ready(
//Wrap description lines from 'My Projects' section
$(function () {
$(".card .description").dotdotdot({ truncate: "letter", keep: "a", watch: true, height: "watch" });
})
);
}
//header change
$(window).scroll(function () {
var header = $(".header");
if ($(this).scrollTop() > $(".start").height() * 0.95) {
if (!header.hasClass("darkheader")) {
header.addClass("darkheader");
}
} else {
if (header.hasClass("darkheader")) {
header.removeClass("darkheader");
}
}
});
//smooth scroll
$(document).ready(function () {
if (window.location.hash) {
$.smoothScroll({ scrollTarget: window.location.hash, speed: 800, offset: -60 });
}
$("a.scroll").smoothScroll({
speed: 800,
offset: -60,
});
});