-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·71 lines (60 loc) · 1.77 KB
/
main.js
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
/*globals rdioUtils, Main, R */
(function() {
// ----------
window.Main = {
$albums: {},
// ----------
init: function() {
var self = this;
if (!rdioUtils.startupChecks()) {
return;
}
R.ready(function() {
R.logger.verbosity('all');
R.request({
method: "getTopCharts",
content: {
type: "Track"
},
success: function(response) {
//alert( "got response for tracks" );
if (!response.result || !response.result.length) {
self.log('Unable to find tracks.');
return;
}
//$('#songlist').append('<select name="song" size="8">');
_.each(response.result, function(v, i) {
//var widget = rdioUtils.trackWidget(v);
//$('body').append(widget.element());
console.log( "result: " + v.name + " artist: " + v.artist + " key: " + v.key);
//$('body').append('<p>' + v.name + " " + v.key);
//$('#songlist').append('<p>' + v.name + " " + v.key);
$('#songlist').append('<option value="' + v.key + '"><b>' + v.name + '</b> - ' + v.artist + '</option>');
});
//$('#songlist').append('</select>');
},
error: function(response) {
self.log(response.message);
}
});
});
},
// ----------
log: function(message) {
$('<p>')
.text(message)
.appendTo('.log');
},
// ----------
template: function(name, config) {
var rawTemplate = $.trim($("#" + name + "-template").text());
var template = _.template(rawTemplate);
var html = template(config);
return $(html);
}
};
// ----------
$(document).ready(function() {
Main.init();
});
})();