-
Notifications
You must be signed in to change notification settings - Fork 0
/
dartExtension.dart
39 lines (30 loc) · 1 KB
/
dartExtension.dart
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
#library('dartSearchExtension');
#import('dart:html');
#import('dart:json');
#source('Result.dart');
#source('Request.dart');
#source('Parser.dart');
callFromJavascript(String name, var suggestFn, var f){
List results = new List();
if(name.toLowerCase() == "home"){
results.add("darlang.org , http://www.dartlang.org/");
f(results,suggestFn,name) ;
}else if (name.toLowerCase() == "spec"){
results.add("language specification , http://www.dartlang.org/docs/spec/latest/dart-language-specification.html");
f(results,suggestFn,name);
}else{
Parser p = new Parser();
p.reaquest = new Request();
Future<List<String>> future = p.getUrlsStartingWith(name);
future.then((resultFuture){
results = resultFuture;
if(results.length == 0 && name.length > 2){
results.add("dartlang.org : , http://www.dartlang.org/search.html?&q=${name}");
}
f(results,suggestFn,name);
});
}
}
void main() {
var t = callFromJavascript;
}