Skip to content

Commit

Permalink
Expermineting to drag results
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikBuetler committed Jun 17, 2024
1 parent 956bcd2 commit 1f238d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
2 changes: 1 addition & 1 deletion api/ui/results.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
37 changes: 13 additions & 24 deletions core/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f238d1

Please sign in to comment.