Why is the name variable empty when it is sent to my postgres database?

I am trying to Post data in my postgres database using javascript and express. I think that the “app.use(express.json());” line in my code is the one giving me problem, but I’m new to javascript and I’m not comfortable yet with middleware.

This is the error I receive in my terminal after making the POST request with postman (it might be slightly different because i translated it from french)

error: a NULL value violates the constraint NOT NULL in the column « name » in the table « players » 

This is the value of the fields i try to insert in my table:

(4, null, null, null)

This is my code

import express from 'express';
import pkg from 'pg';

const { Pool } = pkg;
const db = new Pool({
    user: "postgres",
    host: "localhost",
    database: "postgres", 
    password: "123456", 
    port: 5433
});

const app = express();
const port = process.env.PORT || 3000;

app.use(express.json());

app.get('/', (req, res) => {
    res.send('Hello World!');
  });

app.post('/players', async (req, res) => {
    console.log(req.body);
    const {
        name,
        email,
        password,
        } = req.body;
    try{
        const client = await db.connect();
        const result = await client.query(
            'INSERT INTO players (name,email,password) VALUES ($1, $2, $3) RETURNING *', 
            [name,email,password]);
            res.status(201).json(result.rows[0]);
            client.release();
        } catch(err){
            console.error(err);
            res.status(500).send('Error creating user');
        }
    });

app.listen(port, () => {
    console.log(`Server listening on port ${port}`)
});

I was expecting the value to be the same as the body of my POST request :

{
    "name": "Zelda",
    "email": "[email protected]",
    "password": "zelda123",
}

The server is working because if I make the get request, I get back “Hello world”

Grid.js – Data imported from HTML Table Source breaks Sort

I’m working on adding progressive enhancement to my htmx powered site with grid.js for smarter tables with client side sorting. I already have links in these tables. However when you try to sort a column that has html in it it does nothing.

How do I fix it so my columns containing html are sortable? I’d rather not build a data fetcher service for what I’m doing here.

I’ve tried looking at the search documentation but there is little mention of the import from an html table options.

<table class="dc-dt">
    <thead>
        <tr>
            <th>Member Type</th>
            <th>Congress Member</th>
            <th>Party</th>
            <th>State</th>
            <th>Document Filer</th>
            <th>Destination</th>
            <th>Departure Date</th>
            <th>Return Date</th>
            <th>Sponsor</th>
        </tr>
    </thead>
    <tbody>
        <tr class="table-row-striped">
            <td class="px-4 py-2">
                <span class="badge bg-gray-500">Representative</span>
            </td>
            <td>
                <a href="/congress-member/J000304">Ronny Jackson</a>
            </td>
            <td>R</td>
            <td>TX</td>
            <td>
                Bryan Brody
            </td>
            <td>
                <a href="/travel-by-destination/New York, NY">New York, NY</a>
            </td>
            <td>Jul 25, 2024</td>
            <td>Jul 26, 2024</td>
            <td>United Nations Foundation</td>
        </tr>
        <tr class="table-row-striped">
            <td class="px-4 py-2">
                <span class="badge bg-gray-500">Representative</span>
            </td>
            <td>
                <a href="/congress-member/B001298">Don Bacon</a>
            </td>
            <td>R</td>
            <td>NE</td>
            <td>
                Matthew Duglin
            </td>
            <td>
                <a href="/travel-by-destination/Israel">Israel</a>
            </td>
            <td>Jul 13, 2024</td>
            <td>Jul 21, 2024</td>
            <td>American Israel Education Foundation</td>
        </tr>
    </tbody>
</table>

<script type="module">
    import {
        Grid,
        html
    } from "https://unpkg.com/gridjs?module";


    (function() {
        let x = document.getElementsByClassName('dc-dt');
        let tbl = new Grid({
            from: x[0],
            sort: true,
            search: true
        })

        tbl.render(document.getElementById('grid'));

        console.log(tbl);
    })();
</script>

Web Speech API and WebView compatibility

I have a website that uses the SpeechSynthesis from the Web Speech API. Now, I need to migrate this site to Android, but the Android WebView doesn’t support SpeechSynthesis, while Chrome on Android does.

  1. Is there any way to use the Chrome Android engine in WebView?

  2. I would like to know if there is any community-made alternative WebView that supports the Web Speech API?

  3. Is there any free API similar to the Web Speech API that is compatible with WebView?

