-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
227 lines (204 loc) · 7.01 KB
/
script.js
File metadata and controls
227 lines (204 loc) · 7.01 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
const resolver = {
resolve: function resolve(options, callback) {
// The string to resolve
const resolveString =
options.resolveString ||
options.element.getAttribute("data-target-resolver");
const combinedOptions = Object.assign({}, options, {
resolveString: resolveString
});
function getRandomInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function randomCharacter(characters) {
return characters[getRandomInteger(0, characters.length - 1)];
}
function doRandomiserEffect(options, callback) {
const characters = options.characters;
const timeout = options.timeout;
const element = options.element;
const partialString = options.partialString;
let iterations = options.iterations;
setTimeout(() => {
if (iterations >= 0) {
const nextOptions = Object.assign({}, options, {
iterations: iterations - 1
});
// Ensures partialString without the random character as the final state.
if (iterations === 0) {
element.textContent = partialString;
} else {
// Replaces the last character of partialString with a random character
element.textContent =
partialString.substring(0, partialString.length - 1) +
randomCharacter(characters);
}
doRandomiserEffect(nextOptions, callback);
} else if (typeof callback === "function") {
callback();
}
}, options.timeout);
}
function doResolverEffect(options, callback) {
const resolveString = options.resolveString;
const characters = options.characters;
const offset = options.offset;
const partialString = resolveString.substring(0, offset);
const combinedOptions = Object.assign({}, options, {
partialString: partialString
});
doRandomiserEffect(combinedOptions, () => {
const nextOptions = Object.assign({}, options, { offset: offset + 1 });
if (offset <= resolveString.length) {
doResolverEffect(nextOptions, callback);
} else if (typeof callback === "function") {
callback();
}
});
}
doResolverEffect(combinedOptions, callback);
}
};
// const strings = [
// 'BRANDING',
// 'UX',
// 'UI',
// 'FRONT-END',
// 'USER-EXPERIENCE',
// 'USER-INTERFACE',
// '▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂',
// 'BEGIN WITH THE END IN MIND',
// 'DESIGN IS HOW IT WORKS.',
// '▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂',
// 'HELL0 WORLD!',
// 'TEST. TEST. TEST.',
// '▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂',
// 'GET RID OF MORE.',
// 'DO NOT EVER MAKE IT "POP".',
// '▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂',
// 'SPEAK TO GOALS, NOT FEATURES.',
// 'YOUR GOALS DON\'T CARE HOW YOU FEEL.',
// '▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂▂▂▂▃▅▇█▓▒░░▒▓█▇▅▃▂',
// '( ͡° ͜ʖ ͡°)',
// ];
const strings = [
"BRANDING",
"UX",
"UI",
"FRONT_END",
"USER_EXPERIENCE",
"USER_INTERFACE",
"BEGIN WITH THE END IN MIND",
"DESIGN IS HOW IT WORKS.",
"HELL0 WORLD!",
"TEST. TEST. TEST.",
"GET RID OF MORE.",
'DO NOT EVER MAKE IT "POP".',
"SPEAK TO GOALS, NOT FEATURES.",
"YOUR GOALS DON'T CARE HOW YOU FEEL."
];
let counter = 0;
const options = {
// Initial position
offset: 0,
// Timeout between each random character
timeout: 10,
// Number of random characters to show
iterations: 5,
// Random characters to pick from
characters: [
"$",
"3",
"8",
"d",
"_",
"f",
"g",
"!",
"5",
"j",
"k",
"l",
"2",
"n",
"_",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"x",
"y",
"x",
"#",
"%",
"&",
"-",
"+",
"_",
"?",
"/",
"\\",
"="
],
// String to resolve
resolveString: strings[counter],
// The element
element: document.querySelector("[data-string-01]")
};
// Callback function when resolve completes
function callback() {
setTimeout(() => {
counter++;
if (counter >= strings.length) {
counter = 0;
}
let nextOptions = Object.assign({}, options, {
resolveString: strings[counter]
});
resolver.resolve(nextOptions, callback);
}, 1000);
}
resolver.resolve(options, callback);
//right click
// if (document.addEventListener) {
// // IE >= 9; other browsers
// document.addEventListener(
// "contextmenu",
// function(e) {
// alert(
// "You've tried to open context menu by right clicking.\n\nI've disabled this to make it a smidge more difficult to see behind the scenes of the code and content I have spent a ton of time currating that defines my career here as well as to safegaurd my personal information.\n\n\nThere are others ways to see the source if you really need to ;}"
// ); //here you draw your own menu
// e.preventDefault();
// },
// false
// );
// } else {
// // IE < 9
// document.attachEvent("oncontextmenu", function() {
// alert("You've tried to open context menu");
// window.event.returnValue = false;
// });
// }
//color swapping
// function bgColor1() {
// // document.getElementById("body").style.backgroundColor = "#1ACCAB";
// // document.getElementById("body").style.color = "#e0e9fe";
// document
// .getElementById("body")
// .setAttribute(
// "style",
// "color:#1A3ACC !important;background-color:#1ACCAB !important;"
// );
// }
// function bgColor2() {
// // document.getElementById("body").style.backgroundColor = "#1A3ACC";
// document
// .getElementById("body")
// .setAttribute(
// "style",
// "color:white !important;background-color:#1A3ACC !important;"
// );
// }