From 58f14d407a402aacbf6d30400d872bc98486ef75 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:44:39 +0100 Subject: [PATCH] [Refactor footer.php] Split contesting names to it's own file --- application/views/interface_assets/footer.php | 117 +----------------- assets/js/sections/contestingnames.js | 106 ++++++++++++++++ 2 files changed, 107 insertions(+), 116 deletions(-) create mode 100644 assets/js/sections/contestingnames.js diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index d6976f84..916c9e01 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2173,122 +2173,7 @@ function deleteQsl(id) { uri->segment(1) == "contesting" && $this->uri->segment(2) == "add") { ?> - - + diff --git a/assets/js/sections/contestingnames.js b/assets/js/sections/contestingnames.js new file mode 100644 index 00000000..9e06db28 --- /dev/null +++ b/assets/js/sections/contestingnames.js @@ -0,0 +1,106 @@ +$('.contesttable').DataTable({ + "pageLength": 25, + responsive: false, + ordering: false, + "scrollY": "400px", + "scrollCollapse": true, + "paging": false, + "scrollX": true, + dom: 'Bfrtip', + buttons: [ + 'csv' + ] +}); + +// using this to change color of csv-button if dark mode is chosen +var background = $('body').css( "background-color"); + +if (background != ('rgb(255, 255, 255)')) { + $(".buttons-csv").css("color", "white"); +} + +function createContestDialog() { + $.ajax({ + url: base_url + 'index.php/contesting/create', + type: 'post', + success: function(html) { + BootstrapDialog.show({ + title: 'Add Contest', + size: BootstrapDialog.SIZE_WIDE, + cssClass: 'create-contest-dialog', + nl2br: false, + message: html, + buttons: [{ + label: 'Close', + action: function (dialogItself) { + dialogItself.close(); + } + }] + }); + } + }); +} + +function createContest(form) { + if (form.contestname.value != '') { + $.ajax({ + url: base_url + 'index.php/contesting/create', + type: 'post', + data: {'name': form.contestname.value, + 'adifname': form.adifcontestname.value}, + success: function(html) { + location.reload(); + } + }); + } +} + +function deactivateContest(contestid) { + $.ajax({ + url: base_url + 'index.php/contesting/deactivate', + type: 'post', + data: {'id': contestid }, + success: function(html) { + $(".contest_" + contestid).text('not active'); + $('.btn_'+contestid).html('Activate'); + $('.btn_'+contestid).attr('onclick', 'activateContest('+contestid+')') + } + }); +} + +function activateContest(contestid) { + $.ajax({ + url: base_url + 'index.php/contesting/activate', + type: 'post', + data: {'id': contestid }, + success: function(html) { + $('.contest_'+contestid).text('active'); + $('.btn_'+contestid).html('Deactivate'); + $('.btn_'+contestid).attr('onclick', 'deactivateContest('+contestid+')') + } + }); +} + +function deleteContest(id, contest) { + BootstrapDialog.confirm({ + title: 'DANGER', + message: 'Warning! Are you sure you want to delete the following contest: ' + contest + '?' , + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + callback: function(result) { + if(result) { + $.ajax({ + url: base_url + 'index.php/contesting/delete', + type: 'post', + data: {'id': id + }, + success: function(data) { + $(".contest_" + id).parent("tr:first").remove(); // removes mode from table + } + }); + } + } + }); +}