Skip to content

Commit 2309e1c

Browse files
committed
Use .js files for javascript code
1 parent 92cfb55 commit 2309e1c

File tree

8 files changed

+75
-79
lines changed

8 files changed

+75
-79
lines changed

assets/js/custom/datatables-peers.js

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
$(document).ready(function () {
2+
$("#clientselection").multiselect();
3+
4+
var select = document.getElementById("action");
5+
var selectT = document.getElementById("trigger");
6+
displayInput(select.value, "ban", "bantime");
7+
displayInput2(selectT.value, "client", "clientselectiond", "threshold");
8+
9+
var handleDataTableButtons = function () {
10+
if ($("#rules").length) {
11+
$("#rules").DataTable({
12+
dom: '<"dataTables_exportbtn"B>ft',
13+
paging: false,
14+
order: [[0, "asc"]],
15+
bInfo: false,
16+
buttons: [
17+
{
18+
text: "Export",
19+
extend: "csv",
20+
className: "btn-sm btn-dark",
21+
exportOptions: {
22+
columns: [0, 3, 4, 5],
23+
},
24+
},
25+
],
26+
responsive: true,
27+
});
28+
}
29+
};
30+
31+
TableManageButtons = (function () {
32+
"use strict";
33+
return {
34+
init: function () {
35+
handleDataTableButtons();
36+
},
37+
};
38+
})();
39+
40+
TableManageButtons.init();
41+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$(document).ready(function () {
2+
$("#txmempool").DataTable({
3+
paging: false,
4+
bInfo: false,
5+
order: [],
6+
bFilter: false,
7+
});
8+
});

views/header.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
55
<meta
66
http-equiv="Content-Security-Policy"
7-
content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data: 'self'" />
7+
content="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; font-src: 'self'; img-src data: 'self'" />
88

99
<!-- Meta, title, CSS, favicons, etc. -->
1010
<meta charset="utf-8">

views/hoster.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,5 @@
127127
<script src="assets/js/bootstrap.min.js"></script>
128128
<!-- Custom Theme Scripts -->
129129
<script src="assets/js/custom.min.js"></script>
130-
131130
</body>
132131
</html>

views/peers.phtml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,27 @@
163163
<!-- Custom Theme Scripts -->
164164
<script src="assets/js/custom.min.js"></script>
165165

166-
<!-- Datatables -->
166+
<!-- Custom Datatables Script -->
167+
<script src="assets/js/custom/datatables-peers.js"></script>
168+
<!-- /Datatables -->
167169
<script>
168-
$(document).ready(function() {
169-
170-
$('#connectedpeers').DataTable( {
171-
paging: false,
172-
bInfo: false,
170+
$(document).ready(function() {
171+
$('#connectedpeers').DataTable( {
172+
paging: false,
173+
bInfo: false,
173174
order: [[ 5, 'desc' ]],
174-
dom: '<"dataTables_exportbtn"B>ft',
175-
buttons: [
176-
{
177-
text: 'Rules',
178-
className: "btn btn-info",
179-
action: function () {
180-
document.location = "?p=peers&c=run&t=<?= $_SESSION["csfrToken"] ?>";
181-
}
182-
}
183-
]
175+
dom: '<"dataTables_exportbtn"B>ft',
176+
buttons: [
177+
{
178+
text: 'Rules',
179+
className: "btn btn-info",
180+
action: function () {
181+
document.location = "?p=peers&c=run&t=<?= $_SESSION["csfrToken"] ?>";
182+
}
183+
}
184+
]
184185
} );
185-
186+
186187
// Check for search query
187188
const searchQuery = "<?php if(isset($_GET['q'])) echo htmlspecialchars($_GET['q']) ?>";
188189
if(searchQuery) {
@@ -193,6 +194,5 @@
193194
document.getElementsByClassName("x_content")[0].hidden = false
194195
});
195196
</script>
196-
<!-- /Datatables -->
197197
</body>
198198
</html>

views/rules.phtml

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -297,51 +297,11 @@ In the last fourth row you need to speficy the global trigger event if you check
297297
<script src="assets/js/custom.min.js"></script>
298298
<script src="assets/js/bootstrap-multiselect.js"></script>
299299

300-
<script type="text/javascript">
301-
$(document).ready(function() {
302-
$('#clientselection').multiselect();
303-
304-
var select = document.getElementById('action');
305-
var selectT = document.getElementById('trigger');
306-
displayInput(select.value, "ban", "bantime");
307-
displayInput2(selectT.value, "client", "clientselectiond", "threshold");
308-
309-
310-
311-
var handleDataTableButtons = function() {
312-
if ($("#rules").length) {
313-
$("#rules").DataTable({
314-
dom: '<"dataTables_exportbtn"B>ft',
315-
paging: false,
316-
order: [[ 0, "asc" ]],
317-
bInfo: false,
318-
buttons: [
319-
{
320-
text: 'Export',
321-
extend: "csv",
322-
className: "btn-sm btn-dark",
323-
exportOptions: {
324-
columns: [0,3,4,5]
325-
}
326-
},
327-
],
328-
responsive: true
329-
});
330-
}
331-
};
332-
333-
TableManageButtons = function() {
334-
"use strict";
335-
return {
336-
init: function() {
337-
handleDataTableButtons();
338-
}
339-
};
340-
}();
300+
<!-- Custom Datatables Script -->
301+
<script src="assets/js/custom/datatables-rules.js"></script>
302+
<!-- /Datatables -->
341303

342-
TableManageButtons.init();
343-
});
344-
304+
<script type="text/javascript">
345305
var hid1 = <?php echo ((isset($content['editRule']->id) AND $content['editRule']->global) ? 'false' : 'true') ?>;
346306
$("#global").click (function () {
347307

@@ -355,6 +315,5 @@ In the last fourth row you need to speficy the global trigger event if you check
355315
});
356316

357317
</script>
358-
<!-- /Datatables -->
359318
</body>
360319
</html>

views/wallet.phtml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,9 @@
127127
<script src="assets/js/dataTables.buttons.min.js"></script>
128128
<!-- Custom Theme Scripts -->
129129
<script src="assets/js/custom.min.js"></script>
130-
131-
<!-- Datatables -->
132-
<script>
133-
$(document).ready(function() {
134-
135-
$('#txmempool').DataTable( {
136-
"paging": false,
137-
"bInfo": false,
138-
"order": [],
139-
"bFilter": false
140-
} );
141-
142-
});
143-
</script>
130+
131+
<!-- Custom Datatables Script -->
132+
<script src="assets/js/custom/datatables-wallet.js"></script>
144133
<!-- /Datatables -->
145134
</body>
146135
</html>

0 commit comments

Comments
 (0)