-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbeatport-discography-shortcode-tinymce.html
More file actions
executable file
·444 lines (380 loc) · 13.6 KB
/
Copy pathbeatport-discography-shortcode-tinymce.html
File metadata and controls
executable file
·444 lines (380 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Beatport Discography Shortcode</title>
<link rel="stylesheet" href="css/beatport-discography-shortcode-admin.css">
<style type="text/css">
</style>
</head>
<body>
<form id="beatport-discography-shortcode" class="form-stacked" action="#">
<fieldset class="step-1">
<legend>Step 1 - Select type of feed.</legend>
<ul class="inputs-list">
<li>
<label>
<span class="span2">Artist</span>
<input type="radio" name="feed" id="artistfeed" value="artist"/>
<span class="help-inline">(Get list of tracks/releases by Artist Name)</span>
</label>
</li>
<li>
<label>
<span class="span2">Record Label</span>
<input type="radio" name="feed" id="labelfeed" value="label"/>
<span class="help-inline">(Get list of tracks/releases by Record Label Name)</span>
</label>
</li>
<li>
<label>
<span class="span2">Release (Detailed)</span>
<input type="radio" name="feed" id="idfeed" value="id"/>
<span class="help-inline">(Get a detailed view of a release by Release Id)</span>
</label>
</li>
</ul>
</fieldset>
<fieldset class="step-2">
<legend>Step 2</legend>
<p>The minimum required fields are: Artist Name or Record Label Name</p>
<div class="clearfix">
<ul class="inputs-list">
<li class="artistfeed">
<label>
<span class="span2">Artist Name<span class="required">*</span></span>
<input type="text" name="artist" class="span4 artistfeed"/>
<span class="help-inline">Artist name exactly as it appears on Beatport.</span>
</label>
</li>
<li class="labelfeed">
<label>
<span class="span2">Label Name<span class="required">*</span></span>
<input type="text" name="label" class="span4 labelfeed"/>
<span class="help-inline">Label Name exactly as it appears on Beatport.</span>
</label>
</li>
<li class="idfeed">
<label>
<span class="span2">Release Id<span class="required">*</span></span>
<input type="text" name="id" class="span4 idfeed"/>
<span class="help-inline">Release Id exactly as it appears on Beatport.</span>
</label>
</li>
</ul>
</div>
</fieldset>
<fieldset class="step-3">
<legend>Step 3 - Items you would like displayed</legend>
<ul class="inputs-list">
<li>
<label>
<span class="span2">Artist Bio</span>
<input type="radio" name="items" value="biography" class="biography"/>
</label>
</li>
<li class="releaseitems">
<label>
<span class="span2">Releases</span>
<input type="radio" name="items" value="release" class="releaseitems"/>
</label>
</li>
<li class="trackitems">
<label>
<span class="span2">Tracks</span>
<input type="radio" name="items" value="track" class="trackitems"/>
</label>
</li>
<li>
<label>
<span class="span2">Sound Player</span>
<input type="checkbox" name="soundPlayer" id="soundPlayer"/>
<span class="help-inline">Enable/Disable sound player.</span>
</label>
</li>
<li>
<label>
<span class="span2">Buy on Beatport.com link</span>
<input type="checkbox" name="buylink" id="buylink"/>
<span class="help-inline">Enable/Disable Buy on beatport.com link.</span>
</label>
</li>
</ul>
</fieldset>
<div id="trycode">
<div id="preloader_container">
<img id="preloader" src="image/rectangular_preloader.gif" />
</div>
<div id="results"></div>
</div>
<div class="beatport-discography-shortcode-actions">
<button type="button" id="btnTry" class="btn primary">Try shortcode</button>
<input type="submit" id="btnInsertShortCode" value="Insert shortcode" class="btn primary"/>
or
<input class="btn" type="reset" value="Reset settings"/>
</div>
</form>
</body>
<script type="text/javascript" src="../../../wp-includes/js/jquery/jquery.js"></script>
<script type="text/javascript" src="bootstrap-typeahead.js"></script>
<script type="text/javascript">
// <![CDATA[
!function(){
var data = window.top.beatportDiscographyShortcodeDialogData
, loadJS = function (path){
document.write('<script type="text/javascript" src="'+ path +'"><\/script>');
}
, loadCSS = function (path) {
document.write('<link rel="stylesheet" type="text/css" href="'+ path +'" \/>');
};
// Load CSS and JS
loadCSS(data.pluginsUrl + '/beatport-discography-shortcode/css/bootstrap-1.4.0.min.css?v=' + data.pluginVersion);
loadJS(data.includesUrl + 'js/tinymce/tiny_mce_popup.js?v=' + data.pluginVersion);
}();
// ]]>
</script>
<script type="text/javascript">
// <![CDATA[
function toTitleCase(str){
return str.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
jQuery(document).ready(function(){
jQuery('.labelfeed').prop('disabled', true);
jQuery('#soundPlayer').prop('disabled', true);
jQuery('.step-2').hide();
jQuery('.step-3').hide();
jQuery('.beatport-discography-shortcode-actions').hide();
jQuery('#btnTry').addClass('disabled');
jQuery('#btnTry').prop('disabled', true);
jQuery('#btnTry').attr('disabled', 'disabled');
jQuery('#btnInsertShortCode').addClass('disabled');
jQuery('#btnInsertShortCode').prop('disabled', true);
jQuery('#btnInsertShortCode').attr('disabled', 'disabled');
jQuery('#artistfeed').click(function(){
jQuery('.labelfeed').val('');
jQuery('.idfeed').val('');
jQuery('.step-2').show();
jQuery('.labelfeed').prop('disabled', true);
jQuery('#artistfeed').attr('checked','checked');
jQuery('.artistfeed').prop('disabled', false);
jQuery('.idfeed').prop('disabled', true);
jQuery('.artistfeed').show();
jQuery('.labelfeed').hide();
jQuery('.idfeed').hide();
jQuery('.step-2').show();
jQuery('.step-3').hide();
jQuery('#soundPlayer').removeAttr('checked');
jQuery('#buylink').removeAttr('checked');
//jQuery('input[name=items]').val('');
jQuery('input[name=items]').removeAttr('checked');
jQuery('.beatport-discography-shortcode-actions').hide();
});
jQuery('#labelfeed').click(function(){
jQuery('#labelfeed').attr('checked','checked');
jQuery('.artistfeed').val('');
jQuery('.idfeed').val('');
jQuery('.labelfeed').prop('disabled', false);
jQuery('.artistfeed').prop('disabled', true);
jQuery('.idfeed').prop('disabled', true);
jQuery('.artistfeed').hide();
jQuery('.labelfeed').show();
jQuery('.idfeed').hide();
jQuery('.step-2').show();
jQuery('.step-3').hide();
jQuery('#soundPlayer').removeAttr('checked');
jQuery('#buylink').removeAttr('checked');
//jQuery('input[name=items]').val('');
jQuery('input[name=items]').removeAttr('checked');
jQuery('.beatport-discography-shortcode-actions').hide();
});
jQuery('#idfeed').click(function(){
jQuery('#idfeed').attr('checked','checked');
jQuery('.artistfeed').val('');
jQuery('.labelfeed').val('');
jQuery('.labelfeed').prop('disabled', true);
jQuery('.artistfeed').prop('disabled', true);
jQuery('.idfeed').prop('disabled', false);
jQuery('.artistfeed').hide();
jQuery('.labelfeed').hide();
jQuery('.idfeed').show();
jQuery('.step-2').show();
jQuery('.step-3').hide();
jQuery('#soundPlayer').removeAttr('checked');
jQuery('#buylink').removeAttr('checked');
//jQuery('input[name=items]').val('');
jQuery('input[name=items]').removeAttr('checked');
jQuery('.beatport-discography-shortcode-actions').hide();
});
jQuery('.artistfeed').blur(function(){
if(jQuery(this).val() != ''){
jQuery(this).val(toTitleCase(jQuery(this).val()));
jQuery(this).val(jQuery(this).val().replace(' ', '+'));
jQuery('.beatport-discography-shortcode-actions').show();
jQuery('.step-3').show();
}else{
jQuery('.step-3').hide();
}
});
jQuery('.labelfeed').blur(function(){
if(jQuery(this).val() != ''){
jQuery(this).val(toTitleCase(jQuery(this).val()));
jQuery(this).val(jQuery(this).val().split(' ').join("+"));
jQuery('.beatport-discography-shortcode-actions').show();
jQuery('.step-3').show();
}else{
jQuery('.step-3').hide();
}
});
jQuery('.idfeed').blur(function(){
if(jQuery(this).val() != ''){
jQuery('.step-3').show();
jQuery('input.trackitems').removeAttr('checked');
jQuery('.beatport-discography-shortcode-actions').show();
jQuery('.trackitems').hide();
}else{
jQuery('.step-3').hide();
}
});
jQuery('input[name=items]').click(function(){
jQuery('#btnTry').removeClass('disabled');
jQuery('#btnTry').prop('disabled', false);
jQuery('#btnTry').removeAttr('disabled');
jQuery('#btnInsertShortCode').removeClass('disabled');
jQuery('#btnInsertShortCode').prop('disabled', false);
jQuery('#btnInsertShortCode').removeAttr('disabled');
if(jQuery(this).val() == 'release'){
jQuery('#soundPlayer').removeAttr('checked');
jQuery('#soundPlayer').prop('disabled', true);
}else{
jQuery('#soundPlayer').prop('disabled', false);
}
});
jQuery('#btnTry').click(function(){
var url = 'http://www.federicogiust.com/beatportapi/beatport_api.php';
var feed = jQuery('input[name=feed]:checked', '#beatport-discography-shortcode').val();
if( feed == 'artist' ){
var artist = jQuery('input[name=artist]').val();
var items = jQuery('input[name=items]').val();
if(artist != ''){
jQuery('#preloader_container').show();
jQuery('#trycode').show();
jQuery('#results').empty();
if( items == 'release' ){
url = url + '?facets=artistName:' + artist + '&sortBy=publishDate%20desc&perPage=150&url=releases';
}else if( items == 'track' ){
url = url + '?facets=artistName:' + artist + '&sortBy=publishDate%20desc&perPage=150&url=tracks';
}
}
}else if( feed == 'label' ){
var label = jQuery('input[name=label]').val();
var items = jQuery('input[name=items]').val();
if(label != ''){
jQuery('#preloader_container').show();
jQuery('#trycode').show();
jQuery('#results').empty();
if( items == 'release' ){
url = url + '?facets=labelName:' + label + '&sortBy=publishDate%20desc&perPage=150&url=releases';
}else if( items == 'track' ){
url = url + '?facets=labelName:' + label + '&sortBy=publishDate%20desc&perPage=150&url=tracks';
}
}
}else if( feed = 'id' ){
// ?id=5123727&url=beatport/release
var id = jQuery('input[name=id]').val();
var items = jQuery('input[name=items]').val();
if(id != ''){
jQuery('#preloader_container').show();
jQuery('#trycode').show();
jQuery('#results').empty();
if( items == 'release' ){
url = url + '?id=' + id + '&sortBy=publishDate%20desc&perPage=150&url=releases';
}else if( items == 'track' ){
url = url + '?id=' + id + '&sortBy=publishDate%20desc&perPage=150&url=tracks';
}
}
}
console.log('http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from json where url="' + url + '"') + '&format=json&callback=');
jQuery.ajax({
type: 'GET',
crossDomain: true,
url: 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from json where url="' + url + '"') + '&format=json&callback=',
dataType: 'JSON',
success: function(data){
//console.log(data.query.results.json);
var jsonData = data.query.results.json;
var jsonDataString = JSON.stringify(jsonData);
jQuery('#preloader_container').hide();
jQuery('#results').html('<pre>' + jsonDataString + '</pre>');
}
});
});
});
tinyMCEPopup.onInit.add(function(ed) {
var form = window.document.forms[0],
isEmpty = function(value) {
return (/^\s*$/.test(value));
},
encodeStr = function(value) {
return value.replace(/\s/g, "%20")
.replace(/"/g, "%22")
.replace(/'/g, "%27")
.replace(/=/g, "%3D")
.replace(/\[/g, "%5B")
.replace(/\]/g, "%5D")
.replace(/\//g, "%2F");
},
toTitleCase = function (str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
},
insertShortcode = function(e){
var sc = "[beatport_discography_sc ",
inputs = form.elements, input, inputName, inputValue,
l = inputs.length, i = 0;
feed = jQuery('input[name=feed]:checked').val();
if (feed == 'artist') {
value = jQuery('input[name=artist]').val();
if (isEmpty(value)) {
alert("You need to introduce an artist name.");
return false;
}
}
else if (feed == 'label') {
value = jQuery('input[name=label]').val();
if (isEmpty(value)) {
alert("You need to introduce a label name.");
return false;
}
}
else if (feed == 'id') {
value = jQuery('input[name=id]').val();
if (isEmpty(value)) {
alert("You need to introduce an id of the release or track.");
return false;
}
}
for ( ; i < l; i++) {
input = inputs[i];
inputName = input.name;
inputValue = input.value;
// inputs of type "checkbox", "radio" and "text"
if (input.checked || (input.type == "text" && !isEmpty(inputValue) && inputValue != input.defaultValue)) {
if (inputName == "title") {
inputValue = encodeStr(inputValue);
}
sc += ' ' + inputName + '="' + inputValue + '"';
}
}
sc += "]";
ed.execCommand('mceInsertContent', 0, sc);
tinyMCEPopup.close();
return false;
};
form.onsubmit = insertShortcode;
tinyMCEPopup.resizeToInnerSize();
});
// ]]>
</script>
</html>