Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 27e6185

Browse files
author
Zirak
committed
Cleaned off #235 per style guide.
1 parent b0f84b4 commit 27e6185

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

master.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5103,8 +5103,16 @@ bot.addCommand(bot.CommunityCommand({
51035103
(function () {
51045104

51055105
function mdn ( args, cb ) {
5106-
IO.jsonp.google(
5107-
args.toString() + ' site:developer.mozilla.org', finishCall );
5106+
var terms = args.toString().split(/,\s*/g);
5107+
var results = {
5108+
unescapedUrls : [],
5109+
formatted : []
5110+
};
5111+
5112+
terms.forEach(function ( term ) {
5113+
IO.jsonp.google(
5114+
term + ' site:developer.mozilla.org', finishCall );
5115+
});
51085116

51095117
function finishCall ( resp ) {
51105118
if ( resp.responseStatus !== 200 ) {
@@ -5114,9 +5122,26 @@ function mdn ( args, cb ) {
51145122

51155123
var result = resp.responseData.results[ 0 ];
51165124
bot.log( result, '/mdn result' );
5117-
finish( result.url );
5125+
5126+
var title = IO.decodehtmlEntities(
5127+
result.titleNoFormatting.split(' -')[0].trim()
5128+
);
5129+
5130+
results.formatted.push( bot.adapter.link(title, result.url) );
5131+
results.unescapedUrls.push( result.url );
5132+
5133+
if ( results.formatted.length === terms.length ) {
5134+
aggregatedResults();
5135+
}
51185136
}
5137+
function aggregatedResults () {
5138+
var msg = results.formatted.join( ', ' );
5139+
if ( msg.length > bot.adapter.maxLineLength ) {
5140+
msg = results.unescapedUrls.join( ', ' );
5141+
}
51195142

5143+
finish( msg );
5144+
}
51205145
function finish ( res ) {
51215146
if ( cb && cb.call ) {
51225147
cb( res );

0 commit comments

Comments
 (0)