Thanks in advance for your help!

I tried Android-AdvancedWebView without success.

Rails 6 to 7 upgrade javascript not loading

I am trying to upgrade a project from Rails 6 to Rails 7.

Gemfile

ruby '3.1.2'
gem 'rails',           '7.0.4'
gem "sassc-rails",     '2.1.2'
gem "sprockets-rails", "3.4.2"
gem "importmap-rails", "1.1.0"
gem "turbo-rails",     "1.1.1"
gem "stimulus-rails",  "1.0.4"
gem "jbuilder",        "2.11.5"
gem "puma",            "5.6.4"
gem "bootsnap",        "1.12.0", require: false
gem 'sass-rails',      '6.0.0'

app/assets/config/manifest.js

// link_directory ../javascripts .js
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js

config/importmap.rb

pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
pin_all_from "app/javascript/custom",      under: "custom"

app/javascript/application.js

import "@hotwired/turbo-rails"
import "controllers"
import "custom/menu"
alert('hello');

I have moved all my javascript files from app/assets/javascripts/ to app/javascript/ (all except the old application.js which remains in assets).

The javascript in app/javascript/application.js should be loaded, which means an alert box with “hello” in should appear, but it does not. Where am I going wrong?

Global Variable is not being accesses in a particular block

I created a boolean variable at the top of my js code, It worked perfectly throughout the code and changes globally when its value changes in all Functions/Block where it is used. But in a particular block, I had to declare and initialize it again before it could be accessed in that block.It was a “document.addEventListener” block

I’m working on a responsive design so I created different event listeners for different width sizes.

It happened like this:

let isVisible = false
let query = window.matchMedia("(max-width: 600px)");

document.addEventListener("DOMContentLoaded", () => {
  if (query.matches) {
    button.addEventListener("click", () => {
      if (!isVisible) {
        searchBar.style.display = "block";
        isVisible = true;
      } else if (isVisible && searchBar.value) {
        get_movie(searchBar.value);
      } else {
        searchBar.style.display = "none";
        isVisible = false;
      }
    });
  }
});

The button.addEventListener doesn’t run at all because the isVisible conditions are yet to be met which is because the global variable is not being accessed.

It only starts running when I declare isVisible again inside that document.addEventListener block.

Coldfusion not redirecting after login

I have a simple coldfusion app that uses Google Single Sign On. When a user logs in, they should be redirected to the index.cfm page. And their session tokens should be set. However, they keep being redirected back to the login page. I’ve been troubleshooting this for a while and I’m stuck. I’ve tried modifying onRequestStart and I can only get a too many redirects error. I just want to get users to the main page after signing in. I must be missing something.

Application.cfc:

<cfcomponent>
    <cfset this.name = "myApp">
    <cfset this.sessionManagement = true>
    <cfset session.email=''>
    <cfset session.loggedIn = false>
            
   <cffunction name="onRequestStart" returntype="void">
    <cfargument name="targetPage" type="string" required="false">
    
    <cfif session.loggedIn EQ "false" AND targetPage NEQ "login.cfm">
        <cflocation url="login.cfm" addtoken="false">
    </cfif>
        
</cffunction>        
</cfcomponent>

login.cfm:

<script>
        
        function decodeJwtResponseFromGoogleAPI(token) {
            var base64Url = token.split('.')[1]
            var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
            var jsonPayload = 
           decodeURIComponent(atob(base64).split('').map(function (c) {
                return '%' + ('00' + 
           c.charCodeAt(0).toString(16)).slice(-2);
            }).join(''));
            return JSON.parse(jsonPayload)
        }
    
        function handleCredentialResponse(response) {
            responsePayload = decodeJwtResponseFromGoogleAPI(response.credential);

            email = responsePayload.email;
            
            $.ajax({
                url: 'setSession.cfm',
                type: 'POST',
                data: { email: email },
            });
                window.location.href="index.cfm";
        };
       
            window.onload = function () {
                    google.accounts.id.initialize({
                        client_id: CLIENT_ID,
                        callback: handleCredentialResponse
                    });
                    google.accounts.id.renderButton(
                        document.getElementById('g_id_signin'),
                        { theme: 'outline', size: 'large' }
                    );
                    google.accounts.id.prompt();   
        };
       
    </script>

