Subversion Repositories munaweb

Rev

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