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 1/3] [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 d6976f843..916c9e01f 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2173,122 +2173,7 @@ function displayCountyContacts(state, county) { 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 000000000..9e06db281 --- /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 + } + }); + } + } + }); +} From cf9e87c6276b87c1be15b4113b4d4b77921df398 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:51:13 +0100 Subject: [PATCH 2/3] [Refactor footer.php] Split modes functions to it's own file --- application/views/interface_assets/footer.php | 105 +----------------- assets/js/sections/mode.js | 97 ++++++++++++++++ 2 files changed, 98 insertions(+), 104 deletions(-) create mode 100644 assets/js/sections/mode.js diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 916c9e01f..f37060499 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1540,110 +1540,7 @@ function displayTimelineContacts(querystring, band, mode, type) { uri->segment(1) == "mode") { ?> - + uri->segment(1) == "accumulated") { ?> diff --git a/assets/js/sections/mode.js b/assets/js/sections/mode.js new file mode 100644 index 000000000..7717736d5 --- /dev/null +++ b/assets/js/sections/mode.js @@ -0,0 +1,97 @@ +$('.modetable').DataTable({ + "pageLength": 25, + responsive: false, + ordering: false, + "scrollY": "500px", + "scrollCollapse": true, + "paging": false, + "scrollX": true +}); + +function createModeDialog() { + $.ajax({ + url: base_url + 'index.php/mode/create', + type: 'post', + success: function(html) { + BootstrapDialog.show({ + title: 'Create mode', + size: BootstrapDialog.SIZE_WIDE, + cssClass: 'create-mode-dialog', + nl2br: false, + message: html, + buttons: [{ + label: 'Close', + action: function (dialogItself) { + dialogItself.close(); + } + }] + }); + } + }); +} + +function createMode(form) { + if (form.mode.value != '') { + $.ajax({ + url: base_url + 'index.php/mode/create', + type: 'post', + data: {'mode': form.mode.value, + 'submode': form.submode.value, + 'qrgmode': form.qrgmode.value, + 'active': form.active.value}, + success: function(html) { + location.reload(); + } + }); + } +} + +function deactivateMode(modeid) { + $.ajax({ + url: base_url + 'index.php/mode/deactivate', + type: 'post', + data: {'id': modeid }, + success: function(html) { + $(".mode_" + modeid).text('not active'); + $('.btn_'+modeid).html('Activate'); + $('.btn_'+modeid).attr('onclick', 'activateMode('+modeid+')') + } + }); +} + +function activateMode(modeid) { + $.ajax({ + url: base_url + 'index.php/mode/activate', + type: 'post', + data: {'id': modeid }, + success: function(html) { + $('.mode_'+modeid).text('active'); + $('.btn_'+modeid).html('Deactivate'); + $('.btn_'+modeid).attr('onclick', 'deactivateMode('+modeid+')') + } + }); +} + +function deleteMode(id, mode) { + BootstrapDialog.confirm({ + title: 'DANGER', + message: 'Warning! Are you sure you want to delete the following mode: ' + mode + '?' , + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + callback: function(result) { + if(result) { + $.ajax({ + url: base_url + 'index.php/mode/delete', + type: 'post', + data: {'id': id + }, + success: function(data) { + $(".mode_" + id).parent("tr:first").remove(); // removes mode from table + } + }); + } + } + }); +} From 098657c95214fc35a2ff23e951035351f08c36f8 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:56:04 +0100 Subject: [PATCH 3/3] [Refactor footer.php] Split timeplotter functions to it's own file --- application/views/interface_assets/footer.php | 87 +------------------ assets/js/sections/timeplot.js | 81 +++++++++++++++++ 2 files changed, 82 insertions(+), 86 deletions(-) create mode 100644 assets/js/sections/timeplot.js diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index f37060499..50a339ad3 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1553,92 +1553,7 @@ function displayTimelineContacts(querystring, band, mode, type) { - + uri->segment(1) == "qsl") { ?> diff --git a/assets/js/sections/timeplot.js b/assets/js/sections/timeplot.js new file mode 100644 index 000000000..8d1f1699b --- /dev/null +++ b/assets/js/sections/timeplot.js @@ -0,0 +1,81 @@ +function timeplot(form) { + $(".ld-ext-right").addClass('running'); + $(".ld-ext-right").prop('disabled', true); + $(".alert").remove(); + $.ajax({ + url: base_url+'index.php/timeplotter/getTimes', + type: 'post', + data: {'band': form.band.value, 'dxcc': form.dxcc.value, 'cqzone': form.cqzone.value}, + success: function(tmp) { + $(".ld-ext-right").removeClass('running'); + $(".ld-ext-right").prop('disabled', false); + if (tmp.ok == 'OK') { + plotTimeplotterChart(tmp); + } + else { + $("#container").remove(); + $("#info").remove(); + $("#timeplotter_div").append('
×\n' + + tmp.error + + '
'); + } + } + }); +} + +function plotTimeplotterChart(tmp) { + $("#container").remove(); + $("#info").remove(); + $("#timeplotter_div").append('

' + tmp.qsocount + ' contacts were plotted.

'); + var options = { + chart: { + type: 'column', + zoomType: 'xy', + renderTo: 'container' + }, + title: { + text: 'Time Distribution' + }, + xAxis: { + categories: [], + crosshair: true, + type: "category", + min:0, + max:47, + }, + yAxis: { + title: { + text: '# QSOs' + } + }, + rangeSelector: { + selected: 1 + }, + tooltip: { + formatter: function () { + if(this.point) { + return "Time: " + options.xAxis.categories[this.point.x] + + "
Callsign(s) worked (max 5): " + myComments[this.point.x] + + "
Number of QSOs: " + series.data[this.point.x] + ""; + } + } + }, + series: [] + }; + var myComments=[]; + + var series = { + data: [] + }; + + $.each(tmp.qsodata, function(){ + myComments.push(this.calls); + options.xAxis.categories.push(this.time); + series.name = 'Number of QSOs'; + series.data.push(this.count); + }); + + options.series.push(series); + + var chart = new Highcharts.Chart(options); +}