forked from boogiespook/telescope-toggle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·634 lines (565 loc) · 23.3 KB
/
index.php
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charSet="utf-8"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<title data-react-helmet="true">Telescope Toggle</title>
<link rel="stylesheet" href="css/patternfly.css" />
<link rel="stylesheet" href="css/patternfly-addons.css" />
<link rel="stylesheet" href="css/brands.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/tabs.css" />
</head>
<body>
<?php
$pg_host = getenv('PG_HOST');
$pg_db = getenv('PG_DATABASE');
$pg_user = getenv('PG_USER');
$pg_passwd = getenv('PG_PASSWORD');
$db_connection = pg_connect("host=$pg_host port=5432 dbname=$pg_db user=$pg_user password=$pg_passwd");
include 'functions.php';
?>
<div class="pf-c-page">
<header class="pf-c-page__header">
<div class="pf-c-page__header-brand">
<div class="pf-c-page__header-brand-toggle">
</div>
<a class="pf-c-page__header-brand-link">
<img class="pf-c-brand" src="images/telescope-banner4.png" alt="Telescope logo" />
</a>
</div>
</header>
<main class="pf-c-page__main" tabindex="-1">
<section class="pf-c-page__main-section pf-m-full-height">
<div class="tabset">
<!-- Tab 1 -->
<!-- Tab 4 -->
<input type="radio" name="tabset" id="tab1" aria-controls="dashboard" checked>
<label for="tab1">Dashboard</label>
<input type="radio" name="tabset" id="tab2" aria-controls="toggle">
<label for="tab2">Telescope Toggle</label>
<!-- Tab 2 -->
<input type="radio" name="tabset" id="tab3" aria-controls="integrations">
<label for="tab3">Integrations</label>
<!-- Tab 3 -->
<input type="radio" name="tabset" id="tab4" aria-controls="methods">
<label for="tab4">Integration Methods</label>
<input type="radio" name="tabset" id="tab5" aria-controls="domains">
<label for="tab5">Domains</label>
<input type="radio" name="tabset" id="tab6" aria-controls="capabilities">
<label for="tab6">Capabilities</label>
<!-- Start of Toggle -->
<div class="tab-panels">
<!-- Start of Dashboard -->
<section id="dashboard" class="tab-panel">
<p id="dashboard" class="pf-c-title pf-m-3xl">Telescope Dashboard </p>
<section class="pf-c-page__main-section pf-m-fill">
<div class="pf-l-gallery pf-m-gutter">
<?php
## Get domains & capabilities
$getDomains = "select domain.description, domain.id from domain ORDER BY domain.description;";
$domainResult = pg_query($getDomains) or die('Error message: ' . pg_last_error());
# putAperture($row['id'])
$i = 1;
while ($row = pg_fetch_assoc($domainResult)) {
print '
<div class="pf-c-card pf-m-selectable-raised pf-m-rounded" id="card-' . $i . '">
<div class="pf-c-card__header">';
putAperture($row['id']);
print '
</div>
<div class="pf-c-card__title">
<p id="card-' . $i . '-check-label">'. $row['description'] . '</p>
<div class="pf-c-content">
<small>Key Capabilities</small>
</div>
</div>
<div class="pf-c-card__body">
<div class="pf-c-content">';
$getCapabilities = "select capability.id as id, capability.description as capability, flag.description as flag from capability,flag where domain_id = '" . $row['id'] . "' and capability.flag_id = flag.id ORDER BY capability;";
$capabilityResult = pg_query($getCapabilities) or die('Error message: ' . pg_last_error());
while ($capRow = pg_fetch_assoc($capabilityResult)) {
print putIcon($capRow['flag'], $capRow['capability']);
}
$i++;
print "</div></div></div>";
}
?>
</section>
<button onClick="window.location.reload();" class="pf-c-button pf-m-primary" type="button">Refresh</button>
</section>
<!-- End of Dashboard -->
<!-- Start of Toggle -->
<section id="toggle" class="tab-panel">
<form id="toggle" class="pf-c-form" action="updateToggle.php" >
<p class="pf-c-title pf-m-3xl">Telescope Toggle</p>
<p>Items in <span class="blue">Blue</span> indicate that an integration is in place for that capability</p>
<div class="pf-l-gallery pf-m-gutter">
<!-- CHANGE TO GET DYNAMIC NAMES -->
<?php putToggleItems(); ?>
<div class="pf-c-form__group pf-m-action">
<div class="pf-c-form__actions">
<button class="pf-c-button pf-m-primary" type="submit">Submit Updates</button>
</div>
</div>
</form>
<!-- End of Toggle -->
</section>
<section id="integrations" class="tab-panel">
<!-- Start of Integrations -->
<p id="integrations" class="pf-c-title pf-m-2xl">Current Integrations</p>
<table class="pf-c-table pf-m-grid-lg" role="grid" aria-label="This is a sortable table example" id="table-sortable">
<thead>
<tr role="row">
<th class="pf-c-table__sort pf-m-selected " role="columnheader" aria-sort="ascending" scope="col">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Capability</span>
<span class="pf-c-table__sort-indicator">
<i class="fas fa-long-arrow-alt-up"></i>
</span>
</div>
</button>
</th>
<th class="pf-c-table__sort pf-m-help " role="columnheader" aria-sort="none" scope="col">
<div class="pf-c-table__column-help">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Integration Name</span>
<span class="pf-c-table__sort-indicator">
<i class="fas fa-arrows-alt-v"></i>
</span>
</div>
</button>
<span class="pf-c-table__column-help-action">
</span>
</div>
</th>
<th class="pf-c-table__sort pf-m-help " role="columnheader" aria-sort="none" scope="col">
<div class="pf-c-table__column-help">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Success Criteria</span>
<span class="pf-c-table__sort-indicator">
<i class="fas fa-arrows-alt-v"></i>
</span>
</div>
</button>
<span class="pf-c-table__column-help-action">
</span>
</div>
</th>
<th class="pf-c-table__sort pf-m-help " role="columnheader" aria-sort="none" scope="col">
<div class="pf-c-table__column-help">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Last Update</span>
<span class="pf-c-table__sort-indicator">
<i class="fas fa-arrows-alt-v"></i>
</span>
</div>
</button>
<span class="pf-c-table__column-help-action">
</span>
</div>
</th>
<th class="pf-c-table__sort pf-m-help " role="columnheader" aria-sort="none" scope="col">
<div class="pf-c-table__column-help">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Delete Integration<br></span>
</div>
</button>
<span class="pf-c-table__column-help-action">
</span>
</div>
</th>
<th class="pf-c-table__sort pf-m-help " role="columnheader" aria-sort="none" scope="col">
<div class="pf-c-table__column-help">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text"></span>
</div>
</button>
<span class="pf-c-table__column-help-action">
</span>
</div>
</th>
</tr>
</thead>
<tbody role="rowgroup">
<?php
$qq = "SELECT integrations.integration_id, capability.description as capability , integrations.integration_name as integration, integrations.last_update as updated, success_criteria from capability,integrations WHERE integrations.capability_id = capability.id";
#print $qq;
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
## Add to table
## <td role="cell" data-label="updated"><button class="pf-c-button pf-m-primary pf-m-small" type="button">Run Integration</button></td>
while ($row = pg_fetch_assoc($result)) {
print '
<tr role="row">
<td role="cell" data-label="Capability">' . $row['capability'] . '</td>
<td role="cell" data-label="Integration">' . $row['integration'] . '</td>
<td role="cell" data-label="Success Criteria">' . $row['success_criteria'] . '</td>
<td role="cell" data-label="updated">' . $row['updated'] . '</td>
<td role="cell" data-label="deleteIntegration"> <a aria-label="Delete" href="delete.php?id=' . $row['integration_id'] . '&table=integrations&idColumn=integration_id" class="confirmation"> <i class="fa fa-trash"></i></a> </td>
</tr>
';
}
?>
</tbody>
</table>
<br>
<!-- Start of Add Integrations -->
<p id="integrations" class="pf-c-title pf-m-2xl">Add Integration</p>
<form class="pf-c-form" action="addIntegration.php">
<div class="pf-l-grid pf-m-all-6-col-on-md pf-m-gutter">
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="horizontal-form-name">
<span class="pf-c-form__label-text">Integration Name</span>
<span class="pf-c-form__label-required" aria-hidden="true">*</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" required type="text" id="integration-name" name="integration-name" aria-describedby="horizontal-form-name-helper2" />
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="endpoint-url">
<span class="pf-c-form__label-text">URL endpoint</span>
<span class="pf-c-form__label-required" aria-hidden="true">*</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" type="text" id="endpoint-url" name="endpoint-url" required/>
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="capability-id">
<span class="pf-c-form__label-text">Capability</span>
</label>
</div>
<div class="pf-c-form__group-control">
<select class="pf-c-form-control" id="capability-id" name="capability-id">
<?php
$qq = "select domain.description as domain, capability.description as capability, capability.id as capabilityId from domain,capability where domain.id = capability.domain_id;";
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
while ($row = pg_fetch_assoc($result)) {
$str = $row['domain'] . " - " . $row['capability'];
print '
<option value="' . $row['capabilityid'] . '">' . $str . '</option>
';
}
?>
</select>
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="integration_method_id">
<span class="pf-c-form__label-text">Integration Method</span>
</label>
</div>
<div class="pf-c-form__group-control">
<select class="pf-c-form-control" id="integration_method_id" name="integration_method_id">
<?php
$qq = "select integration_method_name, id from integration_methods;";
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
while ($row = pg_fetch_assoc($result)) {
print '
<option value="' . $row['id'] . '">' . $row['integration_method_name'] . '</option>
';
}
?>
</select>
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="username">
<span class="pf-c-form__label-text">Username</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" type="text" id="username" name="username" />
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="password">
<span class="pf-c-form__label-text">Password</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" type="text" id="password" name="password" />
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="token">
<span class="pf-c-form__label-text">Token</span>
</label>
</div>
<div class="pf-c-form__group-control">
<textarea class="pf-c-form-control" name="token" id="token"></textarea> </div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="success-criteria">
<span class="pf-c-form__label-text">Success Criteria</span>
</label>
</div>
<p
class="pf-c-form__helper-text"
id="form-demo-grid-name-helper"
aria-live="polite"
>Success criteria depends on the specific integration. For example it could be a number (such as a %) or boolean (true/false, yes/no)</p>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" type="text" id="success-criteria" name="success-criteria" required/>
</div>
</div>
<div class="pf-c-form__group pf-m-action">
<div class="pf-c-form__actions">
<button class="pf-c-button pf-m-primary" type="submit">Add Integration</button>
</div>
</div>
</div>
</form>
</section>
<!-- End of Add Integrations -->
<!-- Start of Add Integration Methods -->
<section id="methods" class="tab-panel">
<p id="integrations" class="pf-c-title pf-m-2xl">Current Integration Methods</p>
<table class="pf-c-table pf-m-grid-lg" role="grid" aria-label="This is a sortable table example" id="table-sortable">
<thead>
<tr role="row">
<th class="pf-c-table__sort pf-m-selected " role="columnheader" aria-sort="ascending" scope="col">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Integration Method</span>
</div>
</button>
</th>
<th class="pf-c-table__sort pf-m-selected " role="columnheader" aria-sort="ascending" scope="col">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Delete Integration Method</span>
</div>
</button>
</th>
</tr>
</thead>
<tbody role="rowgroup">
<?php
$qq = "select integration_method_name, id from integration_methods";
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
while ($row = pg_fetch_assoc($result)) {
print '
<tr role="row">
<td role="cell" data-label="method">' . $row['integration_method_name'] . '</td>
<td role="cell" data-label="deleteIntegrationMethod"> <a aria-label="Delete" href="delete.php?id=' . $row['id'] . '&table=integration_methods&idColumn=id" class="confirmation"> <i class="fa fa-trash"></i></a> </td>
</tr>
';
}
?>
</tbody>
</table>
<br>
<p id="integrations" class="pf-c-title pf-m-2xl">Add Integration Method</p>
<form class="pf-c-form" action="addIntegrationMethod.php">
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="horizontal-form-name">
<span class="pf-c-form__label-text">Integration Method Name</span>
<span class="pf-c-form__label-required" aria-hidden="true">*</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" required type="text" id="integration_method" name="integration_method" aria-describedby="horizontal-form-name-helper2" />
</div>
</div>
<div class="pf-c-form__group pf-m-action">
<div class="pf-c-form__actions">
<button class="pf-c-button pf-m-primary" type="submit">Add Integration Method</button>
</div>
</div>
</form>
<!-- End of Add Integrations Methods -->
</section>
<!-- Start of Domains -->
<section id="domains" class="tab-panel">
<div class="pf-l-grid pf-m-gutter">
<div class="pf-l-grid__item pf-m-6-col">
<p class="pf-c-title pf-m-2xl">Domains</p>
<p class="pf-c-title pf-m-md"><span class="red">WARNING</span> - Deleting a domain will also delete all child capabilities</p>
<table class="pf-c-table pf-m-compact pf-m-grid-md" role="grid" id="table-sortable">
<thead>
<tr role="row">
<th class="pf-c-table__sort pf-m-selected " role="columnheader" aria-sort="ascending" scope="col">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Domain</span>
</div>
</button>
</th>
<th class="pf-c-table__sort pf-m-selected " role="columnheader" aria-sort="ascending" scope="col">
<button class="pf-c-table__button">
<div class="pf-c-table__button-content">
<span class="pf-c-table__text">Delete Domain</span>
</div>
</button>
</th>
</tr>
</thead>
<tbody role="rowgroup">
<?php
$qq = "select description,id from domain order by description";
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
while ($row = pg_fetch_assoc($result)) {
print '
<tr role="row">
<td role="cell" data-label="method">' . $row['description'] . '</td>
<td role="cell" data-label="deleteDomain"> <a aria-label="Delete" href="delete.php?id=' . $row['id'] . '&table=domain&idColumn=id" class="confirmation"> <i class="fa fa-trash"></i></a> </td>
</tr>
';
}
?>
</tbody>
</table>
<br>
<p id="integrations" class="pf-c-title pf-m-2l">Add Domain</p>
<form class="pf-c-form" action="addDomain.php">
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="horizontal-form-name">
<span class="pf-c-form__label-text">Domain Name</span>
<span class="pf-c-form__label-required" aria-hidden="true">*</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" required type="text" id="domain" name="domain" aria-describedby="horizontal-form-name-helper2" />
</div>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__actions">
<button class="pf-c-button pf-m-primary" type="submit">Add Domain</button>
</div>
</div>
</form>
</div>
</div>
</section>
<!-- End of Domains -->
<!-- Start of Capabilities -->
<section id="capabilities" class="tab-panel">
<div class="pf-l-grid pf-m-gutter">
<div class="pf-l-grid__item pf-m-6-col">
<p class="pf-c-title pf-m-2xl">Capabilities</p>
<p class="pf-c-title pf-m-md">Use the tree structure below to view and delete capabilities</p>
<p><i>Note: You can't delete capabilities which have active integrations</i></p>
<br>
<?php
#$qq = "select capability.description as capability,capability.id as capabilityid,capability.domain_id,domain.description as domain from capability, domain WHERE domain.id = capability.domain_id order by domain";
$qq = "select description from domain order by description";
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
while ($row = pg_fetch_assoc($result)) {
print '
<details class="details">
<summary class="summary">' . $row['description'] . '</summary>
<ul>';
$qq2 = "select capability.description as capability,capability.id as capabilityid,capability.domain_id,domain.description as domain from capability, domain WHERE domain.id = capability.domain_id and domain.description = '" . $row['description'] . "' order by domain";
$result2 = pg_query($qq2) or die('Error message: ' . pg_last_error());
while ($row2 = pg_fetch_assoc($result2)) {
## Check if there is an integration for the capability
$integrationQuery = "select count(*) as total from integrations where capability_id = '" . $row2['capabilityid'] . "'";
$integrationResult = pg_query($integrationQuery) or die('Error message: ' . pg_last_error());
$intCount = pg_fetch_assoc($integrationResult);
if ($intCount['total'] > 0) {
print '<li><span role="cell" data-label="deleteCapability"><i class="fa fa-times"></i></span>  ' . $row2['capability'] . '</li>';
#$toggleClass = "toggle-capability-integration";
} else {
print '<li><span role="cell" data-label="deleteCapability"> <a aria-label="Delete" href="delete.php?id=' . $row2['capabilityid'] . '&table=capability&idColumn=id" class="confirmation"> <i class="fa fa-trash"></i></a></span>  ' . $row2['capability'] . '</li>';
#$toggleClass = "toggle-capability";
}
}
print "</ul></details>";
}
?>
</div>
<div class="pf-l-grid__item pf-m-6-col">
<p id="capabilities" class="pf-c-title pf-m-2l">Add Capability</p>
<form class="pf-c-form" action="addCapability.php">
<div class="pf-c-form__group">
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="horizontal-form-name">
<span class="pf-c-form__label-text">Capability Name</span>
<span class="pf-c-form__label-required" aria-hidden="true">*</span>
</label>
</div>
<div class="pf-c-form__group-control">
<input class="pf-c-form-control" required type="text" id="capability" name="capability" aria-describedby="horizontal-form-name-helper2" />
</div>
</div>
<div class="pf-c-form__group-control">
<label class="pf-c-form__label" for="horizontal-form-name">
<span class="pf-c-form__label-text">Select Domain</span>
</label>
<select class="pf-c-form-control" id="domainId" name="domainId">
<?php
$qq = "select description,id from domain order by description;";
$result = pg_query($qq) or die('Error message: ' . pg_last_error());
while ($row = pg_fetch_assoc($result)) {
$str = $row['description'];
print '
<option value="' . $row['id'] . '">' . $str . '</option>
';
}
?>
</select>
</div>
<div class="pf-c-form__group">
<div class="pf-c-form__actions">
<button class="pf-c-button pf-m-primary" type="submit">Add Capability</button>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<!-- End of Capabilities -->
</div>
</section>
</main>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script type="text/javascript">
var elems = document.getElementsByClassName('confirmation');
var confirmIt = function (e) {
if (!confirm('Are you sure you want to delete this entry ?')) e.preventDefault();
};
for (var i = 0, l = elems.length; i < l; i++) {
elems[i].addEventListener('click', confirmIt, false);
}
</script>
<script type="text/javascript" >
$("form").submit(function () {
var this_master = $(this);
this_master.find('input[type="checkbox"]').each( function () {
var checkbox_this = $(this);
if( checkbox_this.is(":checked") == true ) {
checkbox_this.attr('value','1');
} else {
checkbox_this.prop('checked',true);
//DONT' ITS JUST CHECK THE CHECKBOX TO SUBMIT FORM DATA
checkbox_this.attr('value','0');
}
})
})
</script>
</body>
</html>