| 27754 |
amit.gupta |
1 |
$(document).on('click', ".web-listing", function() {
|
| 26738 |
amit.gupta |
2 |
loadWebListing("main-content");
|
|
|
3 |
});
|
| 27754 |
amit.gupta |
4 |
$(document).on('click', "a.listing-details", function() {
|
| 26738 |
amit.gupta |
5 |
var webListingId = $(this).data("id");
|
|
|
6 |
doAjaxRequestHandler(`${context}/web-listing/${webListingId}`, "GET", function(response) {
|
|
|
7 |
$('.web-products-container').html(response);
|
| 26731 |
amit.gupta |
8 |
});
|
| 28270 |
tejbeer |
9 |
|
| 26738 |
amit.gupta |
10 |
})
|
|
|
11 |
|
| 28270 |
tejbeer |
12 |
|
| 29515 |
tejbeer |
13 |
$(document).on('click', ".web-sctrach-offer", function() {
|
|
|
14 |
loadScratchOffer("main-content");
|
|
|
15 |
|
|
|
16 |
})
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
$(document).on('click', "#downloadSctrachTemplate", function() {
|
|
|
20 |
|
|
|
21 |
window.location.href = context + "/sctrachOffer/downloadTemplate";
|
|
|
22 |
});
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
$(document).on('click', ".sctrachOfferfileUpload", function() {
|
|
|
26 |
|
|
|
27 |
console.log("hello");
|
|
|
28 |
if (confirm('Confirm upload ?')) {
|
|
|
29 |
var fileSelector = $(this)[0];
|
|
|
30 |
if (fileSelector != undefined) {
|
|
|
31 |
var url = `${context}/sctrachOffer/upload`;
|
|
|
32 |
console.log(url);
|
|
|
33 |
var file = $("#sctrachOffer")[0].files[0];
|
|
|
34 |
let fileInput = $(this);
|
|
|
35 |
console.log("file" + file);
|
|
|
36 |
console.log("fileInput" + fileInput);
|
|
|
37 |
doAjaxUploadRequestHandler(
|
|
|
38 |
url,
|
|
|
39 |
'POST',
|
|
|
40 |
file, function(response) {
|
|
|
41 |
|
|
|
42 |
console.log(response)
|
|
|
43 |
alert("successfully uploaded");
|
|
|
44 |
|
|
|
45 |
});
|
|
|
46 |
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
});
|
|
|
50 |
|
| 28270 |
tejbeer |
51 |
$(document).on('click', "a.prodcut-remove", function() {
|
|
|
52 |
var webProductId = $(this).data("productid");
|
|
|
53 |
var webListingId = $(this).data("id");
|
|
|
54 |
if (confirm("Are you sure you want to remove the Item!") == true) {
|
|
|
55 |
|
|
|
56 |
doDeleteAjaxRequestHandler(context + "/webProductListing/removeItem?id="
|
|
|
57 |
+ webProductId + "&webListingId=" + webListingId, function(response) {
|
|
|
58 |
|
|
|
59 |
alert("Product removed successfully");
|
|
|
60 |
$('.web-products-container').html(response);
|
|
|
61 |
|
|
|
62 |
});
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
})
|
|
|
66 |
|
|
|
67 |
$(document).on('click', ".web-listing-active", function() {
|
|
|
68 |
var webListingId = $(this).data("id");
|
|
|
69 |
var status = $(this).data("active");
|
|
|
70 |
if (status == true) {
|
|
|
71 |
status = false;
|
|
|
72 |
} else {
|
|
|
73 |
status = true;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
if (confirm("Are you sure you want to Update the Status!") == true) {
|
|
|
78 |
doPostAjaxRequestHandler(context
|
|
|
79 |
+ "/web-listing/updateStatus?id=" + webListingId + "&status=" + status,
|
|
|
80 |
function(response) {
|
|
|
81 |
$('#main-content').html(response);
|
|
|
82 |
});
|
|
|
83 |
}
|
|
|
84 |
})
|
|
|
85 |
|
|
|
86 |
$(document).on('click', "#update-rank", function() {
|
|
|
87 |
if (confirm("Are you sure you want to update ranks?")) {
|
|
|
88 |
var webListingId = $(this).data("id");
|
|
|
89 |
var webProductIds = [];
|
|
|
90 |
$("#web-product-listing-tbody").find("tr").each(function() {
|
| 26738 |
amit.gupta |
91 |
console.log(this);
|
|
|
92 |
webProductIds.push($(this).data("id"));
|
|
|
93 |
});
|
|
|
94 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
|
|
|
95 |
$('.web-products-container').html(response);
|
|
|
96 |
});
|
|
|
97 |
}
|
| 26731 |
amit.gupta |
98 |
});
|
| 28270 |
tejbeer |
99 |
|
|
|
100 |
|
|
|
101 |
$(document).on('click', "#weblisting-update-rank", function() {
|
|
|
102 |
if (confirm("Are you sure you want to update ranks?")) {
|
|
|
103 |
var webListingIds = [];
|
|
|
104 |
$("#web-listing-tbody").find("tr").each(function() {
|
|
|
105 |
console.log(this);
|
|
|
106 |
webListingIds.push($(this).data("id"));
|
|
|
107 |
});
|
|
|
108 |
|
|
|
109 |
console.log(webListingIds)
|
|
|
110 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order-listing`, JSON.stringify(webListingIds), function(response) {
|
|
|
111 |
$('#main-content').html(response);
|
|
|
112 |
});
|
|
|
113 |
}
|
|
|
114 |
});
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
|
118 |
$(document).on('click', ".web-listing-id", function() {
|
|
|
119 |
var webListingId = $(this).data("id");
|
|
|
120 |
doAjaxRequestHandler(`${context}/getweb-listing/${webListingId}`, "GET", function(response) {
|
|
|
121 |
$('.web-listing-edit-container .modal-content').html(response);
|
|
|
122 |
});
|
|
|
123 |
});
|
|
|
124 |
|
|
|
125 |
$(document).on('click', ".edit-web-listing", function() {
|
|
|
126 |
var webListingId = $(this).data("id");
|
|
|
127 |
|
|
|
128 |
webListingTitle = $("#web-listing-edit-title").val();
|
|
|
129 |
webListingUrl = $("#web-listing-edit-url").val();
|
|
|
130 |
webListingRank = $("#web-listing-edit-rank").val();
|
| 28301 |
tejbeer |
131 |
webListingBannerUrl = $("#web-listing-edit-bannerurl").val();
|
| 28270 |
tejbeer |
132 |
|
| 28566 |
tejbeer |
133 |
webListingHeaderUrl = $("#web-listing-edit-headerurl").val();
|
|
|
134 |
|
| 28270 |
tejbeer |
135 |
if (webListingTitle === "") {
|
|
|
136 |
alert("Title is required!");
|
|
|
137 |
return false;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
if (webListingUrl === "") {
|
|
|
141 |
alert("Url is required!");
|
|
|
142 |
return false;
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
if (webListingRank === "") {
|
|
|
146 |
alert("Rank is required!");
|
|
|
147 |
return false;
|
|
|
148 |
}
|
|
|
149 |
|
| 28566 |
tejbeer |
150 |
json = { title: webListingTitle, url: webListingUrl, rank: webListingRank, bannerUrl: webListingBannerUrl, headerUrl: webListingHeaderUrl };
|
| 28270 |
tejbeer |
151 |
console.log(json)
|
|
|
152 |
if (confirm("Are you sure you want to Edit the Web Listing!") == true) {
|
|
|
153 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing-edit/${webListingId}`, JSON.stringify(json),
|
|
|
154 |
function(response) {
|
|
|
155 |
$('#main-content').html(response);
|
|
|
156 |
|
|
|
157 |
});
|
|
|
158 |
}
|
|
|
159 |
});
|
|
|
160 |
|
| 27754 |
amit.gupta |
161 |
$(document).on('click', "#add-listing", function() {
|
| 28270 |
tejbeer |
162 |
var webListingId = $(this).data("id");
|
| 26738 |
amit.gupta |
163 |
var entityIds = [entityId];
|
| 26731 |
amit.gupta |
164 |
|
| 28270 |
tejbeer |
165 |
var entityIdTxt = $("#entityData").val();
|
|
|
166 |
if (entityIdTxt.length > 0) {
|
|
|
167 |
if (entityIdTxt.indexOf(",") > 0) {
|
| 26738 |
amit.gupta |
168 |
entityIds = entityIdTxt.split(",");
|
|
|
169 |
}
|
|
|
170 |
} else {
|
|
|
171 |
alert("Please enter items");
|
|
|
172 |
return;
|
|
|
173 |
}
|
|
|
174 |
json = [];
|
| 28270 |
tejbeer |
175 |
for (var e of entityIds) {
|
|
|
176 |
json.push({ webListingId: webListingId, entityId: e });
|
| 26738 |
amit.gupta |
177 |
}
|
|
|
178 |
console.log(json);
|
|
|
179 |
console.log(JSON.stringify(json))
|
|
|
180 |
doPostAjaxRequestWithJsonHandler(`${context}/web-product-listing/add`, JSON.stringify(json), function(response) {
|
|
|
181 |
$('.web-products-container').html(response);
|
|
|
182 |
});
|
| 28270 |
tejbeer |
183 |
|
| 26738 |
amit.gupta |
184 |
});
|
|
|
185 |
|
| 26731 |
amit.gupta |
186 |
function loadWebListing(domId) {
|
|
|
187 |
doAjaxRequestHandler(context + "/web-listing", "GET", function(response) {
|
|
|
188 |
$('#' + domId).html(response);
|
|
|
189 |
});
|
|
|
190 |
}
|
| 29515 |
tejbeer |
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
function loadScratchOffer(domId) {
|
|
|
195 |
|
|
|
196 |
doAjaxRequestHandler(context + "/scratchOffer", "GET", function(response) {
|
|
|
197 |
$('#' + domId).html(response);
|
|
|
198 |
});
|
|
|
199 |
}
|
|
|
200 |
|
| 26738 |
amit.gupta |
201 |
function addWebListing() {
|
|
|
202 |
webListingTitle = $("#web-listing-title").val();
|
|
|
203 |
webListingUrl = $("#web-listing-url").val();
|
| 28270 |
tejbeer |
204 |
webListingRank = $("#web-listing-rank").val();
|
| 28301 |
tejbeer |
205 |
webListingBannerUrl = $("#web-listing-bannerurl").val();
|
| 28566 |
tejbeer |
206 |
|
|
|
207 |
webListingHeaderUrl = $("#web-listing-headerurl").val();
|
|
|
208 |
|
| 28270 |
tejbeer |
209 |
if (webListingTitle === "") {
|
|
|
210 |
alert("Title is required!");
|
|
|
211 |
return false;
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
if (webListingUrl === "") {
|
|
|
215 |
alert("Url is required!");
|
|
|
216 |
return false;
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
if (webListingRank === "") {
|
|
|
220 |
alert("Rank is required!");
|
|
|
221 |
return false;
|
|
|
222 |
}
|
|
|
223 |
|
| 28301 |
tejbeer |
224 |
|
| 28566 |
tejbeer |
225 |
json = { title: webListingTitle, url: webListingUrl, rank: webListingRank, bannerUrl: webListingBannerUrl, headerUrl: webListingHeaderUrl };
|
| 26738 |
amit.gupta |
226 |
doPostAjaxRequestWithJsonHandler(context + "/web-listing/add", JSON.stringify(json), function(response) {
|
|
|
227 |
$('#main-content').html(response);
|
| 26731 |
amit.gupta |
228 |
});
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
|
| 28270 |
tejbeer |
232 |
$(document).on('mousedown', ".grab", function(e) {
|
|
|
233 |
var tr = $(e.target).closest("#web-product-listing-table tr"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
234 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
235 |
tr.addClass("grabbed");
|
|
|
236 |
function move(e) {
|
|
|
237 |
console.log(Math.abs(e.pageY - sy));
|
|
|
238 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
239 |
drag = true;
|
|
|
240 |
tr.siblings().each(function() {
|
|
|
241 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
242 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
243 |
if (e.pageY <= y + (s.outerHeight() / 2))
|
|
|
244 |
tr.insertBefore(s);
|
|
|
245 |
else
|
|
|
246 |
tr.insertAfter(s);
|
|
|
247 |
return false;
|
|
|
248 |
}
|
|
|
249 |
});
|
|
|
250 |
}
|
|
|
251 |
function up(e) {
|
|
|
252 |
if (drag && si != tr.index()) {
|
|
|
253 |
drag = false;
|
|
|
254 |
$("#update-rank").prop('disabled', false);
|
|
|
255 |
}
|
|
|
256 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
257 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
258 |
tr.removeClass("grabbed");
|
|
|
259 |
}
|
|
|
260 |
$(document).mousemove(move).mouseup(up);
|
| 26738 |
amit.gupta |
261 |
});
|
| 26731 |
amit.gupta |
262 |
|
|
|
263 |
|
| 28270 |
tejbeer |
264 |
$(document).on('mousedown', ".grab", function(e) {
|
|
|
265 |
var tr = $(e.target).closest("#catalog-feature-table tr"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
266 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
267 |
tr.addClass("grabbed");
|
|
|
268 |
function move(e) {
|
|
|
269 |
console.log(Math.abs(e.pageY - sy));
|
|
|
270 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
271 |
drag = true;
|
|
|
272 |
tr.siblings().each(function() {
|
|
|
273 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
274 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
275 |
if (e.pageY <= y + (s.outerHeight() / 2))
|
|
|
276 |
tr.insertBefore(s);
|
|
|
277 |
else
|
|
|
278 |
tr.insertAfter(s);
|
|
|
279 |
return false;
|
|
|
280 |
}
|
|
|
281 |
});
|
|
|
282 |
}
|
|
|
283 |
function up(e) {
|
|
|
284 |
if (drag && si != tr.index()) {
|
|
|
285 |
drag = false;
|
|
|
286 |
$("#weblisting-update-rank").prop('disabled', false);
|
|
|
287 |
}
|
|
|
288 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
289 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
290 |
tr.removeClass("grabbed");
|
|
|
291 |
}
|
|
|
292 |
$(document).mousemove(move).mouseup(up);
|
|
|
293 |
});
|
| 26738 |
amit.gupta |
294 |
|
|
|
295 |
|
| 28270 |
tejbeer |
296 |
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
|