<file_sep>function displayResults(rAWR) {
    var htmlOpen = '<p>';
    var content = '';
    var htmlClose = '</p>';
    $("#results").empty();
    $("#results").addClass('well');
    for (var i=0;i<rAWR[1].length;i++) {
    var title=rAWR[1][i];
    var description=rAWR[2][i];
    var wikiURL=rAWR[3][i];
      content=htmlOpen+'<em><a href="'+wikiURL+'" target="_blank">'+title+'</a></em> '+description;
      $("#results").append(htmlOpen+content+htmlClose);
    }
  }

var fetchWiki = function(query) {
  var roar;
  $.ajax({
    url: '//en.wikipedia.org/w/api.php?action=opensearch&format=json&prop=revisions&search='+query+'&rvprop=content&rvlimit=10&rvsection=0',
    method: "GET",
    data: roar,
    dataType: "jsonp",
    //headers: { 'Api-User-Agent': 'Example/1.0' },
    success: function(roar) { displayResults(roar);}
  });
};

function sanitizeInput(string) {
    var resStr = string.split("");
    var repl={ "&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","\'":"&#x27","/":"&#x2F"};
    resStr=resStr.map(function(a){return (repl.hasOwnProperty(a)) ? repl[a] : a; });
    return resStr.join("");
  }

  $("#search").submit(function( event ) {
    event.preventDefault();
    var query=sanitizeInput($("input").val());
    fetchWiki(query);
  });
