-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
102 lines (96 loc) · 2.5 KB
/
main.js
File metadata and controls
102 lines (96 loc) · 2.5 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
/*
This will filter all rows inside the contactList table on our main page
Our search parameter is checked against the contents of each row and if found, the entire row is toggled
*/
function filterContacts(search) {
$("#contactList tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(search) > -1)
});
}
// Because of bootstrap we're toggling the hide class for our search bar rather than simply using the toggle function
function searchButtonPressed() {
$("#searchBar").toggleClass("hide");
$("#searchBar").focus();
}
/*
All functions below here use AJAX to allow asynchronous content changing
We're using it to update elements on our page without reloading or changing the page
This also allows us to animate those changes
We're using 2 ajax requests in each function, this is to update both our main content area and also our header
*/
function backButtonPressed() {
var html = $.ajax({
url: "contacts.cfm",
cache: false
})
.done(function(html) {
$("#contentWindow").fadeOut(200, function () {
$("#contentWindow").html(html);
$("#contentWindow").fadeIn(200);
});
});
var headerhtml = $.ajax({
url: "header_contacts.cfm",
cache: false
})
.done(function(headerhtml) {
$("#contentHeader").html(headerhtml);
});
}
function contactPressed(id, name) {
var html = $.ajax({
url: "contact.cfm?uid=" + id,
cache: false
})
.done(function(html) {
$("#contentWindow").fadeOut(200, function () {
$("#contentWindow").html(html);
$("#contentWindow").fadeIn(200);
});
});
var headerhtml = $.ajax({
url: "header_contact.cfm?name=" + name + "&uid=" + id,
cache: false
})
.done(function(headerhtml) {
$("#contentHeader").html(headerhtml);
});
}
function addContactPressed() {
var html = $.ajax({
url: "addcontact.cfm",
cache: false
})
.done(function(html) {
$("#contentWindow").fadeOut(200, function () {
$("#contentWindow").html(html);
$("#contentWindow").fadeIn(200);
});
});
var headerhtml = $.ajax({
url: "header_addcontact.cfm",
cache: false
})
.done(function(headerhtml) {
$("#contentHeader").html(headerhtml);
});
}
function editContactPressed(id) {
var html = $.ajax({
url: "editcontact.cfm?uid=" + id,
cache: false
})
.done(function(html) {
$("#contentWindow").fadeOut(200, function () {
$("#contentWindow").html(html);
$("#contentWindow").fadeIn(200);
});
});
var headerhtml = $.ajax({
url: "header_addcontact.cfm",
cache: false
})
.done(function(headerhtml) {
$("#contentHeader").html(headerhtml);
});
}