2 |
- |
1 |
<!DOCTYPE html>
|
|
|
2 |
<html lang="en">
|
|
|
3 |
|
|
|
4 |
<head>
|
|
|
5 |
<title>Export eBay Listings to Shopify</title>
|
|
|
6 |
<meta charset="UTF-8">
|
|
|
7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
8 |
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
|
|
|
9 |
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
|
|
10 |
|
30 |
- |
11 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
|
|
12 |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
|
|
|
13 |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
|
14 |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
|
|
15 |
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
|
|
16 |
<script src="js/XMLWriter.js"></script>
|
|
|
17 |
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
|
|
|
18 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.23.0/moment.min.js"></script>
|
|
|
19 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.23/moment-timezone-with-data-2012-2022.min.js"></script>
|
2 |
- |
20 |
<link rel="stylesheet" href="css/tablesorter.theme.blue.css">
|
|
|
21 |
<script src="js/jquery.tablesorter.min.js"></script>
|
|
|
22 |
<script src="js/jquery.tablesorter.widgets.js"></script>
|
|
|
23 |
<script src="js/jquery.parser-input-select.js"></script>
|
30 |
- |
24 |
<link rel="stylesheet" href="css/style.css">
|
|
|
25 |
<script src="js/muna-tools.js"></script>
|
32 |
- |
26 |
<script src="js/stopcock.js"></script>
|
2 |
- |
27 |
</head>
|
|
|
28 |
|
|
|
29 |
<body onload="return initConfig();">
|
30 |
- |
30 |
<div>
|
68 |
- |
31 |
<div>
|
30 |
- |
32 |
<div class="container-fluid bg-secondary">
|
|
|
33 |
<div class="clearfix">
|
|
|
34 |
<img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" />
|
|
|
35 |
<h1 id="connected">Export eBay Listings to Shopify
|
|
|
36 |
<input id="login" type="button" class="btn bg-success mb-2 w3-hide" onclick="eBayLogin();" value="Login" /></h1>
|
|
|
37 |
</div>
|
2 |
- |
38 |
</div>
|
|
|
39 |
|
30 |
- |
40 |
<div class="col border">
|
2 |
- |
41 |
<div>
|
30 |
- |
42 |
<form id="searchForm" class="container-fluid bg-light" onsubmit="return getListings();">
|
|
|
43 |
<div id="form1div" class="w3-hide">
|
|
|
44 |
<div class="form-check">
|
|
|
45 |
<label for="completedList">
|
|
|
46 |
<input id="completedList" class="form-check-input" type="radio" name="rptType" value="completedList" checked>Completed Listings
|
|
|
47 |
</label>
|
|
|
48 |
</div>
|
|
|
49 |
<div class="form-check">
|
|
|
50 |
<label for="liveList">
|
|
|
51 |
<input id="liveList" class="form-check-input" type="radio" name="rptType" value="liveList" checked>Live Listings
|
|
|
52 |
</label>
|
|
|
53 |
</div>
|
|
|
54 |
<input id="startButton" type="button" class="btn btn-danger" onclick="getListings();" value="Start" />
|
6 |
- |
55 |
</div>
|
30 |
- |
56 |
<div id="form2div" class="w3-hide">
|
|
|
57 |
<input id="downloadButton" type="button" class="btn btn-dark" onclick="downloadListings()" value="Download CSV" />
|
6 |
- |
58 |
</div>
|
2 |
- |
59 |
</form>
|
|
|
60 |
</div>
|
30 |
- |
61 |
<div class="modal" id="progressBarDiv">
|
|
|
62 |
<div class="modal-dialog">
|
|
|
63 |
<div class="modal-content">
|
|
|
64 |
<div class="modal-header">
|
|
|
65 |
<h4 id="progressBarHeader"></h4>
|
|
|
66 |
</div>
|
|
|
67 |
<div class="modal-body">
|
|
|
68 |
<div class="progress">
|
|
|
69 |
<div id="progressBar" class="progress-bar" style="width:0%">0%</div>
|
|
|
70 |
</div>
|
|
|
71 |
</div>
|
|
|
72 |
</div>
|
2 |
- |
73 |
</div>
|
|
|
74 |
</div>
|
30 |
- |
75 |
<div id="results" class="border bg-info w3-hide"></div>
|
|
|
76 |
<div id="csv" class="w3-hide"></div>
|
|
|
77 |
<div id="logging"></div>
|
2 |
- |
78 |
</div>
|
|
|
79 |
</div>
|
|
|
80 |
|
30 |
- |
81 |
<footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">
|
17 |
- |
82 |
<div w3-include-html="php/footer.php"></div>
|
2 |
- |
83 |
</footer>
|
|
|
84 |
|
|
|
85 |
</div>
|
|
|
86 |
|
|
|
87 |
<script>
|
|
|
88 |
|
|
|
89 |
// Globals
|
|
|
90 |
var tableName = 'exportTable';
|
|
|
91 |
var tableSorterName = 'selectTable';
|
|
|
92 |
var liveListing;
|
|
|
93 |
var maxPagesToProcess = 0;
|
|
|
94 |
var pagesToProcess = 0;
|
|
|
95 |
var pagesProcessed = 0;
|
|
|
96 |
var maxNotesToAdd = 0;
|
|
|
97 |
var notesToAdd = 0;
|
|
|
98 |
var notesAdded = 0;
|
32 |
- |
99 |
var listingsToFill = 0;
|
|
|
100 |
var maxListingsToFill = 0;
|
|
|
101 |
var listingsFilled = 0;
|
|
|
102 |
var listingsToFind = 0;
|
|
|
103 |
var maxListingsToFind = 0;
|
|
|
104 |
var listingsFound = 0;
|
2 |
- |
105 |
var html = [];
|
|
|
106 |
|
|
|
107 |
// Initialize Configuration Variables
|
|
|
108 |
function initConfig() {
|
|
|
109 |
var x = document.getElementById("form1div");
|
|
|
110 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
111 |
x.className += " w3-show";
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
eBayAuthToken = readCookie();
|
|
|
115 |
if (eBayAuthToken.length > 0) {
|
|
|
116 |
connected();
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
if (eBayAuthTokenFlag === false) {
|
|
|
120 |
x = document.getElementById("login");
|
|
|
121 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
122 |
x.className += " w3-show";
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
function connected() {
|
|
|
128 |
var x;
|
|
|
129 |
|
|
|
130 |
eBayAuthTokenFlag = true;
|
|
|
131 |
document.getElementById("connected").innerHTML += " (Connected)";
|
|
|
132 |
|
|
|
133 |
x = document.getElementById("startButton");
|
30 |
- |
134 |
x.className = x.className.replace(" btn-danger", " btn-dark");
|
2 |
- |
135 |
|
|
|
136 |
x = document.getElementById("login");
|
|
|
137 |
x.className = x.className.replace(" w3-show", "");
|
|
|
138 |
|
|
|
139 |
x = document.getElementById("results");
|
|
|
140 |
x.innerHTML = "";
|
|
|
141 |
x.className = x.className.replace(" w3-show", "");
|
|
|
142 |
x.className = x.className.replace(" process-errors", "");
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
function requireNewLogin() {
|
|
|
146 |
var x = document.getElementById("startButton");
|
30 |
- |
147 |
x.className = x.className.replace(" btn-dark", " btn-danger ");
|
2 |
- |
148 |
}
|
|
|
149 |
|
|
|
150 |
function downloadListings() {
|
|
|
151 |
var noteList = [];
|
|
|
152 |
var table = document.getElementById(tableSorterName);
|
|
|
153 |
|
|
|
154 |
maxPagesToProcess = 0;
|
|
|
155 |
pagesToProcess = 0;
|
|
|
156 |
pagesProcessed = 0;
|
|
|
157 |
|
|
|
158 |
initProgressBar("Downloading Selected Items");
|
|
|
159 |
|
|
|
160 |
var x = document.getElementById("results");
|
|
|
161 |
x.innerHTML = '';
|
|
|
162 |
x.className = x.className.replace("process-errors", "");
|
|
|
163 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
164 |
x.className += " w3-show";
|
|
|
165 |
}
|
|
|
166 |
x.innerHTML = '<p><strong>Downloading Listings...</strong></p>';
|
|
|
167 |
|
|
|
168 |
document.getElementById("csv").innerHTML = '';
|
|
|
169 |
|
|
|
170 |
tableStart();
|
|
|
171 |
for (var i = 2; i < table.rows.length; i++) {
|
|
|
172 |
if (table.rows[i].cells[0].children[0].checked) {
|
|
|
173 |
++maxPagesToProcess;
|
|
|
174 |
++pagesToProcess;
|
|
|
175 |
noteList.push(table.rows[i].cells[3].innerHTML);
|
32 |
- |
176 |
eBaySearch(table.rows[i].cells[3].innerHTML, (table.rows[i].cells[13].innerHTML == 'Yes' ? true : false));
|
2 |
- |
177 |
|
|
|
178 |
table.deleteRow(i--);
|
|
|
179 |
}
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
function checkpagesToProcess() {
|
|
|
183 |
if (pagesToProcess > 0) {
|
|
|
184 |
window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds
|
|
|
185 |
} else {
|
|
|
186 |
tableEnd();
|
7 |
- |
187 |
tableSorterUpdateCounters(tableSorterName);
|
2 |
- |
188 |
endProgressBar();
|
36 |
- |
189 |
exportTableToCSV(tableName, 'import.csv', true);
|
2 |
- |
190 |
addNotes(noteList);
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
checkpagesToProcess();
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
function addNotes(noteList) {
|
|
|
198 |
var i, x;
|
|
|
199 |
|
|
|
200 |
maxNotesToAdd = 0;
|
|
|
201 |
notesToAdd = 0;
|
|
|
202 |
notesAdded = 0;
|
|
|
203 |
|
|
|
204 |
if (!liveListing) {
|
|
|
205 |
initProgressBar('Adding Notes to Ended Listings');
|
|
|
206 |
|
|
|
207 |
for (i = 0; i < noteList.length; i++) {
|
|
|
208 |
++maxNotesToAdd;
|
|
|
209 |
++notesToAdd;
|
|
|
210 |
addNote(noteList[i]);
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
function checkNotesToAdd() {
|
|
|
215 |
if (notesToAdd > 0) {
|
|
|
216 |
window.setTimeout(checkNotesToAdd, 100); // wait 100 milliseconds
|
|
|
217 |
} else {
|
|
|
218 |
endProgressBar();
|
|
|
219 |
|
|
|
220 |
x = document.getElementById("results");
|
|
|
221 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
|
|
222 |
if (!x.className.includes("process-errors")) {
|
|
|
223 |
setTimeout(function() {
|
|
|
224 |
x.className = x.className.replace(" w3-show", "");
|
|
|
225 |
}, 3000);
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
}
|
|
|
229 |
|
|
|
230 |
checkNotesToAdd();
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
function tableStart() {
|
|
|
234 |
document.getElementById("csv").innerHTML = '';
|
|
|
235 |
html = [];
|
|
|
236 |
|
|
|
237 |
html.push('<h3>Shopify Import</h3>');
|
30 |
- |
238 |
html.push('<div class="border table-responsive">');
|
2 |
- |
239 |
html.push('<table id="' + tableName + '">');
|
|
|
240 |
html.push('<thead>');
|
|
|
241 |
html.push('<tr>');
|
|
|
242 |
|
|
|
243 |
html.push(tableHeader('Handle'));
|
|
|
244 |
html.push(tableHeader('Title'));
|
|
|
245 |
html.push(tableHeader('Body (HTML)'));
|
|
|
246 |
html.push(tableHeader('Vendor'));
|
|
|
247 |
html.push(tableHeader('Type'));
|
|
|
248 |
html.push(tableHeader('Tags'));
|
|
|
249 |
html.push(tableHeader('Published'));
|
25 |
- |
250 |
html.push(tableHeader('Option1 Name'));
|
|
|
251 |
html.push(tableHeader('Option1 Value'));
|
|
|
252 |
html.push(tableHeader('Option2 Name'));
|
|
|
253 |
html.push(tableHeader('Option2 Value'));
|
|
|
254 |
html.push(tableHeader('Option3 Name'));
|
|
|
255 |
html.push(tableHeader('Option3 Value'));
|
2 |
- |
256 |
html.push(tableHeader('Variant SKU'));
|
25 |
- |
257 |
html.push(tableHeader('Variant Grams'));
|
2 |
- |
258 |
html.push(tableHeader('Variant Inventory Tracker'));
|
25 |
- |
259 |
html.push(tableHeader('Variant Inventory Qty'));
|
2 |
- |
260 |
html.push(tableHeader('Variant Inventory Policy'));
|
|
|
261 |
html.push(tableHeader('Variant Fulfillment Service'));
|
|
|
262 |
html.push(tableHeader('Variant Price'));
|
25 |
- |
263 |
html.push(tableHeader('Variant Compare At Price'));
|
2 |
- |
264 |
html.push(tableHeader('Variant Requires Shipping'));
|
|
|
265 |
html.push(tableHeader('Variant Taxable'));
|
|
|
266 |
html.push(tableHeader('Variant Barcode'));
|
|
|
267 |
html.push(tableHeader('Image Src'));
|
|
|
268 |
html.push(tableHeader('Image Position'));
|
|
|
269 |
html.push(tableHeader('Image Alt Text'));
|
25 |
- |
270 |
html.push(tableHeader('Gift Card'));
|
|
|
271 |
html.push(tableHeader('Google Shopping / MPN'));
|
|
|
272 |
html.push(tableHeader('Google Shopping / Age Group'));
|
|
|
273 |
html.push(tableHeader('Google Shopping / Gender'));
|
|
|
274 |
html.push(tableHeader('Google Shopping / Google Product Category'));
|
|
|
275 |
html.push(tableHeader('SEO Title'));
|
|
|
276 |
html.push(tableHeader('SEO Description'));
|
|
|
277 |
html.push(tableHeader('Google Shopping / AdWords Grouping'));
|
|
|
278 |
html.push(tableHeader('Google Shopping / AdWords Labels'));
|
|
|
279 |
html.push(tableHeader('Google Shopping / Condition'));
|
|
|
280 |
html.push(tableHeader('Google Shopping / Custom Product'));
|
|
|
281 |
html.push(tableHeader('Google Shopping / Custom Label 0'));
|
|
|
282 |
html.push(tableHeader('Google Shopping / Custom Label 1'));
|
|
|
283 |
html.push(tableHeader('Google Shopping / Custom Label 2'));
|
|
|
284 |
html.push(tableHeader('Google Shopping / Custom Label 3'));
|
|
|
285 |
html.push(tableHeader('Google Shopping / Custom Label 4'));
|
|
|
286 |
html.push(tableHeader('Variant Image'));
|
2 |
- |
287 |
html.push(tableHeader('Variant Weight Unit'));
|
25 |
- |
288 |
html.push(tableHeader('Variant Tax Code'));
|
|
|
289 |
html.push(tableHeader('Cost per item'));
|
2 |
- |
290 |
|
|
|
291 |
html.push('</tr>');
|
|
|
292 |
html.push('</thead>');
|
|
|
293 |
html.push('<tbody>');
|
|
|
294 |
}
|
|
|
295 |
|
32 |
- |
296 |
function tableEntry(JsonObj, onShopify) {
|
2 |
- |
297 |
var i, n, barcode, handle;
|
|
|
298 |
var tags = [];
|
|
|
299 |
var ConditionDescription = JsonObj.ConditionDescription;
|
|
|
300 |
var ConditionID = JsonObj.ConditionID;
|
|
|
301 |
var CurrentPrice = JsonObj.SellingStatus.CurrentPrice;
|
|
|
302 |
var CurrentPriceValue = CurrentPrice === undefined ? 0.00 : Number(CurrentPrice.text);
|
|
|
303 |
var price = CurrentPriceValue;
|
|
|
304 |
var Description = JsonObj.Description;
|
|
|
305 |
var userDescription;
|
|
|
306 |
var ItemID = JsonObj.ItemID;
|
|
|
307 |
var ItemSpecifics = JsonObj.ItemSpecifics;
|
6 |
- |
308 |
var PictureURL = getJsonArray(JsonObj.PictureDetails.PictureURL);
|
2 |
- |
309 |
var PrimaryCategoryName = JsonObj.PrimaryCategory.CategoryName;
|
16 |
- |
310 |
var Quantity = Number(JsonObj.Quantity);
|
|
|
311 |
var QuantitySold = Number(JsonObj.SellingStatus.QuantitySold);
|
2 |
- |
312 |
var SKU = JsonObj.SKU;
|
|
|
313 |
var ProductListingDetails = JsonObj.ProductListingDetails;
|
|
|
314 |
var weightInGrams = 0;
|
|
|
315 |
var categoryName = PrimaryCategoryName;
|
|
|
316 |
var Title = JsonObj.Title;
|
|
|
317 |
|
|
|
318 |
if (Number(ConditionID) === 1000) {
|
|
|
319 |
tags.push("Condition: Brand New");
|
|
|
320 |
} else {
|
|
|
321 |
tags.push("Condition: Preowned");
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
n = (SKU === undefined ? 0 : SKU.indexOf(" - "));
|
|
|
325 |
if (n > 0) {
|
|
|
326 |
barcode = SKU.substr(n + 3);
|
|
|
327 |
barcode = barcode.substr(barcode.indexOf(" ") + 1);
|
|
|
328 |
handle = 'B' + barcode;
|
|
|
329 |
barcode = '\'' + barcode;
|
|
|
330 |
SKU = SKU.substr(0, n);
|
|
|
331 |
} else {
|
|
|
332 |
if (categoryName.indexOf("Books") != -1 && ProductListingDetails && ProductListingDetails.ISBN && isNumeric(ProductListingDetails.ISBN)) {
|
|
|
333 |
barcode = '\'' + ProductListingDetails.ISBN;
|
|
|
334 |
handle = 'B' + ProductListingDetails.ISBN;
|
|
|
335 |
} else if (ProductListingDetails && ProductListingDetails.UPC && isNumeric(ProductListingDetails.UPC)) {
|
|
|
336 |
barcode = '\'' + ProductListingDetails.UPC;
|
|
|
337 |
handle = 'B' + ProductListingDetails.UPC;
|
|
|
338 |
} else if (ProductListingDetails && ProductListingDetails.ProductReferenceID && isNumeric(ProductListingDetails.ProductReferenceID)) {
|
|
|
339 |
barcode = 'R' + ProductListingDetails.ProductReferenceID;
|
|
|
340 |
handle = barcode;
|
|
|
341 |
} else {
|
|
|
342 |
barcode = 'H' + Title.hashCode();
|
|
|
343 |
handle = barcode;
|
|
|
344 |
}
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
userDescription = extractDescription(Description);
|
16 |
- |
348 |
if (ItemSpecifics && ItemSpecifics.NameValueList && PrimaryCategoryName.indexOf('DVD') < 0) {
|
|
|
349 |
userDescription += '<table><tbody>';
|
|
|
350 |
for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
|
|
|
351 |
var itemSpecific = ItemSpecifics.NameValueList[i];
|
|
|
352 |
if (itemSpecific.Name != 'All returns accepted' &&
|
|
|
353 |
itemSpecific.Name != 'Item must be returned within' &&
|
|
|
354 |
itemSpecific.Name != 'Refund will be given as' &&
|
|
|
355 |
itemSpecific.Name != 'Return policy details' &&
|
|
|
356 |
itemSpecific.Name != 'Restocking Fee' &&
|
|
|
357 |
itemSpecific.Name != 'Return shipping will be paid by') {
|
|
|
358 |
userDescription += '<tr><td style="padding: 0;">' + itemSpecific.Name + ':</td><td style="padding: 0;">' + itemSpecific.Value + '</td></tr>';
|
2 |
- |
359 |
}
|
|
|
360 |
}
|
16 |
- |
361 |
userDescription += '</tbody></table>';
|
2 |
- |
362 |
}
|
|
|
363 |
|
|
|
364 |
if (ConditionDescription &&
|
|
|
365 |
(userDescription.indexOf('Please view all actual images.') < 0 && userDescription.indexOf('mint condition') < 0)) {
|
|
|
366 |
userDescription += '<p>' + ConditionDescription + '</p>';
|
|
|
367 |
}
|
|
|
368 |
|
|
|
369 |
if (categoryName.indexOf("CDs") != -1) {
|
|
|
370 |
categoryName = 'Music CDs';
|
190 |
- |
371 |
price = 5.45;
|
2 |
- |
372 |
} else if (categoryName.indexOf("Movies") != -1) {
|
|
|
373 |
categoryName = 'Movies';
|
190 |
- |
374 |
price = 5.45;
|
2 |
- |
375 |
} else if (categoryName.indexOf("Books") != -1) {
|
|
|
376 |
categoryName = 'Books';
|
|
|
377 |
price = 5.95;
|
|
|
378 |
} else if (categoryName.indexOf("Trading Cards") != -1) {
|
|
|
379 |
if (categoryName.indexOf("Baseball") != -1) {
|
|
|
380 |
tags.push('Trading Cards: Baseball');
|
|
|
381 |
} else if (categoryName.indexOf("Football") != -1) {
|
|
|
382 |
tags.push('Trading Cards: Football');
|
|
|
383 |
} else if (categoryName.indexOf("Basketball") != -1) {
|
|
|
384 |
tags.push('Trading Cards: Basketball');
|
|
|
385 |
} else if (categoryName.indexOf("Soccer") != -1) {
|
|
|
386 |
tags.push('Trading Cards: Soccer');
|
|
|
387 |
} else if (categoryName.indexOf("Ice Hockey") != -1) {
|
|
|
388 |
tags.push('Trading Cards: Ice Hockey');
|
|
|
389 |
} else if (categoryName.indexOf("Auto Racing") != -1) {
|
|
|
390 |
tags.push('Trading Cards: Auto Racing');
|
|
|
391 |
}
|
|
|
392 |
categoryName = 'Trading Cards';
|
|
|
393 |
price = 1.99;
|
|
|
394 |
}
|
|
|
395 |
tags.push(categoryName);
|
|
|
396 |
|
|
|
397 |
if (liveListing) {
|
|
|
398 |
tags.push('_eBay Live');
|
|
|
399 |
|
53 |
- |
400 |
price = round((CurrentPriceValue * 0.90), 1) + 0.05; // always end with 5
|
190 |
- |
401 |
if (categoryName.indexOf("CDs") != -1 && price < 5.45) {
|
|
|
402 |
price = 5.45;
|
|
|
403 |
} else if (categoryName.indexOf("Movies") != -1 && price < 5.45) {
|
|
|
404 |
price = 5.45;
|
2 |
- |
405 |
} else if (categoryName.indexOf("Books") != -1 && price < 5.95) {
|
|
|
406 |
price = 5.95;
|
|
|
407 |
} else if (categoryName.indexOf("Trading Cards") != -1 && price < 1.99) {
|
|
|
408 |
price = 1.99;
|
|
|
409 |
}
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
if (JsonObj.ShippingPackageDetails !== undefined) {
|
|
|
413 |
if (JsonObj.ShippingPackageDetails.WeightMajor !== undefined) {
|
|
|
414 |
weightInGrams += (Number(JsonObj.ShippingPackageDetails.WeightMajor.text) * 453.5);
|
|
|
415 |
}
|
|
|
416 |
|
|
|
417 |
if (JsonObj.ShippingPackageDetails.WeightMinor !== undefined) {
|
|
|
418 |
weightInGrams += (Number(JsonObj.ShippingPackageDetails.WeightMinor.text) * 28.3);
|
|
|
419 |
}
|
|
|
420 |
}
|
|
|
421 |
|
|
|
422 |
html.push('<tr>');
|
|
|
423 |
|
|
|
424 |
html.push(tableCell(handle));
|
|
|
425 |
html.push(tableCell(Title));
|
|
|
426 |
html.push(tableCell(escapeHtml(userDescription)));
|
|
|
427 |
html.push(tableCell("MUNA Trading"));
|
|
|
428 |
html.push(tableCell(categoryName));
|
|
|
429 |
html.push(tableCell(tags.join(',')));
|
|
|
430 |
html.push(tableCell("TRUE"));
|
28 |
- |
431 |
html.push(tableCell("Title"));
|
|
|
432 |
html.push(tableCell("Default Title"));
|
25 |
- |
433 |
html.push(tableCell(""));
|
|
|
434 |
html.push(tableCell(""));
|
|
|
435 |
html.push(tableCell(""));
|
|
|
436 |
html.push(tableCell(""));
|
2 |
- |
437 |
html.push(tableCell((SKU !== undefined ? SKU : "")));
|
25 |
- |
438 |
html.push(tableCell(Math.floor(weightInGrams)));
|
2 |
- |
439 |
html.push(tableCell("shopify"));
|
16 |
- |
440 |
html.push(tableCell((Quantity - QuantitySold)));
|
2 |
- |
441 |
html.push(tableCell("deny"));
|
|
|
442 |
html.push(tableCell("manual"));
|
|
|
443 |
html.push(tableCell(price));
|
25 |
- |
444 |
html.push(tableCell(""));
|
2 |
- |
445 |
html.push(tableCell("TRUE"));
|
|
|
446 |
html.push(tableCell("TRUE"));
|
|
|
447 |
html.push(tableCell(barcode));
|
32 |
- |
448 |
if (onShopify) {
|
|
|
449 |
html.push(tableCell(""));
|
|
|
450 |
html.push(tableCell(""));
|
|
|
451 |
html.push(tableCell(""));
|
|
|
452 |
} else {
|
|
|
453 |
html.push(tableCell(PictureURL[0].substr(0, PictureURL[0].lastIndexOf('/') + 1) + '$_57.JPG'));
|
|
|
454 |
html.push(tableCell(1));
|
|
|
455 |
html.push(tableCell(Title + " Image 1"));
|
|
|
456 |
}
|
25 |
- |
457 |
html.push(tableCell("FALSE"));
|
|
|
458 |
html.push(tableCell(""));
|
|
|
459 |
html.push(tableCell(""));
|
|
|
460 |
html.push(tableCell(""));
|
|
|
461 |
html.push(tableCell(""));
|
|
|
462 |
html.push(tableCell(""));
|
|
|
463 |
html.push(tableCell(""));
|
|
|
464 |
html.push(tableCell(""));
|
|
|
465 |
html.push(tableCell(""));
|
|
|
466 |
html.push(tableCell(""));
|
|
|
467 |
html.push(tableCell(""));
|
|
|
468 |
html.push(tableCell(""));
|
|
|
469 |
html.push(tableCell(""));
|
|
|
470 |
html.push(tableCell(""));
|
|
|
471 |
html.push(tableCell(""));
|
|
|
472 |
html.push(tableCell(""));
|
|
|
473 |
html.push(tableCell(""));
|
2 |
- |
474 |
html.push(tableCell("oz"));
|
25 |
- |
475 |
html.push(tableCell(""));
|
|
|
476 |
html.push(tableCell(""));
|
2 |
- |
477 |
|
|
|
478 |
html.push('</tr>');
|
|
|
479 |
|
32 |
- |
480 |
if (!onShopify) {
|
|
|
481 |
for (i = 1; i < PictureURL.length; i++) {
|
|
|
482 |
html.push('<tr>');
|
2 |
- |
483 |
|
32 |
- |
484 |
html.push(tableCell(handle));
|
|
|
485 |
html.push(tableCell(""));
|
|
|
486 |
html.push(tableCell(""));
|
|
|
487 |
html.push(tableCell(""));
|
|
|
488 |
html.push(tableCell(""));
|
|
|
489 |
html.push(tableCell(""));
|
|
|
490 |
html.push(tableCell(""));
|
|
|
491 |
html.push(tableCell(""));
|
|
|
492 |
html.push(tableCell(""));
|
|
|
493 |
html.push(tableCell(""));
|
|
|
494 |
html.push(tableCell(""));
|
|
|
495 |
html.push(tableCell(""));
|
|
|
496 |
html.push(tableCell(""));
|
|
|
497 |
html.push(tableCell(""));
|
|
|
498 |
html.push(tableCell(""));
|
|
|
499 |
html.push(tableCell(""));
|
|
|
500 |
html.push(tableCell(""));
|
|
|
501 |
html.push(tableCell(""));
|
|
|
502 |
html.push(tableCell(""));
|
|
|
503 |
html.push(tableCell(""));
|
|
|
504 |
html.push(tableCell(""));
|
|
|
505 |
html.push(tableCell(""));
|
|
|
506 |
html.push(tableCell(""));
|
|
|
507 |
html.push(tableCell(""));
|
|
|
508 |
html.push(tableCell(PictureURL[i].substr(0, PictureURL[i].lastIndexOf('/') + 1) + '$_57.JPG'));
|
|
|
509 |
html.push(tableCell(i + 1));
|
|
|
510 |
html.push(tableCell(Title + " Image " + (i + 1)));
|
|
|
511 |
html.push(tableCell(""));
|
|
|
512 |
html.push(tableCell(""));
|
|
|
513 |
html.push(tableCell(""));
|
|
|
514 |
html.push(tableCell(""));
|
|
|
515 |
html.push(tableCell(""));
|
|
|
516 |
html.push(tableCell(""));
|
|
|
517 |
html.push(tableCell(""));
|
|
|
518 |
html.push(tableCell(""));
|
|
|
519 |
html.push(tableCell(""));
|
|
|
520 |
html.push(tableCell(""));
|
|
|
521 |
html.push(tableCell(""));
|
|
|
522 |
html.push(tableCell(""));
|
|
|
523 |
html.push(tableCell(""));
|
|
|
524 |
html.push(tableCell(""));
|
|
|
525 |
html.push(tableCell(""));
|
|
|
526 |
html.push(tableCell(""));
|
|
|
527 |
html.push(tableCell(""));
|
|
|
528 |
html.push(tableCell(""));
|
|
|
529 |
html.push(tableCell(""));
|
|
|
530 |
html.push(tableCell(""));
|
2 |
- |
531 |
|
32 |
- |
532 |
html.push('</tr>');
|
|
|
533 |
}
|
2 |
- |
534 |
}
|
|
|
535 |
}
|
|
|
536 |
|
|
|
537 |
function extractDescription(str) {
|
|
|
538 |
var startText = "<!-- *************** Place description here ****************** -->";
|
|
|
539 |
var startPos = str.indexOf(startText) + startText.length;
|
|
|
540 |
var endPos = str.lastIndexOf("<!-- *************** Place description here ****************** -->");
|
|
|
541 |
var userDescription = str.substr(startPos, endPos - startPos);
|
|
|
542 |
var parser = new DOMParser();
|
|
|
543 |
var htmlDoc = parser.parseFromString(userDescription, "text/html");
|
|
|
544 |
|
|
|
545 |
return ((htmlDoc.getElementsByTagName('div')[0] !== undefined ? htmlDoc.getElementsByTagName('div')[0].innerHTML : userDescription));
|
|
|
546 |
}
|
|
|
547 |
|
|
|
548 |
function tableEnd() {
|
|
|
549 |
html.push('</tbody>');
|
|
|
550 |
html.push('</table>');
|
|
|
551 |
html.push('</div>');
|
|
|
552 |
|
|
|
553 |
document.getElementById("csv").innerHTML = html.join('');
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
function addNote(itemId) {
|
|
|
557 |
var i;
|
|
|
558 |
var xml;
|
|
|
559 |
|
|
|
560 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
561 |
var xhr = new XMLHttpRequest();
|
|
|
562 |
|
|
|
563 |
if (!createAddXMLNote(xw, xhr, 'SetUserNotesRequest', 'SetUserNotes', itemId)) {
|
|
|
564 |
return;
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
xml = xw.flush();
|
|
|
568 |
xw.close();
|
|
|
569 |
|
|
|
570 |
xhr.onload = function() {
|
16 |
- |
571 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
572 |
var obj = jsonObj.SetUserNotesResponse;
|
2 |
- |
573 |
var returnCode = obj.Ack;
|
19 |
- |
574 |
var str;
|
2 |
- |
575 |
|
|
|
576 |
var x = document.getElementById("results");
|
|
|
577 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
578 |
x.className += " w3-show";
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917108')) {
|
19 |
- |
582 |
str = '<p>' + itemId + ': <strong>' + returnCode + '</strong></p>';
|
2 |
- |
583 |
|
|
|
584 |
if (returnCode == 'Warning') {
|
19 |
- |
585 |
str += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
|
2 |
- |
586 |
}
|
19 |
- |
587 |
|
|
|
588 |
x.innerHTML += str;
|
2 |
- |
589 |
} else {
|
|
|
590 |
x.className += " process-errors";
|
30 |
- |
591 |
str = '<p class="text-danger">' + itemId + ': <strong>' + returnCode + ':</strong></p>';
|
2 |
- |
592 |
|
6 |
- |
593 |
var errors = getJsonArray(obj.Errors);
|
19 |
- |
594 |
str += "<p>";
|
6 |
- |
595 |
for (i = 0; i < errors.length; i++) {
|
19 |
- |
596 |
str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
2 |
- |
597 |
}
|
19 |
- |
598 |
str += "</p>";
|
|
|
599 |
|
|
|
600 |
x.innerHTML += str;
|
2 |
- |
601 |
}
|
|
|
602 |
|
|
|
603 |
if (obj.Message) {
|
|
|
604 |
x.innerHTML += obj.Message;
|
|
|
605 |
}
|
|
|
606 |
|
|
|
607 |
--notesToAdd;
|
|
|
608 |
++notesAdded;
|
|
|
609 |
|
|
|
610 |
updateProgressBar(maxNotesToAdd, notesAdded);
|
|
|
611 |
};
|
|
|
612 |
|
|
|
613 |
xhr.send(xml);
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
function createAddXMLNote(xw, xhr, xmlrequest, callname, itemId) {
|
|
|
617 |
var today = new Date();
|
|
|
618 |
var todayYYYYMMDD = today.toISOString().slice(0, 10);
|
|
|
619 |
|
|
|
620 |
xw.writeStartDocument();
|
|
|
621 |
xw.writeStartElement(xmlrequest);
|
|
|
622 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
623 |
|
|
|
624 |
xw.writeStartElement('RequesterCredentials');
|
|
|
625 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
626 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
627 |
|
|
|
628 |
xw.writeElementString('ItemID', itemId);
|
|
|
629 |
xw.writeElementString('Action', 'AddOrUpdate');
|
|
|
630 |
xw.writeElementString('NoteText', 'Exported to Shopify on ' + todayYYYYMMDD);
|
|
|
631 |
|
|
|
632 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
633 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
634 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
635 |
|
|
|
636 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
637 |
xw.writeEndDocument();
|
|
|
638 |
|
|
|
639 |
xhr.open('POST', configProxyUrl, true);
|
|
|
640 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
641 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
642 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
643 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
644 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
645 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
646 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
647 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
648 |
|
|
|
649 |
return true;
|
|
|
650 |
}
|
|
|
651 |
|
32 |
- |
652 |
function eBaySearch(itemId, onShopify) {
|
2 |
- |
653 |
var i;
|
|
|
654 |
var xml;
|
|
|
655 |
|
|
|
656 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
657 |
var xhr = new XMLHttpRequest();
|
|
|
658 |
|
|
|
659 |
if (!createAddXMLSearch(xw, xhr, 'GetItemRequest', 'GetItem', itemId)) {
|
|
|
660 |
return;
|
|
|
661 |
}
|
|
|
662 |
|
|
|
663 |
xml = xw.flush();
|
|
|
664 |
xw.close();
|
|
|
665 |
|
|
|
666 |
xhr.onload = function() {
|
190 |
- |
667 |
var returnCode;
|
|
|
668 |
var str;
|
16 |
- |
669 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
670 |
var obj = jsonObj.GetItemResponse;
|
2 |
- |
671 |
|
190 |
- |
672 |
if (obj === undefined) {
|
|
|
673 |
returncode = 'Response undefined';
|
|
|
674 |
} else {
|
|
|
675 |
returnCode = obj.Ack;
|
|
|
676 |
}
|
|
|
677 |
|
2 |
- |
678 |
var x = document.getElementById("results");
|
|
|
679 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
680 |
x.className += " w3-show";
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
if (returnCode == 'Success') {
|
32 |
- |
684 |
tableEntry(obj.Item, onShopify);
|
2 |
- |
685 |
} else {
|
|
|
686 |
x.className += " process-errors";
|
30 |
- |
687 |
str = '<p class="text-danger">' + itemId + ': <strong>' + returnCode + ':</strong></p>';
|
2 |
- |
688 |
|
6 |
- |
689 |
var errors = getJsonArray(obj.Errors);
|
19 |
- |
690 |
str += "<p>";
|
6 |
- |
691 |
for (i = 0; i < errors.length; i++) {
|
19 |
- |
692 |
str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
2 |
- |
693 |
}
|
19 |
- |
694 |
str += "</p>";
|
6 |
- |
695 |
|
19 |
- |
696 |
x.innerHTML += str;
|
2 |
- |
697 |
}
|
|
|
698 |
|
|
|
699 |
--pagesToProcess;
|
|
|
700 |
++pagesProcessed;
|
|
|
701 |
|
|
|
702 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
703 |
};
|
|
|
704 |
|
|
|
705 |
xhr.send(xml);
|
|
|
706 |
}
|
|
|
707 |
|
|
|
708 |
function createAddXMLSearch(xw, xhr, xmlrequest, callname, itemId) {
|
|
|
709 |
|
|
|
710 |
xw.writeStartDocument();
|
|
|
711 |
xw.writeStartElement(xmlrequest);
|
|
|
712 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
713 |
|
|
|
714 |
xw.writeStartElement('RequesterCredentials');
|
|
|
715 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
716 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
717 |
|
|
|
718 |
xw.writeElementString('ItemID', itemId);
|
|
|
719 |
xw.writeElementString('IncludeItemSpecifics', 'true');
|
|
|
720 |
xw.writeElementString('DetailLevel', 'ReturnAll');
|
|
|
721 |
|
|
|
722 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
723 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
724 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
725 |
|
|
|
726 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
727 |
xw.writeEndDocument();
|
|
|
728 |
|
|
|
729 |
xhr.open('POST', configProxyUrl, true);
|
|
|
730 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
731 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
732 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
733 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
734 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
735 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
736 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
737 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
738 |
|
|
|
739 |
return true;
|
|
|
740 |
}
|
|
|
741 |
|
|
|
742 |
function getListings() {
|
|
|
743 |
var x;
|
|
|
744 |
|
|
|
745 |
if (eBayAuthTokenFlag === false) {
|
|
|
746 |
return;
|
|
|
747 |
}
|
|
|
748 |
|
|
|
749 |
document.getElementById("logging").innerHTML = '';
|
|
|
750 |
|
|
|
751 |
x = document.getElementById("results");
|
|
|
752 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
753 |
x.className += " w3-show";
|
|
|
754 |
}
|
|
|
755 |
x.className = x.className.replace("process-errors", "");
|
|
|
756 |
x.innerHTML = '<p><strong>Retrieving Listings...</strong></p>';
|
|
|
757 |
|
32 |
- |
758 |
initProgressBar('Getting Items for Export (Step 1/3)');
|
2 |
- |
759 |
|
|
|
760 |
liveListing = (getRadioValue('rptType') == 'liveList');
|
|
|
761 |
tableSorterStart();
|
|
|
762 |
maxPagesToProcess = 1;
|
|
|
763 |
pagesToProcess = 1;
|
|
|
764 |
pagesProcessed = 0;
|
|
|
765 |
eBaySorterSearch(1);
|
|
|
766 |
|
|
|
767 |
function checkpagesToProcess() {
|
|
|
768 |
if (pagesToProcess > 0) {
|
|
|
769 |
window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds
|
|
|
770 |
} else {
|
|
|
771 |
tableSorterEnd();
|
|
|
772 |
endProgressBar();
|
|
|
773 |
// fillSorterListings(); is now in tableSorterEnd()
|
|
|
774 |
}
|
|
|
775 |
}
|
|
|
776 |
|
|
|
777 |
checkpagesToProcess();
|
|
|
778 |
}
|
|
|
779 |
|
|
|
780 |
function tableSorterStart() {
|
|
|
781 |
document.getElementById("logging").innerHTML = '';
|
|
|
782 |
html = [];
|
|
|
783 |
|
|
|
784 |
html.push('<h3>Items for Export</h3>');
|
|
|
785 |
html.push('<p>Showing <span id="filtered-rows">0</span> of <span id="total-rows">0</span> / <span id="selected-rows">0</span> selected.</p>');
|
30 |
- |
786 |
html.push('<div class="border table-responsive">');
|
2 |
- |
787 |
html.push('<table id="' + tableSorterName + '" class="tablesorter">');
|
|
|
788 |
html.push('<thead>');
|
|
|
789 |
html.push('<tr>');
|
|
|
790 |
|
6 |
- |
791 |
html.push(tableHeaderCheckbox());
|
2 |
- |
792 |
html.push(tableHeader('Image'));
|
|
|
793 |
html.push(tableHeader('Title'));
|
|
|
794 |
html.push(tableHeader('Item Id'));
|
|
|
795 |
html.push(tableHeader('SKU'));
|
|
|
796 |
html.push(tableHeader('Category'));
|
|
|
797 |
html.push(tableHeader('Format'));
|
|
|
798 |
html.push(tableHeader('Price'));
|
|
|
799 |
html.push(tableHeader('Quantity'));
|
|
|
800 |
html.push(tableHeader('Views'));
|
|
|
801 |
html.push(tableHeader('Watchers'));
|
|
|
802 |
html.push(tableHeader(liveListing ? 'Start Date' : 'End Date'));
|
|
|
803 |
html.push(tableHeader('Note'));
|
32 |
- |
804 |
html.push(tableHeader('Shopify'));
|
2 |
- |
805 |
|
|
|
806 |
html.push('</tr>');
|
|
|
807 |
html.push('</thead>');
|
|
|
808 |
html.push('<tbody>');
|
|
|
809 |
}
|
|
|
810 |
|
|
|
811 |
function tableSorterEntry(JsonObj) {
|
|
|
812 |
var i;
|
|
|
813 |
var image;
|
|
|
814 |
var title;
|
|
|
815 |
var itemId;
|
|
|
816 |
var sku;
|
|
|
817 |
var format;
|
|
|
818 |
var price;
|
|
|
819 |
var quantity;
|
|
|
820 |
var views;
|
|
|
821 |
var watchers;
|
|
|
822 |
var listingDate;
|
|
|
823 |
var privateNote;
|
|
|
824 |
var ebayNote;
|
|
|
825 |
var relisted;
|
16 |
- |
826 |
var bidCount;
|
2 |
- |
827 |
|
|
|
828 |
for (i = 0; i < JsonObj.length; i++) {
|
16 |
- |
829 |
image = getJsonValue(JsonObj[i].PictureDetails.GalleryURL).replace('http:', 'https:');
|
2 |
- |
830 |
title = getJsonValue(JsonObj[i].Title);
|
|
|
831 |
itemId = getJsonValue(JsonObj[i].ItemID);
|
|
|
832 |
sku = getJsonValue(JsonObj[i].SKU);
|
|
|
833 |
format = getJsonValue(JsonObj[i].ListingType);
|
16 |
- |
834 |
bidCount = (typeof(JsonObj[i].SellingStatus) === 'object' ? Number(getJsonValue(JsonObj[i].SellingStatus.BidCount)) : 0);
|
2 |
- |
835 |
if (format == 'Chinese') {
|
|
|
836 |
format = 'Auction';
|
|
|
837 |
price = getJsonValue(JsonObj[i].StartPrice.text);
|
|
|
838 |
} else {
|
|
|
839 |
format = 'Fixed Price';
|
|
|
840 |
price = getJsonValue(JsonObj[i].BuyItNowPrice.text);
|
|
|
841 |
}
|
|
|
842 |
quantity = getJsonValue(JsonObj[i].QuantityAvailable);
|
|
|
843 |
views = '';
|
16 |
- |
844 |
watchers = Number(getJsonValue(JsonObj[i].WatchCount));
|
|
|
845 |
listingDate = getJsonValue((liveListing ? JsonObj[i].ListingDetails.StartTime : JsonObj[i].ListingDetails.EndTime)).substr(0, 10);
|
2 |
- |
846 |
privateNote = getJsonValue(JsonObj[i].PrivateNotes);
|
|
|
847 |
ebayNote = getJsonValue(JsonObj[i].eBayNotes);
|
|
|
848 |
relisted = getJsonValue(JsonObj[i].Relisted);
|
|
|
849 |
|
|
|
850 |
if (!liveListing) {
|
|
|
851 |
if (privateNote.startsWith("Exported to ") || relisted == 'true' || privateNote.startsWith("Sold via ") || privateNote.startsWith("Relisted As New Item")) {
|
|
|
852 |
continue;
|
|
|
853 |
}
|
16 |
- |
854 |
} else {
|
|
|
855 |
if (bidCount > 0) {
|
|
|
856 |
continue;
|
|
|
857 |
}
|
2 |
- |
858 |
}
|
68 |
- |
859 |
|
|
|
860 |
if (Number(quantity) < 1) {
|
|
|
861 |
continue;
|
|
|
862 |
}
|
2 |
- |
863 |
|
|
|
864 |
html.push('<tr>');
|
|
|
865 |
|
|
|
866 |
html.push(tableCellCheckbox());
|
30 |
- |
867 |
html.push(tableCell('<img class="img-fluid" src="' + image + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">'));
|
2 |
- |
868 |
html.push(tableCell(title));
|
|
|
869 |
html.push(tableCell(itemId));
|
|
|
870 |
html.push(tableCell(sku));
|
|
|
871 |
html.push(tableCellLabel('Category' + itemId));
|
|
|
872 |
html.push(tableCell(format));
|
|
|
873 |
html.push(tableCell('$' + price));
|
|
|
874 |
html.push(tableCell(quantity));
|
|
|
875 |
html.push(tableCellLabel('Views' + itemId));
|
|
|
876 |
html.push(tableCell(watchers));
|
|
|
877 |
html.push(tableCell(listingDate));
|
|
|
878 |
html.push(tableCell(privateNote + ' ' + ebayNote));
|
32 |
- |
879 |
html.push(tableCellLabel('Shopify' + itemId));
|
2 |
- |
880 |
|
|
|
881 |
html.push('</tr>');
|
|
|
882 |
}
|
|
|
883 |
}
|
|
|
884 |
|
|
|
885 |
function tableSorterEnd() {
|
|
|
886 |
html.push('</tbody>');
|
|
|
887 |
html.push('</table>');
|
|
|
888 |
html.push('</div>');
|
|
|
889 |
|
|
|
890 |
document.getElementById("logging").innerHTML = html.join('');
|
|
|
891 |
|
|
|
892 |
$(function() {
|
|
|
893 |
$("#" + tableSorterName).on('tablesorter-initialized', function() {
|
|
|
894 |
|
|
|
895 |
// class name to add on tr when checkbox is checked
|
|
|
896 |
var highlightClass = 'checked',
|
|
|
897 |
// resort the table after the checkbox is modified?
|
|
|
898 |
resort = true,
|
|
|
899 |
$table = $(this),
|
|
|
900 |
c = this.config,
|
|
|
901 |
wo = c && c.widgetOptions,
|
|
|
902 |
// include sticky header checkbox; if installed
|
|
|
903 |
$sticky = c && wo.$sticky || '',
|
|
|
904 |
doChecky = function(c, col) {
|
|
|
905 |
$table
|
|
|
906 |
.children('tbody')
|
|
|
907 |
.children('tr:visible')
|
|
|
908 |
.children('td:nth-child( ' + (parseInt(col, 10) + 1) + ' )')
|
|
|
909 |
.find('input[type=checkbox]')
|
|
|
910 |
.each(function() {
|
|
|
911 |
this.checked = c;
|
|
|
912 |
$(this).trigger('change');
|
|
|
913 |
});
|
|
|
914 |
};
|
|
|
915 |
|
|
|
916 |
$table
|
|
|
917 |
.children('tbody')
|
|
|
918 |
.on('change', 'input[type=checkbox]', function() {
|
|
|
919 |
// ignore change if updating all rows
|
|
|
920 |
if ($table[0].ignoreChange) {
|
|
|
921 |
return;
|
|
|
922 |
}
|
|
|
923 |
var $this = $(this);
|
|
|
924 |
$this.closest('tr').toggleClass(highlightClass, this.checked);
|
19 |
- |
925 |
// resort will jump bqack to the top
|
|
|
926 |
// $this.trigger('updateCell', [$this.closest('td'), resort]);
|
2 |
- |
927 |
|
|
|
928 |
// handle header
|
7 |
- |
929 |
var rowCount = $('#' + tableSorterName + ' tbody tr').length;
|
2 |
- |
930 |
var checkedCount = $('#' + tableSorterName + ' tbody .checked').length;
|
|
|
931 |
var ua = window.navigator.userAgent;
|
|
|
932 |
if (checkedCount === 0) {
|
|
|
933 |
$table.add($sticky).find('thead input[type=checkbox]').prop('checked', false);
|
|
|
934 |
$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);
|
|
|
935 |
} else if (checkedCount === rowCount) {
|
|
|
936 |
$table.add($sticky).find('thead input[type=checkbox]').prop('checked', true);
|
|
|
937 |
$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);
|
|
|
938 |
} else {
|
|
|
939 |
$table.add($sticky).find('thead input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
|
|
|
940 |
$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', true);
|
|
|
941 |
}
|
|
|
942 |
$('#selected-rows').html(checkedCount);
|
|
|
943 |
})
|
|
|
944 |
.end()
|
|
|
945 |
.add($sticky)
|
|
|
946 |
.find('thead input[type=checkbox]')
|
|
|
947 |
// Click on checkbox in table header to toggle all inputs
|
|
|
948 |
.on('change', function() {
|
|
|
949 |
// prevent updateCell for every cell
|
|
|
950 |
$table[0].ignoreChange = true;
|
|
|
951 |
var c = this.checked,
|
|
|
952 |
col = $(this).closest('th').attr('data-column');
|
|
|
953 |
doChecky(c, col);
|
|
|
954 |
// update main & sticky header
|
|
|
955 |
|
|
|
956 |
$table.children('tbody').children('tr:visible').toggleClass(highlightClass, c);
|
|
|
957 |
// update all at once
|
|
|
958 |
$table[0].ignoreChange = false;
|
|
|
959 |
$table.trigger('update', [resort]);
|
|
|
960 |
|
|
|
961 |
// handle header
|
7 |
- |
962 |
var rowCount = $('#' + tableSorterName + ' tbody tr').length;
|
2 |
- |
963 |
var checkedCount = $('#' + tableSorterName + ' tbody .checked').length;
|
|
|
964 |
var ua = window.navigator.userAgent;
|
|
|
965 |
if (checkedCount === 0) {
|
|
|
966 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', false);
|
|
|
967 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);
|
|
|
968 |
} else if (checkedCount === rowCount) {
|
|
|
969 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', true);
|
|
|
970 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);
|
|
|
971 |
} else {
|
|
|
972 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
|
|
|
973 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', true);
|
|
|
974 |
}
|
|
|
975 |
$('#selected-rows').html(checkedCount);
|
|
|
976 |
})
|
|
|
977 |
.on('mouseup', function() {
|
|
|
978 |
return false;
|
|
|
979 |
});
|
|
|
980 |
|
|
|
981 |
});
|
|
|
982 |
|
|
|
983 |
$("#" + tableSorterName).tablesorter({
|
|
|
984 |
theme: "blue",
|
|
|
985 |
widgets: ["zebra", "stickyHeaders", "filter"],
|
|
|
986 |
headers: {
|
|
|
987 |
0: {
|
|
|
988 |
sorter: "checkbox"
|
|
|
989 |
},
|
|
|
990 |
1: {
|
|
|
991 |
sorter: false,
|
|
|
992 |
filter: false
|
|
|
993 |
}
|
|
|
994 |
},
|
|
|
995 |
initialized: function() {
|
|
|
996 |
fillSorterListings();
|
|
|
997 |
}
|
|
|
998 |
});
|
|
|
999 |
|
|
|
1000 |
$("#" + tableSorterName).bind('filterInit filterEnd', function(event, data) {
|
|
|
1001 |
$('#filtered-rows').html(data.filteredRows);
|
|
|
1002 |
$('#total-rows').html(data.totalRows);
|
|
|
1003 |
});
|
|
|
1004 |
});
|
|
|
1005 |
}
|
|
|
1006 |
|
|
|
1007 |
function eBaySorterSearch(pageNo) {
|
|
|
1008 |
var i;
|
|
|
1009 |
var xml;
|
|
|
1010 |
|
|
|
1011 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
1012 |
var xhr = new XMLHttpRequest();
|
|
|
1013 |
|
|
|
1014 |
if (!createSorterAddXMLSearch(xw, xhr, 'GetMyeBaySelling', pageNo)) {
|
|
|
1015 |
return;
|
|
|
1016 |
}
|
|
|
1017 |
|
|
|
1018 |
xml = xw.flush();
|
|
|
1019 |
xw.close();
|
|
|
1020 |
|
|
|
1021 |
xhr.onload = function() {
|
16 |
- |
1022 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
1023 |
var obj = jsonObj.GetMyeBaySellingResponse;
|
2 |
- |
1024 |
var returnCode = obj.Ack;
|
19 |
- |
1025 |
var str;
|
2 |
- |
1026 |
|
|
|
1027 |
var objArray = (liveListing ? obj.ActiveList : obj.UnsoldList);
|
|
|
1028 |
|
|
|
1029 |
var x = document.getElementById("results");
|
|
|
1030 |
|
|
|
1031 |
if (returnCode == 'Success') {
|
16 |
- |
1032 |
tableSorterEntry(objArray.ItemArray.Item);
|
2 |
- |
1033 |
|
|
|
1034 |
if (Number(objArray.PaginationResult.TotalNumberOfPages) > pageNo) {
|
|
|
1035 |
maxPagesToProcess = Number(objArray.PaginationResult.TotalNumberOfPages);
|
|
|
1036 |
++pagesToProcess;
|
|
|
1037 |
eBaySorterSearch(pageNo + 1);
|
|
|
1038 |
}
|
|
|
1039 |
|
|
|
1040 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
1041 |
} else {
|
|
|
1042 |
x.className += " process-errors";
|
30 |
- |
1043 |
str = '<p class="text-danger">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
|
6 |
- |
1044 |
var errors = getJsonArray(obj.Errors);
|
19 |
- |
1045 |
str += "<p>";
|
6 |
- |
1046 |
for (i = 0; i < errors.length; i++) {
|
19 |
- |
1047 |
str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
2 |
- |
1048 |
}
|
19 |
- |
1049 |
str += "</p>";
|
6 |
- |
1050 |
|
19 |
- |
1051 |
x.innerHTML += str;
|
2 |
- |
1052 |
}
|
|
|
1053 |
|
|
|
1054 |
--pagesToProcess;
|
|
|
1055 |
++pagesProcessed;
|
|
|
1056 |
|
|
|
1057 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
1058 |
};
|
|
|
1059 |
|
|
|
1060 |
xhr.send(xml);
|
|
|
1061 |
}
|
|
|
1062 |
|
|
|
1063 |
function createSorterAddXMLSearch(xw, xhr, callname, pageNo) {
|
14 |
- |
1064 |
var outputSelector;
|
|
|
1065 |
|
2 |
- |
1066 |
xw.writeStartDocument();
|
|
|
1067 |
xw.writeStartElement(callname + "Request");
|
|
|
1068 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
1069 |
|
|
|
1070 |
xw.writeStartElement('RequesterCredentials');
|
|
|
1071 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
1072 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
1073 |
|
|
|
1074 |
xw.writeElementString('DetailLevel', 'ReturnAll');
|
|
|
1075 |
xw.writeStartElement('DeletedFromSoldList');
|
|
|
1076 |
xw.writeElementString('Include', 'false');
|
|
|
1077 |
xw.writeEndElement(); /* DeletedFromSoldList */
|
|
|
1078 |
xw.writeStartElement('DeletedFromUnsoldList');
|
|
|
1079 |
xw.writeElementString('Include', 'false');
|
|
|
1080 |
xw.writeEndElement(); /* DeletedFromUnsoldList */
|
|
|
1081 |
xw.writeStartElement('ScheduledList');
|
|
|
1082 |
xw.writeElementString('Include', 'false');
|
|
|
1083 |
xw.writeEndElement(); /* ScheduledList */
|
|
|
1084 |
xw.writeStartElement('SellingSummary');
|
|
|
1085 |
xw.writeElementString('Include', 'false');
|
|
|
1086 |
xw.writeEndElement(); /* SellingSummary */
|
|
|
1087 |
xw.writeStartElement('SoldList');
|
|
|
1088 |
xw.writeElementString('Include', 'false');
|
|
|
1089 |
xw.writeEndElement(); /* SoldList */
|
|
|
1090 |
|
|
|
1091 |
xw.writeStartElement(liveListing ? 'UnsoldList' : 'ActiveList');
|
|
|
1092 |
xw.writeElementString('Include', 'false');
|
|
|
1093 |
xw.writeEndElement(); /* ActiveList */
|
|
|
1094 |
|
|
|
1095 |
xw.writeStartElement(liveListing ? 'ActiveList' : 'UnsoldList');
|
|
|
1096 |
xw.writeElementString('Include', 'true');
|
|
|
1097 |
xw.writeElementString('IncludeNotes', 'true');
|
|
|
1098 |
xw.writeStartElement('Pagination');
|
|
|
1099 |
xw.writeElementString('EntriesPerPage', '200');
|
|
|
1100 |
xw.writeElementString('PageNumber', '' + pageNo);
|
|
|
1101 |
xw.writeEndElement(); /* Pagination*/
|
|
|
1102 |
xw.writeEndElement(); /* UnsoldList> */
|
|
|
1103 |
|
14 |
- |
1104 |
outputSelector = liveListing ? 'ActiveList.' : 'UnsoldList.';
|
|
|
1105 |
|
16 |
- |
1106 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.SellingStatus.BidCount');
|
14 |
- |
1107 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.BuyItNowPrice');
|
|
|
1108 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.eBayNotes');
|
|
|
1109 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.ItemID');
|
16 |
- |
1110 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.ListingDetails.' + (liveListing ? 'StartTime' : 'EndTime'));
|
14 |
- |
1111 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.ListingType');
|
|
|
1112 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.PrivateNotes');
|
|
|
1113 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.QuantityAvailable');
|
|
|
1114 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.PictureDetails');
|
|
|
1115 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.Relisted');
|
|
|
1116 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.SKU');
|
|
|
1117 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.Title');
|
|
|
1118 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.StartPrice');
|
|
|
1119 |
xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.WatchCount');
|
|
|
1120 |
xw.writeElementString('OutputSelector', outputSelector + 'PaginationResult');
|
|
|
1121 |
|
2 |
- |
1122 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
1123 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
1124 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
1125 |
|
|
|
1126 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
1127 |
xw.writeEndDocument();
|
|
|
1128 |
|
|
|
1129 |
xhr.open('POST', configProxyUrl, true);
|
|
|
1130 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
1131 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
1132 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
1133 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
1134 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
1135 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
1136 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
1137 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
1138 |
|
|
|
1139 |
return true;
|
|
|
1140 |
}
|
|
|
1141 |
|
|
|
1142 |
function fillSorterListings() {
|
|
|
1143 |
var i;
|
|
|
1144 |
var x = document.getElementById(tableSorterName);
|
|
|
1145 |
var fillList = [];
|
|
|
1146 |
var maxItems = 20;
|
|
|
1147 |
|
|
|
1148 |
listingsToFill = 0;
|
|
|
1149 |
maxListingsToFill = 0;
|
|
|
1150 |
listingsFilled = 0;
|
|
|
1151 |
|
32 |
- |
1152 |
initProgressBar('Filling Listing Information (Step 2/3)');
|
2 |
- |
1153 |
|
|
|
1154 |
for (i = 2; i < x.rows.length; i++) {
|
|
|
1155 |
fillList.push(x.rows[i].cells[3].innerHTML);
|
|
|
1156 |
}
|
6 |
- |
1157 |
|
16 |
- |
1158 |
for (i = 0; (i * maxItems) < fillList.length; i++) {
|
2 |
- |
1159 |
++listingsToFill;
|
|
|
1160 |
++maxListingsToFill;
|
|
|
1161 |
fillSorterListing(fillList.slice(i * maxItems, (i + 1) * maxItems));
|
|
|
1162 |
}
|
|
|
1163 |
|
|
|
1164 |
function checkListingsToFill() {
|
|
|
1165 |
if (listingsToFill > 0) {
|
|
|
1166 |
window.setTimeout(checkListingsToFill, 100); // wait 100 milliseconds
|
|
|
1167 |
} else {
|
|
|
1168 |
$("#" + tableSorterName).trigger("update");
|
|
|
1169 |
|
|
|
1170 |
endProgressBar();
|
32 |
- |
1171 |
findOnShopify();
|
|
|
1172 |
}
|
|
|
1173 |
}
|
2 |
- |
1174 |
|
32 |
- |
1175 |
checkListingsToFill();
|
|
|
1176 |
}
|
|
|
1177 |
|
|
|
1178 |
function findOnShopify() {
|
|
|
1179 |
var i;
|
|
|
1180 |
var x = document.getElementById(tableSorterName);
|
|
|
1181 |
|
|
|
1182 |
listingsToFind = 0;
|
|
|
1183 |
maxListingsToFind = 0;
|
|
|
1184 |
listingsFound = 0;
|
|
|
1185 |
|
|
|
1186 |
initProgressBar('Finding Listings already on Shopify (Step 3/3)');
|
|
|
1187 |
|
|
|
1188 |
for (i = 2; i < x.rows.length; i++) {
|
|
|
1189 |
++listingsToFind;
|
|
|
1190 |
++maxListingsToFind;
|
54 |
- |
1191 |
findShopifyListing(x.rows[i].cells[3].innerHTML, x.rows[i].cells[2].innerText).then(function(env) {
|
32 |
- |
1192 |
--listingsToFind;
|
|
|
1193 |
++listingsFound;
|
|
|
1194 |
updateProgressBar(maxListingsToFind, listingsFound);
|
|
|
1195 |
});
|
|
|
1196 |
}
|
|
|
1197 |
|
|
|
1198 |
function checkListingsToFind() {
|
|
|
1199 |
if (listingsToFind > 0) {
|
|
|
1200 |
window.setTimeout(checkListingsToFind, 100); // wait 100 milliseconds
|
|
|
1201 |
} else {
|
|
|
1202 |
$("#" + tableSorterName).trigger("update");
|
|
|
1203 |
|
|
|
1204 |
endProgressBar();
|
|
|
1205 |
|
2 |
- |
1206 |
x = document.getElementById("form1div");
|
|
|
1207 |
x.className = x.className.replace(" w3-show", "");
|
|
|
1208 |
x = document.getElementById("form2div");
|
|
|
1209 |
x.className += " w3-show";
|
|
|
1210 |
|
|
|
1211 |
x = document.getElementById("results");
|
|
|
1212 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
|
|
1213 |
if (!x.className.includes("process-errors")) {
|
|
|
1214 |
setTimeout(function() {
|
|
|
1215 |
x.className = x.className.replace(" w3-show", "");
|
|
|
1216 |
}, 3000);
|
|
|
1217 |
}
|
|
|
1218 |
}
|
|
|
1219 |
}
|
|
|
1220 |
|
32 |
- |
1221 |
checkListingsToFind();
|
2 |
- |
1222 |
}
|
|
|
1223 |
|
32 |
- |
1224 |
const findShopifyListing = stopcock(function request(itemId, title) {
|
|
|
1225 |
var xhttp = new XMLHttpRequest();
|
|
|
1226 |
xhttp.onreadystatechange = function() {
|
|
|
1227 |
if (this.readyState == 4 && this.status == 200) {
|
|
|
1228 |
var json = JSON.parse(this.responseText);
|
139 |
- |
1229 |
if (typeof(json.products) != 'undefined') {
|
32 |
- |
1230 |
var x = document.getElementById('Shopify' + itemId);
|
139 |
- |
1231 |
x.innerHTML = (json.products.length > 0 ? 'Yes' : 'No');
|
32 |
- |
1232 |
}
|
|
|
1233 |
|
|
|
1234 |
return Promise.resolve(true);
|
|
|
1235 |
}
|
|
|
1236 |
};
|
|
|
1237 |
|
53 |
- |
1238 |
title = cleanTitleForShopifySearch(title);
|
|
|
1239 |
|
32 |
- |
1240 |
xhttp.open("GET", configProxyUrl, true);
|
145 |
- |
1241 |
xhttp.setRequestHeader("X-Proxy-Url", configShopifyUrl + configShopifyProductsUrl + '?limit=1&title=' + title);
|
32 |
- |
1242 |
xhttp.setRequestHeader("X-LEAVE-ENCODED", "1");
|
|
|
1243 |
xhttp.send();
|
|
|
1244 |
});
|
|
|
1245 |
|
2 |
- |
1246 |
function fillSorterListing(itemIdList) {
|
|
|
1247 |
var i;
|
|
|
1248 |
var xml;
|
|
|
1249 |
|
|
|
1250 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
1251 |
var xhr = new XMLHttpRequest();
|
|
|
1252 |
|
|
|
1253 |
if (!createSorterFillXMLSearch(xw, xhr, 'GetMultipleItems', itemIdList)) {
|
|
|
1254 |
return;
|
|
|
1255 |
}
|
|
|
1256 |
|
|
|
1257 |
xml = xw.flush();
|
|
|
1258 |
xw.close();
|
|
|
1259 |
|
|
|
1260 |
xhr.onload = function() {
|
16 |
- |
1261 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
1262 |
var obj = jsonObj.GetMultipleItemsResponse;
|
147 |
- |
1263 |
var returnCode;
|
19 |
- |
1264 |
var str;
|
2 |
- |
1265 |
var x = document.getElementById("results");
|
|
|
1266 |
|
163 |
- |
1267 |
if (obj === undefined) {
|
158 |
- |
1268 |
fillSorterListing(itemIdList);
|
163 |
- |
1269 |
return;
|
147 |
- |
1270 |
} else {
|
|
|
1271 |
returnCode = obj.Ack;
|
|
|
1272 |
}
|
|
|
1273 |
|
2 |
- |
1274 |
if (returnCode == 'Success') {
|
|
|
1275 |
for (i = 0; i < obj.Item.length; i++) {
|
|
|
1276 |
var itemId = getJsonValue(obj.Item[i].ItemID);
|
|
|
1277 |
document.getElementById("Views" + itemId).innerHTML = getJsonValue(obj.Item[i].HitCount);
|
|
|
1278 |
document.getElementById("Category" + itemId).innerHTML = getJsonValue(obj.Item[i].PrimaryCategoryName);
|
6 |
- |
1279 |
}
|
2 |
- |
1280 |
} else {
|
|
|
1281 |
x.className += " process-errors";
|
30 |
- |
1282 |
str = '<p class="text-danger"><strong>' + returnCode + ':</strong></p>';
|
2 |
- |
1283 |
|
6 |
- |
1284 |
var errors = getJsonArray(obj.Errors);
|
19 |
- |
1285 |
str += "<p>";
|
6 |
- |
1286 |
for (i = 0; i < errors.length; i++) {
|
19 |
- |
1287 |
str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
2 |
- |
1288 |
}
|
|
|
1289 |
x.innerHTML += "</p>";
|
19 |
- |
1290 |
|
|
|
1291 |
x.innerHTML += str;
|
2 |
- |
1292 |
}
|
|
|
1293 |
|
|
|
1294 |
--listingsToFill;
|
|
|
1295 |
++listingsFilled;
|
|
|
1296 |
updateProgressBar(maxListingsToFill, listingsFilled);
|
|
|
1297 |
};
|
|
|
1298 |
|
|
|
1299 |
xhr.send(xml);
|
|
|
1300 |
}
|
|
|
1301 |
|
|
|
1302 |
function createSorterFillXMLSearch(xw, xhr, callname, itemIdList) {
|
|
|
1303 |
var i;
|
6 |
- |
1304 |
|
2 |
- |
1305 |
xw.writeStartDocument();
|
|
|
1306 |
xw.writeStartElement(callname + "Request");
|
|
|
1307 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
1308 |
|
|
|
1309 |
for (i = 0; i < itemIdList.length; i++) {
|
|
|
1310 |
xw.writeElementString('ItemID', itemIdList[i]);
|
|
|
1311 |
}
|
|
|
1312 |
|
|
|
1313 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
1314 |
xw.writeElementString('Version', configeBayShoppingVersion);
|
|
|
1315 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
1316 |
|
|
|
1317 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
1318 |
xw.writeEndDocument();
|
|
|
1319 |
|
|
|
1320 |
xhr.open('POST', configProxyUrl, true);
|
|
|
1321 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
1322 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
1323 |
xhr.setRequestHeader('X-EBAY-API-VERSION', configeBayShoppingVersion);
|
|
|
1324 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
1325 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
1326 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
1327 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
1328 |
xhr.setRequestHeader('X-EBAY-API-REQUEST-ENCODING', 'XML');
|
|
|
1329 |
xhr.setRequestHeader('X-Proxy-URL', configeBayShopping);
|
|
|
1330 |
|
|
|
1331 |
return true;
|
|
|
1332 |
}
|
|
|
1333 |
|
|
|
1334 |
</script>
|
17 |
- |
1335 |
<script>includeHTML();</script>
|
2 |
- |
1336 |
|
|
|
1337 |
</body>
|
|
|
1338 |
</html>
|