liveui option of videojs seeking is not working on Chrome browser of android (rest all platforms its working good)

I am unable to see the liveui seek bar in android.
As given in official documentation of videojs ;
“Note: This user interface will not work on Android due to the native live HLS implementation not supporting seekable ranges during live streams. We recommend overriding the native hls implementation with @videojs/http-streaming; this will make the new liveui work.”

But I coundnt find anything to do the same.

These are the options which i have given.

var options = {
    preload: true,
    autoplay: false,                       
    controls: true,
    liveui: true,
    preloadWebComponents: true,
    techOrder: [ 'chromecast', 'html5' ],
    controlBar: {
        'liveDisplay': true,
        'pictureInPictureToggle': false,
        'subsCapsButton': false,
    },
   
};'''

https://docs.videojs.com/tutorial-live.html
[1]: https://i.stack.imgur.com/xs3bP.png

Imgur image uploading through api not working

I’m trying to build a blog website, so I wanted to upload images to imgur and retrieve the link for the image. But when I try to upload image using the below code, the images are not uploading. Is there anything wrong in my code? Or is there any better way to do the same?

This is the code that I’m using.

<input type="file" accept="image/*">


        <script src='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.js'></script>
        <script type="text/javascript">
            $('document').ready(function () {
            $('input[type=file]').on('change', function () {
                var $files = $(this).get(0).files;

                if ($files.length) {
                // Reject big files
                if ($files[0].size > $(this).data('max-size') * 1024) {
                    console.log('Please select a smaller file');
                    return false;
                }

                // Begin file upload
                console.log('Uploading file to Imgur..');

                // Replace ctrlq with your own API key
                var apiUrl = 'https://api.imgur.com/3/image';
                var apiKey = 'b985f2a2610584c';

                var settings = {
                    async: false,
                    crossDomain: true,
                    processData: false,
                    contentType: false,
                    type: 'POST',
                    url: apiUrl,
                    headers: {
                    Authorization: 'Client-ID ' + apiKey,
                    Accept: 'application/json',
                    },
                    mimeType: 'multipart/form-data',
                };

                var formData = new FormData();
                formData.append('image', $files[0]);
                settings.data = formData;

                // Response contains stringified JSON
                // Image URL available at response.data.link
                $.ajax(settings).done(function (response) {
                    console.log(response);
                });
                }
            });
            });
        </script>

Btw i’m using flask to build my website.
Thanks in advance.

Creating Two Modals With the same Style

Good day all.

So I have been trying to create an additional modal for my website. The first modal is on the home page, and the second modal is on the service page. but after writing the codes, only the first one works fine, and the second modal on my service page doesn’t work well.

Here are the codes:

  1. Html for modal 1 on home page

     <div class="nippy-modal-header">
       <h3 style="font-weight: bold;">More Technologies & Frameworks <span id="nippy-closeBtn" class="nippy-closeBtn">&times;</span></h3>
    
     </div>
    
     <div class="nippy-modal-body">
       <p>
         The technologies and applications that is use varies, depending on the nature of the Job.
         I can use Wix or Shopify to create the perfect E-Commerce for you.
       </p>
       <p>
         The list goes on. Javascript frameworks include: React.js, Node.js, Express.js and we keep exploring this wonderful technology.
       </p>
     </div>
    
     <div class="nippy-modal-footer">
       <a href="services.html"><button type="button" class="nippy-button">See My Services<i class="fa-solid fa-arrow-right"></i></button></a>
     </div>
    
  2. HTML for modal 2 on service page:

       <div class="gModalHeader">
         <h3 style="font-weight: bold;">Graphics & Branding <span id="gModalCloseBtn" class="gModalCloseBtn">&times;</span></h3>
    
       </div>
    
       <div class="gModalBody">
         <ol>
           <li>Logos</li>
           <li>UI Interface Design and Development</li>
           <li>Flyers</li>
           <li>Branding</li>
           <li>Buisness/Complementary Cards</li>
           <li>Merchs and Mockups</li>
         </ol>
       </div>
    
       <div class="gModalFooter">
         <a href="index.html#hire-me"><button type="button" class="nippy-button">Hire Me<i class="fa-solid fa-arrow-right"></i></button></a>
       </div>
    
     </div>
    
  3. Javascript for modal one:

    // Get All Elements
    const modal = document.getElementById(“nippy-modal”);
    const seeMoreBtn = document.getElementById(“nippy-modalBtn”);
    const closeBtn = document.getElementById(“nippy-closeBtn”);

    // Listen for open click
    seeMoreBtn.addEventListener(“click”, openModal);
    // Listen For Close click
    closeBtn.addEventListener(“click”, closeModal);

    // function to open modal
    function openModal() {
    modal.style.display = “block”;
    }
    // function to Close modal
    function closeModal() {
    modal.style.display = “none”;
    }

  4. Javascript for modal Two:

    var gModal = document.getElementById(“gModal”);
    var gSeeMoreBtn = document.getElementById(“gModalBtn”);
    var gCloseBtn = document.getElementById(“gModalCloseBtn”);

    // Listen for open click
    gSeeMoreBtn.addEventListener(“click”, gOpenModal);
    // Listen For Close click
    gCloseBtn.addEventListener(“click”, gCloseModal);

    // function to open modal
    function gOpenModal() {
    gModal.style.display = “block”;
    }
    // function to Close modal
    function gCloseModal() {
    gModal.style.display = “none”;
    }

Add AOS attributes by Javascript

I am trying to add the attributes to launch AOS animations via javascript, but it is not working correctly. Now, adding the attributes by js, when the animation is launched, instead of showing the element, it hides it. I think it may be because the element is rendered first, and js acts after adding the AOS attributes, so the animation does it in reverse for me. this is my code to add AOS attr:

var hero = document.getElementById('main-hero');
hero.setAttribute('data-aos', 'fade-up');

Is there any way to add AOS by js and have it work? add it on HTML is currently unvailable for accessibility.

The JavaScript array not showing expected result in HTML [duplicate]

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遊戲選購</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    
</head>
<body>
    <script>
        var name = new Array("PS4","Switch","Xbox")
        var price = new Array(9980, 12999, 11000)
        var imgfile = new Array("ps4.jpg", "switch.jpg", "xboxone.jpg")
        document.write("<table class='table table-hover'>");
        document.write("<tr class='table-warning'>");
        document.write("<td>品名</td>");
        document.write("<td>單價</td>");
        document.write("<td>產品圖示</td>");
        document.write("</tr>");
        for (var i = 0; i < name.length; i++) {
            document.write("<tr>");
            document.write("<td>" + name[i] + "</td>");
            document.write("<td>" + price[i] + "</td>");
            document.write("<td><img src='images/" + imgfile[i] + "' class='img-thumbnail' width='150'></td>");
            document.write("</tr>");
        }
        document.write("</table>");
   </script>

    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>

When I try to create an array name with 3 items inside, the array splits into each letter instead of three elements only. In the table, I am going to show the three items in document.write("<td>" + name[i] + "</td>"); that each item uses a row instead of breaking each letter. Anyone knows where is the problem?

different text color in text area [duplicate]

how can i give text a color defined in JavaScript

like if apple in text area it outputs to red same as market in green

<!DOCTYPE html>
<html>
<head>

</head>
<body>


    
  <textarea class="custom-area" id="myTextArea"> apple market</textarea>

    <script type="text/javascript">

const colorMap = {"apple": "red", "market": "green"};
let textArea = document.getElementById("myTextArea");

function applyColors(text)
{
    let re = new RegExp(Object.keys(colorMap).join("|"), "gi");

    return text.replace(re, function(m)
    {
        let c = colorMap[m.toLowerCase()];
        return `<spam style="color:${c}">${m}</spam>`;
    });
}
    </script>
</body>
</html>

How to push to History in React Router Dom v6

I tried many times but couldn’t upgrade my code to make push.history work properly.

here is my old code with react-router-dom v5:

This code perfectly works in the previous version but as I upgraded to v6 I don’t know what will be the replacement of withRouter and push.history in the new version.

import React from 'react'
import { withRouter } from 'react-router-dom'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import TextFieldGroup from '../common/TextFieldGroup'
import TextAreaFieldGroup from '../common/TextAreaFieldGroup'
import SelectListGroup from '../common/SelectListGroup'
import InputGroup from '../common/InputGroup'
import { createProfile } from '../../actions/profileActions'

class CreateProfile extends React.Component{
    constructor( props ) {
        super(props)

        this.state = {
            displaySocialInputs: false,
            handle: '',
            company: '',
            website: '',
            location: '',
            status: '',
            skills: '',
            githubusername: '',
            bio: '',
            twitter: '',
            facebook: '',
            linkedin: '',
            youtube: '',
            instagram: '',
            errors:{}
        }


        this.onChange = this.onChange.bind(this)
        this.onSubmit = this.onSubmit.bind(this)

    }

    UNSAFE_componentWillReceiveProps( nextProps ) {
        if ( nextProps.errors ) {
            this.setState(()=>({ errors: nextProps.errors }))
        }
    }
    onSubmit( e ){
        e.preventDefault()
        
        const profileData = {
            handle: this.state.handle,
            company: this.state.company,
            website: this.state.website,
            location: this.state.location,
            status: this.state.status,
            skills: this.state.skills,
            githubusername: this.state.githubusername,
            bio: this.state.bio,
            twitter: this.state.twitter,
            facebook: this.state.facebook,
            linkedin: this.state.linkedin,
            youtube: this.state.youtube,
            instagram: this.state.instagram,
        }

        this.props.createProfile( profileData , this.props.history )
    }

    onChange( e ) {
        e.persist()
        this.setState(()=>({ [ e.target.name ]: e.target.value }))
    }

    render(){

        const options = [
            { label: 'وضعیت حرفه ای خود را انتخاب فرمایید *' , value : 0 },
            { label: 'برنامه نویس' , value : 'برنامه نویس' },
            { label: 'برنامه نویس مبتدی' , value : 'برنامه نویس مبتدی' },
            { label: 'برنامه نویس با تجربه' , value : 'برنامه نویس با تجربه' },
            { label: 'مدیر' , value : 'مدیر' },
            { label: 'درحال یادگیری' , value : 'درحال یادگیری' },
            { label: 'مدرس' , value : 'مدرس' },
            { label: 'دانشجو' , value : 'دانشجو' },
            { label: 'سایر' , value : 'سایر' }

        ]

        const { errors , displaySocialInputs } = this.state
        let socialInputes

        if ( displaySocialInputs ) {
            socialInputes = (
                    <div>
                        <InputGroup 
                            placeholder="آدرس شبکه توئیتر"
                            name="twitter"
                            icon="fab fa-twitter"
                            value={this.state.twitter}
                            onChange={this.onChange}
                            error={errors.twitter}
                        />


                        <InputGroup 
                            placeholder="آدرس شبکه فیسبوک"
                            name="facebook"
                            icon="fab fa-facebook"
                            value={this.state.facebook}
                            onChange={this.onChange}
                            error={errors.facebook}
                        />

                        <InputGroup 
                            placeholder="آدرس شبکه لینکدن"
                            name="linkedin"
                            icon="fab fa-linkedin"
                            value={this.state.linkedin}
                            onChange={this.onChange}
                            error={errors.linkedin}
                        />


                        <InputGroup 
                            placeholder="آدرس شبکه یوتیوب"
                            name="youtube"
                            icon="fab fa-youtube"
                            value={this.state.youtube}
                            onChange={this.onChange}
                            error={errors.youtube}
                        />


                        <InputGroup 
                            placeholder="آدرس شبکه اینستاگرم"
                            name="instagram"
                            icon="fab fa-instagram"
                            value={this.state.instagram}
                            onChange={this.onChange}
                            error={errors.instagram}
                        />

                    </div>
            )
        }

        return (
            <div className="create-profile">
                <div className="container">
                    <div className="row">
                        <div className="col-md-8 m-auto">
                            <h1 className="display-4 text-center">ساخت پروفایل شما</h1>
                            <p className="lead text-center">یک معرفی خوب وصعت کارتان را بیشتر می کند</p>
                            <small className="d-block bp-3 text-right">فیلدهای ستاره دار * اجباری می باشند</small>
                            <form onSubmit={ this.onSubmit }>

                                <TextFieldGroup 
                                    placeholder="هندلر پروفایل *"
                                    name="handle"
                                    value={this.state.handle}
                                    onChange={this.onChange}
                                    error={errors.handle}
                                    info="منظور از handle داشتن URL اختصاصی پروفایل شماست"
                                />


                                <SelectListGroup 
                                    placeholder="وضعیت"
                                    name="status"
                                    value={this.state.status}
                                    onChange={this.onChange}
                                    error={errors.status}
                                    options={options}
                                    info="تصویری از وضعیت کنونی شما"
                                />

                                <TextFieldGroup 
                                    placeholder="شرکت"
                                    name="company"
                                    value={this.state.company}
                                    onChange={this.onChange}
                                    error={errors.company}
                                    info="شرکت خودتان یا جایی که در آنجا مشغول به کار هستید"
                                />

                                <TextFieldGroup 
                                    placeholder="وب سایت"
                                    name="website"
                                    value={this.state.website}
                                    onChange={this.onChange}
                                    error={errors.website}
                                    info="وب سایت خودتان یا جاییکه کار می کنید"
                                />

                                <TextFieldGroup 
                                    placeholder="محل"
                                    name="location"
                                    value={this.state.location}
                                    onChange={this.onChange}
                                    error={errors.location}
                                    info="شهر یا استان و شهر"
                                />

                                <TextFieldGroup 
                                    placeholder="مهارت ها *"
                                    name="skills"
                                    value={this.state.skills}
                                    onChange={this.onChange}
                                    error={errors.skills}
                                    info="برای جدا سازی عبارت ها از کاما استفاده کنید html, css, js, php"
                                />


                                <TextFieldGroup 
                                    placeholder="نام کاربری شما در گیت هاب"
                                    name="githubusername"
                                    value={this.state.githubusername}
                                    onChange={this.onChange}
                                    error={errors.githubusername}
                                    info="برای ایجاد ارتباط و دسترسی به مخازن عمومی شما لطفا نام کاربری خودتان را وارد فرمایید"
                                />

                                <TextAreaFieldGroup 
                                    placeholder="مختصری از خودتان"
                                    name="bio"
                                    value={this.state.bio}
                                    onChange={this.onChange}
                                    error={errors.bio}
                                    info="لطفا توضیح مختصری از خودتان برای علاقمندان خودتان بنویسد"
                                />

                                <div className="mb-3 text-right">
                                    <button
                                        type="button"                                        
                                        className="btn btn-light" onClick={ () => {
                                        this.setState(( prevState)=>({ displaySocialInputs: !prevState.displaySocialInputs }))
                                    }}>
                                                اضافه کردن کانکشن در مدیا
                                    </button>
                                    <span className="text-muted">اختیاری میباشد</span>
                                </div>
                                        { socialInputes }
                                        <input type="submit" value="ثبت" className="btn btn-info btn-block mt-4" />
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}

CreateProfile.propTypes = {
    profile: PropTypes.object.isRequired,
    errors: PropTypes.object.isRequired
}

const mapStateToProps = ( state ) => {
    return {
        profile: state.profile,
        errors: state.errors
    }
}

export default connect( mapStateToProps , { createProfile })( withRouter( CreateProfile ) )

My action files

export const createProfile = ( profileData , history ) => ( dispatch ) => {
  axios.post( '/api/profile' , profileData )
  .then(( result ) =>{
    history.push('/dashboard') 
  }).catch(( errors )=> {
    dispatch({
      type: GET_ERRORS,
      payload: errors.response.data
    })
  })
}

Spring Boot Stripe Payment Integration

I am developing a web application where a user can buy a course for learning. For payment, I am trying to implement Stripe payment gateway. I am a beginner in implementation of payment gateway.
I am unaware and bit confused that where should I start from. I have custom payment form where I am taking cardholder name, card number, CVV, card expiration date and a static amount to buy that course. I want to persist credit card data like card number, expiry date and customer ID into my database (MySql). I have public and secret key (test-mode). I have configured both keys in my application.yml file.

Below is my controller where I have written checkout function:

@RequestMapping(value= {WebUrl.checkout},method= {RequestMethod.GET,RequestMethod.POST})
    public ModelAndView checkout(HttpServletRequest request, HttpSession session) {
        ModelAndView modelAndView = null;
        User loginuser = (User) session.getAttribute("user");
        if(loginuser == null) {
            modelAndView = new ModelAndView("redirect:.."+WebUrl.studentlogin);
        }else {
            modelAndView = new ModelAndView(WebUrl.checkout);
            modelAndView.addObject("loginuser", loginuser);
            modelAndView.addObject("amount", 1);
            modelAndView.addObject("stripePublicKey", stripePublicKey);
            modelAndView.addObject("currency", ChargeRequest.Currency.USD);
        }
        return modelAndView;
    }

Below is my StripePayment service class:

public Charge createCharge(String userid, String token, int amount, String cardnumber, String cardexpirydate) {
    Charge chargeObj = null;
        try {
            Long uid = Long.parseLong(userid);
            User userById = userDao.findByUserid(uid);
            if(userById != null) {
                String email = userById.getEmail();
                Map<String, Object> chargeParams = new HashMap<>();
                chargeParams.put("description","Charge for "+email);
                chargeParams.put("currency",chargeRequest.getCurrency());
                chargeParams.put("amount", amount);
                chargeParams.put("source",chargeRequest.getStripeToken());
                
                chargeObj = Charge.create(chargeParams);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return chargeObj;
    }
}

Below is my API for payment:

@RequestMapping(value = ApiUrl.createCharge, method = { RequestMethod.POST, RequestMethod.GET }, produces = {MediaType.APPLICATION_JSON_VALUE })
    public ResponseEntity<?> createCharge(HttpServletRequest request, HttpSession session, @PathVariable("token") String token, @PathVariable("cardExpiryDate") String cardexpiry, @PathVariable("userid") String userid, @PathVariable("cardNumber") String cardnumber) {
        CustomResponse = ResponseFactory.getResponse(request);
        try {
            if(token == null || token == "") {
                CustomResponse.setResponse("Stripe payment token is missing. please try again later.");
                CustomResponse.setStatus(CustomStatus.Error);
                CustomResponse.setStatusCode(CustomStatus.Error_CODE);
                CustomResponse.setResponseMessage(CustomStatus.ErrorMsg);
            }
            Charge charge = stripeService.createCharge(userid, token, 100, cardnumber, cardexpiry);//1 usd or 100 cents
            Long uid = Long.parseLong(userid);
            User user = userDao.findByUserid(uid);
            UserPayment paymentByUser = new UserPayment();
            if(cardexpiry != null || cardexpiry != "") {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Date date = sdf.parse(cardexpiry);
                paymentByUser.setCardExpiryDate(date);
            }
            paymentByUser.setCardNumber(cardnumber);
            paymentByUser.setUserid(user);
            paymentByUser.setAmount(chargeamount.doubleValue());
            UserPayment payment = userPaymentDao.save(paymentByUser);
            if (charge != null && payment != null) {
                CustomResponse.setResponse("Success your charge id is "+charge);
                CustomResponse.setStatus(CustomStatus.OK);
                CustomResponse.setStatusCode(CustomStatus.OK_CODE);
                CustomResponse.setResponseMessage(CustomStatus.SuccessMsg);
            }
        } catch (Exception e) {
            e.printStackTrace();
            CustomResponse.setResponse(null);
            CustomResponse.setStatus(CustomStatus.Error);
            CustomResponse.setStatusCode(CustomStatus.Error_CODE);
            CustomResponse.setResponseMessage(CustomStatus.ErrorMsg);
        }
        return new ResponseEntity<ResponseDao>(CustomResponse, HttpStatus.OK);
    }

**I am confused here whether I am missing something or not. Please suggest me.**What should be major steps to follow for Stripe payment gateway implementation?
enter image description here

Hide jquery slide arrows and make appear in mobile version of website

I trying to make this thing, for example, on the first section of FullPage.js website there is three slides. On the default settings there are control arrows on the right and left, and that’s okay. But, I want to make this arrows appear only on mobile version of website. For example, on the desktop there is no slides, just first one with all information, and on the mobile there is 3 slides so I can navigate with. How can I do this?
I know there is “controlArrows: false,” option, but I wanna disable controlArrows only on desktop!

Why does formData not work in axios 0.26.1 in react native Android emulator?

I have use expo-image-picker and axios 0.26.1. formData in axios version 0.26.1 isn’t work. when using formData, data is not sent to the api

enter image description here

downgrade axios to version 0.24.0 but I get this error when sending formData in Android emulator.

Error: Network Error

formData:

enter image description here

export const sendRequest = (url, response, method, formData) => {
  return axios({
    url,
    method,
    data: method !== "get" ? formData : null,
    headers: {
      Authorization: `Bearer ${response.data.access}`,
      headers: { "Content-Type": "multipart/form-data" },
      transformRequest: (data, headers) => {
        return formData;
      },
    },
  });

const formData = new FormData();
const imageUri = image.value.uri;
const newImageUri = "file:///" + imageUri.split("file:/").join("");

formData.append("photo", {
  uri: newImageUri,
  type: mime.getType(newImageUri),
  name: newImageUri.split("/").pop(),
});

data.append("title", title);

can you help me please?

Display JavaScript function output on webpage using getElementByID

Hei.

I have made a JavaScript function that will convert input (UPPER CASE LETTERS) using ROT13. Problem is that the output will not show as a “paragraph” on the .html page when the letters are submittet to the function. All files is saved in the same folder and using XAMP for testing.

HTML code:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Caesars Cipher Converter</title>
        <link rel="stylesheet" href="index.css">
    </head>
    <body>
        <h1>Caesars Cipher Converter (freeCodeCamp project for JavaScript)</h1>
        <h3>Description</h3>
        <p> <!-- Add an anchor/link to wikipedia in the description-->
            Input letters into the input field and press submit. The JavaScript code that I have 
             made will convert the letters using <strong><a href="https://en.wikipedia.org/wiki/ROT13">ROT13.</a></strong>
        </p> 
        <p>     
            NB: Only uppercase letters are allowed. 
        </p>
        <form>
            <label for="Input">Input</label>
            <input type="text" id="input" required> 
            <!-- Adding the submit putton that activate the rot 13 converter javascript function when clicked -->
            <button type="button" onclick="rot13()">Submit</button>
        </form>
        <p id="output"></p>
        <!-- Here comes the external javascript import -->
        <script src="ROT13_converter.js"></script>
    </body>
</html>

JavaScript code:

var alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M'];
var oppAlph = ['N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];

function rot13() {
  var str = document.getElementById("input").value;
  var newStr = str.split("");
  for (let i = 0; i < newStr.length; i++) {
    for (let j = 0; j < alphabet.length; j++) {
      if (newStr[i] === alphabet[j]) {
        newStr[i] = oppAlph[j];
      } else if (newStr[i] === oppAlph[j]) {
        newStr[i] = alphabet[j];
      }
    }
  }
  document.getElementById("output").innerHTML = newStr.join("");

}

Here is a similar project i made just with roman number convertion (I want the same ouput):
Preview (Roman number convertion)

Update a obj list in js with a form and show it in HTML page

I have a HTML page with a form and a table.
In a js file I have a list of objects (JSON) and with this list I populate the table when the page loads.

The form should allow me to add an element to the list and then display it as a new row in the table.

This is my js file:

var data = [
    {
        "first_name": "John",
        "last_name": "Smith",
        "email": "[email protected]",
        "job": "CEO",
        "agree": true
    },
    {
        "first_name": "Marie",
        "last_name": "Curie",
        "email": "[email protected]",
        "job": "Researcher",
        "agree": true
    }];
populateTable();
function populateTable() {
    var out = "<table><tr>"
        + "<th>First Name</th><th>Last Name</th>"
        + "<th>Email</th>"
        + "<th>Job</th><th>Agree</th></tr>";
    var i;
    for (i = 0; i < data.length; i++) {
        out += '<tr><td>' + data[i].first_name + '</td><td>' + data[i].last_name + '</td><td>'
            + data[i].email + '</td><td>' + data[i].job + '</td><td>' + data[i].agree + '</td></tr>';
    }
    document.getElementById("showData").innerHTML = out;
};

function collectData(){
    var TestName = document.getElementById("fname").value;
    var TestSurname = document.getElementById("lname").value;
    var TestEmail = document.getElementById("email").value;
    var TestJob = document.getElementById("job").value;
    var TestAgree = document.getElementById("agree_terms").value;
    
    //insert this data on JSON file
    var jsonObject = {
        "first_name": TestName, 
        "last_name": TestSurname,
        "email": TestEmail,
        "job": TestJob,
        "agree": TestAgree
    };
    data.push(jsonObject);
}

I tried to push the new element on the list but naturally the code reload the function populateTable() without considering this new element.

Ho can I resolve it?

how create loop with jquery

It is a Google web design code with custom function.
I need to delate moltiple image by mouse. When the user go out the image the first image need to be delate, when the user go again inside the document, he is able to delate the follow image.

My problem is that whe the user go out the document all the image are going to be delay..

  1. I need to select different image by Css ID –> WHR
  2. somethings don’t work. I’m looking for a different solution.
        
      //var MAX = 3;
     var i = 1;
     gwd.image2 = function(e) {
          var i = 1;
          var whr = "#gwd-image_"+ i;
          var whr2 = "#gwd-image_"+ (i+1);
             
            $(document).mousemove(function(e) {
            
             console.log(whr);
              
              $(whr).css({
                left: e.pageX - 150,
                top: e.pageY - 125,
              }, 10);
             
           
              $(whr).css("-webkit-transform", "rotate(" + (e.pageX - 150) / 10 + "deg)");
              
              $(document).mouseout(function(e) {
                $(whr).animate({
                  left: (e.pageX - 150) * 3 + 'px'
                }, "fast", function() {

                  gwd.actions.events.setInlineStyle('gwd-image_1', 'display: none;');
                  i = i+1;
                })
              })
              })
        
        }
    
      <script type="text/javascript" gwd-events="registration">
    // Support code for event handling in Google Web Designer
    // This script block is auto-generated. Please do not edit!
    gwd.actions.events.registerEventHandlers = function(event) {
   
      gwd.actions.events.addHandler('gwd-taparea_image1', 'mousemove', gwd.image2, false);
    };
    gwd.actions.events.deregisterEventHandlers = function(event) {
      gwd.actions.events.removeHandler('gwd-taparea_1', 'mousemove', gwd.auto_Gwd_taparea_1Touchenter, false);
      gwd.actions.events.removeHandler('gwd-taparea_image1', 'mousemove', gwd.image2, false);
    };
    document.addEventListener("DOMContentLoaded", gwd.actions.events.registerEventHandlers);
    document.addEventListener("unload", gwd.actions.events.deregisterEventHandlers);
  </script>
    
    ```

   In Body there are four image that I need to delate with mouse moviment.

    ```
      <body>
      ...


        
            <div class="gwd-page-content gwd-page-size">
              <gwd-image id="gwd-image_3" source="assets/SO-91650-Solferino_Tamaro_01.03-30.03_300X250.jpg" scaling="stretch" class="gwd-image-1s8p"></gwd-image>
              <gwd-image id="gwd-image_2" source="assets/SO-91650-Solferino_Panebianco_01.03-
              <gwd-image id="gwd-image_1" source="assets/SO-91650-Solferino_Sinclair_05.03-05.04_300X250.jpg" scaling="stretch" class="gwd-image-on7n"></gwd-image>
              <gwd-taparea id="gwd-taparea_image1" class="gwd-taparea-odyq" data-gwd-name="tap_image1"></gwd-taparea>
              <gwd-taparea id="gwd-taparea_1" class="gwd-taparea-f0yc" data-gwd-name="first_interaction" data-gwd-tl-hidden=""></gwd-taparea>
            </div>
          ---
       </body>

        ```



React PropTypes – OR

For this code:

const FirstComponentPropTypes = {
   foo: PropTypes.any,
};

const SecondComponentPropTypes = {
   bar: PropTypes.any,
};

...

function MyComponent({ foo, bar }) { ... }

In order to set the propTypes of MyComponent, is it possible to do something like:

MyComponent.propTypes = FirstComponentPropTypes | SecondComponentPropTypes;

?

Transforming MediaStream in an ended state

I am trying to apply some transformations on the video frames of an ended MediaStreamTrack. I tried using the MediaStreamTrack Insertable Media Processing using Streams API:

const stream = await navigator.mediaDevices.getDisplayMedia({ video: true });
stream.addEventListener(streamEndedEvent, async () => {
    const videoTrack = stream.getVideoTracks()[0];
    const trackProcessor = new MediaStreamTrackProcessor({ track: videoTrack });
    const trackGenerator = new MediaStreamTrackGenerator({ kind: 'video' });

    const transformer = new TransformStream({
        async transform(videoFrame, controller) {
            const newFrame = await transform(videoFrame);
            videoFrame.close();
            controller.enqueue(newFrame);
        }
    });

    trackProcessor.readable.pipeThrough(transformer).pipeTo(trackGenerator.writable);
    // use the transformed stream here
});

I am getting an error when trying to construct the MediaStreamTrackProcessor object:

Uncaught (in promise) TypeError: Failed to construct 'MediaStreamTrackProcessor': Input track cannot be ended

If MediaStreamTrackProcessor cannot be used, is there some other API that would allow me to parse the constituent frames of a MediaStream, apply some transformation on them and create a new stream?