From 3df54d92273988e431ec97c6073132acf13eff00 Mon Sep 17 00:00:00 2001 From: Andres Sanchez Garcia Date: Thu, 20 Sep 2018 01:21:50 +0200 Subject: [PATCH] Night mode Rudimentary night mode and little ordered JS functions --- admin.php | 6 ++++++ core/night.php | 11 +++++++++++ editText.php | 6 ++++++ index.php | 6 ++++++ js/funciones-basic.js | 35 ++++++++++++++++++++++++++++++++++- textos.php | 6 ++++++ usuarios.php | 6 ++++++ 7 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 core/night.php diff --git a/admin.php b/admin.php index 0c7ffa0..03881ae 100644 --- a/admin.php +++ b/admin.php @@ -4,6 +4,12 @@ $conn = new connectionSQLite('.'); //conexion BD session_start(); +if (isset($_SESSION['nightMode'])) { + echo ''; +} else { + echo ''; +} + if ($_SESSION["logueado"] == TRUE) { ?> diff --git a/core/night.php b/core/night.php new file mode 100644 index 0000000..300feea --- /dev/null +++ b/core/night.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/editText.php b/editText.php index 2480ee3..869f58a 100644 --- a/editText.php +++ b/editText.php @@ -4,6 +4,12 @@ require 'core/connectionSQLite.php'; $conn = new connectionSQLite('.'); +if (isset($_SESSION['nightMode'])) { + echo ''; +} else { + echo ''; +} + if (isset($_SESSION["ident"]) && isset($_SESSION["clave"])) { $clave = $_SESSION["clave"]; $identificador = $_SESSION["ident"]; diff --git a/index.php b/index.php index 4fe12ef..cb7c004 100644 --- a/index.php +++ b/index.php @@ -3,6 +3,12 @@ var night= "' . $_SESSION['nightMode'] . '"; '; +} else { + echo ''; +} + if (!empty($_SESSION["logueado"])) { if ($_SESSION["logueado"] == TRUE) { Header("Location: admin.php"); diff --git a/js/funciones-basic.js b/js/funciones-basic.js index c34f817..748e2da 100644 --- a/js/funciones-basic.js +++ b/js/funciones-basic.js @@ -1,14 +1,41 @@ $(document).ready(function(){ + init(); //funciones cargas al inicio + + checkNight();//funcion para comprobar el modo noche +}); + +function init(){ $("#tooglenight").change(function() { + const data = new FormData();//creamos datos para un form if(this.checked) { $("#bd").addClass("night"); $(".footer i").css("color", "white"); $(".by").css("color", "white"); + data.append('nightMode', 'yes');//incluimos key y valor }else{ + data.append('nightMode', 'no'); $("#bd").removeClass("night"); $(".footer i").css("color", "#ff8d0c"); $(".by").css("color", "#ff8d0c"); } + //send data post con ajax JQuery + fetch('./core/night.php', { + method: 'POST', + body: data + }) + .then(function(response) { + if(response.ok) { + return response.text(); + } else { + throw "Error en la llamada Ajax"; + } + }) + .then(function(texto) { + console.log(texto); + }) + .catch(function(err) { + console.log(err); + }); }); $(".btEditar").click(function(evt) { @@ -29,4 +56,10 @@ $(document).ready(function(){ } $('#'+evt.currentTarget.parentElement.parentElement.id+' .ocult').fadeIn(1000); }); -}); +} + +function checkNight(){ + if(night === 'yes'){ + $("#tooglenight").click(); + } +} \ No newline at end of file diff --git a/textos.php b/textos.php index 6d02856..91dee86 100644 --- a/textos.php +++ b/textos.php @@ -5,6 +5,12 @@ $conn = new connectionSQLite('.'); $textos = $conn->getStrings(); +if (isset($_SESSION['nightMode'])) { + echo ''; +} else { + echo ''; +} + if ($_SESSION["logueado"] == TRUE) { ?> diff --git a/usuarios.php b/usuarios.php index 166a27b..1c7fa3e 100644 --- a/usuarios.php +++ b/usuarios.php @@ -6,6 +6,12 @@ $usuarios = $conn->getUsers(); +if (isset($_SESSION['nightMode'])) { + echo ''; +} else { + echo ''; +} + if ($_SESSION["logueado"] == TRUE) { ?>