Subversion Repositories munaweb

Rev

Rev 17 | Rev 25 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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">
17 - 66
            <div w3-include-html="php/footer.php"></div>
2 - 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;
16 - 262
    var Quantity = Number(JsonObj.Quantity);
263
    var QuantitySold = Number(JsonObj.SellingStatus.QuantitySold);
2 - 264
    var SKU = JsonObj.SKU;
265
    var ProductListingDetails = JsonObj.ProductListingDetails;
266
    var weightInGrams = 0;
267
    var categoryName = PrimaryCategoryName;
268
 
269
    var Title = JsonObj.Title;
270
 
271
    if (Number(ConditionID) === 1000) {
272
        tags.push("Condition: Brand New");
273
    } else {
274
        tags.push("Condition: Preowned");
275
    }
276
 
277
    n = (SKU === undefined ? 0 : SKU.indexOf(" - "));
278
    if (n > 0) {
279
        barcode = SKU.substr(n + 3);
280
        barcode = barcode.substr(barcode.indexOf(" ") + 1);
281
        handle = 'B' + barcode;
282
        barcode = '\'' + barcode;
283
        SKU = SKU.substr(0, n);
284
    } else {
285
        if (categoryName.indexOf("Books") != -1 && ProductListingDetails && ProductListingDetails.ISBN && isNumeric(ProductListingDetails.ISBN)) {
286
            barcode = '\'' + ProductListingDetails.ISBN;
287
            handle = 'B' + ProductListingDetails.ISBN;
288
        } else if (ProductListingDetails && ProductListingDetails.UPC && isNumeric(ProductListingDetails.UPC)) {
289
            barcode = '\'' + ProductListingDetails.UPC;
290
            handle = 'B' + ProductListingDetails.UPC;
291
        } else if (ProductListingDetails && ProductListingDetails.ProductReferenceID && isNumeric(ProductListingDetails.ProductReferenceID)) {
292
            barcode = 'R' + ProductListingDetails.ProductReferenceID;
293
            handle = barcode;
294
        } else {
295
            barcode = 'H' + Title.hashCode();
296
            handle = barcode;
297
        }
298
    }
299
 
300
    userDescription = extractDescription(Description);
16 - 301
    if (ItemSpecifics && ItemSpecifics.NameValueList && PrimaryCategoryName.indexOf('DVD') < 0) {
302
        userDescription += '<table><tbody>';
303
        for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
304
            var itemSpecific = ItemSpecifics.NameValueList[i];
305
            if (itemSpecific.Name != 'All returns accepted' &&
306
                itemSpecific.Name != 'Item must be returned within' &&
307
                itemSpecific.Name != 'Refund will be given as' &&
308
                itemSpecific.Name != 'Return policy details' &&
309
                itemSpecific.Name != 'Restocking Fee' &&
310
                itemSpecific.Name != 'Return shipping will be paid by') {
311
                userDescription += '<tr><td style="padding: 0;">' + itemSpecific.Name + ':</td><td style="padding: 0;">' + itemSpecific.Value + '</td></tr>';
2 - 312
            }
313
        }
16 - 314
        userDescription += '</tbody></table>';
2 - 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"));
16 - 386
    html.push(tableCell((Quantity - QuantitySold)));
2 - 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() {
16 - 467
        var jsonObj = XMLparse(xhr.responseXML, false);
468
        var obj = jsonObj.SetUserNotesResponse;
2 - 469
        var returnCode = obj.Ack;
19 - 470
        var str;
2 - 471
 
472
        var x = document.getElementById("results");
473
        if (x.className.indexOf("w3-show") == -1) {
474
            x.className += " w3-show";
475
        }
476
 
477
        if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917108')) {
19 - 478
            str = '<p>' + itemId + ': <strong>' + returnCode + '</strong></p>';
2 - 479
 
480
            if (returnCode == 'Warning') {
19 - 481
                str += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
2 - 482
            }
19 - 483
 
484
            x.innerHTML += str;
2 - 485
        } else {
486
            x.className += " process-errors";
19 - 487
            str = '<p class="w3-red">' + itemId + ': <strong>' + returnCode + ':</strong></p>';
2 - 488
 
6 - 489
            var errors = getJsonArray(obj.Errors);
19 - 490
            str += "<p>";
6 - 491
            for (i = 0; i < errors.length; i++) {
19 - 492
                str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
2 - 493
            }
19 - 494
            str += "</p>";
495
 
496
            x.innerHTML += str;
2 - 497
        }
