/
keywords.blade.php
74 lines (61 loc) · 2.19 KB
/
keywords.blade.php
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
<div class="box box-primary" id="box-keywords" style="min-height: 400px;">
<div class="box-header with-border">
<h3 class="box-title">
<span><i class="fa fa-file-text"></i></span>
<span>Top Keywords</span>
</h3>
@include('admin.partials.boxes.toolbar')
</div>
<div class="box-body">
<div class="loading-widget text-primary">
<i class="fa fa-fw fa-spinner fa-spin"></i>
</div>
<table id="tbl-keywords" data-order-by="1|desc" class="table nowrap table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Keywords</th>
<th>Sessions</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
@section('scripts')
@parent
<script type="text/javascript" charset="utf-8">
$(function ()
{
var datatable;
initToolbarDateRange('#box-keywords .daterange', updateKeywords);
function updateKeywords(start, end)
{
$('#box-keywords .loading-widget').show();
if (datatable) {
datatable.destroy();
$('#box-keywords table tbody').html('')
}
if (!start) {
start = moment().subtract(29, 'days').format('YYYY-MM-DD');
end = moment().format('YYYY-MM-DD');
}
doAjax('/api/analytics/keywords', {
'start': start, 'end': end,
}, renderTableKeywords);
}
function renderTableKeywords(data)
{
$('#box-keywords .loading-widget').slideUp();
for (var i = 0; i < data.length; i++) {
var html = '<tr><td>' + data[i]['keyword'] + '</td><td>' + data[i]['sessions'] + '</td></tr>';
$('#box-keywords table tbody').append(html);
}
datatable = initDataTables('#tbl-keywords');
}
setTimeout(function ()
{
updateKeywords();
}, 300);
})
</script>
@endsection