-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeachnote.js
78 lines (61 loc) · 2.15 KB
/
peachnote.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
72
73
74
75
76
77
78
// API module for querying peachnote.js
(function(global) {
var Peachnote = {
//url : "http://20.scoresy-hrd.appspot.com/rest/api/v1/ngramCounts?type=chordAffine&q=",
url : "http://www.peachnote.com/rest/api/v1/ngramCounts?type=chordAffine&q=",
callback : function (data) {},
query : function (ngram) {
console.log("Querying Ngram: "+ngram);
$.ajax({
dataType: "jsonp",
url: Peachnote.url+ngram,
success: Peachnote.callback
});
}
};
global.Peachnote = Peachnote;
})(this);
/*(function(global) {
var pendingRequests = [];
var Peachnote = {
url : "http://www.peachnote.com/rest/api/v0/ngramCounts?type=chordAffine&q=",
callback : function (data) {},
query : function (ngram) {
console.log("Querying Ngram: "+ngram);
var req = document.createElement('script');
req.setAttribute('src',Peachnote.url+ngram)
req.setAttribute('id',ngram);
document.body.appendChild(req);
}
};
function parseResponse(data) {
console.log(data);
var ngram = Object.keys(data)[0];
document.body.removeChild(document.getElementById(ngram));
Peachnote.callback(data);
}
global.Peachnote = Peachnote;
global.parseResponse = parseResponse;
})(this);*/
/*(function(global) {
var client = new XMLHttpRequest();
var Peachnote = {
url : "http://www.peachnote.com/rest/api/v0/ngramCounts?type=chordAffine&q=",
callback : function (data) {},
query : function (ngram) {
console.log("Querying Ngram: "+ngram);
client.open("GET",Peachnote.url+ngram,true);
client.send(null);
}
};
function parseResponse(data) {
console.log(data);
Peachnote.callback(data);
}
client.onreadystatechange = function() {
if (client.readyState == 4 && client.status == 200){
parseResponse(client.responseText);
}
};
global.Peachnote = Peachnote;
})(this);*/