| 2 |
- |
1 |
<!DOCTYPE html>
|
|
|
2 |
<html lang="en">
|
|
|
3 |
|
|
|
4 |
<head>
|
|
|
5 |
<title>Relist on eBay</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">Relist on eBay
|
|
|
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" />
|
|
|
31 |
</p>
|
|
|
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="createForm" class="w3-container w3-card-2 w3-cell w3-padding">
|
|
|
38 |
<input id="includeExported" name="includeExported" class="w3-check" style="height:1em;vertical-align:super;" type="checkbox">
|
|
|
39 |
<label for="includeExported">Include Exported Listing</label>
|
|
|
40 |
<p>Listing Type:</p>
|
|
|
41 |
<input type="radio" name="ltype" id="ltFixed" checked /> Fixed Price<br>
|
|
|
42 |
<input type="radio" name="ltype" id="ltAuction" /> Auction<br>
|
|
|
43 |
<input type="radio" name="ltype" id="ltBoth" /> Both<br>
|
|
|
44 |
<input id="startButton" type="button" class="w3-btn w3-large w3-red w3-margin w3-round-large w3-ripple" onclick="getListings();" value="Start" />
|
|
|
45 |
</div>
|
|
|
46 |
<div id="relistForm" class="w3-container w3-card-2 w3-cell w3-padding w3-hide">
|
|
|
47 |
<input id="relistButton" type="button" class="w3-btn w3-large w3-black w3-margin w3-round-large w3-ripple" onclick="putListings();" value="Relist" />
|
|
|
48 |
</div>
|
|
|
49 |
</form>
|
|
|
50 |
</div>
|
|
|
51 |
<div id="progressBarDiv" class="w3-container w3-padding w3-margin w3-card-4 w3-hide">
|
|
|
52 |
<h2 id="progressBarHeader"></h2>
|
|
|
53 |
<div class="w3-light-grey">
|
|
|
54 |
<div id="progressBar" class="w3-container w3-green w3-center" style="width:0%">0%</div>
|
|
|
55 |
</div>
|
|
|
56 |
</div>
|
|
|
57 |
<div id="results" class="w3-container w3-padding w3-card-4 w3-hide"></div>
|
|
|
58 |
<div id="logging" class="w3-container w3-padding"></div>
|
|
|
59 |
</div>
|
|
|
60 |
</div>
|
|
|
61 |
|
|
|
62 |
<footer class="w3-container w3-center w3-border-top w3-margin">
|
|
|
63 |
Copyright © 2018 MUNA Trading. All rights reserved.
|
|
|
64 |
</footer>
|
|
|
65 |
|
|
|
66 |
</div>
|
|
|
67 |
|
|
|
68 |
<script>
|
|
|
69 |
// Globals
|
|
|
70 |
var tableName = "unsoldTable";
|
|
|
71 |
var maxPagesToProcess = 0;
|
|
|
72 |
var pagesToProcess = 0;
|
|
|
73 |
var pagesProcessed = 0;
|
|
|
74 |
var listingsToFill = 0;
|
|
|
75 |
var maxListingsToFill = 0;
|
|
|
76 |
var listingsFilled = 0;
|
|
|
77 |
var listingsToRelist = 0;
|
|
|
78 |
var maxListingsToRelist = 0;
|
|
|
79 |
var listingsRelisted = 0;
|
|
|
80 |
var html = [];
|
|
|
81 |
|
|
|
82 |
// Initialize Configuration Variables
|
|
|
83 |
function initConfig() {
|
|
|
84 |
eBayAuthToken = readCookie();
|
|
|
85 |
if (eBayAuthToken.length > 0) {
|
|
|
86 |
connected();
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
if (eBayAuthTokenFlag === false) {
|
|
|
90 |
var x = document.getElementById("login");
|
|
|
91 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
92 |
x.className += " w3-show";
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
function connected() {
|
|
|
98 |
var x;
|
|
|
99 |
|
|
|
100 |
eBayAuthTokenFlag = true;
|
|
|
101 |
document.getElementById("connected").innerHTML += " (Connected)";
|
|
|
102 |
|
|
|
103 |
x = document.getElementById("startButton");
|
|
|
104 |
x.className = x.className.replace(" w3-red", " w3-black");
|
|
|
105 |
|
|
|
106 |
x = document.getElementById("login");
|
|
|
107 |
x.className = x.className.replace(" w3-show", "");
|
|
|
108 |
|
|
|
109 |
x = document.getElementById("results");
|
|
|
110 |
x.innerHTML = "";
|
|
|
111 |
x.className = x.className.replace(" w3-show", "");
|
|
|
112 |
x.className = x.className.replace(" process-errors", "");
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
function requireNewLogin() {
|
|
|
116 |
var x = document.getElementById("startButton");
|
|
|
117 |
x.className = x.className.replace(" w3-black", " w3-red ");
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
function getListings() {
|
|
|
121 |
var x;
|
|
|
122 |
|
|
|
123 |
if (eBayAuthTokenFlag === false) {
|
|
|
124 |
return;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
document.getElementById("logging").innerHTML = '';
|
|
|
128 |
|
|
|
129 |
x = document.getElementById("results");
|
|
|
130 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
131 |
x.className += " w3-show";
|
|
|
132 |
}
|
|
|
133 |
x.className = x.className.replace("process-errors", "");
|
|
|
134 |
x.innerHTML = '<p><strong>Retrieving Unsold Listings...</strong></p>';
|
|
|
135 |
|
|
|
136 |
initProgressBar('Get Unsold and Not Relisted Items (1/2)');
|
|
|
137 |
|
|
|
138 |
tableStart();
|
|
|
139 |
maxPagesToProcess = 1;
|
|
|
140 |
pagesToProcess = 1;
|
|
|
141 |
pagesProcessed = 0;
|
|
|
142 |
eBaySearch(1);
|
|
|
143 |
|
|
|
144 |
function checkpagesToProcess() {
|
|
|
145 |
if (pagesToProcess > 0) {
|
|
|
146 |
window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds
|
|
|
147 |
} else {
|
|
|
148 |
tableEnd();
|
|
|
149 |
endProgressBar();
|
|
|
150 |
// fillListings(); is now in tableEnd()
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
checkpagesToProcess();
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
function tableStart() {
|
|
|
158 |
document.getElementById("logging").innerHTML = '';
|
|
|
159 |
html = [];
|
|
|
160 |
|
|
|
161 |
html.push('<h3>Unsold and Not Relisted</h3>');
|
|
|
162 |
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>');
|
|
|
163 |
html.push('<div class="w3-responsive">');
|
|
|
164 |
html.push('<table id="' + tableName + '" class="tablesorter">');
|
|
|
165 |
html.push('<thead>');
|
|
|
166 |
html.push('<tr>');
|
|
|
167 |
|
| 6 |
- |
168 |
html.push(tableHeaderCheckbox());
|
| 2 |
- |
169 |
html.push(tableHeader('Image'));
|
|
|
170 |
html.push(tableHeader('Title'));
|
|
|
171 |
html.push(tableHeader('Item Id'));
|
|
|
172 |
html.push(tableHeader('SKU'));
|
|
|
173 |
html.push(tableHeader('Category'));
|
|
|
174 |
html.push(tableHeader('Format'));
|
|
|
175 |
html.push(tableHeader('Price'));
|
|
|
176 |
html.push(tableHeader('Quantity'));
|
|
|
177 |
html.push(tableHeader('Views'));
|
|
|
178 |
html.push(tableHeader('Watchers'));
|
|
|
179 |
html.push(tableHeader('End Date'));
|
|
|
180 |
html.push(tableHeader('Note'));
|
|
|
181 |
|
|
|
182 |
html.push('</tr>');
|
|
|
183 |
html.push('</thead>');
|
|
|
184 |
html.push('<tbody>');
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
function tableEntry(JsonObj) {
|
|
|
188 |
var i;
|
|
|
189 |
var image;
|
|
|
190 |
var title;
|
|
|
191 |
var itemId;
|
|
|
192 |
var sku;
|
|
|
193 |
var format;
|
|
|
194 |
var price;
|
|
|
195 |
var quantity;
|
|
|
196 |
var views;
|
|
|
197 |
var watchers;
|
|
|
198 |
var endDate;
|
|
|
199 |
var privateNote;
|
|
|
200 |
var ebayNote;
|
|
|
201 |
var relisted;
|
|
|
202 |
|
|
|
203 |
for (i = 0; i < JsonObj.length; i++) {
|
| 12 |
- |
204 |
image = getJsonValue(JsonObj[i].PictureDetails.GalleryURL).replace('http:', 'https:');
|
| 2 |
- |
205 |
title = getJsonValue(JsonObj[i].Title);
|
|
|
206 |
itemId = getJsonValue(JsonObj[i].ItemID);
|
|
|
207 |
sku = getJsonValue(JsonObj[i].SKU);
|
|
|
208 |
format = getJsonValue(JsonObj[i].ListingType);
|
|
|
209 |
if (format == 'Chinese') {
|
|
|
210 |
format = 'Auction';
|
|
|
211 |
price = getJsonValue(JsonObj[i].StartPrice.text);
|
|
|
212 |
} else {
|
|
|
213 |
format = 'Fixed Price';
|
|
|
214 |
price = getJsonValue(JsonObj[i].BuyItNowPrice.text);
|
|
|
215 |
}
|
|
|
216 |
quantity = getJsonValue(JsonObj[i].QuantityAvailable);
|
|
|
217 |
views = '';
|
|
|
218 |
watchers = getJsonValue(JsonObj[i].WatchCount);
|
|
|
219 |
watchers = (watchers.length === 0 ? "0" : watchers);
|
| 12 |
- |
220 |
endDate = getJsonValue(JsonObj[i].ListingDetails.EndTime).substr(0, 10);
|
| 2 |
- |
221 |
privateNote = getJsonValue(JsonObj[i].PrivateNotes);
|
|
|
222 |
ebayNote = getJsonValue(JsonObj[i].eBayNotes);
|
|
|
223 |
relisted = getJsonValue(JsonObj[i].Relisted);
|
|
|
224 |
|
|
|
225 |
if ((privateNote.startsWith("Exported to ") && !document.getElementById('includeExported').checked) || relisted == 'true' || privateNote.startsWith("Sold via ") || privateNote.startsWith("Relisted As New Item")) {
|
|
|
226 |
continue;
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
if (format == 'Auction' && document.getElementById('ltFixed').checked) {
|
|
|
230 |
continue;
|
|
|
231 |
} else if (format == 'Fixed Price' && document.getElementById('ltAuction').checked) {
|
|
|
232 |
continue;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
html.push('<tr>');
|
|
|
236 |
|
|
|
237 |
html.push(tableCellCheckbox());
|
|
|
238 |
html.push(tableCell('<img class="w3-image" src="' + image + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">'));
|
|
|
239 |
html.push(tableCell(title));
|
|
|
240 |
html.push(tableCell(itemId));
|
|
|
241 |
html.push(tableCell(sku));
|
|
|
242 |
html.push(tableCellLabel('Category' + itemId));
|
|
|
243 |
html.push(tableCell(format));
|
|
|
244 |
html.push(tableCell('$' + price));
|
|
|
245 |
html.push(tableCell(quantity));
|
|
|
246 |
html.push(tableCellLabel('Views' + itemId));
|
|
|
247 |
html.push(tableCell(watchers));
|
|
|
248 |
html.push(tableCell(endDate));
|
|
|
249 |
html.push(tableCell(privateNote + ' ' + ebayNote));
|
|
|
250 |
|
|
|
251 |
html.push('</tr>');
|
|
|
252 |
}
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
function tableEnd() {
|
|
|
256 |
html.push('</tbody>');
|
|
|
257 |
html.push('</table>');
|
|
|
258 |
html.push('</div>');
|
|
|
259 |
|
|
|
260 |
document.getElementById("logging").innerHTML = html.join('');
|
|
|
261 |
|
|
|
262 |
$(function() {
|
|
|
263 |
$("#" + tableName).on('tablesorter-initialized', function() {
|
|
|
264 |
|
|
|
265 |
// class name to add on tr when checkbox is checked
|
|
|
266 |
var highlightClass = 'checked',
|
|
|
267 |
// resort the table after the checkbox is modified?
|
|
|
268 |
resort = true,
|
|
|
269 |
$table = $(this),
|
|
|
270 |
c = this.config,
|
|
|
271 |
wo = c && c.widgetOptions,
|
|
|
272 |
// include sticky header checkbox; if installed
|
|
|
273 |
$sticky = c && wo.$sticky || '',
|
|
|
274 |
doChecky = function(c, col) {
|
|
|
275 |
$table
|
|
|
276 |
.children('tbody')
|
|
|
277 |
.children('tr:visible')
|
|
|
278 |
.children('td:nth-child( ' + (parseInt(col, 10) + 1) + ' )')
|
|
|
279 |
.find('input[type=checkbox]')
|
|
|
280 |
.each(function() {
|
|
|
281 |
this.checked = c;
|
|
|
282 |
$(this).trigger('change');
|
|
|
283 |
});
|
|
|
284 |
};
|
|
|
285 |
|
|
|
286 |
$table
|
|
|
287 |
.children('tbody')
|
|
|
288 |
.on('change', 'input[type=checkbox]', function() {
|
|
|
289 |
// ignore change if updating all rows
|
|
|
290 |
if ($table[0].ignoreChange) {
|
|
|
291 |
return;
|
|
|
292 |
}
|
|
|
293 |
var $this = $(this);
|
|
|
294 |
$this.closest('tr').toggleClass(highlightClass, this.checked);
|
|
|
295 |
$this.trigger('updateCell', [$this.closest('td'), resort]);
|
|
|
296 |
|
|
|
297 |
// handle header
|
| 7 |
- |
298 |
var rowCount = $('#' + tableName + ' tbody tr').length;
|
| 2 |
- |
299 |
var checkedCount = $('#' + tableName + ' tbody .checked').length;
|
|
|
300 |
var ua = window.navigator.userAgent;
|
|
|
301 |
if (checkedCount === 0) {
|
|
|
302 |
$table.add($sticky).find('thead input[type=checkbox]').prop('checked', false);
|
|
|
303 |
$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);
|
|
|
304 |
} else if (checkedCount === rowCount) {
|
|
|
305 |
$table.add($sticky).find('thead input[type=checkbox]').prop('checked', true);
|
|
|
306 |
$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);
|
|
|
307 |
} else {
|
|
|
308 |
$table.add($sticky).find('thead input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
|
|
|
309 |
$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', true);
|
|
|
310 |
}
|
|
|
311 |
$('#selected-rows').html(checkedCount);
|
|
|
312 |
})
|
|
|
313 |
.end()
|
|
|
314 |
.add($sticky)
|
|
|
315 |
.find('thead input[type=checkbox]')
|
|
|
316 |
// Click on checkbox in table header to toggle all inputs
|
|
|
317 |
.on('change', function() {
|
|
|
318 |
// prevent updateCell for every cell
|
|
|
319 |
$table[0].ignoreChange = true;
|
|
|
320 |
var c = this.checked,
|
|
|
321 |
col = $(this).closest('th').attr('data-column');
|
|
|
322 |
doChecky(c, col);
|
|
|
323 |
// update main & sticky header
|
|
|
324 |
|
|
|
325 |
$table.children('tbody').children('tr:visible').toggleClass(highlightClass, c);
|
|
|
326 |
// update all at once
|
|
|
327 |
$table[0].ignoreChange = false;
|
|
|
328 |
$table.trigger('update', [resort]);
|
|
|
329 |
|
|
|
330 |
// handle header
|
| 7 |
- |
331 |
var rowCount = $('#' + tableName + ' tbody tr').length;
|
| 2 |
- |
332 |
var checkedCount = $('#' + tableName + ' tbody .checked').length;
|
|
|
333 |
var ua = window.navigator.userAgent;
|
|
|
334 |
if (checkedCount === 0) {
|
|
|
335 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', false);
|
|
|
336 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);
|
|
|
337 |
} else if (checkedCount === rowCount) {
|
|
|
338 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', true);
|
|
|
339 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);
|
|
|
340 |
} else {
|
|
|
341 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
|
|
|
342 |
$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', true);
|
|
|
343 |
}
|
|
|
344 |
$('#selected-rows').html(checkedCount);
|
|
|
345 |
})
|
|
|
346 |
.on('mouseup', function() {
|
|
|
347 |
return false;
|
|
|
348 |
});
|
|
|
349 |
|
|
|
350 |
});
|
|
|
351 |
|
|
|
352 |
$("#" + tableName).tablesorter({
|
|
|
353 |
theme: "blue",
|
|
|
354 |
widgets: ["zebra", "stickyHeaders", "filter"],
|
|
|
355 |
headers: {
|
|
|
356 |
0: {
|
|
|
357 |
sorter: "checkbox"
|
|
|
358 |
},
|
|
|
359 |
1: {
|
|
|
360 |
sorter: false,
|
|
|
361 |
filter: false
|
|
|
362 |
}
|
|
|
363 |
},
|
|
|
364 |
initialized: function() {
|
|
|
365 |
fillListings();
|
|
|
366 |
}
|
|
|
367 |
});
|
|
|
368 |
|
|
|
369 |
$("#" + tableName).bind('filterInit filterEnd', function(event, data) {
|
|
|
370 |
$('#filtered-rows').html(data.filteredRows);
|
|
|
371 |
$('#total-rows').html(data.totalRows);
|
|
|
372 |
});
|
|
|
373 |
});
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
function addNote(itemId) {
|
|
|
377 |
var i;
|
|
|
378 |
var xml;
|
|
|
379 |
|
|
|
380 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
381 |
var xhr = new XMLHttpRequest();
|
|
|
382 |
|
|
|
383 |
if (!createAddXMLNote(xw, xhr, 'SetUserNotes', itemId)) {
|
|
|
384 |
return;
|
|
|
385 |
}
|
|
|
386 |
|
|
|
387 |
xml = xw.flush();
|
|
|
388 |
xw.close();
|
|
|
389 |
|
|
|
390 |
xhr.onload = function() {
|
| 12 |
- |
391 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
392 |
var obj = jsonObj.SetUserNotesResponse;
|
| 2 |
- |
393 |
var returnCode = obj.Ack;
|
|
|
394 |
|
|
|
395 |
var x = document.getElementById("results");
|
|
|
396 |
|
|
|
397 |
if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917108')) {
|
|
|
398 |
if (returnCode == 'Warning') {
|
|
|
399 |
x.innerHTML += '<p>' + obj.CorrelationID + ': <strong>' + returnCode + '</strong></p>';
|
|
|
400 |
x.innerHTML += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
|
|
|
401 |
}
|
|
|
402 |
} else {
|
|
|
403 |
x.className += " process-errors";
|
|
|
404 |
x.innerHTML += '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
|
| 6 |
- |
405 |
var errors = getJsonArray(obj.Errors);
|
| 2 |
- |
406 |
x.innerHTML += "<p>";
|
| 6 |
- |
407 |
for (i = 0; i < errors.length; i++) {
|
|
|
408 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
| 2 |
- |
409 |
}
|
|
|
410 |
x.innerHTML += "</p>";
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
if (obj.Message) {
|
|
|
414 |
x.innerHTML += obj.Message;
|
|
|
415 |
}
|
|
|
416 |
|
|
|
417 |
--listingsToRelist;
|
|
|
418 |
++listingsRelisted;
|
|
|
419 |
updateProgressBar(maxListingsToRelist, listingsRelisted);
|
|
|
420 |
};
|
|
|
421 |
|
|
|
422 |
xhr.send(xml);
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
function createAddXMLNote(xw, xhr, callname, itemId) {
|
|
|
426 |
var today = new Date();
|
|
|
427 |
var todayYYYYMMDD = today.toISOString().slice(0, 10);
|
|
|
428 |
|
|
|
429 |
xw.writeStartDocument();
|
|
|
430 |
xw.writeStartElement(callname + "Request");
|
|
|
431 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
432 |
|
|
|
433 |
xw.writeStartElement('RequesterCredentials');
|
|
|
434 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
435 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
436 |
|
|
|
437 |
xw.writeElementString('ItemID', itemId);
|
|
|
438 |
xw.writeElementString('MessageID', itemId);
|
|
|
439 |
xw.writeElementString('Action', 'AddOrUpdate');
|
|
|
440 |
xw.writeElementString('NoteText', 'Relisted As New Item on ' + todayYYYYMMDD);
|
|
|
441 |
|
|
|
442 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
443 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
444 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
445 |
|
|
|
446 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
447 |
xw.writeEndDocument();
|
|
|
448 |
|
|
|
449 |
xhr.open('POST', configProxyUrl, true);
|
|
|
450 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
451 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
452 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
453 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
454 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
455 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
456 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
457 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
458 |
|
|
|
459 |
return true;
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
function eBaySearch(pageNo) {
|
|
|
463 |
var i;
|
|
|
464 |
var xml;
|
|
|
465 |
|
|
|
466 |
if (eBayAuthTokenFlag === false) {
|
|
|
467 |
return;
|
|
|
468 |
}
|
|
|
469 |
|
|
|
470 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
471 |
var xhr = new XMLHttpRequest();
|
|
|
472 |
|
|
|
473 |
if (!createAddXMLSearch(xw, xhr, 'GetMyeBaySelling', pageNo)) {
|
|
|
474 |
return;
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
xml = xw.flush();
|
|
|
478 |
xw.close();
|
|
|
479 |
|
|
|
480 |
xhr.onload = function() {
|
| 12 |
- |
481 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
482 |
var obj = jsonObj.GetMyeBaySellingResponse;
|
| 2 |
- |
483 |
var returnCode = obj.Ack;
|
|
|
484 |
|
|
|
485 |
var x = document.getElementById("results");
|
|
|
486 |
|
|
|
487 |
if (returnCode == 'Success') {
|
| 12 |
- |
488 |
tableEntry(obj.UnsoldList.ItemArray.Item);
|
| 2 |
- |
489 |
|
|
|
490 |
if (Number(obj.UnsoldList.PaginationResult.TotalNumberOfPages) > pageNo) {
|
|
|
491 |
maxPagesToProcess = Number(obj.UnsoldList.PaginationResult.TotalNumberOfPages);
|
|
|
492 |
++pagesToProcess;
|
|
|
493 |
eBaySearch(pageNo + 1);
|
|
|
494 |
}
|
|
|
495 |
|
|
|
496 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
497 |
} else {
|
|
|
498 |
x.className += " process-errors";
|
|
|
499 |
x.innerHTML += '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
|
| 6 |
- |
500 |
var errors = getJsonArray(obj.Errors);
|
| 2 |
- |
501 |
x.innerHTML += "<p>";
|
| 6 |
- |
502 |
for (i = 0; i < errors.length; i++) {
|
|
|
503 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
| 2 |
- |
504 |
}
|
|
|
505 |
x.innerHTML += "</p>";
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
--pagesToProcess;
|
|
|
509 |
++pagesProcessed;
|
|
|
510 |
|
|
|
511 |
updateProgressBar(maxPagesToProcess, pagesProcessed);
|
|
|
512 |
};
|
|
|
513 |
|
|
|
514 |
xhr.send(xml);
|
|
|
515 |
}
|
|
|
516 |
|
|
|
517 |
function createAddXMLSearch(xw, xhr, callname, pageNo) {
|
|
|
518 |
|
|
|
519 |
xw.writeStartDocument();
|
|
|
520 |
xw.writeStartElement(callname + "Request");
|
|
|
521 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
522 |
|
|
|
523 |
xw.writeStartElement('RequesterCredentials');
|
|
|
524 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
525 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
526 |
|
|
|
527 |
xw.writeElementString('DetailLevel', 'ReturnAll');
|
|
|
528 |
xw.writeStartElement('ActiveList');
|
|
|
529 |
xw.writeElementString('Include', 'false');
|
|
|
530 |
xw.writeEndElement(); /* ActiveList */
|
|
|
531 |
xw.writeStartElement('DeletedFromSoldList');
|
|
|
532 |
xw.writeElementString('Include', 'false');
|
|
|
533 |
xw.writeEndElement(); /* DeletedFromSoldList */
|
|
|
534 |
xw.writeStartElement('DeletedFromUnsoldList');
|
|
|
535 |
xw.writeElementString('Include', 'false');
|
|
|
536 |
xw.writeEndElement(); /* DeletedFromUnsoldList */
|
|
|
537 |
xw.writeStartElement('ScheduledList');
|
|
|
538 |
xw.writeElementString('Include', 'false');
|
|
|
539 |
xw.writeEndElement(); /* ScheduledList */
|
|
|
540 |
xw.writeStartElement('SellingSummary');
|
|
|
541 |
xw.writeElementString('Include', 'false');
|
|
|
542 |
xw.writeEndElement(); /* SellingSummary */
|
|
|
543 |
xw.writeStartElement('SoldList');
|
|
|
544 |
xw.writeElementString('Include', 'false');
|
|
|
545 |
xw.writeEndElement(); /* SoldList */
|
|
|
546 |
|
|
|
547 |
xw.writeStartElement('UnsoldList');
|
|
|
548 |
xw.writeElementString('Include', 'true');
|
|
|
549 |
xw.writeElementString('IncludeNotes', 'true');
|
|
|
550 |
xw.writeStartElement('Pagination');
|
|
|
551 |
xw.writeElementString('EntriesPerPage', '200');
|
|
|
552 |
xw.writeElementString('PageNumber', '' + pageNo);
|
|
|
553 |
xw.writeEndElement(); /* Pagination*/
|
|
|
554 |
xw.writeEndElement(); /* UnsoldList> */
|
|
|
555 |
xw.writeElementString('OutputSelector', 'BuyItNowPrice');
|
|
|
556 |
xw.writeElementString('OutputSelector', 'eBayNotes');
|
|
|
557 |
xw.writeElementString('OutputSelector', 'ItemID');
|
|
|
558 |
xw.writeElementString('OutputSelector', 'EndTime');
|
|
|
559 |
xw.writeElementString('OutputSelector', 'ListingType');
|
|
|
560 |
xw.writeElementString('OutputSelector', 'PrivateNotes');
|
|
|
561 |
xw.writeElementString('OutputSelector', 'QuantityAvailable');
|
|
|
562 |
xw.writeElementString('OutputSelector', 'PictureDetails');
|
|
|
563 |
xw.writeElementString('OutputSelector', 'Relisted');
|
|
|
564 |
xw.writeElementString('OutputSelector', 'SKU');
|
|
|
565 |
xw.writeElementString('OutputSelector', 'Title');
|
|
|
566 |
xw.writeElementString('OutputSelector', 'StartPrice');
|
|
|
567 |
xw.writeElementString('OutputSelector', 'WatchCount');
|
|
|
568 |
xw.writeElementString('OutputSelector', 'PaginationResult');
|
|
|
569 |
|
|
|
570 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
571 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
572 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
573 |
|
|
|
574 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
575 |
xw.writeEndDocument();
|
|
|
576 |
|
|
|
577 |
xhr.open('POST', configProxyUrl, true);
|
|
|
578 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
579 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
580 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
581 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
582 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
583 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
584 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
585 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
586 |
|
|
|
587 |
return true;
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
function fillListings() {
|
|
|
591 |
var i;
|
|
|
592 |
var x = document.getElementById(tableName);
|
|
|
593 |
|
|
|
594 |
listingsToFill = 0;
|
|
|
595 |
maxListingsToFill = 0;
|
|
|
596 |
listingsFilled = 0;
|
|
|
597 |
|
|
|
598 |
initProgressBar('Fill Listing Information (2/2)');
|
|
|
599 |
|
|
|
600 |
for (i = 2; i < x.rows.length; i++) {
|
|
|
601 |
++listingsToFill;
|
|
|
602 |
++maxListingsToFill;
|
|
|
603 |
fillListing(x.rows[i].cells[3].innerHTML);
|
|
|
604 |
}
|
|
|
605 |
|
|
|
606 |
function checkListingsToFill() {
|
|
|
607 |
if (listingsToFill > 0) {
|
|
|
608 |
window.setTimeout(checkListingsToFill, 100); // wait 100 milliseconds
|
|
|
609 |
} else {
|
|
|
610 |
$("#" + tableName).trigger("update");
|
|
|
611 |
|
|
|
612 |
endProgressBar();
|
|
|
613 |
|
|
|
614 |
document.getElementById("createForm").className += " w3-hide";
|
|
|
615 |
document.getElementById("relistForm").className += " w3-show";
|
|
|
616 |
|
|
|
617 |
x = document.getElementById("results");
|
|
|
618 |
x.innerHTML += '<p><strong>Report Finished!</strong></p>';
|
|
|
619 |
if (!x.className.includes("process-errors")) {
|
|
|
620 |
setTimeout(function() {
|
|
|
621 |
x.className = x.className.replace(" w3-show", "");
|
|
|
622 |
}, 3000);
|
|
|
623 |
}
|
|
|
624 |
}
|
|
|
625 |
}
|
|
|
626 |
|
|
|
627 |
checkListingsToFill();
|
|
|
628 |
}
|
|
|
629 |
|
|
|
630 |
function fillListing(itemId) {
|
|
|
631 |
var i;
|
|
|
632 |
var xml;
|
|
|
633 |
|
|
|
634 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
635 |
var xhr = new XMLHttpRequest();
|
|
|
636 |
|
|
|
637 |
if (!createFillXMLSearch(xw, xhr, 'GetItem', itemId)) {
|
|
|
638 |
return;
|
|
|
639 |
}
|
|
|
640 |
|
|
|
641 |
xml = xw.flush();
|
|
|
642 |
xw.close();
|
|
|
643 |
|
|
|
644 |
xhr.onload = function() {
|
| 12 |
- |
645 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
646 |
var obj = jsonObj.GetItemResponse;
|
| 2 |
- |
647 |
var returnCode = obj.Ack;
|
|
|
648 |
|
|
|
649 |
var x = document.getElementById("results");
|
|
|
650 |
|
|
|
651 |
if (returnCode == 'Success') {
|
|
|
652 |
var itemId = getJsonValue(obj.Item.ItemID);
|
|
|
653 |
document.getElementById("Views" + itemId).innerHTML = getJsonValue(obj.Item.HitCount);
|
| 12 |
- |
654 |
document.getElementById("Category" + itemId).innerHTML = getJsonValue(obj.Item.PrimaryCategory.CategoryName);
|
| 2 |
- |
655 |
} else {
|
|
|
656 |
x.className += " process-errors";
|
|
|
657 |
x.innerHTML += '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
|
|
|
658 |
|
| 6 |
- |
659 |
var errors = getJsonArray(obj.Errors);
|
| 2 |
- |
660 |
x.innerHTML += "<p>";
|
| 6 |
- |
661 |
for (i = 0; i < errors.length; i++) {
|
|
|
662 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
| 2 |
- |
663 |
}
|
|
|
664 |
x.innerHTML += "</p>";
|
|
|
665 |
}
|
|
|
666 |
|
|
|
667 |
--listingsToFill;
|
|
|
668 |
++listingsFilled;
|
|
|
669 |
updateProgressBar(maxListingsToFill, listingsFilled);
|
|
|
670 |
};
|
|
|
671 |
|
|
|
672 |
xhr.send(xml);
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
function createFillXMLSearch(xw, xhr, callname, itemId) {
|
|
|
676 |
xw.writeStartDocument();
|
|
|
677 |
xw.writeStartElement(callname + "Request");
|
|
|
678 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
679 |
|
|
|
680 |
xw.writeStartElement('RequesterCredentials');
|
|
|
681 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
682 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
683 |
|
|
|
684 |
xw.writeElementString('ItemID', itemId);
|
|
|
685 |
xw.writeElementString('MessageID', itemId);
|
|
|
686 |
xw.writeElementString('OutputSelector', 'ItemID');
|
|
|
687 |
xw.writeElementString('OutputSelector', 'HitCount');
|
|
|
688 |
xw.writeElementString('OutputSelector', 'CategoryName');
|
|
|
689 |
|
|
|
690 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
691 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
692 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
693 |
|
|
|
694 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
695 |
xw.writeEndDocument();
|
|
|
696 |
|
|
|
697 |
xhr.open('POST', configProxyUrl, true);
|
|
|
698 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
699 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
700 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
701 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
702 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
703 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
704 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
705 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
706 |
|
|
|
707 |
return true;
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
function putListings() {
|
|
|
711 |
var table = document.getElementById(tableName);
|
|
|
712 |
|
|
|
713 |
listingsToRelist = 0;
|
|
|
714 |
maxListingsToRelist = 0;
|
|
|
715 |
listingsRelisted = 0;
|
|
|
716 |
|
|
|
717 |
initProgressBar("Relist selected Items");
|
|
|
718 |
|
|
|
719 |
var x = document.getElementById("results");
|
|
|
720 |
x.innerHTML = '';
|
|
|
721 |
x.className = x.className.replace("process-errors", "");
|
|
|
722 |
if (x.className.indexOf("w3-show") == -1) {
|
|
|
723 |
x.className += " w3-show";
|
|
|
724 |
}
|
|
|
725 |
|
|
|
726 |
for (var i = 2; i < table.rows.length; i++) {
|
|
|
727 |
if (table.rows[i].cells[0].children[0].checked) {
|
|
|
728 |
++listingsToRelist;
|
|
|
729 |
++maxListingsToRelist;
|
|
|
730 |
|
|
|
731 |
if (Number(table.rows[i].cells[10].innerHTML) > 0 || table.rows[i].cells[12].innerHTML.startsWith("Exported to ")) { // watchers or previously exported
|
| 10 |
- |
732 |
relistItem(table.rows[i].cells[3].innerHTML, (table.rows[i].cells[6].innerHTML == 'Auction'));
|
| 2 |
- |
733 |
} else {
|
|
|
734 |
handleAddItem(table.rows[i].cells[3].innerHTML);
|
|
|
735 |
}
|
|
|
736 |
|
|
|
737 |
table.deleteRow(i--);
|
|
|
738 |
}
|
|
|
739 |
}
|
|
|
740 |
|
|
|
741 |
function checkListingsToRelist() {
|
|
|
742 |
if (listingsToRelist > 0) {
|
|
|
743 |
window.setTimeout(checkListingsToRelist, 100); // wait 100 milliseconds
|
|
|
744 |
} else {
|
| 7 |
- |
745 |
tableSorterUpdateCounters(tableName);
|
| 2 |
- |
746 |
endProgressBar();
|
|
|
747 |
|
|
|
748 |
x = document.getElementById("results");
|
|
|
749 |
x.innerHTML += '<p><strong>Relist Finished!</strong></p>';
|
|
|
750 |
if (!x.className.includes("process-errors")) {
|
|
|
751 |
setTimeout(function() {
|
|
|
752 |
x.className = x.className.replace(" w3-show", "");
|
|
|
753 |
}, 3000);
|
|
|
754 |
}
|
|
|
755 |
}
|
|
|
756 |
}
|
|
|
757 |
|
|
|
758 |
checkListingsToRelist();
|
|
|
759 |
}
|
|
|
760 |
|
|
|
761 |
function relistItem(itemId, auctionFlag) {
|
|
|
762 |
var i;
|
|
|
763 |
var xml;
|
|
|
764 |
|
|
|
765 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
766 |
var xhr = new XMLHttpRequest();
|
|
|
767 |
|
| 12 |
- |
768 |
if (!createRelistXML(xw, xhr, (auctionFlag ? "RelistItem" : "RelistFixedPriceItem"), itemId)) {
|
| 2 |
- |
769 |
return;
|
|
|
770 |
}
|
|
|
771 |
|
|
|
772 |
xml = xw.flush();
|
|
|
773 |
xw.close();
|
|
|
774 |
|
|
|
775 |
xhr.onload = function() {
|
| 12 |
- |
776 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
777 |
var obj = (auctionFlag ? jsonObj.RelistItemResponse : jsonObj.RelistFixedPriceItemResponse);
|
| 2 |
- |
778 |
var returnCode = obj.Ack;
|
|
|
779 |
|
|
|
780 |
var x = document.getElementById("results");
|
|
|
781 |
|
|
|
782 |
if (returnCode != 'Success') {
|
|
|
783 |
x.className += " process-errors";
|
|
|
784 |
x.innerHTML += '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
|
| 6 |
- |
785 |
var errors = getJsonArray(obj.Errors);
|
| 2 |
- |
786 |
x.innerHTML += "<p>";
|
| 6 |
- |
787 |
for (i = 0; i < errors.length; i++) {
|
|
|
788 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
| 2 |
- |
789 |
}
|
|
|
790 |
x.innerHTML += "</p>";
|
|
|
791 |
}
|
|
|
792 |
|
|
|
793 |
--listingsToRelist;
|
|
|
794 |
++listingsRelisted;
|
|
|
795 |
updateProgressBar(maxListingsToRelist, listingsRelisted);
|
|
|
796 |
};
|
|
|
797 |
|
|
|
798 |
xhr.send(xml);
|
|
|
799 |
}
|
|
|
800 |
|
|
|
801 |
function createRelistXML(xw, xhr, callname, itemId) {
|
|
|
802 |
xw.writeStartDocument();
|
|
|
803 |
xw.writeStartElement(callname + "Request");
|
|
|
804 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
805 |
|
|
|
806 |
xw.writeStartElement('RequesterCredentials');
|
|
|
807 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
808 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
809 |
|
|
|
810 |
xw.writeStartElement('Item');
|
|
|
811 |
xw.writeElementString('ItemID', itemId);
|
|
|
812 |
xw.writeEndElement(); /* Item */
|
|
|
813 |
|
|
|
814 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
815 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
816 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
817 |
xw.writeElementString('MessageID', itemId);
|
|
|
818 |
|
|
|
819 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
820 |
xw.writeEndDocument();
|
|
|
821 |
|
|
|
822 |
xhr.open('POST', configProxyUrl, true);
|
|
|
823 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
824 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
825 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
826 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
827 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
828 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
829 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
830 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
831 |
|
|
|
832 |
return true;
|
|
|
833 |
}
|
|
|
834 |
|
|
|
835 |
function handleAddItem(itemId) {
|
|
|
836 |
var i;
|
|
|
837 |
var xml;
|
|
|
838 |
|
|
|
839 |
var xw = new XMLWriter('UTF-8', '1.0');
|
|
|
840 |
var xhr = new XMLHttpRequest();
|
|
|
841 |
|
|
|
842 |
if (!createGetItemAllXML(xw, xhr, "GetItem", itemId)) {
|
|
|
843 |
return;
|
|
|
844 |
}
|
|
|
845 |
|
|
|
846 |
xml = xw.flush();
|
|
|
847 |
xw.close();
|
|
|
848 |
|
|
|
849 |
xhr.onload = function() {
|
| 12 |
- |
850 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
851 |
var obj = jsonObj.GetItemResponse;
|
| 2 |
- |
852 |
var returnCode = obj.Ack;
|
|
|
853 |
|
|
|
854 |
var x = document.getElementById("results");
|
|
|
855 |
|
|
|
856 |
if (returnCode == 'Success') {
|
|
|
857 |
var st = xhr.responseText.indexOf('<Item>') + 6;
|
|
|
858 |
var len = xhr.responseText.indexOf('</Item>') - st;
|
| 12 |
- |
859 |
addItem(itemId, obj.Item, xhr.responseText.substr(st, len));
|
| 2 |
- |
860 |
} else {
|
|
|
861 |
x.className += " process-errors";
|
|
|
862 |
x.innerHTML += '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
|
|
|
863 |
|
| 6 |
- |
864 |
var errors = getJsonArray(obj.Errors);
|
| 2 |
- |
865 |
x.innerHTML += "<p>";
|
| 6 |
- |
866 |
for (i = 0; i < errors.length; i++) {
|
|
|
867 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
| 2 |
- |
868 |
}
|
|
|
869 |
x.innerHTML += "</p>";
|
|
|
870 |
|
|
|
871 |
--listingsToRelist;
|
|
|
872 |
++listingsRelisted;
|
|
|
873 |
updateProgressBar(maxListingsToRelist, listingsRelisted);
|
|
|
874 |
}
|
|
|
875 |
};
|
|
|
876 |
|
|
|
877 |
xhr.send(xml);
|
|
|
878 |
}
|
|
|
879 |
|
|
|
880 |
function createGetItemAllXML(xw, xhr, callname, itemId) {
|
|
|
881 |
xw.writeStartDocument();
|
|
|
882 |
xw.writeStartElement(callname + "Request");
|
|
|
883 |
xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
|
|
|
884 |
|
|
|
885 |
xw.writeStartElement('RequesterCredentials');
|
|
|
886 |
xw.writeElementString('eBayAuthToken', eBayAuthToken);
|
|
|
887 |
xw.writeEndElement(); /* RequesterCredentials */
|
|
|
888 |
|
|
|
889 |
xw.writeElementString('ItemID', itemId);
|
|
|
890 |
xw.writeElementString('MessageID', itemId);
|
|
|
891 |
xw.writeElementString('DetailLevel', 'ReturnAll');
|
|
|
892 |
xw.writeElementString('IncludeItemSpecifics', 'true');
|
|
|
893 |
xw.writeElementString('IncludeTaxTable', 'true');
|
|
|
894 |
xw.writeElementString('OutputSelector', 'AutoPay');
|
|
|
895 |
xw.writeElementString('OutputSelector', 'BuyItNowPrice');
|
|
|
896 |
xw.writeElementString('OutputSelector', 'BuyerResponsibleForShipping');
|
|
|
897 |
xw.writeElementString('OutputSelector', 'ConditionDescription');
|
|
|
898 |
xw.writeElementString('OutputSelector', 'ConditionDisplayName');
|
|
|
899 |
xw.writeElementString('OutputSelector', 'ConditionID');
|
|
|
900 |
xw.writeElementString('OutputSelector', 'Country');
|
|
|
901 |
xw.writeElementString('OutputSelector', 'Currency');
|
|
|
902 |
xw.writeElementString('OutputSelector', 'Description');
|
|
|
903 |
xw.writeElementString('OutputSelector', 'DispatchTimeMax');
|
|
|
904 |
xw.writeElementString('OutputSelector', 'HitCounter');
|
|
|
905 |
xw.writeElementString('OutputSelector', 'ItemSpecifics');
|
|
|
906 |
xw.writeElementString('OutputSelector', 'ListingDetails');
|
|
|
907 |
xw.writeElementString('OutputSelector', 'ListingDuration');
|
|
|
908 |
xw.writeElementString('OutputSelector', 'ListingType');
|
|
|
909 |
xw.writeElementString('OutputSelector', 'Location');
|
|
|
910 |
xw.writeElementString('OutputSelector', 'PayPalEmailAddress');
|
|
|
911 |
xw.writeElementString('OutputSelector', 'PaymentMethods');
|
|
|
912 |
xw.writeElementString('OutputSelector', 'PictureDetails');
|
|
|
913 |
xw.writeElementString('OutputSelector', 'PostalCode');
|
|
|
914 |
xw.writeElementString('OutputSelector', 'PrimaryCategory');
|
|
|
915 |
xw.writeElementString('OutputSelector', 'ProductListingDetails');
|
| 12 |
- |
916 |
xw.writeElementString('OutputSelector', 'Item.Quantity');
|
|
|
917 |
xw.writeElementString('OutputSelector', 'Item.SellingStatus.QuantitySold');
|
| 2 |
- |
918 |
xw.writeElementString('OutputSelector', 'ReservePrice');
|
|
|
919 |
xw.writeElementString('OutputSelector', 'ReturnPolicy');
|
|
|
920 |
xw.writeElementString('OutputSelector', 'SellerProfiles');
|
|
|
921 |
xw.writeElementString('OutputSelector', 'SKU');
|
|
|
922 |
xw.writeElementString('OutputSelector', 'ShippingDetails');
|
|
|
923 |
xw.writeElementString('OutputSelector', 'ShippingPackageDetails');
|
|
|
924 |
xw.writeElementString('OutputSelector', 'Site');
|
|
|
925 |
xw.writeElementString('OutputSelector', 'StartPrice');
|
|
|
926 |
xw.writeElementString('OutputSelector', 'Storefront');
|
|
|
927 |
xw.writeElementString('OutputSelector', 'Title');
|
|
|
928 |
xw.writeElementString('OutputSelector', 'UseTaxTable');
|
|
|
929 |
xw.writeElementString('ErrorLanguage', 'en_US');
|
|
|
930 |
xw.writeElementString('Version', configeBayTradingVersion);
|
|
|
931 |
xw.writeElementString('WarningLevel', configWarningLevel);
|
|
|
932 |
|
|
|
933 |
xw.writeEndElement(); /* xmlrequest */
|
|
|
934 |
xw.writeEndDocument();
|
|
|
935 |
|
|
|
936 |
xhr.open('POST', configProxyUrl, true);
|
|
|
937 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
938 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
939 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
940 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
941 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
942 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
943 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
944 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
945 |
|
|
|
946 |
return true;
|
|
|
947 |
}
|
|
|
948 |
|
| 12 |
- |
949 |
function addItem(itemId, item, itemXml) {
|
| 2 |
- |
950 |
var i;
|
|
|
951 |
|
|
|
952 |
var xhr = new XMLHttpRequest();
|
| 12 |
- |
953 |
var xml = createAddItemXML(xhr, item, "AddItem", itemId, itemXml);
|
| 2 |
- |
954 |
|
|
|
955 |
xhr.onload = function() {
|
| 12 |
- |
956 |
var jsonObj = XMLparse(xhr.responseXML, false);
|
|
|
957 |
var obj = jsonObj.AddItemResponse;
|
| 2 |
- |
958 |
var returnCode = obj.Ack;
|
|
|
959 |
var newItemId = obj.ItemID;
|
|
|
960 |
var correlationID = obj.CorrelationID;
|
|
|
961 |
|
|
|
962 |
var x = document.getElementById("results");
|
|
|
963 |
|
|
|
964 |
if (returnCode == 'Success' || returnCode == 'Warning') {
|
|
|
965 |
addNote(itemId);
|
|
|
966 |
correlationID = newItemId;
|
|
|
967 |
}
|
|
|
968 |
|
|
|
969 |
if (returnCode != 'Success') {
|
|
|
970 |
x.className += " process-errors";
|
|
|
971 |
x.innerHTML += '<p class="w3-red">' + correlationID + ': <strong>' + returnCode + ':</strong></p>';
|
| 6 |
- |
972 |
var errors = getJsonArray(obj.Errors);
|
| 2 |
- |
973 |
x.innerHTML += "<p>";
|
| 6 |
- |
974 |
for (i = 0; i < errors.length; i++) {
|
|
|
975 |
x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
|
| 2 |
- |
976 |
}
|
|
|
977 |
x.innerHTML += "</p>";
|
|
|
978 |
--listingsToRelist;
|
|
|
979 |
++listingsRelisted;
|
|
|
980 |
updateProgressBar(maxListingsToRelist, listingsRelisted);
|
|
|
981 |
}
|
|
|
982 |
};
|
|
|
983 |
|
|
|
984 |
xhr.send(xml);
|
|
|
985 |
|
|
|
986 |
}
|
|
|
987 |
|
| 12 |
- |
988 |
function createAddItemXML(xhr, item, callname, itemId, itemXml) {
|
|
|
989 |
var n1 = 0, n2 = 0;
|
|
|
990 |
var quantity = Number(getJsonValue(item.Quantity));
|
|
|
991 |
var quantitySold = Number(getJsonValue(item.SellingStatus.QuantitySold));
|
| 2 |
- |
992 |
|
| 12 |
- |
993 |
n1 = itemXml.indexOf('<Quantity>') + 10;
|
|
|
994 |
if (n1 > 0) {
|
|
|
995 |
n2 = itemXml.indexOf('</Quantity>')
|
|
|
996 |
str = itemXml.substr(0, n1) + (quantity - quantitySold) + itemXml.substr(n2);
|
|
|
997 |
itemXml = str;
|
|
|
998 |
}
|
|
|
999 |
|
|
|
1000 |
if (itemXml.contains('<SellingStatus>')) {
|
|
|
1001 |
n1 = itemXml.indexOf('<SellingStatus>');
|
|
|
1002 |
if (n1 > 0) {
|
|
|
1003 |
n2 = itemXml.indexOf('</SellingStatus>') + 16;
|
|
|
1004 |
str = itemXml.substr(0, n1) + itemXml.substr(n2);
|
|
|
1005 |
itemXml = str;
|
|
|
1006 |
}
|
|
|
1007 |
}
|
|
|
1008 |
|
| 2 |
- |
1009 |
if (itemXml.contains('<ShippingType>Flat</ShippingType>')) {
|
|
|
1010 |
n1 = itemXml.indexOf('<CalculatedShippingRate>');
|
|
|
1011 |
if (n1 > 0) {
|
|
|
1012 |
n2 = itemXml.indexOf('</CalculatedShippingRate>') + 25;
|
| 12 |
- |
1013 |
str = itemXml.substr(0, n1) + itemXml.substr(n2);
|
|
|
1014 |
itemXml = str;
|
| 2 |
- |
1015 |
}
|
|
|
1016 |
}
|
|
|
1017 |
|
|
|
1018 |
if (itemXml.contains('<ShippingPackage>None</ShippingPackage>')) {
|
|
|
1019 |
n1 = itemXml.indexOf('<ShippingPackageDetails>');
|
|
|
1020 |
if (n1 > 0) {
|
|
|
1021 |
n2 = itemXml.indexOf('</ShippingPackageDetails>') + 25;
|
| 12 |
- |
1022 |
str = itemXml.substr(0, n1) + itemXml.substr(n2);
|
|
|
1023 |
itemXml = str;
|
| 2 |
- |
1024 |
}
|
|
|
1025 |
}
|
|
|
1026 |
|
|
|
1027 |
var xml = '<?xml version="1.0" encoding="utf-8"?>';
|
|
|
1028 |
xml += '<' + callname + 'Request xmlns="urn:ebay:apis:eBLBaseComponents">';
|
|
|
1029 |
xml += '<RequesterCredentials><eBayAuthToken>' + eBayAuthToken + '</eBayAuthToken></RequesterCredentials>';
|
|
|
1030 |
xml += '<ErrorLanguage>en_US</ErrorLanguage>';
|
|
|
1031 |
xml += '<WarningLevel>' + configWarningLevel + '</WarningLevel>';
|
|
|
1032 |
xml += '<MessageID>' + itemId + '</MessageID>';
|
|
|
1033 |
xml += '<Item>';
|
|
|
1034 |
xml += itemXml;
|
|
|
1035 |
xml += '<UseTaxTable>true</UseTaxTable>';
|
|
|
1036 |
xml += '</Item>';
|
|
|
1037 |
xml += '</' + callname + 'Request>';
|
|
|
1038 |
|
|
|
1039 |
xhr.open('POST', configProxyUrl, true);
|
|
|
1040 |
xhr.setRequestHeader('Content-Type', 'text/xml');
|
|
|
1041 |
xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
|
|
|
1042 |
xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
|
|
|
1043 |
xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
|
|
|
1044 |
xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
|
|
|
1045 |
xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
|
|
|
1046 |
xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
|
|
|
1047 |
xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
|
|
|
1048 |
|
|
|
1049 |
return xml;
|
|
|
1050 |
}
|
|
|
1051 |
|
|
|
1052 |
</script>
|
|
|
1053 |
|
|
|
1054 |
</body>
|
| 6 |
- |
1055 |
</html>
|