Floating input in React Native

I’m trying to create a floating input in React Native, but the problem is that I have to press in the empty area (the red area) so that the placeholder could float and allow me to write inside the input field.

However, if I try to press the placeholder title, nothing happens. The placeholder doesn’t float, the cursor doesn’t appear, and I can’t write.

enter image description here

this is my code


export default function SingleLineText({ onChange, placeholder, columnName, requiredInput, inputValue }) {
    const [value, setValue] = useState("");
    const moveText = useRef(new Animated.Value(0)).current;
    const schema = yup.object().shape({
        columnName: yup.string().required('You should enter this field.'),
    });

    const { control, handleSubmit, formState: { errors } } = useForm({
        resolver: yupResolver(schema),
        defaultValues: {
            columnName: inputValue ? inputValue : '',
        },
    });

    useEffect(() => {
        if (value !== "") {
            moveTextTop();
        } else if (value === "") {
            moveTextBottom();
        }
    }, [value])

    useEffect(() => {
        onChange(value)
    }, [value])

    const onChangeText = (text) => {
        setValue(text);
    };

    const onFocusHandler = () => {
        moveTextTop();
    };

    const onBlurHandler = () => {
        if (value === "") {
            moveTextBottom();
        }
    };

    const moveTextTop = () => {
        Animated.timing(moveText, {
            toValue: 1,
            duration: 200,
            useNativeDriver: true,
        }).start();
    };

    const moveTextBottom = () => {
        Animated.timing(moveText, {
            toValue: 0,
            duration: 200,
            useNativeDriver: true,
        }).start();
    };

    const yVal = moveText.interpolate({
        inputRange: [0, 2.5],
        outputRange: [4, -20],
    });

    const animStyle = {
        transform: [
            {
                translateY: yVal,
            },
        ],
    };
    return (
        <View style={styles.container}>
            <Animated.View style={[styles.animatedStyle, animStyle]}>
                <Text style={styles.label}>{placeholder}</Text>
            </Animated.View>
            <Controller
                control={control}
                rules={{ requiredInput }}
                render={({ field: { onChange, value, onBlur } }) => (
                    <TextInput
                        onBlur={onBlurHandler}
                        value={inputValue}
                        onChangeText={onChangeText}
                        style={styles.input}
                        onFocus={onFocusHandler}
                    />
                )}
                name={columnName}
            />
            {errors.columnName && <Text >{errors?.columnName?.message}</Text>}
        </View>
    )
}
const styles = StyleSheet.create({
    container: {
        height: 53,
        backgroundColor: Colors.lightGray,
        borderRadius: 8,
        paddingTop: 15,
        marginVertical: 5,
        paddingHorizontal: 18,
        borderColor: "#bdbdbd",
        width: "100%",
        justifyContent: "center",
    },
    input: {
        fontFamily: FONTS.PoppinsRegular,
        fontSize: 18,
        height: 53,
    },
    label: {
        paddingVertical: 5,
        fontFamily: FONTS.PoppinsRegular,
        color: Colors.SmokeBlue,
        fontSize: 15,
    },
    animatedStyle: {
        top: 4,
        left: 15,
        position: 'absolute',
        borderRadius: 90,
        zIndex: 10000,
    },
    errorMessage: {
        color: Colors.Red,
        fontFamily: FONTS.PoppinsMedium,
        fontSize: 10,
    }
});

Can I make this kind of radio button?

Essentially I want have 2 options on button click with a group of 3 buttons.

Buttons can say: Free or Qtr

And if one button says qtr then the other buttons in that group must say free

This is the closest script that has worked properly but it is for colored checks, not for text and also doesn’t offer the radio function of making it say free if qtr is selected on another button in group

     if(color.equal(event.target.textColor,color.black))
 event.target.textColor = color.green;

else if(color.equal(event.target.textColor,color.green))
event.target.textColor = color.red;
else
event.target.textColor = color.black;

Image is centered when setView() and setZoom() are applied together in Leaflet

I want to move the image to some point on the iamge with setView() and zoom there by 2 with setZoom(), but when the image is moved by setView(), setZoom() moves the image to the center. I want it to be zoomed in while keeping its new position set by setView(). It is the same with panTo().

L.Map.ScrollWheelZoom.include({
        _performZoom: function() {
            var map = this._map,
                zoom = map.getZoom(),
                snap = this._map.options.zoomSnap || 0;

            map._stop();

            var d2 = this._delta / (this._map.options.wheelPxPerZoomLevel * 4),
                d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2,
                d4 = snap ? Math.ceil(d3 / snap) * snap : d3,
                delta = map._limitZoom(zoom + (this._delta > 0 ? d4 : -d4)) - zoom;

            this._delta = 0;
            this._startTime = null;

            if (!delta) {
                return;
            }

            if (map.options.scrollWheelZoom === 'center') {
                console.log(zoom + delta);
                map.setZoom(zoom + delta);

            } else if (map.options.scrollWheelZoom instanceof L.Point) {
                map.setZoomAround(map.options.scrollWheelZoom, zoom + delta);
            
            } else {
                map.setZoomAround(this._lastMousePos, zoom + delta);
            }
        }
    });

    var map = L.map('map', {
        maxZoom: 5,
        minZoom: 1,
        scrollWheelZoom: L.point(window.innerWidth/2, window.innerHeight/2),
        crs: L.CRS.Simple
    });

    var bounds = [[0,0], [1000,1000]];
    var image = L.imageOverlay('Texture/test map.png', bounds).addTo(map);

    map.fitBounds(bounds);

    map.setMaxBounds(bounds);
    map.on('drag', function() {
        map.panInsideBounds(bounds, { animate: false });
    });

