This repository has been archived by the owner on Jun 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kljucne-besede.html
155 lines (154 loc) · 6.4 KB
/
kljucne-besede.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
<!DOCTYPE html>
<html>
<head>
<title>Studenc</title>
<link rel="icon" href="icon.png">
<link rel="stylesheet" href="index.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
<script type="text/javascript">
var keywords = []
$(document).ready(function() {
var xlabels = []
var graphdata = []
var chart = new Chart("myChart", {
type: "line",
data: {
ylabels: xlabels,
datasets: graphdata
},
options: {
responsive: true,
title: {
display: true,
position: "top",
text: "GRAF",
fontSize: 18,
fontColor: "#008cff"
},
legend: {
display: true,
position: "top",
labels: {
fontColor: "#333",
fontSize: 16
}
},
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Število zadetkov'
},
xAxes: [{
type: "time"
}],
ticks: {
beginAtZero: true
}
}]
}
}
});
chart.render();
$('#add').click(function(){
var temp = {}
word = $("#besedainput").val()
let kwd = keywords.find(o => o.word === word)
if (typeof kwd === 'undefined') {
color = $("#colorselector").val()
temp["word"] = word
temp["color"] = color
keywords.push(temp)
//request all keyword data and display it
$.ajax({
url: "http://localhost:6969/keywordhits",
data: {word: temp.word},
success: function(data) {
$("#tabelabesedbody").append("<tr style='color:"+temp.color+"'><th>"+temp.word+"</th><th>"+data["total"]+"</th></tr>")
var tempData = {}
tempData.label = temp.word
tempDataPoints = []
tempData.borderColor = temp.color
tempData.fill = false
delete data["total"]
for (date in data) {
tmpdp = {}
tmpdp.t = date
tmpdp.y = data[date]
tempDataPoints.push(tmpdp)
xlabels.push(date)
}
tempData.data = tempDataPoints
graphdata.push(tempData)
chart.update()
},
})
} else {
alert("Ta beseda že obstaja!")
}
});
})
</script>
</head>
<body>
<div class="header">
<table>
<thead>
<tr>
<td><a href="/"><img src="icon.png" height="128px"></img></a></td>
<td>
<div class="header-titles">
<h2><strong>DOBRODOŠLI PRI STUDENCU</strong></h2>
<h4><strong>Web scraper za študentske programerske službe na <a href="https://www.studentski-servis.com/studenti">studentski-servis.com</a></strong></h4>
<h4 class="buttons"><a href="/">SLUŽBE</a></h4>
<h4 class="buttons"><a href="/kljucne-besede.html">STATISTIKA KLJUČNIH BESED</a></h4>
</div>
</td>
</tr>
</thead>
</table>
</div>
<br>
<div id="dodajbesede">
<p class="title">DODAJ KLJUČNE BESEDE</p>
<div class="wordinputform">
<p class="inputshit">BESEDA:</p>
<input class="inputshit" type="text" id="besedainput">
<p class="inputshit">BARVA:</p>
<select name="BARVE" id="colorselector">
<option value="red">RDEČA</option>
<option value="blue">MODRA</option>
<option value="green">ZELENA</option>
<option value="chocolate">RJAVA</option>
<option value="violet">VIJOLIČNA</option>
<option value="orange">ORANŽNA</option>
<option value="deeppink">ROZA</option>
<option value="yellow">RUMENA</option>
<option value="magenta">MAGENTA</option>
<option value="indigo">INDIGO</option>
<option value="aqua">AQUA</option>
</select>
<button id="add">DODAJ</button>
</div>
</div>
<br>
<div id="besede">
<table class="tabelabesed" id="tabelabesed">
<thead>
<tr>
<th>BESEDA</th>
<th>ŠTEVILO ZADETKOV</th>
</tr>
</thead>
<tbody id="tabelabesedbody">
</tbody>
</table>
</div>
<br>
<div id="charts">
<canvas id="myChart" style="width:100%"></canvas>
</div>
<div class="footer"></div>
</body>
</html>