-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
159 lines (130 loc) · 4 KB
/
index.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
$('.error').draggable();
var error = '<div class="error">' + $('.error').html() + '</div>',
x = window.innerWidth / 3,
y = window.innerHeight / 3;
$('body').on('click', '.ok, .close-button', function () {
$('body').append(error);
$('.error').last()
.css({
top: y + 'px',
left: x + 'px'
})
.draggable();
x += 4; y += 4;
});
$('.continue').click(function () {
$([document.documentElement, document.body]).animate({
scrollTop: $(".tech-stuff-wrapper").offset().top
}, 2000);
})
$('.close-button').on('click', function () {
$(this).parents(('.plane')).remove();
})
$(document).on('scroll', function () {
if (window.scrollY + 300 > $('.extra-about-me-main-wrapper .error.box:last-child').position()) {
const innerTemplate = $('.template.default.chatroom__no-chat__inner-wrapper');
const innerDom = innerTemplate.clone();
const template = $(".template.chatroom__no-chat__wrapper");
const dom = template.clone();
innerDom.appendTo($('.extra-about-me-wrapper'));
return dom;
}
})
let agent;
let agentSpeaked = false;
$(function () {
let menuOpened = false;
const closeMenu = () => {
$('#menu').removeClass('opened')
}
function animate(agent, animations) {
function doneCallback(animation) {
// console.log('done ' + animation);
}
let statesText = animations.join(' '),
$state = $('.js-state'),
$states = $('.js-states');
for (var i = 0; i < animations.length; i++) {
((index) => {
setTimeout(_ => {
let animation = animations[index];
let currentStateInStates = statesText.replace(animation, `<b>${animation}</b>`);
$state.text(animation);
$states.html(currentStateInStates);
agent.play(animation, undefined, doneCallback.bind(null, animation));
}, index * 8000);
})(i);
}
}
const agentSpeaking = () => {
const animations = agent.animations();
agent.moveTo(170, (window.innerHeight || document.body.clientHeight) - 113);
setTimeout(animate.bind(null, agent, animations), 8000);
setTimeout(function () {
agent.speak("hmmm...");
setTimeout(function () {
agent.speak("Looks like you're trying to explore things about Jerome?");
}, 1000)
}, 1000)
}
const openMenu = () => {
$('#menu').addClass('opened');
let clippyBoi = document.getElementsByClassName('clippy')[0];
let clippyBoiSays = document.getElementsByClassName('clippy-balloon')[0];
if (!agentSpeaked) agentSpeaking();
agentSpeaked = true;
}
const triggerMenu = () => {
if (menuOpened) {
closeMenu();
menuOpened = false;
} else {
openMenu();
menuOpened = true;
}
}
$('.hamburger-trigger, .nav-content > a').click(function () {
triggerMenu();
})
$('.main').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
if (menuOpened) {
triggerMenu();
}
})
function runClippy(clippy) {
agent = clippy;
let clippyBoi = document.getElementsByClassName('clippy')[0];
let clippyBoiSays = document.getElementsByClassName('clippy-balloon')[0];
$('.nav-inner-wrapper').append($(clippyBoi));
$('.nav-inner-wrapper').append($(clippyBoiSays));
agent.show();
// add stuff here:
}
clippy.load('Clippy', runClippy);
});
// (function () {
// var body, bodyClick, button, container;
// button = $('.hamburger-trigger');
// container = $('.container');
// body = $('body');
// bodyClick = function (event) {
// if (!$(event.target).closest('.menu').length) {
// body.off('click');
// return container.toggleClass('menu-open');
// }
// };
// button.on('click', function (event) {
// event.stopPropagation();
// event.preventDefault();
// setTimeout(function () {
// container.toggleClass('menu-open');
// }, 25);
// return body.on('click', function (event) {
// if (container.hasClass('menu-open')) {
// return bodyClick(event);
// }
// });
// });
// }).call(this);