498
 
499
        if (obj.Message) {
500
            x.innerHTML += obj.Message;
501
        }
502
 
503
        --notesToAdd;
504
        ++notesAdded;
505
 
506
        updateProgressBar(maxNotesToAdd, notesAdded);
507
    };
508
 
509
    xhr.send(xml);
510
}
511
 
512
function createAddXMLNote(xw, xhr, xmlrequest, callname, itemId) {
513
    var today = new Date();
514
    var todayYYYYMMDD = today.toISOString().slice(0, 10);
515
 
516
    xw.writeStartDocument();
517
    xw.writeStartElement(xmlrequest);
518
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
519
 
520
    xw.writeStartElement('RequesterCredentials');
521
    xw.writeElementString('eBayAuthToken', eBayAuthToken);
522
    xw.writeEndElement(); /* RequesterCredentials */
523
 
524
    xw.writeElementString('ItemID', itemId);
525
    xw.writeElementString('Action', 'AddOrUpdate');
526
    xw.writeElementString('NoteText', 'Exported to Shopify on ' + todayYYYYMMDD);
527
 
528
    xw.writeElementString('ErrorLanguage', 'en_US');
529
    xw.writeElementString('Version', configeBayTradingVersion);
530
    xw.writeElementString('WarningLevel', configWarningLevel);
531
 
532
    xw.writeEndElement(); /* xmlrequest */
533
    xw.writeEndDocument();
534
 
535
    xhr.open('POST', configProxyUrl, true);
536
    xhr.setRequestHeader('Content-Type', 'text/xml');
537
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
538
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
539
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
540
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
541
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
542
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
543
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
544
 
545
    return true;
546
}
547
 
548
function eBaySearch(itemId) {
549
    var i;
550
    var xml;
551
 
552
    var xw = new XMLWriter('UTF-8', '1.0');
553
    var xhr = new XMLHttpRequest();
554
 
555
    if (!createAddXMLSearch(xw, xhr, 'GetItemRequest', 'GetItem', itemId)) {
556
        return;
557
    }
558
 
559
    xml = xw.flush();
560
    xw.close();
561
 
562
    xhr.onload = function() {
16 - 563
        var jsonObj = XMLparse(xhr.responseXML, false);
564
        var obj = jsonObj.GetItemResponse;
2 - 565
        var returnCode = obj.Ack;
19 - 566
        var str;
2 - 567
 
568
        var x = document.getElementById("results");
569
        if (x.className.indexOf("w3-show") == -1) {
570
            x.className += " w3-show";
571
        }
572
 
573
        if (returnCode == 'Success') {
574
            tableEntry(obj.Item);
575
        } else {
576
            x.className += " process-errors";
19 - 577
            str = '<p class="w3-red">' + itemId + ': <strong>' + returnCode + ':</strong></p>';
2 - 578
 
6 - 579
            var errors = getJsonArray(obj.Errors);
19 - 580
            str += "<p>";
6 - 581
            for (i = 0; i < errors.length; i++) {
19 - 582
                str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
2 - 583
            }
19 - 584
            str += "</p>";
6 - 585
 
19 - 586
            x.innerHTML += str;
2 - 587
        }
588
 
589
        --pagesToProcess;
590
        ++pagesProcessed;
591
 
592
        updateProgressBar(maxPagesToProcess, pagesProcessed);
593
    };
594
 
595
    xhr.send(xml);
596
}
597
 
598
function createAddXMLSearch(xw, xhr, xmlrequest, callname, itemId) {
599
 
600
    xw.writeStartDocument();
601
    xw.writeStartElement(xmlrequest);
602
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
603
 
604
    xw.writeStartElement('RequesterCredentials');
605
    xw.writeElementString('eBayAuthToken', eBayAuthToken);
606
    xw.writeEndElement(); /* RequesterCredentials */
607
 
608
    xw.writeElementString('ItemID', itemId);
609
    xw.writeElementString('IncludeItemSpecifics', 'true');
610
    xw.writeElementString('DetailLevel', 'ReturnAll');
611
 
612
    xw.writeElementString('ErrorLanguage', 'en_US');
613
    xw.writeElementString('Version', configeBayTradingVersion);
614
    xw.writeElementString('WarningLevel', configWarningLevel);
615
 
616
    xw.writeEndElement(); /* xmlrequest */
617
    xw.writeEndDocument();
618
 
619
    xhr.open('POST', configProxyUrl, true);
620
    xhr.setRequestHeader('Content-Type', 'text/xml');
621
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
622
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
623
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
624
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
625
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
626
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
627
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
628
 
629
    return true;
630
}
631
 