nestjs , stream question, i dont know my code would synchronization or asynchronous

i dont know my code would synchronization or asynchronous
when users request upload files API , i want asynchronous, dont block my program

import { Injectable } from '@nestjs/common';
import { InjectConnection } from '@nestjs/mongoose';
import { Connection } from 'mongoose';
import { GridFSBucket } from 'mongodb';
import { createReadStream } from 'fs';

@Injectable()
export class GridFSService {
    private bucket:GridFSBucket;
    constructor(
      @InjectConnection() private readonly connection: Connection
    ) {
      this.bucket =new GridFSBucket(this.connection.db,{bucketName:'podimages'});
    }
    async uploadFile(file: Express.Multer.File): Promise<any> {
      const readableFile = createReadStream(file.path);
      const writable =  this.bucket.openUploadStream(file.originalname)
      readableFile.pipe(writable);

      return {
        message: 'File uploaded successfully',
        code: 200
      }
    }
}

NodeJS crashing chrome browser

Nodejs application developed with ExpressJS and pkg to build executable. It opens a chrome application window and the application runs perfectly on development machine. Once nodejs application is running, a second copy can be started in chrome browser tab by referencing localhost.

On my brother’s machine running the exact same Windows 11 and exact same version of chrome, the chrome application window opens and then closes in a few seconds without any error message or chrome crash log. However, if he opens the chrome browser window before starting the nodejs application, the nodejs chrome application window opens and the applications runs correctly.

We uninstalled his antivirus program to eliminate this potential problem caused by antivirus programand the uninstall had no affect on the failure. I don’t think it a memory problem since it runs successfully if the chrome browser window is opened first.
We reinstalled chrome to make sure that we were running the same exact chrome code.

Any ideas where the problem might be?

Im working on a project and deadline is near and would be very greatfull if anyone could sort it out [closed]

I tried on my own but it doesnt respond

WELCOME PAGE which is a login page for the users requiring a Batch number and password and an option for the admin to login through Email and password and a Sign up option and forgot password The Sign up option will consist of the following empty spaces that is mandatory to be filled: Name: YT email address: YT email address password: second email address: country: discord account: Enter Password: Confirm password: The forgot password option will ask for YT channel email address and when the user will enter the email correctly it will send a password re-set link if wrong or unknown email is written it will prompt no email found on the screen For the admin there will be following options after logged in 1 Check progress for Videos running 2 Check progress for Like and Subs 3 Payment 4 Open and close Video link box 5 Announcement 6 Links for the day After Logged in for users the second page will have 3 main options on screen That will be: 1 Run Videos 2 Like and Subscribe 3 My progress 4 Payment 5 Enter Video Link 6 How to work? So how the options work (Admin): 1 the admin will have the option to check the users track of how many links users have played and a search bar to check the asked a specific user asked thorgh a search bar and a filter options completed and not completed 2 The same process as above will be followed 3 after clicking the third option a list will appear and besides every user name there will be a tick and cross option and a filter option of payed and not payed this should be in such way that every month has its own sheet that could be edited in the future and and after clicking on any user the a profile will be opened of the user with YT email address and password and an empty box where the admin will enter the amount and for the user it will be displayed as “Your this month total to be payed is:” and for example the admin enters $20 so it will be displayed ”Your this month total to be payed is $20” and the user should get an announcement for there respective payment update There will be another option to check the total amount of all the users of any month it will sum the payment amount of all the users and display for ex the admin selects the month September 2024 so it will display the amount of all the users from September 2024 and display “ The business of September 2024 is xyz amount” 4 The admin can unlock the Enter video link option for the for 24 hours by typing Batch number/user-name range there wil be two box in this that will be Start batch number Stop Batch number for example The user types 1 in the startbox and 1000 in end box so for all the users from 1-1000 the Enter video link box will be opened for 24 hours 5 If the admin wants to make An announcement so there will be a text box where the admin will enter the announcement and after the announcement is published all the users should get notification 6 This option will gather the links for users that have entered in the Enter video link box after 24 it should queue all the links in Run videos option for user So how the options work (User): 1 Before running display a message “Do not forget to turn on your VPN” and an OK button after user presses the button Run videos option will run such in such way that it open 15 youtube links each in different tab at the same time from queue and skips the ad after it is fully played and plays the video and after mins it closes down the links and opens the next 15 link following the same procedure and continues to do so for 12 hours and after 12 hours it closes down and display the message “ Your Automation task for today is completed” and should keep the record of it so that user and admin could check 2 Like and Sub option will run such in such way that it open 15 youtube links each in different tab at the same time from queue and skips the ad after it is fully played and plays the video and after 3mins it closes down the links and opens the next 15 link following the same procedure and continues to do so for 4 hours and after 4 hours it closes down and display the message “ Your Manual task for today is completed” and should keep the record of it so that user and admin could check 3 This will consist of two headings: Automation work Manual work This will show the remaining hours of the work left for example if someone has run the automation part for 8 hours instead of 12 so it will show in Automation work that 4 hours remaining same goes with Manual work 4 A figure will be shown to User and a bank account number where user will pay and an option to attach image where a text will be displayed that screen-shot the transaction 5 Enter Video Link box will be the option where user will enter the link of the video 6 A video will be posted here by the admin what resources do I need to built it and are you capable for developing this project?

