From 05fc0418d302388c28ca480606da6d15839e7744 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Thu, 15 Mar 2012 12:52:47 +0000 Subject: [PATCH] cleaned interpolatedquote so it fits with the coding style --- modules/quotes.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/quotes.js b/modules/quotes.js index d001260..e805ebd 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -5,19 +5,27 @@ var quotes = function(dbot) { // Retrieve a random quote from a given category, interpolating any quote references (~~QUOTE CATEGORY~~) within it var interpolatedQuote = function(key, quoteTree) { - if( quoteTree !== undefined && quoteTree.indexOf( key ) != -1 ) { console.log('nrll'); return ''; } - else if( quoteTree === undefined ) quoteTree = []; + if(quoteTree !== undefined && quoteTree.indexOf(key) != -1) { + console.log('nrll'); + return ''; + } else if(quoteTree === undefined) { + quoteTree = []; + } + var quoteString = quotes[key].random(); var quoteRefs = quoteString.match(/~~([\d\w\s-]*)~~/g); var thisRef; - while( quoteRefs && (thisRef = quoteRefs.shift()) !== undefined ) { + + while(quoteRefs && (thisRef = quoteRefs.shift()) !== undefined) { var cleanRef = dbot.cleanNick(thisRef.replace(/^~~/,'').replace(/~~$/,'').trim()); if (quotes.hasOwnProperty(cleanRef)) { - quoteTree.push( key ); - quoteString = quoteString.replace("~~"+cleanRef+"~~", interpolatedQuote(cleanRef, quoteTree.slice())); + quoteTree.push(key); + quoteString = quoteString.replace("~~" + cleanRef + "~~", + interpolatedQuote(cleanRef, quoteTree.slice())); quoteTree.pop(); } } + return quoteString; };