blob: 067b4de7bc177153f8e40f4802a124a96bc9071c (
plain)
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
|
const blob = document.querySelector('#blob');
var blobData = blob.dataset.forceForm;
function loadScript(src) {
var script = document.createElement('script');
script.src = src;
document.body.appendChild(script);
}
var blobItem;
if (blobData) {
blobItem = blobData;
} else {
// check if user's on mobile
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) || window.orientation > 1) {
// do randomBlob since user is on mobile(mouseBlob is buggy on mobile so ya)
blobItem = "random"
} else {
blobItem = "mouse"
}
}
if (blobItem == "mouse") {
loadScript('/js/mouseblob.js')
} else if (blobItem == "random") {
loadScript('/js/randomblob.js')
} else {
throw new Error("Unknown blob type")
}
|