Compare commits

..

No commits in common. "32133a0d05bba793efe0e44bbcecbc0628a742ce" and "ce798e3b65af692702c168c032278449a4001aba" have entirely different histories.

2 changed files with 31 additions and 21 deletions

View File

@ -11,8 +11,10 @@ function addAddress(url) {
}
function editAddress(id) {
console.log("editButon")
if (document.getElementById('edit_button_' + id).value === 'Save') {
// save
console.log("save")
const url = "/address/update";
fetch(url, {
method: "POST",
@ -43,6 +45,7 @@ function editAddress(id) {
document.getElementById('edit_button_' + id).value = 'Edit'
} else {
//switch to edit
console.log("switch to edit")
document.getElementById('first_' + id).disabled = false
document.getElementById('last_' + id).disabled = false
document.getElementById('street_' + id).disabled = false
@ -55,6 +58,7 @@ function editAddress(id) {
}
function deleteAddress(id) {
console.log("del")
if (confirm('Are you sure?')) {
const url = "/address/delete";
fetch(url, {
@ -74,21 +78,17 @@ function deleteAddress(id) {
}
function sortBy(column) {
// switch direction on every call
let currentSortOrder = document.getElementById(column + '_sort')
if (currentSortOrder.innerHTML === 'asc') {
currentSortOrder.innerHTML = 'desc'
} else {
currentSortOrder.innerHTML = 'asc'
}
console.log("sortby: " + column)
const table = document.getElementById('address_table');
let dirty = true;
// loop until clean
while (dirty) {
console.log('dirty', dirty)
// assume we are finished
dirty = false
const rows = table.rows;
console.log(rows)
for (let i = 1; i < (rows.length - 2); i++) {
let x = rows[i]
let rowXId = x.id
@ -100,14 +100,14 @@ function sortBy(column) {
let rowYNumber = rowYId.charAt(rowYId.length -1)
let valueY = document.getElementById(column + '_' + rowYNumber).value
let currentSortOrder = document.getElementById(column + '_sort')
let sortOrder = 0
if (currentSortOrder.innerHTML === 'asc') {
sortOrder = 1
} else {
sortOrder = -1
}
console.log(valueX, valueY)
// mind asc & desc
let sortOrder = 1
console.log(valueX.localeCompare(valueY))
if (valueX.localeCompare(valueY) === sortOrder) {
console.log('switch A')
// switch rows
x.parentNode.insertBefore(y, x);
dirty = true
}

View File

@ -84,7 +84,7 @@ class Router
foreach ($this->dynamicRoutes as $route) {
// PHPStorm doesn't know that $parameters are always available,
// (as it is a dynamic route) so I init the array just to make PHPStorm happy.
// (as it is a dynamic route) so the init the array just to mke PHPstorm happy.
$parameters = [];
if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
foreach ($route->getParameters() as $id => $parameter) {
@ -104,6 +104,7 @@ class Router
public function path(string $routeName, array $vars = [])
{
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
if ($route->getName() == $routeName) {
if ($vars) {
// build route for dynamic routes
@ -118,7 +119,16 @@ class Router
}
}
}
// no 404, this is reached only if the code is buggy
// no 404, this is reached only if the code is wrong
// TODO doesn't find the last route
/*
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
echo $route->getRoute() . '<br>';
if ($routeName == $route->getRoute()) {
echo "equal";
}
}
die("Missing Route: $routeName");
*/
}
}