Skip to content

Instantly share code, notes, and snippets.

@jaseflow
Created August 24, 2017 00:40
Show Gist options
  • Save jaseflow/9fd16f9064cd03e58b886c0fb392524b to your computer and use it in GitHub Desktop.
Save jaseflow/9fd16f9064cd03e58b886c0fb392524b to your computer and use it in GitHub Desktop.
if (supportsTemplate()) {
forEach(Object.keys(data), function(i) {
var review = data[i];
var t = document.querySelector('#innova-review');
var date = new Date(review.created_at);
var styledDate = date.getDate() + ' ' + monthNames[date.getMonth()] + ' ' + date.getFullYear();
t.content.querySelector('.innova-review__date').textContent = styledDate;
t.content.querySelector('.innova-review__business').textContent = innovaBusiness;
t.content.querySelector('.innova-review__name').textContent = review.name;
t.content.querySelector('.innova-review__score').textContent = review.rating;
t.content.querySelector('.innova-review__title').textContent = review.title;
t.content.querySelector('.innova-review__message').textContent = review.content;
t.content.querySelector('.innova-stars__star').setAttribute('class', 'innova-stars__star innova-stars__star--' + review.rating.toString().replace('.','-'));
var clone = document.importNode(t.content, true);
document.getElementById('innova-reviews').appendChild(clone);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment