Rev 26744 | Rev 28270 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(document).on('click', ".web-listing", function() {loadWebListing("main-content");});$(document).on('click', "a.listing-details", function() {var webListingId = $(this).data("id");doAjaxRequestHandler(`${context}/web-listing/${webListingId}`, "GET", function(response) {$('.web-products-container').html(response);});})$(document).on('click', "#update-rank", function(){if(confirm("Are you sure you want to update ranks?")) {var webListingId=$(this).data("id");var webProductIds=[];$("#web-product-listing-tbody").find("tr").each(function(){console.log(this);webProductIds.push($(this).data("id"));});doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {$('.web-products-container').html(response);});}});$(document).on('click', "#add-listing", function() {var webListingId=$(this).data("id");var entityIds = [entityId];var entityIdTxt=$("#entityData").val();if(entityIdTxt.length > 0) {if(entityIdTxt.indexOf(",") > 0) {entityIds = entityIdTxt.split(",");}} else {alert("Please enter items");return;}json = [];for(var e of entityIds) {json.push({webListingId:webListingId, entityId: e});}console.log(json);console.log(JSON.stringify(json))doPostAjaxRequestWithJsonHandler(`${context}/web-product-listing/add`, JSON.stringify(json), function(response) {$('.web-products-container').html(response);});});function loadWebListing(domId) {doAjaxRequestHandler(context + "/web-listing", "GET", function(response) {$('#' + domId).html(response);});}function addWebListing() {webListingTitle = $("#web-listing-title").val();webListingUrl = $("#web-listing-url").val();json = {title:webListingTitle, url : webListingUrl};doPostAjaxRequestWithJsonHandler(context + "/web-listing/add", JSON.stringify(json), function(response) {$('#main-content').html(response);});}$(document).on('mousedown', ".grab", function (e) {var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;b.addClass("grabCursor").css("userSelect", "none");tr.addClass("grabbed");function move (e) {console.log(Math.abs(e.pageY - sy));if (!drag && Math.abs(e.pageY - sy) < 10) return;drag = true;tr.siblings().each(function() {var s = $(this), i = s.index(), y = s.offset().top;if (e.pageY >= y && e.pageY < y + s.outerHeight()) {if (e.pageY <= y + (s.outerHeight()/2))tr.insertBefore(s);elsetr.insertAfter(s);return false;}});}function up (e) {if (drag && si != tr.index()) {drag = false;$("#update-rank").prop('disabled', false);}$(document).unbind("mousemove", move).unbind("mouseup", up);b.removeClass("grabCursor").css("userSelect", "none");tr.removeClass("grabbed");}$(document).mousemove(move).mouseup(up);});