var PLUGIN_INFO = {NAME} Scala API document Scala API を検索し、補完します。 2.0pre 2.0pre http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/scalapi.js Yuichi Tateno MPL 1.1/GPL 2.0/LGPL 2.1 0.1 ; (function() { var p = function(arg) { Application.console.log(arg); // liberator.log(arg); }; var scalaApiURL = liberator.globalVariables.scalaApiURL || 'http://www.scala-lang.org/docu/files/api/'; if (!liberator.globalVariables.scalaApiCache) { let xhr = new XMLHttpRequest(); let regex = new RegExp('([^.]+)', 'g'); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { let text = xhr.responseText; let res = []; res.hashMap = {}; text.replace(regex, function(m) { let path = RegExp.$1; let name = path.replace('$object', ''); name = name.replace(/\//g, '.'); res.push([name, path]); res.hashMap[name] = path; }); liberator.globalVariables.scalaApiCache = res; } else { liberator.echoerr('Scala API : XHR Error: ' + xhr.statusText); // throw new Error(xhr.statusText); } } }; xhr.open('GET', scalaApiURL + 'all-classes.html', true); xhr.send(null); } commands.addUserCommand( liberator.globalVariables.scalaApiCommands || ['scalapi', 'sc'], 'Scala API Search', function(args) { var name = (args.string || ''); var url = (name && liberator.globalVariables.scalaApiCache.hashMap[name]) ? scalaApiURL + 'scala/' + liberator.globalVariables.scalaApiCache.hashMap[name] + '.html' : scalaApiURL + 'index.html'; liberator.open(url, args.bang ? liberator.NEW_TAB : null); }, { completer: function(context) { context.title = ['API Name', 'API']; var word = context.filter;// .toUpperCase(); /* if (word.indexOf('.') >= 0) { let regex = word.split(/\.+/).map(function(i) i + '[^.]*').join('.'); p(regex); regex = new RegExp('^' + regex.replace(/\[\^\.\]\*$/, '')); p(regex); context.filters = [function(item) regex.test(item.item[0])]; } else { context.filters = [function(item) item.item[0].toUpperCase().indexOf(word) != -1]; } */ try { var regex = new RegExp(word, 'i'); context.filters = [function(item) regex.test(item.item[0])]; } catch(e) { var word = context.filter.toUpperCase(); context.filters = [function(item) item.item[0].toUpperCase().indexOf(word) != -1]; } context.completions = liberator.globalVariables.scalaApiCache || []; }, argCount: '*', bang: true }, true ); })(); 5ff989af7ca9bfd4ba4a08976c4e45a7cd2e8 (plain)
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