632
function getListings() {
633
    var x;
634
 
635
    if (eBayAuthTokenFlag === false) {
636
        return;
637
    }
638
 
639
    document.getElementById("logging").innerHTML = '';
640
 
641
    x = document.getElementById("results");
642
    if (x.className.indexOf("w3-show") == -1) {
643
        x.className += " w3-show";
644
    }
645
    x.className = x.className.replace("process-errors", "");
646
    x.innerHTML = '<p><strong>Retrieving Listings...</strong></p>';
647
 
648
    initProgressBar('Getting Items for Export (1/2)');
649
 
650
    liveListing = (getRadioValue('rptType') == 'liveList');
651
    tableSorterStart();
652
    maxPagesToProcess = 1;
653
    pagesToProcess = 1;
654
    pagesProcessed = 0;
655
    eBaySorterSearch(1);
656
 
657
    function checkpagesToProcess() {
658
        if (pagesToProcess > 0) {
659
            window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds
660
        } else {
661
            tableSorterEnd();
662
            endProgressBar();
663
            // fillSorterListings(); is now in tableSorterEnd()
664
        }
665
    }
666
 
667
    checkpagesToProcess();
668
}
669
 
670
function tableSorterStart() {
671
    document.getElementById("logging").innerHTML = '';
672
    html = [];
673
 
674
    html.push('<h3>Items for Export</h3>');
675
    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>');
676
    html.push('<div class="w3-responsive">');
677
    html.push('<table id="' + tableSorterName + '" class="tablesorter">');
678
    html.push('<thead>');
679
    html.push('<tr>');
680
 
6 - 681
    html.push(tableHeaderCheckbox());
2 - 682
    html.push(tableHeader('Image'));
683
    html.push(tableHeader('Title'));
684
    html.push(tableHeader('Item Id'));
685
    html.push(tableHeader('SKU'));
686
    html.push(tableHeader('Category'));
687
    html.push(tableHeader('Format'));
688
    html.push(tableHeader('Price'));
689
    html.push(tableHeader('Quantity'));
690
    html.push(tableHeader('Views'));
691
    html.push(tableHeader('Watchers'));
692
    html.push(tableHeader(liveListing ? 'Start Date' : 'End Date'));
693
    html.push(tableHeader('Note'));
694
 
695
    html.push('</tr>');
696
    html.push('</thead>');
697
    html.push('<tbody>');
698
}
699
 
