Subversion Repositories munaweb

Rev

Rev 151 | Rev 172 | 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>eBay Quick Listing</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
 
30 - 11
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
12
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
13
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
14
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
15
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/css/bootstrap-select.min.css">
16
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
17
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/js/bootstrap-select.js"></script>
18
    <script src="js/XMLWriter.js"></script>
19
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
20
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
2 - 21
    <link rel="stylesheet" href="css/style.css">
22
    <script src="js/muna-tools.js"></script>
53 - 23
    <script src="js/barcoder.js"></script>
30 - 24
    <style>
25
        .btn-group-sm > .btn, .btn-sm {font-size:small!important}
128 - 26
        .invert {filter: invert(20%);}
30 - 27
    </style>
2 - 28
</head>
29
 
30 - 30
<body style="font-size:80%!important;" onload="return initConfig();" onbeforeunload="return confirmUnload();">
31
    <div>
32
        <div>
33
            <div class="container-fluid bg-secondary">
34
                <div class="clearfix">
35
                    <img class="img-fluid float-right" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" />
36
                    <h1 id="connected">eBay Quick Listing
37
                    <input id="login" type="button" class="btn bg-success mb-2 w3-hide" onclick="eBayLogin();" value="Login" /></h1>
38
                </div>
2 - 39
            </div>
40
 
30 - 41
            <div class="container-fluid bg-light">
42
                <div class="row">
43
                    <div class="container-fluid border col-6">
44
                        <div class="container-fluid border bg-primary">
45
                            <div class="form-group">
46
                                <form id="searchForm" onsubmit="findOneBay();return false;">
47
                                    <select id="keyword" title="Select Item ..." class="selectpicker mx-2 mt-2 btn-sm" data-style="btn-sm" data-width="fit" data-live-search="true" autofocus="autofocus" onchange="findOneBay();">
48
                                    </select>
49
                                </form>
2 - 50
                            </div>
30 - 51
                        </div>
52
 
53
                        <div class="container-fluid border">
54
                            <form id="listForm">
55
                                <div class="mt-2">
56
                                    <label for="category" class="mr-sm-2">Category:</label>
57
                                    <select id="category" name="category" data-placeholder="Select Category..." class="selectpicker mb-2 mr-sm-2" data-style="btn-outline-dark btn-sm" onchange="return categoryValues();" onload="return categoryValues();">
58
                                        <option class="small" value="29792">Audiobooks</option>
59
                                        <option class="small" value="29223">Books Antiquarian &amp; Collectible</option>
60
                                        <option class="small" value="182882">Books Children Young Adults</option>
61
                                        <option class="small" value="171228">Books Fiction Literature</option>
62
                                        <option class="small" value="171243">Books Nonfiction</option>
63
                                        <option class="small" value="268">Books Other</option>
64
                                        <option class="small" value="2228">Books Textbooks, Education</option>
65
                                        <option class="small" selected="selected" value="176984">CDs</option>
66
                                        <option class="small" value="617">DVDs Blu-ray Discs</option>
67
                                        <!--option value="666">Trading Cards Auto Racing</option-->
68
                                        <option class="small" value="213">Trading Cards Baseball</option>
69
                                        <option class="small" value="214">Trading Cards Basketball</option>
70
                                        <!--option value="133072">Trading Cards College</option-->
71
                                        <option class="small" value="215">Trading Cards Football</option>
72
                                        <!--option value="4240">Trading Cards Golf</option-->
73
                                        <option class="small" value="216">Trading Cards Ice Hockey</option>
74
                                        <!--option value="183444">Trading Cards Soccer</option-->
2 - 75
                                    </select>
30 - 76
                                    <label for="format" class="mr-sm-2">Format:</label>
77
                                    <select id="format" name="format" data-placeholder="Select Format..." class="selectpicker mb-2 mr-sm-2" data-style="btn-outline-dark btn-sm" onchange="return categoryValues();" onload="return categoryValues();">
78
                                        <option class="small" value="Chinese">Auction</option>
79
                                        <option class="small" value="FixedPriceItem" selected>Fixed Price</option>
2 - 80
                                    </select>
81
                                </div>
30 - 82
 
83
                                <div class="mt-2">
84
                                    <div class="clearfix">
85
                                        <a id="image1anchor" href="#" target="_blank"><img id="image1" src="images/default-image.png" alt="(Front Image Missing)" style="max-height:80px;" onload="return pictureLoad(true);" onerror="return pictureLoad(false);" crossorigin="anonymous" /></a>
86
                                        <a id="image2anchor" href="#" target="_blank"><img id="image2" src="images/default-image.png" alt="(Back Image Missing)" style="max-height:80px;" onload="return pictureLoad(true);" onerror="return pictureLoad(false);" crossorigin="anonymous" /></a>
87
                                        <img id="descriptionImage" src="images/default-image.png" alt="(Front/Back Image Missing)" style="max-height:50px;display:inline-block;" onload="return pictureLoad(true);" onerror="return pictureLoad(false); " crossorigin="anonymous" />
88
                                        <a id="image3anchor" class=" invisible" href="#" target="_blank"><img id="image3" src="images/default-image.png" alt="(Optional Image 3)" style="max-height:80px;" crossorigin="anonymous" /></a>
89
                                        <a id="image4anchor" class=" invisible" href="#" target="_blank"><img id="image4" src="images/default-image.png" alt="(Optional Image 4)" style="max-height:80px;" crossorigin="anonymous" /></a>
90
                                        <a id="image5anchor" class=" invisible" href="#" target="_blank"><img id="image5" src="images/default-image.png" alt="(Optional Image 5)" style="max-height:80px;" crossorigin="anonymous" /></a>
91
                                        <a id="image6anchor" class=" invisible" href="#" target="_blank"><img id="image6" src="images/default-image.png" alt="(Optional Image 6)" style="max-height:80px;" crossorigin="anonymous" /></a>
92
                                        <a id="image7anchor" class=" invisible" href="#" target="_blank"><img id="image7" src="images/default-image.png" alt="(Optional Image 7)" style="max-height:80px;" crossorigin="anonymous" /></a>
93
                                        <a id="image8anchor" class=" invisible" href="#" target="_blank"><img id="image8" src="images/default-image.png" alt="(Optional Image 8)" style="max-height:80px;" crossorigin="anonymous" /></a>
94
                                        <a id="image9anchor" class=" invisible" href="#" target="_blank"><img id="image9" src="images/default-image.png" alt="(Optional Image 9)" style="max-height:80px;" crossorigin="anonymous" /></a>
95
                                        <a id="image10anchor" class=" invisible" href="#" target="_blank"><img id="image10" src="images/default-image.png" alt="(Optional Image 10)" style="max-height:80px;" crossorigin="anonymous" /></a>
96
                                    </div>
2 - 97
                                </div>
30 - 98
 
99
                                <div class="mt-2">
100
                                    <label for="title" class="keepTogether mr-sm-2">Title:</label>
101
                                    <input id="title" name="title" type="text" maxlength="80" style="width:90%" onblur="return extractFromTitle();" onKeyPress="printTitleLength()" onKeyUp="printTitleLength()" required>
102
                                    <span id="titleLength" class="small">(0)</span>
2 - 103
                                </div>
30 - 104
 
105
                                <div class="mt-2">
106
                                    <label for="price" class="keepTogether mr-sm-2">Price:</label>
107
                                    <input id="price" name="price" style="width:8%" type="text" required>
108
                                    <label for="bestoffer" class="mr-sm-2">Best Offer:</label>
109
                                    <input id="bestoffer" name="bestoffer" class="checkbox" type="checkbox">
110
                                    <label for="quantity" class="keepTogether mr-sm-2">Quantity:</label>
111
                                    <input id="quantity" name="quantity" style="width:8%" type="text" value="1" maxlength="4" required>
112
                                    <label for="sku" class="keepTogether mr-sm-2">SKU:</label>
113
                                    <input id="sku" name="sku" style="width:12%" type="text" value="Batch X" maxlength="20" required>
114
                                    <label for="conditionId" class="keepTogether mr-sm-2">Condition:</label>
115
                                    <select id="conditionId" name="conditionId" data-placeholder="Select Condition..." class="selectpicker" data-style="btn-outline-dark btn-sm">
116
                                        <option class="small" value="1000">New</option>
117
                                        <option class="small" value="1500">New other (see details)</option>
118
                                        <option class="small" value="1750">New with defects</option>
119
                                        <option class="small" value="2000">Manufacturer refurbished</option>
120
                                        <option class="small" value="2500">Seller refurbished</option>
121
                                        <option class="small" value="2750">Like New</option>
122
                                        <option class="small" value="3000">Used / Pre-owned</option>
123
                                        <option class="small" value="4000">Very Good</option>
124
                                        <option class="small" value="5000">Good</option>
125
                                        <option class="small" value="6000">Acceptable</option>
126
                                        <option class="small" value="7000">For parts or not working</option>
2 - 127
                                    </select>
128
                                </div>
30 - 129
                                <div class="form-group">
130
                                    <label for="condition">Condition Description:</label>
131
                                    <input id="CdConditionDescriptionSingular" type="button" class="btn btn-dark btn-xs border rounded-circle mx-2 w3-hide" onclick="return setCdConditionDescription('S');" value="S" />
132
                                    <input id="CdConditionDescriptionPlural" type="button" class="btn btn-dark btn-xs border rounded-circle mx-2 w3-hide" onclick="return setCdConditionDescription('P');" value="P" />
133
                                    <input id="CdConditionDescriptionDigipak" type="button" class="btn btn-dark btn-xs border rounded-circle mx-2 w3-hide" onclick="return setCdConditionDescription('D');" value="D" />
134
                                    <input id="CdConditionDescriptionNewCase" type="button" class="btn btn-dark btn-xs border rounded-circle mx-2 w3-hide" onclick="return setCdConditionDescription('N');" value="N" />
135
                                    <textarea id="condition" name="condition" class="form-control" style="font-size:95%!important" rows="2" maxlength="1000" required></textarea>
2 - 136
                                </div>
30 - 137
                            </form>
138
                            <div id="bookDetails" class="container-fluid  ">
139
                                <form id="bookForm" class="form-fluid">
140
                                    <div>
141
                                        <label for="bookISBN" class="keepTogether mr-sm-2">ISBN:</label>
142
                                        <input id="bookISBN" name="bookISBN" style="width:13%" type="text" disabled>
143
                                        <label for="bookFormat" class="keepTogether mr-sm-2">Format:</label>
144
                                        <select id="bookFormat" name="bookFormat" data-placeholder="Select Format..." class="selectpicker" data-style="btn-outline-dark btn-sm">
145
                                            <option class="small" value="Hardcover">Hardcover</option>
146
                                            <option class="small" value="Paperback">Paperback</option>
147
                                            <option class="small" value="CD-ROM (Non-Audio)">CD-ROM (Non-Audio)</option>
148
                                            <option class="small" value="Mixed Lot">Mixed Lot</option>
149
                                            <option class="small" value="Board Book">Board Book</option>
150
                                            <option class="small" value="Loose-Leaf">Loose-Leaf</option>
151
                                            <option class="small" value="Postcard Book">Postcard Book</option>
152
                                            <option class="small" value="Shrink-Wrapped Pack">Shrink-Wrapped Pack</option>
153
                                        </select>
154
                                        <label for="bookAuthor" class="keepTogether mr-sm-2">Author:</label>
155
                                        <input id="bookAuthor" name="bookAuthor" style="width:29%" type="text" maxlength="40">
156
                                        <label for="bookPublicationYear" class="keepTogether mr-sm-2">Year:</label>
157
                                        <input id="bookPublicationYear" name="bookPublicationYear" style="width:8%" type="text" maxlength="4">
158
                                    </div>
159
                                    <div>
160
                                        <label for="bookSubject" class="keepTogether mr-sm-2">Subject:</label>
161
                                        <select id="bookSubject" name="bookSubject" data-placeholder="Select Subject..." class="selectpicker" data-style="btn-outline-dark btn-sm">
162
                                            <option class="small" value="Activity &amp; Coloring Books">Activity & Coloring Books</option>
163
                                            <option class="small" value="Architecture &amp; Design">Architecture & Design</option>
164
                                            <option class="small" value="Art &amp; Photography">Art & Photography</option>
165
                                            <option class="small" value="Biography &amp; Autobiography">Biography & Autobiography</option>
166
                                            <option class="small" value="Books on Collecting">Books on Collecting</option>
167
                                            <option class="small" value="Business &amp; Economics">Business & Economics</option>
168
                                            <option class="small" value="Computers &amp; Internet">Computers & Internet</option>
169
                                            <option class="small" value="Cooking, Food &amp; Wine">Cooking, Food & Wine</option>
170
                                            <option class="small" value="Erotica">Erotica</option>
171
                                            <option class="small" value="Family &amp; Relationships">Family & Relationships</option>
172
                                            <option class="small" value="Games &amp; Puzzles">Games & Puzzles</option>
173
                                            <option class="small" value="Health &amp; Fitness">Health & Fitness</option>
174
                                            <option class="small" value="History">History</option>
175
                                            <option class="small" value="Hobbies &amp; Crafts">Hobbies & Crafts</option>
176
                                            <option class="small" value="Home &amp; Garden">Home & Garden</option>
177
                                            <option class="small" value="Humor">Humor</option>
178
                                            <option class="small" value="Law &amp; Government">Law & Government</option>
179
                                            <option class="small" value="Library &amp; Information Science">Library & Information Science</option>
180
                                            <option class="small" value="Literary Criticism">Literary Criticism</option>
181
                                            <option class="small" value="Literature">Literature</option>
182
                                            <option class="small" value="Medical">Medical</option>
183
                                            <option class="small" value="Military &amp; War">Military & War</option>
184
                                            <option class="small" value="Novel">Novel</option>
185
                                            <option class="small" value="Outdoor &amp; Nature">Outdoor & Nature</option>
186
                                            <option class="small" value="Paranormal &amp; Metaphysical">Paranormal & Metaphysical</option>
187
                                            <option class="small" value="Performing Arts">Performing Arts</option>
188
                                            <option class="small" value="Pets &amp; Animal Care">Pets & Animal Care</option>
189
                                            <option class="small" value="Philosophy">Philosophy</option>
190
                                            <option class="small" value="Psychology">Psychology</option>
191
                                            <option class="small" value="Reference">Reference</option>
192
                                            <option class="small" value="Religion &amp; Spirituality">Religion & Spirituality</option>
193
                                            <option class="small" value="Science &amp; Technology">Science & Technology</option>
194
                                            <option class="small" value="Self-Help">Self-Help</option>
195
                                            <option class="small" value="Sexuality">Sexuality</option>
196
                                            <option class="small" value="Social Sciences">Social Sciences</option>
197
                                            <option class="small" value="Sports &amp; Recreation">Sports & Recreation</option>
198
                                            <option class="small" value="Teaching &amp; Education">Teaching & Education</option>
199
                                            <option class="small" value="Transportation">Transportation</option>
200
                                            <option class="small" value="Travel, Geography &amp; Exploration">Travel, Geography & Exploration</option>
201
                                            <option class="small" value="True Crime">True Crime</option>
202
                                            <option class="small" value="Vintage Paperbacks">Vintage Paperbacks</option>
203
                                        </select>
204
                                        <label for="bookLanguage" class="keepTogether mr-sm-2">Language:</label>
205
                                        <input id="bookLanguage" name="bookLanguage" style="width:20%" type="text">
206
                                        <label for="bookCountry" class="keepTogether mr-sm-2">Country:</label>
207
                                        <input id="bookCountry" name="bookCountry" style="width:25%" type="text" maxlength="65">
208
                                    </div>
209
 
210
                                    <div class="border">
211
                                        <div class="form-check-inline">
212
                                            <label class="form-check-label">Special Attributes:</label>
10 - 213
                                        </div>
30 - 214
                                        <div class="form-check-inline">
215
                                            <label class="form-check-label" for="bookDustJacket">
216
                                                <input id="bookDustJacket" name="bookDustJacket" class="form-check-input" type="checkbox">Dust Jacket
217
                                            </label>
218
                                        </div>
219
                                        <div class="form-check-inline">
220
                                            <label class="form-check-label" for="bookIllustrated">
221
                                                <input id="bookIllustrated" name="bookIllustrated" class="form-check-input" type="checkbox">Illustrated
222
                                            </label>
223
                                        </div>
224
                                        <div class="form-check-inline">
225
                                            <label class="form-check-label" for="bookLargePrint">
226
                                                <input id="bookLargePrint" name="bookLargePrint" class="form-check-input" type="checkbox">Large Print
227
                                            </label>
228
                                        </div>
229
                                        <div class="form-check-inline">
230
                                            <label class="form-check-label" for="bookSigned">
231
                                                <input id="bookSigned" name="bookSigned" class="form-check-input" type="checkbox">Signed
232
                                            </label>
233
                                        </div>
234
                                    </div>
235
                                </form>
236
                            </div>
237
                            <div id="cdDetails" class="container-fluid  ">
238
                                <form id="cdForm" class="form-fluid">
239
                                    <div>
240
                                        <label for="cdUPC" class="keepTogether w3-hide">UPC:</label>
241
                                        <input id="cdUPC" name="cdUPC" class="w3-hide" type="text" disabled>
242
                                        <label for="cdArtist" class="keepTogether mr-sm-2">Artist:</label>
40 - 243
                                        <input id="cdArtist" name="cdArtist" style="width:30%" type="text" maxlength="65">
30 - 244
                                        <label for="cdTitle" class="keepTogether mr-sm-2">Title:</label>
245
                                        <input id="cdTitle" name="cdTitle" style="width:30%" type="text" maxlength="65">
246
                                        <label for="cdRecordLabel" class="keepTogether mr-sm-2">Label:</label>
247
                                        <input id="cdRecordLabel" name="cdRecordLabel" style="width:20%" type="text" maxlength="40">
248
                                    </div>
249
                                    <div>
250
                                        <label for="cdReleaseYear" class="keepTogether mr-sm-2">Year:</label>
251
                                        <input id="cdReleaseYear" name="cdReleaseYear" type="text" style="width:6%" maxlength="4">
252
                                        <label for="cdDuration" class="keepTogether mr-sm-2">Duration:</label>
253
                                        <select id="cdDuration" name="cdDuration" data-placeholder="Select Duration..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
254
                                            <option class="small" value="Album" selected>Album</option>
255
                                            <option class="small" value="Mini Album">Mini Album</option>
256
                                            <option class="small" value="Box Set">Box Set</option>
257
                                            <option class="small" value="EP">EP</option>
258
                                            <option class="small" value="Single">Single</option>
259
                                            <option class="small" value="Maxi-Single">Maxi-Single</option>
260
                                        </select>
261
                                        <label for="cdGenre" class="keepTogether mr-sm-2">Genre:</label>
262
                                        <select id="cdGenre" name="cdGenre" data-placeholder="Select Genre..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
263
                                            <option class="small" value="Blues">Blues</option>
264
                                            <option class="small" value="Children&apos;s">Children's</option>
265
                                            <option class="small" value="Classical">Classical</option>
266
                                            <option class="small" value="Comedy &amp; Spoken Word">Comedy & Spoken Word</option>
267
                                            <option class="small" value="Country">Country</option>
268
                                            <option class="small" value="Dance &amp; Electronica">Dance & Electronica</option>
269
                                            <option class="small" value="Folk">Folk</option>
270
                                            <option class="small" value="Holiday">Holiday</option>
271
                                            <option class="small" value="Jazz">Jazz</option>
272
                                            <option class="small" value="Latin">Latin</option>
273
                                            <option class="small" value="Metal">Metal</option>
274
                                            <option class="small" value="Military">Military</option>
275
                                            <option class="small" value="New Age &amp; Easy Listening">New Age & Easy Listening</option>
276
                                            <option class="small" value="Pop">Pop</option>
277
                                            <option class="small" value="R&amp;B &amp; Soul">R&B & Soul</option>
278
                                            <option class="small" value="Rap &amp; Hip-Hop">Rap & Hip-Hop</option>
279
                                            <option class="small" value="Reggae, Ska &amp; Dub">Reggae, Ska & Dub</option>
280
                                            <option class="small" value="Religious &amp; Devotional">Religious & Devotional</option>
281
                                            <option class="small" value="Rock">Rock</option>
282
                                            <option class="small" value="Soundtracks &amp; Musicals">Soundtracks & Musicals</option>
283
                                            <option class="small" value="Sound Effects &amp; Nature">Sound Effects & Nature</option>
284
                                            <option class="small" value="World Music">World Music</option>
285
                                        </select>
286
                                        <label for="cdCountry" class="keepTogether mr-sm-2">Country:</label>
287
                                        <input id="cdCountry" name="cdCountry" type="text" style="width:16%" maxlength="65">
288
                                    </div>
289
 
290
                                    <div class="border">
291
                                        <span>Special Attributes:<br/></span>
292
                                        <div class="form-check-inline">
293
                                            <label class="form-check-label" for="cdCompilation">
294
                                                <input id="cdCompilation" name="cdCompilation" class="form-check-input" type="checkbox">Compilation
295
                                            </label>
296
                                        </div>
297
                                        <div class="form-check-inline">
298
                                            <label class="form-check-label" for="cdDigipak">
299
                                                <input id="cdDigipak" name="cdDigipak" class="form-check-input" type="checkbox">Digipak
300
                                            </label>
301
                                        </div>
302
                                        <div class="form-check-inline">
303
                                            <label class="form-check-label" for="cdDualDisc">
304
                                                <input id="cdDualDisc" name="cdDualDisc" class="form-check-input" type="checkbox">DualDisc
305
                                            </label>
306
                                        </div>
307
                                        <div class="form-check-inline">
308
                                            <label class="form-check-label" for="cdEnhanced">
309
                                                <input id="cdEnhanced" name="cdEnhanced" class="form-check-input" type="checkbox">Enhanced
310
                                            </label>
311
                                        </div>
312
                                        <div class="form-check-inline">
313
                                            <label class="form-check-label" for="cdLiveRecording">
314
                                                <input id="cdLiveRecording" name="cdLiveRecording" class="form-check-input" type="checkbox">Live
315
                                            </label>
316
                                        </div>
317
                                        <div class="form-check-inline">
318
                                            <label class="form-check-label" for="cdPromo">
319
                                                <input id="cdPromo" name="cdPromo" class="form-check-input" type="checkbox">Promo
320
                                            </label>
321
                                        </div>
322
                                        <div class="form-check-inline">
323
                                            <label class="form-check-label" for="cdReissue">
324
                                                <input id="cdReissue" name="cdReissue" class="form-check-input" type="checkbox">Reissue
325
                                            </label>
326
                                        </div>
327
                                        <div class="form-check-inline">
328
                                            <label class="form-check-label" for="cdRemastered">
329
                                                <input id="cdRemastered" name="cdRemastered" class="form-check-input" type="checkbox">Remastered
330
                                            </label>
331
                                        </div>
332
                                        <div class="form-check-inline">
333
                                            <label class="form-check-label" for="cdHDCD">
334
                                                <input id="cdHDCD" name="cdHDCD" class="form-check-input" type="checkbox">HDCD
335
                                            </label>
336
                                        </div>
337
                                        <div class="form-check-inline">
338
                                            <label class="form-check-label" for="cdGreatestHits">
339
                                                <input id="cdGreatestHits" name="cdGreatestHits" class="form-check-input" type="checkbox">Greatest Hits
340
                                            </label>
341
                                        </div>
36 - 342
                                        <div class="form-check-inline">
343
                                            <label class="form-check-label" for="cdImport">
344
                                                <input id="cdImport" name="cdImport" class="form-check-input" type="checkbox">Import
345
                                            </label>
346
                                        </div>
40 - 347
                                        <div class="form-check-inline">
348
                                            <label class="form-check-label" for="cdClub">
349
                                                <input id="cdClub" name="cdClub" class="form-check-input" type="checkbox">Club
350
                                            </label>
351
                                        </div>
30 - 352
                                    </div>
36 - 353
 
354
                                    <div>
355
                                        <label for="cdLanguage" class="keepTogether mr-sm-2">Language:</label>
356
                                        <input id="cdLanguage" name="cdLanguage" type="text" style="width:12%" maxlength="65" value="English">
357
                                        <label for="cdModified" class="keepTogether mr-sm-2">Modified:</label>
358
                                        <select id="cdModified" name="cdModified" class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm" onchange="return setModifiedDescription();">
359
                                            <option class="small" value="No" selected>No</option>
360
                                            <option class="small" value="Yes">Yes</option>
361
                                        </select>
362
                                        <label for="cdModificationDescription" class="keepTogether mr-sm-2">Mod Desc:</label>
68 - 363
                                        <input id="cdModificationDescription" name="cdModificationDescription" type="text" style="width:45%" maxlength="200">
36 - 364
                                    </div>
30 - 365
 
366
                                    <div>
367
                                        <div class="container-fluid row">
368
                                            <div class="container-fluid col-6">
369
                                                <label for="cdTracksFormat" class="mb-2 mr-sm-2">Track List (optional):</label>
370
                                                <input id="cdTracksFormat" type="button" class="btn btn-dark btn-xs border rounded-circle mb-2 mr-sm-2" onclick="return formatTrackList();" value="Format" />
371
                                                <input id="cdUnorderedTrackList" name="cdUnorderedTrackList" class="mb-2" type="checkbox" onchange="return updateTracklistPreview();">
372
                                                <label for="cdUnorderedTrackList" class="mb-2 mr-sm-2">Unordered</label>
373
                                                <textarea id="cdTracks" name="cdTracks" class="form-control" style="font-size:95%!important" rows="12"></textarea>
10 - 374
                                            </div>
30 - 375
                                            <div class="container-fluid col-6">
376
                                                <p>Preview:</p>
377
                                                <div class="border">
378
                                                    <p id="tracklistPreview"></p>
379
                                                </div>
380
                                            </div>
10 - 381
                                        </div>
382
                                    </div>
30 - 383
                                </form>
384
                            </div>
385
                            <div id="dvdDetails" class="container-fluid  ">
386
                                <form id="dvdForm" class="form-fluid">
387
                                    <div>
388
                                        <label for="dvdUPC" class="keepTogether mr-sm-2">UPC:</label>
389
                                        <input id="dvdUPC" name="dvdUPC" style="width:13%" type="text" disabled>
390
                                        <label for="dvdFormat" class="keepTogether mr-sm-2">Format:</label>
391
                                        <select id="dvdFormat" name="dvdFormat" data-placeholder="Select Format..." class="selectpicker" data-style="btn-outline-dark btn-sm">
392
                                            <option class="small" value="Blu-ray Disc">Blu-ray Disc</option>
393
                                            <option class="small" value="DVD" selected>DVD</option>
394
                                            <option class="small" value="HD DVD">HD DVD</option>
395
                                            <option class="small" value="UltraViolet Code">UltraViolet Code</option>
396
                                        </select>
397
                                        <label for="dvdTitle" class="keepTogether mr-sm-2">Title:</label>
398
                                        <input id="dvdTitle" name="dvdTitle" style="width:44%" type="text" maxlength="65">
399
                                    </div>
400
                                    <div>
401
                                        <label for="dvdActor" class="keepTogether mr-sm-2">Actor:</label>
402
                                        <input id="dvdActor" name="dvdActor" style="width:30%" type="text" maxlength="65">
403
                                        <label for="dvdLeadingRole" class="keepTogether mr-sm-2">Lead:</label>
404
                                        <input id="dvdLeadingRole" name="dvdLeadingRole" style="width:30%" type="text" maxlength="65">
405
                                        <label for="dvdDirector" class="keepTogether mr-sm-2">Director:</label>
406
                                        <input id="dvdDirector" name="dvdDirector" style="width:20%" type="text" maxlength="65">
407
                                    </div>
408
                                    <div>
409
                                        <label for="dvdReleaseYear" class="keepTogether mr-sm-2">Movie Year:</label>
410
                                        <input id="dvdReleaseYear" name="dvdReleaseYear" style="width:8%" type="text" maxlength="4">
411
                                        <label for="dvdDVDEditionYear" class="keepTogether mr-sm-2">DVD Year:</label>
412
                                        <input id="dvdDVDEditionYear" name="dvdDVDEditionYear" style="width:8%" type="text" maxlength="4">
413
                                        <label for="dvdGenre" class="keepTogether mr-sm-2">Genre:</label>
414
                                        <select id="dvdGenre" name="dvdGenre" data-placeholder="Select Genre..." class="selectpicker" data-style="btn-outline-dark btn-sm">
415
                                            <option class="small" value=" " selected> </option>
416
                                            <option class="small" value="Action &amp; Adventure">Action & Adventure</option>
417
                                            <option class="small" value="Animation &amp; Anime">Animation & Anime</option>
418
                                            <option class="small" value="Children&apos;s &amp; Family">Children's & Family</option>
419
                                            <option class="small" value="Comedy">Comedy</option>
420
                                            <option class="small" value="Documentary">Documentary</option>
421
                                            <option class="small" value="Drama">Drama</option>
422
                                            <option class="small" value="Educational">Educational</option>
