Subversion Repositories munaweb

Rev

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