700
function tableSorterEntry(JsonObj) {
701
    var i;
702
    var image;
703
    var title;
704
    var itemId;
705
    var sku;
706
    var format;
707
    var price;
708
    var quantity;
709
    var views;
710
    var watchers;
711
    var listingDate;
712
    var privateNote;
713
    var ebayNote;
714
    var relisted;
16 - 715
    var bidCount;
2 - 716
 
717
    for (i = 0; i < JsonObj.length; i++) {
16 - 718
        image = getJsonValue(JsonObj[i].PictureDetails.GalleryURL).replace('http:', 'https:');
2 - 719
        title = getJsonValue(JsonObj[i].Title);
720
        itemId = getJsonValue(JsonObj[i].ItemID);
721
        sku = getJsonValue(JsonObj[i].SKU);
722
        format = getJsonValue(JsonObj[i].ListingType);
16 - 723
        bidCount = (typeof(JsonObj[i].SellingStatus) === 'object' ? Number(getJsonValue(JsonObj[i].SellingStatus.BidCount)) : 0);
2 - 724
        if (format == 'Chinese') {
725
            format = 'Auction';
726
            price = getJsonValue(JsonObj[i].StartPrice.text);
727
        } else {
728
            format = 'Fixed Price';
729
            price = getJsonValue(JsonObj[i].BuyItNowPrice.text);
730
        }
731
        quantity = getJsonValue(JsonObj[i].QuantityAvailable);
732
        views = '';
16 - 733
        watchers = Number(getJsonValue(JsonObj[i].WatchCount));
734
        listingDate = getJsonValue((liveListing ? JsonObj[i].ListingDetails.StartTime : JsonObj[i].ListingDetails.EndTime)).substr(0, 10);
2 - 735
        privateNote = getJsonValue(JsonObj[i].PrivateNotes);
736
        ebayNote = getJsonValue(JsonObj[i].eBayNotes);
737
        relisted = getJsonValue(JsonObj[i].Relisted);
738
 
739
        if (!liveListing) {
740
            if (privateNote.startsWith("Exported to ") || relisted == 'true' || privateNote.startsWith("Sold via ") || privateNote.startsWith("Relisted As New Item")) {
741
                continue;
742
            }
16 - 743
        } else {
744
            if (bidCount > 0) {
745
                continue;
746
            }
2 - 747
        }
748
 
16 - 749
 
750
 
2 - 751
        html.push('<tr>');
752
 
753
        html.push(tableCellCheckbox());
754
        html.push(tableCell('<img class="w3-image" src="' + image + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">'));
755
        html.push(tableCell(title));
756
        html.push(tableCell(itemId));
757
        html.push(tableCell(sku));
758
        html.push(tableCellLabel('Category' + itemId));
759
        html.push(tableCell(format));
760
        html.push(tableCell('$' + price));
761
        html.push(tableCell(quantity));
762
        html.push(tableCellLabel('Views' + itemId));
763
        html.push(tableCell(watchers));
764
        html.push(tableCell(listingDate));
765
        html.push(tableCell(privateNote + ' ' + ebayNote));
766
 
767
        html.push('</tr>');
768
    }
769
}
770
 
771
function tableSorterEnd() {
772
    html.push('</tbody>');
773
    html.push('</table>');
774
    html.push('</div>');
775
 
776
    document.getElementById("logging").innerHTML = html.join('');
777
 
778
    $(function() {
779
        $("#" + tableSorterName).on('tablesorter-initialized', function() {
780
 
781
            // class name to add on tr when checkbox is checked
782
            var highlightClass = 'checked',
783
                // resort the table after the checkbox is modified?
784
                resort = true,
785
                $table = $(this),
786
                c = this.config,
787
                wo = c && c.widgetOptions,
788
                // include sticky header checkbox; if installed
789
                $sticky = c && wo.$sticky || '',
790
                doChecky = function(c, col) {
791
                    $table
792
                        .children('tbody')
793
                        .children('tr:visible')
794
                        .children('td:nth-child( ' + (parseInt(col, 10) + 1) + ' )')
795
                        .find('input[type=checkbox]')
796
                        .each(function() {
797
                            this.checked = c;
798
                            $(this).trigger('change');
799
                        });
800
                };
801
 
802
            $table
803
                .children('tbody')
804
                .on('change', 'input[type=checkbox]', function() {
805
                    // ignore change if updating all rows
806
                    if ($table[0].ignoreChange) {
807
                        return;
808
                    }
809
                    var $this = $(this);
810
                    $this.closest('tr').toggleClass(highlightClass, this.checked);
19 - 811
                    // resort will jump bqack to the top
812
                    // $this.trigger('updateCell', [$this.closest('td'), resort]);
2 - 813
 
814
                    // handle header
7 - 815
                    var rowCount = $('#' + tableSorterName + ' tbody tr').length;
2 - 816
                    var checkedCount = $('#' + tableSorterName + ' tbody .checked').length;
817
                    var ua = window.navigator.userAgent;
818
                    if (checkedCount === 0) {
819
                        $table.add($sticky).find('thead input[type=checkbox]').prop('checked', false);
820
                        $table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);
821
                    } else if (checkedCount === rowCount) {
822
                        $table.add($sticky).find('thead input[type=checkbox]').prop('checked', true);
823
                        $table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);
824
                    } else {
825
                        $table.add($sticky).find('thead input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
826
                        $table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', true);
827
                    }
828
                    $('#selected-rows').html(checkedCount);
829
                })
830
                .end()
831
                .add($sticky)
832
                .find('thead input[type=checkbox]')
833
                // Click on checkbox in table header to toggle all inputs
834
                .on('change', function() {
835
                    // prevent updateCell for every cell
836
                    $table[0].ignoreChange = true;
837
                    var c = this.checked,
838
                        col = $(this).closest('th').attr('data-column');
839
                    doChecky(c, col);
840
                    // update main & sticky header
841
 
842
                    $table.children('tbody').children('tr:visible').toggleClass(highlightClass, c);
843
                    // update all at once
844
                    $table[0].ignoreChange = false;
845
                    $table.trigger('update', [resort]);
846
 
847
                    // handle header
7 - 848
                    var rowCount = $('#' + tableSorterName + ' tbody tr').length;
2 - 849
                    var checkedCount = $('#' + tableSorterName + ' tbody .checked').length;
850
                    var ua = window.navigator.userAgent;
851
                    if (checkedCount === 0) {
852
                        $table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', false);
853
                        $table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);
854
                    } else if (checkedCount === rowCount) {
855
                        $table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', true);
856
                        $table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);
857
                    } else {
858
                        $table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));
859
                        $table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', true);
860
                    }
861
                    $('#selected-rows').html(checkedCount);
862
                })
863
                .on('mouseup', function() {
864
                    return false;
865
                });
866
 
867
        });