423
                                            <option class="small" value="Exercise &amp; Fitness">Exercise & Fitness</option>
424
                                            <option class="small" value="Foreign Language">Foreign Language</option>
425
                                            <option class="small" value="Horror">Horror</option>
426
                                            <option class="small" value="Music &amp; Concerts">Music & Concerts</option>
427
                                            <option class="small" value="Musicals &amp; Broadway">Musicals & Broadway</option>
428
                                            <option class="small" value="Romance">Romance</option>
429
                                            <option class="small" value="Sci-Fi &amp; Fantasy">Sci-Fi & Fantasy</option>
430
                                            <option class="small" value="Sports">Sports</option>
431
                                            <option class="small" value="Thriller &amp; Mystery">Thriller & Mystery</option>
432
                                            <option class="small" value="TV Shows">TV Shows</option>
433
                                            <option class="small" value="Westerns">Westerns</option>
434
                                        </select>
435
                                        <label for="dvdRating" class="keepTogether mr-sm-2">Rating:</label>
436
                                        <select id="dvdRating" name="dvdRating" data-placeholder="Select Rating..." class="selectpicker" data-style="btn-outline-dark btn-sm">
437
                                            <option class="small" value="G">G</option>
438
                                            <option class="small" value="PG">PG</option>
439
                                            <option class="small" value="PG-13">PG-13</option>
440
                                            <option class="small" value="R">R</option>
441
                                            <option class="small" value="NR">NR</option>
442
                                            <option class="small" value="NC-17">NC-17</option>
443
                                            <option class="small" value="TV-Y">TV-Y</option>
444
                                            <option class="small" value="TV-Y7">TV-Y7</option>
445
                                            <option class="small" value="TV-G">TV-G</option>
446
                                            <option class="small" value="TV-PG">TV-PG</option>
447
                                            <option class="small" value="TV-14">TV-14</option>
448
                                            <option class="small" value="TV-MA">TV-MA</option>
449
                                        </select>
450
                                    </div>
451
                                    <div>
452
                                        <label for="dvdRegionCode" class="keepTogether mr-sm-2">Region:</label>
453
                                        <select id="dvdRegionCode" name="dvdRegionCode" data-placeholder="Select Region..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
454
                                            <option class="small" value="Blu-ray: Region Free">Blu-ray: Region Free</option>
455
                                            <option class="small" value="Blu-ray: A (Americas, Southeast Asia...)">Blu-ray: A</option>
456
                                            <option class="small" value="Blu-ray: B (Europe, AU, NZ, Africa...)">Blu-ray: B</option>
457
                                            <option class="small" value="Blu-ray: C (China, Russia, India...)">Blu-ray: C</option>
458
                                            <option class="small" value="DVD: 0/All (Region Free/Worldwide)">DVD: 0/All</option>
459
                                            <option class="small" value="DVD: 1 (US, Canada...)" selected>DVD: 1</option>
460
                                            <option class="small" value="DVD: 2 (Europe, Japan, Middle East...)">DVD: 2</option>
461
                                            <option class="small" value="DVD: 3 (Southeast Asia, Taiwan, HK...)">DVD: 3</option>
462
                                            <option class="small" value="DVD: 4 (AU, NZ, Latin America...)">DVD: 4</option>
463
                                            <option class="small" value="DVD: 5 (Russia, India, Africa...)">DVD: 5</option>
464
                                            <option class="small" value="DVD: 6 (China)">DVD: 6 (China)</option>
465
                                        </select>
466
                                        <label for="dvdRental" class="keepTogether mr-sm-2">Rental:</label>
467
                                        <select id="dvdRental" name="dvdRental" class="selectpicker" data-width="fit" data-style="btn-outline-dark btn-sm">
468
                                            <option class="small" value="No" selected>No</option>
469
                                            <option class="small" value="Yes">Yes</option>
470
                                        </select>
471
                                        <label for="dvdSeason" class="keepTogether mr-sm-2">Season:</label>
472
                                        <select id="dvdSeason" name="dvdSeason" data-placeholder="Select Season..." class="selectpicker" data-width="auto" data-style="btn-outline-dark btn-sm">
473
                                            <option class="small" value="" selected></option>
474
                                            <option class="small" value="Complete Series Box Set">Complete Series Box Set</option>
475
                                            <option class="small" value="1">1</option>
476
                                            <option class="small" value="2">2</option>
477
                                            <option class="small" value="3">3</option>
478
                                            <option class="small" value="4">4</option>
479
                                            <option class="small" value="5">5</option>
480
                                            <option class="small" value="6">6</option>
481
                                            <option class="small" value="7">7</option>
482
                                            <option class="small" value="8">8</option>
483
                                            <option class="small" value="9">9</option>
484
                                            <option class="small" value="10">10</option>
485
                                            <option class="small" value="11">11</option>
486
                                            <option class="small" value="12">12</option>
487
                                            <option class="small" value="13">13</option>
488
                                            <option class="small" value="14">14</option>
489
                                            <option class="small" value="15">15</option>
490
                                            <option class="small" value="16">16</option>
491
                                            <option class="small" value="17">17</option>
492
                                            <option class="small" value="18">18</option>
493
                                            <option class="small" value="19">19</option>
494
                                            <option class="small" value="20">20</option>
495
                                            <option class="small" value="21">21</option>
496
                                            <option class="small" value="22">22</option>
497
                                            <option class="small" value="23">23</option>
498
                                            <option class="small" value="24">24</option>
499
                                        </select>
500
                                        <label for="dvdCountry" class="keepTogether mr-sm-2">Country:</label>
501
                                        <input id="dvdCountry" name="dvdCountry" style="width:14%" type="text" maxlength="65">
502
                                    </div>
503
 
504
                                    <div class="border">
505
                                        <div class="form-check-inline">
506
                                            <label class="form-check-label">Special Attributes:</label>
507
                                        </div>
508
                                        <div class="form-check-inline">
509
                                            <label class="form-check-label" for="dvd3D">
510
                                                <input id="dvd3D" name="dvd3D" class="form-check-input" type="checkbox">3D
511
                                            </label>
512
                                        </div>
513
                                        <div class="form-check-inline">
514
                                            <label class="form-check-label" for="dvdAnniversaryEdition">
515
                                                <input id="dvdAnniversaryEdition" name="dvdAnniversaryEdition" class="form-check-input" type="checkbox">Anniversary Edition
516
                                            </label>
517
                                        </div>
518
                                        <div class="form-check-inline">
519
                                            <label class="form-check-label" for="dvdBoxSet">
520
                                                <input id="dvdBoxSet" name="dvdBoxSet" class="form-check-input" type="checkbox">Box Set
521
                                            </label>
522
                                        </div>
523
                                        <div class="form-check-inline">
524
                                            <label class="form-check-label" for="dvdCollectorsEdition">
525
                                                <input id="dvdCollectorsEdition" name="dvdCollectorsEdition" class="form-check-input" type="checkbox">Collector's Edition
526
                                            </label>
527
                                        </div>
528
                                        <div class="form-check-inline">
529
                                            <label class="form-check-label" for="dvdDeluxeEdition">
530
                                                <input id="dvdDeluxeEdition" name="dvdDeluxeEdition" class="form-check-input" type="checkbox">Deluxe Edition
531
                                            </label>
532
                                        </div>
533
                                        <div class="form-check-inline">
534
                                            <label class="form-check-label" for="dvdDirectorsCut">
535
                                                <input id="dvdDirectorsCut" name="dvdDirectorsCut" class="form-check-input" type="checkbox">Director's Cut
536
                                            </label>
537
                                        </div>
538
                                        <div class="form-check-inline">
539
                                            <label class="form-check-label" for="dvdExtendedEdition">
540
                                                <input id="dvdExtendedEdition" name="dvdExtendedEdition" class="form-check-input" type="checkbox">Extended Edition
541
                                            </label>
542
                                        </div>
543
                                        <div class="form-check-inline">
544
                                            <label class="form-check-label" for="dvdFullScreen">
545
                                                <input id="dvdFullScreen" name="dvdFullScreen" class="form-check-input" type="checkbox">Full Screen
546
                                            </label>
547
                                        </div>
548
                                        <div class="form-check-inline">
549
                                            <label class="form-check-label" for="dvdLimitedEdition">
550
                                                <input id="dvdLimitedEdition" name="dvdLimitedEdition" class="form-check-input" type="checkbox">Limited Edition
551
                                            </label>
552
                                        </div>
553
                                        <div class="form-check-inline">
554
                                            <label class="form-check-label" for="dvdPromo">
555
                                                <input id="dvdPromo" name="dvdPromo" class="form-check-input" type="checkbox">Promo
556
                                            </label>
557
                                        </div>
558
                                        <div class="form-check-inline">
559
                                            <label class="form-check-label" for="dvdSignatureCollection">
560
                                                <input id="dvdSignatureCollection" name="dvdSignatureCollection" class="form-check-input" type="checkbox">Signature Collection
561
                                            </label>
562
                                        </div>
563
                                        <div class="form-check-inline">
564
                                            <label class="form-check-label" for="dvdSpecialEdition">
565
                                                <input id="dvdSpecialEdition" name="dvdSpecialEdition" class="form-check-input" type="checkbox">Special Edition
566
                                            </label>
567
                                        </div>
568
                                        <div class="form-check-inline">
569
                                            <label class="form-check-label" for="dvdSteelbook">Steelbook
570
                                                <input id="dvdSteelbook" name="dvdSteelbook" class="form-check-input" type="checkbox">
571
                                            </label>
572
                                        </div>
573
                                        <div class="form-check-inline">
574
                                            <label class="form-check-label" for="dvdUnratedEdition">
575
                                                <input id="dvdUnratedEdition" name="dvdUnratedEdition" class="form-check-input" type="checkbox">Unrated Edition
576
                                            </label>
577
                                        </div>
578
                                        <div class="form-check-inline">
579
                                            <label class="form-check-label" for="dvdWidescreen">
580
                                                <input id="dvdWidescreen" name="dvdWidescreen" class="form-check-input" type="checkbox">Widescreen
581
                                            </label>
582
                                        </div>
583
                                    </div>
584
                                </form>
585
                            </div>
586
                            <div id="tradingCardDetails" class="container-fluid   w3-hide">
587
                                <form id="tradingCardForm" class="form-fluid">
588
                                    <div>
589
                                        <label for="tcPlayer" class="keepTogether mr-sm-2">Player:</label>
590
                                        <input id="tcPlayer" name="tcPlayer" style="width:29%" type="text">
591
                                        <label for="tcPosition" class="keepTogether mr-sm-2">Position:</label>
592
                                        <input id="tcPosition" name="tcPosition" style="width:8%" type="text">
593
                                        <label for="tcTeam" class="keepTogether mr-sm-2">Team:</label>
594
                                        <input id="tcTeam" name="tcTeam" style="width:29%" type="text">
595
                                        <label for="tcSeason" class="keepTogether mr-sm-2">Season:</label>
596
                                        <input id="tcSeason" name="tcSeason" style="width:8%" type="text">
597
                                    </div>
598
                                    <div>
599
                                        <label for="tcManufacturer" class="keepTogether mr-sm-2">Manufacturer:</label>
600
                                        <input id="tcManufacturer" name="tcManufacturer" style="width:30%" type="text">
601
                                        <label for="tcNumber" class="keepTogether mr-sm-2">Number:</label>
602
                                        <input id="tcNumber" name="tcNumber" style="width:8%" type="text">
603
                                        <label for="tcSeries" class="keepTogether mr-sm-2">Series:</label>
604
                                        <input id="tcSeries" name="tcSeries" style="width:30%" type="text">
605
                                    </div>
606
                                    <div>
607
                                        <div class="form-check-inline">
608
                                            <label class="form-check-label" for="tcPoA">
609
                                                <input id="tcPoA" name="tcPoA" class="form-check-input" type="checkbox">Piece of Authentic
610
                                            </label>
611
                                        </div>
612
                                        <div class="form-check-inline">
613
                                            <label class="form-check-label" for="tcRookie">
614
                                                <input id="tcRookie" name="tcRookie" class="form-check-input" type="checkbox">Rookie
615
                                            </label>
616
                                        </div>
617
                                        <div class="form-check-inline">
618
                                            <label class="form-check-label" for="tcSerial">
619
                                                <input id="tcSerial" name="tcSerial" class="form-check-input" type="checkbox">Serialized
620
                                            </label>
621
                                        </div>
622
                                    </div>
623
                                </form>
624
                            </div>
625
                            <div id="results" class="container-fluid w3-hide"></div>
2 - 626
                        </div>
30 - 627
 
628
                        <div class="clearfix">
629
                            <input id="verify" type="submit" class="btn btn-danger" onclick="verifyListingImage();" value="Verify" />
630
                            <input id="list" type="button" class="btn btn-danger mx-3" onclick="submitListing(0);" value="List" />
631
                            <input id="savexml" type="button" class="btn btn-danger mx-2" onclick="submitListing(1);" value="XML" />
632
                            <input type="button" class="btn btn-dark float-right" onclick="resetForm()" value="Reset form" />
2 - 633
                        </div>
30 - 634
 
2 - 635
                    </div>
636
 
30 - 637
                    <div class="container-fluid col-6">
638
                        <div class="container border bg-light">
639
                            <div id="productinfo"></div>
640
                            <div id="productinfoSearch"></div>
641
                            <div id="productinfoDuplicate"></div>
642
                        </div>
643
                        <div id="discogsReleases" class="container border w3-hide"></div>
644
                        <div id="prices" class="container border w3-hide"></div>
2 - 645
                    </div>
646
                </div>
647
            </div>
648
 
649
        </div>
650
 
30 - 651
        <footer class="container-fluid text-center border border-bottom-0 border-left-0 border-right-0">
652
            <div w3-include-html="php/footer.php"></div>
2 - 653
        </footer>
654
 
655
    </div>
30 - 656
 
2 - 657
    <script>
658
 
659
// Globals
660
var picturesAreLoaded = false;
661
var xml = '';
662
var category = '';
663
var catalogTitle = '';
664
var catalogActorNames = '';
665
var listItems = [];
666
var additionalPictures = [];
170 - 667
var additionalPicturesToMove = [];
2 - 668
var isManualMode = false;
669
var isDuplicate = false;
670
var eBayProductId = '';
151 - 671
var releaseInTitle = false;
2 - 672
 
673
var CC = -1; /* 0=Book, 1=CD, 2=DVD, 3=Trading Card */
674
var ShippingProfileIdList = ['146987753023', '146987646023', '146987753023', '125181485023'];
675
var ShippingProfileNameList = ['Free Economy Shipping', 'Free Standard Shipping', 'Free Economy Shipping', 'Trading Card without Tracking Number'];
170 - 676
var MinPriceList = ['5.98', '5.95', '5.95', '0.99'];
2 - 677
var ProductListingDetailsNameList = ['ISBN', 'UPC', 'UPC', 'UPC'];
678
var StoreCategoryList = ['30460217018', '30432075018', '30606323018', '1'];
679
var movieFormats = ["DVD", "Blu-ray Disc", "HD DVD"];
680
var auctionFormat = ['FixedPriceItem', 'FixedPriceItem', 'FixedPriceItem', 'Chinese'];
681
var discogsQty = 0;
682
 
683
var ConditionIdList = ['2750', '4000', '4000', '4000'];
684
var ConditionDescriptionList = ['The book is in mint condition and shows only slight cover wear due to shelf storage. The cover and binding are undamaged and the pages have no markings or writing. Please view all images of the actual book.',
142 - 685
    'The disc is in near mint/mint condition and has been tested by us. The jewel case is in great shape, the inside tray is intact. Please view the actual images.',
686
    'The case is in good shape, the disc in near mint/mint condition. Please view the actual images.',
6 - 687
    'The card is in near mint/mint condition and will be mailed out in a sleeve within 1 business day after payment cleared. Expedited service with tracking number and top loader is available at an extra charge.'
2 - 688
];
689
 
142 - 690
var ConditionDescriptionCdPlural = 'The discs are in near mint/mint condition and have been tested by us. The jewel case is in great shape, the inside trays are intact. Please view the actual images.';
691
var ConditionDescriptionCdNewCase = 'The disc is in near mint/mint condition and comes in a new jewel case. Please view the actual images.';
692
var ConditionDescriptionCdDigipak = 'The disc is in near mint/mint condition and has been tested by us. The digipak is in good shape, the inside tray intact. Please view the actual images.';
2 - 693
 
30 - 694
var Description1 = '<meta name="viewport" content="width=device-width, initial-scale=1.0"><style>.w3-ol{list-style-type:1}.w3-ol li{padding:8px 16px;border-bottom:1px solid #ddd}.w3-ol li:last-child{border-bottom:none} img {max-width:100%}.tabs {max-width:90%;float:none;list-style: none;margin: 0 auto;}.tabs:after {content:"";display:table;clear: both;}.tabs input[type=radio] {display:none;}.tabs label {opacity:0.5;display:block;font-size:30px;font-weight:normal;text-decoration:none;text-align:center;line-height:2;cursor:pointer;-webkit-transition:all 0.5s;transition:all 0.5s;}.tabs label span {display:inline-block;float:left;}.tabs label:hover {opacity:1;}.tab-content {display:none;width:100%;float:left;padding:8px 16px;box-shadow:0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);border-radius:8px;background-color:#ffffff;}.tab-content * {-webkit-animation:scale 0.7s ease-in-out;-moz-animation:scale 0.7s ease-in-out;animation:scale 0.7s ease-in-out;}@keyframes scale {0% {transform:scale(0.9);opacity:0;}50% {transform:scale(1.01);opacity:0.5;}100% {transform:scale(1);opacity:1;}}.tabs [id^="tab"]:checked + label { opacity:1; }#tab1:checked ~ #tab-content1, #tab2:checked ~ #tab-content2, #tab3:checked ~ #tab-content3 {display:block;}.header-logo { max-height:100px!important; }.header-company-name { font-size:64px!important; }.header-button-1, .header-button-2, .header-button-3, .header-button-4, .header-button-5 {	}.header-icon-text { font-size:30px!important; }.header-icon { width:50px!important; height:50px!important;}.paypal-logo { max-height:100px!important; }.tab-alternate-header {	display:none!important; }@media only screen and (max-width:780px) {.header-logo { max-height:80px!important; }.header-company-name { font-size:48px!important; }.header-button-2, .header-button-3, .header-button-5 { display:none!important; }.header-icon-text { font-size:24px!important; }.header-icon { width:45px!important; height:45px!important;}.paypal-logo { max-height:80px!important; }.tabs {max-width:100%!important;}.tab-button { display:none!important; }.tab-alternate-header { display:block!important; }#tab-content1, #tab-content2, #tab-content3 { display:block!important; }}@media only screen and (max-width:500px) {.header-logo { max-height:60px!important; }.header-company-name { font-size:32px!important; }.header-button-2, .header-button-3, .header-button-4, .header-button-5 { display:none!important; }.header-icon-text { font-size:20px!important; }.header-icon { width:40px!important; height:40px!important;}.paypal-logo { max-height:60px!important; }.tabs {max-width:100%!important;}.tab-button { display:none!important; }.tab-alternate-header {	display:block!important; }#tab-content1, #tab-content2, #tab-content3 { display:block!important; }}</style><link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"><div class="w3-main"><div class="w3-container  w3-light-grey w3-text-black  w3-round-large" style="background-color:hsla(200, 100%, 25%, .8);"><div class="w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Clipboard" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_clipboard_1055091.png"> Product Description</h2></div><div class="row "><!-- *************** Place description here ****************** --><div class="w3-container  w3-twothird">';
695
var Description2 = '</div><div class="w3-container  w3-third"><img class="w3-image w3-border w3-right" alt="';
2 - 696
var Description2a = '" src="';
697
var DescImage;
151 - 698
var Description3 = '"></div><!-- *************** Place description here ****************** --></div></div><div class="w3-container  w3-light-grey w3-text-black  w3-round-large" style="background-color:hsla(200, 100%, 25%, .8);"><div class="tabs "><!-- Radio button and label for #tab-content1 --><input name="tabs" id="tab1" checked="" type="radio"><label for="tab1"><span class="tab-button header-icon-text  w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><img class="header-icon" alt="Credit Card" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_creditcard_1055079.png"> Payments</span></label><!-- Radio button and label for #tab-content2 --><input class="tab-button" name="tabs" id="tab2" type="radio"><label for="tab2"><span class="tab-button header-icon-text  w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><img class="header-icon" alt="Dolly" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_dolly_1055070.png"> Shipping</span></label><!-- Radio button and label for #tab-content3 --><input class="tab-button" name="tabs" id="tab3" type="radio"><label for="tab3"><span class="tab-button header-icon-text  w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><img class="header-icon" alt="Delivery Truck" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_truck_1054949.png"> Return</span> </label><div id="tab-content1" class="tab-content"><div class="tab-alternate-header w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Credit Card" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_creditcard_1055079.png"> Payments</h2></div><img class="paypal-logo w3-image w3-right " alt="PayPal Seal" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/paypal-verified.png"><p>We accept PayPal and all major credit cards through secure eBay Managed Payments.</p><ul><li>Taxes may be applicable at checkout.</li><li>Payment must be received in full within 3 days from the date of purchase.</li><li>We leave positive eBay feedback as soon as the payment clears.</li></ul></div><!-- #tab-content1 --><div id="tab-content2" class="tab-content"><div class="tab-alternate-header w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Dolly" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_dolly_1055070.png"> Shipping</h2></div>';
2 - 699
var DescriptionFreeShipping = '<p>We offer free USPS Economy or Media Mail, expedited service is available at an additional cost.</p>';
700
var DescriptionTradingCardShipping = '<p>Standard USPS shipping without Tracking Number. Expedited service with tracking number and top loader available at an extra cost.</p>';
30 - 701
var Description4 = '<ul><li>All items will be shipped from the United States.</li><li>We will only ship to the confirmed PayPal address. Please make sure it matches your shipping address.</li><li>Shipping Monday through Saturday, excluding federal holidays, within 24 hours after payment is received.</li><li>If a tracking number is provided by the shipping carrier, we will update your order with the tracking information.</li><li>Shipping Outside of the United States incurs additional shipping charges.</li></ul></div><!-- #tab-content2 --><div id="tab-content3" class="tab-content"><div class="tab-alternate-header w3-center w3-text-white w3-round-large w3-border-white w3-topbar w3-bottombar w3-rightbar w3-leftbar " style="background-color:hsla(200, 100%, 25%, .8);"><h2 class="header-icon-text"><img class="header-icon" alt="Delivery Truck" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_truck_1054949.png"> Return</h2></div><p>Please <a href="https://contact.ebay.com/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=muna_trading" target="_blank">contact us</a> before returning an item or leaving negative feedback. We will get back to you immediately and work with you to make your purchase right. </p></div><!-- #tab-content3 --></div></div><footer class="w3-container w3-center"><div class="w3-container w3-center "><a class="header-button-1 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://stores.ebay.com/munatrading" target="_blank"><img alt="Sales Tag" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_shop_1054978.png" width="35px" height="35px"> Other Items</a><a class="header-button-2 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&amp;userid=muna_trading&amp;ftab=AllFeedback" target="_blank"><img alt="Paper and pencil" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_compose_1055085.png" width="35px" height="35px"> Feedbacks</a><a class="header-button-3 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://www.ebay.com/usr/muna_trading" target="_blank"><img alt="Contacts" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_contacts_1055082.png" width="35px" height="35px"> About Us</a><a class="header-button-4 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://contact.ebay.com/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=muna_trading" target="_blank"><img alt="Envelope" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_mail_1055030.png" width="35px" height="35px"> Contact Us</a><a class="header-button-5 w3-button w3-round-xlarge w3-border w3-border-black w3-white" href="https://my.ebay.com/ws/eBayISAPI.dll?AcceptSavedSeller&amp;mode=0&amp;preference=0&amp;ssPageName=STRK:MEFS:ADDMP&amp;sellerid=muna_trading" target="_blank"><img alt="Heart" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/if_heart_1055045.png" width="35px" height="35px"> Add To Favorites</a></div><div class="w3-container w3-center "><img class="header-logo w3-image" src="https://cdn.shopify.com/s/files/1/0018/0273/1609/files/MUNA_-_Logo_100x100.png" alt="MUNA Logo"></div><p>Thanks so much for looking at our auction and please do not hesitate to <a href="https://contact.ebay.com/ws/eBayISAPI.dll?ContactUserNextGen&amp;recipient=muna_trading" target="_blank">contact us</a> should you have any questions!</p></footer></div>';
2 - 702
var DescCore = '';
703
var ImageURLs = [];
30 - 704
var maxAdditionalImages = 8;
2 - 705
var imagesToUpload = 0;
706
var imageUploadError = false;
147 - 707
var ImageRetryCount = [];
708
var TitleRetryCount = [];
2 - 709
var titlesToRead = 0;
710
var upc = '';
711
 
712
 
713
// Initialize Configuration Variables
714
function initConfig() {
6 - 715
    var i;
716
    var j;
2 - 717
 
6 - 718
    eBayAuthToken = readCookie();
719
    if (eBayAuthToken.length > 0) {
720
        connected();
721
    }
2 - 722
 
6 - 723
    if (eBayAuthTokenFlag === false) {
724
        var x = document.getElementById("login");
725
        if (x.className.indexOf("w3-show") == -1) {
726
            x.className += " w3-show";
727
        }
728
    }
2 - 729
 
6 - 730
    categoryValues();
731
    requireNewVerify();
2 - 732
 
10 - 733
    $('#listForm').on('change input cut paste',requireNewVerify);
734
    $('#bookForm').on('change input cut paste',requireNewVerify);
735
    $('#cdForm').on('change input cut paste',requireNewVerify);
736
    $('#dvdForm').on('change input cut paste',requireNewVerify);
737
    $('#tradingCardForm').on('change input cut paste',requireNewVerify);
30 - 738
 
6 - 739
    var xhttp = new XMLHttpRequest();
740
    xhttp.onreadystatechange = function() {
741
        if (this.readyState == 4 && this.status == 200) {
742
            //window.alert(this.responseText);
2 - 743
 
6 - 744
            var parser = new DOMParser();
745
            var htmlDoc = parser.parseFromString(this.responseText, "text/html");
746
            var x = htmlDoc.getElementsByTagName("a");
2 - 747
 
6 - 748
            listItems = [];
749
            additionalPictures = [];
750
            titlesToRead = 0;
147 - 751
            TitleRetryCount = [];
2 - 752
 
6 - 753
            for (i = 0, j = 0; i < x.length; i++) {
754
                if (htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configImage1Extension)) {
755
                    var n = htmlDoc.getElementsByTagName("a")[i].innerHTML.lastIndexOf(configImage1Extension);
756
                    listItems[j] = htmlDoc.getElementsByTagName("a")[i].innerHTML.substr(0, n);
757
                    ++titlesToRead;
758
                    getTitleFromeBay(listItems[j], j);
759
                    j++;
760
                }
761
            }
2 - 762
 
6 - 763
            for (i = 0; i < x.length; i++) {
764
                if (htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configImage1Extension) ||
765
                    htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configImage2Extension) ||
766
                    htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(configdescriptionImageExtension)) {
767
                    continue;
768
                }
2 - 769
 
6 - 770
                if (htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(".jpg")) {
771
                    for (j = 0; j < listItems.length; j++) {
772
                        if (htmlDoc.getElementsByTagName("a")[i].innerHTML.startsWith(listItems[j]) && !htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(" - small.jpg")) {
773
                            if (additionalPictures[j] === undefined) {
774
                                additionalPictures[j] = [];
775
                            }
776
                            additionalPictures[j].push(htmlDoc.getElementsByTagName("a")[i].innerHTML);
170 - 777
                        } else if (htmlDoc.getElementsByTagName("a")[i].innerHTML.startsWith(listItems[j]) && htmlDoc.getElementsByTagName("a")[i].innerHTML.endsWith(" - small.jpg")) {
778
                            if (additionalPicturesToMove[j] === undefined) {
779
                                additionalPicturesToMove[j] = [];
780
                            }
781
                            additionalPicturesToMove[j].push(htmlDoc.getElementsByTagName("a")[i].innerHTML);
6 - 782
                        }
783
                    }
784
                }
785
            }
30 - 786
 
6 - 787
            function checkTitlesToRead() {
788
                if (titlesToRead > 0) {
789
                    window.setTimeout(checkTitlesToRead, 100); // wait 100 milliseconds
790
                } else {
791
                    sortList(document.getElementById("keyword"));
30 - 792
                    $("#keyword").selectpicker('refresh');
6 - 793
                    document.getElementById("bookDetails").className += " w3-hide";
794
                    document.getElementById("cdDetails").className += " w3-hide";
795
                    document.getElementById("dvdDetails").className += " w3-hide";
796
                }
797
            }
2 - 798
 
6 - 799
            checkTitlesToRead();
30 - 800
 
6 - 801
        }
802
    };
803
    xhttp.open("GET", configListingUrl + '?t=' + Math.random(), true);
804
    xhttp.send();
2 - 805
 
806
}
807
 