setSession.cfm:

<cfif structKeyExists(form, "email")>
        <cfset email = form.email>
        <cfset session.loggedIn = true>
        <cfset session.email = email>
</cfif>

toggle visibility of 2 divs with 2 buttons independently

I create two divs (audiodescription-text and options-wrapper). I want to toggle their visibility independently. In other words, the visibility of one div doesn’t affect another one’s visibility. That’s why I created 2 buttons, one for each div.

However, with the following code, when you click in any button, the same div is hidden or shown.

What am I doing wrong? Can someone fix the code for me?

/* Inserir aqui script para exibir ou ocultar o menu de seleção de cores */
var div = document.getElementById('audiodescription-text');
var display = 1;

function showHidenButtonAudiodescription() {
  if (display == 0) {
    div.style.display = 'none';
    display = 1;
    document.querySelector("button_audiodescription").innerHTML = "Exibir audiodescrição";
  } else {
    div.style.display = 'inherit';
    display = 0;
    document.querySelector("button_audiodescription").innerHTML = "Ocultar audiodescrição";
  }
}

/* Inserir aqui script para exibir ou ocultar o menu de seleção de cores */
var div = document.getElementById('options-wrapper');
var display = 1;

function showHidenButtonModel() {
  if (display == 0) {
    div.style.display = 'none';
    display = 1;
    document.querySelector("button_model").innerHTML = "Exibir audiodescrição";
  } else {
    div.style.display = 'inherit';
    display = 0;
    document.querySelector("button_model").innerHTML = "Ocultar audiodescrição";
  }
}
var config = { /* Insira aqui a URL do modelo tridimensional hospedado no Sketchfab que será carregado. Insira aqui os materiais, os nomes e as cores de cada estrutura. Basicamente, este é o trecho do código que deve ser alterado para se adaptar a cada modelo tridimensional */

  "model": "066fa44695014754ad13f0e69ddda1c3",
  "params": {
    "camera": 0,
    "autoplay": 0,
    "preload": 1,
    "ui_controls": 0,
    "ui_infos": 0,
    "ui_watermark": 0
  },
  "config": [{
      "name": "01. Parede Celular",
      "type": "color",
      "material": "Parede",
      "default": "#b27e00",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688313518707
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688313518707
        },
        {
          "name": "Branco",
          "color": "#ffffff",
          "id": 1688313518707
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688313518707
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688313518707
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688313518707
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688313518707
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688313518707
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688313518707
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688313518707
        }
      ]
    },
    {
      "name": "02. Cílios",
      "type": "color",
      "material": "Cilios",
      "default": "#a9821b",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688313690276
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688313690276
        },
        {
          "name": "Branco",
          "color": "#ffffff",
          "id": 1688313690276
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688313690276
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688313690276
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688313690276
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688313690276
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688313690276
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688313690276
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688313690276
        }
      ]
    },
    {
      "name": "03. Membrana Plasmática",
      "type": "color",
      "material": "Membrana",
      "default": "#e7710c",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688313830703
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688313830703
        },
        {
          "name": "Branco",
          "color": "#ffffff",
          "id": 1688313830703
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688313830703
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688313830703
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688313830703
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688313830703
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688313830703
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688313830703
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688313830703
        }
      ]
    },
    {
      "name": "04.Citoplasma",
      "type": "color",
      "material": "Citoplasma",
      "default": "#e7e7e7",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688313956926
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688313956926
        },
        {
          "name": "Branco",
          "color": "#ffffff",
          "id": 1688313956926
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688313956926
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688313956926
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688313956926
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688313956926
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688313956926
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688313956926
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688313956926
        }
      ]
    },
    {
      "name": "05. Ribossomos",
      "type": "color",
      "material": "Ribossomos",
      "default": "#e300e7",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688314141902
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688314141902
        },
        {
          "name": "Branco",
          "color": "#FFFFFF",
          "id": 1688314141902
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688314141902
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688314141902
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688314141902
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688314141902
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688314141902
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688314141902
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688314141902
        }
      ]
    },
    {
      "name": "06. Material Genético",
      "type": "color",
      "material": "Material Genetico",
      "default": "#00c8e7",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688314249006
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688314249006
        },
        {
          "name": "Branco",
          "color": "#FFFFFF",
          "id": 1688314249006
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688314249006
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688314249006
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688314249006
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688314249006
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688314249006
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688314249006
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688314249006
        }
      ]
    },
    {
      "name": "07. Plasmídio",
      "type": "color",
      "material": "Plasmidio",
      "default": "#0011e7",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688314352195
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688314352195
        },
        {
          "name": "Branco",
          "color": "#FFFFFF",
          "id": 1688314352195
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688314352195
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688314352195
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688314352195
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688314352195
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688314352195
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688314352195
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688314352195
        }
      ]
    },
    {
      "name": "08. Flagelo",
      "type": "color",
      "material": "Flagelo",
      "default": "#834520",
      "options": [{
          "name": "Preto",
          "color": "#000000",
          "id": 1688314449619
        },
        {
          "name": "Cinza",
          "color": "#b3b3b3",
          "id": 1688314449619
        },
        {
          "name": "Branco",
          "color": "#FFFFFF",
          "id": 1688314449619
        },
        {
          "name": "Vermelho",
          "color": "#db2828",
          "id": 1688314449619
        },
        {
          "name": "Laranja",
          "color": "#f2711c",
          "id": 1688314449619
        },
        {
          "name": "Amarelo",
          "color": "#fbbd08",
          "id": 1688314449619
        },
        {
          "name": "Verde",
          "color": "#21ba45",
          "id": 1688314449619
        },
        {
          "name": "Azul",
          "color": "#2185d0",
          "id": 1688314449619
        },
        {
          "name": "Roxo",
          "color": "#a333c8",
          "id": 1688314449619
        },
        {
          "name": "Rosa",
          "color": "#e03997",
          "id": 1688314449619 /* Aqui termina o conteúdo personalizado de cada modelo tridimensional */
        }
      ]
    }
  ].map((e) => {
    return {
      ...e,
      options: e.options.map((f) => ({
        color: f.color,
        id: f.id,
      })),
    };
  })
};
var iframeEl = document.getElementById('api-frame');
var optionsEl = document.querySelector('.options');
var configurator = new SketchfabConfigurator.Configurator(iframeEl, optionsEl, config);
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: 'Quicksand', sans-serif;
  /* Altere aqui a fonte e o tamanho da fonte */
  box-sizing: border-box;
  font-size: 12px;
}

