Repository navigation
Expand file tree
/
Copy pathloader.js
More file actions
64 lines (60 loc) · 3.05 KB
/
Copy pathloader.js
File metadata and controls
64 lines (60 loc) · 3.05 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
/* Loads the JSON files in /data, turns them into the objects the page code uses, then starts app.js.
Edit the files in /data (by hand or through Pages CMS); this file only needs a change when a new data file is added. */
(function () {
'use strict';
var adapters = {
profile: function (j) {
window.PROFILE = { name: j.name, email: j.email, phoneDisplay: j.phone_display, phoneIntl: j.phone_international, location: j.location, cv: j.cv_file, socials: j.socials };
window.SPECIALTIES = j.specialties;
window.GITHUB_USER = j.github_user;
window.GITHUB_SHOW = j.github_show;
window.GITHUB_HIDE = j.github_hidden;
},
kaggle: function (j) { window.KAGGLE = j; },
skills: function (j) {
window.SKILLS = j.map(function (s) { return [s.name, s.icon, (s.groups || []).join(' '), s.note || '', s.percent || 0]; });
},
projects: function (j) {
window.PROJECTS = j.map(function (p) {
return { t: p.title, tag: p.tag, c: (p.groups || []).join(' '), g: p.color, i: p.icon, d: p.description, m: p.metric, s: p.stack || [],
l: (p.links || []).map(function (l) { return [l.label, l.url]; }), lead: p.team_leader, note: p.note, img: p.image };
});
},
demos: function (j) { window.DEMOS = j; },
certificates: function (j) {
window.CERTS = j.map(function (c) {
return { group: c.group, key: c.file_name, icon: c.icon, org: c.organization, t: c.title, by: c.taught_by, date: c.date, verify: c.coursera_verify_id,
learned: c.learned, star: c.featured, topics: c.topic_pages || [], badge: c.badge, image: c.image, thumb: c.thumb, link_label: c.link_label, link_url: c.link_url };
});
},
education: function (j) { window.EDUCATION = j; },
leadership: function (j) { window.LEADERSHIP = j; },
achievements: function (j) { window.ACHIEVEMENTS = j; },
about: function (j) { window.ABOUT = j; },
/*@adapters*/
};
function fail(err) {
if (window.console) console.error('Could not load the site data:', err);
var box = document.createElement('div');
box.setAttribute('role', 'alert');
box.style.cssText = 'position:fixed;left:12px;right:12px;bottom:12px;z-index:200;padding:12px 16px;border-radius:12px;background:#fff;border:1px solid #d6e3db;color:#14151a;font:600 14px/1.4 system-ui,sans-serif;box-shadow:0 10px 30px rgba(0,0,0,.15)';
box.textContent = 'Some content could not be loaded. Please refresh the page.';
document.body.appendChild(box);
}
function start() {
var s = document.createElement('script');
s.src = 'app.js';
document.body.appendChild(s);
}
var names = Object.keys(adapters);
Promise.all(names.map(function (n) {
return fetch('data/' + n + '.json').then(function (r) {
if (!r.ok) throw new Error('data/' + n + '.json: ' + r.status);
return r.json();
}).then(function (json) { return [n, json]; });
})).then(function (all) {
all.forEach(function (p) { adapters[p[0]](p[1]); });
document.dispatchEvent(new Event('site-data-ready'));
start();
}).catch(fail);
})();