Skip to content

Commit

Permalink
Use .js files for javascript code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirobit committed Sep 13, 2023
1 parent 92cfb55 commit 2309e1c
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 79 deletions.
Empty file.
41 changes: 41 additions & 0 deletions assets/js/custom/datatables-rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
$(document).ready(function () {
$("#clientselection").multiselect();

var select = document.getElementById("action");
var selectT = document.getElementById("trigger");
displayInput(select.value, "ban", "bantime");
displayInput2(selectT.value, "client", "clientselectiond", "threshold");

var handleDataTableButtons = function () {
if ($("#rules").length) {
$("#rules").DataTable({
dom: '<"dataTables_exportbtn"B>ft',
paging: false,
order: [[0, "asc"]],
bInfo: false,
buttons: [
{
text: "Export",
extend: "csv",
className: "btn-sm btn-dark",
exportOptions: {
columns: [0, 3, 4, 5],
},
},
],
responsive: true,
});
}
};

TableManageButtons = (function () {
"use strict";
return {
init: function () {
handleDataTableButtons();
},
};
})();

TableManageButtons.init();
});
8 changes: 8 additions & 0 deletions assets/js/custom/datatables-wallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$(document).ready(function () {
$("#txmempool").DataTable({
paging: false,
bInfo: false,
order: [],
bFilter: false,
});
});
2 changes: 1 addition & 1 deletion views/header.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data: 'self'" />
content="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; font-src: 'self'; img-src data: 'self'" />

<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
Expand Down
1 change: 0 additions & 1 deletion views/hoster.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,5 @@
<script src="assets/js/bootstrap.min.js"></script>
<!-- Custom Theme Scripts -->
<script src="assets/js/custom.min.js"></script>

</body>
</html>
36 changes: 18 additions & 18 deletions views/peers.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,27 @@
<!-- Custom Theme Scripts -->
<script src="assets/js/custom.min.js"></script>

<!-- Datatables -->
<!-- Custom Datatables Script -->
<script src="assets/js/custom/datatables-peers.js"></script>
<!-- /Datatables -->
<script>
$(document).ready(function() {

$('#connectedpeers').DataTable( {
paging: false,
bInfo: false,
$(document).ready(function() {
$('#connectedpeers').DataTable( {
paging: false,
bInfo: false,
order: [[ 5, 'desc' ]],
dom: '<"dataTables_exportbtn"B>ft',
buttons: [
{
text: 'Rules',
className: "btn btn-info",
action: function () {
document.location = "?p=peers&c=run&t=<?= $_SESSION["csfrToken"] ?>";
}
}
]
dom: '<"dataTables_exportbtn"B>ft',
buttons: [
{
text: 'Rules',
className: "btn btn-info",
action: function () {
document.location = "?p=peers&c=run&t=<?= $_SESSION["csfrToken"] ?>";
}
}
]
} );

// Check for search query
const searchQuery = "<?php if(isset($_GET['q'])) echo htmlspecialchars($_GET['q']) ?>";
if(searchQuery) {
Expand All @@ -193,6 +194,5 @@
document.getElementsByClassName("x_content")[0].hidden = false
});
</script>
<!-- /Datatables -->
</body>
</html>
49 changes: 4 additions & 45 deletions views/rules.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -297,51 +297,11 @@ In the last fourth row you need to speficy the global trigger event if you check
<script src="assets/js/custom.min.js"></script>
<script src="assets/js/bootstrap-multiselect.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('#clientselection').multiselect();

var select = document.getElementById('action');
var selectT = document.getElementById('trigger');
displayInput(select.value, "ban", "bantime");
displayInput2(selectT.value, "client", "clientselectiond", "threshold");



var handleDataTableButtons = function() {
if ($("#rules").length) {
$("#rules").DataTable({
dom: '<"dataTables_exportbtn"B>ft',
paging: false,
order: [[ 0, "asc" ]],
bInfo: false,
buttons: [
{
text: 'Export',
extend: "csv",
className: "btn-sm btn-dark",
exportOptions: {
columns: [0,3,4,5]
}
},
],
responsive: true
});
}
};

TableManageButtons = function() {
"use strict";
return {
init: function() {
handleDataTableButtons();
}
};
}();
<!-- Custom Datatables Script -->
<script src="assets/js/custom/datatables-rules.js"></script>
<!-- /Datatables -->

TableManageButtons.init();
});

<script type="text/javascript">
var hid1 = <?php echo ((isset($content['editRule']->id) AND $content['editRule']->global) ? 'false' : 'true') ?>;
$("#global").click (function () {

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

</script>
<!-- /Datatables -->
</body>
</html>
17 changes: 3 additions & 14 deletions views/wallet.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,9 @@
<script src="assets/js/dataTables.buttons.min.js"></script>
<!-- Custom Theme Scripts -->
<script src="assets/js/custom.min.js"></script>

<!-- Datatables -->
<script>
$(document).ready(function() {

$('#txmempool').DataTable( {
"paging": false,
"bInfo": false,
"order": [],
"bFilter": false
} );

});
</script>

<!-- Custom Datatables Script -->
<script src="assets/js/custom/datatables-wallet.js"></script>
<!-- /Datatables -->
</body>
</html>

0 comments on commit 2309e1c

Please sign in to comment.