From 8e179e7b0b60056535c2d0f8b8242ecf9b250850 Mon Sep 17 00:00:00 2001 From: Eirik Th S Date: Wed, 26 Jan 2022 18:05:50 +0100 Subject: [PATCH] Code cleanup and revert to php version 7.3 support --- www/api/v1/.htaccess | 6 +++--- www/api/v1/products.php | 18 +++++++++--------- www/plan/draggingClass.js | 6 ++++-- www/plan/index.php | 2 +- www/review/index.php | 2 +- www/webdata/navbar.php | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/www/api/v1/.htaccess b/www/api/v1/.htaccess index 8e4c575..388fd23 100644 --- a/www/api/v1/.htaccess +++ b/www/api/v1/.htaccess @@ -3,9 +3,9 @@ RewriteEngine On #RewriteRule ^/v1/?([*a-zA-Z0-9_-]+)$ /api/index.php?slug1=$1 [L] -RewriteRule ^([*a-zA-Z0-9_-]+)(?:\/|)$ index.php?fi=$1 [L] -RewriteRule ^([*a-zA-Z0-9_-]+)/([*a-zA-Z0-9_-]+)(?:\/|)$ index.php?fi=$1&sc=$2 [L] -RewriteRule ^([*a-zA-Z0-9_-]+)/([*a-zA-Z0-9_-]+)/([*a-zA-Z0-9_-]+)(?:\/|)$ index.php?fi=$1&sc=$2&th=$3 [L] +RewriteRule ^([*a-zA-Z0-9_-]+)(?:/|)$ index.php?fi=$1 [L] +RewriteRule ^([*a-zA-Z0-9_-]+)/([*a-zA-Z0-9_-]+)(?:/|)$ index.php?fi=$1&sc=$2 [L] +RewriteRule ^([*a-zA-Z0-9_-]+)/([*a-zA-Z0-9_-]+)/([*a-zA-Z0-9_-]+)(?:/|)$ index.php?fi=$1&sc=$2&th=$3 [L] #RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?slug=$1 [L] #RewriteRule ^project/$ projects/index.php [L] diff --git a/www/api/v1/products.php b/www/api/v1/products.php index b88e367..33e77ca 100644 --- a/www/api/v1/products.php +++ b/www/api/v1/products.php @@ -98,12 +98,12 @@ class Product { return $results; } - private int $product_id; - private int $variant_id; - private string $product_name; - public ?float $price = null; - public ?DateTime $price_updated = null; - public ?int $price_age = null; + private $product_id; // int + private $variant_id; // int + private $product_name; // string + public $price = null; // ?float + public $price_updated = null; // ?DateTime + public $price_age = null; // ?int public function __construct(int $product_id, string $product_name, int $variant_id = 0){ $this->product_id = $product_id; @@ -111,7 +111,7 @@ class Product { $this->variant_id = $variant_id; } - public function getPrice(): int|false { + public function getPrice() { // : int|false global $db; if(!empty($this->price)){ return $this->price; } @@ -138,7 +138,7 @@ class Product { $productArray = array(); $productArray['name'] = $this->product_name; if($this->price){ - $productArray['price']['price'] = $this->price; + $productArray['price']['price'] = (float) $this->price; $productArray['price']['updated'] = $this->price_updated->format('Y-m-d'); $productArray['price']['age'] = $this->price_age; $productArray['price']['store'] = "store_id"; @@ -149,6 +149,6 @@ class Product { } class ProductGroup { - private string $name; + private $name; // string } \ No newline at end of file diff --git a/www/plan/draggingClass.js b/www/plan/draggingClass.js index 2aab2ae..623b853 100644 --- a/www/plan/draggingClass.js +++ b/www/plan/draggingClass.js @@ -40,13 +40,15 @@ class Draggable { this.activeDragging = true; this.draggingElem = $(ev.currentTarget); - if($(".elemHolder").length < 1){ + let holderElem = $(".elemHolder"); + + if(holderElem.length < 1){ $("body").append(elemHolderHtml); } this.draggingElem.clone().appendTo(".elemHolder"); this.draggingElem.css('opacity', '30%'); - $(".elemHolder").css('height', '').css('height', ($(".elemHolder").height()+10)+"px"); + holderElem.css('height', '').css('height', (holderElem.height()+10)+"px"); } else if(ev.type === "panend" && this.activeDragging){ // console.log("end", ev); diff --git a/www/plan/index.php b/www/plan/index.php index e685ed7..c274fef 100644 --- a/www/plan/index.php +++ b/www/plan/index.php @@ -74,7 +74,7 @@ }); }); - $("#addEmptyStore").click(ev => { + $("#addEmptyStore").on('click', ev => { stores.push(new Store()); addStoreModal.hide(); }); diff --git a/www/review/index.php b/www/review/index.php index e0fbf74..dd0fba6 100644 --- a/www/review/index.php +++ b/www/review/index.php @@ -121,7 +121,7 @@ diff --git a/www/webdata/navbar.php b/www/webdata/navbar.php index 706fce0..1333bde 100644 --- a/www/webdata/navbar.php +++ b/www/webdata/navbar.php @@ -1,5 +1,5 @@