-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsection-confirmationJS.js
139 lines (106 loc) · 4.86 KB
/
section-confirmationJS.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
*
*/
var id_div_confirmation_modal;
var id_textarea_confirmation_message;
var id_button_confirmation_yes;
var id_button_confirmation_no;
var id_p_confirmation_reply;
function onLoadBody_section_confirmation() {
initElements_section_confirmation();
}
function onClickConfirmationYes_section_confirmation() {
var urlQuery = window.location.search;
urlQuery = urlQuery.replace('?', '');
setConfirmationInvitation_section_confirmation(urlQuery, 1);
}
function onClickConfirmationNo_section_confirmation() {
var urlQuery = window.location.search;
urlQuery = urlQuery.replace('?', '');
setConfirmationInvitation_section_confirmation(urlQuery, 2);
}
function onClickSaveMessage_section_confirmation() {
var urlQuery = window.location.search;
urlQuery = urlQuery.replace('?', '');
replaceContentMessage_section_confirmation(urlQuery, id_textarea_confirmation_message.value);
}
function initElements_section_confirmation() {
id_div_confirmation_modal = document.getElementById('id_div_confirmation_modal');
id_textarea_confirmation_message = document.getElementById('id_textarea_confirmation_message');
id_button_confirmation_yes = document.getElementById('id_button_confirmation_yes');
id_button_confirmation_no = document.getElementById('id_button_confirmation_no');
id_p_confirmation_reply = document.getElementById('id_p_confirmation_reply')
}
/* --- Ajax to set confirmation value --*/
function setConfirmationInvitation_section_confirmation(urlQuery, confirmation) {
var xmlHttp = createXmlHttpRequestObject();
if (xmlHttp.readyState == 0 || xmlHttp.readyState == 4) {
preAjaxSetConfirmationInvitation_section_confirmation();
xmlHttp.open("POST", "server-side/XMLSetConfirmationInvitation.php", true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
postAjaxSetConfirmationInvitation_section_confirmation(xmlHttp.responseXML);
}
}
};
xmlHttp.send("url_query=" + urlQuery + "&confirmation=" + confirmation);
} else {
setTimeout(function() {
setConfirmationInvitation_section_confirmation(urlQuery, confirmation);
}, 1000);
}
}
function preAjaxSetConfirmationInvitation_section_confirmation() {
id_button_confirmation_yes.disabled = true;
id_button_confirmation_no.disabled = true;
}
function postAjaxSetConfirmationInvitation_section_confirmation(responseXML) {
var xmlData = responseXML.documentElement.getElementsByTagName("invitation");
var confirmation = xmlData[0].getElementsByTagName("invitation_confirmation")[0].firstChild.nodeValue;
if(confirmation == 1) {
id_button_confirmation_yes.className = "btn btn-block text-center background-dark-pink text-light-pink";
id_button_confirmation_no.className = "btn btn-block text-center background-light-grey text-dark-grey";
id_p_confirmation_reply.innerHTML = "Terima kasih atas konfirmasi kehadirannya, <br />Kami tunggu kehadiran Bapak/Ibu/Saudara/i di Jogja";
}
else if(confirmation == 2) {
id_button_confirmation_yes.className = "btn btn-block text-center background-light-grey text-dark-grey";
id_button_confirmation_no.className = "btn btn-block text-center background-dark-pink text-light-pink";
id_p_confirmation_reply.innerHTML = "Terima kasih atas konfirmasi kehadirannya, <br />Mohon doa restunya";
}
id_button_confirmation_yes.disabled = false;
id_button_confirmation_no.disabled = false;
$(id_div_confirmation_modal).modal('show');
}
/* ----------------------------------------------------------------- */
/* --- Ajax to get notification whether there is new access or request -- */
function replaceContentMessage_section_confirmation(urlQuery, content) {
var xmlHttp = createXmlHttpRequestObject();
if (xmlHttp.readyState == 0 || xmlHttp.readyState == 4) {
preAjaxReplaceContentMessage_section_confirmation();
xmlHttp.open("POST", "server-side/XMLReplaceContentMessage.php", true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
postAjaxReplaceContentMessage_section_confirmation(xmlHttp.responseXML);
}
}
};
xmlHttp.send("url_query=" + urlQuery + "&content=" + content);
} else {
setTimeout(function() {
replaceContentMessage_section_confirmation(urlQuery, content);
}, 1000);
}
}
function preAjaxReplaceContentMessage_section_confirmation() {
}
function postAjaxReplaceContentMessage_section_confirmation(responseXML) {
var xmlData = responseXML.documentElement.getElementsByTagName("message");
var content = xmlData[0].getElementsByTagName("message_content")[0].firstChild.nodeValue;
id_textarea_confirmation_message.value = content;
$(id_div_confirmation_modal).modal('hide');
}
/* ----------------------------------------------------------------- */