From 1f238d1dbd61b9f174872df40f10b4f86e8495e9 Mon Sep 17 00:00:00 2001
From: PatrikB
Date: Mon, 17 Jun 2024 20:24:53 +0200
Subject: [PATCH] Expermineting to drag results
---
api/ui/results.php | 2 +-
core/api.php | 37 +++++++++++++------------------------
2 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/api/ui/results.php b/api/ui/results.php
index 283664bc69..89a3578fda 100644
--- a/api/ui/results.php
+++ b/api/ui/results.php
@@ -70,7 +70,7 @@ public function get() {
break;
case 'up':
if(!empty($this->get['uid'])) { /*Add Check if previous is set)*/
- $arr[] = $this->get();
+ $arr[] = $this->getData();
echo $arr[0];
echo $arr[1];
//foreach ($arr as $key => $value) {
diff --git a/core/api.php b/core/api.php
index 847daac865..736939299d 100644
--- a/core/api.php
+++ b/core/api.php
@@ -59,12 +59,20 @@ public function __construct($getVars) {
* @throws Exception
*/
public function get() {
- return $this->data->type;
- //throw new Exception('The action GET is not defined!');
+ throw new Exception('The action GET is not defined!');
+ }
+
+ /**
+ * @throws Exception
+ */
+ public function set() {
+ throw new Exception('The action SET is not defined!');
}
- public function set($rearrangeddata) {
- $this->data = $rearrangeddata;
- //throw new Exception('The action SET is not defined!');
+ public function setData($rearrangeddata) {
+ $this->data->content = $rearrangeddata;
+ }
+ public function getData() {
+ return $this->data->type;
}
/**
* @throws Exception
@@ -177,25 +185,6 @@ private function buildJsonEnvelope() {
}
echo json_encode($json);
}
-
- public function swap($direction, $id) {
- echo $this->data;
- if($direction==='down') {
- foreach ($this->data as $index => $value) {
- if (isset($this->data['id']) && this->data['id'] === $id) {
- if ($index < count($this->data) - 1) {
- // Swap the element with the next element
- $temp = $this->data[$index];
- $this->data[$index] = $this->data[$index + 1];
- $this->data[$index + 1] = $temp;
- }
- // No need to continue the loop once we've found and swapped the element
- break;
- }
- }
- echo $this->data;
- }
- }
/**
* Destructor: Renders the output