-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
110 lines (100 loc) · 3.32 KB
/
index.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
const newHog_name = document.getElementById('newHog-name');
const newHog_btag = document.getElementById('newHog-btag');
const newHog_region = document.getElementById('newHog-region');
const newHog_rating = document.getElementById('newHog-rating');
const newHog_rank = document.getElementById('newHog-rank');
const rateHog_rating = document.getElementById('rateHog-rating');
const rateHog_rank = document.getElementById('rateHog-rank');
let hogRateId = 0;
let detailsModal = new bootstrap.Modal(document.getElementById('hogDetails'))
function submitNewHog() {
console.log(newHog_name.value);
console.log(newHog_btag.value);
console.log(newHog_region.value);
console.log(newHog_rating.value);
console.log(newHog_rank.value);
if (newHog_name.value !== '') {
$.ajax({
dataType: 'json',
data: ({
'newHog_name': newHog_name.value,
'newHog_btag': newHog_btag.value,
'newHog_region': newHog_region.value,
'newHog_rating': newHog_rating.value,
'newHog_rank': newHog_rank.value,
}),
type: 'post',
url: 'new.php',
success: function (result) {
console.log(result);
console.log('success: ' + result['data']);
if (result['status'] === 4) {
alert('This player is already in the database')
} else {
location.reload();
}
},
error: function (result) {
console.log(result);
console.log('error: ' + result['data']);
}
})
}
}
function modalUpdate(hogId, hogName) {
document.getElementById('rateHog-title').innerText = 'Rate: ' + hogName
hogRateId = hogId;
}
function rateHog() {
console.log(hogRateId)
console.log(rateHog_rating.value);
console.log(rateHog_rank.value);
$.ajax({
dataType: 'json',
data: ({
'rateHog_id': hogRateId,
'rateHog_rating': rateHog_rating.value,
'rateHog_rank': rateHog_rank.value
}),
type: 'post',
url: 'rate.php',
success: function (result) {
console.log(result);
console.log('success: ' + result['data']);
if (result['status'] === 2) {
alert('You have already voted on this player');
} else {
location.reload();
}
},
error: function (result) {
console.log(result);
console.log('error: ' + result['data']);
}
})
}
function detailUpdateShow(id, hogName) {
document.getElementById('hogDetails-title').innerText = 'Ratings History For: ' + hogName;
document.getElementById('hogDetails-content').innerHTML = '';
$.ajax({
dataType: 'html',
data: ({
'rateHog_id': id,
}),
type: 'post',
url: 'details.php',
success: function (result) {
document.getElementById('hogDetails-content').innerHTML = result;
},
error: function (result) {
console.log(result);
console.log('error: ' + result['data']);
}
})
detailsModal.show()
}
jQuery(function () {
$('#hog-players').DataTable({
paging: false,
});
});