function welcome() {
	/*
	speakParagraph("Welcome to Voice Wikipedia. \
		Use your voice to tell which Wikipedia entry to search for.\
		No need to use your eyes, the entry's content will be reading to you!.\
		Let's try it. Say. Show me.")
*/
	speakParagraph("Welcome to Voice Wikipedia.")
}

function recentList() {
	speakParagraph("There are 10 recent wikipedia articles.\
		Do you want to hear them?.")
}

function help() {
	speakParagraph("Welcome to Voice Wikipedia. \
		You can using voice commands to control this application.\
		If you want to search for a wikipedia entry. Say. Show me.\
		If you want to hear recent wikpedia. Say. List.")
}

var globalTerm = "";

function search(term) {
	para = "You want to search for " + term + ".";
	globalTerm = term;
	writelog(para);
	speakParagraph(para);
}

function yes() {
	if (globalTerm != "") {
		speakParagraph("You said yes.");
		// send ajax and get results.
		speakParagraph(" Found an article. Do you want to hear this?.");		
	}	
}

function no() {
	speakParagraph("You said no.");
	globalTerm = "";
}

function writelog(str) {
	console.log(str);
	node = document.getElementById("log");
	node.innerHTML = str;
	// $(".log").text(str);
}

function initAnnyang() {
	console.log("INIT");
	console.log(annyang);
	if (annyang) {
	
	  // Let's define our first command. First the text we expect, and then the function it should call
	  var commands = {
	  	'show me *entry': search,
	  	'list': list,
	  	'help': help,
	  	'help me': help,
	  	'yes': yes,
	  	'no': no,
	  };
	  // Add our commands to annyang
	  annyang.addCommands(commands);

	  // Start listening. You can call this here, or attach this call to an event, button, etc.
	  annyang.start();
	}
}

function initGestures() {
	var gestures = new Array();
	// gestures["L"] = "46";
	gestures["L"] = "64";
	gestures["S"] = "432101234";
	gestures["?"] = "6701232";
	gestures["R"] = "267012341";
	gestures["Z"] = "030";
	gestures["Y"] = "21076234567";
	gestures["N"] = "616";

	$('body').gestures(gestures, function (data) {
		// document.getElementById('outputbox').innerHTML += data;
		// document.getElementById('outputbox').innerHTML = data;
		if (data !== "") {
			writelog(data);
			// speakEnglish(data);	
			switch(data) {
			    case "S":
			        search("Taylor Swift");
			        break;
			    case "R":
			        recentList();
			        break;
			    case "?": 
			    	help();
			    	break;
			    case "Y": 
			    	yes();
			    	break;
			    case "N": 
			    	no();
			    	break;
			    default:
			        
			}
		}
		
	});
}

function initPad() {
	// setup a new canvas for drawing wait for device init
   //  setTimeout(function(){
	   // newCanvas();
	   $(".main").pad();
    // }, 1000);	
}

function init() {
	initAnnyang();
	initGestures();
	initPad();
}


welcome();
init();
@@ -692,17 +692,20 @@
 term) %7B%0A
-%09
+    
 para = %22
@@ -743,17 +743,20 @@
  + %22.%22;%0A
-%09
+    
 globalTe
@@ -766,17 +766,20 @@
 = term;%0A
-%09
+    
 writelog
@@ -786,17 +786,20 @@
 (para);%0A
-%09
+    
 speakPar
@@ -812,27 +812,63 @@
 (para);%0A
-%7D%0A%0A
+    $.getJSON(%22/api/search?q=%22 + term, 
 function
  yes() %7B
@@ -863,13 +863,13 @@
 tion
- yes(
+(data
 ) %7B%0A
@@ -877,30 +877,48 @@
 if (
-globalTerm != %22%22
+data != null && data.length %3E 0
 ) %7B%0A%09
-%09
+    
 spea
@@ -933,125 +933,276 @@
 ph(%22
-You said yes.%22);%0A%09%09// send ajax and get results.%0A%09%09speakParagraph(%22 Found an article. Do you want to hear this?.%22);%09%09
+Found an article. Do you want to hear this?.%22);%0A%09    globalTerm = data%5B0%5D.id%0A%09%7D else %7B%0A%09    speakParagraph(%22Article not found%22)%0A%09%7D%0A    %7D)%0A%7D%0A%0Afunction yes() %7B%0A%09if (globalTerm != %22%22) %7B%0A%09    speakParagraph(%22You said yes.%22);%0A%09    window.location = %22/article/%22 + globalTerm
 %0A%09%7D%09
@@ -1661,17 +1661,23 @@
 'list': 
-l
+recentL
 ist,%0A%09  
@@ -2487,20 +2487,16 @@
 %0A%09%09%09    
-    
 search(%22

Add search