-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinklisteners.js
160 lines (152 loc) · 8.1 KB
/
linklisteners.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
160
let testBool = false
const globalTransform = 'transform 0.4s 0.1s'
function transformItems(arr,distance,str, bool){
switch(str){
case 'spotify':
arr.splice(0,1);
let spotifyWidget = document.querySelector("#spotify-widget")
for(let i=0; i< arr.length; i++){
switch(i){
case 0:
bool? distance=0 : distance='-15.6rem';
arr[i].style.transform = `translateY(${distance})`;
arr[i].style.transition = globalTransform;
break
case 1:
bool? distance='-20.6rem' : distance='-36.2rem';
arr[i].style.transform = `translateY(${distance})`;
arr[i].style.transition = globalTransform;
break
case 2:
bool? distance='-24.9rem' : distance='-40.6rem';
arr[i].style.transform = `translateY(${distance})`;
arr[i].style.transition = globalTransform;
console.log(arr[i])
break
}
}
bool? distance=0 : distance='-20.6rem';
spotifyWidget.style.transform = `translateY(${distance})`;
spotifyWidget.style.transition = globalTransform;
break
case 'releases':
console.log("releases")
arr.splice(0,1);
let releasesWidget = Array.from(document.querySelectorAll('#releases-widget'))
for(let i=0; i< arr.length; i++){
switch(i){
case 0:
bool? distance='-16rem' : distance='-36.2rem';
arr[i].style.transform = `translateY(${distance})`;
arr[i].style.transition = globalTransform;
break
case 1:
bool? distance='-20.6rem' : distance='-40.6rem';
arr[i].style.transform = `translateY(${distance})`;
arr[i].style.transition = globalTransform;
break
}
}
bool? distance=0 : distance='-24.1rem';
releasesWidget.map(e => {
e.style.transform = `translateY(${distance})`
e.style.transition = "transform 0.4s 0.1s";
});
break
case 'soundcloud':
arr.splice(0,1);
let soundCloudWidget = Array.from(document.querySelectorAll('#soundcloud-widget'))
for(let i=0; i< arr.length; i++){
switch(i){
case 0:
bool? distance='-35.2rem' : distance='-40.6rem';
arr[i].style.transform = `translateY(${distance})`;
arr[i].style.transition = globalTransform;
break
}
}
bool? distance=0 : distance='-9.5rem';
soundCloudWidget.map(e => {
console.log(e)
e.style.transform = `translateY(${distance})`
e.style.transition = "transform 0.4s 0.1s";
});
break
case 'mixcloud':
arr.splice(0,1);
let mixCloudWidget = Array.from(document.querySelectorAll('#mixcloud-widget'))
bool? distance=0 : distance='-16.3rem';
mixCloudWidget.map(e => {
console.log(e)
e.style.transform = `translateY(${distance})`
e.style.transition = "transform 0.4s 0.1s";
});
break
}
}
function wasClicked(domElement, bool){
let distance = 0;
const allLinks = Array.from(document.querySelectorAll('.link__wrapper'))
switch (domElement.path[1]) {
case allLinks[0]:
transformItems(allLinks,distance,'spotify', bool)
break
case allLinks[1]:
allLinks.splice(0,1);
transformItems(allLinks,distance,'releases', bool)
break
case allLinks[2]:
allLinks.splice(0,2);
transformItems(allLinks,distance,'soundcloud', bool)
break
case allLinks[3]:
allLinks.splice(0,3);
transformItems(allLinks,distance,'mixcloud', bool)
break
}
}
function linkListeners() {
const links = Array.from(document.querySelectorAll('.links__button'))
links.map((item) => {
addWidget(item);
item.addEventListener('click', (e) => {
e.preventDefault()
testBool = !testBool
wasClicked(e, testBool)
})
})
}
function addWidget(item) {
let widget
let positionOffset =0;
switch (item.id) {
case 'spotify':
widget = document
.createRange()
.createContextualFragment(
`<iframe style="border: 0; width: 88%; height: 250px;" id="${item.id}-widget" src='https://embed.spotify.com/?uri=spotify:artist:2OBZ4TbehlTMKtLmpBpKnq' frameborder='0' allowtransparency='true'></iframe>`,
)
break
case 'releases':
widget = document.createRange().createContextualFragment(
`<iframe class=widget id="${item.id}-widget" style="border: 0; width: 88%; height: 120px;" src="https://bandcamp.com/EmbeddedPlayer/album=3099874378/size=large/bgcol=333333/linkcol=ffffff/tracklist=false/artwork=small/transparent=true/" seamless><a href="http://instinctrecs.bandcamp.com/album/instinct-09-2">INSTINCT 09 by INSTINCT</a></iframe>
<iframe class=widget id="${item.id}-widget" style="border: 0; width: 88%; height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/827588753&color=%23242424&auto_play=false&hide_related=false&show_comments=false&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe><div id=${item.id} style="font-size: 10px; color: #cccccc;line-break: anywhere;word-break: normal;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-family: Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif;font-weight: 100;"><a href="https://soundcloud.com/holloway-95" target="_blank" style="color: #cccccc; text-decoration: none;"></a> · <a href="https://soundcloud.com/holloway-95/sets/dr-banana" target="_blank" style="color: #cccccc; text-decoration: none;"></a></div>`,
)
break
case 'soundcloud':
widget = document.createRange().createContextualFragment(
`<iframe class= S-widget id="${item.id}-widget" width="78%" height="20" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/718251409&color=%23645c54&inverse=false&auto_play=false&show_user=true"></iframe><div id=${item.id} style="font-size: 10px; color: #cccccc;line-break: anywhere;word-break: normal;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-family: Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif;font-weight: 100;"><a href="https://soundcloud.com/rinsefm" target="_blank" style="color: #cccccc; text-decoration: none;"></a><a href="https://soundcloud.com/rinsefm/soundbwoykillah251119" target="_blank" style="color: #cccccc; text-decoration: none;"></a></div>
<iframe class= S-widget id="${item.id}-widget" width="78%" height="20" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/698705842&color=%23645c54&inverse=false&auto_play=false&show_user=true"></iframe><div id=${item.id} style="font-size: 10px; color: #cccccc;line-break: anywhere;word-break: normal;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-family: Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif;font-weight: 100;"><a href="https://soundcloud.com/rinsefm" target="_blank" style="color: #cccccc; text-decoration: none;"></a><a href="https://soundcloud.com/rinsefm/allcentre181019" target="_blank" style="color: #cccccc; text-decoration: none;"></a></div>
`,
)
break
case 'mixcloud':
widget = document.createRange().createContextualFragment(
`<iframe width="88%" class=mix-widget id="${item.id}-widget" height="60" src="https://www.mixcloud.com/widget/iframe/?hide_cover=1&mini=1&feed=%2FNTSRadio%2Ffrom-the-depths-w-holloway-6th-march-2020%2F" frameborder="0" ></iframe>
<iframe width="88%" class=mix-widget id="${item.id}-widget" height="60" src="https://www.mixcloud.com/widget/iframe/?hide_cover=1&mini=1&feed=%2FNTSRadio%2Falexander-nut-19th-november-2019%2F" frameborder="0" ></iframe>
<iframe width="88%" class=mix-widget id="${item.id}-widget" height="60" src="https://www.mixcloud.com/widget/iframe/?hide_cover=1&mini=1&feed=%2FNTSRadio%2Ffauzia-19th-july-2019%2F" frameborder="0" ></iframe>`,
)
}
document.getElementById(`${item.id}`).appendChild(widget)
}
export { linkListeners }