#audiodescription-instructions {
  width: 100%;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding-top: 10px;
}

button_audiodescription {
  /* Altere aqui as configurações visuais do botão em estado normal*/
  padding: 6px 24px;
  text-align: center;
  font-family: 'Quicksand', sans-serif;
  color: #0d6efd;
  font-size: 14px;
  border: solid;
  border-width: 1px;
  border-color: #0d6efd;
  border-radius: 8px;
  cursor: pointer;
}

button_audiodescription:hover {
  /* Altere aqui as configurações visuais do botão em estado normal*/
  color: white;
  background-color: #0d6efd;
}

#audiodescription-text {
  /* Criar aqui uma classe para conter a interface de seleção de cores */
  margin: 20px;
  padding-left: 15px;
  padding-right: 15px;
  padding-bottom: 15px;
  border-width: 1px;
  border-style: solid;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
  letter-spacing: 0.12px;
  border-width: 1px;
  border-style: solid;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
}

.sketchfab-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 900px;
  overflow: hidden;
  /* Oculte aqui a barra de rolagem */
}

iframe {
  width: 100%;
  height: 70%;
  margin-bottom: 0px;
  /* Oculte aqui a borda */
  border: none;
}

#model-instructions {
  /* Criar aqui uma classe para exibir texto com instrução de seleção de cores. Este será o elemento-pai */
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding-top: 10px;
}

button_model {
  /* Altere aqui as configurações visuais do botão em estado normal*/
  padding: 6px 24px;
  text-align: center;
  font-family: 'Quicksand', sans-serif;
  color: #0d6efd;
  font-size: 14px;
  border: solid;
  border-width: 1px;
  border-color: #0d6efd;
  border-radius: 8px;
  cursor: pointer;
}