868
 
869
        $("#" + tableSorterName).tablesorter({
870
            theme: "blue",
871
            widgets: ["zebra", "stickyHeaders", "filter"],
872
            headers: {
873
                0: {
874
                    sorter: "checkbox"
875
                },
876
                1: {
877
                    sorter: false,
878
                    filter: false
879
                }
880
            },
881
            initialized: function() {
882
                fillSorterListings();
883
            }
884
        });
885
 
886
        $("#" + tableSorterName).bind('filterInit filterEnd', function(event, data) {
887
            $('#filtered-rows').html(data.filteredRows);
888
            $('#total-rows').html(data.totalRows);
889
        });
890
    });
891
}
892
 
893
function eBaySorterSearch(pageNo) {
894
    var i;
895
    var xml;
896
 
897
    var xw = new XMLWriter('UTF-8', '1.0');
898
    var xhr = new XMLHttpRequest();
899
 
900
    if (!createSorterAddXMLSearch(xw, xhr, 'GetMyeBaySelling', pageNo)) {
901
        return;
902
    }
903
 
904
    xml = xw.flush();
905
    xw.close();
906
 
907
    xhr.onload = function() {
16 - 908
        var jsonObj = XMLparse(xhr.responseXML, false);
909
        var obj = jsonObj.GetMyeBaySellingResponse;
2 - 910
        var returnCode = obj.Ack;
19 - 911
        var str;
2 - 912
 
913
        var objArray = (liveListing ? obj.ActiveList : obj.UnsoldList);
914
 
915
        var x = document.getElementById("results");
916
 
917
        if (returnCode == 'Success') {
16 - 918
            tableSorterEntry(objArray.ItemArray.Item);
2 - 919
 
920
            if (Number(objArray.PaginationResult.TotalNumberOfPages) > pageNo) {
921
                maxPagesToProcess = Number(objArray.PaginationResult.TotalNumberOfPages);
922
                ++pagesToProcess;
923
                eBaySorterSearch(pageNo + 1);
924
            }
925
 
926
            updateProgressBar(maxPagesToProcess, pagesProcessed);
927
        } else {
928
            x.className += " process-errors";
19 - 929
            str = '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';
6 - 930
            var errors = getJsonArray(obj.Errors);
19 - 931
            str += "<p>";
6 - 932
            for (i = 0; i < errors.length; i++) {
19 - 933
                str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
2 - 934
            }
19 - 935
            str += "</p>";
6 - 936
 
19 - 937
            x.innerHTML += str;
2 - 938
        }
939
 
940
        --pagesToProcess;
941
        ++pagesProcessed;
942
 
943
        updateProgressBar(maxPagesToProcess, pagesProcessed);
944
    };
945
 
946
    xhr.send(xml);
947
}
948
 