808
function sortList(lb) {
6 - 809
    var arrTexts = [];
810
    var res;
811
    var i;
30 - 812
    var lbCopy = $.extend(true, {}, lb);
2 - 813
 
30 - 814
    for (i = 0; i < lb.length; i++) {
815
        arrTexts[i] = lb.options[i].style.color + '|' + lb.options[i].id + '|' + lb.options[i].text + '|' + i;
6 - 816
    }
2 - 817
 
6 - 818
    arrTexts.sort();
2 - 819
 
6 - 820
    for (i = 0; i < arrTexts.length; i++) {
821
        res = arrTexts[i].split('|');
30 - 822
        lb[i] =  lbCopy[res[3]];
6 - 823
    }
2 - 824
}
825
 
826
function getTitleFromeBay(identifier, index) {
147 - 827
    var maxRetries = 5;
828
    if (TitleRetryCount[index] === undefined){
829
        TitleRetryCount[index] = 0;
830
    }
831
 
6 - 832
    // Construct the request
833
    url = configeBayShopping + "?";
834
    url += "callname=FindProducts";
835
    url += "&version=" + configeBayShoppingVersion;
836
    url += "&appid=" + configAppid;
837
    url += "&responseencoding=JSON";
838
    url += "&siteid=0";
839
    url += "&MaxEntries=1";
840
    url += "&MessageID=";
841
    url += index;
115 - 842
    if (isNumeric(identifier)) {
126 - 843
        url += "&ProductID.Type=UPC&ProductID.Value=" + identifier.trim();
115 - 844
    } else {
845
        url += "&QueryKeywords=";
846
        url += encodeURIComponent(identifier.trim().replace(/ /g, "+"));
847
    }
2 - 848
 
6 - 849
    var xhttp = new XMLHttpRequest();
2 - 850
 
6 - 851
    xhttp.onreadystatechange = function() {
147 - 852
        if (this.readyState == 4 && this.status == 200) {
853
            if (this.responseText) {
854
                _cb_getTitleFromeBay(JSON.parse(this.responseText));
855
            } else {
856
                if (TitleRetryCount[index] < maxRetries){
857
                    ++TitleRetryCount[index];
858
                    getTitleFromeBay(identifier, index);
859
                } else {
860
                    _cb_getTitleFromeBay(JSON.parse('{"Ack":"NO RETURN DATA"}'));
861
                }
862
            }
6 - 863
        }
864
    };
2 - 865
 
6 - 866
    xhttp.open("GET", configProxyUrl, true);
126 - 867
    xhttp.setRequestHeader("X-Proxy-Url", /*encodeURI(*/url/*)*/);
6 - 868
    xhttp.send();
2 - 869
 
6 - 870
    return false;
2 - 871
}
872
 
873
// Create new page for single item
874
function _cb_getTitleFromeBay(root) {
6 - 875
    var optionsAsString;
876
    var JsonObj;
877
    var color;
2 - 878
 
147 - 879
    if (root.Ack == 'NO RETURN DATA') {
880
        /* No correlation id */
881
    } else if (root.Ack != 'Success') {
6 - 882
        color = 'purple';
53 - 883
        if (isNumeric(listItems[root.CorrelationID])) {
884
            var validator = new Barcoder();
885
            var validation = validator.validate(listItems[root.CorrelationID]);
886
 
887
            if (!validation.isValid) {
6 - 888
                    color = 'red';
889
            }
890
        }
2 - 891
 
30 - 892
        optionsAsString = "<option class='small' id='" + escapeHtml(listItems[root.CorrelationID]) + "' " + "value='" + escapeHtml(listItems[root.CorrelationID]) + "'>" + listItems[root.CorrelationID] + "</option>";
6 - 893
        document.getElementById("keyword").innerHTML += optionsAsString;
894
        document.getElementById(listItems[root.CorrelationID]).style.color = color;
895
    } else {
896
        JsonObj = typeof root.Product[0] != 'object' ? JSON.parse(root.Product[0]) : root.Product[0];
30 - 897
        optionsAsString = "<option class='small'' id='" + escapeHtml(listItems[root.CorrelationID]) + "' " + "value='" + escapeHtml(listItems[root.CorrelationID]) + "'>" + listItems[root.CorrelationID] + " - " + JsonObj.Title + "</option>";
6 - 898
        document.getElementById("keyword").innerHTML += optionsAsString;
899
    }
2 - 900
 
6 - 901
    --titlesToRead;
2 - 902
}
903
 
904
// Create new page for single item
905
function _cb_FindProducts(root) {
6 - 906
    var j;
907
    var x;
908
    var ack = root.Ack;
909
    var MoreResults = root.MoreResults;
2 - 910
 
151 - 911
    if (ack != 'Success' || MoreResults) { // bugbug allow to look at all results
6 - 912
        x = document.getElementById("productinfo");
30 - 913
        y = document.getElementById("productinfoSearch");
6 - 914
        if (root.Errors !== undefined && root.Errors[0].ShortMessage != 'No match found.') {
915
            x.innerHTML = "<h2>eBay API Error<h2>";
916
            x.innerHTML += "<p>Id: " + root.Errors[0].ErrorCode + "<br/>";
917
            x.innerHTML += "Domain: " + root.Errors[0].ErrorClassification + "<br/>";
918
            x.innerHTML += "Severity: " + root.Errors[0].SeverityCode + "<br/>";
919
            x.innerHTML += "Category: " + root.Errors[0].category + "<br/>";
920
            x.innerHTML += "Short Message: " + root.Errors[0].ShortMessage + "<br/>";
921
            x.innerHTML += "Long Message: " + root.Errors[0].LongMessage + "<br/>";
922
            x.innerHTML += "Build/Version: " + root.Build + '/' + root.Version + "</p>";
923
            x.innerHTML += "<p>URL: " + "<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>" + "</p>";
924
        } else {
30 - 925
            x.innerHTML = '<h2 class="bg-danger">Manual Mode</h3>';
6 - 926
            x.innerHTML += "<h3>" + document.getElementById("keyword").value + "</h3>";
30 - 927
            catalogTitle = document.getElementById("keyword").value.trim();
6 - 928
            if (isNumeric(catalogTitle)) {
929
                if (catalogTitle.startsWith('978') || catalogTitle.startsWith('979')) {
30 - 930
                    y.innerHTML += '<a href="https://isbnsearch.org/isbn/' + catalogTitle + '" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> ISBN Search</button></a>';
931
                    y.innerHTML += '<a href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dpopular&field-keywords=' + catalogTitle + '" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> Amazon</button></a>';
97 - 932
                    y.innerHTML += '<a href="https://munatrading.linkpc.net/ebay/search.html?keyword=' + catalogTitle.trim().replace(/ /g, "+").substr(0, 98) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> eBay</button></a>';
6 - 933
                } else {
30 - 934
                    y.innerHTML += '<a href="https://dvdlist.kazart.com/queryDVDList.php3?search=' + catalogTitle + '&select=UPC&Submit=Search&since=All&genre=All&date=All&status=All&sort1=title&sort1by=ASC&sort2=year&sort2by=ASC&sort3=genre&sort3by=ASC" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> Kazart</button></a>';
935
                    y.innerHTML += '<a href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dpopular&field-keywords=' + catalogTitle + '" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> Amazon</button></a>';
97 - 936
                    y.innerHTML += '<a href="https://munatrading.linkpc.net/ebay/search.html?keyword=' + catalogTitle.trim().replace(/ /g, "+").substr(0, 98) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> eBay</button></a>';
6 - 937
                }
938
            } else {
939
                catalogTitle = document.getElementById("keyword").value.trim();
940
                splitTradingCardElements();
941
                fillForm();
2 - 942
 
97 - 943
                y.innerHTML += '<a href="https://munatrading.linkpc.net/ebay/search.html?keyword=' + catalogTitle.trim().replace(/ /g, "+").substr(0, 98) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> eBay</button></a>';
6 - 944
            }
2 - 945
 
6 - 946
            printManualButtons();
947
        }
2 - 948
 
6 - 949
        unsetAdditionalImages();
2 - 950
 
6 - 951
        for (i = 0; i < additionalPictures.length; i++) {
952
            if (additionalPictures[i] !== undefined && additionalPictures[i][0].startsWith(document.getElementById("keyword").value.trim())) {
953
                if (additionalPictures[i].length > maxAdditionalImages) {
30 - 954
                    document.getElementById("productinfo").innerHTML += '<p class="bg-danger"><strong>Too many additional images.</a></strong></p>';
6 - 955
                } else {
956
                    for (j = 0; j < additionalPictures[i].length; j++) {
957
                        setAdditionalImage(j + 3, additionalPictures[i][j]);
958
                    }
959
                }
960
            }
961
        }
2 - 962
 
6 - 963
        document.getElementById("image1").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage1Extension;
964
        document.getElementById("image2").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage2Extension;
965
        document.getElementById("descriptionImage").src = configListingUrl + document.getElementById("keyword").value.trim() + configdescriptionImageExtension;
966
        document.getElementById("image1anchor").href = document.getElementById("image1").src;
967
        document.getElementById("image2anchor").href = document.getElementById("image2").src;
2 - 968
 
6 - 969
        isManualMode = true;
970
        catalogActorNames = '';
2 - 971
 
6 - 972
        isDuplicate = false;
973
        findDuplicateListing();
974
        findPotentialDuplicateListing();
975
        findShopifyDuplicateListing();
2 - 976
 
6 - 977
        upc = catalogTitle;
2 - 978
 
6 - 979
        return;
980
    }
2 - 981
 
6 - 982
    isManualMode = false;
2 - 983
 
6 - 984
    var str = "";
30 - 985
    var str2 = "";
6 - 986
    var i = 0;
987
    var JsonObj = typeof root.Product[0] != 'object' ? JSON.parse(root.Product[0]) : root.Product[0];
2 - 988
 
6 - 989
    var DetailsURL = JsonObj.DetailsURL;
990
    var ItemSpecifics = JsonObj.ItemSpecifics;
991
    var StockPhotoURL = JsonObj.StockPhotoURL;
992
    var ProductID = JsonObj.ProductID;
993
    var TotalProducts = Number(root.TotalProducts);
994
    var searchStr = '';
995
    var munaSearchStr = '';
2 - 996
 
6 - 997
    catalogTitle = JsonObj.Title;
998
    catalogActorNames = '';
2 - 999
 
6 - 1000
    str = '';
1001
    DescCore = '';
2 - 1002
 
6 - 1003
    if (StockPhotoURL && StockPhotoURL.length > 1) {
1004
        if (DetailsURL && DetailsURL.length > 1) {
1005
            str += '<a href="' + DetailsURL + '" target="_blank">';
1006
        }
30 - 1007
        str += '<img class="img-fluid float-right " src="' + StockPhotoURL + '" alt="Gallery Image" style="max-height:100px;max-width:100px;">';
6 - 1008
        if (DetailsURL && DetailsURL.length > 1) {
1009
            str += '</a>';
1010
        }
1011
    }
2 - 1012
 
6 - 1013
    str += '<h3>' + catalogTitle + '</h3>';
2 - 1014
 
30 - 1015
    str += '<table class="table-bordered"><tbody>';
2 - 1016
 
6 - 1017
    eBayProductId = '';
1018
    upc = catalogTitle;
1019
    if (ProductID) {
1020
        for (i = 0; i < ProductID.length; i++) {
1021
            if (ProductID[i].Type == 'Reference') {
30 - 1022
                str += '<tr><td>' + ProductID[i].Type + '</td><td>' + ProductID[i].Value + '</td></tr>';
6 - 1023
                munaSearchStr = 'ReferenceID%3A' + ProductID[i].Value;
1024
                eBayProductId = ProductID[i].Value;
1025
            } else {
30 - 1026
                str += '<tr><td>' + ProductID[i].Type + '</td><td>' + ProductID[i].Value + '</td></tr>';
6 - 1027
                searchStr = ProductID[i].Value;
1028
                if (ProductID[i].Type == 'UPC') {
1029
                    upc = ProductID[i].Value;
1030
                }
1031
            }
1032
        }
1033
    }
2 - 1034
 
6 - 1035
    if (ItemSpecifics) {
1036
        for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
30 - 1037
            str += '<tr><td>' + ItemSpecifics.NameValueList[i].Name + '</td><td>' + ItemSpecifics.NameValueList[i].Value + '</td></tr>';
2 - 1038
 
6 - 1039
            if (ItemSpecifics.NameValueList[i].Name == 'Leading Role') {
1040
                catalogActorNames = ItemSpecifics.NameValueList[i].Value;
1041
            }
1042
        }
1043
    }
2 - 1044
 
30 - 1045
    str += '</tbody></table>';
2 - 1046
 
6 - 1047
    if (MoreResults) {
30 - 1048
        str += '<p class="float-right bg-danger">' + TotalProducts + ' Products found</p>';
6 - 1049
    }
2 - 1050
 
6 - 1051
    if (catalogTitle.includes(movieFormats[0]) || catalogTitle.includes(movieFormats[1]) || catalogTitle.includes(movieFormats[2])) {
30 - 1052
        str2 += '<a href="https://dvdlist.kazart.com/queryDVDList.php3?search=' + searchStr + '&select=UPC&Submit=Search&since=All&genre=All&date=All&status=All&sort1=title&sort1by=ASC&sort2=year&sort2by=ASC&sort3=genre&sort3by=ASC" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> Kazart</button></a>';
6 - 1053
    } else if (catalogTitle.includes('Paperback') || catalogTitle.includes('Hardcover')) {
30 - 1054
        str2 += '<a href="https://isbnsearch.org/isbn/' + searchStr + '" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> ISBN Search</button></a>';
6 - 1055
    }
2 - 1056
 
30 - 1057
    str2 += '<a href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=' + searchStr + '" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> Amazon</button></a>';
97 - 1058
    str2 += '<a href="https://munatrading.linkpc.net/ebay/search.html?keyword=' + (munaSearchStr.length > 0 ? munaSearchStr : catalogTitle.trim().replace(/ /g, "+").substr(0, 98)) + '&listingType=All&hideDuplicateItems=on&locatedIn=WorldWide&sortOrder=PricePlusShippingLowest&results=100" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> eBay</button></a>';
2 - 1059
 
6 - 1060
    x = document.getElementById("productinfo");
1061
    x.innerHTML = str;
30 - 1062
    x = document.getElementById("productinfoSearch");
1063
    x.innerHTML = str2;
2 - 1064
 
1065
 
6 - 1066
    isDuplicate = false;
1067
    findDuplicateListing();
1068
    findPotentialDuplicateListing();
1069
    findShopifyDuplicateListing();
2 - 1070
 
6 - 1071
    fillForm(ItemSpecifics);
2 - 1072
}
1073
 
1074
function printManualButtons() {
6 - 1075
    var x = document.getElementById("productinfo");
1076
    if (!x.innerHTML.includes('fillManualForm0')) {
1077
        x.innerHTML += '<p><br/></p>';
30 - 1078
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm0" class="btn btn-dark btn-xs mx-2 border" onclick="fillManualForm(0)">Book Form</a>';
1079
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm1" class="btn btn-dark btn-xs mx-2 border" onclick="fillManualForm(1)">CD Form</a>';
1080
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm2" class="btn btn-dark btn-xs mx-2 border" onclick="fillManualForm(2)">DVD Form</a>';
1081
        x.innerHTML += '<a href="javascript:void(0)" id="fillManualForm3" class="btn btn-dark btn-xs mx-2 border" onclick="fillManualForm(3)">Trading Card Form</a>';
1082
        x.innerHTML += '<p><br/></p>';
6 - 1083
    }
2 - 1084
}
1085
 
1086
function setAdditionalImage(imageNumber, imageName) {
6 - 1087
    if (imageName !== undefined) {
1088
        document.getElementById("image" + imageNumber).src = configListingUrl + imageName.trim();
30 - 1089
        document.getElementById("image" + imageNumber + "anchor").className = document.getElementById("image" + imageNumber + "anchor").className.replace(" invisible", " visible");
6 - 1090
        document.getElementById("image" + imageNumber + "anchor").href = document.getElementById("image" + imageNumber).src;
1091
    }
2 - 1092
}
1093
 
1094
function unsetAdditionalImages() {
30 - 1095
    for (var i = 0; i < maxAdditionalImages; i++) {
1096
        document.getElementById("image" + (i+3)).src = 'images/default-image.png';
1097
        document.getElementById("image" + (i+3) + "anchor").className = document.getElementById("image" + (i+3) + "anchor").className.replace(" visible", " invisible");
1098
        document.getElementById("image" + (i+3) + "anchor").href = '#';
6 - 1099
    }
2 - 1100
}
1101
 
1102
function requireNewVerify() {
6 - 1103
    listButtonHot(false);
2 - 1104
}
1105
 
1106
function requireNewLogin() {
6 - 1107
    // dummy
2 - 1108
}
1109
 
1110
function hideDetailWindows() {
6 - 1111
    var x, y;
2 - 1112
 
6 - 1113
    x = document.getElementById("bookDetails");
1114
    x.className = x.className.replace(" w3-show", "");
1115
    document.getElementById("bookForm").reset();
1116
    x = document.getElementById("cdDetails");
1117
    x.className = x.className.replace(" w3-show", "");
1118
    document.getElementById("cdForm").reset();
1119
    x = document.getElementById("dvdDetails");
1120
    x.className = x.className.replace(" w3-show", "");
1121
    document.getElementById("dvdForm").reset();
1122
    x = document.getElementById("tradingCardDetails");
1123
    x.className = x.className.replace(" w3-show", "");
1124
    document.getElementById("tradingCardForm").reset();
1125
    document.getElementById("cdTracks").innerHTML = "";
1126
    document.getElementById("cdUnorderedTrackList").checked = false;
10 - 1127
    updateTracklistPreview();
2 - 1128
 
6 - 1129
    for (var imageNumber = 0; imageNumber < maxAdditionalImages; imageNumber++) {
1130
        x = document.getElementById("image" + (imageNumber + 3) + "anchor");
1131
        y = document.getElementById("image" + (imageNumber + 3));
2 - 1132
 
30 - 1133
        x.className = x.className.replace(" visible", " invisible");
1134
        x.href = '#';
1135
        y.src = 'images/default-image.png';
6 - 1136
    }
2 - 1137
}
1138
 
1139
var url = "";
1140
 
1141
function findOneBay() {
6 - 1142
    var n;
1143
    var keyword;
2 - 1144
 
30 - 1145
    if (document.getElementById("list").className.includes("btn-success")) {
6 - 1146
        alert("Listing verified but not yet submitted");
1147
        return;
1148
    }
2 - 1149
 
6 - 1150
    requireNewVerify();
2 - 1151
 
6 - 1152
    hideDetailWindows();
2 - 1153
 
6 - 1154
    ImageURLs = [];
2 - 1155
 
6 - 1156
    if (!document.getElementById("keyword").value) {
1157
        return false;
1158
    }
2 - 1159
 
6 - 1160
    if (document.getElementById("keyword").value.endsWith(" Front")) {
1161
        n = document.getElementById("keyword").value.lastIndexOf(" Front");
1162
        document.getElementById("keyword").value = document.getElementById("keyword").value.substr(0, n);
1163
    } else if (document.getElementById("keyword").value.endsWith(" Rear")) {
1164
        n = document.getElementById("keyword").value.lastIndexOf(" Rear");
1165
        document.getElementById("keyword").value = document.getElementById("keyword").value.substr(0, n);
1166
    }
2 - 1167
 
6 - 1168
    keyword = document.getElementById('keyword').value;
2 - 1169
 
6 - 1170
    // Clear results outputs button
1171
    clearStatusWindows();
30 - 1172
    document.getElementById("productinfoSearch").innerHTML = "";
1173
    document.getElementById("productinfoDuplicate").innerHTML = "";
2 - 1174
 
6 - 1175
    discogsQty = 1;
2 - 1176
 
6 - 1177
    // Construct the request
1178
    url = configeBayShopping + "?";
1179
    url += "callname=FindProducts";
1180
    url += "&version=" + configeBayShoppingVersion;
1181
    url += "&appid=" + configAppid;
1182
    url += "&responseencoding=JSON";
1183
    url += "&siteid=0";
1184
    url += "&MaxEntries=1";
115 - 1185
    if (isNumeric(keyword)) {
126 - 1186
        url += "&ProductID.Type=UPC&ProductID.Value=" + keyword.trim();
115 - 1187
    } else {
1188
        url += "&QueryKeywords=";
1189
        url += encodeURIComponent(keyword.trim().replace(/ /g, "+")).substr(0, 98);
1190
    }
2 - 1191
 
6 - 1192
    var xhttp = new XMLHttpRequest();
2 - 1193
 
6 - 1194
    xhttp.onreadystatechange = function() {
147 - 1195
        if (this.readyState == 4 && this.status == 200) {
151 - 1196
            if (this.responseText) {
1197
                _cb_FindProducts(JSON.parse(this.responseText));
1198
            } else {
1199
                findOneBay();
1200
            }
6 - 1201
        }
1202
    };
2 - 1203
 
6 - 1204
    xhttp.open("GET", configProxyUrl, true);
1205
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
1206
    xhttp.send();
2 - 1207
 
6 - 1208
    getPricing();
2 - 1209
 
6 - 1210
    return false;
2 - 1211
}
1212
 
1213
function fillForm(ItemSpecifics) {
6 - 1214
    var eBayTitle;
1215
    var fieldName;
1216
    var field;
1217
    var n;
1218
    var i;
1219
    var j;
1220
    var x;
1221
    var movieIndex = 0;
1222
    var titleField = document.getElementById("title");
2 - 1223
 
6 - 1224
    eBayTitle = catalogTitle;
1225
    if (catalogActorNames.length > 0) {
1226
        eBayTitle += ' ' + catalogActorNames.join(', ');
1227
    }
2 - 1228
 
6 - 1229
    document.getElementById("title").value = eBayTitle;
1230
    printTitleLength();
2 - 1231
 
6 - 1232
    if (catalogTitle.includes("(CD")) {
1233
        findDiscogsReleases(document.getElementById("keyword").value);
2 - 1234
 
6 - 1235
        x = document.getElementById("cdDetails");
1236
        if (x.className.indexOf("w3-show") == -1) {
1237
            x.className += " w3-show";
1238
        }
2 - 1239
 
6 - 1240
        if (!isManualMode) {
1241
            titleField.value = reformatCdTitle(catalogTitle);
1242
            printTitleLength();
1243
        }
2 - 1244
 
6 - 1245
        if (titleField.value.endsWith(' (Label))')) {
1246
            titleField.value = titleField.value.substr(0, titleField.value.indexOf(' (Label))')) + ')';
1247
            printTitleLength();
1248
        }
2 - 1249
 
6 - 1250
        if (titleField.value.endsWith(' (USA))')) {
1251
            titleField.value = titleField.value.substr(0, titleField.value.indexOf(' (USA))')) + ')';
1252
            printTitleLength();
1253
        }
2 - 1254
 
6 - 1255
        document.getElementById("cdCountry").value = configDefaultCountry;
36 - 1256
        document.getElementById("cdLanguage").value = configDefaultLanguage;
1257
        document.getElementById("cdModified").value = 'No';
1258
        $('#cdModified').prop('disabled', false).selectpicker('refresh');
1259
        document.getElementById("cdModificationDescription").value = '';
2 - 1260
 
6 - 1261
        if (ItemSpecifics) {
1262
            for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
1263
                fieldName = 'cd' + ItemSpecifics.NameValueList[i].Name.replace(/ /g, '');
1264
                field = document.getElementById(fieldName);
1265
                if (field) {
1266
                    field.value = ItemSpecifics.NameValueList[i].Value;
1267
                }
1268
            }
1269
        }
30 - 1270
        $('#cdGenre').prop('disabled', false).selectpicker('refresh');
2 - 1271
 
170 - 1272
        if (titleField.value.indexOf('EP,') > 0) {
6 - 1273
            document.getElementById("cdDuration").value = 'EP';
170 - 1274
        } else if (titleField.value.indexOf('Maxi-Single,') > 0 || titleField.value.indexOf('[Maxi Single]') > 0) {
6 - 1275
            document.getElementById("cdDuration").value = 'Maxi-Single';
170 - 1276
        } else if (titleField.value.indexOf('Single,') > 0) {
6 - 1277
            document.getElementById("cdDuration").value = 'Single';
1278
        }
30 - 1279
        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
2 - 1280
 
170 - 1281
        if (titleField.value.indexOf('Digipak,') > 0) {
6 - 1282
            document.getElementById("cdDigipak").checked = true;
170 - 1283
            setCdConditionDescription('D');
6 - 1284
        }
2 - 1285
 
6 - 1286
        if (document.getElementById("cdArtist").value.length < 1) {
1287
            if (titleField.value.substr(0, titleField.value.includes('Various Artists'))) {
1288
                document.getElementById("cdArtist").value = 'Various';
36 - 1289
            } else if (document.getElementById("cdArtist").value.length < 1) {
6 - 1290
                document.getElementById("cdArtist").value = titleField.value.substr(0, titleField.value.indexOf(' - '));
1291
            }
1292
        }
2 - 1293
 
36 - 1294
        if (document.getElementById("cdTitle").value.length < 1) {
1295
            var s = titleField.value.indexOf(' - ');
40 - 1296
            if (s == -1) { s = 0; }
1297
            var l = titleField.value.indexOf('(CD') - s;
1298
            if (s > 0) { s = s + 3; l = l - 3; }
1299
            document.getElementById("cdTitle").value = titleField.value.substr(s, l);
36 - 1300
        }
1301
 
6 - 1302
        if (document.getElementById("cdRecordLabel").value.length < 1) {
1303
            n = titleField.value.indexOf('(CD');
1304
            document.getElementById("cdRecordLabel").value = titleField.value.substr(n).substr(titleField.value.substr(n).lastIndexOf(',') + 2);
1305
            document.getElementById("cdRecordLabel").value = document.getElementById("cdRecordLabel").value.substr(0, document.getElementById("cdRecordLabel").value.lastIndexOf(')'));
1306
        }
2 - 1307
 
6 - 1308
        if (document.getElementById("cdReleaseYear").value.length < 1) {
1309
            n = titleField.value.indexOf('(CD');
1310
            document.getElementById("cdReleaseYear").value = getYear(titleField.value.substr(n));
1311
        }
2 - 1312
 
30 - 1313
        $('#category').selectpicker('val', "176984");
1314
        $('#category').selectpicker('refresh');
6 - 1315
        categoryValues();
30 - 1316
 
10 - 1317
        $('#cdTracks').on('change input cut paste',updateTracklistPreview);
6 - 1318
    } else if (catalogTitle.includes(movieFormats[0]) || catalogTitle.includes(movieFormats[1]) || catalogTitle.includes(movieFormats[2])) {
1319
        x = document.getElementById("dvdDetails");
1320
        if (x.className.indexOf("w3-show") == -1) {
1321
            x.className += " w3-show";
1322
        }
2 - 1323
 
6 - 1324
        document.getElementById("dvdCountry").value = configDefaultCountry;
2 - 1325
 
6 - 1326
        if (ItemSpecifics) {
1327
            for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
1328
                fieldName = 'dvd' + ItemSpecifics.NameValueList[i].Name.replace(/ /g, '');
1329
                field = document.getElementById(fieldName);
1330
                if (field) {
1331
                    field.value = ItemSpecifics.NameValueList[i].Value;
1332
                }
1333
            }
1334
        }
30 - 1335
        $('#dvdGenre').prop('disabled', false).selectpicker('refresh');
1336
        $('#dvdRating').prop('disabled', false).selectpicker('refresh');
1337
        $('#dvdRegionCode').prop('disabled', false).selectpicker('refresh');
1338
        $('#dvdRental').prop('disabled', false).selectpicker('refresh');
1339
        $('#dvdSeason').prop('disabled', false).selectpicker('refresh');
2 - 1340
 
6 - 1341
        for (i = 0; i < movieFormats.length; i++) {
1342
            if (catalogTitle.includes('(' + movieFormats[i])) {
30 - 1343
                $('#dvdFormat').selectpicker('val', movieFormats[i]);
6 - 1344
                movieIndex = i;
1345
            } else if (catalogTitle.includes('(HD-DVD')) {
30 - 1346
                $('#dvdFormat').selectpicker('val', 'HD DVD');
6 - 1347
                movieIndex = i;
1348
            }
1349
        }
30 - 1350
        $('#dvdFormat').prop('disabled', false).selectpicker('refresh');
2 - 1351
 
6 - 1352
        if (document.getElementById("dvdReleaseYear").value.length < 1) {
1353
            n = titleField.value.indexOf('(' + movieFormats[movieIndex]);
1354
            document.getElementById("dvdReleaseYear").value = getYear(titleField.value.substr(n));
1355
        }
2 - 1356
 
6 - 1357
        if (document.getElementById("dvdDVDEditionYear").value.length < 1) {
1358
            n = titleField.value.indexOf('(' + movieFormats[movieIndex]);
1359
            document.getElementById("dvdDVDEditionYear").value = getYear(titleField.value.substr(n));
1360
        }
2 - 1361
 
