This repository was archived by the owner on Jul 17, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
1
( function ( ) {
2
2
3
3
function mdn ( args , cb ) {
4
- IO . jsonp . google (
5
- args . toString ( ) + ' site:developer.mozilla.org' , finishCall ) ;
6
-
4
+ var terms = args . toString ( ) . split ( / , \s * / g) ,
5
+ results = { 'unescapedUrls' : [ ] , 'formatted' : [ ] } ;
6
+ terms . forEach ( function ( term ) {
7
+ IO . jsonp . google (
8
+ term + ' site:developer.mozilla.org' , finishCall ) ;
9
+ } ) ;
7
10
function finishCall ( resp ) {
11
+
8
12
if ( resp . responseStatus !== 200 ) {
9
13
finish ( 'Something went on fire; status ' + resp . responseStatus ) ;
10
14
return ;
11
15
}
12
16
13
17
var result = resp . responseData . results [ 0 ] ;
14
18
bot . log ( result , '/mdn result' ) ;
15
- finish ( result . url ) ;
19
+
20
+ var title = result . titleNoFormatting . replace ( / - .+ / , '' ) ;
21
+ results . formatted . push ( bot . adapter . link ( IO . decodehtmlEntities ( title ) , result . url ) ) ;
22
+ results . unescapedUrls . push ( result . url ) ;
23
+
24
+ if ( results . formatted . length === terms . length ) {
25
+ var msg = results . formatted . join ( ', ' ) ;
26
+ if ( msg . length > bot . adapter . maxLineLength ) {
27
+ msg = results . unescapedUrls . join ( ', ' ) ;
28
+ }
29
+ finish ( msg ) ;
30
+ }
31
+
16
32
}
17
33
18
34
function finish ( res ) {
You can’t perform that action at this time.
0 commit comments