forked from CoInvestor/tech-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.html
More file actions
176 lines (163 loc) · 4.85 KB
/
page.html
File metadata and controls
176 lines (163 loc) · 4.85 KB
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
176
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto auto;
grid-template-rows: 100px 300px;
grid-gap: 10px;
background-color: #2196F3;
padding: 10px;
}
.grid-container>div {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding:20px 0;
font-size: 30px;
}
body{
font-family: 'Open Sans',serif;
font-size: 20px;
text-align: center;
background-color: #e0e0eb;
color:#4a4a4a;
}
#grid {
display: grid;
flex-wrap: wrap;
}
#grid ul{
margin: auto;
}
.token{
display: flex;
align-items: center;
background-color: white;
border: 2px solid #c2f0f0;
padding: 12px;
margin: 10px auto;
height: 150px;
}
a{
color: #2aa2a2;
font-size:30px;
margin-left:25px;
float:right;
}
.btnbox{
margin-left:auto;
margin-right:20px;
}
.title{
padding:0;
margin: 10px;
font-size: 25px;
}
.token img{
max-height: 100px;
max-width: 400px;
margin: 10px;
}
.sponsor{
background-color: #d6f5f5;
font-size: 11px;
padding:5px;
border-radius: 6px;
margin: 3px;
display: grid;
}
ul *{
list-style-type:none;
}
$ (function() {
$("body").on("input propertychange", ".floating-label-form-group", function(e) {
$(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
}).on("focus", ".floating-label-form-group", function() {
$(this).addClass("floating-label-form-group-with-focus");
}).on("blur", ".floating-label-form-group", function() {
$(this).removeClass("floating-label-form-group-with-focus");
});
});
</style>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.1.3/mustache.min.js'></script>
<title>Irina Cristache - CoInvestor Coding Test</title>
</head>
<body>
<div id="first">
<span style="color:#33cccc">COINVESTOR FUND MANAGERS</span>
<hr>
</div>
<div id="grid">
<ul>
<script id="token-template" type="text/template">
<li class="token">
<div class="sponsor-box">
{{#sponsors}}
<p class="sponsor">{{.}}</p>
{{/sponsors}}
</div>
<img src="{{logo}}">
<p class="title">{{title}}</p>
<div class="btnbox">
<a class="website" href="{{website}}"><i class="fas fa-globe"></i></a>
<a class="email" href="mailto:{{email}}"><i class="fas fa-envelope"></i></a>
</div>
</li>
</script>
</ul>
</div>
</body>
<script>
$( document ).ready(function() {
let $tm = $("#grid");
let $tokens = $tm.find("ul");
let tokentemplate = $tm.find("#token-template").html();
function renderToken(data){
$tokens.append(Mustache.render(tokentemplate, {title:data.title, logo:data.logo, sponsors:data.sponsors, website: data.website, email:data.email}));
}
function getData(page = 1){
let currentPage = page;
$.ajax({
type: "GET",
url: "https://api.coinvestor.co.uk/v2/company/sponsor?&page="+page,
dataType: "json",
success: function(data){
$.each(data.data, function(i, item){
$.ajax({
type: "GET",
url: "https://api.coinvestor.co.uk/v2/company/sponsor/"+ item.id +"?include=latestLogo,primarySponsorType,otherSponsorTypes,communications",
dataType: "json",
success: function(details){
let ob = new Object();
ob.title = item.attributes.name.toUpperCase();
console.log(ob.title);
ob.sponsors = new Array();
$.each(details.included, function(x, detail){
if(detail.type == "file_manager"){
ob.logo = detail.attributes.path;
}else if(detail.type == "sponsor_type"){
ob.sponsors.push(detail.attributes.value);
}else if(detail.type == "company_communication"){
ob.email = detail.attributes.email;
ob.website = detail.attributes.website;
}
});
renderToken(ob);
}
});
});
if(currentPage < data.meta.pagination.total_pages){
currentPage++;
getData(currentPage);
}
}
});
}
getData();
});
</script>
</html>