-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
78 lines (61 loc) · 1.79 KB
/
script.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
$( document ).ready(function() {
//working on voting bar
function getPercentageChange(p, n){
var decreaseValue = p - n;
return (decreaseValue / p) * 100;
};
function storeIP(data, url, callback) {
$.ajax({
type: 'post',
url: url,
data: data,
success: function (data) {
console.log('Success');
console.log(data);
callback(data);
},
error: function () {
console.log('We are sorry but our servers are having an issue right now');
},
})
};
function storeClicks(clicks, url) {
$.ajax({
type: 'post',
url: url,
data: {badClicks: clicks},
success: function (data) {
console.log('Success');
console.log(data);
},
error: function () {
console.log('We are sorry but our servers are having an issue right now');
},
})
}
$('.row.secondary').hide();
//collecting negative feelings
$('.col.left').on('click', function() {
$( ".row.secondary" ).slideDown( "slow", function() {
$.get( "http://ip-api.com/json", function( data, res ) {
var ip = data.query;
storeIP(ip,'/ipsN', function(result) {
$('#negative').html(result).css('color', 'rgba(224, 86, 88)');
});
});
});
$('#question').text('Thank you for your answer!');
})
//collecting positive feelings
$('.col.right').on('click', function() {
$( ".row.secondary" ).slideDown( "slow", function() {
$.get( "http://ip-api.com/json", function( data ) {
var ip = data.query;
storeIP(ip, '/ipsP', function(result) {
$('#positive').html(result).css('color', 'rgba(61, 247, 102)')
});
});
});
$('#question').text('Thank you for your answer!');
})
});