Compare commits
5 Commits
ce798e3b65
...
32133a0d05
Author | SHA1 | Date |
---|---|---|
tracer | 32133a0d05 | |
tracer | 572cc1eb89 | |
tracer | 48585f14ab | |
tracer | 47439fe358 | |
tracer | 8e0a2ff6e8 |
|
@ -11,10 +11,8 @@ function addAddress(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function editAddress(id) {
|
function editAddress(id) {
|
||||||
console.log("editButon")
|
|
||||||
if (document.getElementById('edit_button_' + id).value === 'Save') {
|
if (document.getElementById('edit_button_' + id).value === 'Save') {
|
||||||
// save
|
// save
|
||||||
console.log("save")
|
|
||||||
const url = "/address/update";
|
const url = "/address/update";
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -32,8 +30,8 @@ function editAddress(id) {
|
||||||
.then(
|
.then(
|
||||||
response => response.text()
|
response => response.text()
|
||||||
).then(
|
).then(
|
||||||
html => console.log(html)
|
html => console.log(html)
|
||||||
);
|
);
|
||||||
|
|
||||||
document.getElementById('first_' + id).disabled = true
|
document.getElementById('first_' + id).disabled = true
|
||||||
document.getElementById('last_' + id).disabled = true
|
document.getElementById('last_' + id).disabled = true
|
||||||
|
@ -45,7 +43,6 @@ function editAddress(id) {
|
||||||
document.getElementById('edit_button_' + id).value = 'Edit'
|
document.getElementById('edit_button_' + id).value = 'Edit'
|
||||||
} else {
|
} else {
|
||||||
//switch to edit
|
//switch to edit
|
||||||
console.log("switch to edit")
|
|
||||||
document.getElementById('first_' + id).disabled = false
|
document.getElementById('first_' + id).disabled = false
|
||||||
document.getElementById('last_' + id).disabled = false
|
document.getElementById('last_' + id).disabled = false
|
||||||
document.getElementById('street_' + id).disabled = false
|
document.getElementById('street_' + id).disabled = false
|
||||||
|
@ -58,7 +55,6 @@ function editAddress(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAddress(id) {
|
function deleteAddress(id) {
|
||||||
console.log("del")
|
|
||||||
if (confirm('Are you sure?')) {
|
if (confirm('Are you sure?')) {
|
||||||
const url = "/address/delete";
|
const url = "/address/delete";
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
|
@ -70,25 +66,29 @@ function deleteAddress(id) {
|
||||||
.then(
|
.then(
|
||||||
response => response.text()
|
response => response.text()
|
||||||
).then(
|
).then(
|
||||||
html => console.log(html)
|
html => console.log(html)
|
||||||
);
|
);
|
||||||
let row = document.getElementById('row_' + id)
|
let row = document.getElementById('row_' + id)
|
||||||
row.parentNode.removeChild(row)
|
row.parentNode.removeChild(row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortBy(column) {
|
function sortBy(column) {
|
||||||
console.log("sortby: " + column)
|
// switch direction on every call
|
||||||
|
let currentSortOrder = document.getElementById(column + '_sort')
|
||||||
|
if (currentSortOrder.innerHTML === 'asc') {
|
||||||
|
currentSortOrder.innerHTML = 'desc'
|
||||||
|
} else {
|
||||||
|
currentSortOrder.innerHTML = 'asc'
|
||||||
|
}
|
||||||
|
|
||||||
const table = document.getElementById('address_table');
|
const table = document.getElementById('address_table');
|
||||||
let dirty = true;
|
let dirty = true;
|
||||||
// loop until clean
|
// loop until clean
|
||||||
while (dirty) {
|
while (dirty) {
|
||||||
console.log('dirty', dirty)
|
|
||||||
// assume we are finished
|
// assume we are finished
|
||||||
dirty = false
|
dirty = false
|
||||||
const rows = table.rows;
|
const rows = table.rows;
|
||||||
console.log(rows)
|
|
||||||
for (let i = 1; i < (rows.length - 2); i++) {
|
for (let i = 1; i < (rows.length - 2); i++) {
|
||||||
let x = rows[i]
|
let x = rows[i]
|
||||||
let rowXId = x.id
|
let rowXId = x.id
|
||||||
|
@ -100,14 +100,14 @@ function sortBy(column) {
|
||||||
let rowYNumber = rowYId.charAt(rowYId.length -1)
|
let rowYNumber = rowYId.charAt(rowYId.length -1)
|
||||||
let valueY = document.getElementById(column + '_' + rowYNumber).value
|
let valueY = document.getElementById(column + '_' + rowYNumber).value
|
||||||
|
|
||||||
console.log(valueX, valueY)
|
let currentSortOrder = document.getElementById(column + '_sort')
|
||||||
// mind asc & desc
|
let sortOrder = 0
|
||||||
let sortOrder = 1
|
if (currentSortOrder.innerHTML === 'asc') {
|
||||||
|
sortOrder = 1
|
||||||
console.log(valueX.localeCompare(valueY))
|
} else {
|
||||||
|
sortOrder = -1
|
||||||
|
}
|
||||||
if (valueX.localeCompare(valueY) === sortOrder) {
|
if (valueX.localeCompare(valueY) === sortOrder) {
|
||||||
console.log('switch A')
|
|
||||||
// switch rows
|
|
||||||
x.parentNode.insertBefore(y, x);
|
x.parentNode.insertBefore(y, x);
|
||||||
dirty = true
|
dirty = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Router
|
||||||
|
|
||||||
foreach ($this->dynamicRoutes as $route) {
|
foreach ($this->dynamicRoutes as $route) {
|
||||||
// PHPStorm doesn't know that $parameters are always available,
|
// PHPStorm doesn't know that $parameters are always available,
|
||||||
// (as it is a dynamic route) so the init the array just to mke PHPstorm happy.
|
// (as it is a dynamic route) so I init the array just to make PHPStorm happy.
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
|
if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
|
||||||
foreach ($route->getParameters() as $id => $parameter) {
|
foreach ($route->getParameters() as $id => $parameter) {
|
||||||
|
@ -104,7 +104,6 @@ class Router
|
||||||
public function path(string $routeName, array $vars = [])
|
public function path(string $routeName, array $vars = [])
|
||||||
{
|
{
|
||||||
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
||||||
|
|
||||||
if ($route->getName() == $routeName) {
|
if ($route->getName() == $routeName) {
|
||||||
if ($vars) {
|
if ($vars) {
|
||||||
// build route for dynamic routes
|
// build route for dynamic routes
|
||||||
|
@ -119,16 +118,7 @@ class Router
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no 404, this is reached only if the code is wrong
|
// no 404, this is reached only if the code is buggy
|
||||||
// TODO doesn't find the last route
|
die("Missing Route: $routeName");
|
||||||
/*
|
|
||||||
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
|
||||||
echo $route->getRoute() . '<br>';
|
|
||||||
if ($routeName == $route->getRoute()) {
|
|
||||||
echo "equal";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
die("Missing Route: $routeName");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue