-
Notifications
You must be signed in to change notification settings - Fork 0
/
df album-details.js
147 lines (120 loc) · 5.39 KB
/
df album-details.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
function getAlbumInformation() {
var vars = getUrlVars();
console.log(vars);
switch(vars.album.normalize('NFD').replace(/[\u0300-\u036f]/g, "")) {
case "princeRoyceTopSongs":
return princeRoyceTopSongs;
case "Colgando en tus manos":
return colgandoEnTusManos;
case "Corazon Profundo":
return corazonProfundo;
case "I Love You More Than Tacos":
return ILoveYouMoreThanTacos;
case "Filosofia Bachata y Zapatos de Goma":
return filosofiaBachataYZapatosDeGoma;
case "En Todo Estare":
return enTodoEstare;
case "Mi Nina Bonita":
return miNinaBonita;
case "Rompiendo Fronteras":
return rompiendoFronteras;
case "El Tren de los Momentos":
return elTrenDeLosMomentos;
case "Mil Ciudades":
return milCiudades;
case "Tus Ojos Mis Ojos":
return tusOjosMisOjos;
case "Mi Primer Millon":
return miPrimerMillon;
case "Todo Cambio":
return todoCambio;
default:
alert("ERROR: ALBUM CANNOT BE FOUND!\
\nThis is the album: " + vars.album);
}
}
function cartMouseUp(element) {
if (element.className == 'shopping-green')
element.className = 'shopping-blue';
else
element.className = 'shopping-green';
mouseup(element, 'icons/' + element.className + '/' + element.className + '.svg',
'icons/' + element.className + '/' + element.className + ' hover.svg');
var price = element.parentNode.previousSibling;
var artist = price.previousSibling.previousSibling.previousSibling;
var title = artist.previousSibling;
// console.log(price.innerHTML + " " + artist.innerHTML + " " + title.innerHTML + " " + document.getElementById("album-art").src)
if (title.innerHTML + artist.innerHTML in cart) {
delete cart[title.innerHTML + artist.innerHTML]
}
else {
cart[title.innerHTML + artist.innerHTML] = title.innerHTML + ";" + artist.innerHTML + ";" + price.innerHTML + ";" + document.getElementById("album-art").src;
}
// console.log(cart)
}
function loadSongs() {
var album = getAlbumInformation();
var titleMain = document.getElementsByClassName("title")[0];
var albumArtMain = document.getElementById("album-art");
var songListLabelMain = document.getElementsByClassName("song-list-label")[0];
titleMain.appendChild(document.createTextNode(album.title));
albumArtMain.src = album.albumArt;
songListLabelMain.appendChild(document.createTextNode(album.label));
var songDiv = document.getElementsByClassName("grid-container-album-details")[0];
var i;
for (i = 0; i < album.songs.length; i++) {
var songNode = document.createElement("div");
songNode.className = "song";
// Create the contents of song node
var indexNode = document.createElement("div");
var textNode = document.createTextNode(i + 1);
indexNode.appendChild(textNode);
var titleNode = document.createElement("div");
textNode = document.createTextNode(album.songs[i].title);
titleNode.appendChild(textNode);
var artistNode = document.createElement("div");
textNode = document.createTextNode(album.songs[i].artist);
artistNode.appendChild(textNode);
var timeNode = document.createElement("div");
textNode = document.createTextNode(album.songs[i].time);
timeNode.appendChild(textNode);
var ratingNode = document.createElement("div");
textNode = document.createTextNode(album.songs[i].rating);
ratingNode.appendChild(textNode);
var priceNode = document.createElement("div");
textNode = document.createTextNode(album.songs[i].price);
priceNode.appendChild(textNode);
var cartNode = document.createElement("div");
// Create img to cart node
var imgNode = document.createElement("img");
// Add class,src, and touch events to img
imgNode.className = "shopping-green";
imgNode.src = "icons/shopping-green/shopping-green.svg";
imgNode.onmouseover = function(){
mouseover(this,'icons/' + this.className + '/' + this.className + ' hover.svg')
};
imgNode.onmouseout= function(){
mouseout(this,'icons/' + this.className + '/' + this.className + '.svg')
};
imgNode.onmousedown= function(){
mousedown(this,'icons/' + this.className + '/' + this.className + ' clicked.svg')
};
imgNode.onmouseup= function(){
cartMouseUp(this);
};
imgNode.id = titleNode.innerHTML + artistNode.innerHTML;
// Append img to cart node
cartNode.appendChild(imgNode);
cartNode.style = "cursor: pointer;";
// Append children to songNode
songNode.appendChild(indexNode);
songNode.appendChild(titleNode);
songNode.appendChild(artistNode);
songNode.appendChild(timeNode);
songNode.appendChild(ratingNode);
songNode.appendChild(priceNode);
songNode.appendChild(cartNode);
// Append songNode to songDiv
songDiv.appendChild(songNode);
}
}