From 3d0129b647de34fa288b50e6ee1b5e81b00b7562 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 24 Nov 2018 16:07:08 -0700 Subject: [PATCH] Improve behavior without JavaScript --- action.php | 6 ++++- langs/en/notes.json | 4 ++- lib/Note.lib.php | 2 ++ pages/editnote.php | 18 ++++++++++--- pages/home.php | 66 ++++++++++++++++++++++----------------------- 5 files changed, 58 insertions(+), 38 deletions(-) diff --git a/action.php b/action.php index c42ce82..517fc29 100644 --- a/action.php +++ b/action.php @@ -38,7 +38,6 @@ switch ($VARS['action']) { if (!isset($VARS['content']) || empty($VARS['noteid'])) { die($Strings->get("invalid parameters", false)); } - http_response_code(204); $note = Note::loadNote($VARS['noteid']); if (!$note->hasWriteAccess(new User($_SESSION['uid']))) { die($Strings->get("invalid parameters", false)); @@ -46,6 +45,11 @@ switch ($VARS['action']) { $note->setText($VARS['content']); $note->setColor($VARS['color']); $note->saveNote(); + if (isset($VARS['reload'])) { + returnToSender("", "¬e=" . $note->getID()); + } else { + http_response_code(204); + } break; case "deletenote": if (empty($VARS['noteid'])) { diff --git a/langs/en/notes.json b/langs/en/notes.json index ee33272..c72dec4 100644 --- a/langs/en/notes.json +++ b/langs/en/notes.json @@ -8,6 +8,8 @@ "Note deleted": "Note deleted", "Favorite": "Favorite", "Set color": "Set color", + "Note color": "Note color", "Cancel": "Cancel", - "Save": "Save" + "Save": "Save", + "Close": "Close" } diff --git a/lib/Note.lib.php b/lib/Note.lib.php index a694ff6..f605834 100644 --- a/lib/Note.lib.php +++ b/lib/Note.lib.php @@ -134,6 +134,7 @@ class Note { * @return string */ public function getColor(): string { + $this->setColor($this->color); return $this->color; } @@ -240,6 +241,7 @@ class Note { */ public function setColor(string $color) { $color = strtoupper($color); + $color = str_replace("#", "", $color); // Make sure we have a valid RRGGBB hex if (!preg_match("/[A-F0-9]{6}/", $color)) { $color = "FFFFFF"; diff --git a/pages/editnote.php b/pages/editnote.php index e0989c1..c620953 100644 --- a/pages/editnote.php +++ b/pages/editnote.php @@ -1,5 +1,4 @@ getOwnerID() != $_SESSION['uid']) { } $note->saveNote(); - ?>
- + + +
\ No newline at end of file diff --git a/pages/home.php b/pages/home.php index 67fbda4..9558f8a 100644 --- a/pages/home.php +++ b/pages/home.php @@ -56,39 +56,6 @@ foreach ($colors as $c) { ?> - -
get("New note"); ?>
@@ -133,4 +100,37 @@ foreach ($colors as $c) {
+ + + \ No newline at end of file