From fa2b3e9d0fceb5a405613a9cdde11f2d6f636ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=96FLER=20Alec=20=5Bha=5D?= Date: Wed, 22 Jul 2020 15:21:26 +0200 Subject: [PATCH] Preloading verbessert --- website/dbcon.php | 2 +- website/incl/img.php | 269 ++++++++++++++++++++------------------ website/index.php | 19 ++- website/randomapi.php | 3 +- website/script/preload.js | 29 ++++ website/script/show.js | 48 +++++++ 6 files changed, 235 insertions(+), 135 deletions(-) create mode 100644 website/script/preload.js create mode 100644 website/script/show.js diff --git a/website/dbcon.php b/website/dbcon.php index 44a7f44..a803896 100644 --- a/website/dbcon.php +++ b/website/dbcon.php @@ -2,7 +2,7 @@ $SQLHost = "db.a-hoefler.eu"; $SQLUser = "root"; -$SQLPasswort = ""; +$SQLPasswort = "bqCdUHZYgHeTd583kZ3cMVd9"; $SQLDatenbank = "jensmemes"; $con = mysqli_connect($SQLHost, $SQLUser, $SQLPasswort, $SQLDatenbank); diff --git a/website/incl/img.php b/website/incl/img.php index f911407..118f416 100644 --- a/website/incl/img.php +++ b/website/incl/img.php @@ -1,143 +1,152 @@ +
-

JensMemes

- +

Jens Memes

+ - -
- - '; - } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ - echo ' -
- -
+ if($ext=="mp4"){ + echo ' + +
+ +
+ + '; + } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ + echo ' +
+ +
+ '; + } + + } + + } + mysqli_free_result( $db_ergJens ); + ?> + +
+

$hit Memes

+ + +
+ + '; + } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ + echo ' +
+ +
+ + '; + } + + } + + } + mysqli_free_result( $db_ergrandom ); + ?> + +
+

Realtox Memes

+ -

randomMemes

- - -
- - '; - } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ - echo ' -
- -
+
+ +
- '; - } + '; + } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ + echo ' +
+ +
+ + '; + } - } + } -} -mysqli_free_result( $db_ergrandom ); -?> -

realtoxMemes

- + +
+

Hendrik Memes

+ - -
- - '; - } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ - echo ' -
- -
+ if($ext=="mp4"){ + echo ' - '; - } - - } - -} -mysqli_free_result( $db_ergrealtox ); -?> -

hendrikMemes

- - - - - '; - } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ - echo ' -
- -
+
+ +
- '; - } + '; + } else if($ext=="png" || $ext=="jpg" ||$ext=="jpeg"||$ext=="gif" ){ + echo ' +
+ +
+ + '; + } - } + } -} -mysqli_free_result( $db_erghendrik ); -?> \ No newline at end of file + } + mysqli_free_result( $db_erghendrik ); + ?> + + \ No newline at end of file diff --git a/website/index.php b/website/index.php index 478e083..9316b73 100644 --- a/website/index.php +++ b/website/index.php @@ -7,10 +7,12 @@ - + - + + @@ -69,6 +71,19 @@ + +
+ +

Anzeigen::

+ +
- +?> \ No newline at end of file diff --git a/website/script/preload.js b/website/script/preload.js new file mode 100644 index 0000000..c82a0e7 --- /dev/null +++ b/website/script/preload.js @@ -0,0 +1,29 @@ +document.addEventListener("DOMContentLoaded", function() { + var lazyloadImages = document.querySelectorAll("img.lazy"); + var lazyloadThrottleTimeout; + + function lazyload () { + if(lazyloadThrottleTimeout) { + clearTimeout(lazyloadThrottleTimeout); + } + + lazyloadThrottleTimeout = setTimeout(function() { + var scrollTop = window.pageYOffset; + lazyloadImages.forEach(function(img) { + if(img.offsetTop < (window.innerHeight + scrollTop)) { + img.src = img.dataset.src; + img.classList.remove('lazy'); + } + }); + if(lazyloadImages.length == 0) { + document.removeEventListener("scroll", lazyload); + window.removeEventListener("resize", lazyload); + window.removeEventListener("orientationChange", lazyload); + } + }, 20); + } + + document.addEventListener("scroll", lazyload); + window.addEventListener("resize", lazyload); + window.addEventListener("orientationChange", lazyload); +}); \ No newline at end of file diff --git a/website/script/show.js b/website/script/show.js new file mode 100644 index 0000000..96734c1 --- /dev/null +++ b/website/script/show.js @@ -0,0 +1,48 @@ +$(document).ready(function(){ + $('#show').on('change', function() { + if ( this.value == '0') + { + $("#jens").show(); + $("#realtox").show(); + $("#random").show(); + $("#hendrik").show(); + $("#jens").show(); + + } + else if(this.value == '1') + { + $("#jens").hide(); + $("#realtox").hide(); + $("#random").hide(); + $("#hendrik").hide(); + $("#jens").show(); + }else if(this.value == '2') + { + $("#jens").hide(); + $("#realtox").show(); + $("#random").hide(); + $("#hendrik").hide(); + $("#jens").hide(); + }else if(this.value == '3') + { + $("#jens").hide(); + $("#realtox").hide(); + $("#random").hide(); + $("#hendrik").show(); + $("#jens").hide(); + }else if(this.value == '4') + { + $("#jens").hide(); + $("#realtox").hide(); + $("#random").show(); + $("#hendrik").hide(); + $("#jens").hide(); + }else if(this.value == '5') + { + $("#jens").hide(); + $("#realtox").hide(); + $("#random").hide(); + $("#hendrik").hide(); + } + }); +}); \ No newline at end of file