Subversion Repositories cheapmusic

Rev

Rev 141 | Rev 146 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

function tableFilterButtons(){$(".filterButton").click(function(){$.post("filterTable.php",{submitBtn:$(this).attr("value"),sessionTab:document.getElementById("sessionTab").value,nonce:document.getElementById("nonce").value},function(e,t){"success"==t&&(document.getElementById("productTable").innerHTML=e,tableFilterButtons(),detailTableFilterButtons(),dataTableSetup())})})}function detailTableFilterButtons(){$("#detailFilterForm").on("submit",function(e){return e.preventDefault(),!1}),$("#detailTab").click(function(){x=document.getElementById("detailFilter"),"block"==x.style.display?(document.getElementById("detailTabArrow").innerHTML='<i class="material-icons material-text">expand_more</i>',x.style.display="none"):(document.getElementById("detailTabArrow").innerHTML='<i class="material-icons material-text">expand_less</i>',x.style.display="block")}),$(".detailFilterButton").click(function(){var e=$("#detailFilterForm").serializeArray();e.push({name:this.name,value:this.value}),e.push({name:"nonce",value:document.getElementById("nonce").value}),$.post("filterTable.php",e,function(e,t){"success"==t&&(document.getElementById("productTable").innerHTML=e,detailTableFilterButtons(),tableFilterButtons(),dataTableSetup())})})}function barcodeFormButtons(){$("#barcodeForm").on("submit",function(e){return e.preventDefault(),!1}),$(".barcodeButton").click(function(){var e=$("#barcodeForm").serializeArray();e.push({name:this.name,value:this.value}),e.push({name:"nonce",value:document.getElementById("nonce").value}),$.post("barcode.php",e,function(e,t){"success"==t&&(document.getElementById("barcodeResult").innerHTML=e)}),new MutationObserver(function(){$("#barcodeSearchForm").off("submit"),document.getElementById("barcodeSearchTerm")&&""!==document.getElementById("barcodeSearchTerm").value&&$("#barcodeSearchForm").submit(function(){searchTitle="Searching for:<br><br><strong>"+document.getElementById("barcodeSearchTerm").value+"</strong>",window.google_tag_manager&&window.ga&&ga.create?window.dataLayer.push({event:"search",search_term:document.getElementById("barcodeSearchTerm").value,eventCallback:function(){progressBar(searchTitle)}}):progressBar(searchTitle)})}).observe(document.getElementById("barcodeResult"),{childList:!0,subtree:!0})})}function alertAutoClose(){window.setTimeout(function(){$(".alert").fadeTo(1e3,0).slideUp(1e3,function(){$(this).remove()})},3e3)}function initProgressBarModal(e){var t=document.getElementById("progressBar");t.style.width="0",t.innerHTML="0%",t=document.getElementById("progressBarHeader"),t.innerHTML=e,t=document.getElementById("progressBarMessage"),t.innerHTML="",$("#progressBarDiv").modal({backdrop:"static"})}function updateProgressBar(e,t){var n=document.getElementById("progressBar");n&&e&&(n.style.width=e+"%",n.innerHTML=e.toFixed(0)+"%")}function endProgressBarModal(){$("#progressBarDiv").modal("hide")}function refreshProgress(){$.ajax({url:"pbChecker.php?file="+document.getElementById("sessionId").value+"_"+document.getElementById("sessionTab").value+"&nonce="+document.getElementById("nonce").value,success:function(e){updateProgressBar(e.percent,e.message),e.percent>=100&&(window.clearInterval(myTimer),myTimer=window.setInterval(function(){completeProgress()},1e3))}})}function completeProgress(){updateProgressBar(100,"Completed"),window.clearInterval(myTimer),endProgressBarModal()}function progressBar(e){initProgressBarModal(e),myTimer=window.setInterval(function(){refreshProgress()},500)}function saveTransfer(e){var t=new XMLHttpRequest;t.open("POST","savetransfer.php",!0),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.send("target="+btoa(e)+"&sessionTab="+document.getElementById("sessionTab").value+"&nonce="+document.getElementById("nonce").value)}function addWishlist(e,t,n,a){$(t).tooltip("hide"),$(t).children("i").first().html("library_add_check");var o=new XMLHttpRequest;o.onreadystatechange=function(){if(4==this.readyState){switch(json=JSON.parse(this.responseText),json.retval){case 0:msg="Added to wishlist.",alertTxt="alert-success";break;case 1:msg="Already on the wishlist.",alertTxt="alert-warning";break;default:msg="ERROR! Could not add to the wishlist.",alertTxt="alert-danger"}document.getElementById("wishlistAdd"+n).innerHTML='<div class="alert '+alertTxt+' alert-dismissible mt-2 mb-0"><button type="button" class="close" data-dismiss="alert">&times;</button>'+msg+"</div>",alertAutoClose()}},o.open("POST","wishlistDB.php",!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.send("id="+e+"&function=add&wl="+a+"&sessionTab="+document.getElementById("sessionTab").value+"&nonce="+document.getElementById("nonce").value)}function deleteWishlist(e,t,n,a){if($(t).tooltip("hide"),confirm("Remove "+n+" by "+a+" from wishlist?")){var o=new XMLHttpRequest;o.open("POST","wishlistDB.php",!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.send("function=delete&id="+e+"&sessionTab="+document.getElementById("sessionTab").value+"&nonce="+document.getElementById("nonce").value),row=t.closest("tr"),$(row).hasClass("child")&&row.previousElementSibling.remove(),row.remove()}}function editWishlist(e,t){if(null!==t){$(t).tooltip("hide");var n=t.closest("tr");$(n).hasClass("child")&&(n=n.previousElementSibling);var a=mysqliHtmlDecode(n.getElementsByTagName("td")[1].innerHTML),o=mysqliHtmlDecode(n.getElementsByTagName("td")[2].innerHTML),l=n.getElementsByTagName("td")[3].getAttribute("data-order"),i=n.getElementsByTagName("td")[4].innerHTML,s=n.getElementsByTagName("td")[5].innerHTML,r=n.getElementsByTagName("td")[6].getAttribute("data-order");document.getElementById("wlMsg").innerHTML="",document.getElementById("wlId").value=e,document.getElementById("wlArtist").value=a,document.getElementById("wlTitle").value=o,document.getElementById("wlBarcode").value=l,document.getElementById("wlCond").value=i,document.getElementById("wlFormat").value=s,document.getElementById("wlPrice").value=r}$("#editWishlistModal").modal({backdrop:"static",keyboard:!1})}function saveEditedWishlist(){var e=document.getElementById("wlId").value,t=document.getElementById("wlIdRow"+e),n=document.getElementById("wlArtist").value,a=document.getElementById("wlTitle").value,o=document.getElementById("wlBarcode").value,l=document.getElementById("wlCond").value,i=document.getElementById("wlFormat").value,s=document.getElementById("wlPrice").value,r=t.closest("table"),d=new XMLHttpRequest;d.onreadystatechange=function(){if(4==this.readyState)switch(json=JSON.parse(this.responseText),json.retval){case 0:$(r).DataTable().cell(t.getElementsByTagName("td")[1]).data(n),t.setAttribute("data-artist",n),$(r).DataTable().cell(t.getElementsByTagName("td")[2]).data(a),t.setAttribute("data-title",a),t.getElementsByTagName("td")[3].setAttribute("data-order",o),$(r).DataTable().cell(t.getElementsByTagName("td")[3]).data(o),t.setAttribute("data-barcode",o),$(r).DataTable().cell(t.getElementsByTagName("td")[4]).data(l),$(r).DataTable().cell(t.getElementsByTagName("td")[5]).data(i),t.getElementsByTagName("td")[6].setAttribute("data-order",s),$(r).DataTable().cell(t.getElementsByTagName("td")[6]).data("$"+Number(s).toFixed(2)),$(r).DataTable().draw(),$("#editWishlistModal").modal("hide");break;case 1:document.getElementById("wlMsg").innerHTML='<div class="alert alert-danger alert-dismissible mt-0 mb-0"><button type="button" class="close" data-dismiss="alert">&times;</button>'+json.msg+"</div>",editWishlist(e,null);break;default:document.getElementById("wlMsg").innerHTML='<div class="alert alert-danger alert-dismissible mt-0 mb-0"><button type="button" class="close" data-dismiss="alert">&times;</button>Unknown Error. Please reload page.</div>'}},d.open("POST","wishlistDB.php",!0),d.setRequestHeader("Content-type","application/x-www-form-urlencoded"),d.send("function=update&id="+e+"&artist="+encodeURIComponent(n)+"&title="+encodeURIComponent(a)+"&barcode="+encodeURIComponent(o)+"&cond="+encodeURIComponent(l)+"&format="+encodeURIComponent(i)+"&price="+encodeURIComponent(s)+"&sessionTab="+document.getElementById("sessionTab").value+"&nonce="+document.getElementById("nonce").value)}function flexdatalistSetup(){$.fn.flexdatalist?($(".flexdatalist").flexdatalist({valueProperty:"value",minLength:0,searchContain:!0,searchByWord:!0,noResultsText:""}),$("input[id='searchTerm-flexdatalist']").val($("input[id='searchTerm']").val()),$("input.flexdatalist").on("select:flexdatalist",function(e){handleFlexdataSelect()})):setTimeout(function(){flexdatalistSetup()},100)}function handleFlexdataSelect(){var e,t,n,a;if(t=$("input.flexdatalist").val(),"*ADV*"!=t.substr(0,5))return void $("input.clearable").trigger("change");for(n=t.substr(5).split("*|*"),e=0;e<n.length;e++)a=n[e].split("*:*"),"a"==a[0]?$("#advArtist").val(a[1]):"t"==a[0]?$("#advTitle").val(a[1]):"tr"==a[0]?$("#advTrack").val(a[1]):"b"==a[0]?$("#advBarcode").val(a[1]):"c"==a[0]?$("#advCatno").val(a[1]):"l"==a[0]?$("#advLabel").val(a[1]):"co"==a[0]?$("#advCountry").val(a[1]):"y"==a[0]&&$("#advYear").val(a[1]);$("#simpleSearchDiv").addClass("d-none"),$("#advSearchDiv").removeClass("d-none"),$("input.clearable").trigger("change")}function paginationSetup(){$.fn.paginate&&$.fn.modal&&$.fn.tooltip&&"undefined"!=typeof Popper?null!==document.getElementById("discogsDeck")&&($("[id^=masterModal]").modal("hide"),$("#discogsDeck").paginate({paginateElement:".card",elementsPerPage:paginationPerPage(),effect:"default",firstButtonText:'<i class="material-icons material-text">first_page</i>',lastButtonText:'<i class="material-icons material-text">last_page</i>',prevButtonText:'<i class="material-icons material-text">navigate_before</i>',nextButtonText:'<i class="material-icons material-text">navigate_next</i>',extraButtonClasses:"btn bg-info px-2 shadow-sm",functionOnNav:function(){tooltipSetup()}}),tooltipSetup()):setTimeout(function(){paginationSetup()},100)}function tooltipSetup(){$.fn.tooltip&&"undefined"!=typeof Popper?($('[data-toggle="tooltip"]').tooltip({trigger:"hover"}),$('[data-toggle2="tooltip"]').tooltip({trigger:"hover"})):setTimeout(function(){tooltipSetup()},100)}function dataTableSetup(){$.fn.DataTable?($("table.DataTable").DataTable({infoCallback:function(e,t,n,a,o,l){return"Showing "+o+" of "+a+" entries"}}),$("div.dataTables_filter input").attr("type","text").addClass("clearable")):setTimeout(function(){dataTableSetup()},100)}function mysqliHtmlDecode(e){return e=e.replace(/&amp;/g,"&"),e=e.replace(/&lt;/g,"<"),e=e.replace(/&gt;/g,">")}function paginationPerPage(){var e=$(window).width(),t=Math.floor(e/210);return t>9?t=9:576>e&&(t=1),t}function topFunction(){document.body.scrollTop=document.documentElement.scrollTop=0}function tog(e){return e?"addClass":"removeClass"}function inputClearerSetup(){$(document).on("input focus change select",".clearable",function(){$(this)[tog(this.value)]("x")}).on("mousemove",".x",function(e){$(this)[tog(this.offsetWidth-18<e.clientX-this.getBoundingClientRect().left)]("onX")}).on("touchstart click",".onX",function(e){e.preventDefault(),$(this).removeClass("x onX").val("").change()}).on("shown.bs.modal",function(e){$("#"+e.target.id+" input.clearable").trigger("input")}),$("input.clearable").trigger("change")}var myTimer;$(document).ready(function(){$(window).on("beforeunload",function(){$(":submit").attr("disabled","disabled"),document.body.style.cursor="progress"}),$(window).bind("resize orientationchange",function(){paginationSetup()}),paginationSetup(),document.getElementById("detailFilterForm")&&(tableFilterButtons(),detailTableFilterButtons()),document.getElementById("barcodeForm")&&barcodeFormButtons(),flexdatalistSetup(),dataTableSetup(),tooltipSetup(),inputClearerSetup()}),String.prototype.toProperCase=function(){return this.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})};