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