-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-page-js.js
175 lines (160 loc) · 9.84 KB
/
custom-page-js.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
$(document).ready(function() {
var reviewsUrl = "https://docs.google.com/spreadsheets/d/e/2PACX-1vRo1pkd7bu8liIf5wU7yrjxeyUTiPmj8sV_dZsgzmZYilAd9RMdDpbhNPUI1b1Gh_WDEddABaIclZlE/pub?gid=0&single=true&output=tsv";
var reviewTemplate = `
<div class="Classic__ClassicContainer">
<a href="{{link}}" target="_blank" rel="noopener noreferrer nofollow" class="Classic__Heading">
<div class="AuthorPicture__Container Classic__StyledAuthorPicture" style="background-image: url({{useravatar}}); opacity: 1; transition: opacity 0.3s ease 0s;"></div>
<div class="Classic__HeadingInfo">
<div class="Classic__AuthorName">{{username}}</div>
<div class="Rating__Container Classic__StyledRating">
<div class="FilledSvg__Container">
<div class="FilledSvg__ContainerAbsolute FilledSvg__Unfilled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
<div class="FilledSvg__ContainerAbsolute FilledSvg__Filled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
</div>
<div class="FilledSvg__Container">
<div class="FilledSvg__ContainerAbsolute FilledSvg__Unfilled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
<div class="FilledSvg__ContainerAbsolute FilledSvg__Filled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
</div>
<div class="FilledSvg__Container">
<div class="FilledSvg__ContainerAbsolute FilledSvg__Unfilled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
<div class="FilledSvg__ContainerAbsolute FilledSvg__Filled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
</div>
<div class="FilledSvg__Container">
<div class="FilledSvg__ContainerAbsolute FilledSvg__Unfilled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
<div class="FilledSvg__ContainerAbsolute FilledSvg__Filled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
</div>
<div class="FilledSvg__Container">
<div class="FilledSvg__ContainerAbsolute FilledSvg__Unfilled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
<div class="FilledSvg__ContainerAbsolute FilledSvg__Filled">
<svg viewBox="0 0 14 14">
<path fill="none" d="M6.826 10.743l-3.28 1.724a.5.5 0 0 1-.725-.528l.627-3.65a.5.5 0 0 0-.144-.443L.65 5.26a.5.5 0 0 1 .277-.853l3.666-.533a.5.5 0 0 0 .377-.273L6.61.279a.5.5 0 0 1 .896 0L9.147 3.6a.5.5 0 0 0 .376.273l3.666.533a.5.5 0 0 1 .277.853l-2.653 2.586a.5.5 0 0 0-.144.442l.627 3.651a.5.5 0 0 1-.726.528l-3.279-1.724a.5.5 0 0 0-.465 0z"></path>
</svg>
</div>
</div>
</div>
<div class="PublicationDate__Container Classic__StyledPublicationDate">
<div datetime="{{time}}" title="{{time}}" class="DateTime__Time Classic__StyledPublicationDate">{{calculated_time}}</div>
</div>
</div>
</a>
<div class="Classic__Content">
<div class="Text__Container Classic__StyledText">
<div class="SimpleShortener__Outer">
<div class="SimpleShortener__Inner">
<div>{{details}}</div>
</div>
</div>
</div>
<a class="Supplier__Container-a7c0ny-0 dZckwk Classic__StyledSupplier" href="{{link}}" target="_blank" rel="noopener noreferrer nofollow">
<div>
<div class="Supplier__Label">Posted on</div>
<div class="Supplier__Name">{{source}}</div>
</div>
</a>
</div>
</div>
`;
var reviews = [];
var reviewsContainer = ".testimonials";
$.get(reviewsUrl, function(res) {
res = res.split("\r\n");
res = res.map(function(item) {
return item.split("\t");
});
var header = res[0];
var data = res.slice(1);
data.filter(function(dataItem) {
var reviewItem = {};
for (var i = 0;i < header.length; i++) {
reviewItem[header[i].toLowerCase().trim()] = dataItem[i];
}
if (reviewItem.products == "Form Datepicker") {
reviews.push(reviewItem);
}
});
reviews.map(function(reviewItem) {
var tpl = reviewTemplate;
for (var key in reviewItem) {
tpl = tpl.replaceAll("{{"+key+"}}", reviewItem[key]);
}
var calculated_time = timeDifference(new Date(), new Date(reviewItem.time));
tpl = tpl.replaceAll("{{calculated_time}}", calculated_time);
$(reviewsContainer).append(tpl);
});
var macyInstance = Macy({
container: ".testimonials",
columns: 4,
margin: {
x: 10,
y: 16
},
breakAt: {
940: 3,
520: 2,
400: 1
}
});
});
function timeDifference(current, previous) {
var msPerMinute = 60 * 1000;
var msPerHour = msPerMinute * 60;
var msPerDay = msPerHour * 24;
var msPerMonth = msPerDay * 30;
var msPerYear = msPerDay * 365;
var elapsed = current - previous;
if (elapsed < msPerMinute) {
return Math.round(elapsed/1000) + ' seconds ago';
}
else if (elapsed < msPerHour) {
return Math.round(elapsed/msPerMinute) + ' minutes ago';
}
else if (elapsed < msPerDay ) {
return Math.round(elapsed/msPerHour ) + ' hours ago';
}
else if (elapsed < msPerMonth) {
return Math.round(elapsed/msPerDay) + ' days ago';
}
else if (elapsed < msPerYear) {
return Math.round(elapsed/msPerMonth) + ' months ago';
}
else {
return Math.round(elapsed/msPerYear ) + ' years ago';
}
}
});