Rev 28270 | Rev 29515 | 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', "a.prodcut-remove", function() {var webProductId = $(this).data("productid");var webListingId = $(this).data("id");if (confirm("Are you sure you want to remove the Item!") == true) {doDeleteAjaxRequestHandler(context + "/webProductListing/removeItem?id="+ webProductId + "&webListingId=" + webListingId, function(response) {alert("Product removed successfully");$('.web-products-container').html(response);});}})$(document).on('click', ".web-listing-active", function() {var webListingId = $(this).data("id");var status = $(this).data("active");if (status == true) {status = false;} else {status = true;}if (confirm("Are you sure you want to Update the Status!") == true) {doPostAjaxRequestHandler(context+ "/web-listing/updateStatus?id=" + webListingId + "&status=" + status,function(response) {$('#main-content').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', "#weblisting-update-rank", function() {if (confirm("Are you sure you want to update ranks?")) {var webListingIds = [];$("#web-listing-tbody").find("tr").each(function() {console.log(this);webListingIds.push($(this).data("id"));});console.log(webListingIds)doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order-listing`, JSON.stringify(webListingIds), function(response) {$('#main-content').html(response);});}});$(document).on('click', ".web-listing-id", function() {var webListingId = $(this).data("id");doAjaxRequestHandler(`${context}/getweb-listing/${webListingId}`, "GET", function(response) {$('.web-listing-edit-container .modal-content').html(response);});});$(document).on('click', ".edit-web-listing", function() {var webListingId = $(this).data("id");webListingTitle = $("#web-listing-edit-title").val();webListingUrl = $("#web-listing-edit-url").val();webListingRank = $("#web-listing-edit-rank").val();webListingBannerUrl = $("#web-listing-edit-bannerurl").val();if (webListingTitle === "") {alert("Title is required!");return false;}if (webListingUrl === "") {alert("Url is required!");return false;}if (webListingRank === "") {alert("Rank is required!");return false;}json = { title: webListingTitle, url: webListingUrl, rank: webListingRank, bannerUrl: webListingBannerUrl };console.log(json)if (confirm("Are you sure you want to Edit the Web Listing!") == true) {doPostAjaxRequestWithJsonHandler(`${context}/web-listing-edit/${webListingId}`, JSON.stringify(json),function(response) {$('#main-content').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();webListingRank = $("#web-listing-rank").val();webListingBannerUrl = $("#web-listing-bannerurl").val();if (webListingTitle === "") {alert("Title is required!");return false;}if (webListingUrl === "") {alert("Url is required!");return false;}if (webListingRank === "") {alert("Rank is required!");return false;}json = { title: webListingTitle, url: webListingUrl, rank: webListingRank, bannerUrl: webListingBannerUrl };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("#web-product-listing-table 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);});$(document).on('mousedown', ".grab", function(e) {var tr = $(e.target).closest("#catalog-feature-table 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;$("#weblisting-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);});