button_model:hover {
  /* Altere aqui as configurações visuais do botão em estado normal*/
  color: white;
  background-color: #0d6efd;
}

#options-wrapper {
  /* Criar aqui uma classe para conter a interface de seleção de cores */
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin: 20px
}

.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 0 50px;
}

.option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Altere aqui o espaçamento entre o nome da estrutura e os quadrados de cores. O espaçamento original é 8px */
  padding: 12px 0;
  /* Altere aqui o espaçamento geral entre as linhas. O espaçamento original é 16px */
}

.color {
  display: flex;
  align-items: center;
  padding: 1px 0;
  /* Altere aqui o espaçamento entre as linhas no menu de seleção de cores. O espaçamento original é 4px */
}

.color input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option__control {
  display: flex;
  /* Altere aqui o espaçamento horizontal entre os quadrados de cores. O espaçamento original é 8px */
  gap: 3px;
}

.color__swatch {
  display: inline-block;
  width: 24px;
  height: 24px;
  /* Altere aqui a curvatura da borda do quadrado de cores. A curvatura orginal é 8px */
  border-radius: 4px;
  /* Altere aqui o tamanho do quadrado de cores. O tamanho original é 25px */
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  margin-right: 4px;
}

.color input:checked+.color__swatch {
  /* Altere aqui a borda da cor atualmente atribuída a determinada estrutura. A cor original é #000 */
  box-shadow: 0 0 0 2px #fff;
}

.color:hover .color__swatch {
  box-shadow: 0 0 0 2px #999;
}

.texture {
  display: block;
  position: relative;
  margin-bottom: 10px;
}

.texture input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.texture__preview {
  display: block;
}

.texture__preview img {
  display: block;
  max-width: 100%;
  height: auto;
}

.texture input:checked+.texture__preview>img {
  box-shadow: 0 0 0 2px #000;
}

.texture__name {
  display: block;
  margin-top: 4px;
}


/* Aqui termina o conteúdo do arquvo styles.css */
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sketchfab Configurator</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Insira aqui a fonte não suportada pelo css -->
<link rel="stylesheet" href="./styles.css">
<script type="text/javascript" src="./assets/js/sketchfab-viewer-1.3.2.js"></script>
<script type="text/javascript" src="./assets/js/SketchfabConfigurator-1.0.6.js">
</script>

<body>
  <div id="audiodescription-instructions">
    <button_audiodescription id="button_audiodescription" onclick="showHidenButtonAudiodescription()">Exibir audiodescrição</button_audiodescription>
    <div style="display:none" ; id="audiodescription-text">
      <p>
        [AUDIODESCRIÇÃO: representação tridimensional colorida de uma célula eucariótica seccionada, ou seja, cortada ao meio para mostrar as principais estruturas constituintes.<br><br> Para facilitar a compreensão e considerando a posição inicial em
        que o modelo tridimensional é carregado, a apresentação e a descrição das estruturas são feitas da esquerda para a direita e de fora para dentro, ou seja, as mais externas primeiro e em seguida as mais internas. Inicialmente são descritas as estruturas
        em primeiro plano, para depois serem descritas as estruturas em planos mais ao fundo.<br><br> A célula eucariótica apresenta formato irregular, mais próximo do arredondado, sendo delimitada pela membrana plasmática com superfície é lisa. Internamente,
        apresenta citoplasma e organelas.<br><br> Em uma célula real as organelas não possuem posição fixa, podendo variar de localização. Neste modelo tridimensional, em primeiro plano e à esquerda, encontram-se lisossomos, pequenas organelas de formato
        arredondado. Mais à direita está o Complexo de Golgi formado por sacos achatados e empilhados, interconectados por vesículas. Um pouco mais atrás, e à esquerda do lisossomo, encontra-se um endossomo, com formato arredondado similar aos lisossomos,
        porém de maior diâmetro. Segue-se o retículo endoplasmático rugoso, rede de cisternas e túbulos interconectados que possuem ribossomos aderidos à sua face externa, os quais estão representados como pequenos grânulos arredondados. À direita do
        retículo endoplasmático rugoso, está uma mitocôndria, de formato alongado e cilíndrico e com cristas mitocondriais de formato ondulado em seu interior. Logo atrás está um proteassomo, estrutura pequena, de formato cilíndrico, cujas extremidades
        apresentam projeções. Do lado direito do proteassomo está o retículo endoplasmático liso, formado por tubos alongados interconectados. Do lado direito do retículo endoplasmático liso está o núcleo, grande esfera com superfície lisa, dotada de
        poros circulares. O núcleo está seccionado de forma a mostrar, em sua região central, o nucléolo de formato também esférico. Finalmente, ao fundo, no extremo esquerdo, encontram-se dois centríolos de formato cilíndrico e dispostos perpendicularmente
        um ao outro, e no extremo direito, dois peroxissomos, organelas de formato circular semelhante ao endossomo e ao lisossomo.<br><br> FIM DA AUDIODESCRIÇÃO.]</p>
    </div>
  </div>

  <div class="sketchfab-container">
    <iframe src="" id="api-frame" allow="autoplay; fullscreen; xr-spatial-tracking" xr-spatial-tracking execution-while-out-of-viewport execution-while-not-rendered web-share allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" height="1000"
      width="100%"></iframe>

    <div id="model-instructions">
      <!-- Inserir aqui a classe e o texto com as instruções de seleção de cores -->
      <p>Selecione a cor desejada para cada estrutura:</p>
    </div>
    <!-- Inserir aqui o texto com as instruções -->
    <button_model id="button_model" onclick="showHidenButtonModel()">Exibir opções de cores</button_model>
    <!-- Inserir aqui botão para exibir ou ocultar o menu de seleção de cores -->
    <div style="display:none" ; id="options-wrapper">
      <!-- Altere aqui o estado inicial de exibição do menu de seleção de cores. display:none ocultará o elemento. display:inherit exibirá o elemento com os padrões de seu elemento-pai -->
      <div class="options" id="color-picker"></div>
    </div>
  </div>