6 - 1362
        if (document.getElementById("dvdTitle").value.length < 1) {
1363
            n = titleField.value.lastIndexOf('(' + movieFormats[movieIndex]);
1364
            document.getElementById("dvdTitle").value = titleField.value.substr(0, n);
1365
        }
2 - 1366
 
6 - 1367
        if (titleField.value.indexOf("3D") > 0) {
1368
            document.getElementById("dvd3D").checked = true;
1369
        }
2 - 1370
 
6 - 1371
        if (titleField.value.indexOf("Anniversary") > 0) {
1372
            document.getElementById("dvdAnniversaryEdition").checked = true;
1373
        }
2 - 1374
 
6 - 1375
        if (titleField.value.indexOf("Collector") > 0) {
1376
            document.getElementById("dvdCollectorsEdition").checked = true;
1377
        }
2 - 1378
 
6 - 1379
        if (titleField.value.indexOf("Deluxe") > 0) {
1380
            document.getElementById("dvdDeluxeEdition").checked = true;
1381
        }
2 - 1382
 
6 - 1383
        if (titleField.value.indexOf("Director") > 0) {
1384
            document.getElementById("dvdDirectorsCut").checked = true;
1385
        }
2 - 1386
 
6 - 1387
        if (titleField.value.indexOf("Extended") > 0) {
1388
            document.getElementById("dvdExtendedEdition").checked = true;
1389
        }
2 - 1390
 
6 - 1391
        if (titleField.value.indexOf("Full Screen") > 0 || titleField.value.indexOf("Fullscreen") > 0 ||
1392
            titleField.value.indexOf("Full Frame") > 0 || titleField.value.indexOf("Fullframe") > 0) {
1393
            document.getElementById("dvdFullScreen").checked = true;
1394
        }
2 - 1395
 
6 - 1396
        if (titleField.value.indexOf("Limited") > 0) {
1397
            document.getElementById("dvdLimitedEdition").checked = true;
1398
        }
2 - 1399
 
6 - 1400
        if (titleField.value.indexOf("Promo") > 0) {
1401
            document.getElementById("dvdPromo").checked = true;
1402
        }
2 - 1403
 
6 - 1404
        if (titleField.value.indexOf("Signature") > 0) {
1405
            document.getElementById("dvdSignatureCollection").checked = true;
1406
        }
2 - 1407
 
6 - 1408
        if (titleField.value.indexOf("Special") > 0) {
1409
            document.getElementById("dvdSpecialEdition").checked = true;
1410
        }
2 - 1411
 
6 - 1412
        if (titleField.value.indexOf("Steelbook") > 0) {
1413
            document.getElementById("dvdSteelbook").checked = true;
1414
        }
2 - 1415
 
6 - 1416
        if (titleField.value.indexOf("Unrated") > 0) {
1417
            document.getElementById("dvdUnratedEdition").checked = true;
1418
        }
2 - 1419
 
6 - 1420
        if (titleField.value.indexOf("Wide Screen") > 0 || titleField.value.indexOf("Widescreen") > 0) {
1421
            document.getElementById("dvdWidescreen").checked = true;
1422
        }
2 - 1423
 
30 - 1424
        $('#category').selectpicker('val', "617");
1425
        $('#category').selectpicker('refresh');
6 - 1426
        categoryValues();
1427
    } else if (catalogTitle.includes("Paperback") || catalogTitle.includes("Hardcover")) {
1428
        x = document.getElementById("bookDetails");
1429
        if (x.className.indexOf("w3-show") == -1) {
1430
            x.className += " w3-show";
1431
        }
2 - 1432
 
6 - 1433
        document.getElementById("bookLanguage").value = configDefaultLanguage;
1434
        document.getElementById("bookCountry").value = configDefaultCountry;
1435
        document.getElementById("bookSubject").value = "";
2 - 1436
 
6 - 1437
        if (ItemSpecifics) {
1438
            for (i = 0; i < ItemSpecifics.NameValueList.length; i++) {
1439
                fieldName = 'book' + ItemSpecifics.NameValueList[i].Name.replace(/ /g, '');
1440
                field = document.getElementById(fieldName);
1441
                if (field) {
1442
                    field.value = ItemSpecifics.NameValueList[i].Value;
1443
                }
1444
            }
1445
        }
2 - 1446
 
30 - 1447
        $('#bookFormat').prop('disabled', false).selectpicker('refresh');
1448
        $('#bookSubject').prop('disabled', false).selectpicker('refresh');
2 - 1449
 
30 - 1450
        $('#category').selectpicker('val', "171243");
1451
        $('#category').selectpicker('refresh');
6 - 1452
        categoryValues();
1453
    } else {
1454
        printManualButtons();
1455
    }
2 - 1456
 
6 - 1457
    function toDataURL(url) {
1458
        var xhr = new XMLHttpRequest();
1459
        xhr.onload = function() {
1460
            var reader = new FileReader();
1461
            reader.onloadend = function() {
1462
                DescImage = reader.result;
1463
            };
1464
            reader.readAsDataURL(xhr.response);
1465
        };
1466
        xhr.open('GET', url);
1467
        xhr.responseType = 'blob';
1468
        xhr.send();
1469
    }
2 - 1470
 
6 - 1471
    toDataURL(configListingUrl + document.getElementById("keyword").value.trim() + configdescriptionImageExtension);
1472
    document.getElementById("image1").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage1Extension;
1473
    document.getElementById("image2").src = configListingUrl + document.getElementById("keyword").value.trim() + configImage2Extension;
1474
    document.getElementById("descriptionImage").src = configListingUrl + document.getElementById("keyword").value.trim() + configdescriptionImageExtension;
1475
    document.getElementById("image1anchor").href = document.getElementById("image1").src;
1476
    document.getElementById("image2anchor").href = document.getElementById("image2").src;
1477
    unsetAdditionalImages();
2 - 1478
 
6 - 1479
    for (i = 0; i < additionalPictures.length; i++) {
1480
        if (additionalPictures[i] !== undefined && additionalPictures[i][0].startsWith(document.getElementById("keyword").value.trim())) {
1481
            if (additionalPictures[i].length > maxAdditionalImages) {
30 - 1482
                document.getElementById("productinfo").innerHTML += '<p class="bg-danger"><strong>Too many additional images.</a></strong></p>';
6 - 1483
            } else {
1484
                for (j = 0; j < additionalPictures[i].length + 4; j++) {
1485
                    setAdditionalImage(j + 3, additionalPictures[i][j]);
1486
                }
1487
            }
1488
        }
1489
    }
2 - 1490
}
1491
 
1492
function getYear(str) {
6 - 1493
    return str.match(/[12][0-9][0-9][0-9]/);
2 - 1494
}
1495
 
1496
function fillManualForm(type) {
6 - 1497
    var n;
1498
    var x;
2 - 1499
 
6 - 1500
    hideDetailWindows();
2 - 1501
 
6 - 1502
    if (document.getElementById("format").value.length <= 1) {
30 - 1503
        $('#format').selectpicker('val', auctionFormat[type]);
1504
        $('#format').selectpicker('refresh');
6 - 1505
    }
2 - 1506
 
6 - 1507
    if (type === 0) {
30 - 1508
        $('#category').selectpicker('val', "171243");
1509
        $('#category').selectpicker('refresh');
6 - 1510
        if (isNumeric(catalogTitle)) {
1511
            document.getElementById("bookISBN").value = catalogTitle;
1512
        } else {
1513
            document.getElementById("bookISBN").value = configDoesNotApply;
1514
        }
1515
        document.getElementById("bookLanguage").value = configDefaultLanguage;
1516
        document.getElementById("bookCountry").value = configDefaultCountry;
1517
        categoryValues();
1518
        x = document.getElementById("bookDetails");
1519
        if (x.className.indexOf("w3-show") == -1) {
1520
            x.className += " w3-show";
1521
        }
2 - 1522
 
30 - 1523
        $('#bookFormat').selectpicker('val', "");
1524
        $('#bookFormat').prop('disabled', false).selectpicker('refresh');
1525
        $('#bookSubject').selectpicker('val', "");
1526
        $('#bookSubject').prop('disabled', false).selectpicker('refresh');
6 - 1527
    } else if (type == 1) {
1528
        document.getElementById("category").value = "176984";
30 - 1529
        $('#category').selectpicker('val', "176984");
1530
        $('#category').selectpicker('refresh');
6 - 1531
        if (isNumeric(catalogTitle)) {
1532
            document.getElementById("cdUPC").value = catalogTitle;
1533
        } else {
1534
            document.getElementById("cdUPC").value = configDoesNotApply;
1535
            if ((n = catalogTitle.indexOf(" - ")) > 0) {
36 - 1536
                if (document.getElementById("cdArtist").value.length < 1) {
1537
                    document.getElementById("cdArtist").value = catalogTitle.substr(0, n);
1538
                }
6 - 1539
            }
1540
        }
1541
        document.getElementById("cdCountry").value = configDefaultCountry;
36 - 1542
        document.getElementById("cdLanguage").value = configDefaultLanguage;
1543
        document.getElementById("cdModified").value = 'No';
1544
        $('#cdModified').prop('disabled', false).selectpicker('refresh');
1545
        document.getElementById("cdModificationDescription").value = '';
6 - 1546
        categoryValues();
2 - 1547
 
30 - 1548
        document.getElementById("cdDuration").selectedIndex = 0;
1549
        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
1550
        $('#cdGenre').selectpicker('val', "");
1551
        $('#cdGenre').prop('disabled', false).selectpicker('refresh');
2 - 1552
 
6 - 1553
        x = document.getElementById("cdDetails");
1554
        if (x.className.indexOf("w3-show") == -1) {
1555
            x.className += " w3-show";
1556
        }
2 - 1557
 
6 - 1558
        findDiscogsReleases(document.getElementById("keyword").value);
10 - 1559
        $('#cdTracks').on('change input cut paste',updateTracklistPreview);
6 - 1560
    } else if (type == 2) {
30 - 1561
        $('#category').selectpicker('val', "617");
1562
        $('#category').selectpicker('refresh');
6 - 1563
        if (isNumeric(catalogTitle)) {
1564
            document.getElementById("dvdUPC").value = catalogTitle;
1565
        } else {
1566
            document.getElementById("dvdUPC").value = configDoesNotApply;
1567
        }
1568
        document.getElementById("dvdCountry").value = configDefaultCountry;
1569
        categoryValues();
1570
        x = document.getElementById("dvdDetails");
1571
        if (x.className.indexOf("w3-show") == -1) {
1572
            x.className += " w3-show";
1573
        }
2 - 1574
 
30 - 1575
        $('#dvdFormat').selectpicker('val', 'DVD');
1576
        $('#dvdGenre').selectpicker('val', "");
1577
        $('#dvdRating').selectpicker('val', "");
1578
        $('#dvdRegionCode').selectpicker('val', 'DVD: 1 (US, Canada...)');
1579
        $('#dvdRental').selectpicker('val', 'No');
1580
        $('#dvdSeason').selectpicker('val', "");
1581
        $('#dvdFormat').prop('disabled', false).selectpicker('refresh');
1582
        $('#dvdGenre').prop('disabled', false).selectpicker('refresh');
1583
        $('#dvdRating').prop('disabled', false).selectpicker('refresh');
1584
        $('#dvdRegionCode').prop('disabled', false).selectpicker('refresh');
1585
        $('#dvdRental').prop('disabled', false).selectpicker('refresh');
1586
        $('#dvdSeason').prop('disabled', false).selectpicker('refresh');
6 - 1587
    } else if (type == 3) {
1588
        catalogTitle = document.getElementById("keyword").value.trim();
1589
        splitTradingCardElements();
1590
    }
2 - 1591
 
6 - 1592
    fillForm();
2 - 1593
}
1594
 
1595
function resetForm() {
6 - 1596
    var i;
2 - 1597
 
6 - 1598
    document.getElementById("searchForm").reset();
1599
    document.getElementById("listForm").reset();
1600
    document.getElementById("productinfo").innerHTML = "<p>Product Info</p>";
1601
    initConfig();
1602
    clearStatusWindows();
1603
    for (i = 1; i <= 7; i++) {
1604
        document.getElementById("image" + i).src = "";
1605
    }
1606
    document.getElementById("descriptionImage").src = "";
1607
    hideDetailWindows();
2 - 1608
}
1609
 
1610
function verifyListingImage() {
6 - 1611
    if (eBayAuthTokenFlag === false) {
1612
        return;
1613
    }
1614
    if (isDuplicate) {
1615
        window.alert("This is a duplicate.");
1616
        return;
1617
    }
2 - 1618
 
6 - 1619
    var x = document.getElementById("results");
1620
    x.innerHTML = '';
1621
    if (x.className.indexOf("w3-show") == -1) {
1622
        x.className += " w3-show";
1623
    }
2 - 1624
 
6 - 1625
    if (ImageURLs.length === 0) {
1626
        uploadSiteHostedPictures();
1627
    } else {
1628
        verifyListing();
1629
    }
2 - 1630
}
1631
 
1632
function verifyListing() {
6 - 1633
    var i;
1634
    var authErrorFlag = false;
2 - 1635
 
6 - 1636
    var xw = new XMLWriter('UTF-8', '1.0');
1637
    var xhr = new XMLHttpRequest();
2 - 1638
 
6 - 1639
    if (!createAddXML(xw, xhr, 'VerifyAddItemRequest', 'VerifyAddItem', false)) {
1640
        return;
1641
    }
2 - 1642
 
6 - 1643
    xml = xw.flush();
1644
    xw.close();
2 - 1645
 
6 - 1646
    xhr.onload = function() {
30 - 1647
        var jsonObj = XMLparse(xhr.responseXML, false);
1648
        var obj = jsonObj.VerifyAddItemResponse;
6 - 1649
        var returnCode = obj.Ack;
1650
        var x = document.getElementById("results");
30 - 1651
        var str = "";
2 - 1652
 
6 - 1653
        if (returnCode == 'Success' ||
139 - 1654
            (returnCode == 'Warning' && (obj.Errors.ErrorCode == '21920204' || obj.Errors.ErrorCode == '21917108' || obj.Errors.ErrorCode == '21920205' || obj.Errors.ErrorCode == '21917164' || obj.Errors.ErrorCode == '21920208'))) {
6 - 1655
            listButtonHot(true);
2 - 1656
 
30 - 1657
            str += '<div class="alert ' + (returnCode == 'Success' ? "alert-success" : "alert-warning" ) + ' alert-dismissible">';
1658
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1659
            str += '<p><strong>' + returnCode + ':</strong></p>';
2 - 1660
 
6 - 1661
            if (returnCode == 'Warning') {
30 - 1662
                str += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
6 - 1663
            }
30 - 1664
            var fees = getJsonArray(obj.Fees.Fee);
1665
            str += "<ul>";
6 - 1666
            for (i = 0; i < fees.length; i++) {
1667
                if (fees[i].Fee.text !== "0.0") {
30 - 1668
                    str += '<li>' + fees[i].Name + ": $" + Number(fees[i].Fee.text).toFixed(2) + "</li>";
6 - 1669
                }
1670
            }
2 - 1671
 
6 - 1672
            if (obj.DiscountReason) {
30 - 1673
                str += "<li>Discount Reason: " + obj.DiscountReason + "</li>";
6 - 1674
            }
2 - 1675
 
30 - 1676
            str += "</ul>";
1677
            str += '</div>';
1678
 
1679
            var recommendations = getJsonArray(obj.ListingRecommendations.Recommendation);
6 - 1680
            for (i = 0; i < recommendations.length; i++) {
30 - 1681
                str += '<div class="alert alert-info alert-dismissible">';
1682
                str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1683
                str += decode(recommendations[i]);
1684
                str += '</div>';
6 - 1685
            }
30 - 1686
 
1687
            x.innerHTML += str;
6 - 1688
        } else {
1689
            requireNewVerify();
2 - 1690
 
30 - 1691
            str += '<div class="alert alert-danger alert-dismissible">';
1692
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1693
            str += '<p><strong>' + returnCode + ':</strong></p>';
1694
 
6 - 1695
            var errors = getJsonArray(obj.Errors);
30 - 1696
            str += "<ul>";
6 - 1697
            for (i = 0; i < errors.length; i++) {
30 - 1698
                str += '<li>' + errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "</li>";
6 - 1699
                if (errors[i].LongMessage.includes('Auth')) {
1700
                    authErrorFlag = true;
1701
                }
1702
            }
30 - 1703
            str += "</ul>";
2 - 1704
 
6 - 1705
            if (obj.DuplicateInvocationDetails) {
30 - 1706
                str += '<p>Duplicate Invocation Id ' + obj.DuplicateInvocationDetails.DuplicateInvocationID + ' Tracking Id' + obj.DuplicateInvocationDetails.InvocationTrackingID + ' Status ' + obj.DuplicateInvocationDetails.Status + '</p>';
6 - 1707
            }
2 - 1708
 
30 - 1709
            str += "</div>";
1710
            x.innerHTML += str;
1711
 
6 - 1712
            if (authErrorFlag === true) {
1713
                eBayAuthTokenFlag = false;
1714
                x = document.getElementById("login");
1715
                if (x.className.indexOf("w3-show") == -1) {
1716
                    x.className += " w3-show";
1717
                }
1718
            }
1719
        }
2 - 1720
 
6 - 1721
        if (obj.Message) {
30 - 1722
            str += '<div class="alert alert-info alert-dismissible">';
1723
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1724
            str += '<p>' + obj.Message + '</p>';
1725
            str += '</div>';
1726
            x.innerHTML += str;
6 - 1727
        }
1728
    };
2 - 1729
 
6 - 1730
    xhr.send(xml);
2 - 1731
}
1732
 
1733
function decode(recommendation) {
6 - 1734
    var str = "<p>";
1735
    var i;
2 - 1736
 
6 - 1737
    str += recommendation.Code + " (" + recommendation.Type + "/" + recommendation.Group + ") for '" + recommendation.FieldName;
1738
    if (recommendation.Value) {
1739
        str += "': " + recommendation.Value;
1740
    }
2 - 1741
 
6 - 1742
    if (recommendation.Message) {
1743
        str += "<br/>" + recommendation.Message;
1744
    }
2 - 1745
 
6 - 1746
    var metadata = recommendation.Metadata;
1747
    if (metadata) {
1748
        if (metadata.length > 0) {
1749
            for (i = 0; i < metadata.length; i++) {
1750
                if (metadata[i].Name != "correlationId" &&
1751
                    metadata[i].Name != "currency" &&
1752
                    metadata[i].Name != "similarItems") {
1753
                    str += "<br/>" + metadata[i].Name + " = " + metadata[i].Value;
1754
                }
1755
            }
1756
        } else {
1757
            if (metadata.Name != "correlationId" &&
1758
                metadata.Name != "currency" &&
1759
                metadata.Name != "similarItems") {
1760
                str += "<br/>" + metadata.Name + " = " + metadata.Value;
1761
            }
1762
        }
1763
    }
2 - 1764
 
6 - 1765
    str += "</p>";
2 - 1766
 
6 - 1767
    return str;
2 - 1768
}
1769
 
1770
function submitListing(saveFlag) {
6 - 1771
    var i;
1772
    var authErrorFlag = false;
2 - 1773
 
30 - 1774
    if (document.getElementById("list").className.indexOf("btn-success") == -1) {
6 - 1775
        return;
1776
    }
2 - 1777
 
6 - 1778
    var xw = new XMLWriter('UTF-8', '1.0');
1779
    var xhr = new XMLHttpRequest();
2 - 1780
 
6 - 1781
    createAddXML(xw, xhr, 'AddItemRequest', 'AddItem', saveFlag);
2 - 1782
 
6 - 1783
    xml = xw.flush();
1784
    xw.close();
2 - 1785
 
6 - 1786
    xhr.onload = function() {
30 - 1787
        var jsonObj = XMLparse(xhr.responseXML, false);
1788
        var obj = jsonObj.AddItemResponse;
1789
        var str = '';
6 - 1790
        var returnCode = obj.Ack;
2 - 1791
 
6 - 1792
        var x = document.getElementById("results");
1793
        if (x.className.indexOf("w3-show") == -1) {
1794
            x.className += " w3-show";
1795
        }
2 - 1796
 
6 - 1797
        if (returnCode == 'Success' ||
139 - 1798
            (returnCode == 'Warning' && (obj.Errors.ErrorCode == '21920204' || obj.Errors.ErrorCode == '21917108' || obj.Errors.ErrorCode == '21920205' || obj.Errors.ErrorCode == '21917164' || obj.Errors.ErrorCode == '21920208'))) {
6 - 1799
            listButtonHot(false);
10 - 1800
            moveImages();
6 - 1801
            ImageURLs = [];
1802
            document.getElementById("title").value = "";
1803
            printTitleLength();
1804
            deleteSubmittedEntry();
2 - 1805
 
1806
 
30 - 1807
            str += '<div class="alert ' + (returnCode == 'Success' ? "alert-success" : "alert-warning" ) + ' alert-dismissible">';
1808
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1809
            str += '<p><strong>' + returnCode + '</strong>, Item Id <a href="https://www.ebay.com/itm/' + obj.ItemID + '" target="_blank">' + obj.ItemID + '</a></p>';
1810
 
6 - 1811
            if (returnCode == 'Warning') {
30 - 1812
                str += "<p>" + obj.Errors.SeverityCode + " (" + obj.Errors.ErrorCode + "): " + escapeHtml(obj.Errors.LongMessage) + "</p>";
6 - 1813
            }
30 - 1814
            var fees = getJsonArray(obj.Fees.Fee);
1815
            str += "<ul>";
6 - 1816
            for (i = 0; i < fees.length; i++) {
1817
                if (fees[i].Fee.text !== "0.0") {
30 - 1818
                    str += '<li>' + fees[i].Name + ": $" + Number(fees[i].Fee.text).toFixed(2) + "</li>";
6 - 1819
                }
1820
            }
2 - 1821
 
6 - 1822
            if (obj.DiscountReason) {
30 - 1823
                str += "<li>Discount Reason: " + obj.DiscountReason + "</li>";
6 - 1824
            }
30 - 1825
 
1826
            str += '</ul>';
1827
            str += '</div>';
1828
 
1829
            x.innerHTML = str;
6 - 1830
        } else {
1831
            requireNewVerify();
30 - 1832
            str += '<div class="alert alert-danger alert-dismissible">';
1833
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1834
            str += '<p><strong>' + returnCode + ':</strong></p>';
2 - 1835
 
6 - 1836
            var errors = getJsonArray(obj.Errors);
30 - 1837
            str += "<ul>";
6 - 1838
            for (i = 0; i < errors.length; i++) {
30 - 1839
                str += '<li>' + errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "</li>";
6 - 1840
                if (errors[i].LongMessage.includes('Auth')) {
1841
                    authErrorFlag = true;
1842
                }
1843
            }
30 - 1844
            str += "</ul>";
2 - 1845
 
30 - 1846
            if (obj.DuplicateInvocationDetails) {
1847
                str += '<p>Duplicate Invocation Id ' + obj.DuplicateInvocationDetails.DuplicateInvocationID + ' Tracking Id' + obj.DuplicateInvocationDetails.InvocationTrackingID + ' Status ' + obj.DuplicateInvocationDetails.Status + '</p>';
1848
            }
2 - 1849
 
30 - 1850
            str += "</div>";
1851
            x.innerHTML = str;
1852
 
6 - 1853
            if (authErrorFlag === true) {
1854
                eBayAuthTokenFlag = false;
1855
                x = document.getElementById("login");
1856
                if (x.className.indexOf("w3-show") == -1) {
1857
                    x.className += " w3-show";
1858
                }
1859
            }
1860
        }
2 - 1861
 
6 - 1862
        unsetAdditionalImages();
1863
    };
2 - 1864
 
6 - 1865
    if (saveFlag) {
1866
        var sPos = xml.indexOf('<Item>');
1867
        var ePos = xml.indexOf('</Item>');
1868
        var textToSave = xml.substr(sPos, ePos - sPos + 7);
1869
        var textToSaveAsBlob = new Blob([String(textToSave)], {
1870
            type: "text/xml"
1871
        });
1872
        var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
1873
        var fileNameToSaveAs = document.getElementById('keyword').value + ".xml";
30 - 1874
        var str = '';
2 - 1875
 
6 - 1876
        var downloadLink = document.createElement("a");
1877
        downloadLink.download = fileNameToSaveAs;
1878
        downloadLink.innerHTML = "Download File";
1879
        downloadLink.href = textToSaveAsURL;
1880
        downloadLink.onclick = destroyClickedElement;
1881
        downloadLink.style.display = "none";
1882
        document.body.appendChild(downloadLink);
2 - 1883
 
30 - 1884
        str += '<div class="alert alert-success alert-dismissible">';
1885
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1886
        str += '<p><strong>XML Saved</strong>, Filename ' + fileNameToSaveAs;
1887
        str += '</div>';
1888
        document.getElementById("results").innerHTML = str;
2 - 1889
 
6 - 1890
        downloadLink.click();
1891
        listButtonHot(false);
30 - 1892
        moveImages();
6 - 1893
        ImageURLs = [];
1894
        unsetAdditionalImages();
1895
        deleteSubmittedEntry();
1896
    } else {
1897
        xhr.send(xml);
1898
    }
2 - 1899
}
1900
 
10 - 1901
function moveImages() {
1902
    var i, j;
1903
    var item = document.getElementById("keyword").value.trim();
1904
    var images = [];
30 - 1905
 
10 - 1906
    images.push(item + configImage1Extension);
1907
    images.push(item + configImage2Extension);
1908
    images.push(item + configdescriptionImageExtension);
1909
 
1910
    for (i = 0; i < additionalPictures.length; i++) {
1911
        if (additionalPictures[i] !== undefined && additionalPictures[i][0].startsWith(item)) {
1912
            for (j = 0; j < additionalPictures[i].length; j++) {
1913
                images.push(additionalPictures[i][j]);
1914
            }
1915
        }
1916
    }
30 - 1917
 
170 - 1918
    for (i = 0; i < additionalPicturesToMove.length; i++) {
1919
        if (additionalPicturesToMove[i] !== undefined && additionalPicturesToMove[i][0].startsWith(item)) {
1920
            for (j = 0; j < additionalPicturesToMove[i].length; j++) {
1921
                images.push(additionalPicturesToMove[i][j]);
1922
            }
1923
        }
1924
    }
1925
 
10 - 1926
    for (i=0; i < images.length; i++) {
1927
        var xhttp = new XMLHttpRequest();
1928
        xhttp.onreadystatechange = function() {
147 - 1929
            // bugbug
10 - 1930
            if (this.readyState == 4 && this.status == 200) {
1931
            } else if (this.readyState == 4 && this.status == 400) {
1932
            }
1933
        };
1934
 
1935
        xhttp.open("GET", "moveImage.php?filename=" + images[i], true);
1936
        xhttp.send();
1937
    }
1938
}
1939
 
2 - 1940
function destroyClickedElement(event) {
6 - 1941
    document.body.removeChild(event.target);
2 - 1942
}
1943
 
1944
function deleteSubmittedEntry() {
6 - 1945
    var x = document.getElementById("keyword");
1946
    x.remove(x.selectedIndex);
1947
    x.selectedIndex = -1;
30 - 1948
    $("#keyword").selectpicker('refresh');
2 - 1949
}
1950
 
