| 120 |
- |
1 |
var myTimer;
|
|
|
2 |
|
| 15 |
- |
3 |
$(document).ready(function() {
|
| 107 |
- |
4 |
$(window).on('beforeunload', function() {
|
|
|
5 |
$(":submit").attr('disabled', 'disabled');
|
|
|
6 |
document.body.style.cursor = "progress";
|
|
|
7 |
});
|
| 52 |
- |
8 |
|
| 120 |
- |
9 |
$(window).bind('resize orientationchange', function() { paginationSetup(); });
|
| 116 |
- |
10 |
paginationSetup();
|
| 81 |
- |
11 |
|
| 120 |
- |
12 |
if (document.getElementById("detailFilterForm")) {
|
| 107 |
- |
13 |
tableFilterButtons();
|
|
|
14 |
detailTableFilterButtons();
|
|
|
15 |
}
|
|
|
16 |
|
| 120 |
- |
17 |
if (document.getElementById("barcodeForm")) {
|
| 113 |
- |
18 |
barcodeFormButtons();
|
|
|
19 |
}
|
|
|
20 |
|
| 107 |
- |
21 |
// Floating Top Navigation Button:
|
|
|
22 |
window.onscroll = function() {
|
|
|
23 |
scrollFunction();
|
|
|
24 |
};
|
| 116 |
- |
25 |
|
|
|
26 |
flexdatalistSetup();
|
|
|
27 |
|
|
|
28 |
tooltipSetup();
|
| 120 |
- |
29 |
|
|
|
30 |
if (typeof addDiscogsEvents === "function") {
|
|
|
31 |
addDiscogsEvents();
|
|
|
32 |
}
|
| 6 |
- |
33 |
});
|
| 11 |
- |
34 |
|
| 107 |
- |
35 |
|
| 15 |
- |
36 |
function tableFilterButtons() {
|
| 124 |
- |
37 |
$(".filterButton").click(function() {
|
| 107 |
- |
38 |
$.post("filterTable.php", {
|
|
|
39 |
submit: $(this).attr("value"),
|
| 120 |
- |
40 |
sessionTab: document.getElementById("sessionTab").value,
|
|
|
41 |
nonce: document.getElementById("nonce").value
|
| 107 |
- |
42 |
},
|
|
|
43 |
function(data, status) {
|
|
|
44 |
if (status == "success") {
|
|
|
45 |
document.getElementById("productTable").innerHTML = data;
|
|
|
46 |
tableFilterButtons();
|
|
|
47 |
detailTableFilterButtons();
|
|
|
48 |
}
|
|
|
49 |
}
|
|
|
50 |
);
|
|
|
51 |
});
|
| 15 |
- |
52 |
}
|
|
|
53 |
|
| 66 |
- |
54 |
function detailTableFilterButtons() {
|
| 107 |
- |
55 |
$("#detailFilterForm").on('submit', function(e) {
|
|
|
56 |
e.preventDefault();
|
|
|
57 |
return false;
|
|
|
58 |
});
|
|
|
59 |
|
|
|
60 |
$("#detailTab").click(function() {
|
| 116 |
- |
61 |
x = document.getElementById("detailFilter");
|
|
|
62 |
if (x.style.display == "block") {
|
|
|
63 |
document.getElementById("detailTabArrow").innerHTML = '<i class="material-icons material-text">expand_more</i>';
|
|
|
64 |
x.style.display = "none";
|
|
|
65 |
} else {
|
|
|
66 |
document.getElementById("detailTabArrow").innerHTML = '<i class="material-icons material-text">expand_less</i>';
|
|
|
67 |
x.style.display = "block";
|
|
|
68 |
}
|
|
|
69 |
return false;
|
| 107 |
- |
70 |
});
|
| 116 |
- |
71 |
|
| 107 |
- |
72 |
$(".detailFilterButton").click(function() {
|
|
|
73 |
var formData = $("#detailFilterForm").serializeArray();
|
|
|
74 |
formData.push({
|
|
|
75 |
name: this.name,
|
| 121 |
- |
76 |
value: this.value,
|
| 107 |
- |
77 |
});
|
| 121 |
- |
78 |
formData.push({
|
|
|
79 |
name: "nonce",
|
|
|
80 |
value: document.getElementById("nonce").value
|
|
|
81 |
});
|
| 107 |
- |
82 |
$.post("filterTable.php",
|
|
|
83 |
formData,
|
|
|
84 |
function(data, status) {
|
|
|
85 |
if (status == "success") {
|
|
|
86 |
document.getElementById("productTable").innerHTML = data;
|
|
|
87 |
detailTableFilterButtons();
|
|
|
88 |
tableFilterButtons();
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
);
|
|
|
92 |
return false;
|
|
|
93 |
});
|
| 66 |
- |
94 |
}
|
|
|
95 |
|
| 113 |
- |
96 |
function barcodeFormButtons() {
|
|
|
97 |
$("#barcodeForm").on('submit', function(e) {
|
| 107 |
- |
98 |
e.preventDefault();
|
| 113 |
- |
99 |
return false;
|
| 107 |
- |
100 |
});
|
|
|
101 |
|
| 113 |
- |
102 |
$(".barcodeButton").click(function() {
|
|
|
103 |
var formData = $("#barcodeForm").serializeArray();
|
|
|
104 |
formData.push({
|
|
|
105 |
name: this.name,
|
|
|
106 |
value: this.value
|
|
|
107 |
});
|
| 121 |
- |
108 |
formData.push({
|
|
|
109 |
name: "nonce",
|
|
|
110 |
value: document.getElementById("nonce").value
|
|
|
111 |
});
|
| 113 |
- |
112 |
$.post("barcode.php",
|
|
|
113 |
formData,
|
|
|
114 |
function(data, status) {
|
|
|
115 |
if (status == "success") {
|
|
|
116 |
document.getElementById("barcodeResult").innerHTML = data;
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
);
|
| 121 |
- |
120 |
|
|
|
121 |
new MutationObserver(function() {
|
|
|
122 |
$("#barcodeSearchForm").off("submit");
|
|
|
123 |
if (document.getElementById("barcodeSearchTerm") && document.getElementById("barcodeSearchTerm").value !== "") {
|
|
|
124 |
$("#barcodeSearchForm").submit(function() {
|
|
|
125 |
progressBar("Searching for:<br><br><strong>" + document.getElementById("barcodeSearchTerm").value + "</strong>");
|
|
|
126 |
});
|
|
|
127 |
}
|
|
|
128 |
}).observe(document.getElementById("barcodeResult"), { childList: true, subtree: true });
|
|
|
129 |
|
| 113 |
- |
130 |
return false;
|
|
|
131 |
});
|
| 66 |
- |
132 |
}
|
| 116 |
- |
133 |
|
| 64 |
- |
134 |
function alertAutoClose() {
|
| 107 |
- |
135 |
window.setTimeout(function() {
|
|
|
136 |
$(".alert").fadeTo(1000, 0).slideUp(1000, function() {
|
|
|
137 |
$(this).remove();
|
|
|
138 |
});
|
|
|
139 |
}, 3000);
|
| 64 |
- |
140 |
}
|
|
|
141 |
|
| 15 |
- |
142 |
function initProgressBarModal(title) {
|
| 107 |
- |
143 |
var elem = document.getElementById("progressBar");
|
|
|
144 |
elem.style.width = '0%';
|
|
|
145 |
elem.innerHTML = '0%';
|
| 15 |
- |
146 |
|
| 107 |
- |
147 |
elem = document.getElementById("progressBarHeader");
|
|
|
148 |
elem.innerHTML = title;
|
| 15 |
- |
149 |
|
| 107 |
- |
150 |
elem = document.getElementById("progressBarMessage");
|
|
|
151 |
elem.innerHTML = "";
|
| 84 |
- |
152 |
|
| 107 |
- |
153 |
$("#progressBarDiv").modal({
|
|
|
154 |
backdrop: "static"
|
|
|
155 |
});
|
| 15 |
- |
156 |
}
|
|
|
157 |
|
|
|
158 |
function updateProgressBar(width, message) {
|
| 107 |
- |
159 |
var elem = document.getElementById("progressBar");
|
|
|
160 |
if (elem && width) {
|
|
|
161 |
elem.style.width = width + '%';
|
|
|
162 |
elem.innerHTML = width.toFixed(0) + '%';
|
|
|
163 |
// bugbug document.getElementById("progressBarMessage").innerHTML = message;
|
|
|
164 |
}
|
| 15 |
- |
165 |
}
|
|
|
166 |
|
|
|
167 |
function endProgressBarModal() {
|
| 107 |
- |
168 |
$("#progressBarDiv").modal("hide");
|
| 15 |
- |
169 |
}
|
|
|
170 |
|
|
|
171 |
// Refresh the progress bar.
|
|
|
172 |
function refreshProgress() {
|
| 107 |
- |
173 |
$.ajax({
|
| 122 |
- |
174 |
url: "pbChecker.php?file=" + document.getElementById("sessionId").value + "_" + document.getElementById("sessionTab").value + "&nonce=" + document.getElementById("nonce").value,
|
| 107 |
- |
175 |
success: function(data) {
|
|
|
176 |
updateProgressBar(data.percent, data.message);
|
|
|
177 |
if (data.percent >= 100) {
|
| 120 |
- |
178 |
window.clearInterval(myTimer);
|
|
|
179 |
myTimer = window.setInterval(function() { completeProgress(); }, 1000);
|
| 107 |
- |
180 |
}
|
|
|
181 |
}
|
|
|
182 |
});
|
| 15 |
- |
183 |
}
|
|
|
184 |
|
|
|
185 |
// End the progress bar.
|
|
|
186 |
function completeProgress() {
|
| 107 |
- |
187 |
updateProgressBar(100, "Completed");
|
| 120 |
- |
188 |
window.clearInterval(myTimer);
|
| 107 |
- |
189 |
endProgressBarModal();
|
| 15 |
- |
190 |
}
|
|
|
191 |
|
|
|
192 |
// Start the progress bar.
|
|
|
193 |
function progressBar(title) {
|
| 107 |
- |
194 |
initProgressBarModal(title);
|
| 121 |
- |
195 |
myTimer = window.setInterval(function() { refreshProgress(); }, 500);
|
| 28 |
- |
196 |
}
|
|
|
197 |
|
| 52 |
- |
198 |
function saveTransfer(url) {
|
| 107 |
- |
199 |
var xhttp = new XMLHttpRequest();
|
|
|
200 |
xhttp.open("POST", "savetransfer.php", true);
|
|
|
201 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
| 122 |
- |
202 |
xhttp.send("target=" + btoa(url) + "&sessionTab=" + document.getElementById("sessionTab").value + "&nonce=" + document.getElementById("nonce").value);
|
| 43 |
- |
203 |
}
|
|
|
204 |
|
| 52 |
- |
205 |
function addWishlist(id, field, cnt, wl) {
|
| 107 |
- |
206 |
$(field).tooltip('hide');
|
|
|
207 |
$(field).remove();
|
|
|
208 |
var xhttp = new XMLHttpRequest();
|
|
|
209 |
xhttp.onreadystatechange = function() {
|
|
|
210 |
if (this.readyState == 4) {
|
|
|
211 |
json = JSON.parse(this.responseText);
|
|
|
212 |
switch (json.retval) {
|
|
|
213 |
case 0:
|
|
|
214 |
msg = "Added to wishlist.";
|
|
|
215 |
alertTxt = "alert-success";
|
|
|
216 |
break;
|
|
|
217 |
case 1:
|
|
|
218 |
msg = "Already on the wishlist.";
|
|
|
219 |
alertTxt = "alert-warning";
|
|
|
220 |
break;
|
|
|
221 |
default:
|
|
|
222 |
msg = "ERROR! Could not add to the wishlist.";
|
|
|
223 |
alertTxt = "alert-danger";
|
|
|
224 |
break;
|
|
|
225 |
}
|
|
|
226 |
document.getElementById("wishlistAdd" + cnt).innerHTML = "<div class=\"alert " + alertTxt + " alert-dismissible mt-2 mb-0\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>" + msg + "</div>";
|
|
|
227 |
alertAutoClose();
|
|
|
228 |
}
|
|
|
229 |
};
|
|
|
230 |
xhttp.open("POST", "wishlistDB.php", true);
|
|
|
231 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
| 122 |
- |
232 |
xhttp.send("id=" + id + "&function=add&wl=" + wl + "&sessionTab=" + document.getElementById("sessionTab").value + "&nonce=" + document.getElementById("nonce").value);
|
| 52 |
- |
233 |
}
|
|
|
234 |
|
|
|
235 |
function deleteWishlist(id, field, title, artist) {
|
| 107 |
- |
236 |
$(field).tooltip('hide');
|
|
|
237 |
if (confirm('Remove ' + title + ' by ' + artist + ' from wishlist?')) {
|
|
|
238 |
var parent = field.parentNode.parentNode.parentNode;
|
|
|
239 |
var xhttp = new XMLHttpRequest();
|
|
|
240 |
xhttp.open("POST", "wishlistDB.php", true);
|
|
|
241 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
| 122 |
- |
242 |
xhttp.send("function=delete&id=" + id + "&sessionTab=" + document.getElementById("sessionTab").value + "&nonce=" + document.getElementById("nonce").value);
|
| 107 |
- |
243 |
parent.parentNode.removeChild(parent);
|
|
|
244 |
}
|
| 52 |
- |
245 |
}
|
|
|
246 |
|
|
|
247 |
function editWishlist(id, field) {
|
| 107 |
- |
248 |
if (field !== null) {
|
|
|
249 |
$(field).tooltip('hide');
|
|
|
250 |
var parent = field.parentNode.parentNode.parentNode;
|
| 52 |
- |
251 |
|
| 107 |
- |
252 |
var artist = mysqliHtmlDecode(parent.getElementsByTagName("td")[1].innerHTML);
|
|
|
253 |
var title = mysqliHtmlDecode(parent.getElementsByTagName("td")[2].innerHTML);
|
|
|
254 |
var barcode = parent.getElementsByTagName("td")[3].innerHTML.replace(/-/g, '');
|
|
|
255 |
var cond = parent.getElementsByTagName("td")[5].innerHTML;
|
|
|
256 |
var format = parent.getElementsByTagName("td")[6].innerHTML;
|
|
|
257 |
var price = parent.getElementsByTagName("td")[7].innerHTML;
|
| 52 |
- |
258 |
|
| 107 |
- |
259 |
document.getElementById("wlMsg").innerHTML = "";
|
|
|
260 |
document.getElementById("wlId").value = id;
|
|
|
261 |
document.getElementById("wlArtist").value = artist;
|
|
|
262 |
document.getElementById("wlTitle").value = title;
|
|
|
263 |
document.getElementById("wlBarcode").value = barcode;
|
|
|
264 |
document.getElementById("wlCond").value = cond;
|
|
|
265 |
document.getElementById("wlFormat").value = format;
|
|
|
266 |
document.getElementById("wlPrice").value = price;
|
|
|
267 |
}
|
| 52 |
- |
268 |
|
| 116 |
- |
269 |
$("#editWishlistModal").modal({
|
|
|
270 |
backdrop: 'static',
|
|
|
271 |
keyboard: false
|
|
|
272 |
});
|
| 52 |
- |
273 |
}
|
|
|
274 |
|
|
|
275 |
function saveEditedWishlist() {
|
| 107 |
- |
276 |
var id = document.getElementById("wlId").value;
|
|
|
277 |
var field = document.getElementById("wlIdRow" + id);
|
|
|
278 |
var parent = field.parentNode;
|
|
|
279 |
var artist = document.getElementById("wlArtist").value;
|
|
|
280 |
var title = document.getElementById("wlTitle").value;
|
|
|
281 |
var barcode = document.getElementById("wlBarcode").value;
|
|
|
282 |
var cond = document.getElementById("wlCond").value;
|
|
|
283 |
var format = document.getElementById("wlFormat").value;
|
|
|
284 |
var price = document.getElementById("wlPrice").value;
|
| 52 |
- |
285 |
|
| 107 |
- |
286 |
var xhttp = new XMLHttpRequest();
|
|
|
287 |
xhttp.onreadystatechange = function() {
|
|
|
288 |
if (this.readyState == 4) {
|
|
|
289 |
json = JSON.parse(this.responseText);
|
|
|
290 |
switch (json.retval) {
|
|
|
291 |
case 0:
|
|
|
292 |
parent.getElementsByTagName("td")[1].innerHTML = artist;
|
|
|
293 |
parent.getElementsByTagName("td")[2].innerHTML = title;
|
|
|
294 |
parent.getElementsByTagName("td")[3].innerHTML = barcode;
|
|
|
295 |
parent.getElementsByTagName("td")[4].innerHTML = barcode; // bugbug Format
|
|
|
296 |
parent.getElementsByTagName("td")[5].innerHTML = cond;
|
|
|
297 |
parent.getElementsByTagName("td")[6].innerHTML = format;
|
|
|
298 |
parent.getElementsByTagName("td")[7].innerHTML = price;
|
|
|
299 |
parent.getElementsByTagName("td")[8].innerHTML = '$' + Number(price).toFixed(2); // bugbug Format
|
|
|
300 |
$("#editWishlistModal").modal('hide');
|
|
|
301 |
break;
|
|
|
302 |
case 1:
|
|
|
303 |
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>";
|
|
|
304 |
editWishlist(id, null);
|
|
|
305 |
break;
|
|
|
306 |
default:
|
|
|
307 |
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>";
|
|
|
308 |
break;
|
|
|
309 |
}
|
|
|
310 |
}
|
|
|
311 |
};
|
|
|
312 |
xhttp.open("POST", "wishlistDB.php", true);
|
|
|
313 |
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
| 122 |
- |
314 |
xhttp.send("function=update&id=" + id + "&artist=" + encodeURIComponent(artist) + "&title=" + encodeURIComponent(title) + "&barcode=" + encodeURIComponent(barcode) + "&cond=" + encodeURIComponent(cond) + "&format=" + encodeURIComponent(format) + "&price=" + encodeURIComponent(price) + "&sessionTab=" + document.getElementById("sessionTab").value + "&nonce=" + document.getElementById("nonce").value);
|
| 52 |
- |
315 |
}
|
|
|
316 |
|
| 116 |
- |
317 |
// Flex Data List
|
|
|
318 |
function flexdatalistSetup() {
|
| 118 |
- |
319 |
if ($.fn.flexdatalist && $.fn.clearer) {
|
| 116 |
- |
320 |
$('.flexdatalist').flexdatalist();
|
|
|
321 |
$(function() {
|
|
|
322 |
$("input[id='searchTerm-flexdatalist']").clearer();
|
|
|
323 |
});
|
|
|
324 |
$('.flexdatalist').flexdatalist({
|
|
|
325 |
minLength: 0,
|
|
|
326 |
searchContain: true,
|
|
|
327 |
noResultsText: ""
|
|
|
328 |
}); /* reset after running clearer */
|
|
|
329 |
} else {
|
| 120 |
- |
330 |
setTimeout(function () { flexdatalistSetup(); }, 100);
|
| 116 |
- |
331 |
}
|
|
|
332 |
}
|
|
|
333 |
|
| 43 |
- |
334 |
// Pagination
|
| 65 |
- |
335 |
function paginationSetup() {
|
| 120 |
- |
336 |
if ($.fn.paginate && $.fn.modal && $.fn.tooltip && typeof Popper !== "undefined") {
|
| 116 |
- |
337 |
if (document.getElementById("discogsDeck") !== null) {
|
|
|
338 |
$("[id^=masterModal]").modal("hide");
|
|
|
339 |
$('#discogsDeck').paginate({
|
|
|
340 |
paginateElement: '.card',
|
|
|
341 |
elementsPerPage: paginationPerPage(),
|
|
|
342 |
effect: 'default',
|
|
|
343 |
firstButtonText: '<i class="material-icons material-text">first_page</i>',
|
|
|
344 |
lastButtonText: '<i class="material-icons material-text">last_page</i>',
|
|
|
345 |
prevButtonText: '<i class="material-icons material-text">navigate_before</i>',
|
|
|
346 |
nextButtonText: '<i class="material-icons material-text">navigate_next</i>',
|
| 124 |
- |
347 |
extraButtonClasses: 'btn bg-info px-2 shadow-sm',
|
| 120 |
- |
348 |
functionOnNav: function () { tooltipSetup(); if (typeof addDiscogsEvents === "function") { addDiscogsEvents();} }
|
| 116 |
- |
349 |
});
|
|
|
350 |
tooltipSetup();
|
| 120 |
- |
351 |
if (typeof addDiscogsEvents === "function") {
|
|
|
352 |
addDiscogsEvents();
|
|
|
353 |
}
|
| 116 |
- |
354 |
}
|
|
|
355 |
} else {
|
| 120 |
- |
356 |
setTimeout(function () { paginationSetup(); }, 100);
|
| 116 |
- |
357 |
}
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
// Tooltip Setup
|
|
|
361 |
function tooltipSetup() {
|
|
|
362 |
if ($.fn.tooltip && typeof Popper != 'undefined') {
|
| 107 |
- |
363 |
$('[data-toggle="tooltip"]').tooltip({
|
|
|
364 |
trigger: 'hover'
|
|
|
365 |
});
|
| 116 |
- |
366 |
|
| 107 |
- |
367 |
$('[data-toggle2="tooltip"]').tooltip({
|
|
|
368 |
trigger: 'hover'
|
|
|
369 |
});
|
| 116 |
- |
370 |
} else {
|
| 120 |
- |
371 |
setTimeout(function () { tooltipSetup(); }, 100);
|
| 107 |
- |
372 |
}
|
| 43 |
- |
373 |
}
|
|
|
374 |
|
| 52 |
- |
375 |
function filterWishlist() {
|
| 107 |
- |
376 |
var input, filter, table, tr, td, i, j, txtValue, flag;
|
|
|
377 |
input = document.getElementById("tableFilter");
|
|
|
378 |
filter = input.value.toUpperCase();
|
|
|
379 |
table = document.getElementById("wishlistTable");
|
|
|
380 |
tr = table.getElementsByTagName("tr");
|
|
|
381 |
document.getElementById("tableFilterButton").style.display = (filter.length > 0 ? "" : "none");
|
| 52 |
- |
382 |
|
| 107 |
- |
383 |
// Loop through all table rows, excluding the header, and hide those who don't match the search query
|
|
|
384 |
for (i = 1; i < tr.length; i++) {
|
|
|
385 |
td = tr[i].getElementsByTagName("td");
|
|
|
386 |
flag = "none";
|
| 52 |
- |
387 |
|
| 107 |
- |
388 |
for (j = 0; j < td.length; j++) {
|
|
|
389 |
if (td[j]) {
|
|
|
390 |
txtValue = td[j].textContent || td[j].innerText;
|
|
|
391 |
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
|
|
392 |
flag = "";
|
|
|
393 |
break;
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
}
|
| 52 |
- |
397 |
|
| 107 |
- |
398 |
tr[i].style.display = flag;
|
|
|
399 |
}
|
| 52 |
- |
400 |
}
|
|
|
401 |
|
|
|
402 |
function mysqliHtmlDecode(str) {
|
| 107 |
- |
403 |
str = str.replace(/&/g, '&');
|
|
|
404 |
str = str.replace(/</g, '<');
|
|
|
405 |
str = str.replace(/>/g, '>');
|
|
|
406 |
return str;
|
| 52 |
- |
407 |
}
|
|
|
408 |
|
| 46 |
- |
409 |
// number of discogs entries per page according to screen size
|
| 43 |
- |
410 |
function paginationPerPage() {
|
| 107 |
- |
411 |
var width = $(window).width();
|
|
|
412 |
var num = Math.floor(width / 210);
|
|
|
413 |
if (num > 9) {
|
|
|
414 |
num = 9;
|
|
|
415 |
} else if (width < 576) {
|
|
|
416 |
num = 1;
|
|
|
417 |
}
|
|
|
418 |
return num;
|
| 43 |
- |
419 |
}
|
| 46 |
- |
420 |
|
|
|
421 |
// sort table by column
|
|
|
422 |
function sortTable(table, col, colType) {
|
| 107 |
- |
423 |
var rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
|
|
|
424 |
table = document.getElementById(table);
|
|
|
425 |
switching = true;
|
|
|
426 |
// Set the sorting direction to ascending:
|
|
|
427 |
dir = "asc";
|
|
|
428 |
/* Make a loop that will continue until no switching has been done: */
|
|
|
429 |
while (switching) {
|
|
|
430 |
// Start by saying: no switching is done:
|
|
|
431 |
switching = false;
|
|
|
432 |
rows = table.rows;
|
|
|
433 |
/* Loop through all table rows (except the first, which contains table headers): */
|
|
|
434 |
for (i = 1; i < (rows.length - 1); i++) {
|
|
|
435 |
// Start by saying there should be no switching:
|
|
|
436 |
shouldSwitch = false;
|
|
|
437 |
/* Get the two elements you want to compare, one from current row and one from the next: */
|
|
|
438 |
x = rows[i].getElementsByTagName("TD")[col];
|
|
|
439 |
y = rows[i + 1].getElementsByTagName("TD")[col];
|
|
|
440 |
/* Check if the two rows should switch place, based on the direction, asc or desc: */
|
|
|
441 |
if (dir == "asc") {
|
|
|
442 |
if (colType == 'numeric') {
|
| 120 |
- |
443 |
if (Number(x.innerHTML) > Number(y.innerHTML)) {
|
| 107 |
- |
444 |
// If so, mark as a switch and break the loop:
|
|
|
445 |
shouldSwitch = true;
|
|
|
446 |
break;
|
|
|
447 |
}
|
|
|
448 |
} else /* if (colType == 'text') */ {
|
|
|
449 |
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
|
|
|
450 |
// If so, mark as a switch and break the loop:
|
|
|
451 |
shouldSwitch = true;
|
|
|
452 |
break;
|
|
|
453 |
}
|
|
|
454 |
}
|
|
|
455 |
} else if (dir == "desc") {
|
|
|
456 |
if (colType == 'numeric') {
|
|
|
457 |
if (Number(x.innerHTML) < Number(y.innerHTML)) {
|
|
|
458 |
// If so, mark as a switch and break the loop:
|
|
|
459 |
shouldSwitch = true;
|
|
|
460 |
break;
|
|
|
461 |
}
|
|
|
462 |
} else /* if (colType == 'text') */ {
|
|
|
463 |
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
|
|
|
464 |
// If so, mark as a switch and break the loop:
|
|
|
465 |
shouldSwitch = true;
|
|
|
466 |
break;
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
}
|
|
|
470 |
}
|
|
|
471 |
if (shouldSwitch) {
|
|
|
472 |
/* If a switch has been marked, make the switch and mark that a switch has been done: */
|
|
|
473 |
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
|
|
474 |
switching = true;
|
|
|
475 |
// Each time a switch is done, increase this count by 1:
|
|
|
476 |
switchcount++;
|
|
|
477 |
} else {
|
| 120 |
- |
478 |
/* If no switching has been done AND the direction is "asc", set the direction to "desc" and run the whole loop again. */
|
| 107 |
- |
479 |
if (switchcount === 0 && dir == "asc") {
|
|
|
480 |
dir = "desc";
|
|
|
481 |
switching = true;
|
|
|
482 |
}
|
|
|
483 |
}
|
|
|
484 |
}
|
| 66 |
- |
485 |
}
|
| 81 |
- |
486 |
|
|
|
487 |
function scrollFunction() {
|
| 107 |
- |
488 |
var topButton = document.getElementById("topBtn");
|
| 81 |
- |
489 |
|
| 107 |
- |
490 |
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
|
|
|
491 |
topButton.style.display = "block";
|
|
|
492 |
} else {
|
|
|
493 |
topButton.style.display = "none";
|
|
|
494 |
}
|
| 81 |
- |
495 |
}
|
|
|
496 |
|
|
|
497 |
function topFunction() {
|
| 107 |
- |
498 |
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
| 124 |
- |
499 |
}
|