949
function createSorterAddXMLSearch(xw, xhr, callname, pageNo) {
14 - 950
    var outputSelector;
951
 
2 - 952
    xw.writeStartDocument();
953
    xw.writeStartElement(callname + "Request");
954
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
955
 
956
    xw.writeStartElement('RequesterCredentials');
957
    xw.writeElementString('eBayAuthToken', eBayAuthToken);
958
    xw.writeEndElement(); /* RequesterCredentials */
959
 
960
    xw.writeElementString('DetailLevel', 'ReturnAll');
961
    xw.writeStartElement('DeletedFromSoldList');
962
    xw.writeElementString('Include', 'false');
963
    xw.writeEndElement(); /* DeletedFromSoldList */
964
    xw.writeStartElement('DeletedFromUnsoldList');
965
    xw.writeElementString('Include', 'false');
966
    xw.writeEndElement(); /* DeletedFromUnsoldList */
967
    xw.writeStartElement('ScheduledList');
968
    xw.writeElementString('Include', 'false');
969
    xw.writeEndElement(); /* ScheduledList */
970
    xw.writeStartElement('SellingSummary');
971
    xw.writeElementString('Include', 'false');
972
    xw.writeEndElement(); /* SellingSummary */
973
    xw.writeStartElement('SoldList');
974
    xw.writeElementString('Include', 'false');
975
    xw.writeEndElement(); /* SoldList */
976
 
977
    xw.writeStartElement(liveListing ? 'UnsoldList' : 'ActiveList');
978
    xw.writeElementString('Include', 'false');
979
    xw.writeEndElement(); /* ActiveList */
980
 
981
    xw.writeStartElement(liveListing ? 'ActiveList' : 'UnsoldList');
982
    xw.writeElementString('Include', 'true');
983
    xw.writeElementString('IncludeNotes', 'true');
984
    xw.writeStartElement('Pagination');
985
    xw.writeElementString('EntriesPerPage', '200');
986
    xw.writeElementString('PageNumber', '' + pageNo);
987
    xw.writeEndElement(); /* Pagination*/
988
    xw.writeEndElement(); /* UnsoldList> */
989
 
14 - 990
    outputSelector = liveListing ? 'ActiveList.' : 'UnsoldList.';
991
 
16 - 992
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.SellingStatus.BidCount');
14 - 993
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.BuyItNowPrice');
994
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.eBayNotes');
995
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.ItemID');
16 - 996
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.ListingDetails.' + (liveListing ? 'StartTime' : 'EndTime'));
14 - 997
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.ListingType');
998
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.PrivateNotes');
999
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.QuantityAvailable');
1000
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.PictureDetails');
1001
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.Relisted');
1002
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.SKU');
1003
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.Title');
1004
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.StartPrice');
1005
    xw.writeElementString('OutputSelector', outputSelector + 'ItemArray.Item.WatchCount');
1006
    xw.writeElementString('OutputSelector', outputSelector + 'PaginationResult');
1007
 
2 - 1008
    xw.writeElementString('ErrorLanguage', 'en_US');
1009
    xw.writeElementString('Version', configeBayTradingVersion);
1010
    xw.writeElementString('WarningLevel', configWarningLevel);
1011
 
1012
    xw.writeEndElement(); /* xmlrequest */
1013
    xw.writeEndDocument();
1014
 
1015
    xhr.open('POST', configProxyUrl, true);
1016
    xhr.setRequestHeader('Content-Type', 'text/xml');
1017
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
1018
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
1019
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
1020
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
1021
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
1022
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
1023
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
1024
 
1025
    return true;
1026
}
1027
 
1028
function fillSorterListings() {
1029
    var i;
1030
    var x = document.getElementById(tableSorterName);
1031
    var fillList = [];
1032
    var maxItems = 20;
1033
 
1034
    listingsToFill = 0;
1035
    maxListingsToFill = 0;
1036
    listingsFilled = 0;
1037
 
1038
    initProgressBar('Filling Listing Information (2/2)');
1039
 
1040
    for (i = 2; i < x.rows.length; i++) {
1041
        fillList.push(x.rows[i].cells[3].innerHTML);
1042
    }
6 - 1043
 
16 - 1044
    for (i = 0; (i * maxItems) < fillList.length; i++) {
2 - 1045
        ++listingsToFill;
1046
        ++maxListingsToFill;
1047
        fillSorterListing(fillList.slice(i * maxItems, (i + 1) * maxItems));
1048
    }
1049
 
1050
    function checkListingsToFill() {
1051
        if (listingsToFill > 0) {
1052
            window.setTimeout(checkListingsToFill, 100); // wait 100 milliseconds
1053
        } else {
1054
            $("#" + tableSorterName).trigger("update");
1055
 
1056
            endProgressBar();
1057
 
1058
            x = document.getElementById("form1div");
1059
            x.className = x.className.replace(" w3-show", "");
1060
            x = document.getElementById("form2div");
1061
            x.className += " w3-show";
1062
 
1063
            x = document.getElementById("results");
1064
            x.innerHTML += '<p><strong>Report Finished!</strong></p>';
1065
            if (!x.className.includes("process-errors")) {
1066
                setTimeout(function() {
1067
                    x.className = x.className.replace(" w3-show", "");
1068
                }, 3000);
1069
            }
1070
        }
1071
    }
1072
 
1073
    checkListingsToFill();
1074
}
1075
 
