Webseite – die neusten Beiträge

DESKTOP vs. SMARTPHONE?

Hallo zusammen. Ich kriege mein Problem seit Wochen nicht gelöst trotz offiziellen Support daher noch mal die Frage anders formuliert. 

Meine WordPress Webseite: https://mecker-ecke.com/ hat massive Unterschiede in der Ausführung von Links auf dem Smartphone. Auf dem Desktop funktioniert alles perfekt, nur auf dem Smartphone geht die "Suche" und das Anklicken von "Letzte Beiträge" nicht und springt beim Anklicken immer wieder auf die Startseite. ... und das seit Wochen.

- Caches und Cookies wurden mehrere mal gelöscht 

- Verschiedene Browser wurden verwendet 

- Unterschiedliche Smartphones wurden verwendet 

- Ich habe alle Plugins, ausser dem ASGAROS Forum, deaktiviert und es gab keine Unterschiede

- ... und einiges mehr.

Hier ein Beispiel wie die Links ausgeführt und es hier ein und derselbe Link ist und der erste logischerweise nicht gefunden werden kann:

SMARTPHONE: https://mecker-ecke.com/#postid-202

WEBSEITE: https://mecker-ecke.com/forum/topic/alice-weidel-uebernnacht-verwehrt/

https://mecker-ecke.com/forum/topic/alice-weidel-uebernnacht-verwehrt/#postid-202

Ich tippe auf die wp-options wo ein Eintrag steht, der bei einer Plugintestinstallation für rediretcion von URL's installiert und wieder gelöscht wurde. N.b. Ich hatte dort den gleichen Effekt auf dem Desktop, aber schlimmer - meine ich!

Weiss jemand, wie so ein Effekt zustande kommt und wenn es nur ein kleiner Hinweis ist?

Smartphone, Forum, Desktop, Webseite, WordPress, URL, Android, Fehlerbehebung, Link, Webentwicklung, Wordpress Plugin

(PHP-Script) Wieso funktioniert das einmal und einmal nicht?

Hab mal eine Frage zu einer Formular-PHP-aus-einer-json-Datei-auslese-und-wieder-eintrag Funktion, die ich versuche genauer zu verstehen. Genauer gesagt komm ich da an einer Stelle nicht weiter (weil sich Teile der Funktion scheinbar komplett willkürlich verhält!)

Also wenn ich in PHP eine Funktion in der Struktur hier habe:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
   $params = [
   "p1" => isset($_POST['p1']) ? $_POST['p1'] : null,
   "p2" => isset($_POST['p2']) ? $_POST['p2'] : null,
   "p3" => isset($_POST['p3']) ? $_POST['p3'] : null,
       "p4" => isset($_POST['p4']) ? $_POST['p4'] : null,
   // A_settings
       "P5" => [
           "SP1" => $_POST['P1'],
           "SP2" => $_POST['P2'],
       ],
   ];

und der Inhalt der auszulesenden json Datei so aussieht:

{
   "p1": "antwort1",
   "p2": "antwort2",
   "p3": "antwort3",
   "p4": "antwort4",
   "self": {
       "P5": {
           "SP1": antwort5,
           "SP2": antwort6
       }
   }
}

klappt scheinbar alles hervorragend. Die Parameter werden gefunden und nach dem Absenden des Formulars korrekt überschrieben.

