var ChatBot=function(){var e;var k;var j;var h;var g;var d;var l=[];var b;var c=false;var i;function n(){var v="";var t=[];var r,q;for(r=0;r$1');u=u.replace(/(\[[^\[\]]+\])/gi,'$1');var s=u.match(/['"](.+?)['"]<\/span>/gi);if(s!=null){for(q=0;q]*>/gi,"");l.push(w.replace(/['"]/gi,""))}}v+='
'+u+"
"}var p=$("#chatBotCommands");if(p.size()==0){p=$('');$("body").append(p)}else{p.html("")}for(r=0;r'))}$("#chatBotCommandDescription").html(v)}function a(p,o){setTimeout(function(){var t="";if($(g).val()!="|"){t+=$(g).val()}t+=p.currentInput.slice(p.start,p.start+1);$(g).val(t);p.start++;if(p.start');q.css("position","absolute");$("body").append(q)}var s=$(g).offset().left;var r=$(g).offset().top+$(g).outerHeight()-3;q.css("left",s+"px");q.css("top",r+"px");q.animate({width:$(g).outerWidth()+"px"},o,function(){q.css("width","0")})}},Math.random()*120+10)}return{Engines:{webknox:function(q){var o=["Ask for stock prices like 'stock price apple' or '[company] stock'.","Ask for distances as in 'how far is Perth from Melbourne' or 'distance between [place1] and [place2]'.","Want to know what the weather is like, just ask like 'weather in San Diego, California'.","Let WebKnox tell you a joke, just say 'tell me a joke'.","Convert units, e.g. '2.4 miles in kilometers' or '4 tablespoons to ml?'.","Get synonyms for a word, e.g. 'synonyms for car'.","Ask for quotes like 'quotes about [topic]' or 'quotes about love'.","Ask for quotes from a person 'quotes by [person]' or 'quotes by aristotle'.","Ask for recipes like 'spaghetti recipes' or 'chocolate donuts'.","Ask for nutrient contents like 'vitamin a in 2 carrots' or 'calories is 1 cup of butter'.","Convert ingredients like '2 cups of butter in grams'.","If you want more results, just say 'more'.","For more similar results say 'more like the first/second/third...'.","Or just ask anything that comes to mind like 'Who was pope in 1499?' or 'Who directed braveheart?'."];var p=Math.random()*100000;return{react:function(r){$.get("https://webknox-question-answering.p.mashape.com/questions/converse?mashape-key="+q+"&contextId="+p+"&text="+encodeURIComponent(r),function(v){var u=v.answerText;if(v.media!=undefined){u+="
";for(var t=0;t
'+s.title+'
Details

More like this
"}}ChatBot.addChatEntry(u,"bot");ChatBot.thinking(false)})},getCapabilities:function(){return o},getSuggestUrl:function(){return"https://webknox-question-answering.p.mashape.com/questions/converse/suggest?mashape-key="+q+"&query="}}},spoonacular:function(q){var o=["Ask for recipes like 'chicken recipes' or 'spaghetti with shrimp'","Ask for nutrient contents like 'vitamin a in 2 carrots' or 'calories is 1 cup of butter'","Convert something with '2 cups of butter in grams'","If you want more results, just say 'more'","For more similar results say 'more like the first/second/third...'","Let spoonacular tell you a joke, just say 'tell me a joke'.","Want to learn some food trivia, just say 'food trivia'."];var p=Math.random()*100000;return{react:function(r){$.get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/food/converse?mashape-key="+q+"&contextId="+p+"&text="+encodeURIComponent(r),function(v){var u=v.answerText;if(v.media!=undefined){u+="
";for(var t=0;t
'+s.title+'
Details

More like this
"}}ChatBot.addChatEntry(u,"bot");ChatBot.thinking(false)})},getCapabilities:function(){return o},getSuggestUrl:function(){return"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/food/converse/suggest?mashape-key="+q+"&query="}}},duckduckgo:function(){var o=["Ask what something is like 'What is DNA'?","Ask where something is like 'Where is China'?","Ask about a person like 'Who is Bill Gates'?","Say a movie/person/location name like 'Braveheart' to get information about that entity","Say a something like 'simpsons characters' to get information about that phrase"];return{react:function(p){$.ajax({type:"GET",url:"https://api.duckduckgo.com/?format=json&pretty=1&q="+encodeURIComponent(p),dataType:"jsonp"}).done(function(u){var t=u.AbstractText;if(t==""&&u.RelatedTopics.length>0){t="

I found multiple answers for you:

";var v=[];for(var s=0;s"+r.Result.replace(""," ")+"

"}for(s=0;s'}}else{if(u.Image!=undefined&&u.Image!=""){t+="
";t+='
'+u.Heading+"
"}}ChatBot.addChatEntry(t,"bot");ChatBot.thinking(false)})},getCapabilities:function(){return o},getSuggestUrl:function(){return null}}}},init:function(o){var p=jQuery.extend({botName:"Bot",humanName:"You",thinkingHtml:'',inputs:"",inputCapabilityListing:true,engines:[],patterns:[],addChatEntryCallback:function(r,s,q){r.addClass("appear")}},o);k=p.botName;j=p.humanName;h=p.thinkingHtml;g=p.inputs;d=p.inputCapabilityListing;b=p.engines;e=p.patterns;i=p.addChatEntryCallback;n();if(d){$(g).attr("list","chatBotCommands")}$(g).keyup(function(q){if(q.keyCode==13){ChatBot.addChatEntry($(this).val(),"human");ChatBot.react($(this).val())}})},setBotName:function(o){k=o},setHumanName:function(o){j=o;$(".chatBotChatEntry.human .origin").html(o)},addChatEntry:function m(q,o){if(q==undefined){return}if(q==""){q="Sorry, I have no idea."}var p=$('
');p.html(''+(o=="bot"?k:j)+""+q);$("#chatBotHistory").prepend(p);if(i!=undefined){i.call(this,p,q,o)}},thinking:function(o){var p=$("#chatBotThinkingIndicator");if(o){if(!c){$(g).attr("disabled","disabled")}p.html(h)}else{if(!c){$(g).removeAttr("disabled");$(g).val("");$(g).focus()}p.html("")}},react:function f(x){this.thinking(true);for(var s=0;s