HTML5 File Input customization on label giveing Keyboard accessibility issue

If we hide the HTML File Input element and customize its lable then when we test for keyboard accessibility check there is no focus border is coming
Although the file system window is opeining when we press keyboard’s tab and then enter but no indication on screen when the window is opening.

Is there any way to highlight or add focus to the input without showing it in the screen as it is hidden and the css is given to the input label. The functionality works fine but it fails when it comes to accessibility issue.

I have tried using position absolute like that but the its not working as the input is hidden and has no width and hight

Html

<form class="form" id="fileForm" enctype="multipart/form-data">
    <label for="uploadButton" class="file__label">
        upload File
    </label>
    <input type="file" accept="text/csv" id="uploadButton" name="fileInput" class="file__input">
</form>

css

.form {
  width: 180px;
}
.form .file__label {
  font-weight: normal;
  cursor: pointer;
  width: 180px;
  vertical-align: middle;
  text-align: center;
  padding: 11px 0;
  background-color: #ffffff;
  color: #5e10b1;
  border: 1px solid #5e10b1;
  margin: 0;
}

.form .file__label:hover {
  background-color: #f6f3f9;
  outline: none;
  border: 1px solid #5e10b1;
  text-decoration: underline;
}
.form:focus {
  outline: 0;
}
.form:focus .file__label {
  outline: 2px solid #ffbf47;
}
.form .file__input {
  height: 0;
  width: 0;
  overflow: hidden;
}

How do I stop the second prompt from appearing until the first if/else condition is satisfied? (Start Page for a game)

If the user name is not entered, the age prompt still comes up, I want the whole prompt to terminate if the user name is not entered, basically, when it says “You cannot proceed without the name” after that the prompt asking for the age still appears, I don’t want that to happen.

Here is my code:

</style>

<body>
<h1>Welcome to </h1>
<h2> Hangman </h2>
<div class="wrapper">
  <button onclick="myFunction()">Let's start</button>
</div>

<script>
  function myFunction() {
  let person = prompt("Please enter your name", "Marium");
  if (person == null || person == "") {
  alert("You cannot proceed without entering the name");
  } 
  else {
  alert("Hello " + person);
  }
   
   let age= prompt("Please enter your age"); 
  if (age<16) { 
   alert("User below 16 cannot proceed");
   }
    else {
   window.location.href= "sample.html";
   }
}

display input type=file at multiple place in a form

In my form there are several places where I need to upload image & display the same
so how can I do the same please help

function previewImage(){
    var file = document.getElementById("file").files;
    var fileReader = new FileReader();
    fileReader.onload = function(event){
        document.getElementById("display").setAttribute("src", event.target.result);
    }
    fileReader.readAsDataURL(file[0])
};
<input type="file" id="file" accept="image/*" onchange="previewImage();">
<img id="display" class="w-50">

the html code is multiple time in my code calling the same function but it display only at first input field.

Count the number of booleans (JavaScript)

Let my object have the following data:

{
  mongoose: {
    name: "Starky",
    age: 3,
    playful: false
  },
  dog: {
    name: "Maks",
    age: 7,
    playful: false
  },
  parrot: {
    name: "Petty",
    age: 4,
    playful: true
  }
}

How can i count the number of booleans?
I know that I can use .reduce, but I didn’t understand exactly how to use it correctly, in an attempt to use it, I just got undefined.

ReactJS, Google Picker API, Upload folders recursively

I have set up the react project, and am able to play with the google picker properly, Now I want to upload the complete folder (i.e. recursively, upload all the subfolders if there are any). But it is allowing to upload files only, I want to upload a complete folder, recursively as well if it has any subfolder.

` backtick not allowed in Flask + JavaScript

I have an html code main.html, part of it is (where the error is caused):

<script>
document.onkeydown = function(event) {
  var thecircle = document.getElementById('circle');
    event = event || window.event;
    if (event.keyCode == 38) {
      size = Math.min(390, Math.max(40, size + 50));
        thecircle.src = "{{ url_for('static', filename=`red_circle_${size * 2}.png`) }}";
        thecircle.height = size
        clickEvent({'clientX': x, 'clientY' : y})
    } else if (event.keyCode == 40) {
      size = Math.min(390, Math.max(40, size - 50));
      thecircle.src = "{{ url_for('static', filename=`red_circle_${size * 2}.png`) }}";
      thecircle.height = size
      clickEvent({'clientX': x, 'clientY' : y})
    }
};
</script>

And a Python code with flask app.py, part of it is:

@app.route('/')
def index():
    return render_template('main.html', static_folder='static')

But it doesn’t let me run the Flask app because it doesn’t like the string formatting:

jinja2.exceptions.TemplateSyntaxError: unexpected char '`' at 1487

