close

  
<p> var GoogleImageSearchAPI = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&amp;rsz=large&amp;q=";
var YahooImageSearchAPI = "http://search.yahooapis.com/ImageSearchService/V1/imageSearch?output=json&amp;results=30";
var FB = acre.freebase;
 
function addThousandsCommas(nStr)
{
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length &gt; 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  }
  return x1 + x2;
}

//
//  AddComma
//
//  Add comma between list items, but not at end of list
//
function AddComma(i,len) {
  return (i+1 !== len) ? ',' : '';
}


//
// Get Topic Images
//
// Now using Yahoo API
//
function GetYahooTopicImages(topic, domain, constraint) {
  
  var YahooAppKey = "w3WOf0zV34HSaY1i8HkTuBETa2aVcKJ2ecMPqyetsMm8LL3V.vydckzrV1hXrwkA9t0-";
  
  var images = [];

  if (topic) {
    
    console.log("constraint", constraint, encodeURIComponent(constraint))
    
    var url = YahooImageSearchAPI + "&amp;query=" + encodeURIComponent(topic.name + " movie" + (constraint ? " " + constraint : "")) + "&amp;appid=" + YahooAppKey;
      
    console.log("url",url);
      
    try {
      var results = JSON.parse(acre.urlfetch(url).body).responseData.ResultSet.Result;
    }
    catch (e) {console.log("Error retrieving Yahoo images", url); return (null)}
      
      console.log("image results", results);  
    
    if (results) {        
      for (var i=0; i  3 ? 3 : topic['/film/film/starring'].length;
    
    for (var i=0; i</p>

Comments

Hide