1076
function fillSorterListing(itemIdList) {
1077
    var i;
1078
    var xml;
1079
 
1080
    var xw = new XMLWriter('UTF-8', '1.0');
1081
    var xhr = new XMLHttpRequest();
1082
 
1083
    if (!createSorterFillXMLSearch(xw, xhr, 'GetMultipleItems', itemIdList)) {
1084
        return;
1085
    }
1086
 
1087
    xml = xw.flush();
1088
    xw.close();
1089
 
1090
    xhr.onload = function() {
16 - 1091
        var jsonObj = XMLparse(xhr.responseXML, false);
1092
        var obj = jsonObj.GetMultipleItemsResponse;
2 - 1093
        var returnCode = obj.Ack;
19 - 1094
        var str;
2 - 1095
 
1096
        var x = document.getElementById("results");
1097
 
1098
        if (returnCode == 'Success') {
1099
            for (i = 0; i < obj.Item.length; i++) {
1100
                var itemId = getJsonValue(obj.Item[i].ItemID);
1101
                document.getElementById("Views" + itemId).innerHTML = getJsonValue(obj.Item[i].HitCount);
1102
                document.getElementById("Category" + itemId).innerHTML = getJsonValue(obj.Item[i].PrimaryCategoryName);
6 - 1103
            }
2 - 1104
        } else {
1105
            x.className += " process-errors";
19 - 1106
            str = '<p class="w3-red"><strong>' + returnCode + ':</strong></p>';
2 - 1107
 
6 - 1108
            var errors = getJsonArray(obj.Errors);
19 - 1109
            str += "<p>";
6 - 1110
            for (i = 0; i < errors.length; i++) {
19 - 1111
                str += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
2 - 1112
            }
1113
            x.innerHTML += "</p>";
19 - 1114
 
1115
            x.innerHTML += str;
2 - 1116
        }
1117
 
1118
        --listingsToFill;
1119
        ++listingsFilled;
1120
        updateProgressBar(maxListingsToFill, listingsFilled);
1121
    };
1122
 
1123
    xhr.send(xml);
1124
}
1125
 
1126
function createSorterFillXMLSearch(xw, xhr, callname, itemIdList) {
1127
    var i;
6 - 1128
 
2 - 1129
    xw.writeStartDocument();
1130
    xw.writeStartElement(callname + "Request");
1131
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
1132
 
1133
    for (i = 0; i < itemIdList.length; i++) {
1134
        xw.writeElementString('ItemID', itemIdList[i]);
1135
    }
1136
 
1137
    xw.writeElementString('ErrorLanguage', 'en_US');
1138
    xw.writeElementString('Version', configeBayShoppingVersion);
1139
    xw.writeElementString('WarningLevel', configWarningLevel);
1140
 
1141
    xw.writeEndElement(); /* xmlrequest */
1142
    xw.writeEndDocument();
1143
 
1144
    xhr.open('POST', configProxyUrl, true);
1145
    xhr.setRequestHeader('Content-Type', 'text/xml');
1146
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
1147
    xhr.setRequestHeader('X-EBAY-API-VERSION', configeBayShoppingVersion);
1148
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
1149
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
1150
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
1151
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
1152
    xhr.setRequestHeader('X-EBAY-API-REQUEST-ENCODING', 'XML');
1153
    xhr.setRequestHeader('X-Proxy-URL', configeBayShopping);
1154
 
1155
    return true;
1156
}
1157
 
1158
    </script>
17 - 1159
    <script>includeHTML();</script>
2 - 1160
 
1161
</body>
1162
</html>