And the app doesn’t even open… How do I fix this?

How to detect if current window is behind another application, using Javascript

Same like facebook on web browser. If you open another application like going to computer dashboard or any app, the video on Facebook will pause, when you switch back to browser the video will resume.

Page Visibility API, onFocus, hasFocus and onBlur are working only if the user switches between the browser tabs.

I want to listen when the user switches away from browser to another application while browser still open on background. Be able to tell full visibility of current page.

It should be possible, same feature is working on facebook Web from the browser.

Axios Bad Request 400

That is my axios code but is throwing me a error of Request failed with status code 400

import axios from "axios";
import { BASE_URL } from "../../enums/baseUrl";
import { UploadUrls } from "../../enums/imageupload/urls";


import { axiosInstance } from "../config";

export const upload = async (formData: FormData
  ): Promise<string> => {
    const { data } = await axiosInstance.post(
      `${BASE_URL.DEVELOPMENT}/${UploadUrls.UPLOAD}`, formData, {
        headers: { 'Authorization': 'Bearer ************', 
        'Content-Type': 'multipart/form-data' },
        transformRequest: formData => formData,
      });
  
    return data;
  };
  

Expo – Remote Config: Indexed DB is not supported by current browser

I have an expo app and tried to add Firebase support to use their remote-config service. I am testing it in this code

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getRemoteConfig } from "firebase/remote-config";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
    apiKey: "aaaaaaaaaaaaaaaaaaa",
    authDomain: "bbbbbbbbbbbbbbbb",
    projectId: "ccccccccccc",
    storageBucket: "ddddddddddddddddddddddddddd",
    messagingSenderId: "eeeeeeeeeeeeeeeee",
    appId: "fffffffffffffffffffff",
    measurementId: "gggggggggggggggggg"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
export const config = getRemoteConfig(app);
config.settings.minimumFetchIntervalMillis = 3600000;
config.defaultConfig = {
    "test": "Welcome222222"
};
config.getValue("test");

But when i try to run it in Expo Go on Android emulator, i get

FirebaseError: Remote Config: Indexed DB is not supported by current browser (remoteconfig/indexed-db-unavailable)

Is there a way to not use any Indexed DB? I thought that the library would just let me use the remote config REST api confortably and i could just send requests, i have no need for any DB in this case.

I get a syntax error on this code for my slideshow

I’m not sure where I am going wrong with this and it is really bugging me.

Can someone help?

enter code here

”’

