-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_data.js
116 lines (91 loc) · 2.15 KB
/
get_data.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
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
autowatch =1 ;
//var d = new Dict("sources");
var sources; // = dict_to_jsobj(d);
var data;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
sources = JSON.parse(xhttp.responseText);
}
};
function url(u) {
post(u);
xhttp.open("GET", u, false);
xhttp.send();
}
/*function dictionary(){
data = sources.body;
data = JSON.parse(data);
post(data.length);
}
/*
for(var i = 0; i < keys.length; i++){
post(keys[i], "\n"); // This will post the key name
post(d.get(keys[i]), "\n"); // This will post the value
}
function dict_to_jsobj(dict) {
if (dict == null) return null;
var o = new Object();
var keys = dict.getkeys();
if (keys == null || keys.length == 0) return null;
if (keys instanceof Array) {
for (var i = 0; i < keys.length; i++)
{
var value = dict.get(keys[i]);
if (value && value instanceof Dict) {
value = dict_to_jsobj(value);
}
o[keys[i]] = value;
}
} else {
var value = dict.get(keys);
if (value && value instanceof Dict) {
value = dict_to_jsobj(value);
}
o[keys] = value;
}
return o;
}*/
function filter(f)
{
var numfields = 1;
var numrecords = sources.length;
//var fieldnames = Object.keys(sources);
var values = new Array(25);
outlet(0, "clear", "all");
outlet(0, "cols", numfields);
outlet(0, "rows", 25);
outlet(0, "set", 0, 0, "SOURCES");
for(var i=0,j=0; i<numrecords; i++){
if(sources[i].source_type==f){
outlet(0, "set", 0, j+1,sources[i].id +" "+ sources[i].name );
j++;
}
}
}
function urlsearch(u)
{
var numrecords = sources.length;
for(var i=0,j=0; i<numrecords; i++){
if(sources[i].id==u){
outlet(0, "url", sources[i].url );
}
}
}
function cc()
{
var numfields = 1;
var numrecords = sources.length;
var fieldnames = Object.keys(sources[0]);
var values = new Array(25);
outlet(0, "clear", "all");
outlet(0, "cols", numfields);
outlet(0, "rows", 25);
outlet(0, "set", 0, 0, "SOURCES");
for(var i=0,j=0; i<numrecords; i++){
if(sources[i].cc_free==true){
outlet(0, "set", 0, j+1,sources[i].id +" "+ sources[i].name );
j++;
}
}
}