Whats the best way to run external React Apps in my dashboard?

im working on a website and i want people to be able to write extensions (tools or whatever) for my site
for example i have a dashboard site and i want people to extend it with their own functionality

this should work in a way where they can write their own react app -> compile it -> upload it and somehow “embed” it into my dashboard with its own section

what would be the best way to start?

i’ve tried running a seperate docker container with an “extension” but i cant figure out a solid way to embed it into my site

How to correctly implement a parallax effect based on the scrolling of the user?

I’ve been following this video tutorial (https://www.youtube.com/watch?v=1wfeqDyMUx4&t=811s&ab_channel=OnlineTutorials) on how to make a parallax website. Everything was going well until I got to the line 44 of my index.html file: moon.style.left = value * 1.05 + ‘px’; There was no error code, it just didn’t do what it did in the video at 15:52, where it slides depending on your scrolling.

Here is my code.
HTML

<!doctype html>
<html>
    <head>
        <title>Parallax Scrolling Website | Vanilla Javascript</title>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <header>
            <a href="#" class="logo">Logo</a>
            <ul>
                <li><a href="#" class="active">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Work</a></li>
                <li><a href="#">Sources</a></li>
            </ul>
        </header>
        <section class="parallax-section">
            <img src="Background (1).png" id="background">
            <img src="Back Mountains.png" id="back_mountains">
            <img src="Front Mountains.png" id="front_mountains">
            <img src="Moon.png" id="moon">
            <img src="Ocean.png" id="ocean">
            <h2 id="text">Moon Light</h2>
            <a href="#sec" id="btn">Explore</a>
            <img src="Weird land_.png" id="weird_land">
        </section>
        <div class="sec" id="sec">
            <h2>Parallax Scrolling Effects</h2>
            <p>Something Something Something <br><br> Something Something Something</p>
        </div>

        <script>
            let Background = document.getElementById('background');
            let Back_mountains = document.getElementById('back_mountains');
            let Front_mountains = document.getElementId('front_mountains');
            let Moon = document.getElementById('moon');
            let Ocean = document.getElementById('ocean');
            let Text = document.getElementById('text');
            let Btn = document.getElementById('btn');
            let Weird_land = document.getElementById('weird_land');

            window.addEventListener('scroll', function(){
                let value = window.scrollY;
                moon.style.left = value * 1.05 + 'px';
                back_mountains.style.top = value * -1.25 + 'px';
                front_mountains.style.top = value * .5 + 'px';
                text.style.marginTop = value * 2 + 'px';
            })
        </script>

    </body>
</html>

CSS

@import url('https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900&display=swap');
*
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    scroll-behavior: smooth;
}

