-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
148 lines (132 loc) · 6.03 KB
/
Copy pathindex.html
File metadata and controls
148 lines (132 loc) · 6.03 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="VFX, Visual Effects, Melbourne, Composite, Stop Motion, Live Action, Nuke, Houdini">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dave Abbott</title>
<link rel="shortcut icon" type="image/png" href="/favicon-32x32.png">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#4b3e38">
<link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./css/style.css">
<link rel="stylesheet" type="text/css" href="./css/lity.css">
<script src="./js/jquery-2.1.0.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/lazysizes.min.js" defer></script>
<script src="./js/lity.js"></script>
</head>
<body>
<div class="container">
<!-- Showreel -->
<div>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="lazyload" src="img/lazyload-ph.png" data-src="https://player.vimeo.com/video/154007587?title=0&byline=0&portrait=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>
<!-- Filters -->
<div id="filter" class="filter">
<p>Filter by:
<input type="checkbox" id="tvcCheckbox" value="tvc" checked>
<label for="tvcCheckbox">Commercials</label>
<input type="checkbox" id="musicCheckbox" value="music" checked>
<label for="musicCheckbox">Music Videos</label>
<input type="checkbox" id="longCheckbox" value="long" checked>
<label for="longCheckbox">Long Form</label>
<input type="checkbox" id="shortCheckbox" value="short" checked>
<label for="shortCheckbox">Short Form</label>
<button id="showAllButton">Show All</button>
</p>
</div>
<!-- Portfolio -->
<div id="grid">
<div id="work" class="cards"></div>
</div>
<!-- Counter -->
<div id="counter" class="counter">
<p>Count: <span id="displayedCount">0</span></p>
</div>
</div>
<script>
fetch('./work.json')
.then(function (response) {
return response.json();
})
.then(function (data) {
appendData(data.filter(function(x){return x.visible === true; }));
})
.catch(function (err) {
console.log('error: ' + err);
});
function appendData(data) {
var mainContainer = document.getElementById("work");
var filterCheckboxes = document.querySelectorAll("#filter input[type='checkbox']");
var showAllButton = document.getElementById("showAllButton");
var displayedCountSpan = document.getElementById("displayedCount");
function filterData() {
var selectedTypes = Array.from(filterCheckboxes)
.filter(function(checkbox) {
return checkbox.checked;
})
.map(function(checkbox) {
return checkbox.value;
});
// sort data by date then featured
data.sort(function(a, b){ return b.id - a.id; });
data.sort(function(a, b){ return b.featured - a.featured; });
var filteredData = data.filter(function(item) {
return selectedTypes.includes(item.type);
});
renderData(filteredData);
displayedCountSpan.textContent = filteredData.length;
}
function renderData(data) {
mainContainer.innerHTML = "";
data.forEach(function(item) {
var divCard = document.createElement('div');
var divThumb = document.createElement('div');
var divInfo = document.createElement('div');
var vClient = item.client ? item.client + ": " : "";
var vProject = item.project || "";
var vRole = item.role || "";
var vAwards = item.awards ? "Awards: <br>" + item.awards : "";
var vNoms = item.nominated ? "Nominations: <br>" + item.nominated : "";
var divInfoTitle = "<p class='thumb-title'>" + vClient + vProject + "</p>";
var divInfoRole = "<p class='thumb-role'>" + vRole + "</p>";
var divInfoAwards = "<p class='thumb-awards'>" + vAwards + "</p>";
var divInfoNominations = "<p class='thumb-awards'>" + vNoms + "</p>";
divInfo.innerHTML = divInfoTitle + divInfoRole + divInfoAwards + divInfoNominations;
var divThumbHTML = "<a href='" + item.video + "' data-lity>" + "<img src='" + item.thumb + "' onerror=\"this.onerror=null; this.src='./img/thumbs/error.jpg';\" alt='Image' class='lazyload' style='max-width: 100%;' />" + "</a>"
divThumb.innerHTML = divThumbHTML;
divCard.appendChild(divThumb);
divCard.appendChild(divInfo);
divCard.setAttribute('class', 'card');
mainContainer.appendChild(divCard);
});
}
filterCheckboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', filterData);
});
function showAll() {
filterCheckboxes.forEach(function(checkbox) {
checkbox.checked = true;
});
filterData();
showAllButton.textContent = "Hide All";
showAllButton.removeEventListener('click', showAll);
showAllButton.addEventListener('click', hideAll);
}
function hideAll() {
filterCheckboxes.forEach(function(checkbox) {
checkbox.checked = false;
});
filterData();
showAllButton.textContent = "Show All";
showAllButton.removeEventListener('click', hideAll);
showAllButton.addEventListener('click', showAll);
}
showAll(); // Set the default state to "Hide All"
}
</script>
</body>
</html>