How to download URL from CreateObjectURL and save it in a folder

I’m making a website that can record audio for 5 seconds, it works, but when the 5 seconds finish I want the audio to download or to be save in a folder of my project, is it posible? here is my code:

navigator.mediaDevices.getUserMedia({ audio: true })
  .then(stream => {
    const mediaRecorder = new MediaRecorder(stream);
    mediaRecorder.start();


    const audioChunks = [];

    mediaRecorder.addEventListener("dataavailable", event => {
      audioChunks.push(event.data);

    });

    mediaRecorder.addEventListener("stop", () => {
      const audioBlob = new Blob(audioChunks)
      const audioUrl = URL.createObjectURL(audioBlob);
      const audio = new Audio(audioUrl);
      audio.play();
    });

And I want to make something like this

    mediaRecorder.addEventListener("stop", () => {
      const audioBlob = new Blob(audioChunks)
      const audioUrl = URL.createObjectURL(audioBlob);
      const audio = new Audio(audioUrl);
      audio.play();
      audio.save("direction-of-the-folder/") // MAKE this
    });

Thank you in advance:)

How do I get the geolocation service working on Android Webview

I tried to enable the geolocation service for the webview, but it never asks for it. I then enabled the service via settings, and it times out every time I try to use it. Is there any problem?
Here’s my code in MainActivity.java:

package com.example.quickweather;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.webkit.*;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView daApp = (WebView)findViewById(R.id.DaApp);
        WebSettings props = daApp.getSettings();
        props.setJavaScriptCanOpenWindowsAutomatically(true);
        props.setJavaScriptEnabled(true);
        props.setGeolocationEnabled(true);
        props.setAllowFileAccessFromFileURLs(true);
        props.setAllowFileAccess(true);
        props.setAppCacheEnabled(true);
        props.setDatabaseEnabled(true);
        props.setDomStorageEnabled(true);
        props.setAllowContentAccess(true);
        daApp.setWebChromeClient(new WebChromeClient(){
            @Override
            public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback){
                callback.invoke(origin,true,false);
            }
        });
     
        daApp.loadUrl("file:///android_asset/webinterface/index.html");
    }
}

Automatically change html dropdown selection based on values entered in inputs

I have a form where the user enters the parcel dimensions into 3 input fields (length,width,height) and then selects the parcel name from the dropdown selection.

The function I am trying to implement is when the user enters his values into the inputs the function automatically selects the parcel name from the dropdown based on his values when the user clicks the calculate button.

I would like the script to work out the result based on the option datasets not by manually setting the results/values in the javascript as I have more datasets which get changed regularly.

The code I have added always only selects the last option, I tried using a for loop but I could not get that to change the end result.

function calculate(clicked_id) {

  Array.from(document.querySelector("#dropdown").options).forEach(function(option_element) {

      var option_text = option_element.text;
      var option_value = option_element.value;
      var option_dataset_length = option_element.dataset.length;
      var option_dataset_width = option_element.dataset.width;
      var option_dataset_height = option_element.dataset.height;
      var is_option_selected = option_element.selected;

      var length = document.getElementById("length").value;
      var width = document.getElementById("width").value;
      var height = document.getElementById("height").value;

        if (length <= option_dataset_length && width <= option_dataset_width && height <= option_dataset_height) {
          document.getElementById("dropdown").value = option_value;
        } 
    }
  )
}
<!-- inputs -->
<div class="row">
<input type="text" id="length" placeholder="length">
<input type="text" id="width" placeholder="width">
<input type="text" id="height" placeholder="height">
</div>

<br>

<!-- dropdown -->
<div class="row">
<select id="dropdown">
    <option value="1" data-length="10" data-width="15" data-height="20">Small Parcel</option>
    <option value="2" data-length="20" data-width="25" data-height="30">Medium Parcel</option>
    <option value="3" data-length="30" data-width="35" data-height="40">Large Parcel</option> 
</select>
</div>

<br>

<!-- button -->
<div class="row">
<button type="button" onClick="calculate(this.id)">Calculate</button>
</div>

ASCII Art From Webcam with Javascript [closed]

I’ve been trying to implement a javascript/html/css app into my website builder. It works in the site builder preview, but not on the live version of the site. When I go to the live site, it shows the camera webcam feed, but the ASCII text is just one line. I’ve literally just copy and pasted this code from this git project.

For context, I’m using cargo.site builder and it’s one line of moving text instead of the whole image feed been kind of challenging to use JS files. My hunch is that my site styles are interfering with the project files. The url for this project is https://grantekilgard.com/ASCII-Webcam-Feed-Generator-copy. Any help is so appreciated, thank you all in advance. this is what I want the live site to display

