JSFiddle - React, Tailwind, and code Playground
by dmitri_aleksejev
HTML
<!-- Head -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- At the end of the document -->
<script type="text/javascript">
var reviews = [];
var reviewsArray = [];
reviews.Content = function (options) {
var defaults = {
id: "",
user: {
image: null,
name: "",
ageRange: 0,
location: ""
},
content: "",
date: "",
rating: 0
}
$.extend(this, defaults, options);
};
$(function () {
var review = $(".review");
review.each(function () {
var $this = $(this);
var id = $this.attr("id").replace(/\D/g, "");
var date = $this.find(".review-date").text();
var rating = Math.round(parseInt($this.find(".review-score img").attr("title")));
var content = $this.find(".review-text").html();
var image = $this.find(".review-author-avatar img").attr("src");
var name = $this.find(".review-author-name").attr("content");
var ageRange = $this.find(".review-author-name span").text();
var location = $this.find(".review-author-name strong").text().split(",")[1];
reviewsArray.push(new reviews.Content({
id: id,
user: {
image: image,
name: name,
ageRange: ageRange,
location: location
},
content: content,
date: date,
rating: rating
}));
});
console.log(window.parent.location);
window.parent.postMessage(reviewsArray, "*");
});
</script>