Subversion Repositories munaweb

Rev

Details | Last modification | View Log | RSS feed

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