Rev 6 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<!DOCTYPE html><html lang="en"><head><title>Export eBay Listings to Shopify</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" href="favicon.ico" type="image/x-icon"><link rel="icon" href="favicon.ico" type="image/x-icon"><link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"><link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"><link rel="stylesheet" href="css/style.css"><link rel="stylesheet" href="css/tablesorter.theme.blue.css"><script src="js/XMLWriter.js"></script><script src="js/vkbeautify.js"></script><script src="js/lodash.min.js"></script><script src="js/XMLparse.js"></script><script src="js/muna-tools.js"></script><script src="js/jquery.js"></script><script src="js/jquery.tablesorter.min.js"></script><script src="js/jquery.tablesorter.widgets.js"></script><script src="js/jquery.parser-input-select.js"></script></head><body onload="return initConfig();"><div class="w3-main"><div class="w3-container w3-padding w3-margin w3-card-4"><div class="w3-container w3-gray" style="height:100px"><img class="w3-image" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" style="height:100px"><p id="connected" class="w3-xxlarge w3-right">Export eBay Listings to Shopify<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" /></p></div><div class="w3-row"><div><form id="searchForm" class="w3-container w3-light-grey w3-padding w3-small" onsubmit="return getListings();"><div id="form1div" class="w3-container w3-card-2 w3-cell w3-padding w3-hide"><p><input id="completedList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="completedList" checked><label for="completedList">Completed Listings</label></p><p><input id="liveList" class="w3-radio" type="radio" style="height:1em" name="rptType" value="liveList"><label for="liveList">Live Listings</label></p><input id="startButton" type="button" class="w3-btn w3-large w3-red w3-margin w3-round-large w3-ripple" onclick="getListings();" value="Start" /></div><div id="form2div" class="w3-container w3-card-2 w3-cell w3-padding w3-hide"><input id="downloadButton" type="button" class="w3-btn w3-large w3-black w3-margin w3-round-large w3-ripple" onclick="downloadListings()" value="Download CSV" /></div></form></div><div id="progressBarDiv" class="w3-container w3-padding w3-margin w3-card-4 w3-hide"><h2 id="progressBarHeader"></h2><div class="w3-light-grey"><div id="progressBar" class="w3-container w3-green w3-center" style="width:0%">0%</div></div></div><div id="results" class="w3-container w3-padding w3-card-4 w3-hide"></div><div id="csv" class="w3-container w3-padding w3-card-4 w3-hide"></div><div id="logging" class="w3-container w3-padding"></div></div></div><footer class="w3-container w3-center w3-border-top w3-margin">Copyright © 2018 MUNA Trading. All rights reserved.</footer></div><script>// Globalsvar tableName = 'exportTable';var tableSorterName = 'selectTable';var liveListing;var maxPagesToProcess = 0;var pagesToProcess = 0;var pagesProcessed = 0;var maxNotesToAdd = 0;var notesToAdd = 0;var notesAdded = 0;var html = [];// Initialize Configuration Variablesfunction initConfig() {var x = document.getElementById("form1div");if (x.className.indexOf("w3-show") == -1) {x.className += " w3-show";}eBayAuthToken = readCookie();if (eBayAuthToken.length > 0) {connected();}if (eBayAuthTokenFlag === false) {x = document.getElementById("login");if (x.className.indexOf("w3-show") == -1) {x.className += " w3-show";}}}function connected() {var x;eBayAuthTokenFlag = true;document.getElementById("connected").innerHTML += " (Connected)";x = document.getElementById("startButton");x.className = x.className.replace(" w3-red", " w3-black");x = document.getElementById("login");x.className = x.className.replace(" w3-show", "");x = document.getElementById("results");x.innerHTML = "";x.className = x.className.replace(" w3-show", "");x.className = x.className.replace(" process-errors", "");}function requireNewLogin() {var x = document.getElementById("startButton");x.className = x.className.replace(" w3-black", " w3-red ");}function downloadListings() {var noteList = [];var table = document.getElementById(tableSorterName);maxPagesToProcess = 0;pagesToProcess = 0;pagesProcessed = 0;initProgressBar("Downloading Selected Items");var x = document.getElementById("results");x.innerHTML = '';x.className = x.className.replace("process-errors", "");if (x.className.indexOf("w3-show") == -1) {x.className += " w3-show";}x.innerHTML = '<p><strong>Downloading Listings...</strong></p>';document.getElementById("csv").innerHTML = '';tableStart();for (var i = 2; i < table.rows.length; i++) {if (table.rows[i].cells[0].children[0].checked) {++maxPagesToProcess;++pagesToProcess;noteList.push(table.rows[i].cells[3].innerHTML);eBaySearch(table.rows[i].cells[3].innerHTML);table.deleteRow(i--);}}function checkpagesToProcess() {if (pagesToProcess > 0) {window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds} else {tableEnd();$("#" + tableSorterName).trigger("update");$('#selected-rows').html('0');$("#" + tableSorterName).find('thead input[type=checkbox]').prop('checked', false);$("#" + tableSorterName).find('thead input[type=checkbox]').prop('indeterminate', false);endProgressBar();exportTableToCSV(tableName, 'import.csv');addNotes(noteList);}}checkpagesToProcess();}function addNotes(noteList) {var i, x;maxNotesToAdd = 0;notesToAdd = 0;notesAdded = 0;if (!liveListing) {initProgressBar('Adding Notes to Ended Listings');for (i = 0; i < noteList.length; i++) {++maxNotesToAdd;++notesToAdd;addNote(noteList[i]);}}function checkNotesToAdd() {if (notesToAdd > 0) {window.setTimeout(checkNotesToAdd, 100); // wait 100 milliseconds} else {endProgressBar();x = document.getElementById("results");x.innerHTML += '<p><strong>Report Finished!</strong></p>';if (!x.className.includes("process-errors")) {setTimeout(function() {x.className = x.className.replace(" w3-show", "");}, 3000);}}}checkNotesToAdd();}function tableStart() {document.getElementById("csv").innerHTML = '';html = [];html.push('<h3>Shopify Import</h3>');html.push('<div class="w3-responsive">');html.push('<table id="' + tableName + '">');html.push('<thead>');html.push('<tr>');html.push(tableHeader('Handle'));html.push(tableHeader('Title'));html.push(tableHeader('Body (HTML)'));html.push(tableHeader('Vendor'));html.push(tableHeader('Type'));html.push(tableHeader('Tags'));html.push(tableHeader('Published'));html.push(tableHeader('Variant SKU'));html.push(tableHeader('Variant Inventory Tracker'));html.push(tableHeader('Variant Inventory Quantity'));html.push(tableHeader('Variant Inventory Policy'));html.push(tableHeader('Variant Fulfillment Service'));html.push(tableHeader('Variant Price'));html.push(tableHeader('Variant Requires Shipping'));html.push(tableHeader('Variant Taxable'));html.push(tableHeader('Variant Barcode'));html.push(tableHeader('Image Src'));html.push(tableHeader('Image Position'));html.push(tableHeader('Image Alt Text'));html.push(tableHeader('Variant Grams'));html.push(tableHeader('Variant Weight Unit'));html.push('</tr>');html.push('</thead>');html.push('<tbody>');}function tableEntry(JsonObj) {var i, n, barcode, handle;var tags = [];var ConditionDescription = JsonObj.ConditionDescription;var ConditionID = JsonObj.ConditionID;var CurrentPrice = JsonObj.SellingStatus.CurrentPrice;var CurrentPriceValue = CurrentPrice === undefined ? 0.00 : Number(CurrentPrice.text);var price = CurrentPriceValue;var Description = JsonObj.Description;var userDescription;var ItemID = JsonObj.ItemID;var ItemSpecifics = JsonObj.ItemSpecifics;var PictureURL = JsonObj.PictureDetails.PictureURL;var PrimaryCategoryName = JsonObj.PrimaryCategory.CategoryName;var Quantity = JsonObj.Quantity;var SKU = JsonObj.SKU;var ProductListingDetails = JsonObj.ProductListingDetails;var weightInGrams = 0;var categoryName = PrimaryCategoryName;var Title = JsonObj.Title;if (Number(ConditionID) === 1000) {tags.push("Condition: Brand New");} else {tags.push("Condition: Preowned");}n = (SKU === undefined ? 0 : SKU.indexOf(" - "));if (n > 0) {barcode = SKU.substr(n + 3);barcode = barcode.substr(barcode.indexOf(" ") + 1);handle = 'B' + barcode;barcode = '\'' + barcode;SKU = SKU.substr(0, n);} else {if (categoryName.indexOf("Books") != -1 && ProductListingDetails && ProductListingDetails.ISBN && isNumeric(ProductListingDetails.ISBN)) {barcode = '\'' + ProductListingDetails.ISBN;handle = 'B' + ProductListingDetails.ISBN;} else if (ProductListingDetails && ProductListingDetails.UPC && isNumeric(ProductListingDetails.UPC)) {barcode = '\'' + ProductListingDetails.UPC;handle = 'B' + ProductListingDetails.UPC;} else if (ProductListingDetails && ProductListingDetails.ProductReferenceID && isNumeric(ProductListingDetails.ProductReferenceID)) {barcode = 'R' + ProductListingDetails.ProductReferenceID;handle = barcode;} else {barcode = 'H' + Title.hashCode();handle = barcode;}}userDescription = extractDescription(Description);if (ItemSpecifics && PrimaryCategoryName.indexOf('DVD') < 0) {userDescription += '<p>';var first = true;for (i = 0; i < ItemSpecifics.length; i++) {if (ItemSpecifics[i].Name != 'All returns accepted' &&ItemSpecifics[i].Name != 'Item must be returned within' &&ItemSpecifics[i].Name != 'Refund will be given as' &&ItemSpecifics[i].Name != 'Return policy details' &&ItemSpecifics[i].Name != 'Restocking Fee' &&ItemSpecifics[i].Name != 'Return shipping will be paid by') {userDescription += (first ? '' : '<br/>') + ItemSpecifics[i].Name + ': ' + ItemSpecifics[i].Value;first = false;}}userDescription += '</p>';}if (ConditionDescription &&(userDescription.indexOf('Please view all actual images.') < 0 && userDescription.indexOf('mint condition') < 0)) {userDescription += '<p>' + ConditionDescription + '</p>';}if (categoryName.indexOf("CDs") != -1) {categoryName = 'Music CDs';price = 4.95;} else if (categoryName.indexOf("Movies") != -1) {categoryName = 'Movies';price = 4.95;} else if (categoryName.indexOf("Books") != -1) {categoryName = 'Books';price = 5.95;} else if (categoryName.indexOf("Trading Cards") != -1) {if (categoryName.indexOf("Baseball") != -1) {tags.push('Trading Cards: Baseball');} else if (categoryName.indexOf("Football") != -1) {tags.push('Trading Cards: Football');} else if (categoryName.indexOf("Basketball") != -1) {tags.push('Trading Cards: Basketball');} else if (categoryName.indexOf("Soccer") != -1) {tags.push('Trading Cards: Soccer');} else if (categoryName.indexOf("Ice Hockey") != -1) {tags.push('Trading Cards: Ice Hockey');} else if (categoryName.indexOf("Auto Racing") != -1) {tags.push('Trading Cards: Auto Racing');}categoryName = 'Trading Cards';price = 1.99;}tags.push(categoryName);if (liveListing) {tags.push('_eBay Live');price = round((CurrentPriceValue * 0.80), 1) + 0.05; // always end with 5if (categoryName.indexOf("CDs") != -1 && price < 4.95) {price = 4.95;} else if (categoryName.indexOf("Movies") != -1 && price < 4.95) {price = 4.95;} else if (categoryName.indexOf("Books") != -1 && price < 5.95) {price = 5.95;} else if (categoryName.indexOf("Trading Cards") != -1 && price < 1.99) {price = 1.99;}}if (JsonObj.ShippingPackageDetails !== undefined) {if (JsonObj.ShippingPackageDetails.WeightMajor !== undefined) {weightInGrams += (Number(JsonObj.ShippingPackageDetails.WeightMajor.text) * 453.5);}if (JsonObj.ShippingPackageDetails.WeightMinor !== undefined) {weightInGrams += (Number(JsonObj.ShippingPackageDetails.WeightMinor.text) * 28.3);}}html.push('<tr>');html.push(tableCell(handle));html.push(tableCell(Title));html.push(tableCell(escapeHtml(userDescription)));html.push(tableCell("MUNA Trading"));html.push(tableCell(categoryName));html.push(tableCell(tags.join(',')));html.push(tableCell("TRUE"));html.push(tableCell((SKU !== undefined ? SKU : "")));html.push(tableCell("shopify"));html.push(tableCell(Quantity));html.push(tableCell("deny"));html.push(tableCell("manual"));html.push(tableCell(price));html.push(tableCell("TRUE"));html.push(tableCell("TRUE"));html.push(tableCell(barcode));if (Array.isArray(PictureURL)) {html.push(tableCell(PictureURL[0].substr(0, PictureURL[0].lastIndexOf('/') + 1) + '$_57.JPG'));} else if (PictureURL !== undefined) {html.push(tableCell(PictureURL.substr(0, PictureURL.lastIndexOf('/') + 1) + '$_57.JPG'));} else {html.push(tableCell(''));}html.push(tableCell(1));html.push(tableCell(Title + " Image 1"));html.push(tableCellHidden(ItemID));html.push(tableCell(Math.floor(weightInGrams)));html.push(tableCell("oz"));html.push(tableCellHidden(ItemID));html.push('</tr>');if (Array.isArray(PictureURL)) {for (i = 1; i < PictureURL.length; i++) {html.push('<tr>');html.push(tableCell(handle));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCell(PictureURL[i].substr(0, PictureURL[i].lastIndexOf('/') + 1) + '$_57.JPG'));html.push(tableCell(i + 1));html.push(tableCell(Title + " Image " + (i + 1)));html.push(tableCell(""));html.push(tableCell(""));html.push(tableCellHidden(ItemID));html.push('</tr>');}}}function extractDescription(str) {var startText = "<!-- *************** Place description here ****************** -->";var startPos = str.indexOf(startText) + startText.length;var endPos = str.lastIndexOf("<!-- *************** Place description here ****************** -->");var userDescription = str.substr(startPos, endPos - startPos);var parser = new DOMParser();var htmlDoc = parser.parseFromString(userDescription, "text/html");return ((htmlDoc.getElementsByTagName('div')[0] !== undefined ? htmlDoc.getElementsByTagName('div')[0].innerHTML : userDescription));}function tableEnd() {html.push('</tbody>');html.push('</table>');html.push('</div>');document.getElementById("csv").innerHTML = html.join('');}function addNote(itemId) {var i;var xml;var xw = new XMLWriter('UTF-8', '1.0');var xhr = new XMLHttpRequest();if (!createAddXMLNote(xw, xhr, 'SetUserNotesRequest', 'SetUserNotes', itemId)) {return;}xml = xw.flush();xw.close();//window.alert(vkbeautify.xml(xml));xhr.onload = function() {var obj = XMLparse(xhr.responseXML);//window.alert(JSON.stringify(obj));//window.alert(vkbeautify.xml(xhr.responseText));var returnCode = obj.Ack;var x = document.getElementById("results");if (x.className.indexOf("w3-show") == -1) {x.className += " w3-show";}if (returnCode == 'Success' || (returnCode == 'Warning' && obj.Errors.ErrorCode == '21917108')) {x.innerHTML += '<p>' + itemId + ': <strong>' + returnCode + '</strong></p>';if (returnCode == 'Warning') {x.innerHTML += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";}} else {x.className += " process-errors";x.innerHTML += '<p class="w3-red">' + itemId + ': <strong>' + returnCode + ':</strong></p>';var errors = obj.Errors;x.innerHTML += "<p>";if (errors.length > 0) {for (i = 0; i < errors.length; i++) {x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";}} else {x.innerHTML += obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "<br/>";}x.innerHTML += "</p>";}if (obj.Message) {x.innerHTML += obj.Message;}--notesToAdd;++notesAdded;updateProgressBar(maxNotesToAdd, notesAdded);};xhr.send(xml);}function createAddXMLNote(xw, xhr, xmlrequest, callname, itemId) {var today = new Date();var todayYYYYMMDD = today.toISOString().slice(0, 10);xw.writeStartDocument();xw.writeStartElement(xmlrequest);xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');xw.writeStartElement('RequesterCredentials');xw.writeElementString('eBayAuthToken', eBayAuthToken);xw.writeEndElement(); /* RequesterCredentials */xw.writeElementString('ItemID', itemId);xw.writeElementString('Action', 'AddOrUpdate');xw.writeElementString('NoteText', 'Exported to Shopify on ' + todayYYYYMMDD);xw.writeElementString('ErrorLanguage', 'en_US');xw.writeElementString('Version', configeBayTradingVersion);xw.writeElementString('WarningLevel', configWarningLevel);xw.writeEndElement(); /* xmlrequest */xw.writeEndDocument();xhr.open('POST', configProxyUrl, true);xhr.setRequestHeader('Content-Type', 'text/xml');xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);xhr.setRequestHeader('X-EBAY-API-SITEID', '0');xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);return true;}function eBaySearch(itemId) {var i;var xml;var xw = new XMLWriter('UTF-8', '1.0');var xhr = new XMLHttpRequest();if (!createAddXMLSearch(xw, xhr, 'GetItemRequest', 'GetItem', itemId)) {return;}xml = xw.flush();xw.close();//window.alert(vkbeautify.xml(xml));xhr.onload = function() {var obj = XMLparse(xhr.responseXML);//window.alert(JSON.stringify(obj));//window.alert(vkbeautify.xml(xhr.responseText));var returnCode = obj.Ack;var x = document.getElementById("results");if (x.className.indexOf("w3-show") == -1) {x.className += " w3-show";}if (returnCode == 'Success') {tableEntry(obj.Item);} else {x.className += " process-errors";x.innerHTML += '<p class="w3-red">' + itemId + ': <strong>' + returnCode + ':</strong></p>';var errors = obj.Errors;x.innerHTML += "<p>";if (errors.length > 0) {for (i = 0; i < errors.length; i++) {x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";}} else {x.innerHTML += obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "<br/>";}x.innerHTML += "</p>";}--pagesToProcess;++pagesProcessed;updateProgressBar(maxPagesToProcess, pagesProcessed);};xhr.send(xml);}function createAddXMLSearch(xw, xhr, xmlrequest, callname, itemId) {xw.writeStartDocument();xw.writeStartElement(xmlrequest);xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');xw.writeStartElement('RequesterCredentials');xw.writeElementString('eBayAuthToken', eBayAuthToken);xw.writeEndElement(); /* RequesterCredentials */xw.writeElementString('ItemID', itemId);xw.writeElementString('IncludeItemSpecifics', 'true');xw.writeElementString('DetailLevel', 'ReturnAll');xw.writeElementString('ErrorLanguage', 'en_US');xw.writeElementString('Version', configeBayTradingVersion);xw.writeElementString('WarningLevel', configWarningLevel);xw.writeEndElement(); /* xmlrequest */xw.writeEndDocument();xhr.open('POST', configProxyUrl, true);xhr.setRequestHeader('Content-Type', 'text/xml');xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);xhr.setRequestHeader('X-EBAY-API-SITEID', '0');xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);return true;}function getListings() {var x;if (eBayAuthTokenFlag === false) {return;}document.getElementById("logging").innerHTML = '';x = document.getElementById("results");if (x.className.indexOf("w3-show") == -1) {x.className += " w3-show";}x.className = x.className.replace("process-errors", "");x.innerHTML = '<p><strong>Retrieving Listings...</strong></p>';initProgressBar('Getting Items for Export (1/2)');liveListing = (getRadioValue('rptType') == 'liveList');tableSorterStart();maxPagesToProcess = 1;pagesToProcess = 1;pagesProcessed = 0;eBaySorterSearch(1);function checkpagesToProcess() {if (pagesToProcess > 0) {window.setTimeout(checkpagesToProcess, 100); // wait 100 milliseconds} else {tableSorterEnd();endProgressBar();// fillSorterListings(); is now in tableSorterEnd()}}checkpagesToProcess();}function tableSorterStart() {document.getElementById("logging").innerHTML = '';html = [];html.push('<h3>Items for Export</h3>');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>');html.push('<div class="w3-responsive">');html.push('<table id="' + tableSorterName + '" class="tablesorter">');html.push('<thead>');html.push('<tr>');html.push(tableHeaderCheckbox(tableSorterName));html.push(tableHeader('Image'));html.push(tableHeader('Title'));html.push(tableHeader('Item Id'));html.push(tableHeader('SKU'));html.push(tableHeader('Category'));html.push(tableHeader('Format'));html.push(tableHeader('Price'));html.push(tableHeader('Quantity'));html.push(tableHeader('Views'));html.push(tableHeader('Watchers'));html.push(tableHeader(liveListing ? 'Start Date' : 'End Date'));html.push(tableHeader('Note'));html.push('</tr>');html.push('</thead>');html.push('<tbody>');}function tableSorterEntry(JsonObj) {var i;var image;var title;var itemId;var sku;var format;var price;var quantity;var views;var watchers;var listingDate;var privateNote;var ebayNote;var relisted;for (i = 0; i < JsonObj.length; i++) {image = getJsonValue(JsonObj[i].PictureDetails).replace('http:', 'https:');title = getJsonValue(JsonObj[i].Title);itemId = getJsonValue(JsonObj[i].ItemID);sku = getJsonValue(JsonObj[i].SKU);format = getJsonValue(JsonObj[i].ListingType);if (format == 'Chinese') {format = 'Auction';price = getJsonValue(JsonObj[i].StartPrice.text);} else {format = 'Fixed Price';price = getJsonValue(JsonObj[i].BuyItNowPrice.text);}quantity = getJsonValue(JsonObj[i].QuantityAvailable);views = '';watchers = getJsonValue(JsonObj[i].WatchCount);watchers = (watchers.length === 0 ? "0" : watchers);listingDate = getJsonValue(JsonObj[i].ListingDetails).substr(0, 10);privateNote = getJsonValue(JsonObj[i].PrivateNotes);ebayNote = getJsonValue(JsonObj[i].eBayNotes);relisted = getJsonValue(JsonObj[i].Relisted);if (!liveListing) {if (privateNote.startsWith("Exported to ") || relisted == 'true' || privateNote.startsWith("Sold via ") || privateNote.startsWith("Relisted As New Item")) {continue;}}html.push('<tr>');html.push(tableCellCheckbox());html.push(tableCell('<img class="w3-image" src="' + image + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">'));html.push(tableCell(title));html.push(tableCell(itemId));html.push(tableCell(sku));html.push(tableCellLabel('Category' + itemId));html.push(tableCell(format));html.push(tableCell('$' + price));html.push(tableCell(quantity));html.push(tableCellLabel('Views' + itemId));html.push(tableCell(watchers));html.push(tableCell(listingDate));html.push(tableCell(privateNote + ' ' + ebayNote));html.push('</tr>');}}function tableSorterEnd() {html.push('</tbody>');html.push('</table>');html.push('</div>');document.getElementById("logging").innerHTML = html.join('');$(function() {$("#" + tableSorterName).on('tablesorter-initialized', function() {// class name to add on tr when checkbox is checkedvar highlightClass = 'checked',// resort the table after the checkbox is modified?resort = true,$table = $(this),c = this.config,wo = c && c.widgetOptions,// include sticky header checkbox; if installed$sticky = c && wo.$sticky || '',doChecky = function(c, col) {$table.children('tbody').children('tr:visible').children('td:nth-child( ' + (parseInt(col, 10) + 1) + ' )').find('input[type=checkbox]').each(function() {this.checked = c;$(this).trigger('change');});};$table.children('tbody').on('change', 'input[type=checkbox]', function() {// ignore change if updating all rowsif ($table[0].ignoreChange) {return;}var $this = $(this);$this.closest('tr').toggleClass(highlightClass, this.checked);$this.trigger('updateCell', [$this.closest('td'), resort]);// handle headervar rowCount = $('#' + tableSorterName + ' tbody tr').length + $('#' + tableSorterName + ' tbody tr:hidden').length;var checkedCount = $('#' + tableSorterName + ' tbody .checked').length;var ua = window.navigator.userAgent;if (checkedCount === 0) {$table.add($sticky).find('thead input[type=checkbox]').prop('checked', false);$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);} else if (checkedCount === rowCount) {$table.add($sticky).find('thead input[type=checkbox]').prop('checked', true);$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', false);} else {$table.add($sticky).find('thead input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));$table.add($sticky).find('thead input[type=checkbox]').prop('indeterminate', true);}$('#selected-rows').html(checkedCount);}).end().add($sticky).find('thead input[type=checkbox]')// Click on checkbox in table header to toggle all inputs.on('change', function() {// prevent updateCell for every cell$table[0].ignoreChange = true;var c = this.checked,col = $(this).closest('th').attr('data-column');doChecky(c, col);// update main & sticky header$table.children('tbody').children('tr:visible').toggleClass(highlightClass, c);// update all at once$table[0].ignoreChange = false;$table.trigger('update', [resort]);// handle headervar rowCount = $('#' + tableSorterName + ' tbody tr').length + $('#' + tableSorterName + ' tbody tr:hidden').length;var checkedCount = $('#' + tableSorterName + ' tbody .checked').length;var ua = window.navigator.userAgent;if (checkedCount === 0) {$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', false);$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);} else if (checkedCount === rowCount) {$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', true);$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', false);} else {$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('checked', !(ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1));$table.add($sticky).find('th[data-column=' + col + '] input[type=checkbox]').prop('indeterminate', true);}$('#selected-rows').html(checkedCount);}).on('mouseup', function() {return false;});});$("#" + tableSorterName).tablesorter({theme: "blue",widgets: ["zebra", "stickyHeaders", "filter"],headers: {0: {sorter: "checkbox"},1: {sorter: false,filter: false}},initialized: function() {fillSorterListings();}});$("#" + tableSorterName).bind('filterInit filterEnd', function(event, data) {$('#filtered-rows').html(data.filteredRows);$('#total-rows').html(data.totalRows);});});}function eBaySorterSearch(pageNo) {var i;var xml;var xw = new XMLWriter('UTF-8', '1.0');var xhr = new XMLHttpRequest();if (!createSorterAddXMLSearch(xw, xhr, 'GetMyeBaySelling', pageNo)) {return;}xml = xw.flush();xw.close();//window.alert(vkbeautify.xml(xml));xhr.onload = function() {var obj = XMLparse(xhr.responseXML);//window.alert(JSON.stringify(obj));//window.alert(vkbeautify.xml(xhr.responseText));var returnCode = obj.Ack;var objArray = (liveListing ? obj.ActiveList : obj.UnsoldList);var x = document.getElementById("results");if (returnCode == 'Success') {tableSorterEntry(objArray.ItemArray);if (Number(objArray.PaginationResult.TotalNumberOfPages) > pageNo) {maxPagesToProcess = Number(objArray.PaginationResult.TotalNumberOfPages);++pagesToProcess;eBaySorterSearch(pageNo + 1);}updateProgressBar(maxPagesToProcess, pagesProcessed);} else {x.className += " process-errors";x.innerHTML += '<p class="w3-red">' + obj.CorrelationID + ': <strong>' + returnCode + ':</strong></p>';var errors = obj.Errors;x.innerHTML += "<p>";if (errors.length > 0) {for (i = 0; i < errors.length; i++) {x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";}} else {x.innerHTML += obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "<br/>";}x.innerHTML += "</p>";}--pagesToProcess;++pagesProcessed;updateProgressBar(maxPagesToProcess, pagesProcessed);};xhr.send(xml);}function createSorterAddXMLSearch(xw, xhr, callname, pageNo) {xw.writeStartDocument();xw.writeStartElement(callname + "Request");xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');xw.writeStartElement('RequesterCredentials');xw.writeElementString('eBayAuthToken', eBayAuthToken);xw.writeEndElement(); /* RequesterCredentials */xw.writeElementString('DetailLevel', 'ReturnAll');xw.writeStartElement('DeletedFromSoldList');xw.writeElementString('Include', 'false');xw.writeEndElement(); /* DeletedFromSoldList */xw.writeStartElement('DeletedFromUnsoldList');xw.writeElementString('Include', 'false');xw.writeEndElement(); /* DeletedFromUnsoldList */xw.writeStartElement('ScheduledList');xw.writeElementString('Include', 'false');xw.writeEndElement(); /* ScheduledList */xw.writeStartElement('SellingSummary');xw.writeElementString('Include', 'false');xw.writeEndElement(); /* SellingSummary */xw.writeStartElement('SoldList');xw.writeElementString('Include', 'false');xw.writeEndElement(); /* SoldList */xw.writeStartElement(liveListing ? 'UnsoldList' : 'ActiveList');xw.writeElementString('Include', 'false');xw.writeEndElement(); /* ActiveList */xw.writeStartElement(liveListing ? 'ActiveList' : 'UnsoldList');xw.writeElementString('Include', 'true');xw.writeElementString('IncludeNotes', 'true');xw.writeStartElement('Pagination');xw.writeElementString('EntriesPerPage', '200');xw.writeElementString('PageNumber', '' + pageNo);xw.writeEndElement(); /* Pagination*/xw.writeEndElement(); /* UnsoldList> */xw.writeElementString('OutputSelector', 'BuyItNowPrice');xw.writeElementString('OutputSelector', 'eBayNotes');xw.writeElementString('OutputSelector', 'ItemID');xw.writeElementString('OutputSelector', liveListing ? 'ActiveList.ItemArray.Item.ListingDetails.StartTime' : 'UnsoldList.ItemArray.Item.ListingDetails.EndTime');xw.writeElementString('OutputSelector', 'ListingType');xw.writeElementString('OutputSelector', 'PrivateNotes');xw.writeElementString('OutputSelector', 'QuantityAvailable');xw.writeElementString('OutputSelector', 'PictureDetails');xw.writeElementString('OutputSelector', 'Relisted');xw.writeElementString('OutputSelector', 'SKU');xw.writeElementString('OutputSelector', 'Title');xw.writeElementString('OutputSelector', 'StartPrice');xw.writeElementString('OutputSelector', 'WatchCount');xw.writeElementString('OutputSelector', 'PaginationResult');xw.writeElementString('ErrorLanguage', 'en_US');xw.writeElementString('Version', configeBayTradingVersion);xw.writeElementString('WarningLevel', configWarningLevel);xw.writeEndElement(); /* xmlrequest */xw.writeEndDocument();xhr.open('POST', configProxyUrl, true);xhr.setRequestHeader('Content-Type', 'text/xml');xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);xhr.setRequestHeader('X-EBAY-API-SITEID', '0');xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);return true;}function fillSorterListings() {var i;var x = document.getElementById(tableSorterName);var fillList = [];var maxItems = 20;listingsToFill = 0;maxListingsToFill = 0;listingsFilled = 0;initProgressBar('Filling Listing Information (2/2)');for (i = 2; i < x.rows.length; i++) {fillList.push(x.rows[i].cells[3].innerHTML);}for (i = 0; (i * maxItems) < fillList.length; i++) {++listingsToFill;++maxListingsToFill;fillSorterListing(fillList.slice(i * maxItems, (i + 1) * maxItems));}function checkListingsToFill() {if (listingsToFill > 0) {window.setTimeout(checkListingsToFill, 100); // wait 100 milliseconds} else {$("#" + tableSorterName).trigger("update");endProgressBar();x = document.getElementById("form1div");x.className = x.className.replace(" w3-show", "");x = document.getElementById("form2div");x.className += " w3-show";x = document.getElementById("results");x.innerHTML += '<p><strong>Report Finished!</strong></p>';if (!x.className.includes("process-errors")) {setTimeout(function() {x.className = x.className.replace(" w3-show", "");}, 3000);}}}checkListingsToFill();}function fillSorterListing(itemIdList) {var i;var xml;var xw = new XMLWriter('UTF-8', '1.0');var xhr = new XMLHttpRequest();if (!createSorterFillXMLSearch(xw, xhr, 'GetMultipleItems', itemIdList)) {return;}xml = xw.flush();xw.close();//window.alert(vkbeautify.xml(xml));xhr.onload = function() {var obj = XMLparse(xhr.responseXML);//window.alert(JSON.stringify(obj));//window.alert(vkbeautify.xml(xhr.responseText));var returnCode = obj.Ack;var x = document.getElementById("results");if (returnCode == 'Success') {for (i = 0; i < obj.Item.length; i++) {var itemId = getJsonValue(obj.Item[i].ItemID);document.getElementById("Views" + itemId).innerHTML = getJsonValue(obj.Item[i].HitCount);document.getElementById("Category" + itemId).innerHTML = getJsonValue(obj.Item[i].PrimaryCategoryName);}} else {x.className += " process-errors";x.innerHTML += '<p class="w3-red"><strong>' + returnCode + ':</strong></p>';var errors = obj.Errors;x.innerHTML += "<p>";if (errors.length > 0) {for (i = 0; i < errors.length; i++) {x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";}} else {x.innerHTML += obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "<br/>";}x.innerHTML += "</p>";}--listingsToFill;++listingsFilled;updateProgressBar(maxListingsToFill, listingsFilled);};xhr.send(xml);}function createSorterFillXMLSearch(xw, xhr, callname, itemIdList) {var i;xw.writeStartDocument();xw.writeStartElement(callname + "Request");xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');for (i = 0; i < itemIdList.length; i++) {xw.writeElementString('ItemID', itemIdList[i]);}xw.writeElementString('ErrorLanguage', 'en_US');xw.writeElementString('Version', configeBayShoppingVersion);xw.writeElementString('WarningLevel', configWarningLevel);xw.writeEndElement(); /* xmlrequest */xw.writeEndDocument();xhr.open('POST', configProxyUrl, true);xhr.setRequestHeader('Content-Type', 'text/xml');xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);xhr.setRequestHeader('X-EBAY-API-VERSION', configeBayShoppingVersion);xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);xhr.setRequestHeader('X-EBAY-API-SITEID', '0');xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');xhr.setRequestHeader('X-EBAY-API-REQUEST-ENCODING', 'XML');xhr.setRequestHeader('X-Proxy-URL', configeBayShopping);return true;}</script></body></html>