| 15 |
- |
1 |
$(document).ready(function() {
|
| 52 |
- |
2 |
var x;
|
|
|
3 |
|
| 17 |
- |
4 |
$('[data-toggle="tooltip"]').tooltip({trigger : 'hover'});
|
|
|
5 |
$('[data-toggle2="tooltip"]').tooltip({trigger : 'hover'});
|
| 28 |
- |
6 |
$('[rel="tooltip"]').on('click', function() {$(this).tooltip('hide');});
|
| 23 |
- |
7 |
|
| 20 |
- |
8 |
$('.flexdatalist').flexdatalist();
|
|
|
9 |
$(function() {
|
|
|
10 |
$("input[id='searchTerm-flexdatalist']").clearer();
|
|
|
11 |
});
|
|
|
12 |
$('.flexdatalist').flexdatalist({minLength: 0, searchContain : true, noResultsText: ""}); /* reset after running clearer */
|
| 6 |
- |
13 |
|
| 15 |
- |
14 |
$(window).on('beforeunload', function() {
|
|
|
15 |
$(":submit").attr('disabled', 'disabled');
|
| 47 |
- |
16 |
document.body.style.cursor = "progress";
|
| 15 |
- |
17 |
});
|
|
|
18 |
|
| 43 |
- |
19 |
$(window).bind('resize orientationchange', paginationSetup);
|
|
|
20 |
|
| 15 |
- |
21 |
tableFilterButtons();
|
| 43 |
- |
22 |
paginationSetup();
|
| 52 |
- |
23 |
|
|
|
24 |
x = document.getElementById("tableFilterButton")
|
|
|
25 |
if (x) {
|
|
|
26 |
x.style.display = "none";
|
|
|
27 |
}
|
| 6 |
- |
28 |
});
|
| 11 |
- |
29 |
|
| 15 |
- |
30 |
function tableFilterButtons() {
|
|
|
31 |
$(".filterButton").click(function() {
|
|
|
32 |
$.post("filterTable.php", {
|
|
|
33 |
submit: $(this).attr("value"),
|
|
|
34 |
sessionTab: document.getElementById("sessionTab").value
|
|
|
35 |
}, function(data, status) {
|
|
|
36 |
if (status == "success") {
|
|
|
37 |
document.getElementById("productTable").innerHTML = data;
|
|
|
38 |
tableFilterButtons();
|
|
|
39 |
}
|
|
|
40 |
});
|
|
|
41 |
});
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
function initProgressBarModal(title) {
|
|
|
45 |
var elem = document.getElementById("progressBar");
|
|
|
46 |
elem.style.width = '0%';
|
|
|
47 |
elem.innerHTML = '0%';
|
|
|
48 |
|
|
|
49 |
elem = document.getElementById("progressBarHeader");
|
|
|
50 |
elem.innerHTML = title;
|
|
|
51 |
|
| 23 |
- |
52 |
$("#progressBarDiv").modal({backdrop: "static"});
|
| 15 |
- |
53 |
}
|
|
|
54 |
|
|
|
55 |
function updateProgressBar(width, message) {
|
|
|
56 |
var elem = document.getElementById("progressBar");
|
|
|
57 |
elem.style.width = width + '%';
|
|
|
58 |
elem.innerHTML = width.toFixed(0) + '%';
|
|
|
59 |
// bugbug document.getElementById("progressBarMessage").innerHTML = message;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
function endProgressBarModal() {
|
|
|
63 |
$("#progressBarDiv").modal("hide");
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
// Refresh the progress bar.
|
|
|
67 |
function refreshProgress() {
|
|
|
68 |
$.ajax({
|
|
|
69 |
url: "pbChecker.php?file=" + document.getElementById("sessionId").value + "_" + document.getElementById("sessionTab").value,
|
|
|
70 |
success: function(data) {
|
|
|
71 |
updateProgressBar(data.percent, data.message);
|
|
|
72 |
if (data.percent == 100) {
|
|
|
73 |
window.clearInterval(timer);
|
|
|
74 |
timer = window.setInterval(completeProgress, 1000);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
});
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
// End the progress bar.
|
|
|
81 |
function completeProgress() {
|
|
|
82 |
updateProgressBar(100, "Completed");
|
|
|
83 |
window.clearInterval(timer);
|
| 39 |
- |
84 |
endProgressBarModal();
|
| 15 |
- |
85 |
}
|
|
|
86 |
|
|
|
87 |
// Start the progress bar.
|
|
|
88 |
function progressBar(title) {
|
|
|
89 |
initProgressBarModal(title);
|
|
|
90 |
timer = window.setInterval(refreshProgress, 1000);
|
| 28 |
- |
91 |
}
|
|
|
92 |
|
| 52 |
- |
93 |
function saveTransfer(url) {
|
| 28 |
- |
94 |
var xhttp = new XMLHttpRequest();
|
|
|
95 |
xhttp.open("POST", "savetransfer.php", true);
|
|
|
96 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
| 52 |
- |
97 |
xhttp.send("target=" + btoa(url) + "&sessionTab=" + document.getElementById("sessionTab").value);
|
| 43 |
- |
98 |
}
|
|
|
99 |
|
| 52 |
- |
100 |
function addWishlist(id, field, cnt, wl) {
|
|
|
101 |
$(field).tooltip('hide');
|
|
|
102 |
$(field).remove();
|
|
|
103 |
var xhttp = new XMLHttpRequest();
|
|
|
104 |
xhttp.onreadystatechange = function() {
|
|
|
105 |
if (this.readyState == 4) {
|
|
|
106 |
json = JSON.parse(this.responseText);
|
|
|
107 |
switch (json.retval) {
|
|
|
108 |
case 0:
|
|
|
109 |
msg = "Added to wishlist.";
|
|
|
110 |
alert = "alert-success";
|
|
|
111 |
break;
|
|
|
112 |
case 1:
|
|
|
113 |
msg = "Already on the wishlist.";
|
|
|
114 |
alert = "alert-warning";
|
|
|
115 |
break;
|
|
|
116 |
default:
|
|
|
117 |
msg = "ERROR! Could not add to the wishlist.";
|
|
|
118 |
alert = "alert-dangere";
|
|
|
119 |
break;
|
|
|
120 |
}
|
|
|
121 |
document.getElementById("wishlistAdd" + cnt).innerHTML = "<div class=\"alert " + alert + " alert-dismissible mt-2 mb-0\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" + msg + "</div>";;
|
|
|
122 |
}
|
|
|
123 |
};
|
|
|
124 |
xhttp.open("POST", "wishlistDB.php", true);
|
|
|
125 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
|
126 |
xhttp.send("id=" + id + "&function=add&wl=" + wl + "&sessionTab=" + document.getElementById("sessionTab").value);
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
function deleteWishlist(id, field, title, artist) {
|
|
|
130 |
$(field).tooltip('hide');
|
|
|
131 |
if (confirm('Delete ' + title + ' by ' + artist + ' from wishlist?')) {
|
|
|
132 |
var parent = field.parentNode.parentNode;
|
|
|
133 |
var xhttp = new XMLHttpRequest();
|
|
|
134 |
xhttp.open("POST", "wishlistDB.php", true);
|
|
|
135 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
|
136 |
xhttp.send("function=delete&id=" + id + "&sessionTab=" + document.getElementById("sessionTab").value);
|
|
|
137 |
parent.parentNode.removeChild(parent);
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
function editWishlist(id, field) {
|
|
|
142 |
if (field !== null) {
|
|
|
143 |
$(field).tooltip('hide');
|
|
|
144 |
var parent = field.parentNode.parentNode;
|
|
|
145 |
|
|
|
146 |
var artist = mysqliHtmlDecode(parent.getElementsByTagName("td")[1].innerHTML);
|
|
|
147 |
var title = mysqliHtmlDecode(parent.getElementsByTagName("td")[2].innerHTML);
|
|
|
148 |
var barcode = parent.getElementsByTagName("td")[3].innerHTML.replace(/-/g, '');
|
|
|
149 |
var format = parent.getElementsByTagName("td")[5].innerHTML;
|
|
|
150 |
var price = parent.getElementsByTagName("td")[6].innerHTML;
|
|
|
151 |
|
|
|
152 |
document.getElementById("wlMsg").innerHTML = "";
|
|
|
153 |
document.getElementById("wlId").value = id;
|
|
|
154 |
document.getElementById("wlArtist").value = artist;
|
|
|
155 |
document.getElementById("wlTitle").value = title;
|
|
|
156 |
document.getElementById("wlBarcode").value = barcode;
|
|
|
157 |
document.getElementById("wlFormat").value = format;
|
|
|
158 |
document.getElementById("wlPrice").value = price;
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
$("#editWishlistModal").modal();
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
function saveEditedWishlist() {
|
|
|
165 |
var id = document.getElementById("wlId").value;
|
|
|
166 |
var field = document.getElementById("wlIdRow" + id);
|
|
|
167 |
var parent = field.parentNode;
|
|
|
168 |
var artist = document.getElementById("wlArtist").value;
|
|
|
169 |
var title = document.getElementById("wlTitle").value;
|
|
|
170 |
var barcode = document.getElementById("wlBarcode").value;
|
|
|
171 |
var format = document.getElementById("wlFormat").value;
|
|
|
172 |
var price = document.getElementById("wlPrice").value;
|
|
|
173 |
|
|
|
174 |
var xhttp = new XMLHttpRequest();
|
|
|
175 |
xhttp.onreadystatechange = function() {
|
|
|
176 |
if (this.readyState == 4) {
|
|
|
177 |
json = JSON.parse(this.responseText);
|
|
|
178 |
switch (json.retval) {
|
|
|
179 |
case 0:
|
|
|
180 |
parent.getElementsByTagName("td")[1].innerHTML = artist;
|
|
|
181 |
parent.getElementsByTagName("td")[2].innerHTML = title;
|
|
|
182 |
parent.getElementsByTagName("td")[3].innerHTML = barcode;
|
|
|
183 |
parent.getElementsByTagName("td")[4].innerHTML = barcode; // bugbug
|
|
|
184 |
parent.getElementsByTagName("td")[5].innerHTML = format;
|
|
|
185 |
parent.getElementsByTagName("td")[6].innerHTML = price;
|
|
|
186 |
parent.getElementsByTagName("td")[7].innerHTML = '$' + Number(price).toFixed(2); //bugbug
|
|
|
187 |
$("#editWishlistModal").modal('hide');
|
|
|
188 |
break;
|
|
|
189 |
case 1:
|
|
|
190 |
document.getElementById("wlMsg").innerHTML = "<div class=\"alert alert-danger alert-dismissible mt-0 mb-0\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" + json.msg + "</div>";
|
|
|
191 |
editWishlist(id, null)
|
|
|
192 |
break;
|
|
|
193 |
default:
|
|
|
194 |
document.getElementById("wlMsg").innerHTML = "<div class=\"alert alert-danger alert-dismissible mt-0 mb-0\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>Unknown Error. Please reload page.</div>";
|
|
|
195 |
break;
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
};
|
|
|
199 |
xhttp.open("POST", "wishlistDB.php", true);
|
|
|
200 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
|
201 |
xhttp.send("function=update&id="+id+"&artist="+encodeURIComponent(artist)+"&title="+encodeURIComponent(title)+"&barcode="+encodeURIComponent(barcode)+"&format="+encodeURIComponent(format)+"&price="+encodeURIComponent(price)+"&sessionTab=" + document.getElementById("sessionTab").value);
|
|
|
202 |
}
|
|
|
203 |
|
| 43 |
- |
204 |
// Pagination
|
|
|
205 |
function paginationSetup(){
|
|
|
206 |
$('#discogsDeck').paginate({
|
|
|
207 |
paginateElement: '.card',
|
|
|
208 |
elementsPerPage: paginationPerPage(),
|
|
|
209 |
effect: 'default',
|
|
|
210 |
firstButtonText: '<i class="fas fa-angle-double-left"></i>',
|
|
|
211 |
lastButtonText: '<i class="fas fa-angle-double-right"></i>',
|
|
|
212 |
prevButtonText: '<i class="fas fa-angle-left"></i>',
|
|
|
213 |
nextButtonText: '<i class="fas fa-angle-right"></i>',
|
|
|
214 |
extraButtonClasses: 'btn btn-primary px-2 shadow-sm'
|
|
|
215 |
});
|
|
|
216 |
$('[data-toggle="tooltip"]').tooltip({trigger : 'hover'});
|
|
|
217 |
$('[data-toggle2="tooltip"]').tooltip({trigger : 'hover'});
|
|
|
218 |
}
|
|
|
219 |
|
| 52 |
- |
220 |
function filterWishlist() {
|
|
|
221 |
var input, filter, table, tr, td, i, j, txtValue, flag;
|
|
|
222 |
input = document.getElementById("tableFilter");
|
|
|
223 |
filter = input.value.toUpperCase();
|
|
|
224 |
table = document.getElementById("wishlistTable");
|
|
|
225 |
tr = table.getElementsByTagName("tr");
|
|
|
226 |
document.getElementById("tableFilterButton").style.display = (filter.length > 0 ? "" : "none");
|
|
|
227 |
|
|
|
228 |
// Loop through all table rows, excluding the header, and hide those who don't match the search query
|
|
|
229 |
for (i = 1; i < tr.length; i++) {
|
|
|
230 |
td = tr[i].getElementsByTagName("td");
|
|
|
231 |
flag = "none";
|
|
|
232 |
|
|
|
233 |
for (j = 0; j < td.length; j++) {
|
|
|
234 |
if (td[j]) {
|
|
|
235 |
txtValue = td[j].textContent || td[j].innerText;
|
|
|
236 |
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
|
|
237 |
flag = "";
|
|
|
238 |
break;
|
|
|
239 |
}
|
|
|
240 |
}
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
tr[i].style.display = flag;
|
|
|
244 |
}
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
function mysqliHtmlDecode(str) {
|
|
|
248 |
str = str.replace(/&/g, '&');
|
|
|
249 |
str = str.replace(/</g, '<');
|
|
|
250 |
str = str.replace(/>/g, '>');
|
|
|
251 |
return str;
|
|
|
252 |
}
|
|
|
253 |
|
| 46 |
- |
254 |
// number of discogs entries per page according to screen size
|
| 43 |
- |
255 |
function paginationPerPage() {
|
|
|
256 |
width = $( document ).width();
|
|
|
257 |
if (width < 576){
|
|
|
258 |
return 1;
|
|
|
259 |
} else if (width < 768){
|
|
|
260 |
return 2;
|
|
|
261 |
} else if (width < 992){
|
|
|
262 |
return 3;
|
|
|
263 |
} else if (width < 1200){
|
|
|
264 |
return 4;
|
|
|
265 |
} else {
|
|
|
266 |
return 6;
|
|
|
267 |
}
|
|
|
268 |
}
|
| 46 |
- |
269 |
|
|
|
270 |
// sort table by column
|
|
|
271 |
function sortTable(table, col, colType) {
|
|
|
272 |
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
|
|
|
273 |
table = document.getElementById(table);
|
|
|
274 |
switching = true;
|
|
|
275 |
// Set the sorting direction to ascending:
|
|
|
276 |
dir = "asc";
|
|
|
277 |
/* Make a loop that will continue until no switching has been done: */
|
|
|
278 |
while (switching) {
|
|
|
279 |
// Start by saying: no switching is done:
|
|
|
280 |
switching = false;
|
|
|
281 |
rows = table.rows;
|
|
|
282 |
/* Loop through all table rows (except the first, which contains table headers): */
|
|
|
283 |
for (i = 1; i < (rows.length - 1); i++) {
|
|
|
284 |
// Start by saying there should be no switching:
|
|
|
285 |
shouldSwitch = false;
|
|
|
286 |
/* Get the two elements you want to compare, one from current row and one from the next: */
|
|
|
287 |
x = rows[i].getElementsByTagName("TD")[col];
|
|
|
288 |
y = rows[i + 1].getElementsByTagName("TD")[col];
|
|
|
289 |
/* Check if the two rows should switch place, based on the direction, asc or desc: */
|
|
|
290 |
if (dir == "asc") {
|
|
|
291 |
if (colType == 'numeric') {
|
|
|
292 |
if (Number(x.innerHTML) > Number(y.innerHTML.toLowerCase)) {
|
|
|
293 |
// If so, mark as a switch and break the loop:
|
|
|
294 |
shouldSwitch = true;
|
|
|
295 |
break;
|
|
|
296 |
}
|
|
|
297 |
} else /* if (colType == 'text') */ {
|
|
|
298 |
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
|
|
|
299 |
// If so, mark as a switch and break the loop:
|
|
|
300 |
shouldSwitch = true;
|
|
|
301 |
break;
|
|
|
302 |
}
|
|
|
303 |
}
|
|
|
304 |
} else if (dir == "desc") {
|
|
|
305 |
if (colType == 'numeric') {
|
|
|
306 |
if (Number(x.innerHTML) < Number(y.innerHTML)) {
|
|
|
307 |
// If so, mark as a switch and break the loop:
|
|
|
308 |
shouldSwitch = true;
|
|
|
309 |
break;
|
|
|
310 |
}
|
|
|
311 |
} else /* if (colType == 'text') */ {
|
|
|
312 |
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
|
|
|
313 |
// If so, mark as a switch and break the loop:
|
|
|
314 |
shouldSwitch = true;
|
|
|
315 |
break;
|
|
|
316 |
}
|
|
|
317 |
}
|
|
|
318 |
}
|
|
|
319 |
}
|
|
|
320 |
if (shouldSwitch) {
|
|
|
321 |
/* If a switch has been marked, make the switch and mark that a switch has been done: */
|
|
|
322 |
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
|
|
323 |
switching = true;
|
|
|
324 |
// Each time a switch is done, increase this count by 1:
|
|
|
325 |
switchcount++;
|
|
|
326 |
} else {
|
|
|
327 |
/* If no switching has been done AND the direction is "asc", set the direction to "desc" and run the while loop again. */
|
|
|
328 |
if (switchcount == 0 && dir == "asc") {
|
|
|
329 |
dir = "desc";
|
|
|
330 |
switching = true;
|
|
|
331 |
}
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
}
|
|
|
335 |
|