close

  
<p> /* number to number with commas */ 
numberWithCommas = function(num) {
    num += '';
    x = num.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;    
}  

/* GUID to Freebase link */
freebaseUrl = function(id) {
    return acre.environ.freebase_service_url
        + '/view'
        + id
}

/* GUID to person page link */ 
nameUrl = function(id) {
    return 'person?id=' + id;
}  
  
/* ISO8601 date to human-readable date */ 
humanDate = function(mqldate, detail) {
    var humandate = '';
    var yymmdd = mqldate.split('-');
    var mm = ["Jan", "Feb", "Mar", "Apr","May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    if (detail != 'year') {
        if (yymmdd[1]) {
            var n = yymmdd[1] - 1;
            humandate += mm[n] + ' ';
        }
        if (yymmdd[2]) {
            var n = yymmdd[2] - 0;
            humandate += n + ', ' ;
        }
    }
    humandate += yymmdd[0];
    return humandate;
}
  
/* request recommendations from 24 Hour Diner */
get24HdRecommendations = function(artistName) {
  /* var items = []; */
  try {
    var url = "http://staging.24hrdiner.com/api/recommendations?project=mb&amp;field=name&amp;atom=" + encodeURIComponent(artistName) + "&amp;format=JSON";
    var jsonBody = acre.urlfetch(url).body;
  } catch (e) {
    console.log(e);
  }
  var res = JSON.parse(jsonBody).result;
  return res;
}
 </p>

Comments

Hide