</body>

Button for Woocommerce

I need help. I have a store on WooCommerce, I wrote a button, but it’s not working
Hi, I need help. I have a store on WooCommerce, I wrote a button, but it’s not working
Hi, I need help. I have a store on WooCommerce, I wrote a button, but it’s not working
Hi, I need help. I have a store on WooCommerce, I wrote a button, but it’s not working
Hi, I need help. I have a store on WooCommerce, I wrote a button, but it’s not working
Hi, I need help. I have a store on WooCommerce, I wrote a button, but it’s not working

<?php
/*
Plugin Name: WooCommerce Custom Sorting v1.3
Description: Adds a single sort button with a dropdown menu to sort products by price and name on the WooCommerce store page.
Version: 1.3
Author: blvckfamily
*/

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}


function add_custom_sorting_dropdown() {
    if ( is_shop() || is_product_category() ) { 
        echo '
        <div class="custom-sorting-dropdown">
            <button id="sortDropdownButton">Sorting <span>&#9662;</span></button>
            <div id="sortOptions" class="dropdown-content">
                <a href="#" data-sort="price">Price</a>
                <a href="#" data-sort="name">Name</a>
            </div>
        </div>';
    }
}
add_action( 'woocommerce_before_shop_loop', 'add_custom_sorting_dropdown', 10 );


function custom_sorting_dropdown_styles() {
    echo '
    <style>
    .custom-sorting-dropdown {
        position: relative;
        display: inline-block;
        margin-bottom: 20px;
    }
    
    #sortDropdownButton {
        background-color: #0071a1;
        color: white;
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        cursor: pointer;
    }
    
    #sortDropdownButton:hover {
        background-color: #005a87;
    }

    .dropdown-content {
        display: none;
        position: absolute;
        background-color: #f9f9f9;
        min-width: 160px;
        box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
        z-index: 1;
    }
    
    .dropdown-content a {
        color: black;
        padding: 12px 16px;
        text-decoration: none;
        display: block;
    }
    
    .dropdown-content a:hover {
        background-color: #f1f1f1;
    }
    
    .custom-sorting-dropdown:hover .dropdown-content {
        display: block;
    }
    </style>';
}
add_action( 'wp_head', 'custom_sorting_dropdown_styles' );


