1
0
mirror of https://github.com/cp6/my-idlers.git synced 2024-11-16 15:33:44 +01:00

Added a constant to set view as Cards or Table

Added a constant to set view as Cards or Table.

"CARDS", "TABLE" this means on page load that default view will be showing.
This commit is contained in:
cp6 2021-01-30 11:19:05 +11:00
parent 3de0b0956c
commit c882d47026
3 changed files with 72 additions and 31 deletions

View File

@ -149,8 +149,36 @@ $(document).ready(function () {
$('.next-dd').val(one_month_on);
if ($("#cardsViewDiv").hasClass("active")) {
loadCards();
} else if ($("#tableViewDiv").hasClass("active")){
loadTable();
}
});
function loadCards(){
$.ajax({
type: "GET",
url: "calls.php",
data: {"type": "object_cards"},
success: function (result) {
$("#cardsViewDiv").append(result);
}
});
}
function loadTable(){
$.ajax({
type: "GET",
url: "calls.php",
data: {"type": "object_tables"},
success: function (result) {
$("#tableViewDiv").append(result);
}
});
}
$(function () {
$(".location-input").autocomplete({
source: function (request, response) {
@ -175,7 +203,6 @@ $(function () {
});
});
$(document).on("click", "#viewMoreServer", function () {
var serverId = this.getAttribute("value");
$("#viewMoreModalBody").empty();
@ -315,35 +342,28 @@ $(document).on("click", "#checkUpStatus", function () {
$(document).on("click", "#viewSwitcherIcon", function () {
var icon = $(this).children().first();
if ($("#serversTable").children().length == 0){
$.ajax({
type: "GET",
url: "calls.php",
data: {"type": "object_tables"},
success: function (result) {
$("#tableViewDiv").append(result);
}
});
icon.removeClass("fa-table");
icon.addClass("fa-th");
$("#cardsViewDiv" ).hide();
$("#tableViewDiv" ).show();
$('#viewSwitchIcon').prop('title', 'Switch to cards');
} else {
if (icon.hasClass("fa-table")) {
if ($("#serversTable").children().length == 0) {
loadTable();
}
icon.removeClass("fa-table");
icon.addClass("fa-th");
$("#cardsViewDiv").hide();
$("#tableViewDiv").show();
$('#viewSwitchIcon').prop('title', 'Switch to cards');
} else if (icon.hasClass("fa-th")) {
if ($("#cardsViewDiv").children().length == 0) {
loadCards();
}
icon.removeClass("fa-th");
icon.addClass("fa-table");
$("#cardsViewDiv").addClass("active");
$("#tableViewDiv").removeClass("active");
$("#tableViewDiv").hide();
$("#cardsViewDiv").show();
$('#viewSwitchIcon').prop('title', 'Switch to table');
}
}
});
$('#virt').change(function(){

View File

@ -40,6 +40,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$idle->getIpForDomain($_GET['hostname'], $_GET['dns_type']);
} elseif ($_GET['type'] == 'check_up') {
echo $idle->checkIsUp($_GET['host']);
} elseif ($_GET['type'] == 'object_cards') {
header('Content-Type: text/html; charset=utf-8');
echo $idle->objectCards();
} elseif ($_GET['type'] == 'object_tables') {
header('Content-Type: text/html; charset=utf-8');
echo $idle->objectTables();

View File

@ -17,6 +17,8 @@ class idlersConfig
//Have slight background color for server table values: was special price and due soon
const COLOR_TABLE = true;
const DEFAULT_VIEW = 'CARDS';//CARDS or TABLE
}
class elementHelpers extends idlersConfig
@ -598,12 +600,17 @@ class idlers extends helperFunctions
$this->outputString('<div id="myTabContent" class="tab-content">');
$this->outputString('<div class="tab-pane server-cards fade active show" id="services">');
$this->viewSwitcherIcon();
$this->tagOpen('div', '', 'cardsViewDiv');
$this->serverCards();
$this->sharedHostingCards();
$this->domainCards();
if (self::DEFAULT_VIEW == 'CARDS') {
$cards_start = 'active';
$table_start = '';
} else {
$cards_start = '';
$table_start = 'active';
}
$this->tagOpen('div', $cards_start, 'cardsViewDiv');
//Object cards
$this->tagClose('div');
$this->tagOpen('div', '', 'tableViewDiv');
$this->tagOpen('div', $table_start, 'tableViewDiv');
//Objects tables
$this->tagClose('div', 2);
$this->outputString('<div class="tab-pane fade" id="add_server">');
@ -981,6 +988,13 @@ class idlers extends helperFunctions
}
}
public function objectCards()
{
$this->serverCards();
$this->sharedHostingCards();
$this->domainCards();
}
public function objectTables()
{
$this->serverTable();
@ -3082,7 +3096,11 @@ class idlers extends helperFunctions
protected function viewSwitcherIcon()
{
$this->rowColOpen('row text-center', 'col-12');
if (self::DEFAULT_VIEW == 'CARDS') {
$this->outputString('<a id="viewSwitcherIcon"><i class="fas fa-table" id="viewSwitchIcon" title="Switch to table"></i></a>');
} else {
$this->outputString('<a id="viewSwitcherIcon"><i class="fas fa-th" id="viewSwitchIcon" title="Switch to cards"></i></a>');
}
$this->tagClose('div', 2);
}