”’
let slideIndex = 0;
”’
showSlides();
”’
function showSlides() {
”’
let i;
”’
let slides = document.getElementsByClassName(“mySlides”);
”’
let dots = document.getElementsByClassName(“dot”);#
”’
for (i = 0; i slides.length) {slideIndex = 1}
”’
for (i = 0; i

;;;

The part in bold is the syntax error.

The Values given from Prompt and used in for loop is not working [duplicate]

I am Beginner in Javascript, and created a program Adding Indeces of an Array numbers would come equal to the target given, and Printing the indeces as an output.

eg – Input is nums array= [1,2,3,4,5] and target = 9
adding 3th & 4th element would give the target value (5+4=9), so output would be 3,4

If i pass the values from Prompt, the code is not working. However if i pass the values directly, the code is working fine. I do not know why is this happening, is there any concept, that i am lacking. Please give your suggestions 🙂

Code is Below:

// taking array from user
let nums = [];
let size = 5; // Array size 

for (let a = 0; a < size; a++) {
    nums[a] = prompt('Enter array Element ' + (a + 1));
}

// taking Sum Target from user
let sum = prompt("Enter the Sum Target");

for (let i = 0; i < nums.length; i++) {
    for (let j = i + 1; j < nums.length; j++) {
        if (nums[i] + nums[j] === sum) {
            alert(`The Two indices are ${i} and ${j}`);
        }
    }
}

Mui Datepicker calls onChange during click outside

I have 2 datepickers on my page,when I select a date on them, and then, after closing the picker, click on input again, the data resets to minDate or ,if its not defined, to null. I provided code samples below. Also during research I found out that onChange event is firing during this, and I don’t understand why it happens

  const startDateFilter = useSelector(selectStartDateFilter);
  const endDateFilter = useSelector(selectEndDateFilter);
  const [endDatePickerOpen, setEndDatePickerOpen] = useState(false);
  const [startDatePickerOpen, setStartDatePickerOpen] = useState(false);
  const minDate = moment('01/01/2001').set('year', moment().year());
  const maxDate = moment('12/31/2001').set('year', moment().year());
  const dispatch = useDispatch();

  const handleChangeStartDateFilter = (startDate) => {
    const momentValue = startDate ? moment(startDate).format('MMM D') : startDate;
    dispatch(setStartDateFilter(momentValue));
    setStartDatePickerOpen(false);
  };

  const handleChangeEndDateFilter = (endDate) => {
    const momentValue = endDate ? moment(endDate).format('MMM D') : endDate;
    dispatch(setEndDateFilter(momentValue));
    setEndDatePickerOpen(false);
  };
    <div className="col-12 col-sm-6 col-xl-3 date-filter-block">
          <LocalizationProvider dateAdapter={AdapterMoment}>
            <div className="d-flex align-items-center">
              <DatePicker
                // clearable
                label="Start Date"
                value={startDateFilter}
                onChange={handleChangeStartDateFilter}
                views={['month', 'day']}
                inputFormat="MMM D"
                mask="MMM_"
                ignoreInvalidInputs
                PopperProps={{ disablePortal: true }}
                minDate={minDate}
                maxDate={maxDate}
                error={false}
                helperText={null}
                open={startDatePickerOpen}
                KeyboardButtonProps={{ disabled: true, style: { display: 'none' } }}
                onOpen={() => setStartDatePickerOpen(true)}
                onClose={() => setStartDatePickerOpen(false)}
                renderInput={({ inputRef, inputProps }) => (
                  <div>
                    <input
                      onClick={() => setStartDatePickerOpen(!startDatePickerOpen)}
                      className="datePicker-input"
                      ref={inputRef}
                      {...inputProps}
                      placeholder="Start Date"
                    />
                  </div>
                )}
              />
              <div onClick={() => setStartDatePickerOpen(!startDatePickerOpen)}>
                <span className="input-group-text mx-3">
                  <i className="mdi mdi-calendar"></i>
                </span>
              </div>
              <DatePicker
                // clearable
                label=" End Date"
                value={endDateFilter}
                onChange={(e) => {
                  handleChangeEndDateFilter(e);
                  console.log(e);
                }}
                ignoreInvalidInputs
                PopperProps={{ disablePortal: true }}
                views={['month', 'day']}
                inputFormat="MMM D"
                mask="MMM_"
                // minDate={minDate}
                // maxDate={maxDate}
                error={false}
                helperText={null}
                open={endDatePickerOpen}
                onOpen={() => setEndDatePickerOpen(true)}
                // onClose={() => setEndDatePickerOpen(false)}
                KeyboardButtonProps={{ disabled: true, style: { display: 'none' } }}
                renderInput={({ inputRef, inputProps }) => (
                  <div>
                    <input
                      onClick={() => setEndDatePickerOpen(!endDatePickerOpen)}
                      className="datePicker-input"
                      ref={inputRef}
                      {...inputProps}
                      placeholder="End Date"
                    />
                  </div>
                )}
              />
            </div>
          </LocalizationProvider>

Vue how to set the active tab

I have a Vue tab component that console logs out the correct index of the selected tab but I don’t know how to set the active tab so it is opened. Any help or direction would be appreciated.

Component:

<Tabs
  :tabs="tabs"
  :active-tab-index="activeTab"
  @tab-changed="changeTab"
/>

Markup

<div v-show="activeTab === 0">
Show tab one content
</div>

<div v-show="activeTab === 1">
Show tab two content
</div>

Data:

  data() {
    return {
      tabs: [
        { id: 0, name: 'Tab One' },
        { id: 1, name: 'Tab Two' },
      ],
      activeTab: 0,
    }
  },

Method:

changeTab(index) {
  console.log('Change activeTab', index)
},

Read Excel sheet with Javascript

I would like to retrieve data from specific cells in a local Excel sheet using Javascript and then output it on an HTML page. My function would be something like readData(row, col).

For example:

Cell 1A = “hello”

<h4><script>readData(1, A)</script></h4> will show as “hello” on my page.

Every solution I have seen has involved uploading the file first (example below from the read-excel-file package), but my Excel file is already a local file within my project.

<script>
  var input = document.getElementById('input')
  input.addEventListener('change', function() {
    readXlsxFile(input.files[0]).then(function(rows) {
      // `rows` is an array of rows
      // each row being an array of cells.
    })
  })
</script>

AntD table rowSpan to show data in table

Hey guys I am trying to display a JSON data in antd table but I am not sure how can i use the rowSpan or colSpan here as its rendering the whole data into one cell .

const columns = [
{
    title: 'Package Name',
    dataIndex: 'packageName',
    key: 'packageName',
    align: 'center',
},

{
    title: 'Operator',
    dataIndex: 'providerOperatorCommissionInfos',
    key: 'providerOperatorCommissionInfos',
    render: (operatorInfo) => {
        return operatorInfo.map(({ operatorCategory, operatorName }) => (
            <div className="row">
                <p>{operatorName}</p>
                <p>{`(${operatorCategory})`}</p>
            </div>
        ));
    },
    align: 'center',
},

{
    title: 'API Slab',
    dataIndex: 'providerOperatorCommissionInfos',
    key: 'providerOperatorCommissionInfos',
    render: (operatorInfo) => {
        return operatorInfo.map(({ apiSlabs }) =>
            apiSlabs.map(({ min, max }) => (
                <div className="row">{`[${min}-${max}]`}</div>
            ))
        );
    },
    align: 'center',
},
{
    title: 'Commission',
    children: [
        {
            title: 'Amount',
            dataIndex: 'providerOperatorCommissionInfos',
            key: 'providerOperatorCommissionInfos',
            render: (operatorInfo) => {
                return operatorInfo.map(({ apiSlabs }) =>
                    apiSlabs.map(({ commission, amountType }) => (
                        <div className="row">
                            {commission}{' '}
                            {(amountType === 'FIXED' && '₹') ||
                                (amountType === 'PERCENT' && '%')}
                        </div>
                    ))
                );
            },
            align: 'center',
        },
        {
            title: 'C/S',
            dataIndex: 'providerOperatorCommissionInfos',
            key: 'providerOperatorCommissionInfos',
            render: (operatorInfo) => {
                return operatorInfo.map(({ apiSlabs }) =>
                    apiSlabs.map(({ commissionType }) => (
                        <div className="row">{commissionType[0]}</div>
                    ))
                );
            },
            align: 'center',
        },
    ],
},
{
    title: 'GST',
    dataIndex: 'providerOperatorCommissionInfos',
    key: 'providerOperatorCommissionInfos',
    render: (operatorInfo) => {
        return operatorInfo.map(({ apiSlabs }) =>
            apiSlabs.map(({ gst }) => <div className="row">{gst}</div>)
        );
    },
    align: 'center',
},
{
    title: 'TDS',
    dataIndex: 'providerOperatorCommissionInfos',
    key: 'providerOperatorCommissionInfos',
    render: (operatorInfo) => {
        return operatorInfo.map(({ apiSlabs }) =>
            apiSlabs.map(({ tds }) => <div className="row">{tds}</div>)
        );
    },
    align: 'center',
},
{
    title: 'Actions',
    dataIndex: 'packageName',
    key: 'packageName',
    render: (packageName) => (
        <div>
            <EditOutlined />
            <DeleteOutlined style={{ marginLeft: 15 }} />
        </div>
    ),
    align: 'center',
},

];

in dataSource i have passed the whole JSON
desired table:

the table I am getting

here is the codeSandbox link : https://codesandbox.io/s/broken-pond-0m5svs?file=/src/App.js:192-2623