Wenn ich allerdings wie im folgenden Beispiel etwas mehr Parameter hinzufüge wie in dieser Struktur hier und für die Benennung etwas längere Namenschemen verwende:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
   $params = [
      /// calculation nr1:
      "Self.P1" => isset($_POST['Self.P1']) ? $_POST['Self.P1'] : null,
      "Self.P2" => isset($_POST['Self.P2']) ? $_POST['Self.P2'] : null,
      "Self.P3" => isset($_POST['Self.P3']) ? $_POST['Self.P3'] : null,
      "Self.P4" => isset($_POST['Self.P4']) ? $_POST['Self.P4'] : null,
      .....
      "Self.P18" => isset($_POST['Self.P18']) ? $_POST['Self.P18'] : null,
      "Self.P19" => isset($_POST['Self.P19']) ? $_POST['Self.P19'] : null,
      "Self.P20" => isset($_POST['Self.P20']) ? $_POST['Self.P20'] : null,
      "Self.P21" => isset($_POST['Self.P21']) ? $_POST['Self.P21'] : null,
      ///
    // A_settings
       "self.A_settings" => [
           "w1" => $_POST['w1'],
           "w2" => $_POST['w2'],
       ],
      // B_settings
       "self.B_settings_2" => [
           "w3" => $_POST['w3'],
           "w4" => $_POST['w4'],
       ],

sieht die json-Datei nach dem Absenden für die ersten einfachen Parameter plötzlich so aus:

{
   "Self.P1": null,
   "Self.P2": null,
   "Self.P3": null,
   .....
    "Self.P21": null,

Nur die verschachtelten Parameter, die danach kommen:

"self.A_settings": {
       "w1": "Antwort1",
       "w2": "Antwort2"
   },
   "self.B_settings_2": {
       "w3": "Antwort3",
       "w4": "Antwort4"
   },

werden nach wie vor korrekt in die Datei geschrieben! 

Weiß einer oder hat eine Theorie wieso das eine problemlos funktioniert und bei der anderen Variante plötzlich systematisch alle einfachen Parameter (also Self.P1-21) den Wert "null" zurückgeben? 

Internet, Webseite, Formular, Code, PHP, Programmiersprache, Webentwicklung, Parameter

Snake Game HTML Score?

Ich will in meinem Snake Game: (Hier der Code)

Einen Score einbauen (ein Food = + ein Score) Kann mir jemand helfen?

//board
var blockSize = 25;
var rows = 20;
var cols = 20;
var board;
var context; 

//snake head
var snakeX = blockSize * 5;
var snakeY = blockSize * 5;

var velocityX = 0;
var velocityY = 0;

var snakeBody = [];

//food
var foodX;
var foodY;

var gameOver = false;

window.onload = function() {
    board = document.getElementById("board");
    board.height = rows * blockSize;
    board.width = cols * blockSize;
    context = board.getContext("2d"); //used for drawing on the board

    placeFood();
    document.addEventListener("keyup", changeDirection);
    // update();
    setInterval(update, 1000/10); //100 milliseconds
}

function update() {
    if (gameOver) {
        return;
    }

    context.fillStyle="black";
    context.fillRect(0, 0, board.width, board.height);

    context.fillStyle="red";
    context.fillRect(foodX, foodY, blockSize, blockSize);

    if (snakeX == foodX && snakeY == foodY) {
        snakeBody.push([foodX, foodY]);
        placeFood();
    }

    for (let i = snakeBody.length-1; i > 0; i--) {
        snakeBody[i] = snakeBody[i-1];
    }
    if (snakeBody.length) {
        snakeBody[0] = [snakeX, snakeY];
    }

    context.fillStyle="lime";
    snakeX += velocityX * blockSize;
    snakeY += velocityY * blockSize;
    context.fillRect(snakeX, snakeY, blockSize, blockSize);
    for (let i = 0; i < snakeBody.length; i++) {
        context.fillRect(snakeBody[i][0], snakeBody[i][1], blockSize, blockSize);
    }

    //game over conditions
    if (snakeX < 0 || snakeX > cols*blockSize || snakeY < 0 || snakeY > rows*blockSize) {
        gameOver = true;
        alert("Game Over");
    }

    for (let i = 0; i < snakeBody.length; i++) {
        if (snakeX == snakeBody[i][0] && snakeY == snakeBody[i][1]) {
            gameOver = true;
            alert("Game Over");
        }
    }
}

function changeDirection(e) {
    if (e.code == "ArrowUp" && velocityY != 1) {
        velocityX = 0;
        velocityY = -1;
    }
    else if (e.code == "ArrowDown" && velocityY != -1) {
        velocityX = 0;
        velocityY = 1;
    }
    else if (e.code == "ArrowLeft" && velocityX != 1) {
        velocityX = -1;
        velocityY = 0;
    }
    else if (e.code == "ArrowRight" && velocityX != -1) {
        velocityX = 1;
        velocityY = 0;
    }
}


function placeFood() {
    //(0-1) * cols -> (0-19.9999) -> (0-19) * 25
    foodX = Math.floor(Math.random() * cols) * blockSize;
    foodY = Math.floor(Math.random() * rows) * blockSize;
}
HTML, Webseite, CSS, JavaScript, Code, Programmiersprache, Webentwicklung

JavaScript: Wie kann ich eine große Tabelle schneller sortieren?

Hallo zusammen,

ich habe eine große Tabelle in meiner ASP.NET Core Razor Pages Anwendung, die ich clientseitig mit JavaScript sortieren möchte.

Allerdings dauert die Sortierung bei einer großen Datenmenge zu lange, und ich suche nach einer performanten Lösung.

Meine aktuelle Implementierung:

Ich nutze Array.sort() und vergleiche Strings und Zahlen entsprechend, das funktioniert aber das ist nicht effizient genug.

Besonders wenn die Tabelle viele Zeilen (z. B. >10.000) hat, wird die Sortierung langsam.

Meine Anforderungen:

✅ Die Sortierung muss komplett in JavaScript (clientseitig) erfolgen

✅ Sie muss sowohl Texte (Strings mit Umlaute, Sonderzeichen, etc.) als auch Zahlen (inkl. Währungen mit €) schnell sortieren

✅ Die Tabelle wird nachträglich dynamisch mit Daten befüllt (also keine initiale Sortierung im Backend möglich)

✅ Die Lösung soll sehr schnell auch bei großen Datenmengen sein

Ich habe bereits probiert:

❌ Array.sort() (wird langsam bei vielen Zeilen)

❌ localeCompare() (korrekt für Strings, aber langsam)

❌ TypedArrays für Zahlenwerte (bringt nicht genug Speed)

Gibt es eine bessere Möglichkeit, eine HTML-Tabelle performant zu sortieren?

Vielleicht mit Web Worker, einer anderen Datenstruktur oder anderen Algorithmen?

oder gibt es andere Funktionen/Möglichkeiten, die ich noch probieren kann?

hier mein aktueller Ansatz:

Tabelle:

    <div class="col-lg-9 col-md-7 col-12">
      <div class="table-container">
        <table class="table-modern table-hover w-100" id="statistikTable">
          <thead>
            <tr>
              <th onclick="sortTable(0, this)">Datum <img class="sort-icon" src="/img/dgvsort.png" style="display: none;"></th>
              <th onclick="sortTable(1, this)">PID <img class="sort-icon" src="/img/dgvsort.png" style="display: none;"></th>
              <th onclick="sortTable(2, this)">Nachname <img class="sort-icon" src="/img/dgvsort.png" style="display: none;"></th>
              <th onclick="sortTable(3, this)">Vorname <img class="sort-icon" src="/img/dgvsort.png" style="display: none;"></th>
              <th onclick="sortTable(4, this)">Rechnungsnetto <img class="sort-icon" src="/img/dgvsort.png" style="display: none;"></th>
              <th onclick="sortTable(5, this)">Belegnummer <img class="sort-icon" src="/img/dgvsort.png" style="display: none;"></th>
            </tr>
          </thead>
          <tbody>
            @if (Model.StatistikData != null && Model.StatistikData.Rows.Count > 0)
            {
              foreach (DataRow row in Model.StatistikData.Rows)
              {
                <tr>
                  <td>@(((DateTime)row["Datum"]).ToString("dd.MM.yyyy"))</td>
                  <td>@row["PID"]</td>
                  <td>@row["KundeNachname"]</td>
                  <td>@row["KundeVorname"]</td>
                  <td>@Convert.ToDecimal(row["Rechnungsnetto"]).ToString("N2")</td>
                  <td>@row["Belegnummer"]</td>
                </tr>
              }
            }
            else
            {
              <tr>
                <td colspan="6" class="text-center">Keine Daten gefunden</td>
              </tr>
            }
          </tbody>
        </table>
      </div>
    </div>

meine sort Funktion:

  function sortTable(columnIndex, header) {
    const table = document.getElementById("statistikTable");
    const tbody = table.tBodies[0];
    const rows = Array.from(tbody.rows);
    const ascending = table.dataset.sortOrder !== "asc";

    const isNumericColumn = !isNaN(parseFloat(rows[0].cells[columnIndex].textContent.replace("€", "").replace(",", ".").trim()));

    let sortedRows;
    if (isNumericColumn) {
      sortedRows = rows
        .map(row => ({
          element: row,
          value: parseFloat(row.cells[columnIndex].textContent.replace("€", "").replace(",", ".").trim()) || 0
        }))
        .sort((a, b) => ascending ? a.value - b.value : b.value - a.value);
    } else {
      const collator = new Intl.Collator("de", { numeric: true, sensitivity: "base" });
      sortedRows = rows
        .map(row => ({
          element: row,
          value: row.cells[columnIndex].textContent.trim()
        }))
        .sort((a, b) => ascending ? collator.compare(a.value, b.value) : collator.compare(b.value, a.value));
    }

    const fragment = document.createDocumentFragment();
    sortedRows.forEach(({ element }) => fragment.appendChild(element));
    tbody.appendChild(fragment);

    table.dataset.sortOrder = ascending ? "asc" : "desc";

    updateSortIcons(header, ascending);
  }

  function updateSortIcons(header, ascending) {
    document.querySelectorAll(".sort-icon").forEach(icon => {
      icon.src = "/img/dgvsort.png";
      icon.style.display = "inline";
    });

    const icon = header.querySelector(".sort-icon");
    if (icon) {
      icon.src = ascending ? "/img/dgvsortup.png" : "/img/dgvsortdown.png";
      icon.style.display = "inline";
    }
  }

Freue mich über jede Hilfe! 😊

HTML, Webseite, programmieren, CSS, JavaScript, HTML5, Programmiersprache, Webdesign, Webentwicklung, Frontend

Meistgelesene Beiträge zum Thema Webseite