-
Notifications
You must be signed in to change notification settings - Fork 0
/
myVinyls.php
158 lines (138 loc) · 6.17 KB
/
myVinyls.php
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
<div style="margin-top: 60px;"></div>
<button class="upload-vinyl">Lemez feltöltés</button>
<div class="slide-container music-style-view">
<div class="slide-title-container">
<div class="slide-title"><a href="index.php">Saját lemezeim</a></div>
</div>
<div style="white-space: normal; height: 100%; overflow:hidden; display: table; text-align: center;" class="vinyls-container" id="genre-vinyls-container">
</div>
</div>
<script>
$.ajax({
url: "ajaxrequest.php",
method: "POST",
data: {
requestType: "getOwnDiscs"
},
dataType: "json",
success:function(data){
for(var i=0; i<data["discId"].length; i++){
$("#genre-vinyls-container").append(
"<div id='DMpop" + i + "' class='image-container'>" +
"<a href=index.php?location=specs&discId="+ data["discId"][i] +"><img class='vinyl-image' src='vinyls/" + data["discId"][i] + ".jpg'></a>" +
"<div class='image-description'>"+ data["album"][i] +"</div>" +
"</div>"
);
}
}
});
</script>
</body>
</html>
<script>
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
$(".upload-vinyl").click(function(){
$("body").append(
"<div class='upload-container'>" +
"<div class='upload-box'>"+
"<div class='close-upload'>" +
"<img onclick='removeMessageBox()' class='close-image' src='images/close.jpg'/>" +
"</div>" +
"<div class='upload-box-title'>" +
"Lemez Feltöltés" +
"</div>" +
"<div class='input-info-container'><div class='disc-specs'>" +
"<div class='disc-artist'>" +
"<div class='info'>A lemez előadója:</div>" +
"<input type='text' class='artist'>" +
"</div>" +
"<div class='disc-album-name'>" +
"<div class='info'>A lemez címe: </div>" +
"<input type='text' class='album-name'>" +
"</div>" +
"<div class='disc-genre'>" +
"<div class='info'>A lemez műfaja: </div>" +
"<select class='genre'>" +
"<option value='pop'>Pop</option>" +
"<option value='rock'>Rock</option>" +
"<option value='hipHop'>Hip-hop</option>" +
"<option value='electronical'>Elektornikus</option>" +
"<option value='classical'>Klasszikus</option>" +
"<option value='country'>Country</option>" +
"</select>" +
"</div>" +
"<div class='disc-released'>" +
"<div class='info'>A lemez kiadási éve: </div>" +
"<input type='text' class='released'>" +
"</div>" +
"<div class='disc-country'>" +
"<div class='info'>A lemez kiadási helye: </div>" +
"<input type='text' class='country'>" +
"</div>" +
"<div class='disc-condition'>" +
"<div class='info'>A lemez állapota: </div>" +
"<input type='text' class='condition'>" +
"</div>" +
"<div class='disc-description'>" +
"<div class='info'>Egyéb megjegyzés: </div>" +
"<input type='text' class='description'>" +
"</div>" +
"<div class='disc-image'>" +
"<label tabindex='0' class='input-file-title'>Kép a lemezről: </label>" +
"<input class='input-file' type='file' id='image' accept='image/*'>" +
"</div>" +
"<div class='upload-buttons-container'>" +
"<button type='button' onclick='removeUploadBox()' class='upload-button'>Mégsem</button>" +
"<button type='button' onClick='uploadVinyl()' class='upload-button'>Feltöltés</button>" +
"</div>" +
"</div></div>" +
"</div>" +
"</div>"
);
});
function removeMessageBox(){
$("div").remove(".upload-container");
}
function uploadVinyl(){
var fd = new FormData();
var files = $('#image')[0].files[0];
fd.append('image', files);
fd.append('requestType', "uploadVinyl");
fd.append('artist', $(".artist").val());
fd.append('albumName', $(".album-name").val());
fd.append('genre', $(".genre").val());
fd.append('released', $(".released").val());
fd.append('country', $(".country").val());
fd.append('condition', $(".condition").val());
fd.append('description', $(".description").val());
console.log(fd);
$.ajax({
url: "./ajaxrequest.php",
type: "POST",
data: fd,
contentType: false,
processData: false,
dataType: "json",
success: function(data){
if(data.success){
console.log(5);
removeMessageBox();
}else{
console.log(6);
alert(data.errorMessage);
}
},
error: function(err){
console.log(err.responseText);
}
});
}
</script>
</body>
</html>