Subversion Repositories munaweb

Rev

Rev 150 | Rev 170 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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