1951
function createAddXML(xw, xhr, xmlrequest, callname, saveFlag) {
6 - 1952
    var errorText = "";
1953
    var ShippingProfileName;
1954
    var ShippingProfileId;
1955
    var si, opt;
1956
    var weightInOz;
2 - 1957
 
6 - 1958
    if (picturesAreLoaded === false) {
1959
        errorText += "<li>Images not yet uploaded!</li>";
1960
    }
2 - 1961
 
6 - 1962
    if (document.getElementById("format").value <= 1) {
1963
        errorText += "<li>Select Auction Format!</li>";
1964
    }
2 - 1965
 
6 - 1966
    if (document.getElementById("sku").value == 'Batch X') {
1967
        errorText += "<li>Wrong Batch Number!</li>";
1968
    }
2 - 1969
 
6 - 1970
    if (document.getElementById("category").value == '0') {
1971
        errorText += "<li>Wrong Category!</li>";
1972
    }
2 - 1973
 
6 - 1974
    if (document.getElementById("sku").value.length < 1) {
1975
        errorText += "<li>Batch Number Empty!</li>";
1976
    }
2 - 1977
 
6 - 1978
    if (document.getElementById("condition").value === "") {
1979
        errorText += "<li>Condition Description Empty!</li>";
1980
    }
2 - 1981
 
6 - 1982
    if (document.getElementById("quantity").value === "") {
1983
        errorText += "<li>Quantity Empty!</li>";
1984
    }
2 - 1985
 
6 - 1986
    if (document.getElementById("price").value === "") {
1987
        errorText += "<li>Price Empty!</li>";
1988
    }
2 - 1989
 
6 - 1990
    if (document.getElementById("title").value === "") {
1991
        errorText += "<li>Title Empty!</li>";
1992
    }
2 - 1993
 
6 - 1994
    if (errorText.length > 0) {
30 - 1995
        var str = '';
6 - 1996
        var x = document.getElementById("results");
30 - 1997
        str += '<div class="alert alert-danger alert-dismissible">';
1998
        str += '<button type="button" class="close" data-dismiss="alert">×</button>';
1999
        str += '<h2>Form Errors</h2><ul>' + errorText + '</ul>';
2000
        str += '</div>';
2001
        x.innerHTML += str;
6 - 2002
        if (x.className.indexOf("w3-show") == -1) {
2003
            x.className += " w3-show";
2004
        }
2 - 2005
 
6 - 2006
        return;
2007
    }
2 - 2008
 
6 - 2009
    xw.writeStartDocument();
2010
    xw.writeStartElement(xmlrequest);
2011
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
2 - 2012
 
6 - 2013
    xw.writeStartElement('RequesterCredentials');
2014
    xw.writeElementString('eBayAuthToken', eBayAuthToken);
2015
    xw.writeEndElement(); /* RequesterCredentials */
2 - 2016
 
6 - 2017
    xw.writeStartElement('Item');
2 - 2018
 
6 - 2019
    if (CC == 3 || saveFlag) {
2020
        xw.writeElementString('UUID', document.getElementById('keyword').value.hashCode().pad(32));
2021
    }
2 - 2022
 
6 - 2023
    xw.writeElementString('Site', 'US');
2024
    xw.writeElementString('Country', 'US');
2025
    xw.writeElementString('PostalCode', configZip);
2026
    xw.writeElementString('Currency', 'USD');
2027
    xw.writeElementString('HitCounter', 'HiddenStyle');
2 - 2028
 
6 - 2029
    var format = document.getElementById('format').value;
2030
    xw.writeElementString('ListingType', format);
2031
    if (format == 'Chinese') {
2032
        xw.writeElementString('ListingDuration', 'Days_7');
2033
    } else if (format == 'FixedPriceItem') {
55 - 2034
        xw.writeElementString('ListingDuration', 'GTC');
6 - 2035
    }
2 - 2036
 
6 - 2037
    xw.writeStartElement('PrimaryCategory');
2038
    xw.writeElementString('CategoryID', category);
2039
    xw.writeEndElement(); /* PrimaryCategory */
2 - 2040
 
6 - 2041
    if (document.getElementById("category").value != '29223') {
2042
        xw.writeElementString('ConditionID', document.getElementById('conditionId').value);
2043
    }
2044
    if (document.getElementById('conditionId').value != '1000') {
2045
        xw.writeElementString('ConditionDescription', escapeXml(document.getElementById('condition').value));
2046
    }
2 - 2047
 
6 - 2048
    xw.writeStartElement('StartPrice');
2049
    xw.writeAttributeString('currencyID', 'USD');
2050
    xw.writeString(document.getElementById('price').value);
2051
    xw.writeEndElement(); /* StartPrice */
2 - 2052
 
139 - 2053
    xw.writeElementString('PayPalEmailAddress', configLinkedPayPal);
143 - 2054
// Not necessary for eBay managed payments
2055
//    xw.writeElementString('PaymentMethods', 'PayPal');
6 - 2056
    xw.writeElementString('Quantity', document.getElementById('quantity').value);
2057
    xw.writeElementString('Title', escapeXml(document.getElementById('title').value));
2058
    if (!isManualMode) {
2059
        xw.writeElementString('SKU', escapeXml(document.getElementById('sku').value));
2060
    } else {
2061
        if (isNumeric(document.getElementById('keyword').value.trim())) {
2062
            xw.writeElementString('SKU', escapeXml(document.getElementById('sku').value + ' - ' + ProductListingDetailsNameList[CC] + ' ' + document.getElementById('keyword').value.trim()));
2063
        } else {
2064
            xw.writeElementString('SKU', escapeXml(document.getElementById('sku').value));
2065
        }
2066
    }
2 - 2067
 
6 - 2068
    xw.writeStartElement('SellerProfiles');
143 - 2069
 
6 - 2070
    xw.writeStartElement('SellerPaymentProfile');
143 - 2071
    xw.writeElementString('PaymentProfileID', '187930424023');
2072
    xw.writeElementString('PaymentProfileName', 'eBay Managed Payments');
6 - 2073
    xw.writeEndElement(); /* SellerPaymentProfile */
143 - 2074
 
6 - 2075
    xw.writeStartElement('SellerReturnProfile');
2076
    xw.writeElementString('ReturnProfileID', '123043332023');
2077
    xw.writeElementString('ReturnProfileName', 'Returns Accepted,Buyer,30 Days,Money Back');
2078
    xw.writeEndElement(); /* SellerReturnProfile */
2 - 2079
 
6 - 2080
    xw.writeStartElement('SellerShippingProfile');
2081
    ShippingProfileId = ShippingProfileIdList[CC];
2082
    ShippingProfileName = ShippingProfileNameList[CC];
2083
    if (CC == 1) {
2084
        if (document.getElementById('title').value.includes('Discs') || discogsQty > 1) {
2085
            ShippingProfileId = ShippingProfileIdList[2];
2086
            ShippingProfileName = ShippingProfileNameList[2];
2087
        }
2088
    }
2089
    xw.writeElementString('ShippingProfileID', ShippingProfileId);
2090
    xw.writeElementString('ShippingProfileName', ShippingProfileName);
2091
    xw.writeEndElement(); /* SellerShippingProfile */
2 - 2092
 
6 - 2093
    xw.writeEndElement(); /* SellerProfiles */
2 - 2094
 
6 - 2095
    if (CC == 1) {
2096
        weightInOz = 4;
2 - 2097
 
6 - 2098
        if (discogsQty > 0) {
2099
            weightInOz = discogsQty * 4;
2100
        }
2 - 2101
 
6 - 2102
        if (document.getElementById('title').value.includes('Discs')) {
2103
            var pos = document.getElementById('title').value.indexOf('Discs');
2104
            var discNo = Number(document.getElementById('title').value.substr(pos - 2, 1));
2105
            if (discNo > 1) {
2106
                weightInOz = discNo * 4;
2107
            }
2108
        }
2 - 2109
 
6 - 2110
        xw.writeStartElement('ShippingPackageDetails');
2111
        xw.writeElementString('ShippingPackage', 'PackageThickEnvelope');
2112
        xw.writeElementString('ShippingIrregular', 'false');
2113
        xw.writeElementString('MeasurementUnit', 'English');
2114
        xw.writeElementString('WeightMajor', '0');
2115
        xw.writeElementString('WeightMinor', weightInOz.toString());
2116
        xw.writeEndElement(); /* ShippingPackageDetails> */
2117
    } else if (CC == 2) {
2118
        xw.writeStartElement('ShippingPackageDetails');
2119
        xw.writeElementString('ShippingPackage', 'PackageThickEnvelope');
2120
        xw.writeElementString('ShippingIrregular', 'false');
2121
        xw.writeElementString('MeasurementUnit', 'English');
2122
        xw.writeElementString('WeightMajor', '0');
2123
        xw.writeElementString('WeightMinor', '6');
2124
        xw.writeEndElement(); /* ShippingPackageDetails> */
2125
    } else if (CC == 3) {
2126
        xw.writeStartElement('ShippingPackageDetails');
2127
        xw.writeElementString('ShippingPackage', 'Letter');
2128
        xw.writeElementString('ShippingIrregular', 'false');
2129
        xw.writeElementString('MeasurementUnit', 'English');
2130
        xw.writeElementString('WeightMajor', '0');
2131
        xw.writeElementString('WeightMinor', '1');
2132
        xw.writeEndElement(); /* ShippingPackageDetails> */
2133
    }
2 - 2134
 
6 - 2135
    xw.writeStartElement('ProductListingDetails');
2136
    if (CC == 3) {
2137
        xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2138
    } else {
2139
        si = document.getElementById("keyword").selectedIndex;
2140
        opt = document.getElementById("keyword").options;
2141
        if (!isManualMode) {
2142
            if (eBayProductId.length > 0) {
2143
                xw.writeElementString('ProductReferenceID', eBayProductId);
2144
            } else {
2145
                if (isNumeric(document.getElementById('keyword').value.trim())) {
2146
                    if (opt[si].style.color != 'red') {
2147
                        xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('keyword').value.trim());
2148
                    } else {
2149
                        xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2150
                    }
2151
                } else {
2152
                    xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2153
                }
2154
            }
2155
        } else {
2156
            if (opt[si].style.color == 'red') {
2157
                xw.writeElementString(ProductListingDetailsNameList[CC], configDoesNotApply);
2158
            } else if (CC === 0) {
2159
                xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('bookISBN').value.trim());
2160
            } else if (CC == 1) {
2161
                xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('cdUPC').value.trim());
2162
            } else if (CC == 2) {
2163
                xw.writeElementString(ProductListingDetailsNameList[CC], document.getElementById('dvdUPC').value.trim());
2164
            }
2165
        }
2166
    }
2167
    xw.writeEndElement(); /* ProductListingDetails */
2 - 2168
 
6 - 2169
    xw.writeStartElement('Storefront');
2170
    if (CC != 3) {
2171
        xw.writeElementString('StoreCategoryID', StoreCategoryList[CC]);
2172
    } else {
2173
        if (category == "666") {
2174
            xw.writeElementString('StoreCategoryID', "30431905018");
2175
        } else if (category == "213") {
2176
            xw.writeElementString('StoreCategoryID', "30431901018");
2177
        } else if (category == "214") {
2178
            xw.writeElementString('StoreCategoryID', "30431902018");
2179
        } else if (category == "215") {
2180
            xw.writeElementString('StoreCategoryID', "30431903018");
2181
        } else if (category == "216") {
2182
            xw.writeElementString('StoreCategoryID', "30431904018");
2183
        } else {
2184
            xw.writeElementString('StoreCategoryID', "");
2185
        }
2186
    }
2187
    xw.writeEndElement(); /* Storefront */
2 - 2188
 
6 - 2189
    xw.writeStartElement('PictureDetails');
2190
    for (var imageNumber = 0; imageNumber < ImageURLs.length; imageNumber++) {
2191
        xw.writeElementString('PictureURL', ImageURLs[imageNumber]);
2192
    }
2193
    xw.writeEndElement(); /* PictureDetails */
2 - 2194
 
6 - 2195
    // Use Tax Table
2196
    //	xw.writeStartElement('ShippingDetails');
2197
    //	xw.writeStartElement('SalesTax');
2198
    //	xw.writeElementString('SalesTaxPercent', configTaxRate);
2199
    //	xw.writeElementString('SalesTaxState', configTaxStateId);
2200
    //	xw.writeElementString('ShippingIncludedInTax', 'false');
2201
    //	xw.writeEndElement(); /* SalesTax */
2202
    //	xw.writeEndElement(); /* ShippingDetails */
2203
    xw.writeElementString('UseTaxTable', 'true');
2 - 2204
 
6 - 2205
    if (document.getElementById('bestoffer').checked) {
151 - 2206
        var autoAcceptPrice = Math.floor(Number(document.getElementById('price').value) * configAutoAcceptPrice);
2207
        var minBestOfferPrice = Math.floor(Number(document.getElementById('price').value) * configMinBestOfferPrice);
2 - 2208
 
6 - 2209
        xw.writeStartElement('BestOfferDetails');
2210
        xw.writeElementString('BestOfferEnabled', 'true');
2211
        xw.writeEndElement(); /* BestOfferDetails */
2212
        xw.writeStartElement('ListingDetails');
2213
        xw.writeStartElement('BestOfferAutoAcceptPrice');
2214
        xw.writeAttributeString('currencyID', 'USD');
2215
        xw.writeString(autoAcceptPrice.toFixed(2));
2216
        xw.writeEndElement(); /* BestOfferAutoAcceptPrice */
2217
        xw.writeStartElement('MinimumBestOfferPrice');
2218
        xw.writeAttributeString('currencyID', 'USD');
2219
        xw.writeString(minBestOfferPrice.toFixed(2));
2220
        xw.writeEndElement(); /* MinimumBestOfferPrice */
2221
        xw.writeEndElement(); /* ListingDetails */
2222
    }
2 - 2223
 
6 - 2224
    var Desc = Description1;
2225
    Desc += '<h3>' + document.getElementById('title').value + '</h3>';
2226
    generateDescCore();
2227
    Desc += DescCore;
2228
    if (document.getElementById('conditionId').value != '1000') {
2229
        Desc += '<p>' + document.getElementById('condition').value + '</p>';
2230
    }
2231
    Desc += Description2;