“Malformed data passed to binarizer” during QR generation

I’m trying to generate a barcode on the web from the png image. I’m using “jsqr” library. My code looks like this:

loadBarcodeImage() async {
    Uint8List? image = await fileUtils.getFileFromLocal(['jpg', 'jpeg', 'png']);
    chosenBarcodeImage = image;
    Uint8ClampedList clampedList = image!.buffer.asUint8ClampedList();
    js.JsArray js_array = js.JsArray.from(clampedList);
    callUIBarcodeScanner(js_array);
}
callUIBarcodeScanner(dynamic barcodeImage) {
    var barcode = jsqr.jsQR(barcodeImage, 100, 100);
    print(barcode);
}

I had been tried a couple of other list types but still getting:

Malformed data passed to binarizer.
    at Object.e.binarize (https://cdn.jsdelivr.net/npm/[email protected]/dist/jsQR.min.js:7:6194)
    at l (https://cdn.jsdelivr.net/npm/[email protected]/dist/jsQR.min.js:7:5602)
```...

Please, help

Overriding script src tag

I want to disable “adblock” detector script on shinden.pl using extension, not existing one.
The file that I need to somehow change is https://shinden.pl/f/js/main-obfuscated.js?p

To make it work i can do 3 things:

  1. force aj variable to always be 0
  2. delete if(p&&aj>0x0)an(bt,data);else from main-obfuscated.js
  3. replace <script src="/f/js/main-obfuscated.js?p"></script> without if(p&&aj>0x0)an(bt,data);else

I searched for some examples how to do that but I couldn’t find any working solution, when i tried using one that executes code before page loads main-obfuscated.js function just didn’t want to execute but simple alert() worked.

If there is some simpler way to do it than to replace main-obfuscated.js please tell me.

JavaScript code to read the latest values from a json file that keeps getting updated every few seconds

I am very new to JavaScript and trying to display the latest values from a .json file that keeps getting updated every 10 seconds into a HTML page. I am reading the file every 10 seconds as well, but I am not getting the latest values from the file. I am getting values which are 50 to 60 seconds older.

I have tried disabling the browser cahche in chrome but stillthe same issue. Can somebody please help on this?

My JavaScript code to read the json file is as follows:

function readJsonFile(callback) {
 var request = new XMLHttpRequest();
 request.open('GET', 'http://localhost:8080/PersonalProject/filename.json');
 request.onload = function() {
  if(request.status>=100 && request.status<=100) {
   //perform some operation
   callback(request.responseText);
  }
  else{
   //perform some operation
   callback('FAILED');
  }
 };
 request.onerror = function() {
  console.error('Connection error');
 };
 request.send();
}


setInterval(function(){
 readJsonFile(function(stat){
  console.log(stat);
 });
}, 10000);

HTML Question about auto loading an excel file from the server

So here is the bulk of the code (Minus other pages, the css files, other js files, basically files unrelated to the question)

I am very happy with how this loads and creates the table and all of that. What I am trying to figure out now is how I can place this excel file on the server (Not on the user’s pc) and have it automatically select the excel file on page load. The file will be stored in “Files/Data.xlsx”

This filename is Inventory.html

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>Some Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <!-- Reference the CSS File -->
    <link rel="stylesheet" href="css/main.css">

    <!--First we have to include Bootstrap Stylesheet and SheetJS library link at header of our HTML page.-->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script type="text/javascript" src="js/xlsx.full.min.js"></script>
</head>

<body>
    <div id="topMenu">
        <ul>
            <!--This I am using as a navigation bar and is unrelated-->
        </ul>
    </div>
    <div class="container">
        <div class="card">
            <div class="card-body">
                <input type="file" id="excel_file" />
            </div>
        </div>
        <br />
        <table id="myTable">
            <tr id="search">
                <!--This is some stuff used to filter the table and is unrelated-->
            </tr>
            <tbody id="excel_data" class="mt-5">
            </tbody>
        </table>
    </div>
</body>

</html>

<script>
    const excel_file = document.getElementById('excel_file');
    excel_file.addEventListener('change', (event) => {
        if (!['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel']
        .includes(event.target.files[0].type)) {
            document.getElementById('excel_data').innerHTML = 
            '<div class="alert alert-danger">Only .xlsx or .xls file format are allowed</div>';
            excel_file.value = '';
            return false;
        }

        var reader = new FileReader();
        reader.readAsArrayBuffer(event.target.files[0]);
        reader.onload = function(event) {
            var data = new Uint8Array(reader.result);
            var work_book = XLSX.read(data, {
                type: 'array'
            });
            var sheet_name = work_book.SheetNames;
            var sheet_data = XLSX.utils.sheet_to_json(work_book.Sheets[sheet_name[0]], {
                header: 1
            });
            if (sheet_data.length > 0) {
                var table_output = '<table class="table table-striped table-bordered">';
                for (var row = 0; row < sheet_data.length; row++) {
                    table_output += '<tr>';
                    for (var cell = 0; cell < sheet_data[row].length; cell++) {
                        if (row == 0) {
                            table_output += '<th>' + sheet_data[row][cell] + '</th>';
                        } else {
                            table_output += '<td>' + sheet_data[row][cell] + '</td>';
                        }
                    }
                    table_output += '</tr>';
                }
                table_output += '</table>';
                document.getElementById('excel_data').innerHTML = table_output;
            }
            excel_file.value = '';
        }
    });
</script>

My next big task will be figuring out how to write the data from the below form to the next empty row in the excel document….

This filename is AddItem.html

<form>
    <label for="prNumberInput">Enter the PR Number: </label>
    <input type="text" name="prNumberInput" placeholder="Enter the PR Number" /><br>

    <label for="netbuildNumberInput">Enter the NetBuild Number: </label>
    <input type="text" name="netbuildNumberInput" placeholder="Enter the NetBuild Number" /><br>

    <label for="trackingNumberInput">Enter the Tracking Number: </label>
    <input type="text" name="trackingNumberInput" placeholder="Enter the Tracking Number" /><br>

    <label for="partNumberInput">Enter the Part Number: </label>
    <input type="text" name="partNumberInput" placeholder="Enter the Part Number" /><br>

    <input type="button" onclick="AddItemSubmit()" value="Add Item">
</form>

Google Firebase user.PhotoURL doesn’t Change After Upload

I’ve been trying to figure out how to update the user photo after uploading it to Google Firebase. The user photo uploads to Firebase, however doesn’t chance after uploading. Only it changes when the page is refreshed.

Is there a way to refresh the user profile photo without refreshing the whole page?

import { useEffect, useState } from "react";
import { useAuth, upload } from "./firebase";

export default function Profile() {
  const currentUser = useAuth();
  const [photo, setPhoto] = useState(null);
  const [loading, setLoading] = useState(false);
  const [photoURL, setPhotoURL] = useState("https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png");

  function handleChange(e) {
    if (e.target.files[0]) {
      setPhoto(e.target.files[0])
    }
  }

  function handleClick() {
    upload(photo, currentUser, setLoading);
  }

  useEffect(() => {
    if (currentUser?.photoURL) {
      setPhotoURL(currentUser.photoURL);
    }
  }, [currentUser])

  return (
    <div className="fields">
      <input type="file" onChange={handleChange} />
      <button disabled={loading || !photo} onClick={handleClick}>Upload</button>
      <img src={photoURL} alt="Avatar" className="avatar" />
    </div>
  );

Code is taken from LogicismX GitHub page.

My onclick function doesn’t recognize my class [duplicate]

  <div id="hoursList" class="hours__list"></div>

I will put some html tag inside to this class “hours_list”.

function booking_hours(hourArray) {
  console.log("heyyyy");

  var table;
  for (var i = 0; i < hourArray.length; i++) {
    // if (parseInt(hourArray[i].childNodes[0].nodeValue) < 9)
    table +=
      "<div data-hours='0" +
      hourArray[i].childNodes[0].nodeValue +
      ".00-0" +
      (parseInt(hourArray[i].childNodes[0].nodeValue) + 1) +
      ".00' class='hour_cell'>" +
      "<p>" +
      "0" +
      hourArray[i].childNodes[0].nodeValue +
      ".00 - 0" +
      (parseInt(hourArray[i].childNodes[0].nodeValue) + 1) +
      ".00" +
      "</p></div>";
 }
  document.getElementById("hoursList").innerHTML = table.slice(9);
}

This function works with this action.

function xhttp() {
  // Create an XMLHttpRequest object
  const xhttp = new XMLHttpRequest();
  var hourArray;
  // Define a callback function
  xhttp.onload = function () {
    var parser, xmlDoc;
    var text = this.responseText;
    parser = new DOMParser();
    xmlDoc = parser.parseFromString(text, "text/xml");
    hourArray = xmlDoc.getElementsByTagName("item");
    booking_hours(hourArray);
  };
  // Send a request
  xhttp.open("GET", "hours.xml");
  xhttp.send();
}

Everything is ok, until now. But The problem is this ” $(“.hour_cell”).click(function ()”. This function doesn’t work. I tested with consol.log but I couldn’t see this message. So how can I solve this problem? Please, help me, I want to le

// Onclick hour cell
$(document).ready(function () {
  $(".hour_cell").click(function () {
    var th = $(this).data().hours.slice(0, 2);
    console.log("H E R E");

    for (var i = 0; i < counterReservedHours; i++) {
      if (i + 1 == counterReservedHours && reservedHours[i] != th) {
        counterReservedHours++;
        reservedHours[i] = th;
        break;
      } else if (reservedHours[i] == th) {
        reservedHours.splice(reservedHours.indexOf(th), 1);
        counterReservedHours--;
        break;
      }
    }
    $(this).toggleClass("isSelected");
  });
});

How to navigation background color change on scroll

**# I want to navigation background color change when story data scroll. When our story data scroll 1 to 100% together nav story background color changes 1 to 100%. I was trying to scroll progress used but I could not solve it. I can’t understand how should solve please, anyone, help As like https://maat-law-firm.webflow.io/story **

import React, { useEffect, useState } from 'react';
import { Col, Container, Image, Row } from 'react-bootstrap';
import './OurStory.css';
      
const OurStory = () => {
     const [story, setStory] = useState([]);
     useEffect(() => {
         fetch('https://pure-refuge-33072.herokuapp.com/story')
            .then(res => res.json())
            .then(data => setStory(data))
     }, []);
return (
   <div className="pb-5">
     <div className="ourStory">
        <Container>
              <div id='ourStory' className='mainSection'>
                  {
                    story.map((story, index) => <div key={story?._id}>
                      <div id={story?._id} className='py-5'>
                          <Row>
                             <Col xs={12} lg={6}>
                                <div className="big-font singleStory">
                                   <h3 className='storyAbout'>{story?.about}</h3>
                                    <h1>{story?.title}</h1>
                                 </div>
                               </Col>
                               <Col xs={12} lg={6}>
                                 <div>
                                    <div className="big-font singleStory">
                                       <h2>{story?.sub_title}</h2>
                                        <p>{story?.description}</p>
                                        <Image className='w-100' src={story?.image} />
                                     </div>
                                 </div>
                               </Col>
                             </Row>
                         </div>
                         <div className='mt-5 pt-5'>
                            <hr className='bg-white' />
                          </div>
                      </div>)
                   }
                </div>
            </Container>
            <div className='navStoryContainer'>
               <Container >
                  <Row className='navStory'>
                     {
                        story.map((story, index) => <div
                           className='navStoryItem'
                            key={story?._id}>
                         <a href={`#${story?._id}`}>
                           <div className='big-font'>
                               <h5>{story?.about}</h5>
                               <p>{story?.title}</p>
                            </div>
                         </a>
                      </div>)
                    }
                 </Row>
              </Container>
           </div>
        </div>
    </div >
   );
 };      
