-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
372 lines (320 loc) · 13.3 KB
/
index.html
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hexa search</title>
<link rel="icon" href="img/logo.ico" type="image/x-icon">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="js/func.js"></script>
<style>
html,
body {
height: 100%;
width: 100%;
}
.container {
height: 100%;
width: 100%;
}
table {
border-collapse: collapse;
border-radius: 10px;
border-style: hidden;
box-shadow: 0 0 0 3px #e3e3e3;
}
#modalTable {
border-collapse: collapse;
border-radius: 10px;
border-style: hidden;
box-shadow: 0 0 0 0 #e3e3e3;
}
#mainTable {
display: none;
}
.spinner-border {
color: #e3e3e3;
}
.navbar {
z-index: 1021;
}
.floatingNav {
border-radius: 2px;
box-shadow: 0px 6px 4px -4px #999;
}
</style>
</head>
<!-- #e1b794 #7f94a3 #e3e3e3-->
<body style="background-color: #fafafa">
<nav class="navbar navbar-expand-lg navbar-light sticky-top col-4">
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Search <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="reverse_search.html">Reverse search</a>
</div>
</div>
</nav>
<div class="container">
<img src="img/partial_logo.png" class="mx-auto d-block" style="padding-top: 0%; padding-bottom: 0%">
<div id="topBar" class="sticky-top pb-4" style="background-color: #FAFAFA;">
<img src="img/name.png" class="mx-auto d-block">
<div class="d-flex row justify-content-center">
<form class="form-inline col-12">
<div class="form-group mx-auto mb-2 col-11">
<input type="text" class="form-control col-12 form-control-lg" id="positionName"
placeholder="Position name">
</div>
<button type="button" class="btn mb-2 btn-lg col-1" style="background-color:#7f94a3; color: white"
onclick="javascript:callAjax(); return false">Search</button>
</form>
</div>
</div>
<div id="spinner" class="d-flex row mt-5 col" style="visibility: hidden">
<div class="spinner-grow spinner-border mx-auto" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="d-flex row mt-3 col-8 mx-auto">
<div id="barChartContainer" class="pb-4">
<canvas id="barChart" class="pb-1"
style="padding-bottom: 15px; height: 370px; aspect-ratio: 4/3; margin-top: 5px;"></canvas>
</div>
<table id="mainTable" class="table table-hover mt-3" style="background-color: white;">
<tbody>
<tr></tr>
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog"
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<table id="modalTable" class="table" style="background-color: white;">
<div id="modalSpinner" class="spinner-grow spinner-border mx-auto" role="status">
<span class="sr-only">Loading...</span>
</div>
<tbody>
<tr id="toDelete"></tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
<script>
Chart.pluginService.register({
beforeDraw: function (chart) {
if (chart.config.options.elements.center) {
//Get ctx from string
var ctx = chart.chart.ctx;
//Get options from the center object in options
var centerConfig = chart.config.options.elements.center;
var fontStyle = centerConfig.fontStyle || 'Arial';
var txt = centerConfig.text;
var color = centerConfig.color || '#000';
var sidePadding = centerConfig.sidePadding || 20;
var sidePaddingCalculated = (sidePadding / 100) * (chart.innerRadius * 2)
//Start with a base font of 30px
ctx.font = "30px " + fontStyle;
//Get the width of the string and also the width of the element minus 10 to give it 5px side padding
var stringWidth = ctx.measureText(txt).width;
var elementWidth = (chart.innerRadius * 2) - sidePaddingCalculated;
// Find out how much the font can grow in width.
var widthRatio = elementWidth / stringWidth;
var newFontSize = Math.floor(30 * widthRatio);
var elementHeight = (chart.innerRadius * 2);
// Pick a new font size so it will not be larger than the height of label.
var fontSizeToUse = Math.min(newFontSize, elementHeight);
//Set font settings to draw it correctly.
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
var centerX = ((chart.chartArea.left + chart.chartArea.right) / 2);
var centerY = ((chart.chartArea.top + chart.chartArea.bottom) / 2);
ctx.font = fontSizeToUse + "px " + fontStyle;
ctx.fillStyle = color;
//Draw text in center
ctx.fillText(txt, centerX, centerY);
}
}
});
var options = {
title: {
display: true,
text: 'What skills are of important quality?',
position: 'top'
},
rotation: -0.7 * Math.PI,
resposive: true,
elements: {
center: {
text: '90%',
color: '#D6C9C9', // Default is #000000
fontStyle: 'Arial', // Default is Arial
sidePadding: 20 // Defualt is 20 (as a percentage)
}
}
};
var filled = false;
$(document).ready(function () {
onReady();
let query = getUrlParameter("search");
if(query!=undefined){
$('#positionName').val(query);
}
callAjax();
});
async function onSkillClick(skill) {
showModal().then(
function () {
fillModal(skill)
});
console.log(skill);
}
async function showModal() {
console.log("showing");
$("#exampleModalCenter").modal('show');
}
async function fillModal(skill) {
$("#exampleModalCenter").find('#exampleModalCenterTitle').html(skill);
$("#modalTable").html("<tbody><tr id='toDelete'></tr></tbody>");
$.ajax({
url: "http://46.101.185.98:5000/stats",
data: {
skill: $('#exampleModalCenterTitle').html(),
limit: 10
},
success: function (result) {
var result_arr = JSON.parse(result);
result_arr.forEach(element => {
addModalRow(element);
});
}
});
}
function craftModalRow(key, value) {
let row = `<tr>
<td align="center" id="skillName">${key}</td>
<td align="center">${value}%</td>
</tr>`
return row;
}
function addModalRow(parsedRow) {
var crafted = craftModalRow(parsedRow.name, parsedRow.result);
$("#modalSpinner").remove();
$("#modalTable").fadeIn(1000);
console.log($('#modalTable tr:last'));
$('#modalTable tr:last').after(crafted);
}
$(window).scroll(function () {
if ($(window).scrollTop() > 400) {
$('#topBar').addClass('floatingNav');
} else {
$('#topBar').removeClass('floatingNav');
}
});
function callAjax() {
if (filled) {
$("#chartContainer").fadeOut(300);
$("#mainTable").fadeOut(300);
$("#mainTable").html('<tbody><tr></tr></tbody>');
$("#barChartContainer").html('<canvas id="barChart" style = "padding-bottom: 15px; height: 370px; aspect-ratio: 4/3;" ></canvas>');
$("#mainTable").fadeIn(1000);
}
console.log("calling!");
$("#spinner").css("visibility", "visible");
filled = true;
$.ajax({
url: "http://46.101.185.98:5000/search",
data: {
text: $('#positionName').val(),
limit: 20
},
success: function (result) {
if (result == "\"\"") {
notFound();
}
else {
console.log(result.length);
var result_arr = JSON.parse(result);
let datapoints = []
let labelpoints = []
let c = 0
let bckColors = []
let sumOffers = result_arr[0]['unique']
console.log(sumOffers)
result_arr.forEach(element => {
// addRow(element);
if (element['count'] != undefined) {
datapoints.push(element['count'])
labelpoints.push(element['skill'])
}
// sumOffers += element['count']
c++
});
data = {
datasets: [{
data: datapoints,
backgroundColor: ['#E1B794', '#7F94A3', '#E3E3E3', '#DB2763',
'#7392B7', '#C6CAED', '#A28497', '#73683B', '#583E23',
'#E8EEF2', '#D6C9C9', '#90A9B7', '#8D5A97'],
}],
labels: labelpoints
}
// $(document).ready(oncallCenterUpdate(sumOffers));
setTimeout(function () {
options.elements.center.text = sumOffers
var canvas = document.getElementById("barChart");
var ctx = canvas.getContext('2d');
var chart = new Chart(ctx, {
type: 'doughnut',
data: data,
options: options
});
}, 1000);
result_arr.forEach(element => {
addRow(element);
});
}
}
});
};
function addRow(parsedRow) {
if (parsedRow['skill'] != undefined) {
var crafted = craftRow(parsedRow.skill, parsedRow.percentage);
$("#spinner").remove();
$("#mainTable").fadeIn(1000);
$('#mainTable tr:last').after(crafted);
}
}
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
</script>
</html>