How to authenticate using SimpleWebAuthnBrowser?

I want to implement webauthn using PHP (specifically Yii2 Framework) along with the SimpleWebAuthnBrowser library (https://simplewebauthn.dev/docs/packages/browser)

When registering the device, here is my response for the challenge

return [
    'challenge' => $challengeBase64,
    'rp' => [
        'name' => Yii::$app->name,
        'id' => 'x-y-z.ngrok-free.app',
    ],
    'user' => [
        'id'          => $userId,
        'name'        => $displayName,
        'displayName' => $displayName,
    ],
    'pubKeyCredParams' => [
        ['type' => 'public-key', 'alg' => -7],
        ['type' => 'public-key', 'alg' => -257],
    ],
    'authenticatorSelection' => [
        'authenticatorAttachment' => 'cross-platform',
        'requireResidentKey' => false,
        'userVerification' => 'discouraged',
    ],
    'timeout' => 60000,
    'attestation' => 'direct',
    'transports' => ['usb'],
];

On the registration view:

try {
    // get challenge
    let challengeResponse = await fetch('/user/challenge');

    if (!challengeResponse.ok) {
        throw new Error('Failed to get challenge from server');
    }
    let challengeData = await challengeResponse.json();

    const attResp = await SimpleWebAuthnBrowser.startRegistration(challengeData);

    // // get credential data
    let credential_id = attResp.rawId;
    let public_key = attResp.response.publicKey;
    let sign_count = 0;
    let transports = attResp.response.transports ? attResp.response.transports : [];
    let attestation_type = attResp.type;
    .....

The registration process is running well, and the credential saved to the database.

Saved Credential

But when I need to validate / do the authentication, the library has an error

NotAllowedError: The operation either timed out or was not allowed. See: https://www.w3.org/TR/webauthn-2/#sctn-privacy-considerations-client.

Here is my code on the view and return from the challenge.

try {
    const response = await fetch('/user/another-challenge', { method: 'GET' });
    const options = await response.json();

    const assertion = await SimpleWebAuthnBrowser.startAuthentication(options); // gives an error above

And here is the response for the /user/another-challenge

return [
    'challenge' => Base64Url::encode($challenge),
    'rp' => [
        'name' => Yii::$app->name,
        'id' => 'x-y-z.ngrok-free.app',
    ],
    'user' => [
        'id' => Base64Url::encode($user->id),
        'name' => $user->username,
        'displayName' => $user->username,
    ],
    'allowCredentials' => [
        [
            'type' => 'public-key',
            'id' => Base64Url::encode($credential->credential_id),
            'transports' => ['usb'],
        ]
    ],
    'timeout' => 60000,
    'userVerification' => 'discouraged',
];

I am wondering if this has something to do with the response from the registration challenge (from the registration phase).

Any clue or guidance will be appreciated. Thank you.

How to install React, TypeScript and TailwindCSS v4 using PostCSS

I tried to configure a new project using React, TypeScript and Tailwind v4 but Tailwind isn’t applying.

Here is my installation:

npx create-react-app web
npm install --save-dev typescript @types/node @types/react @types/react-dom @types/jest
npx tsc --init
npm install --save-dev tailwindcss @tailwindcss/postcss postcss

I could use npx create-react-app web --template typescript but this way puts TypeScript in production dependencies. It is why I used my first steps.

Now, regarding Tailwind v4 doc I created postcss.config.mjs to the root, (near package.json) with this code:

export default {
  plugins: {
    "@tailwindcss/postcss": {},
  }
}

Then, in src/index.css, I removed all styles and I added only this line:

@import "tailwindcss";

Now I changed the App extension from App.js to App.tsx with this sample code:

function App() {
  return (
    <h1 className="text-3xl font-bold underline">
    Hello world!
  </h1>
  );
}

export default App;

and this this is the index.tsx:

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

reportWebVitals();

Now I run npm start but Tailwind CSS not applied.

Here is a screen:

enter image description here

Versions:

"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"tailwindcss": "^4.0.12",
"postcss": "^8.5.3",

Did I miss a step?

tab content not showing when I click a different tab (html, javascript) [closed]

here’s my javascript code, which i think is the problem here

const tabs = document.querySelector('.tabs');
const tabButtons = tabs.querySelectorAll('[role="tabs"]');
const tabPanels = tabs.querySelectorAll('[role="tabpanel"]');

tabButtons.forEach(button => button.addEventListener('click', handleTabClick));

function handleTabClick(event) {
  event.currentTarget.setAttribute('aria-selected', true);
  tabButtons.forEach(tab => {
    // tab.ariaSelected = false;
    tab.setAttribute('aria-selected', false);
  });
  event.currentTarget.setAttribute('aria-selected', true);
  //finding associate tab panel
  const {
    id
  } = event.currentTarget;
  const tabPanel = tabs.querySelector(`[aria-labelledby="${id}"]`);
  console.log(tabPanel);
  tabPanel.hidden = false;
}
<link rel="stylesheet" href="https://unpkg.com/98.css">

<div class="wrapper">
  <div class="tabs">
    <menu role="tablist">
      <li role="tabs" aria-selected="true">
        <button role="tab" id="X" aria-selected="true" >XXX</button>
      </li>
      <li role="tabs" aria-selected="false">
        <button role="tab" id="Y" aria-selected="false">YYY</button>
      </li>
    </menu>
    <div class="window" role="tabpanel" aria-labelledby="X">
      <div class="window-body" role="tabpanel" aria-labelledby="X">
        <p>Hello! This is a work in progress...</p>
      </div>
    </div>
  </div>
  <div class="window" role="tabpanel" aria-labelledby="Y" hidden>
    <div class="window-body" role="tabpanel" aria-labelledby="Y" hidden>
      <p>Hello again!</p>
    </div>
  </div>
</div>

there’s a lot of messiness and confusion in the html code because i’m using the code given to create the tab designs from the 98.css library page, which didn’t contain div role before menu, or buttons. So the tab ‘X’ and ‘Hello! This is a work in progress…’ panel shows when I load the page (everything looks correct), and buttons are clickable but if I click on ‘Y’, nothing happens.
i’m a beginner so any help is appreciated. thank you!

The gravity in my code doesn’t work in CraftyJS

i made a code where there is a player object and two floor (Floor up and Floor Down). I want the player gravity will change to (-400) if the user press up arrow button and (400) if the user press down arrow button. Here is my code, there is a bug where the player only go through the Floor up when the gravity is (-400). How do i fix the bug?

i want that the player are not going to go through the Floor up. Here is my code:

window.onload = function() {
  Crafty.init(600, 400);
  Crafty.background('lightblue');

  // Lantai atas (merah)
  Crafty.e('Floorup, 2D, DOM, Color, Solid, Collision')
    .attr({
      x: 0,
      y: 0,
      w: 600,
      h: 20
    })
    .color('red');

  // Lantai bawah (kuning)
  Crafty.e('Floor, 2D, DOM, Color, Solid, Collision')
    .attr({
      x: 0,
      y: 380,
      w: 600,
      h: 20
    })
    .color('yellow');

  // Objek pemain
  var player = Crafty.e('Player, 2D, DOM, Color, Gravity, Collision')
    .attr({
      x: 280,
      y: 200,
      w: 40,
      h: 40
    })
    .color('blue')
    .bind('KeyDown', function(e) {
      if (e.key === Crafty.keys.UP_ARROW) {
        this.gravity('Floorup');
        this.gravityConst(-400);

      }
    })
    .bind('KeyUp', function(e) {
      if (e.key === Crafty.keys.DOWN_ARROW) {
        this.gravity('Floor');
        this.gravityConst(400);
      }
    });
};
<script type="text/javascript" src="https://rawgithub.com/craftyjs/Crafty/release/dist/crafty-min.js"></script>

Im not able to find what’s wrong whatever console or debugger im using, it’s crashing ,tried chatGpt code it’s also crashing [closed]

I am working on a “Guess the Number” game in JavaScript, but my code keeps running in a loop and doesn’t seem to stop.

  • The issue: It keeps asking for input even after the correct guess.
  • Expected behavior: It should stop once the correct number is guessed.
  • Actual behavior: It continues asking for input.

This is my own buggy attempt:

let random = Math.floor(Math.random() * 100) + 1;
let i = 0;
console.log(random);

let input = Number(prompt('Enter your guess ...'));
while (input != random) {
  if (input > random) {
    console.log(`too high`);
  } else {
    console.log(`too low`);
  }
  i++;
  input = Number(prompt('Enter your guess ...'));
}
console.log(`Correct! You guessed the number in ${i} tries`);
}

Code inspired by ChatGPT:

// --------------------- This ChatGPT code is also crashing 
const guessTheNumber = function() {
  // Generates 1-100
  let random = Math.floor(Math.random() * 100) + 1; 
  let i = 0;
  console.log(`Random number: ${random}`);

  let input = Number(prompt('Enter your guess (1-100) ...'));
  console.log(`Initial user input: ${input}`);

  while (input !== random) {
    console.log(`User guessed: ${input}, Actual number: ${random}`);

    if (isNaN(input)) {
      console.log("Invalid input! Not a number.");
      input = Number(prompt('Enter a valid number: '));
      continue; // Skip this iteration if input is invalid
    }

    if (input > random) {
      console.log(`Too high`);
    } else if (input < random) {
      console.log(`Too low`);
    }
    i++;

    // Ask user for another guess
    input = Number(prompt('Try again: '));
    console.log(`New input: ${input}`);

    // If user enters nothing, break the loop
    if (input === null || input === "") {
      console.log("Game exited by the user.");
      break;
    }
  }

  console.log(`Correct! You guessed the number in ${i} tries`);
};

guessTheNumber();

Guide scaling of an image according limits of parents

Currently I’m helping someone with a page and they needed to display some images of their work. At first I set up a little structure for the display of images to fall under a flex structure.

Now, what I’m trying to do is a transition of an image that when hovered it increases in scale and shows a little footer about the image. But when doing so I find the problem that the scale takes the center position of where the image is.

Thus, the images overflow to the top/bottom/you name it, something that I do not want. So, I was thinking of maybe just moving it to the center, but doing so would cut the transition leaving a glitchy effect onscreen since it is leaving behind the cursor.

Consequently, the last option I thought about is maybe forcing the scale up to adapt and move considering the padding of the parent div (ideally the main div, not body since there is a little nav on the top).

I have tried to think of ways of trying to implement this but I have no clue where to even start. I have seen methods of scaling child to a parent div like this, but that was not what I had in mind.

I just want to prevent the image and footer to overflow out; show the full image still and keeping the ratio. And being quite honest I do not know if choosing a grid set would help me more, since the example I showed, grid is used.

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

.column {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-content: center;
  justify-content: center;
}

.main {
  padding: 1rem;
}

.description {
  opacity: 0;
  padding: 0.3rem;
  padding-top: 0.2rem;
  visibility: hidden;
  overflow: auto;
  font-size: 0.5rem;
  transition: 0.3s ease-in-out;
}

img {
  width: 100%;
}

.zoom {
  transition: all 1s ease-in-out;
  background-color: white;
  width: 60%;
}

.zoom:hover {
  transform: scale(1.5);
  box-shadow: 0.2rem 0.2rem 0.5rem rgba(0, 0, 0, 0.5);
  z-index: 68;
}

.zoom:hover .description {
  visibility: visible;
  animation-name: descriptionName;
  animation-duration: 1.6s;
  animation-fill-mode: forwards;
}

@keyframes descriptionName {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div class="main">
    <div class="row">
      <div class="column">
        <div class="zoom">
          <img src="https://greenwings.co/wp-content/uploads/2018/09/blank-head-profile-pic-for-a-man.jpg">
          <div class="description">
            <p>This is a label - year</p>
          </div>
        </div>
      </div>
      <div class="column">
        <div class="zoom">
          <img src="https://greenwings.co/wp-content/uploads/2018/09/blank-head-profile-pic-for-a-man.jpg">
          <div class="description">
            <p>This is a label - year</p>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="column">
        <div class="zoom">
          <img src="https://greenwings.co/wp-content/uploads/2018/09/blank-head-profile-pic-for-a-man.jpg">
          <div class="description">
            <p>This is a label - year</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>

How to style background color and border line for the selected bar in React ApexCharts like this?

I’m using react-apexcharts to create a bar chart, and I want to customize the appearance of a selected bar when clicked.

designer want this.

I know that setting the states.active.filter to none removes the default darken effect:

states: {
  active: {
    filter: {
      type: 'none',
    },
  },
},

However, I would like to:

  • Add a dashed border around the selected bar
  • Apply a custom background color when selected

I tried using plotOptions and states but couldn’t find a way to achieve this.

How can I achieve this in ApexCharts?

Here is a minimal example of my current chart configuration:


const BarChart = (props: {
    series: any;
    height: number;
    xCategories: string[];
    horizontal?: boolean;
}) => (
    <ChartWrapper
        style={{
            position: `relative`,
            width: `100%`,
            margin: `0 auto`,
            boxSizing: `border-box`,
            border: `none`,
            padding: 0,
        }}
    >
        <ApexCharts
            type={'bar'}
            series={[
                {
                    name: '',
                    data: props.series,
                },
            ]}
            options={{
                chart: {
                    type: 'bar',
                    height: props.height,
                    toolbar: {show: false},
                    events: {
                        dataPointSelection(chart, options) {
                            console.log(chart, options);
                        },
                    },
                    background: 'transparent',
                },
                states: {
                    active: {
                        filter: {
                            type: 'none',
                        },
                    },
                },
                plotOptions: {
                    bar: {
                        barHeight: '50%',
                        borderRadius: 2,
                        horizontal: props.horizontal,
                        columnWidth: '8px',
                    },
                },
                dataLabels: {enabled: false},
                colors: [theme.palette.info.light],

                grid: {
                    show: true,
                    borderColor: theme.palette.greySecondary[100],
                    xaxis: {
                        lines: {
                            show: false,
                        },
                    },
                    yaxis: {
                        lines: {
                            show: true,
                        },
                    },
                },
                xaxis: {
                    categories: props.xCategories,
                    position: 'bottom',
                    axisBorder: {
                        show: true,
                    },
                    labels: {
                        style: {
                            colors: theme.palette.greySecondary[600],
                        },
                    },
                    tooltip: {
                        enabled: true,
                    },
                },
                yaxis: {
                    show: true,
                    axisBorder: {show: false},
                    axisTicks: {show: true},
                    labels: {
                        style: {
                            colors: theme.palette.greySecondary[600],
                        },
                        formatter: (val: number) => val.toLocaleString(),
                    },
                },
                tooltip: {
                    enabled: true,
                    theme: 'light',
                    style: {
                        fontSize: '12px',
                    },
                    y: {
                        formatter: (val: number) => val.toLocaleString(),
                    },
                },
            }}
            height={props.height || `auto`}
        />
    </ChartWrapper>
);

TypeError: Cannot read property ‘length’ of undefined (PolyglotException )

I am executing minified bundled js file using GraalVM to render the page server side, i am facing an issue, my web page is throwing error randomly and page does not get rendered and once i refresh the page it works fine. Although error occurrences are less but its causing bad user exeperience.
The error i get is below

org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property 'length' of undefined
    at <js>.useMemo(bundled.js:89356)
    at <js>.exports.useMemo(bundled.js:98527)
    at <js>.Provider(bundled.js:94056)
    at <js>.d(bundled.js:89362)
    at <js>.Za(bundled.js:89365)
    at <js>.b.render(bundled.js:89370)
    at <js>.b.read(bundled.js:89370)
    at <js>.renderToString(bundled.js:89379)
    at <js>.global.render(bundled.js:170850)

I am not able to find any of my custom component in the stack trace even after turning off minification, the function which are minified and coming in the stack trace is from react-dom-server.browser.production.min.js file, and i am not able to understand the error

Dependent dropdown list using Laminas framework and doctrine-orm – The input was not found in the haystack

The form is working fine. All the selects and other form elements are works fine when I submit. The only problem is the community_id which is dependent on the district. Its always given The input was not found in the haystack. In the browser console the form sends the community_id but I don’t why I keep getting the haystack problem:
district_id: 9c72f59e-f733-11ef-89e9-00155d016f00
community_id: 4acc72cb-fc61-11ef-8c90-00155d016f00

Form:


    Elements
    // Add district selection
        $this->add([
            'name' => 'district_id',
            'type' => ElementSelect::class,
            'options' => [
                'label' => 'District',
                'empty_option' => 'Select District',
                'value_options' => $this->getDistrictOptions(),
                'label_attributes' => [
                    'class' => 'required-field'
                ],
            ],
            'attributes' => [
                'id' => 'district_id',
                'class' => 'form-control form-select',
                'required' => true,
                'data-dependent-url' => '/community/list'
            ],
        ]);
        
        // Add community selection
        $this->add([
            'name' => 'community_id',
            'type' => ElementSelect::class,
            'options' => [
                'label' => 'Community',
                'empty_option' => 'Select Community',
                'value_options' => $this->getCommunityOptions(),
                'label_attributes' => [
                    'class' => 'required-field'
                ],
            ],
            'attributes' => [
                'id' => 'community_id',
                'class' => 'form-control form-select',
                'required' => true,
                'disabled' => true,
                'data-dependent' => 'district_id',
                'value' => ''
            ],
        ]);


    *Inputfilters*
    'district_id' => [
                'required' => true,
                'filters' => [
                    ['name' => 'StringTrim'],
                ],
                'validators' => [
                    [
                        'name' => 'NotEmpty',
                        'options' => [
                            'messages' => [
                                'isEmpty' => 'Please select a district'
                            ],
                        ],
                    ],
                    [
                        'name' => 'Callback',
                        'options' => [
                            'callback' => [$this, 'validateDistrict'],
                            'messages' => [
                                'callbackValue' => 'Invalid district selected'
                            ],
                        ],
                    ],
                ],
            ],
            'community_id' => [
                'required' => true,
                'filters' => [
                    ['name' => 'StringTrim'],
                ],
                'validators' => [
                    [
                        'name' => 'NotEmpty',
                        'options' => [
                            'messages' => [
                                'isEmpty' => 'Please select a community or choose     Other and specify a new community name'
                            ],
                        ],
                    ],
                    [
                        'name' => 'Callback',
                        'options' => [
                            'callback' => [$this, 'validateCommunity'],
                            'messages' => [
                                'callbackValue' => 'Please select a valid community from the list or choose Other and specify a new community name'
                            ],
                        ],
                    ],
                ],
            ],

    *Validators*
    public function validateDistrict($value)
    {
        $district = $this->entityManager->getRepository(GrmEntityDistrict::class)
                ->find($value);
        
        return $district !== null;
    }
    
    public function validateCommunity($value)
    {
        // Log the submitted value
        error_log("Submitted community_id: " . $value);

        // Get the district ID
        $districtId = $this->get('district_id')->getValue();
        error_log("Selected district_id: " . $districtId);

        if (empty($districtId)) {
            error_log("District ID is empty.");
            return false;
        }

        // Handle 'other' option
        if ($value === 'other') {
            $otherCommunity = $this->get('other_community')->getValue();
            if (empty($otherCommunity)) {
                error_log("Other community name is empty.");
                return false;
            }
            return true;
        }

        // For numeric IDs, verify the community exists in the selected district
        if (is_numeric($value)) {
            try {
                $community = $this->entityManager->getRepository(GrmEntityCommunity::class)
                    ->findOneBy([
                        'id' => $value,
                        'district' => $districtId
                    ]);

                if ($community === null) {
                    error_log("Community not found in the selected district.");
                } else {
                    error_log("Community found: " . $community->getName());
                }

                return $community !== null;
            } catch (Exception $e) {
                error_log("Error validating community: " . $e->getMessage());
                return false;
            }
        }

        error_log("Invalid community_id value: " . $value);
        return false;
    }
Index.phtml:
    <!-- District and Community -->
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div class="flex items-center space-x-2">
                                <?= $this->formLabel($form->get('district_id')) ?>
                                <div class="flex-1">
                                    <?= $this->formElement($form->get('district_id'))     ?>
                                    <?= $this->formElementErrors($form->get('district_id')) ?>
                                </div>
                            </div>

                            <div class="flex items-center space-x-2">
                                <?= $this->formLabel($form->get('community_id')) ?>
                                <div class="flex-1">
                                    <?= $this->formElement($form->get('community_id')) ?>
                                    <?= $this->formElementErrors($form->get('community_id')) ?>
                                </div>
                            </div>
                        </div>
*Scripts*
`// Handle dependent dropdowns and form fields
$(document).ready(function() {
// District -> Community dependency
    $('#district_id').change(function() {
        const districtId = $(this).val();
        const communitySelect = $('#community_id');
        const otherCommunityContainer = $('.other-community-container');
        const otherCommunityField = $('#other_community');
        
        // Reset and hide other community field
        otherCommunityContainer.addClass('hidden');
        otherCommunityField.val('').prop('required', false);
        
        if (districtId) {
            // Show loading indicator
            communitySelect.prop('disabled', true).empty()
                .append('<option value="">Select Community</option>');
            
            $.ajax({
                url: '/community/list/' + districtId,
                method: 'GET',
                dataType: 'json',
                success: function(response) {
                    communitySelect.empty();
                    
                    // Add empty option
                    communitySelect.append('<option value="">Select Community</option>');
                    
                    if (response && response.length > 0) {
                        response.forEach(function(community) {
                            communitySelect.append(
                                $('<option></option>')
                                    .val(community.id)
                                    .text(community.name)
                            );
                        });
                    }
                    
                    // Add "Other" option
                    communitySelect.append('<option value="other">Other (Specify)</option>');
                    communitySelect.prop('disabled', false);
                },
                error: function() {
                    communitySelect.empty()
                        .append('<option value="">Error loading communities</option>')
                        .append('<option value="other">Other (Specify)</option>')
                        .prop('disabled', false);
                }
            });
        } else {
            communitySelect.empty()
                .append('<option value="">Select Community</option>')
                .append('<option value="other">Other (Specify)</option>')
                .prop('disabled', true);
            
            // Reset other community field
            otherCommunityContainer.addClass('hidden');
            otherCommunityField.val('').prop('required', false);
        }
    });

    // Handle Other Community selection
    $('#community_id').on('change', function() {
        const selectedValue = $(this).val();
        const otherCommunityContainer = $('.other-community-container');
        const otherCommunityField = $('#other_community');
        
        if (selectedValue === 'other') {
            otherCommunityContainer.removeClass('hidden');
            otherCommunityField.prop('required', true).val('');
        } else {
            otherCommunityContainer.addClass('hidden');
            otherCommunityField.prop('required', false).val('');
        }
    });

});`

How can I render the name in Select option relational table?

Is there a way I can render the first_name and last_name as a defaultValues in the select option after fetching the data which is a relational table?

Currently, I was able to put other information as a defaultValues, but having a hard time on how can I render the first_name and last_name since it is a relational table?

const UpdateNewPaper = () => {

  const {data, isLoading} = useGetSinglePaperQuery(id)

   
  const form = useForm<UpdateNewPaperSchemaType>({
    resolver: zodResolver(UpdateNewPaperSchema),
  });



  useEffect(() => {
    if (data) {
      form.reset({
        title: data.title || "",
        authorId: data.Authors.first_name,
      });
    }
  }, [data, form]);




return (
  <Form>
      <form onSubmit={form.handleSubmit(onSubmit)}>
           <FormField
                    control={form.control}
                    name="authorId"
                    defaultValue={data?.Authors.first_name}
                    render={({ field }) => (
                      <FormItem className="w-full"> {/* Adjust the width here (e.g., w-64, w-80, w-96) */}
                        <Select onValueChange={field.onChange} defaultValue={field.value}>
                          <FormControl>
                            <SelectTrigger className="w-full"> {/* Ensure trigger takes full width of parent */}
                              <SelectValue placeholder="Author" />
                            </SelectTrigger>
                          </FormControl>
                          <SelectContent className='w-full'>
                            {listofAuthors.data.map((author: ListOfAuthors) => (
                              <React.Fragment key={author.id}>
                                <SelectItem value={author.id}>{author.first_name} {author.last_name}</SelectItem>
                              </React.Fragment>
                            ))}
                          </SelectContent>
                        </Select>
                        <FormMessage />
                      </FormItem>
                    )}
                  />
      </form>

  </Form>
)


}


this is the data i’m receiving.

{
    "id": "c7a8ef7c-7b66-4536-9ea8-cdf6bf009c6c",
    "title": "new",
    "authorId": "7e99a9ba-4761-46ab-95f5-d77f2d95e311",
    "Authors": {
        "id": "7e99a9ba-4761-46ab-95f5-d77f2d95e311",
        "first_name": "random",
        "middle_name": "random",
    }
}

DataTable : while looping through datatable using datatable.rows().every() loop indext starts from last of datatable instead of 0

I am new to js and debugging for some issue, found that code has logic written on rowindex and for this loop my rowindex starts from length of datatable till 0 .
Where document suggest that it starts from 0 to length of datatable.

I really not getting what has made this simple loop do this reverse behaviour.

I suspected that some setup for datatable have caused this but thats not the case.

Please help if you have faced anything similar.
Thanks in advance

How to bypass the proxy checking endpoint?

Hope you are doing well
I am trying to call one endpoint using residential proxy, but I am getting 403 Forbidden issue.
Could you let me know how can I call this endpoint?
Or is there any other option because I need to hide my original client ip address.
Thanks

This is the code that I tried

import fetch from 'node-fetch';
import { HttpsProxyAgent } from 'https-proxy-agent';
import axios from 'axios';
import https from 'https';

const proxyUrl = "http://customer-<Username>:<Password>@pr.oxylabs.io:7777";
const agent = new HttpsProxyAgent(proxyUrl);

async function fetchViaProxy() {
    try {
        const locationUrl = "https://ip.oxylabs.io/location";
        const locationResult = await axios.get(locationUrl, {
            httpsAgent: agent,
        });
        console.log(locationResult.data);
        
        const url = "http://x.x.x.x:3000/check";

        const result = await axios.get(url, {
            httpsAgent: agent,
        });

        const { response } = result.data;

        console.log(response);
    } catch (error) {
        console.error("Error fetching via proxy:", error);
    }
}

fetchViaProxy();

Page scrolls by itself when dynamically enabling CSS Anchor Positioning

When I perform the following action in a code snippet, the browser scrolls up and down on its own.
I can prevent this by recording and restoring scrollY before and after the process, but what should I do to solve the fundamental problem?
windows GoogleChrome 134.0.6998.89 .

Scroll to the bottom, press the last button, and then press the top button while it is still on the screen, and windows will scroll by itself.

It is also reproduced in codeSnippet on stackoverflow.

<!DOCTYPE html>
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width" />
  <style>
    * {
      word-break: break-word;
      box-sizing: border-box;
    }
    body {
      margin: 0;
      min-height: 100vh;
    }
    .thin-table th,
    .thin-table td {
      border: 1px solid black;
      border-collapse: collapse;
    }
    .my-anchor {
      anchor-name: --my-anchor;
    }
    .my-popover {
      position-anchor: --my-anchor;
      border: solid 1px black;
      background-color: cyan;
      position: absolute;
      position-area: span-right bottom;
      position-try-fallbacks: flip-block;
    }
  </style>
  <script>
    window.addEventListener(
      "DOMContentLoaded",
      (e) => {
        [...document.querySelectorAll("button")].forEach((e, i) => {
          e.innerText = `Button-${i + 100}`;
          e.addEventListener("click", (e) => showPopOver(e));
        });
      },
      false
    );
    function showPopOver(e, label) {
      document.querySelector(".my-anchor")?.classList.remove("my-anchor");
      e.target.classList.add("my-anchor");
      document.querySelector(".my-popover").style.display = "block";
    }
  </script>
</head>
<body>
  Scroll to the bottom, press the last button, and then press the top button
  while it is still on the screen, and windows will scroll by itself.<br />
  <div class="my-popover" style="display: none">popup</div>
  <table class="thin-table">
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
    <tr>
      <td>A</td>
      <td><button>B</button></td>
    </tr>
  </table>
</body>

Unable to respond to events in a contract using the web3.js library in javascript code

When I called the receivepol1 contract function on the front-end webpage, the event text content of ‘Transaction Successful111111: ‘ was not displayed on the front-end webpage.
Why is this? Didn’t the “Index” event in the contract get a response? But I checked the transaction hash information and found that the index event in the contract had been triggered, but why was the text content not displayed on the front-end webpage?

the solidity contract code as follows:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.4;
import "@chainlink/contracts/src/v0.8/automation/interfaces/KeeperCompatibleInterface.sol";
contract Biao {
    event Index(uint256 indexed amount1);
    address payable public myself;
    constructor() {
        myself = payable(msg.sender);
    }
    function receivepol1() public payable returns (uint256){
        uint256 amount1 = 2;
        emit Index(amount1);
        return amount1;
    }
}

the javascript code as follows:

contract = new web3.eth.Contract(abi, contractAddress);
contract.events.Index({}, async function(error, event) {
  if (!error){
      console.log('Event detected:', event); 
      indexvalue = event.returnValues.amount1;
      var text = document.createElement('span');
      text.innerText = 'Transaction Successful111111: '; 
      text.style.position = 'absolute';
      text.style.top = '690px';
      text.style.left = '500px';
      text.style.color = 'black';
      text.style.fontSize = '14px';
      text.style.fontWeight = 'bold';
      text.style.backgroundColor = 'rgba(0,0,0,0.5)'; 
      text.style.padding = '5px'; 
      document.body.appendChild(text);
  } else {
      console.error('Error listening to Debug events:', error);
  }
});

the html code as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My DApp</title>
    <link rel="icon" href="aa.png" type="image/png">
</head>
<body>
    <h1>Welcome to My DApp</h1>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.3.0/web3.min.js"></script>
    <script src="app.js"></script>
</body>
</html>

Why is there no text information displayed on the front end of the web page? Is it because the code in the javascript is incorrect?