2232
    Desc += document.getElementById('title').value.replace(/['"]+/g, '');
2233
    Desc += Description2a;
2234
    Desc += DescImage;
2235
    Desc += Description3;
2236
    if (CC !== 3) {
2237
        Desc += DescriptionFreeShipping;
2238
    } else {
2239
        Desc += DescriptionTradingCardShipping;
2240
    }
2241
    Desc += Description4;
2242
    xw.writeElementString('Description', escapeXml(Desc));
2 - 2243
 
6 - 2244
    if (callname.includes('Verify') && configGetRecommendations === true) {
2245
        xw.writeElementString('IncludeRecommendations', 'true');
2246
    }
2 - 2247
 
6 - 2248
    generateItemSpecifics(xw);
2 - 2249
 
6 - 2250
    xw.writeEndElement(); /* Item */
2 - 2251
 
6 - 2252
    xw.writeElementString('ErrorLanguage', 'en_US');
2253
    xw.writeElementString('Version', configeBayTradingVersion);
2254
    xw.writeElementString('WarningLevel', configWarningLevel);
2 - 2255
 
6 - 2256
    xw.writeEndElement(); /* xmlrequest */
2257
    xw.writeEndDocument();
2 - 2258
 
6 - 2259
    xhr.open('POST', configProxyUrl, true);
2260
    xhr.setRequestHeader('Content-Type', 'text/xml');
2261
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
2262
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
2263
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
2264
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
2265
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
2266
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
2267
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
2 - 2268
 
6 - 2269
    return true;
2 - 2270
}
2271
 
2272
function categoryValues() {
6 - 2273
    category = document.getElementById("category").value;
2 - 2274
 
6 - 2275
    if (category == 182882 || category == 171228 || category == 171243 || category == 2228 || category == 268) {
2276
        /* Books */
2277
        CC = 0;
2278
        conditionDescriptionButtons(0);
2279
    } else if (category == 176984 || category == 29792) {
2280
        /* CDs */
2281
        CC = 1;
2282
        conditionDescriptionButtons(1);
2283
    } else if (category == 617) {
2284
        /* DVDs */
2285
        CC = 2;
2286
        conditionDescriptionButtons(0);
2287
    } else if (category == 666 || category == 213 || category == 214 || category == 133072 || category == 215 || category == 4240 || category == 216 || category == 183444) {
2288
        /* Trading Cards */
2289
        CC = 3;
2290
        conditionDescriptionButtons(0);
2291
    } else {
2292
        conditionDescriptionButtons(0);
2293
        return;
2294
    }
2 - 2295
 
30 - 2296
    if (document.getElementById("format").value.length < 1) {
2297
        $('#format').selectpicker('val', auctionFormat[CC]);
2298
        $('#format').selectpicker('refresh');
6 - 2299
    }
2 - 2300
 
6 - 2301
    if (document.getElementById("price").value.length < 4) {
2302
        document.getElementById("price").value = MinPriceList[CC];
2303
    }
2 - 2304
 
6 - 2305
    document.getElementById("condition").value = ConditionDescriptionList[CC];
30 - 2306
    $('#conditionId').selectpicker('val', ConditionIdList[CC]);
2307
    $('#conditionId').selectpicker('refresh');
6 - 2308
    document.getElementById("quantity").value = 1;
2309
    document.getElementById("bestoffer").checked = false;
2 - 2310
}
2311
 
2312
function conditionDescriptionButtons(flag) {
6 - 2313
    var x = [];
2314
    x[0] = document.getElementById("CdConditionDescriptionSingular");
30 - 2315
    x[0].className = x[0].className.replace("btn-dark", "btn-info");
6 - 2316
    x[1] = document.getElementById("CdConditionDescriptionPlural");
30 - 2317
    x[1].className = x[1].className.replace("btn-info", "btn-dark");
6 - 2318
    x[2] = document.getElementById("CdConditionDescriptionDigipak");
30 - 2319
    x[2].className = x[2].className.replace("btn-info", "btn-dark");
6 - 2320
    x[3] = document.getElementById("CdConditionDescriptionNewCase");
30 - 2321
    x[3].className = x[3].className.replace("btn-info", "btn-dark");
2 - 2322
 
6 - 2323
    for (var i = 0; i < x.length; i++) {
2324
        if (flag) {
2325
            if (x[i].className.indexOf("w3-show-inline-block") == -1) {
2326
                x[i].className += " w3-show-inline-block";
2327
            }
2328
        } else {
2329
            x[i].className = x[i].className.replace(" w3-show-inline-block", "");
2330
        }
2331
    }
2 - 2332
}
2333
 
2334
function setCdConditionDescription(flag) {
30 - 2335
    var x = [];
2336
    x[0] = document.getElementById("CdConditionDescriptionSingular");
2337
    x[1] = document.getElementById("CdConditionDescriptionPlural");
2338
    x[2] = document.getElementById("CdConditionDescriptionDigipak");
2339
    x[3] = document.getElementById("CdConditionDescriptionNewCase");
2340
 
2341
    x[0].className = x[0].className.replace("btn-info", "btn-dark");
2342
    x[1].className = x[1].className.replace("btn-info", "btn-dark");
2343
    x[2].className = x[2].className.replace("btn-info", "btn-dark");
2344
    x[3].className = x[3].className.replace("btn-info", "btn-dark");
2345
 
6 - 2346
    if (flag == 'S') {
2347
        document.getElementById("condition").value = ConditionDescriptionList[1];
30 - 2348
        x[0].className = x[0].className.replace("btn-dark", "btn-info");
6 - 2349
    } else if (flag == 'P') {
2350
        document.getElementById("condition").value = ConditionDescriptionCdPlural;
30 - 2351
        x[1].className = x[1].className.replace("btn-dark", "btn-info");
6 - 2352
        discogsQty = 2;
2353
    } else if (flag == 'D') {
2354
        document.getElementById("condition").value = ConditionDescriptionCdDigipak;
2355
        document.getElementById("cdDigipak").checked = true;
30 - 2356
        x[2].className = x[2].className.replace("btn-dark", "btn-info");
6 - 2357
    } else if (flag == 'N') {
2358
        document.getElementById("condition").value = ConditionDescriptionCdNewCase;
30 - 2359
        x[3].className = x[3].className.replace("btn-dark", "btn-info");
6 - 2360
    }
2 - 2361
}
2362
 
2363
var minActive = [0.0, 0.0, 0.0];
2364
var maxActive = [0.0, 0.0, 0.0];
2365
var avgActive = [0.0, 0.0, 0.0];
2366
var noActive = [0, 0, 0];
2367
var minSold = [0.0, 0.0, 0.0];
2368
var maxSold = [0.0, 0.0, 0.0];
2369
var avgSold = [0.0, 0.0, 0.0];
2370
var noSold = [0, 0, 0];
2371
var minUnsold = [0.0, 0.0, 0.0];
2372
var maxUnsold = [0.0, 0.0, 0.0];
2373
var avgUnsold = [0.0, 0.0, 0.0];
2374
var noUnsold = [0, 0, 0];
2375
var maxPricingPages = [-1, -1];
2376
var totalPricingEntries = [0, 0];
2377
var newActiveBreakdown = [];
2378
var usedActiveBreakdown = [];
2379
var newSoldBreakdown = [];
2380
var usedSoldBreakdown = [];
2381
var maxPriceByNumber = [0.0, 0.0];
2382
var listingNumberPercentage = 0.25;
2383
 
2384
 
2385
function getPricing() {
6 - 2386
    minActive = [0.0, 0.0, 0.0];
2387
    maxActive = [0.0, 0.0, 0.0];
2388
    avgActive = [0.0, 0.0, 0.0];
2389
    noActive = [0, 0, 0];
2390
    minSold = [0.0, 0.0, 0.0];
2391
    maxSold = [0.0, 0.0, 0.0];
2392
    avgSold = [0.0, 0.0, 0.0];
2393
    noSold = [0, 0, 0];
2394
    minUnsold = [0.0, 0.0, 0.0];
2395
    maxUnsold = [0.0, 0.0, 0.0];
2396
    avgUnsold = [0.0, 0.0, 0.0];
2397
    noUnsold = [0, 0, 0];
2398
    maxPricingPages = [-1, -1];
2399
    totalPricingEntries = [0, 0];
2400
    newActiveBreakdown = [];
2401
    usedActiveBreakdown = [];
2402
    newSoldBreakdown = [];
2403
    usedSoldBreakdown = [];
2 - 2404
 
6 - 2405
    getPricingData(0);
2406
    getPricingData(1);
2 - 2407
}
2408
 
2409
function getPricingData(searchIndex) {
6 - 2410
    var index = 0;
2411
    var keyword;
2 - 2412
 
6 - 2413
    keyword = document.getElementById('keyword').value;
2 - 2414
 
6 - 2415
    // Construct the request
2416
    var url = configeBayFinding + "?";
2417
    if (searchIndex === 0) {
2418
        url += "OPERATION-NAME=findItemsAdvanced";
2419
    } else {
2420
        url += "OPERATION-NAME=findCompletedItems";
2421
    }
2422
    url += "&SECURITY-APPNAME=" + configAppid;
2423
    url += "&GLOBAL-ID=EBAY-US";
2424
    url += "&RESPONSE-DATA-FORMAT=JSON";
2425
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2426
    url += "&REST-PAYLOAD";
2427
    url += "&keywords=";
2428
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2 - 2429
 
6 - 2430
    url += "&paginationInput.entriesPerPage=100";
2431
    url += "&paginationInput.pageNumber=";
2432
    url += (index + 1);
2433
    url += "&buyerPostalCode=";
2434
    url += configZip;
2 - 2435
 
6 - 2436
    var xhttp = new XMLHttpRequest();
2 - 2437
 
6 - 2438
    xhttp.onreadystatechange = function() {
147 - 2439
        if (this.readyState == 4 && this.status == 200) {
6 - 2440
            if (searchIndex === 0) {
2441
                _cb_PriceActiveItems(JSON.parse(this.responseText));
2442
            } else {
2443
                _cb_PriceCompletedItems(JSON.parse(this.responseText));
2444
            }
2445
        }
2446
    };
2 - 2447
 
6 - 2448
    xhttp.open("GET", configProxyUrl, true);
2449
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2450
    xhttp.send();
2 - 2451
 
6 - 2452
    function waitForMaxPricingPages(i) {
2453
        if (maxPricingPages[i] < 0) {
2454
            window.setTimeout(waitForMaxPricingPages, 500, i); // wait 500 milliseconds
2455
        } else {
2456
            for (index = 1; index < maxPricingPages[searchIndex]; index++) {
2457
                // Construct the request
2458
                var url = configeBayFinding + "?";
2459
                if (searchIndex === 0) {
2460
                    url += "OPERATION-NAME=findItemsAdvanced";
2461
                } else {
2462
                    url += "OPERATION-NAME=findCompletedItems";
2463
                }
2464
                url += "&SECURITY-APPNAME=" + configAppid;
2465
                url += "&GLOBAL-ID=EBAY-US";
2466
                url += "&RESPONSE-DATA-FORMAT=JSON";
2467
                url += "&SERVICE-VERSION=" + configeBayFindingVersion;
2468
                url += "&REST-PAYLOAD";
2469
                url += "&keywords=";
2470
                url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
2 - 2471
 
6 - 2472
                url += "&paginationInput.entriesPerPage=100";
2473
                url += "&paginationInput.pageNumber=";
2474
                url += (index + 1);
2 - 2475
 
6 - 2476
                var xhttp = new XMLHttpRequest();
2 - 2477
 
6 - 2478
                xhttp.onreadystatechange = function() {
147 - 2479
                    if (this.readyState == 4 && this.status == 200) {
6 - 2480
                        if (searchIndex === 0) {
2481
                            _cb_PriceActiveItems(JSON.parse(this.responseText));
2482
                        } else {
2483
                            _cb_PriceCompletedItems(JSON.parse(this.responseText));
2484
                        }
2485
                    }
2486
                };
2 - 2487
 
6 - 2488
                xhttp.open("GET", configProxyUrl, true);
2489
                xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
2490
                xhttp.send();
2491
            }
2492
        }
2493
    }
2 - 2494
 
6 - 2495
    waitForMaxPricingPages(searchIndex);
2 - 2496
}
2497
 
2498
function _cb_PriceActiveItems(objArray) {
6 - 2499
    var array = typeof objArray.findItemsAdvancedResponse[0] != 'object' ? JSON.parse(objArray.findItemsAdvancedResponse[0]) : objArray.findItemsAdvancedResponse[0].searchResult[0].item;
2500
    totalPricingEntries[0] = Number(objArray.findItemsAdvancedResponse[0].paginationOutput[0].totalEntries);
2501
    if (totalPricingEntries[0] > 0) {
2502
        priceItem(array, 0);
2503
    }
2 - 2504
}
2505
 
2506
function _cb_PriceCompletedItems(objArray) {
6 - 2507
    var array = typeof objArray.findCompletedItemsResponse[0] != 'object' ? JSON.parse(objArray.findCompletedItemsResponse[0]) : objArray.findCompletedItemsResponse[0].searchResult[0].item;
2508
    totalPricingEntries[1] = Number(objArray.findCompletedItemsResponse[0].paginationOutput[0].totalEntries);
2509
    if (totalPricingEntries[1] > 0) {
2510
        priceItem(array, 1);
2511
    }
2 - 2512
}
2513
 
2514
function priceItem(array, index) {
6 - 2515
    var i;
2516
    var Title;
2517
    var shippingCost = 0.0;
2518
    var itemCost = 0.0;
2519
    var totalCost = 0.0;
2520
    var totalCostInt = 0;
2521
    var sellingStatus;
2522
    var sellingState;
2523
    var bidCount;
2524
    var condInd;
2525
    var condition;
2526
    var conditionId;
2527
    var shippingInfo;
2528
    var shippingServiceCost;
2529
    var convertedCurrentPrice;
2530
    var listingInfo;
2531
    var convertedBuyItNowPrice;
2532
    var JsonObj;
2 - 2533
 
6 - 2534
    if (array === undefined) {
2535
        return;
2536
    }
2 - 2537
 
6 - 2538
    if (totalPricingEntries[index] < 1) {
2539
        maxPricingPages[index] = 0;
2540
    } else {
2541
        maxPricingPages[index] = (totalPricingEntries[index] / 100) > 100 ? 100 : Math.trunc(totalPricingEntries[index] / 100.0) + 1;
2542
    }
2 - 2543
 
6 - 2544
    for (i = 0; i < array.length; i++) {
2545
        JsonObj = array[i];
2 - 2546
 
6 - 2547
        Title = JsonObj.title[0].toLowerCase();
2548
        if (Title.includes("disc only") > 0 ||
2549
            Title.includes("disk only") > 0 ||
2550
            Title.includes("only disc") > 0 ||
2551
            Title.includes("only disk") > 0 ||
2552
            Title.search(/dis[ck].*only/) > 0) {
2553
            continue; // exclude "disc only listing
2554
        }
2 - 2555
 
6 - 2556
        condition = JsonObj.condition;
2557
        if (condition) {
2558
            conditionId = condition[0].conditionId;
2559
            if (conditionId == 1000 || conditionId == 1500 || conditionId == 2750) {
2560
                condInd = 1;
2561
            } else if (conditionId <= 4000) {
2562
                condInd = 2;
2563
            } else {
2564
                continue; // Only 'Very Good' and better
2565
            }
2566
        } else {
2567
            condInd = 2;
2568
        }
2 - 2569
 
6 - 2570
        shippingInfo = JsonObj.shippingInfo;
2571
        shippingServiceCost = shippingInfo[0].shippingServiceCost;
2572
        if (shippingServiceCost) {
2573
            shippingCost = Number(shippingServiceCost[0].__value__);
2574
        } else {
2575
            shippingCost = 0.0;
2576
        }
2 - 2577
 
6 - 2578
        sellingStatus = JsonObj.sellingStatus;
2579
        sellingState = sellingStatus[0].sellingState;
2580
        bidCount = sellingStatus[0].bidCount;
2581
        convertedCurrentPrice = sellingStatus[0].convertedCurrentPrice;
2582
        itemCost = Number(convertedCurrentPrice[0].__value__);
2 - 2583
 
6 - 2584
        listingInfo = JsonObj.listingInfo;
2585
        convertedBuyItNowPrice = listingInfo[0].convertedBuyItNowPrice;
2586
        if (bidCount === 0 && convertedBuyItNowPrice) {
2587
            itemCost = Number(convertedBuyItNowPrice[0].__value__);
2588
        }
2 - 2589
 
6 - 2590
        if (condition) {
2591
            conditionId = condition[0].conditionId;
2592
            if (conditionId == 1000 || conditionId == 1500 || conditionId == 2750) {
2593
                condInd = 1;
2594
            } else {
2595
                condInd = 2;
2596
            }
2597
        } else {
2598
            condInd = 2;
2599
        }
2 - 2600
 
6 - 2601
        totalCost = itemCost + shippingCost;
2602
        totalCostInt = Math.ceil(totalCost);
2 - 2603
 
6 - 2604
        if (sellingState == "Active") {
2605
            if (totalCost < minActive[0] || !minActive[0]) {
2606
                minActive[0] = totalCost;
2607
            }
2608
            if (totalCost > maxActive[0]) {
2609
                maxActive[0] = totalCost;
2610
            }
2611
            avgActive[0] += totalCost;
2612
            ++noActive[0];
2 - 2613
 
6 - 2614
            if (totalCost < minActive[condInd] || !minActive[condInd]) {
2615
                minActive[condInd] = totalCost;
2616
            }
2617
            if (totalCost > maxActive[condInd]) {
2618
                maxActive[condInd] = totalCost;
2619
            }
2620
            avgActive[condInd] += totalCost;
2621
            ++noActive[condInd];
2 - 2622
 
6 - 2623
            if (condInd == 1) {
2624
                if (newActiveBreakdown[totalCostInt] === undefined) {
2625
                    newActiveBreakdown[totalCostInt] = 0;
2626
                }
2627
                ++newActiveBreakdown[totalCostInt];
2628
            } else {
2629
                if (usedActiveBreakdown[totalCostInt] === undefined) {
2630
                    usedActiveBreakdown[totalCostInt] = 0;
2631
                }
2632
                ++usedActiveBreakdown[totalCostInt];
2633
            }
2634
        } else if (sellingState == "EndedWithSales") {
2635
            if (totalCost < minSold[0] || !minSold[0]) {
2636
                minSold[0] = totalCost;
2637
            }
2638
            if (totalCost > maxSold[0]) {
2639
                maxSold[0] = totalCost;
2640
            }
2641
            avgSold[0] += totalCost;
2642
            ++noSold[0];
2 - 2643
 
6 - 2644
            if (totalCost < minSold[condInd] || !minSold[condInd]) {
2645
                minSold[condInd] = totalCost;
2646
            }
2647
            if (totalCost > maxSold[condInd]) {
2648
                maxSold[condInd] = totalCost;
2649
            }
2650
            avgSold[condInd] += totalCost;
2651
            ++noSold[condInd];
2 - 2652
 
6 - 2653
            if (condInd == 1) {
2654
                if (newSoldBreakdown[totalCostInt] === undefined) {
2655
                    newSoldBreakdown[totalCostInt] = 0;
2656
                }
2657
                ++newSoldBreakdown[totalCostInt];
2658
            } else {
2659
                if (usedSoldBreakdown[totalCostInt] === undefined) {
2660
                    usedSoldBreakdown[totalCostInt] = 0;
2661
                }
2662
                ++usedSoldBreakdown[totalCostInt];
2663
            }
2664
        } else /* Unsold */ {
2665
            if (totalCost < minUnsold[0] || !minUnsold[0]) {
2666
                minUnsold[0] = totalCost;
2667
            }
2668
            if (totalCost > maxUnsold[0]) {
2669
                maxUnsold[0] = totalCost;
2670
            }
2671
            avgUnsold[0] += totalCost;
2672
            ++noUnsold[0];
2 - 2673
 
6 - 2674
            if (totalCost < minUnsold[condInd] || !minUnsold[condInd]) {
2675
                minUnsold[condInd] = totalCost;
2676
            }
2677
            if (totalCost > maxUnsold[condInd]) {
2678
                maxUnsold[condInd] = totalCost;
2679
            }
2680
            avgUnsold[condInd] += totalCost;
2681
            ++noUnsold[condInd];
2682
        }
2683
    }
2 - 2684
 
6 - 2685
    var x = document.getElementById("prices");
2686
    if (x.className.indexOf("w3-show") == -1) {
2687
        x.className += " w3-show";
2688
    }
2 - 2689
 
6 - 2690
    var str = '<h3>Pricing Information (Shipping included)</h3>';
30 - 2691
    str += '<table class="table table-striped table-bordered table-hover">';
2692
    str += '	<thead class="thead-dark">';
6 - 2693
    str += '	<tr>';
2694
    str += '		<th></th>';
2695
    str += '		<th>Number</th>';
2696
    str += '        <th>Minimum</th>';
2697
    str += '        <th>Maximum</th>';
2698
    str += '        <th>Average</th>';
2699
    str += '	</tr>';
30 - 2700
    str += '	</thead>';
2701
    str += '	<tbody>';
6 - 2702
    str += '	<tr>';
2703
    str += '		<td>Active</td>';
2704
    str += '		<td>' + noActive[0] + '<br/>' + noActive[1] + ' / ' + noActive[2] + '</td>';
2705
    str += '		<td>$' + Number(minActive[0]).toFixed(2) + '<br/>$' + Number(minActive[1]).toFixed(2) + ' / $' + Number(minActive[2]).toFixed(2) + '</td>';
2706
    str += '		<td>$' + Number(maxActive[0]).toFixed(2) + '<br/>$' + Number(maxActive[1]).toFixed(2) + ' / $' + Number(maxActive[2]).toFixed(2) + '</td>';
2707
    str += '		<td>';
2708
    if (noActive[0]) {
2709
        str += '$' + Number(avgActive[0] / noActive[0]).toFixed(2);
2710
        str += '<br/>$' + (noActive[1] > 0 ? Number(avgActive[1] / noActive[1]).toFixed(2) : 0.00);
2711
        str += ' / $' + (noActive[2] > 0 ? Number(avgActive[2] / noActive[2]).toFixed(2) : 0.00);
2712
    }
2713
    str += '</td>';
2714
    str += '	</tr>';
2 - 2715
 
6 - 2716
    str += '<tr><td colspan="5">';
30 - 2717
    str += '<canvas id="activeChart" width="640" height="320" style="border:1px solid #000000;"></canvas>';
6 - 2718
    str += '</td></tr>';
2 - 2719
 
6 - 2720
    str += '	<tr>';
2721
    str += '		<td>Sold</td>';
2722
    str += '		<td>' + noSold[0] + '<br/>' + noSold[1] + ' / ' + noSold[2] + '</td>';
2723
    str += '		<td>$' + Number(minSold[0]).toFixed(2) + '<br/>$' + Number(minSold[1]).toFixed(2) + ' / $' + Number(minSold[2]).toFixed(2) + '</td>';
2724
    str += '		<td>$' + Number(maxSold[0]).toFixed(2) + '<br/>$' + Number(maxSold[1]).toFixed(2) + ' / $' + Number(maxSold[2]).toFixed(2) + '</td>';
2725
    str += '		<td>';
2726
    if (noSold[0]) {
2727
        str += '$' + Number(avgSold[0] / noSold[0]).toFixed(2);
2728
        str += '<br/>$' + (noSold[1] > 0 ? Number(avgSold[1] / noSold[1]).toFixed(2) : 0.00);
2729
        str += ' / $' + (noSold[2] > 0 ? Number(avgSold[2] / noSold[2]).toFixed(2) : 0.00);
2730
    }
2731
    str += '</td>';
2732
    str += '	</tr>';
2 - 2733
 
6 - 2734
    str += '<tr><td colspan="5">';
30 - 2735
    str += '<canvas id="soldChart" width="640" height="320" style="border:1px solid #000000;"></canvas>';
6 - 2736
    str += '</td></tr>';
2 - 2737
 
6 - 2738
    str += '	<tr>';
2739
    str += '		<td>Unsold</td>';
2740
    str += '		<td>' + noUnsold[0] + '<br/>' + noUnsold[1] + ' / ' + noUnsold[2] + '</td>';
2741
    str += '		<td>$' + Number(minUnsold[0]).toFixed(2) + '<br/>$' + Number(minUnsold[1]).toFixed(2) + ' / $' + Number(minUnsold[2]).toFixed(2) + '</td>';
2742
    str += '		<td>$' + Number(maxUnsold[0]).toFixed(2) + '<br/>$' + Number(maxUnsold[1]).toFixed(2) + ' / $' + Number(maxUnsold[2]).toFixed(2) + '</td>';
2743
    str += '		<td>';
2744
    if (noUnsold[0]) {
2745
        str += '$' + Number(avgUnsold[0] / noUnsold[0]).toFixed(2);
2746
        str += '<br/>$' + (noUnsold[1] > 0 ? Number(avgUnsold[1] / noUnsold[1]).toFixed(2) : 0.00);
2747
        str += ' / $' + (noUnsold[2] > 0 ? Number(avgUnsold[2] / noUnsold[2]).toFixed(2) : 0.00);
2748
    }
2749
    str += '</td>';
2750
    str += '	</tr>';
30 - 2751
    str += '	</tbody>';
6 - 2752
    str += '</table>';
2 - 2753
 
6 - 2754
    x.innerHTML = str;
2 - 2755
 
6 - 2756
    pricingGraphs(0, usedActiveBreakdown, newActiveBreakdown);
2757
    pricingGraphs(1, usedSoldBreakdown, newSoldBreakdown);
2 - 2758
}
2759
 
2760
function pricingGraphs(index, usedBreakdown, newBreakdown) {
6 - 2761
    var i;
2762
    var myChart;
2763
    var newData = [];
2764
    var usedData = [];
2765
    var labelData = [];
2766
    var ctx = document.getElementById(index === 0 ? 'activeChart' : 'soldChart').getContext('2d');
2767
    var min = findMin(usedBreakdown, newBreakdown);
2768
    var max = findMax(usedBreakdown, newBreakdown);
2 - 2769
 
6 - 2770
    for (i = min; i < max; i++) {
2771
        labelData.push('<$' + i);
2 - 2772
 
6 - 2773
        if (usedBreakdown[i] === undefined) {
2774
            usedData.push(0);
2775
        } else {
2776
            usedData.push(usedBreakdown[i]);
2777
        }
2 - 2778
 
6 - 2779
        if (newBreakdown[i] === undefined) {
2780
            newData.push(0);
2781
        } else {
2782
            newData.push(newBreakdown[i]);
2783
        }
2784
    }
2 - 2785
 
6 - 2786
    myChart = new Chart(ctx, {
2787
        type: 'bar',
2788
        options: {
30 - 2789
            responsive: false,
2790
            maintainAspectRatio: false,
6 - 2791
            scales: {
2792
                yAxes: [{
2793
                    ticks: {
2794
                        fixedStepSize: 1
2795
                    }
2796
                }],
2797
            },
2798
        },
2799
        data: {
2800
            labels: labelData,
2801
            datasets: [{
2802
                label: 'Used',
2803
                data: usedData,
2804
                backgroundColor: "rgba(0,102,0,1)"
2805
            }, {
2806
                label: 'New',
2807
                data: newData,
2808
                backgroundColor: "rgba(204,0,0,1)"
2809
            }]
2810
        }
2811
    });
2 - 2812
}
2813
 
2814
function findMin(Used, New) {
6 - 2815
    var i;
2816
    var minUsed = 0,
2817
        minNew = 0;
2818
    var min = 0;
2 - 2819
 
6 - 2820
    for (i = 0; i < Used.length; i++) {
2821
        if (Used[i] !== undefined) {
2822
            minUsed = i;
2823
            break;
2824
        }
2825
    }
2 - 2826
 
6 - 2827
    for (i = 0; i < New.length; i++) {
2828
        if (New[i] !== undefined) {
2829
            minNew = i;
2830
            break;
2831
        }
2832
    }
2 - 2833
 
6 - 2834
    if (minUsed > 0 && minNew > 0) {
2835
        min = Math.min(minUsed, minNew);
2836
    } else if (minUsed > 0) {
2837
        min = minUsed;
2838
    } else if (minNew > 0) {
2839
        min = minNew;
2840
    }
2 - 2841
 
6 - 2842
    return min;
2 - 2843
}
2844
 
2845
function findMax(Used, New) {
6 - 2846
    var max = 0;
2 - 2847
 
6 - 2848
    if (Used.length >= New.length) {
2849
        max = Used.length;
2850
    } else if (New.length >= Used.length) {
2851
        max = New.length;
2852
    }
2 - 2853
 
6 - 2854
    return max;
2 - 2855
}
2856
 
2857
function listButtonHot(flag) {
6 - 2858
    var i;
2859
    var x = [];
2 - 2860
 
6 - 2861
    x[0] = document.getElementById("list");
2862
    x[1] = document.getElementById("savexml");
2 - 2863
 
6 - 2864
    for (i = 0; i < 2; i++) {
2865
        if (flag === true) {
30 - 2866
            x[i].className = x[i].className.replace(" btn-danger", " btn-success");
6 - 2867
        } else {
30 - 2868
            x[i].className = x[i].className.replace(" btn-success", " btn-danger");
6 - 2869
        }
2870
    }
2 - 2871
}
2872
 
2873
function clearStatusWindows() {
6 - 2874
    var x = document.getElementById("results");
2875
    x.innerHTML = "";
2876
    x.className = x.className.replace(" w3-show", "");
2877
    x = document.getElementById("prices");
2878
    x.innerHTML = "";
2879
    x.className = x.className.replace(" w3-show", "");
2880
    x = document.getElementById("discogsReleases");
2881
    x.innerHTML = "";
2882
    x.className = x.className.replace(" w3-show", "");
2 - 2883
}
2884
 
2885
function pictureLoad(flag) {
6 - 2886
    picturesAreLoaded = flag;
2 - 2887
}
2888
 
2889
function reformatCdTitle(str) {
6 - 2890
    if (str.includes("Various Artists")) {
2891
        return str;
2892
    }
2 - 2893
 
6 - 2894
    var n = str.lastIndexOf(" by ");
2 - 2895
 
6 - 2896
    if (n > 0) {
2897
        var title = str.substr(0, n);
2898
        var rest = str.substr(n + 4);
2899
        n = rest.indexOf("(");
2900
        var artist = rest.substr(0, n).trim();
2901
        var info = rest.substr(n);
2902
        return (artist + " - " + title + " " + info);
2903
    }
2 - 2904
 
6 - 2905
    return str;
2 - 2906
}
2907
 
2908
function extractFromTitle() {
6 - 2909
    var titleField = document.getElementById("title");
36 - 2910
    var n, s, l;
2 - 2911
 
6 - 2912
    titleField.value = titleField.value.trim().replace(/[\u2012\u2013\u2014\u2015]/, '-').replace(/\u200E/, '').replace(/  +/g, ' ');
2913
    printTitleLength();
2 - 2914
 
6 - 2915
    if (CC == 1) {
2916
        if (titleField.value.indexOf(', EP,') > 0) {
30 - 2917
            $('#cdDuration').selectpicker('val', 'EP');
170 - 2918
        } else if (titleField.value.indexOf(', Maxi-Single,') > 0 || titleField.value.indexOf('[Maxi Single]') > 0) {
30 - 2919
            $('#cdDuration').selectpicker('val', 'Maxi-Single');
6 - 2920
        } else if (titleField.value.indexOf(', Single,') > 0) {
30 - 2921
            $('#cdDuration').selectpicker('val', 'Single');
6 - 2922
        }
30 - 2923
        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
2 - 2924
 
6 - 2925
        if (titleField.value.indexOf(', Digipak,') > 0) {
2926
            document.getElementById("cdDigipak").checked = true;
170 - 2927
            setCdConditionDescription('D');
6 - 2928
        } else {
2929
            document.getElementById("cdDigipak").checked = false;
170 - 2930
            setCdConditionDescription('S');
6 - 2931
        }
2 - 2932
 
6 - 2933
        if (titleField.value.includes('Various Artists')) {
2934
            document.getElementById("cdArtist").value = 'Various';
36 - 2935
        } else if (document.getElementById("cdArtist").value.length < 1) {
6 - 2936
            document.getElementById("cdArtist").value = titleField.value.substr(0, titleField.value.indexOf(" - "));
2937
        }
2 - 2938
 
6 - 2939
        n = titleField.value.indexOf('(CD');
2 - 2940
 
36 - 2941
        if (document.getElementById("cdRecordLabel").value.length < 1) {
2942
            document.getElementById("cdRecordLabel").value = titleField.value.substr(n).substr(titleField.value.substr(n).lastIndexOf(',') + 2);
2943
            document.getElementById("cdRecordLabel").value = document.getElementById("cdRecordLabel").value.substr(0, document.getElementById("cdRecordLabel").value.lastIndexOf(')'));
2944
        }
2945
 
2946
        if (document.getElementById("cdTitle").value.length < 1) {
40 - 2947
            var s = titleField.value.indexOf(' - ');
2948
            if (s == -1) { s = 0; }
2949
            var l = titleField.value.indexOf('(CD') - s;
2950
            if (s > 0) { s = s + 3; l = l - 3; }
2951
            document.getElementById("cdTitle").value = titleField.value.substr(s, l);
36 - 2952
        }
2953
 
6 - 2954
        document.getElementById("cdReleaseYear").value = getYear(titleField.value.substr(n));
2955
    }
2 - 2956
}
2957
 
2958
function reformatPastedTitle(e) {
6 - 2959
    var clipboardData, pastedData;
2960
    var x = document.getElementById("title");
2 - 2961
 
6 - 2962
    // Stop data actually being pasted
2963
    e.stopPropagation();
2964
    e.preventDefault();
2 - 2965
 
6 - 2966
    // Get pasted data via clipboard API
2967
    clipboardData = e.clipboardData || window.clipboardData;
2968
    pastedData = clipboardData.getData('Text');
2 - 2969
 
6 - 2970
    x.value = pastedData.trim().replace(/[\u2012\u2013\u2014\u2015]/, '-').replace(/\u200E/, '');
2971
    printTitleLength();
2 - 2972
}
2973
 
2974
function formatTrackList() {
6 - 2975
    var i;
2976
    var lines = [];
2977
    var x = document.getElementById("cdTracks");
2 - 2978
 
6 - 2979
    if (x.value.length < 1) {
2980
        return;
2981
    }
2 - 2982
 
6 - 2983
    lines = x.value.split('\n');
2 - 2984
 
6 - 2985
    for (i = 0; i < lines.length; i++) {
2986
        lines[i] = lines[i].trim();
2987
        lines[i] = lines[i].replace(/^\d+ /, '');
2988
        lines[i] = lines[i].replace(/^\d+. /, '');
2989
        lines[i] = lines[i].replace(/^\t/g, '');
2990
        lines[i] = lines[i].replace(/\t(\d+[:.]\d{2})$/, "\[$1\]");
2991
        lines[i] = lines[i].replace(/^\u0096/, '');
2992
        lines[i] = lines[i].replace(/ \t/, ' - ');
2993
        lines[i] = lines[i].replace(/[\u2012\u2013\u2014\u2015]/, '');
2994
        lines[i] = lines[i].replace(/@/g, '*');
2995
        lines[i] = lines[i].replace(/\*/g, '');
2996
    }
2 - 2997
 
6 - 2998
    x.value = lines.join('\n');
10 - 2999
    updateTracklistPreview();
2 - 3000
}
3001
 
3002
function splitTradingCardElements() {
6 - 3003
    // [Year] [First Last], [Position] at [Club] - [Card Manufacturer] [Series] -P-[Card Number] [Rookie] [S####] [other]
3004
    var elem;
3005
    var stop1 = 0,
3006
        stop2 = 0,
3007
        stop3 = 0;
3008
    var str;
3009
    var title;
3010
    var cardYear = '';
3011
    var cardPlayer = '';
3012
    var cardPosition = '';
3013
    var cardTeam = '';
3014
    var cardManufacturer = '';
3015
    var cardSeries = '';
3016
    var cardNumber = '';
3017
    var isRookie = false;
3018
    var isSerialized = false;
3019
    var isPoA = false;
2 - 3020
 
6 - 3021
    title = document.getElementById('keyword').value.replace('-P-', '#');
3022
    catalogTitle = title;
3023
    var res = title.split(' ');
3024
    for (elem = 0; elem < res.length; elem++) {
3025
        if (res[elem].endsWith(',')) {
3026
            stop1 = elem;
3027
        }
2 - 3028
 
6 - 3029
        if (res[elem] == '-') {
3030
            stop2 = elem - 1;
3031
        }
2 - 3032
 
6 - 3033
        if (res[elem].startsWith('#')) {
3034
            stop3 = elem;
3035
        }
3036
    }
2 - 3037
 
6 - 3038
    if (!stop1 || !stop2 || !stop3) {
3039
        return;
3040
    }
2 - 3041
 
6 - 3042
    cardYear = res[0];
3043
    for (elem = 1; elem <= stop1; elem++) {
3044
        cardPlayer += res[elem] + ' ';
3045
    }
3046
    cardPlayer = cardPlayer.substr(0, cardPlayer.length - 2);
2 - 3047
 
6 - 3048
    cardPosition = res[elem];
3049
    elem += 2;
2 - 3050
 
6 - 3051
    for (; elem <= stop2; elem++) {
3052
        cardTeam += res[elem] + ' ';
3053
    }
3054
    cardTeam = cardTeam.trim();
3055
    elem++;
2 - 3056
 
6 - 3057
    cardManufacturer = res[elem];
2 - 3058
 
6 - 3059
    if (cardManufacturer == "UpperDeck") {
3060
        catalogTitle = catalogTitle.replace("UpperDeck", "Upper Deck");
3061
        cardManufacturer = "Upper Deck";
3062
    } else if (cardManufacturer == "AceAuthentic") {
3063
        catalogTitle = catalogTitle.replace("AceAuthentic", "Ace Authentic");
3064
        cardManufacturer = "Ace Authentic";
3065
    } else if (cardManufacturer == "BeAPlayer") {
3066
        catalogTitle = catalogTitle.replace("BeAPlayer", "Be A Player");
3067
        cardManufacturer = "Be A Player";
3068
    } else if (cardManufacturer == "CollectorsEdge") {
3069
        catalogTitle = catalogTitle.replace("CollectorsEdge", "Collector's Edge");
3070
        cardManufacturer = "Collector's Edge";
3071
    } else if (cardManufacturer == "GoalLine") {
3072
        catalogTitle = catalogTitle.replace("GoalLine", "Goal Line");
3073
        cardManufacturer = "Goal Line";
3074
    } else if (cardManufacturer == "InTheGame") {
3075
        catalogTitle = catalogTitle.replace("InTheGame", "In the Game");
3076
        cardManufacturer = "In the Game";
3077
    } else if (cardManufacturer == "OnyxAuthenticated") {
3078
        catalogTitle = catalogTitle.replace("OnyxAuthenticated", "Onyx Authenticated");
3079
        cardManufacturer = "Onyx Authenticated";
3080
    } else if (cardManufacturer == "PressPass") {
3081
        catalogTitle = catalogTitle.replace("PressPass", "Press Pass");
3082
        cardManufacturer = "Press Pass";
3083
    } else if (cardManufacturer == "ProSet") {
3084
        catalogTitle = catalogTitle.replace("ProSet", "Pro Set");
3085
        cardManufacturer = "Pro Set";
3086
    }
3087
    elem++;
2 - 3088
 
6 - 3089
    for (; elem < stop3; elem++) {
3090
        cardSeries += res[elem] + ' ';
3091
    }
3092
    cardSeries = cardSeries.trim();
3093
    cardNumber = res[elem];
3094
    elem++;
2 - 3095
 
6 - 3096
    for (; elem < res.length; elem++) {
3097
        if (res[elem] == "Gameworn") {
3098
            isPoA = true;
3099
        }
2 - 3100
 
6 - 3101
        if (res[elem] == "Rookie") {
3102
            isRookie = true;
3103
        }
2 - 3104
 
6 - 3105
        if (res[elem].startsWith("S") && isNumeric(res[elem].substr(1))) {
3106
            catalogTitle = catalogTitle.replace(res[elem], "/" + res[elem].substr(1));
3107
            isSerialized = true;
3108
        }
3109
    }
2 - 3110
 
6 - 3111
    str = '<h3>' + title + '</h3>';
3112
    str += '<p>';
3113
    str += 'Season: ' + cardYear + '<br/>';
3114
    str += 'Player: ' + cardPlayer + '<br/>';
3115
    str += 'Position: ' + cardPosition + '<br/>';
3116
    str += 'Team: ' + cardTeam + '<br/>';
3117
    str += 'Card Manufacturer: ' + cardManufacturer + '<br/>';
3118
    if (cardSeries.length > 0) {
3119
        str += 'Card Series: ' + cardSeries + '<br/>';
3120
    }
3121
    str += 'Card Number: ' + cardNumber + '<br/>';
3122
    if (isRookie) {
3123
        str += 'Rookie<br/>';
3124
    }
3125
    if (isSerialized) {
3126
        str += 'Serialized<br/>';
3127
    }
3128
    if (isPoA) {
3129
        str += 'Piece of Authentic<br/>';
3130
    }
3131
    str += '</p>';
2 - 3132
 
6 - 3133
    var x = document.getElementById("productinfo");
3134
    x.innerHTML = str;
2 - 3135
 
6 - 3136
    document.getElementById("tcPlayer").value = cardPlayer;
3137
    document.getElementById("tcPosition").value = cardPosition;
3138
    document.getElementById("tcTeam").value = cardTeam;
3139
    document.getElementById("tcSeason").value = cardYear;
3140
    document.getElementById("tcManufacturer").value = cardManufacturer;
3141
    document.getElementById("tcNumber").value = cardNumber;
3142
    document.getElementById("tcSeries").value = cardSeries;
3143
    document.getElementById("tcRookie").checked = false;
3144
    document.getElementById("tcPoA").checked = false;
3145
    document.getElementById("tcSerial").checked = false;
2 - 3146
 
6 - 3147
    if (isRookie) {
3148
        document.getElementById("tcRookie").checked = true;
3149
    }
2 - 3150
 
6 - 3151
    if (isPoA) {
3152
        document.getElementById("tcPoA").checked = true;
3153
    }
2 - 3154
 
6 - 3155
    if (isSerialized) {
3156
        document.getElementById("tcSerial").checked = true;
3157
    }
2 - 3158
 
6 - 3159
    var currentCategory = document.getElementById("category").value;
3160
    if (currentCategory != "213" && currentCategory != "214" && currentCategory != "215" && currentCategory != "216") {
30 - 3161
        $('#category').selectpicker('val', "");
3162
        $('#category').selectpicker('refresh');
6 - 3163
    }
2 - 3164
 
6 - 3165
    x = document.getElementById("tradingCardDetails");
3166
    if (x.className.indexOf("w3-show") == -1) {
3167
        x.className += " w3-show";
3168
    }
2 - 3169
}
3170
 
3171
function generateDescCore() {
6 - 3172
    DescCore = '';
2 - 3173
 
6 - 3174
    if (CC === 0) {
3175
        DescCore = '<p>';
3176
        DescCore += 'Format: ' + document.getElementById("bookFormat").value + '<br/>';
3177
        if (document.getElementById("bookAuthor").value.length > 0) {
3178
            DescCore += 'Author: ' + document.getElementById("bookAuthor").value.toString().replace(/,/g, ', ') + '<br/>';
3179
        }
3180
        if (document.getElementById("bookPublicationYear").value.length > 0) {
3181
            DescCore += 'Publication Year: ' + document.getElementById("bookPublicationYear").value + '<br/>';
3182
        }
3183
        if (document.getElementById("bookSubject").value.length > 0) {
3184
            DescCore += 'Subject: ' + document.getElementById("bookSubject").value + '<br/>';
3185
        }
3186
        if (document.getElementById("bookLanguage").value.length > 0) {
3187
            DescCore += 'Language: ' + document.getElementById("bookLanguage").value + '<br/>';
3188
        }
3189
        if (document.getElementById("bookCountry").value.length > 0) {
3190
            DescCore += 'Country: ' + document.getElementById("bookCountry").value + '<br/>';
3191
        }
3192
        if (document.getElementById("bookDustJacket").checked) {
3193
            DescCore += 'Dust Jacket<br/>';
3194
        }
3195
        if (document.getElementById("bookIllustrated").checked) {
3196
            DescCore += 'Illustrated<br/>';
3197
        }
3198
        if (document.getElementById("bookLargePrint").checked) {
3199
            DescCore += 'Large Print<br/>';
3200
        }
3201
        if (document.getElementById("bookSigned").checked) {
3202
            DescCore += 'Signed<br/>';
3203
        }
3204
        DescCore += '</p>';
3205
    } else if (CC == 1) {
10 - 3206
        DescCore = generateTracklist();
6 - 3207
    } else if (CC == 2) {
3208
        DescCore = '<p>';
3209
        DescCore += 'Format: ' + document.getElementById("dvdFormat").value + '<br/>';
3210
        if (document.getElementById("dvdActor").value.length > 0) {
3211
            DescCore += 'Actors: ' + document.getElementById("dvdActor").value.toString().replace(/,/g, ', ') + '<br/>';
3212
        }
3213
        if (document.getElementById("dvdLeadingRole").value.length > 0) {
3214
            DescCore += 'Leading Role: ' + document.getElementById("dvdLeadingRole").value.toString().replace(/,/g, ', ') + '<br/>';
3215
        }
3216
        if (document.getElementById("dvdDirector").value.length > 0) {
3217
            DescCore += 'Director: ' + document.getElementById("dvdDirector").value.toString().replace(/,/g, ', ') + '<br/>';
3218
        }
3219
        if (document.getElementById("dvdDVDEditionYear").value.length > 0) {
3220
            DescCore += 'DVD Edition Year: ' + document.getElementById("dvdDVDEditionYear").value + '<br/>';
3221
        }
3222
        if (document.getElementById("dvdReleaseYear").value.length > 0) {
3223
            DescCore += 'Movie Release Year: ' + document.getElementById("dvdReleaseYear").value + '<br/>';
3224
        }
3225
        if (document.getElementById("dvdGenre").value.length > 1) {
3226
            DescCore += 'Genre: ' + document.getElementById("dvdGenre").value + '<br/>';
3227
        }
3228
        if (document.getElementById("dvdRating").value.length > 1) {
3229
            DescCore += 'Rating: ' + document.getElementById("dvdRating").value + '<br/>';
3230
        }
3231
        if (document.getElementById("dvdRegionCode").value.length > 1) {
3232
            DescCore += 'Region Code: ' + document.getElementById("dvdRegionCode").value + '<br/>';
3233
        }
3234
        if (document.getElementById("dvdSeason").value.length > 0 && document.getElementById("dvdSeason").value != ' ') {
3235
            DescCore += 'Season: ' + document.getElementById("dvdSeason").value + '<br/>';
3236
        }
3237
        if (document.getElementById("dvdCountry").value.length > 0) {
3238
            DescCore += 'Country/Region of Manufacture: ' + document.getElementById("dvdCountry").value + '<br/>';
3239
        }
3240
        if (document.getElementById("dvd3D").checked) {
3241
            DescCore += '3D<br/>';
3242
        }
3243
        if (document.getElementById("dvdAnniversaryEdition").checked) {
3244
            DescCore += 'Anniversary Edition<br/>';
3245
        }
3246
        if (document.getElementById("dvdBoxSet").checked) {
3247
            DescCore += 'Box Set<br/>';
3248
        }
3249
        if (document.getElementById("dvdCollectorsEdition").checked) {
3250
            DescCore += 'Collector\'s Edition<br/>';
3251
        }
3252
        if (document.getElementById("dvdDeluxeEdition").checked) {
3253
            DescCore += 'Deluxe Edition<br/>';
3254
        }
3255
        if (document.getElementById("dvdDirectorsCut").checked) {
3256
            DescCore += 'Director\'s Cut<br/>';
3257
        }
3258
        if (document.getElementById("dvdExtendedEdition").checked) {
3259
            DescCore += 'Extended Edition<br/>';
3260
        }
3261
        if (document.getElementById("dvdFullScreen").checked) {
3262
            DescCore += 'Full Screen<br/>';
3263
        }
3264
        if (document.getElementById("dvdLimitedEdition").checked) {
3265
            DescCore += 'Limited Edition<br/>';
3266
        }
3267
        if (document.getElementById("dvdPromo").checked) {
3268
            DescCore += 'Promo<br/>';
3269
        }
3270
        if (document.getElementById("dvdSignatureCollection").checked) {
3271
            DescCore += 'Signature Collection<br/>';
3272
        }
3273
        if (document.getElementById("dvdSpecialEdition").checked) {
3274
            DescCore += 'Special Edition<br/>';
3275
        }
3276
        if (document.getElementById("dvdSteelbook").checked) {
3277
            DescCore += 'Steelbook<br/>';
3278
        }
3279
        if (document.getElementById("dvdUnratedEdition").checked) {
3280
            DescCore += 'Unrated Edition<br/>';
3281
        }
3282
        if (document.getElementById("dvdWidescreen").checked) {
3283
            DescCore += 'Widescreen<br/>';
3284
        }
3285
        DescCore += '</p>';
3286
    } else if (CC == 3) {
3287
        DescCore = '<p>';
3288
        DescCore += 'Season: ' + document.getElementById("tcSeason").value + '<br/>';
3289
        DescCore += 'Player: ' + document.getElementById("tcPlayer").value + '<br/>';
3290
        DescCore += 'Position: ' + document.getElementById("tcPosition").value + '<br/>';
3291
        DescCore += 'Team: ' + document.getElementById("tcTeam").value + '<br/>';
3292
        DescCore += 'Card Manufacturer: ' + document.getElementById("tcManufacturer").value + '<br/>';
3293
        if (document.getElementById("tcSeries").value.length > 0) {
3294
            DescCore += 'Card Series: ' + document.getElementById("tcSeries").value + '<br/>';
3295
        }
3296
        DescCore += 'Card Number: ' + document.getElementById("tcNumber").value + '<br/>';
3297
        if (document.getElementById("tcRookie").checked) {
3298
            DescCore += 'Rookie<br/>';
3299
        }
3300
        if (document.getElementById("tcSerial").checked) {
3301
            DescCore += 'Serialized<br/>';
3302
        }
3303
        if (document.getElementById("tcPoA").checked) {
3304
            DescCore += 'Piece of Authentic<br/>';
3305
        }
3306
        DescCore += '</p>';
3307
    }
2 - 3308
}
3309
 
10 - 3310
function generateTracklist() {
3311
    var str = '';
3312
    var listType = 'ol';
30 - 3313
 
10 - 3314
    if (document.getElementById("cdTracks").value.length > 0) {
3315
        if (document.getElementById("cdUnorderedTrackList").checked) {
3316
            listType = 'ul';
3317
        }
3318
 
3319
        str += '<p>Tracklist:</p><' + listType + ' class="w3-' + listType + '">';
3320
        var lines = document.getElementById("cdTracks").value.split('\n');
3321
        for (var i = 0; i < lines.length; i++) {
3322
            str += '<li>' + lines[i] + '</li>';
3323
        }
3324
        str += '</' + listType + '>';
3325
    }
30 - 3326
 
10 - 3327
    return (str);
3328
}
3329
 
3330
function updateTracklistPreview() {
3331
    document.getElementById("tracklistPreview").innerHTML = generateTracklist();
3332
}
3333
 
2 - 3334
function generateItemSpecifics(xw) {
6 - 3335
    xw.writeStartElement('ItemSpecifics');
2 - 3336
 
6 - 3337
    if (CC === 0) {
3338
        xw.writeStartElement('NameValueList');
3339
        xw.writeElementString('Name', 'Author');
3340
        xw.writeElementString('Value', escapeXml(document.getElementById("bookAuthor").value));
3341
        xw.writeEndElement(); /* NameValueList */
3342
        xw.writeStartElement('NameValueList');
3343
        xw.writeElementString('Name', 'Format');
3344
        xw.writeElementString('Value', escapeXml(document.getElementById("bookFormat").value));
3345
        xw.writeEndElement(); /* NameValueList */
3346
        xw.writeStartElement('NameValueList');
3347
        xw.writeElementString('Name', 'Publication Year');
3348
        xw.writeElementString('Value', escapeXml(document.getElementById("bookPublicationYear").value));
3349
        xw.writeEndElement(); /* NameValueList */
3350
        xw.writeStartElement('NameValueList');
3351
        xw.writeElementString('Name', 'Subject');
3352
        xw.writeElementString('Value', escapeXml(document.getElementById("bookSubject").value));
3353
        xw.writeEndElement(); /* NameValueList */
3354
        xw.writeStartElement('NameValueList');
3355
        xw.writeElementString('Name', 'Language');
3356
        xw.writeElementString('Value', escapeXml(document.getElementById("bookLanguage").value));
3357
        xw.writeEndElement(); /* NameValueList */
3358
        xw.writeStartElement('NameValueList');
3359
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3360
        xw.writeElementString('Value', escapeXml(document.getElementById("bookCountry").value));
3361
        xw.writeEndElement(); /* NameValueList */
2 - 3362
 
6 - 3363
        if (document.getElementById("bookDustJacket").checked ||
3364
            document.getElementById("bookIllustrated").checked ||
3365
            document.getElementById("bookLargePrint").checked ||
3366
            document.getElementById("bookSigned").checked) {
3367
            xw.writeStartElement('NameValueList');
3368
            xw.writeElementString('Name', 'Special Attributes');
3369
            itemSpecificCheckbox(xw, "bookDustJacket", 'Dust Jacket');
3370
            itemSpecificCheckbox(xw, "bookIllustrated", 'Illustrated');
3371
            itemSpecificCheckbox(xw, "bookLargePrint", 'Large Print');
3372
            itemSpecificCheckbox(xw, "bookSigned", 'Signed');
3373
            xw.writeEndElement(); /* NameValueList */
3374
        }
3375
    } else if (CC == 1) {
36 - 3376
        var modifiedItem = escapeXml(document.getElementById("cdModified").value);
3377
 
6 - 3378
        xw.writeStartElement('NameValueList');
3379
        xw.writeElementString('Name', 'Genre');
3380
        xw.writeElementString('Value', escapeXml(document.getElementById("cdGenre").value));
3381
        xw.writeEndElement(); /* NameValueList */
3382
        xw.writeStartElement('NameValueList');
3383
        xw.writeElementString('Name', 'Duration');
3384
        xw.writeElementString('Value', escapeXml(document.getElementById("cdDuration").value));
3385
        xw.writeEndElement(); /* NameValueList */
3386
        xw.writeStartElement('NameValueList');
3387
        xw.writeElementString('Name', 'Record Label');
3388
        xw.writeElementString('Value', escapeXml(document.getElementById("cdRecordLabel").value));
3389
        xw.writeEndElement(); /* NameValueList */
3390
        xw.writeStartElement('NameValueList');
3391
        xw.writeElementString('Name', 'Release Year');
3392
        xw.writeElementString('Value', escapeXml(document.getElementById("cdReleaseYear").value));
3393
        xw.writeEndElement(); /* NameValueList */
3394
        xw.writeStartElement('NameValueList');
3395
        xw.writeElementString('Name', 'Artist');
3396
        xw.writeElementString('Value', escapeXml(document.getElementById("cdArtist").value));
3397
        xw.writeEndElement(); /* NameValueList */
3398
        xw.writeStartElement('NameValueList');
3399
        xw.writeElementString('Name', 'Title');
3400
        xw.writeElementString('Value', escapeXml(document.getElementById("cdTitle").value));
3401
        xw.writeEndElement(); /* NameValueList */
3402
        xw.writeStartElement('NameValueList');
3403
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3404
        xw.writeElementString('Value', escapeXml(document.getElementById("cdCountry").value));
3405
        xw.writeEndElement(); /* NameValueList */
36 - 3406
        xw.writeStartElement('NameValueList');
3407
        xw.writeElementString('Name', 'Custom Bundle');
3408
        xw.writeElementString('Value', 'No');
3409
        xw.writeEndElement(); /* NameValueList */
3410
        xw.writeStartElement('NameValueList');
3411
        xw.writeElementString('Name', 'Language');
3412
        xw.writeElementString('Value', escapeXml(document.getElementById("cdLanguage").value));
3413
        xw.writeEndElement(); /* NameValueList */
3414
        xw.writeStartElement('NameValueList');
3415
        xw.writeElementString('Name', 'Modified Item');
3416
        xw.writeElementString('Value', modifiedItem);
3417
        xw.writeEndElement(); /* NameValueList */
3418
        if (modifiedItem == 'Yes') {
3419
            xw.writeStartElement('NameValueList');
3420
            xw.writeElementString('Name', 'Modification Description');
3421
            xw.writeElementString('Value', escapeXml(document.getElementById("cdModificationDescription").value));
3422
            xw.writeEndElement(); /* NameValueList */
3423
        }
2 - 3424
 
6 - 3425
        if (document.getElementById("cdCompilation").checked ||
3426
            document.getElementById("cdDigipak").checked ||
3427
            document.getElementById("cdDualDisc").checked ||
3428
            document.getElementById("cdEnhanced").checked ||
36 - 3429
            document.getElementById("cdImport").checked ||
6 - 3430
            document.getElementById("cdHDCD").checked) {
3431
            xw.writeStartElement('NameValueList');
3432
            xw.writeElementString('Name', 'Special Attributes');
3433
            itemSpecificCheckbox(xw, "cdCompilation", 'Compilation');
3434
            itemSpecificCheckbox(xw, "cdDigipak", 'Digipak');
3435
            itemSpecificCheckbox(xw, "cdDualDisc", 'DualDisc');
3436
            itemSpecificCheckbox(xw, "cdEnhanced", 'Enhanced');
36 - 3437
            itemSpecificCheckbox(xw, "cdImport", 'Import');
6 - 3438
            itemSpecificCheckbox(xw, "cdHDCD", 'HDCD');
3439
            xw.writeEndElement(); /* NameValueList */
3440
        }
2 - 3441
 
6 - 3442
        if (document.getElementById("cdLiveRecording").checked ||
3443
            document.getElementById("cdPromo").checked ||
3444
            document.getElementById("cdReissue").checked ||
3445
            document.getElementById("cdRemastered").checked ||
40 - 3446
            document.getElementById("cdClub").checked ||
6 - 3447
            document.getElementById("cdGreatestHits").checked) {
3448
            xw.writeStartElement('NameValueList');
3449
            xw.writeElementString('Name', 'Edition');
3450
            itemSpecificCheckbox(xw, "cdLiveRecording", 'Live Recording');
3451
            itemSpecificCheckbox(xw, "cdPromo", 'Promo');
3452
            itemSpecificCheckbox(xw, "cdReissue", 'Reissue');
3453
            itemSpecificCheckbox(xw, "cdRemastered", 'Remastered');
40 - 3454
            itemSpecificCheckbox(xw, "cdClub", 'Club Edition');
6 - 3455
            itemSpecificCheckbox(xw, "cdGreatestHits", 'Greatest Hits');
3456
            xw.writeEndElement(); /* NameValueList */
3457
        }
3458
    } else if (CC == 2) {
3459
        xw.writeStartElement('NameValueList');
3460
        xw.writeElementString('Name', 'Format');
3461
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdFormat").value));
3462
        xw.writeEndElement(); /* NameValueList */
3463
        xw.writeStartElement('NameValueList');
3464
        xw.writeElementString('Name', 'Movie/TV Title');
3465
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdTitle").value));
3466
        xw.writeEndElement(); /* NameValueList */
3467
        xw.writeStartElement('NameValueList');
3468
        xw.writeElementString('Name', 'Actor');
3469
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdActor").value));
3470
        xw.writeEndElement(); /* NameValueList */
3471
        xw.writeStartElement('NameValueList');
3472
        xw.writeElementString('Name', 'Leading Role');
3473
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdLeadingRole").value));
3474
        xw.writeEndElement(); /* NameValueList */
3475
        xw.writeStartElement('NameValueList');
3476
        xw.writeElementString('Name', 'Release Year');
3477
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdReleaseYear").value));
3478
        xw.writeEndElement(); /* NameValueList */
3479
        xw.writeStartElement('NameValueList');
3480
        xw.writeElementString('Name', 'DVD Edition Year');
3481
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdDVDEditionYear").value));
3482
        xw.writeEndElement(); /* NameValueList */
3483
        xw.writeStartElement('NameValueList');
3484
        xw.writeElementString('Name', 'Director');
3485
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdDirector").value));
3486
        xw.writeEndElement(); /* NameValueList */
3487
        xw.writeStartElement('NameValueList');
3488
        xw.writeElementString('Name', 'Genre');
3489
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdGenre").value));
3490
        xw.writeEndElement(); /* NameValueList */
3491
        xw.writeStartElement('NameValueList');
3492
        xw.writeElementString('Name', 'Rating');
3493
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdRating").value));
3494
        xw.writeEndElement(); /* NameValueList */
3495
        xw.writeStartElement('NameValueList');
3496
        xw.writeElementString('Name', 'Region Code');
3497
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdRegionCode").value));
3498
        xw.writeEndElement(); /* NameValueList */
2 - 3499
 
6 - 3500
        if (document.getElementById("dvd3D").checked ||
3501
            document.getElementById("dvdAnniversaryEdition").checked ||
3502
            document.getElementById("dvdBoxSet").checked ||
3503
            document.getElementById("dvdCollectorsEdition").checked ||
3504
            document.getElementById("dvdDeluxeEdition").checked ||
3505
            document.getElementById("dvdDirectorsCut").checked ||
3506
            document.getElementById("dvdExtendedEdition").checked ||
3507
            document.getElementById("dvdFullScreen").checked ||
3508
            document.getElementById("dvdLimitedEdition").checked ||
3509
            document.getElementById("dvdPromo").checked ||
3510
            document.getElementById("dvdSignatureCollection").checked ||
3511
            document.getElementById("dvdSpecialEdition").checked ||
3512
            document.getElementById("dvdSteelbook").checked ||
3513
            document.getElementById("dvdUnratedEdition").checked ||
3514
            document.getElementById("dvdWidescreen").checked) {
3515
            xw.writeStartElement('NameValueList');
3516
            xw.writeElementString('Name', 'Edition');
3517
            itemSpecificCheckbox(xw, "dvd3D", '3D');
3518
            itemSpecificCheckbox(xw, "dvdAnniversaryEdition", 'Anniversary Edition');
3519
            itemSpecificCheckbox(xw, "dvdBoxSet", 'Box Set');
3520
            itemSpecificCheckbox(xw, "dvdCollectorsEdition", 'Collector&apos;s Edition');
3521
            itemSpecificCheckbox(xw, "dvdDeluxeEdition", 'Deluxe Edition');
3522
            itemSpecificCheckbox(xw, "dvdDirectorsCut", 'Director&apos;s Cut');
3523
            itemSpecificCheckbox(xw, "dvdExtendedEdition", 'Extended Edition');
3524
            itemSpecificCheckbox(xw, "dvdFullScreen", 'Full Screen');
3525
            itemSpecificCheckbox(xw, "dvdLimitedEdition", 'Limited Edition');
3526
            itemSpecificCheckbox(xw, "dvdPromo", 'Promo');
3527
            itemSpecificCheckbox(xw, "dvdSignatureCollection", 'Signature Collection');
3528
            itemSpecificCheckbox(xw, "dvdSpecialEdition", 'Special Edition');
3529
            itemSpecificCheckbox(xw, "dvdSteelbook", 'Steelbook');
3530
            itemSpecificCheckbox(xw, "dvdUnratedEdition", 'UnratedEdition');
3531
            itemSpecificCheckbox(xw, "dvdWidescreen", 'Widescreen');
3532
            xw.writeEndElement(); /* NameValueList */
3533
        }
2 - 3534
 
6 - 3535
        xw.writeStartElement('NameValueList');
3536
        xw.writeElementString('Name', 'Former Rental');
3537
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdRental").value));
3538
        xw.writeEndElement(); /* NameValueList */
3539
        xw.writeStartElement('NameValueList');
3540
        xw.writeElementString('Name', 'Season');
3541
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdSeason").value));
3542
        xw.writeEndElement(); /* NameValueList */
3543
        xw.writeStartElement('NameValueList');
3544
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3545
        xw.writeElementString('Value', escapeXml(document.getElementById("dvdCountry").value));
3546
        xw.writeEndElement(); /* NameValueList */
3547
    } else if (CC == 3) {
3548
        xw.writeStartElement('NameValueList');
3549
        xw.writeElementString('Name', 'Card Manufacturer');
3550
        xw.writeElementString('Value', escapeXml(document.getElementById("tcManufacturer").value));
3551
        xw.writeEndElement(); /* NameValueList */
2 - 3552
 
6 - 3553
        if (document.getElementById("tcRookie").checked ||
3554
            document.getElementById("tcSerial").checked ||
3555
            document.getElementById("tcPoA").checked) {
3556
            xw.writeStartElement('NameValueList');
3557
            xw.writeElementString('Name', 'Card Attributes');
3558
            if (document.getElementById("tcRookie").checked) {
3559
                itemSpecificCheckbox(xw, "tcRookie", 'Rookie');
3560
            }
3561
            if (document.getElementById("tcSerial").checked) {
3562
                itemSpecificCheckbox(xw, "tcSerial", 'Serial Numbered');
3563
            }
3564
            if (document.getElementById("tcPoA").checked) {
3565
                itemSpecificCheckbox(xw, "tcPoA", 'Piece of Authentic');
3566
            }
3567
            xw.writeEndElement(); /* NameValueList */
3568
        }
2 - 3569
 
6 - 3570
        xw.writeStartElement('NameValueList');
3571
        xw.writeElementString('Name', 'Product');
3572
        xw.writeElementString('Value', 'Single');
3573
        xw.writeEndElement(); /* NameValueList */
3574
        xw.writeStartElement('NameValueList');
3575
        xw.writeElementString('Name', 'Professional Grader');
3576
        xw.writeElementString('Value', 'Not Professionally Graded');
3577
        xw.writeEndElement(); /* NameValueList */
3578
        xw.writeStartElement('NameValueList');
3579
        xw.writeElementString('Name', 'Grade');
3580
        xw.writeElementString('Value', 'Ungraded');
3581
        xw.writeEndElement(); /* NameValueList */
3582
        xw.writeStartElement('NameValueList');
3583
        xw.writeElementString('Name', 'Original/Reprint');
3584
        xw.writeElementString('Value', 'Original');
3585
        xw.writeEndElement(); /* NameValueList */
3586
        //		xw.writeStartElement('NameValueList');
3587
        //		xw.writeElementString('Name', 'Autograph Authentication');
3588
        //		xw.writeElementString('Value', 'Not Authenticated');
3589
        //		xw.writeEndElement(); /* NameValueList */
3590
        //		xw.writeStartElement('NameValueList');
3591
        //		xw.writeElementString('Name', 'Autograph Format');
3592
        //		xw.writeElementString('Value', 'Not Autographed');
3593
        //		xw.writeEndElement(); /* NameValueList */
3594
        xw.writeStartElement('NameValueList');
3595
        xw.writeElementString('Name', 'Modified Item');
3596
        xw.writeElementString('Value', 'No');
3597
        xw.writeEndElement(); /* NameValueList */
3598
        xw.writeStartElement('NameValueList');
3599
        xw.writeElementString('Name', 'Player');
3600
        xw.writeElementString('Value', escapeXml(document.getElementById("tcPlayer").value));
3601
        xw.writeEndElement(); /* NameValueList */
3602
        xw.writeStartElement('NameValueList');
3603
        xw.writeElementString('Name', 'Team');
3604
        xw.writeElementString('Value', escapeXml(document.getElementById("tcTeam").value));
3605
        xw.writeEndElement(); /* NameValueList */
3606
        xw.writeStartElement('NameValueList');
3607
        xw.writeElementString('Name', 'Season');
3608
        xw.writeElementString('Value', escapeXml(document.getElementById("tcSeason").value));
3609
        xw.writeEndElement(); /* NameValueList */
3610
        xw.writeStartElement('NameValueList');
3611
        xw.writeElementString('Name', 'Year');
3612
        xw.writeElementString('Value', escapeXml(document.getElementById("tcSeason").value));
3613
        xw.writeEndElement(); /* NameValueList */
3614
        xw.writeStartElement('NameValueList');
3615
        xw.writeElementString('Name', 'Era');
3616
        if (category == '213') {
3617
            xw.writeElementString('Value', 'Modern (1981-Now)');
3618
        } else {
3619
            xw.writeElementString('Value', 'Modern (1970-Now)');
3620
        }
3621
        xw.writeEndElement(); /* NameValueList */
3622
        xw.writeStartElement('NameValueList');
3623
        xw.writeElementString('Name', 'League');
3624
        if (category == "215") {
3625
            xw.writeElementString('Value', 'NFL');
3626
        } else if (category == "213") {
3627
            xw.writeElementString('Value', 'Major League');
3628
        } else if (category == "214") {
3629
            xw.writeElementString('Value', 'NBA');
3630
        } else if (category == "216") {
3631
            xw.writeElementString('Value', 'NHL');
3632
        } else {
3633
            xw.writeElementString('Value', '');
3634
        }
3635
        xw.writeEndElement(); /* NameValueList */
3636
        xw.writeStartElement('NameValueList');
3637
        xw.writeElementString('Name', 'Card Number');
3638
        xw.writeElementString('Value', escapeXml(document.getElementById("tcNumber").value));
3639
        xw.writeEndElement(); /* NameValueList */
3640
        xw.writeStartElement('NameValueList');
3641
        xw.writeElementString('Name', 'Series');
3642
        xw.writeElementString('Value', escapeXml(document.getElementById("tcSeries").value));
3643
        xw.writeEndElement(); /* NameValueList */
3644
        xw.writeStartElement('NameValueList');
3645
        xw.writeElementString('Name', 'Country/Region of Manufacture');
3646
        xw.writeElementString('Value', 'United States');
3647
        xw.writeEndElement(); /* NameValueList */
3648
    }
2 - 3649
 
6 - 3650
    xw.writeEndElement(); /* ItemSpecifics */
2 - 3651
}
3652
 
3653
function itemSpecificCheckbox(xw, id, val) {
6 - 3654
    if (document.getElementById(id).checked) {
3655
        xw.writeElementString('Value', val);
3656
    }
2 - 3657
}
3658
 
3659
function _cb_findDuplicateListing(root) {
6 - 3660
    var x;
3661
    var response = root.findItemsAdvancedResponse[0];
3662
    var ack = response.ack;
3663
    if (ack != 'Success') {
53 - 3664
        x = document.getElementById("productinfoDuplicate").innerHTML += '<br/><span class="bg-danger"><strong>Duplicate Check Failed</strong></span>';
2 - 3665
 
6 - 3666
        if (ack == 'Failure' || ack == 'PartialFailure') {
3667
            return;
3668
        }
3669
    }
2 - 3670
 
6 - 3671
    var items = response.searchResult[0].item || [];
2 - 3672
 
6 - 3673
    if (Number(response.paginationOutput[0].totalEntries) > 0) {
53 - 3674
        document.getElementById("productinfoDuplicate").innerHTML += '<br/><span class="bg-danger"><strong>Duplicate, see Item Id <a href="https://www.ebay.com/itm/' + items[0].itemId + '" target="_blank">' + items[0].itemId + '</a></strong></span>';
6 - 3675
        isDuplicate = true;
3676
    }
2 - 3677
}
3678
 
3679
function findDuplicateListing() {
6 - 3680
    var keyword = document.getElementById('keyword').value;
2 - 3681
 
6 - 3682
    // Construct the request
3683
    url = configeBayFinding + "?";
3684
    url += "OPERATION-NAME=findItemsAdvanced";
3685
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3686
    url += "&SECURITY-APPNAME=" + configAppid;
3687
    url += "&GLOBAL-ID=EBAY-US";
3688
    url += "&RESPONSE-DATA-FORMAT=JSON";
3689
    url += "&REST-PAYLOAD";
3690
    url += "&keywords=";
3691
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3692
    url += "&paginationInput.entriesPerPage=1";
3693
    url += "&paginationInput.pageNumber=1";
3694
    url += "&itemFilter(0).name=Seller";
3695
    url += "&itemFilter(0).value=";
3696
    url += configeBaySellerName;
3697
    url += "&outputSelector=SellerInfo";
2 - 3698
 
6 - 3699
    // Submit the request
3700
    var xhttp = new XMLHttpRequest();
2 - 3701
 
6 - 3702
    xhttp.onreadystatechange = function() {
147 - 3703
        if (this.readyState == 4 && this.status == 200) {
6 - 3704
            _cb_findDuplicateListing(JSON.parse(this.responseText));
3705
        }
3706
    };
2 - 3707
 
6 - 3708
    xhttp.open("GET", configProxyUrl, true);
3709
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3710
    xhttp.send();
2 - 3711
 
6 - 3712
    return false;
2 - 3713
}
3714
 
3715
function _cb_findPotentialDuplicateListing(root) {
6 - 3716
    var x;
3717
    var response = root.findCompletedItemsResponse[0];
3718
    var ack = response.ack;
3719
    if (ack != 'Success') {
53 - 3720
        x = document.getElementById("productinfoDuplicate").innerHTML += '<br/><span class="bg-danger"><strong>Duplicate Check Failed</strong></span>';
2 - 3721
 
6 - 3722
        if (ack == 'Failure' || ack == 'PartialFailure') {
3723
            return;
3724
        }
3725
    }
2 - 3726
 
6 - 3727
    var items = response.searchResult[0].item || [];
2 - 3728
 
6 - 3729
    if (Number(response.paginationOutput[0].totalEntries) > 0) {
53 - 3730
        document.getElementById("productinfoDuplicate").innerHTML += '<br/><span class="bg-warning"><strong>Potential Duplicate, see Item Id <a href="https://www.ebay.com/itm/' + items[0].itemId + '" target="_blank">' + items[0].itemId + '</a></strong></span>';
6 - 3731
    }
2 - 3732
}
3733
 
3734
function findPotentialDuplicateListing() {
6 - 3735
    var keyword = document.getElementById('keyword').value;
2 - 3736
 
6 - 3737
    // Construct the request
3738
    url = configeBayFinding + "?";
3739
    url += "OPERATION-NAME=findCompletedItems";
3740
    url += "&SERVICE-VERSION=" + configeBayFindingVersion;
3741
    url += "&SECURITY-APPNAME=" + configAppid;
3742
    url += "&GLOBAL-ID=EBAY-US";
3743
    url += "&RESPONSE-DATA-FORMAT=JSON";
3744
    url += "&REST-PAYLOAD";
3745
    url += "&keywords=";
3746
    url += encodeURIComponent(keyword.trim().replace(/ /g, "+"));
3747
    url += "&paginationInput.entriesPerPage=1";
3748
    url += "&paginationInput.pageNumber=1";
3749
    url += "&itemFilter(0).name=Seller";
3750
    url += "&itemFilter(0).value=";
3751
    url += configeBaySellerName;
3752
    url += "&outputSelector=SellerInfo";
2 - 3753
 
6 - 3754
    var xhttp = new XMLHttpRequest();
2 - 3755
 
6 - 3756
    xhttp.onreadystatechange = function() {
147 - 3757
        if (this.readyState == 4 && this.status == 200) {
6 - 3758
            _cb_findPotentialDuplicateListing(JSON.parse(this.responseText));
3759
        }
3760
    };
2 - 3761
 
6 - 3762
    xhttp.open("GET", configProxyUrl, true);
3763
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
3764
    xhttp.send();
2 - 3765
 
6 - 3766
    return false;
2 - 3767
}
3768
 
40 - 3769
function findShopifyDuplicateListing() {
3770
    for (var i = 1; i < 7; i++){
3771
        findShopifyDuplicateListingFunc(i);
3772
    }
3773
}
3774
 
3775
 
3776
function findShopifyDuplicateListingFunc(flag) { // Barcode Search
3777
    var queryText = '';
3778
    var title = document.getElementById('keyword').value;
3779
    var barcode = parseInt(title, 10);
3780
    var len;
3781
 
3782
    if (flag < 6 && isNaN(barcode)) {
3783
        return;
3784
    }
3785
 
6 - 3786
    var xhttp = new XMLHttpRequest();
3787
    xhttp.onreadystatechange = function() {
3788
        if (this.readyState == 4 && this.status == 200) {
3789
            //window.alert(this.responseText);
3790
            var json = JSON.parse(this.responseText);
3791
            if (json.products[0] !== undefined) {
7 - 3792
			    var sku = getJsonValue(json.products[0].variants[0].sku);
40 - 3793
			    var handle = getJsonValue(json.products[0].handle);
53 - 3794
                document.getElementById("productinfoDuplicate").innerHTML += '<br/><span class="bg-warning"><strong>Potential Duplicate, see Shopify Item Id <a href="https://munatrading.com/products/' + handle + '" target="_blank">' + handle + '</a> (SKU=' + sku + ')</strong></span>';
6 - 3795
            }
3796
        }
3797
    };
2 - 3798
 
40 - 3799
    if (flag == 1) { // handle b{upc}
3800
        queryText = 'handle=b' + barcode;
3801
    } else if (flag == 2) { // handle b0{upc}
3802
        queryText = 'handle=b0' + barcode;
3803
    } else if (flag == 3) { // handle b00{upc}
3804
        queryText = 'handle=b00' + barcode;
3805
    } else if (flag == 4) { // handle b000{upc}
3806
        queryText = 'handle=b000' + barcode;
3807
    } else if (flag == 5) { // handle {upc} (without leading zeroes)
3808
        queryText = 'handle=' + barcode;
3809
    } else if (flag == 6) { // title
53 - 3810
        if (!isNaN(barcode)) {
40 - 3811
            title = reformatCdTitle(catalogTitle);
3812
        }
53 - 3813
        title = cleanTitleForShopifySearch(title);
3814
        queryText = 'title=' + title;
40 - 3815
    }
2 - 3816
 
6 - 3817
    xhttp.open("GET", configProxyUrl, true);
144 - 3818
	xhttp.setRequestHeader("X-Proxy-Url", configShopifyUrl + configShopifyProductsUrl + '?limit=1&fields=id,handle,variants&' + queryText);
40 - 3819
	if (flag == 6) { xhttp.setRequestHeader("X-LEAVE-ENCODED", "1"); }
6 - 3820
    xhttp.send();
2 - 3821
}
3822
 
3823
function connected() {
6 - 3824
    var x;
2 - 3825
 
6 - 3826
    eBayAuthTokenFlag = true;
30 - 3827
    if (!document.getElementById("connected").innerHTML.endsWith("(Connected)")) {
3828
        document.getElementById("connected").innerHTML += " (Connected)";
3829
    }
2 - 3830
 
6 - 3831
    x = document.getElementById("verify");
30 - 3832
    x.className = x.className.replace(" btn-danger", " btn-success");
2 - 3833
 
6 - 3834
    x = document.getElementById("login");
3835
    x.className = x.className.replace(" w3-show", "");
2 - 3836
 
6 - 3837
    x = document.getElementById("results");
3838
    x.innerHTML = "";
3839
    x.className = x.className.replace(" w3-show", "");
2 - 3840
}
3841
 
3842
function confirmUnload() {
6 - 3843
    return "Do you really want to leave the quick listing tool?";
2 - 3844
}
3845
 
3846
function uploadSiteHostedPictures() {
6 - 3847
    imagesToUpload = 0;
3848
    imageUploadError = false;
147 - 3849
    ImageRetryCount = [];
3850
 
6 - 3851
    ++imagesToUpload;
3852
    uploadSiteHostedPicture('image1', 0);
3853
    ++imagesToUpload;
3854
    uploadSiteHostedPicture('image2', 1);
3855
    for (var imageNumber = 0; imageNumber < maxAdditionalImages; imageNumber++) {
30 - 3856
        if (document.getElementById("image" + (imageNumber + 3) + "anchor").className.includes(" visible")) {
6 - 3857
            ++imagesToUpload;
3858
            uploadSiteHostedPicture('image' + (imageNumber + 3), (imageNumber + 2));
3859
        }
3860
    }
2 - 3861
 
6 - 3862
    function checkImagesToUpload() {
3863
        if (imagesToUpload > 0) {
3864
            window.setTimeout(checkImagesToUpload, 100); // wait 100 milliseconds
3865
        } else {
3866
            if (!imageUploadError) {
3867
                verifyListing();
3868
            } else {
3869
                ImageURLs = [];
3870
                imagesToUpload = 0;
3871
            }
3872
        }
3873
    }
2 - 3874
 
6 - 3875
    checkImagesToUpload();
2 - 3876
}
3877
 
3878
function uploadSiteHostedPicture(imageId, index) {
6 - 3879
    var i;
3880
    var str = '';
3881
    var imageBasename = document.getElementById(imageId).src.substr(document.getElementById(imageId).src.lastIndexOf('/') + 1);
147 - 3882
    var maxRetries = 5;
2 - 3883
 
147 - 3884
    if (ImageRetryCount[index] === undefined) {
3885
        ImageRetryCount[index] = 0;
3886
    }
3887
 
6 - 3888
    str += '<?xml version="1.0" encoding="utf-8"?>';
3889
    str += '<UploadSiteHostedPicturesRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
3890
    str += '    <RequesterCredentials>';
3891
    str += '        <eBayAuthToken>' + eBayAuthToken + '</eBayAuthToken>';
3892
    str += '    </RequesterCredentials>';
3893
    str += '	<ExtensionInDays>' + 30 + '</ExtensionInDays>';
3894
    str += '    <PictureSet>Supersize</PictureSet>';
3895
    str += '	<PictureName>' + imageBasename + '</PictureName>';
3896
    str += '    <ExternalPictureURL>' + document.getElementById(imageId).src + '</ExternalPictureURL>';
3897
    str += '</UploadSiteHostedPicturesRequest>';
2 - 3898
 
6 - 3899
    var xhr = new XMLHttpRequest();
3900
    xhr.open("POST", configProxyUrl, true);
3901
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
3902
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', configDevid);
3903
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', configCertid);
3904
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
3905
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', 'UploadSiteHostedPictures');
3906
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
3907
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
2 - 3908
 
6 - 3909
    xhr.onload = function() {
30 - 3910
        var jsonObj = XMLparse(xhr.responseXML, false);
3911
        var obj = jsonObj.UploadSiteHostedPicturesResponse;
3912
        var str = '';
6 - 3913
        var returnCode = obj.Ack;
3914
        var x = document.getElementById("results");
2 - 3915
 
6 - 3916
        if (returnCode == 'Success') {
30 - 3917
            str += '<div class="alert alert-success alert-dismissible">';
3918
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
147 - 3919
            str += '<p>Image ' + (index + 1);
3920
            if (ImageRetryCount[index] > 0){
3921
                str += ' (Retry ' + ImageRetryCount[index] + ')';
3922
            }
3923
            str += ' Upload: <strong>' + returnCode + '</strong></p>';
30 - 3924
            str += '</div>';
3925
            x.innerHTML += str;
6 - 3926
            ImageURLs[index] = obj.SiteHostedPictureDetails.FullURL;
147 - 3927
            --imagesToUpload;
6 - 3928
        } else {
30 - 3929
            str += '<div class="alert alert-danger alert-dismissible">';
3930
            str += '<button type="button" class="close" data-dismiss="alert">×</button>';
147 - 3931
            str += '<p>Image ' + (index + 1);
3932
            if (ImageRetryCount[index] > 0){
3933
                str += ' (Retry ' + ImageRetryCount[index] + ')';
3934
            }
3935
            str += ' Upload: <strong>' + returnCode + '</strong></p>';
2 - 3936
 
6 - 3937
            var errors = getJsonArray(obj.Errors);
30 - 3938
            str += "<ul>";
6 - 3939
            for (i = 0; i < errors.length; i++) {
30 - 3940
                str += '<li>' + errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "</li>";
6 - 3941
            }
30 - 3942
            str += "</ul>";
3943
            str += '</div>';
3944
            x.innerHTML += str;
147 - 3945
 
3946
            if (ImageRetryCount[index] < maxRetries) {
3947
                ++ImageRetryCount[index];
3948
                uploadSiteHostedPicture(imageId, index);
3949
            } else {
3950
                ImageURLs = [];
3951
                imageUploadError = true;
3952
                --imagesToUpload;
3953
            }
6 - 3954
        }
3955
    };
2 - 3956
 
6 - 3957
    xhr.send(str);
2 - 3958
}
3959
 
3960
function findDiscogsReleases(str) {
97 - 3961
    var releaseNumber = "";
3962
    var pos = 0;
3963
 
6 - 3964
    if (str.length < 1) {
3965
        return;
3966
    }
2 - 3967
 
97 - 3968
    // Check if release number is in title
3969
    pos = str.lastIndexOf("(R");
151 - 3970
    releaseInTitle = false;
97 - 3971
    if (pos > 0) {
3972
        releaseNumber = str.substr(pos + 2, str.length - pos - 3);
3973
        if (isNumeric(releaseNumber)) {
3974
            str = "r" + releaseNumber;
151 - 3975
            releaseInTitle = true;
97 - 3976
        }
3977
    }
3978
 
6 - 3979
    // Construct the request
3980
    url = configDiscogsApiUrl + "?";
3981
    url += "token=";
3982
    url += configDiscogsToken;
3983
    url += "&type=release";
3984
    url += "&format=CD";
3985
    if (isNumeric(str)) {
3986
        url += "&barcode=";
3987
    } else {
3988
        url += "&q=";
3989
    }
3990
    url += str;
2 - 3991
 
6 - 3992
    var xhttp = new XMLHttpRequest();
2 - 3993
 
6 - 3994
    xhttp.onreadystatechange = function() {
147 - 3995
        if (this.readyState == 4 && this.status == 200) {
6 - 3996
            var response = this.responseText;
3997
            if (this.status != 200) { // discogs returns HTML instead JSON
3998
                response = '{"pagination": {"per_page": 50, "items": 0, "page": 1, "urls": {}, "pages": 1}, "results": []}';
3999
            }
4000
            _cb_findDiscogsReleases(JSON.parse(response));
4001
        }
4002
    };
2 - 4003
 
6 - 4004
    xhttp.open("GET", configProxyUrl, true);
97 - 4005
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url.trim().replace(/ /g, "+")));
6 - 4006
    xhttp.send();