body
{
    min-height: 100vh;
    overflow-x: hidden;
    background: linear-gradient(#01789c, #1c0130);
}

header
{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 100px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10000;
}

header .logo
{
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    font-size: 2em;
    text-transform: uppercase;
    letter-spacing: 2px;
}

header ul
{
    display: flex;
    justify-content: center;
    align-items: center;
}

header ul li
{
    list-style: none;
    margin-left: 20px;
}

header ul li a
{
    text-decoration: none;
    padding: 6px 15px;
    color: #fff;
    border-radius: 20px
}

header ul li a:hover, header ul li a.active
{
    background: #fff;
    color: #2b1055;
}

section
{
    position: relative;
    width: 100%;
    height: 100vh;
    padding: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

section::before
{
    content: '';
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, #1c0522, transparent);
    z-index: 1000;
}

section img
{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

section img#moon
{
    mix-blend-mode: screen;
}

section img#mountains_front
{
    z-index: 10;
}

#text
{
    position: absolute;
    color: #fff;
    white-space: nowrap;
    font-size: 7.5vw;
    z-index: 9;
}

#btn
{
    text-decoration: none;
    display: inline-block;
    padding: 8px 30px;
    border-radius: 40px;
    background: #fff;
    color: #2b1055;
    font-size: 1.5em;
    z-index: 9;
    transform: translateY(100px);
}

.sec
{
    position: relative;
    padding: 100px;
    background: #1c0522;
}

.sec h2
{
    font-size: 3.5em;
    margin-bottom: 10px;
    color: #fff;
}

.sec p
{
    font-size: 1.2em;
    color: #fff;
}

I tried to change the .left to .top to see if it would do anything but it’s still static. I also tried changing the values to see if maybe that would have an effect, still nothing. I expected it to slide according to the scrolling like in the video but nothing happened and it remained static.

allow multi carousel in same page

I have this code for slider. i need help to edit it to allow multiple sliders in same page.

i used ChatGPT to edit it and working.

but i get some problem with touch event.

I have this code for slider. i need help to edit it to allow multiple sliders in same page.

i used ChatGPT to edit it and working.

but i get some problem with touch event.

var all_divs = $('.px-carousel-container .px-carousel-item').length;

var i = 0,
    n = 0;
let scrollleft_before = 0;

let margin = 0;
if (is_rtl()) {
    margin = parseInt($('.px-carousel-item').css('margin-left'));
} else {
    margin = parseInt($('.px-carousel-item').css('margin-right'));
}
var position_items = [0];

function width_total() {
    var sumando_ancho = 0;
    for (var pi = 0; pi < all_divs; pi++) {
        if (pi + 1 == all_divs) {
            sumando_ancho += parseFloat($('.px-carousel-container .px-carousel-item')[pi].getBoundingClientRect().width.toFixed(2));
        } else {
            sumando_ancho += parseFloat($('.px-carousel-container .px-carousel-item')[pi].getBoundingClientRect().width.toFixed(2)) + margin;
        }
    }
    var carousel_wrapper_width = $('.px-carousel-wrapper').outerWidth();
    $('.px-carousel-container').css({
        'width': sumando_ancho + "px"
    });


    return sumando_ancho;
}
$('.px-carousel-container').css({
    'min-width': +$('.px-carousel-wrapper').outerWidth() + 'px'
});

function posiciones() {
    var position_items = [0];
    var sumando_posicion = 0;
    for (var pi = 0; pi < all_divs; pi++) {
        if (pi > 0) {
            if (is_rtl()) {
                sumando_posicion += parseFloat($('.px-carousel-container .px-carousel-item')[pi - 1].getBoundingClientRect().width.toFixed(2)) + margin;
            } else {
                sumando_posicion += parseFloat($('.px-carousel-container .px-carousel-item')[pi - 1].getBoundingClientRect().width.toFixed(2)) + margin;
            }
            position_items.push(sumando_posicion);
        }
    }
    return position_items;
}

function getTranslate3d(el) {
    var values = el.style.transform.split(/w+(|);?/);
    if (!values[1] || !values[1].length) {
        return [];
    }
    return parseFloat(values[1].split(/px,s?/g)[0]);
}


if ($('.px-carousel-container').length) {

    document.getElementsByClassName('px-carousel-container')[0].addEventListener("touchstart", startTouch, {
        passive: true
    });
    document.getElementsByClassName('px-carousel-container')[0].addEventListener("touchmove", moveTouch, {
        passive: true
    });

    var initialX = null;
    var initialY = null;

    var rev = -1;

    function startTouch(e) {
        initialX = e.touches[0].clientX;
        initialY = e.touches[0].clientY;
        blu_ = 0;
    };

    var iniciado = 0;
    var trnas = 0;
    var blu_ = 0;

    function moveTouch(e) {
        var sumando_ancho = width_total();
        blu_++;

        if (blu_ == 1) {
            iniciado = e.touches[0].pageX;
            trnas = getTranslate3d(document.getElementsByClassName('px-carousel-container')[0]);
        }
        var currentX = e.touches[0].clientX;
        var currentY = e.touches[0].clientY;

        var diffX = initialX - currentX;
        var diffY = initialY - currentY;

        var translate_new = diffX * rev + trnas;

        if (is_rtl()) {
            if (translate_new > 0 && translate_new < sumando_ancho - $('.px-carousel-wrapper').outerWidth()) {
                $('.px-carousel-container').css({
                    'transform': 'translate3d(' + translate_new + 'px, 0px, 0px)',
                    'transition': 'none'
                });
            }
        } else {
            if ((translate_new * rev) > 0 && (translate_new * rev) < (sumando_ancho - $('.px-carousel-wrapper').outerWidth())) {
                $('.px-carousel-container').css({
                    'transform': 'translate3d(' + translate_new + 'px, 0px, 0px)',
                    'transition': 'none'
                });
            }
        }
        e.preventDefault();
    };
}


$(document).on('click', '.px-carousel-nav .px-next', function() {
var sumando_ancho = width_total();
var widthToMove = 4 * $('.px-carousel-item').outerWidth(true);
var translate = getTranslate3d(document.getElementsByClassName('px-carousel-container')[0]);
var newTranslate = translate - widthToMove;
if (newTranslate <= -(sumando_ancho - $('.px-carousel-wrapper').outerWidth())) {
    newTranslate = -(sumando_ancho - $('.px-carousel-wrapper').outerWidth());
    $('.px-next').addClass('disabled');
} else {
    $('.px-next').removeClass('disabled');
    $('.px-prev').removeClass('disabled');
}
$('.px-carousel-container').css({
    'transform': 'translate3d(' + newTranslate + 'px, 0px, 0px)',
    'transition': 'all 0.25s ease 0s'
});
});

$(document).on('click', '.px-carousel-nav .px-prev', function() {
var widthToMove = 4 * $('.px-carousel-item').outerWidth(true);
var translate = getTranslate3d(document.getElementsByClassName('px-carousel-container')[0]);
var newTranslate = translate + widthToMove;
if (newTranslate > 0) {
    newTranslate = 0;
    $('.px-prev').addClass('disabled');
} else {
    $('.px-prev').removeClass('disabled');
    $('.px-next').removeClass('disabled');
}
$('.px-carousel-container').css({
    'transform': 'translate3d(' + newTranslate + 'px, 0px, 0px)',
    'transition': 'all 0.25s ease 0s'
});
});
function is_rtl() {
    if ($('html[dir=rtl]').length) {
        return true;
    }
}

function carousel_px(citem) {
    if (!$('.px-carousel').length) return false;

    let margin;
    if (is_rtl()) {
        margin = parseInt($('.px-carousel-item').css('margin-left'));
    } else {
        margin = parseInt($('.px-carousel-item').css('margin-right'));
    }


    let cd = (($('.px-carousel-wrapper').width()) / citem) - margin + (margin / citem);
    $('.home .px-carousel .px-carousel-item').width(cd.toFixed(2));
    

    let width_slide = $('.px-carousel-container');
    let scrollleft_slide = Math.round($('.px-carousel-container').scrollLeft());

    $('.px-carousel-container').scrollLeft(scrollleft_slide);
}
let detectViewPort = function() {
    width_total();
    let viewPortWidth = $(window).width();
    if (viewPortWidth <= 470) {
        carousel_px(3);
        } else if (viewPortWidth <= 540) {
        carousel_px(4);
        } else if (viewPortWidth <= 640) {
        carousel_px(4);
    } else if (viewPortWidth <= 740) {
        carousel_px(6);
        } else if (viewPortWidth <= 940) {
        carousel_px(8);
        
    } else {
        if( $(document).find('body').hasClass('sidg') ) {
            if( $(document).find('body').hasClass('full-width') ) {
                carousel_px(3);
            } else {
                carousel_px(2);
            }
        }
        else {
            if( $(document).find('body').hasClass('full-width') && viewPortWidth >= 1100 ) {
                carousel_px(7);
            } else {
                carousel_px(10);
            }
        }
    }

};
detectViewPort();
$(window).resize(function() {
    detectViewPort();
});

Error with SVG gauges – ESP8266 Web Server

i am a newbie. This looks like a stupid question but i am stuck in this. I am looking forward on using some SVG Gauges but i don’t know what i am doing wrong.

this is the result i am looking to view locally and later on upload it to a local web server on the ESP8266. https://codepen.io/naikus/pen/BzZoLL

i have created 3 files

index
style
script

var gauge1 = Gauge(
  document.getElementById("gauge1"), {
    max: 100,
    dialStartAngle: -90,
    dialEndAngle: -90.001,
    value: 100,
    label: function(value) {
      return Math.round(value * 100) / 100;
    }
  }
);

var gauge2 = Gauge(
  document.getElementById("gauge2"), {
    min: -50,
    max: 50,
    dialStartAngle: 180,
    dialEndAngle: 0,
    value: 50,
     color: function(value) {
        if(value < -25) {
          return "#5ee432";
        }else if(value < 0) {
          return "#fffa50";
        }else if(value < 25) {
          return "#f7aa38";
        }else {
          return "#ef4655";
        }
      }
  }
);

var gauge3 = Gauge(
  document.getElementById("gauge3"), {
    max: 100,
    value: 50
  }
);

var gauge4 = Gauge(
  document.getElementById("gauge4"), {
    max: 30000,
    dialStartAngle: 90,
    dialEndAngle: 0,
    value: 50
  }
);

var gauge5 = Gauge(
  document.getElementById("gauge5"), {
    max: 200,
    dialStartAngle: 0,
    dialEndAngle: -180,
    value: 50
  }
);

var gauge6 = Gauge(
  document.getElementById("gauge6"), {
    max: 100,
    dialStartAngle: 90.01,
    dialEndAngle: 89.99,
    dialRadius: 10,
    showValue: false,
    value: 50
  }
);


var gauge7 = Gauge(
  document.getElementById("gauge7"), {
    max: 100,
    dialStartAngle: -90,
    dialEndAngle: -90.001,
    value: 100,
    showValue: false,
    label: function(value) {
      return Math.round(value * 100) / 100;
    }
  }
);




(function loop() {
  var value1 = Math.random() * 100,
      value2 = Math.random() * 100,
      value3 = Math.random() * 100,
      value4 = Math.random() * 100,
      value5 = Math.random() * 100;

  // setValueAnimated(value, durationInSecs);
  // var maxVals = [100, 200];
  // gauge1.setMaxValue(maxVals[Math.round(Math.random())])
  gauge1.setValueAnimated(value1, 1);
  gauge2.setValueAnimated(50 - value2, 2);
  gauge3.setValueAnimated(value3, 1.5);
  gauge4.setValueAnimated(value4 * 300, 2);
  gauge5.setValueAnimated(value5 * 2, 1);
  gauge6.setValueAnimated(value1, 1);
  gauge7.setValueAnimated(value1, 1);
  window.setTimeout(loop, 4000);
})();
body {
  background-color: rgba(0,0,0,0.8);
  color: #999;
  font-family: Hevletica, sans-serif;
}

.info {
  clear: both;
  padding: 10px;
  font-size: 0.9em;
}
a.link {
  color: rgb(47, 227, 255);
  text-decoration: none;
}

.warn {
  font-size: 0.8em;
  background-color: darken(orange, 15%);
  color: #fff;
  padding: 10px;
}

/* ------ Default Style ---------- */
.gauge-container {
  width: 150px;
  height: 150px;
  display: block;
  float: left;
  padding: 10px;
  background-color: #222;
  margin: 7px;
  border-radius: 3px;
  position: relative;
}
.gauge-container > .label {
  position: absolute;
  right: 0;
  top: 0;
  display: inline-block;
  background: rgba(0,0,0,0.5);
  font-family: monospace;
  font-size: 0.8em;
  padding: 5px 10px;
}
.gauge-container > .gauge .dial {
  stroke: #334455;
  stroke-width: 2;
  fill: rgba(0,0,0,0);
}
.gauge-container > .gauge .value {
  stroke: rgb(47, 227, 255);
  stroke-width: 2;
  fill: rgba(0,0,0,0);
}
.gauge-container > .gauge .value-text {
  fill: rgb(47, 227, 255);
  font-family: sans-serif;
  font-weight: bold;
  font-size: 0.8em;
}




/* ------- Alternate Style ------- */
.wrapper {
  height: 100px;
  float: left;
  margin: 7px;
  overflow: hidden;
}
.wrapper > .gauge-container {
  margin: 0;
}
.gauge-container.two {
}
.gauge-container.two > .gauge .dial {
  stroke: #334455;
  stroke-width: 10;
}
.gauge-container.two > .gauge .value {
  stroke: orange;
  stroke-dasharray: none;
  stroke-width: 13;
}
.gauge-container.two > .gauge .value-text {
  fill: #ccc;
  font-weight: 100;
  font-size: 1em;
}



/* ------- Alternate Style ------- */
.gauge-container.three {
}
.gauge-container.three > .gauge .dial {
  stroke: #334455;
  stroke-width: 2;
}
.gauge-container.three > .gauge .value {
  stroke: #C9DE3C;
  stroke-width: 5;
}
.gauge-container.three > .gauge .value-text {
  fill: #C9DE3C;
} 



/* ----- Alternate Style ----- */
.gauge-container.four > .gauge .dial {
  stroke: #334455;
  stroke-width: 10;
}
.gauge-container.four > .gauge .value {
  stroke: #F32450;
  stroke-dasharray: none;
  stroke-width: 10;
}
.gauge-container.four > .gauge .value-text {
  fill: #F32450;
  transform: translate3d(26%, 20%, 0);
  display: inline-block;
}
.gauge-container.four .value-text {
  color: #F32450;
  font-weight: 100;
  position: absolute;
  bottom: 18%;
  right: 10%;
  display: inline-block;
} 



/* ----- Alternate Style ----- */
.gauge-container.five > .gauge .dial {
  stroke: #334455;
  stroke-width: 5;
}
.gauge-container.five > .gauge .value {
  stroke: #F8774B;
  stroke-dasharray: 25 1;
  stroke-width: 5;
}
.gauge-container.five > .gauge .value-text {
  fill: #F8774B;
  font-size: 0.7em;
}



/* ----- Alternate Style ----- */
  .gauge-container.six > .gauge .dial {
    stroke: #334455;
    fill: "#334455";
    stroke-width: 20;
  }
  .gauge-container.six > .gauge .value {
    stroke: #FF6DAF;
    stroke-width: 20;
  }
  .gauge-container.six > .gauge .value-text {
    fill: #FF6DAF;
    font-size: 0.7em;
  }


.gauge-container.seven > .gauge .dial {
  stroke: transparent;
  stroke-width: 5;
  transform: scale(0.9,0.9) translate3d(5.5px, 5.5px, 0);
  fill: rgba(148, 112, 57, 0.42);
}
.gauge-container.seven > .gauge .value {
  stroke: #F8774B;
  stroke-dasharray: none;
  stroke-width: 5;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example</title>
    <link rel="stylesheet" href="style.css"> <!-- Link to your CSS file -->
</head>
<body>
     <div id="gauge1" class="gauge-container">
    <span class="label">DEFAULT</span>
    </div>

    <div class="wrapper">
      <div id="gauge2" class="gauge-container two">
        <span class="label">.two</span>
      </div>
    </div>

    <div id="gauge3" class="gauge-container three">
      <span class="label">.three</span>
    </div>

    <div id="gauge4" class="gauge-container four">
      <span class="label">.four</span>
      <span class="value-text">km/hr</span>
    </div>

    <div id="gauge5" class="gauge-container five">
      <span class="label">.five</span>
    </div>

    <div id="gauge6" class="gauge-container six">
      <span class="label">.six</span>
    </div>

    <div id="gauge7" class="gauge-container seven">
      <span class="label">.seven</span>
    </div>

    <div class="info">
      Grab yours at <a class="link" href="https://github.com/naikus/svg-gauge" target="_blank">https://github.com/naikus/svg-gauge</a> Fork and star :D OR <pre>npm install svg-gauge</pre>
    </div>

    <div class="info">
      New feature! Change dial colors for different values. 
      
      <p class="warn">
      WARNING!! Some breaking changes: Gauge now uses a viewbox of 100x100 instead of previous 1000x1000. So all style stroke and font values need to be adjusted. (divide by 10)
      </p>
     
      
      <p>
        Also check out my tiny mobile view manager library for building simple SPAs
        <a target="_blank" href="https://codepen.io/naikus/pen/PKgPyN" class="link">
          
        </a>
        and 
        
        <a target="_blank" class="link" href="https://codepen.io/naikus/project/full/AzkkER">the project here</a>
      </p>
    </div>


    <script src="script.js"></script>
</body>
</html>

i have this error and no clue how to fix it.

  "message": "ReferenceError: Gauge is not defined",
  "filename": "https://stacksnippets.net/js",
  "lineno": 259,
  "colno": 22

why when I check endpoint /tasks, an error always appears “error : invalid token” even though I have entered the appropriate token that I got

this is the code that I made using javascript, express and jwt for authentication to learn restful api but I am constrained when checking in postman for endpoint /tasks, an error always appears
“error: invalid token”
even though I have entered the jwt token that matches what I got from the endpoint login

index.js

const express = require("express");
const fs = require("fs");
const jwt = require("jsonwebtoken");
const api = express();
const HOST = "localhost";
const PORT = 3000;
const SECRET_KEY = "your_secret_key"; // Ganti dengan kunci rahasia Anda

api.use(express.json());

// Fungsi untuk memuat data dari file JSON
const loadData = () => {
  const data = fs.readFileSync("data.json", "utf8");
  return JSON.parse(data);
};

// Fungsi untuk menambahkan data baru ke file JSON
const addData = (task) => {
  const tasks = loadData();
  task.id = tasks.length + 1;
  tasks.push(task);
  fs.writeFileSync("data.json", JSON.stringify(tasks));
};

// Fungsi untuk mendapatkan token JWT dari payload
const generateToken = (payload) => {
  return jwt.sign(payload, SECRET_KEY);
};

// Middleware untuk verifikasi token JWT
const verifyToken = (req, res, next) => {
  const token = req.headers["authorization"];

  if (!token) {
    return res.status(403).json({ error: "Token is required" });
  }

  jwt.verify(token, SECRET_KEY, (err, decoded) => {
    if (err) {
      return res.status(401).json({ error: "Invalid token" });
    }
    req.user = decoded;
    next();
  });
};

// Endpoint untuk registrasi (sign-up)
api.post("/register", (req, res) => {
  // Proses pendaftaran pengguna (diimplementasikan sesuai kebutuhan)
  const { username, password } = req.body;
  // Contoh sederhana, hanya menampilkan data yang didaftarkan
  res.status(201).json({ username, password });
});

// Endpoint untuk login
api.post("/login", (req, res) => {
  // Proses autentikasi pengguna (diimplementasikan sesuai kebutuhan)
  const { username, password } = req.body;
  // Contoh sederhana, hanya menampilkan token JWT
  const token = generateToken({ username });
  res.status(200).json({ token });
});

// Endpoint untuk menampilkan semua tugas (READ)
api.get("/tasks", verifyToken, (req, res) => {
  const data = loadData();
  res.status(200).json(data);
});

// Endpoint untuk menampilkan tugas berdasarkan parameter id (READ)
api.get("/tasks/:id", verifyToken, (req, res) => {
  const id = parseInt(req.params.id);
  const data = loadData()
  const task = data.filter(task => task.id == id);

  if (!task) {
    return res.status(404).json({ error: "Task not found" });
  }

  res.status(200).json(task);
});

// Endpoint untuk menambahkan tugas baru (CREATE)
api.post("/tasks", verifyToken, (req, res) => {
  addData(req.body);
  res.status(201).json(loadData());
});

// Endpoint untuk mengupdate tugas berdasarkan ID (UPDATE)
api.put("/tasks/:id", verifyToken, (req, res) => {
  const id = parseInt(req.params.id);
    const newData = req.body;
    const data = loadData();
    let updated = false;
  
    const updatedData = data.map(task => {
      if (task.id === id) {
        Object.assign(task, newData);
        updated = true;
      }
      return task;
    });
  
    if (!updated) {
      return res.status(404).json({ error: "Task not found" });
    }
  
    fs.writeFileSync('data.json', JSON.stringify(updatedData));
    res.status(200).json(loadData());
});

// Endpoint untuk menghapus tugas berdasarkan ID (DELETE)
api.delete("/tasks/:id", verifyToken, (req, res) => {
  const id = parseInt(req.params.id);
    const data = loadData();
    const newData = data.filter(task => task.id !== id);
  
    if (data.length === newData.length) {
      return res.status(404).json({ error: "Task not found" });
    }
  
    fs.writeFileSync('data.json', JSON.stringify(newData));
    res.status(200).json(loadData());
});

api.listen(PORT, () => console.log(`API running at ${HOST}:${PORT}!`));


how can I display the /tasks and /task/:id endpoints when doing a check in postman

Simulate WeChat scanning short connection redirection, but the QQ display result is different from WeChat?

I used my iOS phone WeChat to scan the code correctly, but when I scanned the code on QQ, a second pop-up window popped up before I could wait for the first one to confirm? But on Android, WeChat and QQ are both executed normally!
At first, I thought there was an issue with the QQ browser kernel, but after simulating it in QQ browser, it was still normal [PASS]
2. After research and discussion, it was initially believed that the issue was the interception of iOS’s QQ internal browser
[Attached below are the QR code, source code, and warehouse address! I hope everyone can correct me and answer my questions!]

 <script type="text/javascript">
        // 获取终端的相关信息
        var Terminal = {
            // 辨别移动终端类型
            platform : function(){
                var u = navigator.userAgent, app = navigator.appVersion;
                return {
                    trident: u.indexOf('Trident') > -1, //IE内核
                    presto: u.indexOf('Presto') > -1, //opera内核
                    webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
                    mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                    ios: !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                    // android终端或者uc浏览器
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('Adr') > -1,
                    // 是否为iPhone或者QQHD浏览器
                    iPhone: u.indexOf('iPhone') > -1 ,
                    // 是否iPad
                    iPad: u.indexOf('iPad') > -1,
                    webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
                    weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)
                    qq: u.match(/sQQ/i) == " qq" //是否QQ
                };
            }(),
            // 辨别移动终端的语言:zh-cn、en-us、ko-kr、ja-jp...
            language : (navigator.browserLanguage || navigator.language).toLowerCase()
        }
        const Doc = document.querySelector('#demo');
        const sleep = () => {
            return new Promise(resolve => {
                setTimeout(()=>{
                    alert('...判断中');
                    Doc.textContent = '判断中';
                    setTimeout(()=>{
                        resolve()
                    },1000)
                }, 1000)
            });
        }

        sleep().then(() => {
            // 根据不同的终端,跳转到不同的地址
            if(Terminal.platform.android){
                theUrl = 'ztxAndroid APP对应下载地址:apk文件地址';
                alert(theUrl)
                Doc.textContent = 'ztxAndroid';
            }else if(Terminal.platform.iPhone){
                theUrl = 'ztxiPhone APP对应下载地址:APP Store地址';
                alert(theUrl)
                Doc.textContent = 'ztxiPhone';
            }
        })
    </script>

Warehouse Address
QR code image

  1. Detection on Android and iOS real machines
  2. Simulation detection of commonly used browsers
    I am wondering if the reason for this issue is due to the built-in QQ browser in iOS (because scanning the code opens the QQ built-in browser)

Embedded TikTok posts / thumbnail styling issue

I am building an HTML/CSS/JS app that displays embedded TikTok posts. It’s a pretty simple operation – I make an API call that returns a list of post id’s, and then dynamically display the posts using the embed code provided by TikTok. I am NOT using the TikTok embed API here, I am just populating iframe elements in the DOM and updating their innerHTML with the embed code for each post ID returned by the API. The embed code is just the default that you can copy from any public post.

The issue I’m having is that the thumbnails are appearing very small, only showing half of the video image, and the user has to click on the thumbnail in order to then scroll and see the rest of the thumbnail + caption. I am not seeing anything hard-coded in the embed code that would affect the height this way, and I cannot seem to affect the height via CSS either.

Does anyone see a solution here? I have tried setting the height both in percentage and px via HTML, JS, and CSS…with literally no success in any instance.

Here is a working codepen and see below for code. Thanks in advance.

tikTokArr = [{
    post_id: "7351959206842436907"
  },

];

// Store container in variable
let tikTokContainer = document.getElementById("tik-tok-feed-container");

tikTokArr.forEach((post) => {
  const postId = post.post_id;

  const postContainer = document.createElement("div");
  tikTokContainer.append(postContainer);
  postContainer.classList.add("post");

  const postFrame = document.createElement("iframe");
  postContainer.append(postFrame);
  postFrame.classList.add("post--frame");
  postFrame.id = `tt-post__${postId}`;
  postFrame.src = `https://www.tiktok.com/embed/v2/${postId}?lang=en-US&amp`;
  postFrame.innerHTML = `<blockquote class="tiktok-embed" cite="https://www.tiktok.com/embed/v2/${postId}?lang=en-US&amp" data-video-id="${postId}" style="max-width: 605px; min-width: 325px;"><iframe
      name="__tt_embed__v6828268207359413509"
      sandbox="allow-popups allow-popups-to-escape-sandbox allow-scriptallow-top-navigation allow-same-origin"
      src="https://www.tiktok.com/embed/v2/${postId}?lang=en-US&amp;"
      style="width: 100%; height: 100%; min-height: 900px; display: block; visibility: "></iframe></blockquote>`

})
#tik-tok-feed-container {
  display: flex;
  flex-direction: row;
  row-gap: 1rem;
  column-gap: 3rem;
  padding: 1rem;
}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<div id="tik-tok-feed-container">

</div>

Horizontal Scrolling with Media Queries

I have a horizontal scroll with a map and other text, but when using the website on phone (finished media queries) this page, and all the other pages seem to add extra height, or not show the full height of the page due to the search bar still showing. For this specific horizontal scrolling page, I have the height set to unset, but I cannot change it otherwise the horizontal scroll will not work. Is there any solution to making sure that the search bar of the browser doesn’t add any extra height to the page?

html {
  overflow-x: scroll;
  height: 100%;
}

body {
  overflow-y: hide;
  position: absolute;
  height: unset;
  background: black;
}

html, body {
  overflow-x: hidden;
  margin: 0;
}

This is what I have in the horizontal scroll page…