function custom_sorting_dropdown_scripts() {
    ?>
    <script>
    document.addEventListener("DOMContentLoaded", function() {
        const sortDropdownButton = document.getElementById("sortDropdownButton");
        const dropdownContent = document.getElementById("sortOptions");

        if (!sortDropdownButton || !dropdownContent) {
            console.error("Dropdown button or content not found.");
            return;
        }

        document.querySelectorAll(".dropdown-content a").forEach(function(item) {
            item.addEventListener("click", function(event) {
                event.preventDefault();
                event.stopPropagation(); 

                let sortType = this.getAttribute("data-sort");

                if (!sortType) {
                    console.error("Sort type not found.");
                    return;
                }

                let sortOrder = "asc"; 

                let products = document.querySelectorAll('.woocommerce ul.products li.product');

                if (!products.length) {
                    console.error("No products found.");
                    return;
                }

                let productsArray = Array.prototype.slice.call(products, 0);

                if (sortType === "price") {
                    productsArray.sort(function(a, b) {
                        let priceAElement = a.querySelector('.woocommerce-Price-amount');
                        let priceBElement = b.querySelector('.woocommerce-Price-amount');

                        if (!priceAElement || !priceBElement) {
                            console.error("Price element not found in one of the products.");
                            return 0;
                        }

                        let priceA = parseFloat(priceAElement.innerText.replace(/[^0-9.-]+/g,""));
                        let priceB = parseFloat(priceBElement.innerText.replace(/[^0-9.-]+/g,""));
                        return sortOrder === "asc" ? priceA - priceB : priceB - priceA;
                    });
                } else if (sortType === "name") {
                    productsArray.sort(function(a, b) {
                        let nameAElement = a.querySelector('.woocommerce-loop-product__title');
                        let nameBElement = b.querySelector('.woocommerce-loop-product__title');

                        if (!nameAElement || !nameBElement) {
                            console.error("Product title element not found in one of the products.");
                            return 0;
                        }

                        let nameA = nameAElement.innerText.toLowerCase();
                        let nameB = nameBElement.innerText.toLowerCase();
                        if (nameA < nameB) return sortOrder === "asc" ? -1 : 1;
                        if (nameA > nameB) return sortOrder === "asc" ? 1 : -1;
                        return 0;
                    });
                }

                let parent = document.querySelector('.woocommerce ul.products');
                if (!parent) {
                    console.error("Products container not found.");
                    return;
                }

                
                parent.innerHTML = "";

                
                productsArray.forEach(function(product) {
                    parent.appendChild(product);
                });
            });
        });
    });
    </script>
    <?php
}

    
add_action( 'wp_footer', 'custom_sorting_dropdown_scripts' );

I just need help, actually.

how do I fetch a list of locations by zipcode

I have never worked in frontend so really a newbie to webdesign and javascript
Here is the problem I am trying to solve:
I want to design a webpage where the user inputs a zipcode and based on that the webpage fetches a list of locations. Similar to google maps functionality like “restaurants near 12345” or “gas stations near me”. I am using square space for the website, but I do know a bit of html and css. Also fluent in backend programming. Which frontend technologies should I look into?

Have just tried googling info.. looked up charity navigator, etc but nothing useful

Update css variable globally without javascript [duplicate]

I have the following styles:

html {
  --header-height: 80px;
  --announcement-bar-height: 40px;

  scroll-padding-top: calc(
    var(--header-height) + var(--announcement-bar-height) + 5px
  );

  body[data-scrolled] {
    --announcement-bar-height: 0px;
  }
}

The problem is that when I scroll the page and hence data-scrolled attribute is added to body, the --announcement-bar-height is not updated to 0px in scroll-padding-top in html and still 40px is used. How to fix that without javacript?

Error message on terminal when trying to create a React project

Im currently doing the Odin Project for web development (javascript path).
In the React Course, im learning to set up a project with React.
This is the page: https://www.theodinproject.com/lessons/node-path-react-new-setting-up-a-react-environment

The problem is that when i paste this command “npm create vite@latest my-first-react-app — –template react
” into the CLI, i get an error.

The error is this:
npm error Class extends value undefined is not a constructor or null
npm error A complete log of this run can be found in: C:UsersequipoAppDataLocalnpm-cache_logs2024-08-09T19_54_01_302Z-debug-0.log

Im using git Bash, and my pc cant run a virtual machine or WSL2.. so im stuck with this.

Anyone could help me? Thanks!!