2 - 4007
}
4008
 
4009
function _cb_findDiscogsReleases(root) {
6 - 4010
    var tableStr = '';
4011
    var i, j;
4012
    var x;
2 - 4013
 
6 - 4014
    tableStr = '<h3>Discogs Releases</h3>';
30 - 4015
    tableStr += '<table id="discogsTable" class="table small table-hover">';
4016
    tableStr += '<thead class="thead-dark">';
6 - 4017
    tableStr += '<tr>';
4018
    tableStr += tableHeader('Title');
4019
    tableStr += tableHeader('Label');
4020
    tableStr += tableHeader('Catalog #');
4021
    tableStr += tableHeader('Format');
4022
    tableStr += tableHeader('Year');
4023
    tableStr += tableHeader('Country');
4024
    tableStr += tableHeader('Genre');
30 - 4025
    tableStr += tableHeader('');
6 - 4026
    tableStr += '</tr>';
4027
    tableStr += '</thead>';
30 - 4028
    tableStr += '<tbody>';
2 - 4029
 
6 - 4030
    for (i = 0; i < root.results.length; i++) {
97 - 4031
        tableStr += '<tr';
4032
        if (root.results[i].country.startsWith("US")) {
128 - 4033
            tableStr += ' class="bg-white invert"';
97 - 4034
        }
4035
        tableStr += '>';
2 - 4036
 
6 - 4037
        tableStr += tableCellLink(root.results[i].title, configDiscogsBaseUrl + root.results[i].uri);
2 - 4038
 
6 - 4039
        str = [];
4040
        for (j = 0; j < root.results[i].label.length && j < 2; j++) {
4041
            str.push(root.results[i].label[j]);
4042
        }
4043
        tableStr += tableCell(str.join(', '));
2 - 4044
 
6 - 4045
        tableStr += tableCell(root.results[i].catno);
2 - 4046
 
6 - 4047
        str = [];
4048
        for (j = 0; j < root.results[i].format.length; j++) {
4049
            str.push(root.results[i].format[j]);
4050
        }
4051
        tableStr += tableCell(str.join(', '));
2 - 4052
 
6 - 4053
        tableStr += tableCell(root.results[i].year);
4054
        tableStr += tableCell(root.results[i].country);
2 - 4055
 
6 - 4056
        tableStr += tableCell(root.results[i].genre.join(', '));
2 - 4057
 
6 - 4058
        tableStr += tableCellButton(root.results[i].resource_url);
2 - 4059
 
6 - 4060
        tableStr += '</tr>';
4061
    }
2 - 4062
 
30 - 4063
    tableStr += '</tbody>';
6 - 4064
    tableStr += '</table>';
2 - 4065
 
30 - 4066
    tableStr += '<div class="container-fluid">';
4067
    tableStr += '<form id="searchFormDiscogs" class="form-inline" onsubmit="specialDiscogsSearch();return false;">';
4068
    tableStr += '<div class="input-group">';
4069
    tableStr += '<label for="discogsRelease" class="keepTogether mr-sm-2">Release #:</label>';
4070
    tableStr += '<input id="discogsRelease" name="discogsRelease" class="form-control" style="width:30%;font-size:95%!important" type="text" maxlength="10">';
4071
    tableStr += '<div class="input-group-append">';
4072
    tableStr += '<button class="btn mx-2" onclick="specialDiscogsSearch();return false;"><i class="fa fa-search"></i></button>';
4073
    tableStr += '</div>';
4074
    tableStr += '</div>';
4075
    tableStr += '</form>';
4076
    tableStr += '</div>';
4077
 
4078
    if (!document.getElementById("productinfoSearch").innerHTML.includes("Discogs")) {
4079
        document.getElementById("productinfoSearch").innerHTML += '<a href="https://www.discogs.com/search/?q=&format_exact=CD&type=all" target="_blank"><button class="btn mx-2"><i class="fa fa-search"></i> Discogs</button></a>';
6 - 4080
    }
2 - 4081
 
6 - 4082
    x = document.getElementById("discogsReleases");
4083
    x.innerHTML = tableStr;
4084
    if (x.className.indexOf("w3-show") == -1) {
4085
        x.className += " w3-show";
4086
    }
2 - 4087
 
30 - 4088
    x = document.getElementById("productinfoSearch");
121 - 4089
    if (!x.innerHTML.includes("FindCheapMusic")) {
4090
        x.innerHTML += '<a href="https://www.findcheapmusic.com/index.php?q=' + upc + '" target="blank"><button class="btn mx-2"><i class="fa fa-search"></i> FindCheapMusic</button></a>';
30 - 4091
    }
2 - 4092
}
4093
 
