-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
309 lines (259 loc) · 11.4 KB
/
index.html
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
}
#regForm {
background-color: #ffffff;
margin: 100px auto;
font-family: Raleway;
padding: 40px;
width: 70%;
min-width: 300px;
}
h1 {
text-align: center;
}
input {
padding: 10px;
width: 100%;
font-size: 17px;
font-family: Raleway;
border: 1px solid #aaaaaa;
}
/* Mark input boxes that gets an error on validation: */
input.invalid {
background-color: #ffdddd;
}
/* Hide all steps by default: */
.tab {
display: none;
}
button {
background-color: #04AA6D;
color: #ffffff;
border: none;
padding: 10px 20px;
font-size: 17px;
font-family: Raleway;
cursor: pointer;
}
button:hover {
opacity: 0.8;
}
#prevBtn {
background-color: #bbbbbb;
}
/* Make circles that indicate the steps of the form: */
.step {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbbbbb;
border: none;
border-radius: 50%;
display: inline-block;
opacity: 0.5;
}
.step.active {
opacity: 1;
}
/* Mark the steps that are finished and valid: */
.step.finish {
background-color: #04AA6D;
}
</style>
<body>
<!-- <form id="regForm" action=""><div class="tab">I_RECHARGE_AMOUNT:
<p><input placeholder="100" oninput="this.className = ''"></p>I_RECHARGE_AMOUNT:
<p><input placeholder="200" oninput="this.className = ''"></p></div><div class="tab">I_DATE:
<p><input placeholder="2023/05/03 16:41:43" oninput="this.className = ''"></p>
</div><div class="tab">I_SUBSCRIBER_TYPE:
<p><input placeholder="SMS;EMAIL" oninput="this.className = ''"></p>
</div><div style="overflow:auto;">
<div style="float:right;">
<button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
<button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
</div>
<div style="text-align:center;margin-top:40px;"><span class="step"></span><span class="step"></span><span class="step"></span><span class="step"></span>
</div>
</div> </form> -->
<form id="regForm" action="">
<div id="content"></div>
</form>
<script>
let htmlstring = ``
function XmlToList() {
// XML data string
htmlstring = `<form id="regForm" action="">`
let xmlString = "<DETAIL><RULES><RULE><IF><CONDITION><NEGATED><![CDATA[N]]></NEGATED><CONDITIONS><CONDITION><NEGATED><![CDATA[N]]></NEGATED><LEFTVALUE><![CDATA[I_RECHARGE_AMOUNT]]></LEFTVALUE><FUNCTION><![CDATA[>=]]></FUNCTION><VALUE><TEXT><![CDATA[100]]></TEXT></VALUE></CONDITION><CONDITION><NEGATED><![CDATA[N]]></NEGATED><OPERATOR><![CDATA[AND]]></OPERATOR><LEFTVALUE><![CDATA[I_RECHARGE_AMOUNT]]></LEFTVALUE><FUNCTION><![CDATA[<=]]></FUNCTION><VALUE><TEXT><![CDATA[200]]></TEXT></VALUE></CONDITION></CONDITIONS></CONDITION><THEN><IF><CONDITION><NEGATED><![CDATA[N]]></NEGATED><LEFTVALUE><![CDATA[I_DATE]]></LEFTVALUE><FUNCTION><![CDATA[<=]]></FUNCTION><VALUE><TEXT><![CDATA[2023/05/03 16:41:43]]></TEXT></VALUE></CONDITION><THEN><IF><CONDITION><NEGATED><![CDATA[N]]></NEGATED><LEFTVALUE><![CDATA[I_SUBSCRIBER_TYPE]]></LEFTVALUE><FUNCTION><![CDATA[not in list]]></FUNCTION><VALUE><TEXT><![CDATA[SMS;EMAIL]]></TEXT></VALUE></CONDITION><THEN><ACTION><FIELD><NAME><![CDATA[ActionID]]></NAME><VALUE><![CDATA[0_0_1_0]]></VALUE></FIELD><FIELD><NAME><![CDATA[ActionConsequence]]></NAME><VALUE><![CDATA[true]]></VALUE></FIELD><FIELD><NAME><![CDATA[ActionName]]></NAME><VALUE><![CDATA[COMMON_SERVICE]]></VALUE></FIELD><FIELD><NAME><![CDATA[ActionCall]]></NAME><VALUE><![CDATA[EXTERNAL]]></VALUE></FIELD><FIELD><NAME><![CDATA[ActionURL]]></NAME><VALUE><![CDATA[http://localhost:8080/RuleEngine/rule/dummy-synch-response]]></VALUE></FIELD><FIELD><NAME><![CDATA[ActionFeature]]></NAME><VALUE><![CDATA[PROMOTION]]></VALUE></FIELD><FIELD><NAME><![CDATA[ActionType]]></NAME><VALUE><![CDATA[SYNCH]]></VALUE></FIELD><FIELD><NAME><![CDATA[GuiActionName]]></NAME><VALUE><![CDATA[ExternalSUBRULE]]></VALUE></FIELD></ACTION></THEN></IF></THEN></IF></THEN></IF><SCHEDULE><FIELD><NAME><![CDATA[ScheduleId]]></NAME><VALUE><![CDATA[3015]]></VALUE></FIELD><FIELD><NAME><![CDATA[ScheduleName]]></NAME><VALUE><![CDATA[GUITEST3015]]></VALUE></FIELD><FIELD><NAME><![CDATA[ScheduleType]]></NAME><VALUE><![CDATA[ScheduleNow]]></VALUE></FIELD><FIELD><NAME><![CDATA[CAMPAIGN_ID]]></NAME><VALUE><![CDATA[1229]]></VALUE></FIELD><FIELD><NAME><![CDATA[CAMPAIGN_NAME]]></NAME><VALUE><![CDATA[magikcampaign]]></VALUE></FIELD><FIELD><NAME><![CDATA[Priority]]></NAME><VALUE><![CDATA[1]]></VALUE></FIELD><FIELD><NAME><![CDATA[Threshold]]></NAME><VALUE><![CDATA[NORMAL]]></VALUE></FIELD><FIELD><NAME><![CDATA[ThresholdProcess]]></NAME><VALUE><![CDATA[SINGLE]]></VALUE></FIELD></SCHEDULE></RULE></RULES></DETAIL>";
// Create a new DOMParser object
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, "application/xml");
const ifTags = xmlDoc.getElementsByTagName('IF');
const count = ifTags.length;
for (let i = 0; i < xmlDoc.getElementsByTagName("RULE").length; i++) {
const rule = xmlDoc.getElementsByTagName("RULE")[i];
if(rule.getElementsByTagName("IF")[0]!=null){
parseIf(rule.getElementsByTagName("IF")[0]);
}
}
htmlstring = htmlstring + `<div style="overflow:auto;">
<div style="float:right;">
<button type="button" id="prevBtn" onclick="nextPrev(-1)" style="display: none;">Previous</button>
<button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
</div>
<div style="text-align:center;margin-top:40px;">
<span class="step finish active"> </span>`
for (let index = 1; index < count; index++) {
htmlstring = htmlstring + `<span class="step"> </span>`
}
htmlstring = htmlstring + `
</div>
</div>
</form>`
console.log("*****************",htmlstring)
}
function parseIf(element) {
if (element.getElementsByTagName("CONDITION")[0] != null) {
parseCondition(element.getElementsByTagName("CONDITION")[0])
}
if (element.getElementsByTagName("THEN")[0].getElementsByTagName("IF")[0] != null) {
parseIf(element.getElementsByTagName("THEN")[0].getElementsByTagName("IF")[0])
}
}
function parseCondition(condition) {
if (condition.getElementsByTagName("CONDITIONS")[0] != null) {
parseConditions(condition.getElementsByTagName("CONDITIONS")[0])
}
else{
var Name = condition.getElementsByTagName("LEFTVALUE")[0].childNodes[0].nodeValue;
var Nameval = condition.getElementsByTagName("VALUE")
[0].getElementsByTagName("TEXT")[0].childNodes[0].nodeValue;
htmlstring = htmlstring + `<div class="tab" style="display: none;">`+ Name +`:
<p><input placeholder="`+ Nameval +`" oninput="this.className = ''"></p>
</div>`
}
}
function parseConditions(conditions) {
htmlstring = htmlstring + `<div class="tab" style="display: block;">`
for (let i = 0; i < conditions.getElementsByTagName("CONDITION").length; i++) {
if (conditions.getElementsByTagName("CONDITION")[i]!= null) {
parseCondition2(conditions.getElementsByTagName("CONDITION")[i])
}
}
htmlstring = htmlstring + `</div>`
}
function parseCondition2(condition2){
var Name = condition2.getElementsByTagName("LEFTVALUE")[0].childNodes[0].nodeValue;
var Nameval = condition2.getElementsByTagName("VALUE")
[0].getElementsByTagName("TEXT")[0].childNodes[0].nodeValue;
htmlstring = htmlstring + Name +`:
<p><input placeholder="`+ Nameval +`" oninput="this.className = ''" class=""></p>`
}
window.addEventListener('DOMContentLoaded', function() {
XmlToList()
var contentContainer = document.getElementById('content');
// let htmlstring2 = `<form id="regForm" action=""><div class="tab" style="display: block;">I_RECHARGE_AMOUNT:
// <p><input placeholder="100" oninput="this.className = ''" class=""></p>I_RECHARGE_AMOUNT:
// <p><input placeholder="200" oninput="this.className = ''" class=""></p>
// </div><div class="tab" style="display: none;">I_DATE:
// <p><input placeholder="2023/05/03 16:41:43" oninput="this.className = ''"></p>
// </div>
// <div class="tab">I_SUBSCRIBER_TYPE:
// <p><input placeholder="SMS;EMAIL" oninput="this.className = ''"></p>
// </div>
// <div style="overflow:auto;">
// <div style="float:right;">
// <button type="button" id="prevBtn" onclick="nextPrev(-1)" style="display: none;">Previous</button>
// <button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
// </div>
// <div style="text-align:center;margin-top:40px;">
// <span class="step finish active">
// </span><span class="step">
// </span><span class="step">
// </span><span class="step">
// </span>
// </div>
// </div> </form>`
contentContainer.outerHTML = htmlstring;
console.log("code reaching")
});
var currentTab = 0; // Current tab is set to be the first tab (0)
showTab(currentTab); // Display the current tab
function showTab(n) {
// This function will display the specified tab of the form...
var x = document.getElementsByClassName("tab");
console.log("x",x)
x[n].style.display = "block";
//... and fix the Previous/Next buttons:
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1)) {
document.getElementById("nextBtn").innerHTML = "Submit";
} else {
document.getElementById("nextBtn").innerHTML = "Next";
}
//... and run a function that will display the correct step indicator:
fixStepIndicator(n)
}
function nextPrev(n) {
// This function will figure out which tab to display
var x = document.getElementsByClassName("tab");
// Exit the function if any field in the current tab is invalid:
if (n == 1 && !validateForm()) return false;
// Hide the current tab:
x[currentTab].style.display = "none";
// Increase or decrease the current tab by 1:
currentTab = currentTab + n;
// if you have reached the end of the form...
if (currentTab >= x.length) {
// ... the form gets submitted:
document.getElementById("regForm").submit();
return false;
}
// Otherwise, display the correct tab:
showTab(currentTab);
}
function validateForm() {
// This function deals with validation of the form fields
var x, y, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("input");
// A loop that checks every input field in the current tab:
for (i = 0; i < y.length; i++) {
// If a field is empty...
if (y[i].value == "") {
// add an "invalid" class to the field:
y[i].className += " invalid";
// and set the current valid status to false
valid = false;
}
}
// If the valid status is true, mark the step as finished and valid:
if (valid) {
document.getElementsByClassName("step")[currentTab].className += " finish";
}
return valid; // return the valid status
}
function fixStepIndicator(n) {
// This function removes the "active" class of all steps...
var i, x = document.getElementsByClassName("step");
for (i = 0; i < x.length; i++) {
x[i].className = x[i].className.replace(" active", "");
}
//... and adds the "active" class on the current step:
x[n].className += " active";
}
</script>
</body>
</html>