export default OurStory;

How can “All Mail” data be extracted into Google sheet?

I’m trying to extract all my gmail emails into spreadsheet & used below code which is working fine for “Inbox” data.. I need to get “All Mail” data instead of just inbox. Is it possible? Also, i want a new line added to the spreadsheet as soon as a new email is arrived in my inbox.. my current code is actually creating multiple duplicates of I run it again or set a time trigger. Any help in this would be much much much appreciated!!?Part-1

Part-2

My react app is working in browser but not in my mobile

I’m developing a react app, I want to try some functions in my mobile but when I try to connect to it, I have an error.
I understand that is an asynchronus problem… I’m trying to map an (by the moment) undefined array. But I don’t understand by in the browser is working well and in my mobile not.

const eventsFetch = async () => {
    const resEvents = await getAllEvents();
    const newArray = resEvents.filter((e) => {
        const date = new Date(e.date);

    return date.getTime() >= Date.now();
    });

    newArray.sort((e) => e.important === true ? -1 : 1);
    setEvents(newArray);
}

Here is an screenshot from the mobile browser.. I tried with Chrome, Safari and Brave and always I got the same error.
enter image description here

By last, I already try adding the optional chaining operator to the array, but I have the same result.

How to set one State with few value of inputs

i would like to know how can i set one state with few inputs value for the example this is the state

const [userBirthday, setUserBirthday] = useState('')

there are 3 inputs, i want to get e.target.value from each one and conbain them in the state

something like that
**I know the syntax actually not good but it is only to simplify my question

      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />
      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />
      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />   

`

console.log(userBirthday) == Result: 12 September 2020