4094
function specialDiscogsSearch() {
6 - 4095
    if (document.getElementById("discogsRelease").value.length > 0) {
4096
        findDiscogsReleases("r" + document.getElementById("discogsRelease").value);
4097
    }
2 - 4098
}
4099
 
4100
function tableHeader(str) {
6 - 4101
    return ('<th>' + (str === undefined ? '' : str) + '</th>');
2 - 4102
}
4103
 
4104
function tableCell(str) {
6 - 4105
    return ('<td>' + (str === undefined ? '' : str) + '</td>');
2 - 4106
}
4107
 
4108
function tableCellLink(text, link) {
6 - 4109
    var str = "<a href=\"" + link + "\" target=\"_blank\">" + text + "</a>";
4110
    return ('<td>' + str + '</td>');
2 - 4111
}
4112
 
4113
function tableCellButton(link) {
30 - 4114
    var str = '<button type="button" class="btn btn-primary fa fa-arrow-left" onclick="getDiscogsRelease(&quot;' + link + '&quot;);"></button>';
6 - 4115
    return ('<td>' + str + '</td>');
2 - 4116
}
4117
 
4118
function getDiscogsRelease(url) {
6 - 4119
    var xhttp = new XMLHttpRequest();
2 - 4120
 
6 - 4121
    xhttp.onreadystatechange = function() {
147 - 4122
        if (this.readyState == 4 && this.status == 200) {
6 - 4123
            _cb_getDiscogsRelease(JSON.parse(this.responseText));
4124
        }
4125
    };
2 - 4126
 
6 - 4127
    xhttp.open("GET", configProxyUrl, true);
4128
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4129
    xhttp.send();
2 - 4130
}
4131
 
4132
function _cb_getDiscogsRelease(root) {
6 - 4133
    var str;
4134
    var titleStr = '';
4135
    var trackStr;
4136
    var artist;
4137
    var label;
4138
    var year;
4139
    var position;
4140
    var promo = '';
4141
    var digipak = '';
4142
    var duration = '';
4143
    var quantity = '';
4144
    var i, j;
4145
    var temp;
2 - 4146
 
36 - 4147
// xxxxx    getDiscogsPriceRecommendation(root.id);
4148
 
6 - 4149
    // Tracklist
4150
    trackStr = [];
4151
    allNumbers = true;
2 - 4152
 
6 - 4153
    for (i = 0; i < root.tracklist.length; i++) {
4154
        str = '';
4155
        if (root.tracklist[i].position.length > 0) {
4156
            str += root.tracklist[i].position + '. ';
2 - 4157
 
6 - 4158
            position = Number(root.tracklist[i].position);
4159
            if (isNaN(position) || position != (i + 1)) {
4160
                allNumbers = false;
4161
            }
4162
        }
2 - 4163
 
6 - 4164
        if (root.tracklist[i].artists !== undefined) {
4165
            for (j = 0; j < root.tracklist[i].artists.length; j++) {
4166
                temp = root.tracklist[i].artists[j].name.replace(/\([0-9]+\)$/, "");
4167
                str += temp + " " + root.tracklist[i].artists[j].join + " ";
4168
            }
4169
            str += " - ";
4170
        }
2 - 4171
 
6 - 4172
        str += root.tracklist[i].title;
2 - 4173
 
6 - 4174
        if (root.tracklist[i].duration.length > 0) {
4175
            str += " [" + root.tracklist[i].duration + "]";
4176
        }
2 - 4177
 
6 - 4178
        trackStr.push(str);
4179
    }
2 - 4180
 
6 - 4181
    str = str.replace(/  +/g, ' ');
4182
    if (allNumbers) {
4183
        for (i = 0; i < trackStr.length; i++) {
4184
            trackStr[i] = trackStr[i].replace(/^\d+. /g, '');
4185
        }
4186
    } else {
4187
        document.getElementById("cdUnorderedTrackList").checked = true;
4188
    }
2 - 4189
 
6 - 4190
    $("#cdTracks").val(trackStr.join('\n'));
10 - 4191
    updateTracklistPreview();
2 - 4192
 
6 - 4193
    // Title
4194
    titleStr = '';
4195
    artist = '';
4196
    label = '';
4197
    year = '';
4198
    catno = '';
4199
    if (root.artists !== undefined) {
4200
        for (i = 0; i < root.artists.length; i++) {
4201
            temp = root.artists[i].name.replace(/\([0-9]+\)$/, "");
4202
            artist += temp + " " + root.artists[i].join + " ";
4203
        }
4204
    }
2 - 4205
 
6 - 4206
    artist = artist.trim();
4207
    if (artist != 'Various') {
4208
        titleStr += artist + " - " + root.title;
4209
    } else {
4210
        titleStr += root.title + " by Various Artists";
4211
    }
4212
    titleStr += " (CD";
2 - 4213
 
6 - 4214
    document.getElementById("cdTitle").value = root.title;
2 - 4215
 
6 - 4216
    // formats
4217
    promo = '';
4218
    duration = '';
4219
    quantity = '';
4220
    digipak = '';
4221
    for (i = 0; i < root.formats.length; i++) {
4222
        if (root.formats[i].name.startsWith("CD")) {
30 - 4223
            if (root.formats[i].descriptions !== undefined) {
4224
                for (j = 0; j < root.formats[i].descriptions.length; j++) {
4225
                    if (root.formats[i].descriptions[j] == "Enhanced") {
4226
                        document.getElementById("cdEnhanced").checked = true;
4227
                    } else if (root.formats[i].descriptions[j] == "Compilation") {
4228
                        document.getElementById("cdCompilation").checked = true;
4229
                    } else if (root.formats[i].descriptions[j] == "Digipak") {
4230
                        document.getElementById("cdDigipak").checked = true;
4231
                        digipak = root.formats[i].descriptions[j];
4232
                        setCdConditionDescription('D');
4233
                    } else if (root.formats[i].descriptions[j] == "Promo") {
4234
                        document.getElementById("cdPromo").checked = true;
4235
                        promo = 'PROMO';
4236
                    } else if (root.formats[i].descriptions[j] == "Reissue") {
4237
                        document.getElementById("cdReissue").checked = true;
4238
                    } else if (root.formats[i].descriptions[j] == "Remastered") {
4239
                        document.getElementById("cdRemastered").checked = true;
40 - 4240
                    } else if (root.formats[i].descriptions[j] == "Club Edition") {
4241
                        document.getElementById("cdClub").checked = true;
30 - 4242
                    } else if (root.formats[i].descriptions[j] == "HDCD") {
4243
                        document.getElementById("cdHDCD").checked = true;
4244
                    } else if (root.formats[i].descriptions[j] == "Album" ||
4245
                        root.formats[i].descriptions[j] == "Mini-Album" ||
4246
                        root.formats[i].descriptions[j] == "EP" ||
4247
                        root.formats[i].descriptions[j] == "Maxi-Single" ||
4248
                        root.formats[i].descriptions[j] == "Single") {
4249
                        $('#cdDuration').selectpicker('val', root.formats[i].descriptions[j]);
4250
                        $('#cdDuration').prop('disabled', false).selectpicker('refresh');
4251
                        if (!root.formats[i].descriptions[j].includes("Album")) {
4252
                            duration = root.formats[i].descriptions[j];
4253
                        }
6 - 4254
                    }
4255
                }
30 - 4256
            }
2 - 4257
 
30 - 4258
            discogsQty = Number(root.formats[i].qty);
4259
            if (discogsQty > 1) {
4260
                setCdConditionDescription('P');
4261
                quantity = Number(root.formats[i].qty) + ' Discs';
6 - 4262
            }
4263
        }
4264
    }
2 - 4265
 
6 - 4266
    // genres
4267
    if (document.getElementById("cdGenre").value.length <= 1) {
4268
        for (i = 0; i < root.genres.length; i++) {
4269
            if (isInSelectList("cdGenre", root.genres[i])) {
30 - 4270
                $('#cdGenre').prop('disabled', false).selectpicker('refresh');
6 - 4271
                break;
4272
            }
4273
        }
4274
    }
2 - 4275
 
6 - 4276
    // country
30 - 4277
    var country = getJsonValue(root.country);
4278
    if (country != 'undefined' && country != 'US' && !country.includes('Europe')) {
4279
        if (country == 'UK') {
6 - 4280
            document.getElementById("cdCountry").value = 'United Kingdom';
4281
        } else {
4282
            document.getElementById("cdCountry").value = root.country;
4283
        }
4284
    } else {
4285
        document.getElementById("cdCountry").value = "United States";
4286
    }
2 - 4287
 
6 - 4288
    // title remainder
4289
    if (duration.length > 0) {
4290
        titleStr += ", " + duration;
4291
    }
2 - 4292
 
6 - 4293
    if (digipak.length > 0) {
4294
        titleStr += ", " + digipak;
4295
    }
2 - 4296
 
6 - 4297
    if (quantity.length > 0) {
4298
        titleStr += ", " + quantity;
4299
    }
2 - 4300
 
6 - 4301
    if (root.released !== undefined) {
4302
        year = root.released.substr(0, 4);
4303
        titleStr += ", " + year;
4304
    }
2 - 4305
 
6 - 4306
    if (root.labels !== undefined) {
4307
        label = root.labels[0].name;
4308
        titleStr += ", " + label;
4309
    }
2 - 4310
 
6 - 4311
    titleStr += ")";
2 - 4312
 
6 - 4313
    if (promo.length > 0) {
4314
        titleStr += " " + promo + ' ' + root.labels[0].catno;
4315
    }
2 - 4316
 
6 - 4317
    titleStr = titleStr.trim();
4318
    titleStr = titleStr.replace(/  +/g, ' ');
4319
    titleStr = titleStr.replace('<br>', '');
2 - 4320
 
10 - 4321
    if (titleStr.includes('Greatest Hits')) {
4322
        document.getElementById("cdGreatestHits").checked = true;
4323
    }
4324
 
151 - 4325
    if (isNumeric(document.getElementById("title").value) || document.getElementById("title").value.length === 0 || releaseInTitle) {
6 - 4326
        document.getElementById("title").value = titleStr;
4327
        printTitleLength();
4328
        document.getElementById("cdArtist").value = artist;
4329
        document.getElementById("cdRecordLabel").value = label;
4330
        document.getElementById("cdReleaseYear").value = year;
4331
    }
2 - 4332
}
4333
 
36 - 4334
function getDiscogsPriceRecommendation(release) {
4335
    // Construct the request
4336
    url = configDiscogsPriceUrl + release;
4337
    url += "&token=";
4338
    url += configDiscogsToken;
4339
 
4340
    var xhttp = new XMLHttpRequest();
4341
 
4342
    xhttp.onreadystatechange = function() {
147 - 4343
        if (this.readyState == 4 && this.status == 200) {
36 - 4344
            var response = this.responseText;
4345
            if (this.status != 200) { // discogs returns HTML instead JSON
4346
                response = '{"pagination": {"per_page": 50, "items": 0, "page": 1, "urls": {}, "pages": 1}, "results": []}';
4347
            }
4348
            /* _cb_findDiscogsReleases(JSON.parse(response)); */
4349
        }
4350
    };
4351
 
4352
    xhttp.open("GET", configProxyUrl, true);
4353
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
4354
    xhttp.setRequestHeader("User-Agent", configDiscogsUserAgent);
4355
    xhttp.send();
4356
}
4357
 
2 - 4358
function isInSelectList(list, value) {
6 - 4359
    var i;
4360
    var opts = document.getElementById(list).options;
2 - 4361
 
6 - 4362
    for (i = 0; i < opts.length; ++i)
4363
        if (opts[i].value.includes(value)) {
30 - 4364
            $('#' + list).selectpicker('val', opts[i].value);
6 - 4365
            return true;
4366
        }
2 - 4367
 
6 - 4368
    return false;
2 - 4369
}
4370
 
4371
function printTitleLength() {
6 - 4372
    var len = document.getElementById("title").value.length;
2 - 4373
 
6 - 4374
    color = (len > 80 ? 'red' : 'black');
2 - 4375
 
6 - 4376
    document.getElementById("titleLength").innerHTML = '(' + len + ')';
4377
    document.getElementById("titleLength").style.color = color;
2 - 4378
}
4379
 
36 - 4380
function setModifiedDescription() {
4381
    if (document.getElementById("cdModified").value == 'Yes') {
4382
        document.getElementById("cdModificationDescription").value = 'Marked by Record Label as Radio/DJ Promo: Barcode punched out.';
4383
    } else {
4384
        document.getElementById("cdModificationDescription").value = '';
6 - 4385
    }
4386
}
2 - 4387
 
4388
    </script>
30 - 4389
    <script>includeHTML();</script>
2 - 4390
 
4391
</body>
4392
</html>