-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
108 lines (101 loc) · 3.35 KB
/
Copy pathscripts.js
File metadata and controls
108 lines (101 loc) · 3.35 KB
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
$(document).ready(function(){
// save comment to database
$(document).on('click', '#submit_btn', function(){
var placeName = $('#placeName').val();
var personName = $('#personName').val();
var coffeeGrade = $('#coffeeGrade').val();
var priceGrade = $('#priceGrade').val();
var atmosphereGrade = $('#atmosphereGrade').val();
$.ajax({
url: 'server.php',
type: 'POST',
data: {
'save': 1,
'placeName': placeName,
'personName': personName,
'coffeeGrade': coffeeGrade,
'priceGrade': priceGrade,
'atmosphereGrade': atmosphereGrade,
},
success: function(response){
// $('#placeName').val('');
// $('#personName').val('');
// $('#coffeeGrade').val('');
// $('#priceGrade').val('');
// $('#atmosphereGrade').val('');
$('#display_area').append(response);
}
});
});
// delete from database
$(document).on('click', '.delete', function(){
var id = $(this).data('id');
$clicked_btn = $(this);
$.ajax({
url: 'server.php',
type: 'GET',
data: {
'delete': 1,
'id': id,
},
success: function(response){
// remove the deleted comment
$clicked_btn.parent().remove();
$('#personName').val('');
$('#placeName').val('');
$('#coffeeGrade').val('');
$('#priceGrade').val('');
$('#atmosphereGrade').val('');
}
});
});
var $edit_id;
var $edit_coffeeGrade;
$(document).on('click', '.edit', function(){
$edit_id = $(this).data('id');
$edit_coffeeGrade = $(this).parent();
// grab the comment to be editted
var placeName = $(this).siblings('.display_name').text();
var personName = $(this).siblings('.comment_text').text();
// place comment in form
$('#placeName').val(placeName);
$('#personName').val(personName);
$('#coffeeGrade').val(coffeeGrade);
$('#priceGrade').val(priceGrade);
$('#atmosphereGrade').val(atmosphereGrade);
$('#submit_btn').hide();
$('#update_btn').show();
});
$(document).on('click', '#update_btn', function(){
var id = $edit_id;
var placeName = $('#placeName').val();
var personName = $('#personName').val();
var coffeeGrade = $('#coffeeGrade').val();
var priceGrade = $('#priceGrade').val();
var atmosphereGrade = $('#atmosphereGrade').val();
$.ajax({
url: 'server.php',
type: 'POST',
data: {
'update': 1,
'id': id,
'placeName': placeName,
'personName': personName,
'coffeeGrade': coffeeGrade,
'priceGrade': priceGrade,
'atmosphereGrade': atmosphereGrade,
},
success: function(response){
// $('#placeName').val('');
// $('#personName').val('');
// $('#coffeeGrade').val('');
// $('#priceGrade').val('');
// $('#atmosphereGrade').val('');
$('#submit_btn').show();
$('#update_btn').show();
$('#display_area').append(response);
$edit_coffeeGrade.replaceWith(response);
}
});
});
});