PS: node and npm are up to date.

I really dont know what to do, i search on google and stack overflow posts but couldnt find the solution.. and in the Odin Porject they dont help windows users..

eventListener onload and “not defined” ID error in javascript

Problem:

the function “function1” start onload with many tasks and instead “function2” is awaiting to be load after some user event.

function2 create some elements with createElement and function1 even if has a listener inside seems to answer (as obvious) with a “not defined” error blocking everything.

is there a logic way to solve this procedural mistake/error=

Why does Discord refuse to embed my website?

My website embeds perfectly as expected everywhere I’ve tried except Discord, for some reason it refuses to embed no matter what I try and I cannot figure out why, I’ve tried:

  • remaking my tags entirely;
  • stripping my backend of all security;
  • completely rebuilding my backend; and
  • allowing Discord through every bit of security I have.

The only times it has embedded properly were when I tried hosting one of my html files on tiiny.host and on GitHub Pages, so it must be something in my backend, but the only things I could think of possibly causing it were CORS, CSP, and Helmet, but even removing all 3 of them entirely didn’t work.

How to disable the touch elements in other parts of a display in the APL templates in an Alexa Skill?

So we have created an alexa skill which plays the latest news from WPI. But in viuals part when we click anywhere on the Alexa template in the Alexa Skill, it stops speaking so can someone please help us to disable the touch interactions on other parts of the display apart from the buttons.

We tried using touchwrapper and set state but it didn’t work.

sqlite3 callback gets run only after program is complete. Why then?

Disclaimer: I’m a 40 year veteran software developer: C, Java, lots of other stuff. Trying to do simple Object Oriented program in Javascript under Node.js. The threading and global memory management is baffling me.

I’m using a sqlite tutorial:
https://www.sqlitetutorial.net/sqlite-nodejs/query/

I’m running the query for all rows.
I have inserted this code into a Node.js file. I have wrapped that simple query in a function call. The function gets called, the query is submitted and the function returns to the calling code. However at that point I have code to save the results as a json file and the data is not there. When the program completes, THEN the callback from the query runs, but it is too late because the program saved no data and completed.

What do I need to insert to get it to actually run the query and call the callback?

Here is my ‘Book.js’ file:

    const fs = require('fs')
    // const Bible = require('./Bible.js');

    class Bible {
        constructor() {
            this.books = [];
            this.xrefs = [];
        }

        AddBook(book) {
            this.books.push(book);
            console.log('Book added: ' + book.name);
        }

        AddXref(xref) {
            this.xrefs.push(xref);
            console.log('Xref added: ' + xref);
        }
    }

    let theBible = new Bible();

    class Book {
        constructor(row) {
            this.ordinal     = row.order;
            this.name        = row.title_short;
            this.title       = row.title_full;
            this.category    = row.category;
            this.nChapters   = row.chapters;
        }
    }

    Book.load = function load( theBible ) {
        const sqlite3 = require('sqlite3').verbose();

    // open the database
        let db = new sqlite3.Database('./Data/bible-sqlite.db');

        let sql = `SELECT * FROM book_info`;

        db.all(sql, [], (err, rows) => {
            if (err) {
                throw err;
            }
            rows.forEach((row) => {
                book = new Book(row);
                theBible.AddBook(book);
                console.log(`Book[${book.ordinal}] ${book.name} loaded.`)
                console.log(book);
            });
        });

    // close the database connection
        db.close();
    }

    Book.saveAll = function saveAll(theBible) {

        if ( theBible != undefined && theBible.books != undefined) {
            console.log(theBible.books);

            // convert JSON object to a string
            const jsonData = JSON.stringify(theBible.books)

            // write JSON string to a file
            fs.writeFile('books.json', jsonData, err => {
                if (err) {
                    throw err
                }
                console.log('Books JSON data is saved.')
            })

        }

    }

    console.log('ready to load');
    Book.load(theBible);
    console.log("loaded, now to save it all.")
    Book.saveAll(theBible);
    console.log('done.');

    module.exports = Book;

Only after the final 5 lines of code are run and the program is done does the callback thread run.

What am I missing?

explained in the description. I was expecting the callback to deliver the data after the call to the Book.load() function (Method) returns, but it only happens after the whole program is ‘complete’.