store given answers of a Quiz App into array in React

I’m building a quiz app in react, I have created the quiz card with 4 answers for each question, the question and the answers in the card change everytime you click on Submit.
Here is my code:

 

    const handleSubmit = (event) => {
        setValue(true);
        let updatedAnswers = [...givenAnswer, event.target.value];
        setGivenAnswer(updatedAnswers);
      };
    
      console.log(givenAnswer)
    
    
      const handleSelectedItem = (index) => {
        setClickedIndex(index);
        
      };
    
      
    
      const goToNext = () => {
        setCurrentQuestionIndex((prevState) => prevState + 1);
        setValue(false);
        setClickedIndex(null);
      };
    
      useEffect(() => {
        const transformQuestions = (questionObj) => {
          const loadedQuestions = [];
    
          for (const questionKey in questionObj) {
            loadedQuestions.push({
              id: questionKey,
              id_test: questionObj[questionKey].id_test,
              tipologia_domanda: questionObj[questionKey].tipologia_domanda,
              testo: questionObj[questionKey].testo,
              immagine: questionObj[questionKey].immagine,
              eliminata: questionObj[questionKey].eliminata,
            });
          }
          setQuestions(loadedQuestions);
        };
        getQuestions(
          {
            method: 'GET',
            url: baseURL_Q,
          },
          transformQuestions
        );
      }, [getQuestions]);
    
      useEffect(() => {
        const transformAnswers = (answerObj) => {
          const loadedAnswers = [];
    
          for (const answerKey in answerObj) {
            loadedAnswers.push({
              id: answerKey,
              domanda_id: answerObj[answerKey].domanda_id,
              corretta: answerObj[answerKey].corretta,
              testo: answerObj[answerKey].testo,
              immagine: answerObj[answerKey].immagine,
            });
          }
          setAnswers(loadedAnswers);
        };
        getAnswers(
          {
            method: 'GET',
            url: baseURL_A,
          },
          transformAnswers
        );
      }, [getAnswers]);
    
      let questionsTitle = questions.map((element) => `${element.testo}`);
      let questionIndicator = (currentQuestionIndex * 100) / questionsTitle.length;
      let answerQuestionId = questions.map((q) => {
        let temp = answers.filter(
          (element) => `${element.domanda_id}` === `${q.id}`
        );
        return temp;
      });
      let sortedAnswers = answerQuestionId.map((item) =>
        item.map((innerItem) => `${innerItem.testo}`)
      );
    
      return (
        <Grid container spacing={1}>
          <Grid item xs={12} sm={8} md={4}>
            <Box
              sx={{
                minWidth: 275,
                display: 'flex',
                alignItems: 'center',
                paddingLeft: '100%',
                position: 'center',
              }}
            >
              <Card
                variant='outlined'
                sx={{
                  minWidth: 400,
                }}
              >
                {onTime ? (
                  <>
                    <CardContent>
                      <Grid container spacing={0}>
                        <Grid item xs={8}>
                          <Typography
                            variant='h5'
                            component='div'
                            fontFamily={'Roboto'}
                          >
                            Nome Test
                          </Typography>
                        </Grid>
                        <Grid item xs={4}>
                          <CountDown setOnTime={setOnTime} seconds={1000} />
                        </Grid>
                      </Grid>
    
                      <Box sx={{ display: 'flex', alignItems: 'center' }}>
                        <Box sx={{ width: '100%', mr: 1 }}>
                          <LinearProgress
                            variant='determinate'
                            value={questionIndicator}
                          />
                        </Box>
                        <Box sx={{ minWidth: 35 }}>
                          <Typography variant='body2' color='text.secondary'>
                            {currentQuestionIndex + 1}/{questionsTitle.length + 1}
                          </Typography>
                        </Box>
                      </Box>
    
                      <Typography
                        sx={{ mb: 1.5, mt: 1.5, textAlign: 'center' }}
                        fontFamily={'Roboto'}
                        fontWeight={'bold'}
                      >
                        {questionsTitle[currentQuestionIndex]}
                      </Typography>
    
                      {sortedAnswers.length > 0 && (
                        <ButtonGroup
                          fullWidth
                          orientation='vertical'
                          onClick={handleSubmit}
                          
                        >
                          {sortedAnswers[currentQuestionIndex].map(
                            (answer, index) => (
                              <ListItemButton
                                selected={clickedIndex === index}
                                onClick={() => handleSelectedItem(index)}
                                key={index}
                              >
                                {answer}
                              </ListItemButton>
                            )
                          )}
                        </ButtonGroup>
                      )}
                    </CardContent>
                    <CardActions>
                      <Button
                        onClick={goToNext}
                        disabled={!value}
                        variant='contained'
                        size='small'
                      >
                        Avanti
                      </Button>
                    </CardActions>
                  </>
                ) : (
                  <>
                    <Typography
                      sx={{ mb: 1.5, mt: 1.5 }}
                      fontFamily={'Roboto'}
                      fontWeight={'bold'}
                      align={'center'}
                    >
                      TEMPO ESAURITO
                    </Typography>
                    <NavLink> Torna ai Test</NavLink>
                  </>
                )}
              </Card>
            </Box>
          </Grid>
        </Grid>
      );
    }

I wanto to store the given answers in an array so i can store them in an array and check later of they are correct. I’ve tried to do this:


    const [givenAnswer, setGivenAnswer] = useState([]);
    const handleSubmit = (event) => {
        setValue(true);
        let updatedAnswers = [...givenAnswer, event.target.value];
        setGivenAnswer(updatedAnswers);
      };
      console.log(givenAnswer)

but in the console it returns an array of undefined, while i Want an array with the text of the answers. Can anyone help me, please?

GraphQL: Unknown field “employee”: The parent selection or operation does not resolve to a valid schema type

I’m trying to define a simple GraphQL query that gets a list of all employees at a given department. The query looks like this:

export const QUERY_DEPARTMENT_EMPLOYEES = gql`
    query Employees($departmentId: ID) {
        employee(departmentId: $departmentId) {
            ...EmployeeFields
        }
    }`

IntelliJ is indicating an error on Employee: Unknown field "employee": The parent selection or operation does not resolve to a valid schema type . Is something missing from my schema.graphql, or is something not being read? This is what’s in my schema.graphql file:

type Employee {
    username: String!
    fullName: String!
    lastName: String!
}

I’ve tried making the query simpler by removing the arguments but the error persists. I’ve explicitly made my documents parameter in graphql.config.yml empty, and this is what that file looks like now:

schema: ./schema.graphql
documents: []

How to reach the grid component of inner pages ascx files from outer aspx file

I have a aspx file which consist of inner ascx files. I use ascx files as a user control file. There is a menu bar on the left side of aspx file(outer file). if a grid file is empty in user control files; I want to set the color of the menu of it blue. I want to do it with js because of lag problems.

aspx outer file

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Ozgecmis.Default" MaintainScrollPositionOnPostback="true" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7" />
<title>Özgeçmiş</title>
<script>
$(document).ready(function () {
var gridView = document.getElementById("<%=*gridTecrube*.ClientID %>");
var rows = gridView.getElementsByTagName("tr")
if (rows.length == 1) {
    document.getElementById('ozgecmis-nav').children[5].style.color = 'blue';                  
    }
});
</script>
</head>
<body data-spy="scroll" data-target=".ozgecmis-sidebar">
<form id="formOzgecmis" runat="server">
    <section id="top" class="section-start" style="position: absolute;"></section>
    <asp:PlaceHolder ID="ctlTemplatePlaceHolder" runat="server"></asp:PlaceHolder>
    <asp:Panel ID="ctlContentPanel" CssClass="SectionPanel" runat="server" Width="100%">
        <link href="/Assets/csspages/ozgecmis-default.css?v=20160307" rel="stylesheet" />
        <div class="row">
            <div class="span3 ozgecmis-sidebar">
                <ul class="nav nav-list ozgecmis-sidenav" id="ozgecmis-nav">                        
                    <li><a href="#ogrenim" class="section-link">Öğrenim Bilgileri</a></li>
                    <li><a href="#meslek" class="section-link">Meslek Bilgileri</a></li>
                    <li id="tecrubeMenu" runat="server" Visible ="true"><a href="#tecrube"        class="section-link">İş Tecrübesi</a></li>                         
                </ul>
                <br />
            </div>
            <div class="span9">
                <div style="min-height: 60px; padding-top: 10px;">
                    <table class="pull-right">
                        <tr>
                            <td><span style="font-size: calc(30px + 1vw); font-weight: bold;">Özgeçmiş</span></td>
                            <td style="padding-left: 20px;">
                                <ozgecmisUserControl:OzgecmisDolulukOran runat="server" ID="ucOzgecmisDolulukOran" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="divTecrube" runat="server">
                    <section id="tecrube">                          
                         <div class="section-header warning"  style="background-color:pink;" id="isTecrubesiBos" runat="server" ClientIDMode="Static" >
                             İş Tecrübesi                                
                        </div>
                        <div class="section-body">
                            <ozgecmisUserControl:OzgecmisTecrube 
runat="server" ID="ucOzgecmisTecrube" />
                        </div>                           
                    </section>
                </div>
                 <section id="end" class="section-end"></section>
            </div>
        </div>
        <script src="/Assets/jspages/ozgecmis-default.js?v=20210620" type="text/javascript">                     </script>
    </asp:Panel>
</form>

ascx (inner) file:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="OzgecmisTecrube.ascx.cs"   Inherits="Ozgecmis.UserControls.OzgecmisTecrube" %>
<asp:UpdatePanel runat="server" ID="upOzgecmisTecrube" UpdateMode="Conditional">
<ContentTemplate>
    <div id="divYardimOzgecmisTecrube" class="hide">
        <iskurControls:IskurPortalTableHeader ID="headerOzgecmisTecrube" runat="server">
        </iskurControls:IskurPortalTableHeader>
    </div>
    <asp:GridView ID="*gridTecrube*" runat="server" AutoGenerateColumns="false"     ShowHeader="false"  ShowFooter="false"
        CssClass="table table-bordered table-condensed"
        EmptyDataText="Kayıtlı İş Tecrübesi Bilgisi Bulunmamaktadır."
        OnRowDataBound="OnGridRowDataBound" OnRowCommand="OnGridRowCommand"     OnRowCreated="OnGridRowCreated"
        DataKeyNames="KAYITNO"
        RowStyle-CssClass="ozgecmis-grid-row" AlternatingRowStyle-CssClass="ozgecmis-grid-row-    alternate" SelectedRowStyle-CssClass="ozgecmis-grid-row-selected">
        <Columns>
            <asp:TemplateField ItemStyle-CssClass="ozgecmis-data-key">
                <ItemTemplate>
                    <asp:Button runat="server" ID="dataKeyButton"    CommandArgument='<%#DataBinder.Eval(Container.DataItem,"KAYITNO") %>' Visible="false" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-CssClass="ozgecmis-data-command" ItemStyle-VerticalAlign="Middle">
                <ItemTemplate>
                    <a href="#" class="btn btn-small btn-info">Seç</a>
                </ItemTemplate>
            </asp:TemplateField>            
        </Columns>
    </asp:GridView>
</ContentTemplate>

</asp:UpdatePanel>

What is the difference between upload() and save() for storage?

I am trying to figure out how to upload images to firestore using Google Cloud Functions, and I see there are upload() and save() methods. I haven’t been able to figure out the difference between them and when you should use one or the other. Can you tell me when each method is appropriate to use to upload/save an image to Firestore using Google Cloud Functions?

Example

await bucket.upload({destination, contentType})

await bucket.file().save()

Copy only filtered range to other sheet with starting range at column B instead of column A

I have a similar questions here. Could anyone help me to solve it? Here is my code first in Google sheets Macros

`function check_closed_status_monthly_001() {
  var sourceSheetName = "Copy of Open Order Shared Sheet"; // Replace with the 
name of the sheet
  var targetSheetName = "Copy of CLOSED"; // Replace with the name of the target 
sheet
  var statusColumnIndex = 2; // Adjust to the index of the status column (AR is 
the 44th column)
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName(sourceSheetName);
  var targetSheet = ss.getSheetByName(targetSheetName);

  // Step 1: Go to the sheet
  sourceSheet.activate();

  // Define the range to copy (B2:P) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!set 
this to B2:P, and change targetRange_04 to 15 instead of 
16!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  var valuesToCopy = sourceSheet.getRange("B2:P").getValues();

  // Apply filter criteria here
  var hiddenValues = ["vouched"];
  values_04 = valuesToCopy.filter(function(v) {
    return hiddenValues.indexOf(v[1]) !== -1;
  });

  /*// Exit if there are no filtered values
  if (values_04.length === 0) {
    return;
  }*/
  console.log(values_04)
  // Calculate the range to paste in the target sheet
  var targetLastRow = targetSheet.getLastRow();
  var targetRange_04 = targetSheet.getRange(targetLastRow + 1, 1, 
values_04.length, 15).setValues(values_04);

  // Set the values in the target range to the copied values
  // targetRange_04.setValues(values_04);

}`

Exception: The number of rows in the range must be at least 1. Here is the issue that I have

For the range part, I am trying to set the range to B2:P, however, the values at values_04 is empty (but, the values does exists in the sourceSheet, and when I set the range to A2:P, it gives me the values). My question is how do I set the range to B2:P, and make it to work.

Please refer to this link for more details! Copy only filtered range to other sheet

How to pass array to a function as its elements in string forms (Uncaught SyntaxError: Unexpected token ‘&’)

I’m trying to pass the imageSrcs array as its array elements with quotation marks. But it doesn’t really work that way. How can I pass an array to a function as its elements in string forms?

<%  for (let i = 0; i < posts.length; i++) {
  let imageSrcs = [];

  for (let j = 0; j < posts[i].images.length; j++) {
      let imageSrc = '"' + `data:image/${posts[i].images[j].image.contentType};base64, ${posts[i].images[j].image.data.toString('base64')}` + '"';
      imageSrcs.push(imageSrc);
  } %>
  initializeSlider($(".slider-<%= i+1 %>"), <%= imageSrcs %>);

<% } %>

enter image description here

A way to make a custom sorting logic in the Quote Line Editor of CPQ

We are using Salesforce CPQ and our users wanted a way to force a particular product to always appear at the bottom of the Line Editor. We have this QCP plugin and I’ve tried to manipulate the array of the quoteLines in hopes that it displays the quoteLines based on the array index.

The array of quoteLines were being sorted but this sequence is not being followed when quote lines are displayed in the Quote Line Editor.

Quote Line Editor

I tried to manipulate the array by using splice and array.sort. I also tried to change the SBQQ_Number__c but didn’t work.

What I was expecting was when FREIGHT is added, it will always appear as the last item.

Downloading data from socket servers doesn’t work good

I have written socket client which connets with multiple socket servers. Ips and ports are stored in .json file. Client is sending message, then gets responses, which are stored in an array. The problem is that responses are changing their order.

require('events').EventEmitter.prototype._maxListeners = 10000;
const net = require('net')
let adresses = require('./ips.json')
const express = require('express')
const cors = require('cors')
let data = ''
let object = {Scales: []}
let weights = []
let units = []
let i = 0;
let temp1 = {}

adresses.ips.forEach(ip => {
    const client = new net.Socket()
    client.connect(ip.port, ip.ip, () => {
        console.log('connected')
        setInterval(() => {
            client.write('SIArn')
        }, 200)
        client.on('data', (result) => {
            data = result.toString().trim()
            weights[0] = data.slice(5, 15).replace(/s+/g, '')
            units[0] = data.slice(15, 19).replace(/s+/g, '')
            weights[1] = data.slice(25, 35).replace(/s+/g, '')
            units[1] = data.slice(35, 39).replace(/s+/g, '')
            weights[2] = data.slice(45, 55).replace(/s+/g, '')
            units[2] = data.slice(55, 59).replace(/s+/g, '')
            weights[3] = data.slice(65, 75).replace(/s+/g, '')
            units[3] = data.slice(75, 79).replace(/s+/g, '')
            temp1 = {
                id: i,
                Weighnings: [
                    {id: 1, weight: weights[0], unit: units[0]},
                    {id: 2, weight: weights[1], unit: units[1]},
                    {id: 3, weight: weights[2], unit: units[2]},
                    {id: 4, weight: weights[3], unit: units[3]}
                ]
            }
            object.Scales[i] = temp1
            if (i === adresses.ips.length-1) {
                i = 0
            } else {
                i++
            }
            client.on('error', (err) => {
                console.log(err)
            })
            client.on('close', () => {
                console.log('conn closed')
            })
        })
    })
})

const app = express()

app.use(cors())
app.use(express.json())

app.get('/db', (req, res) => {
    res.set('Content-Type', 'application/json')
    res.send(JSON.stringify(object))
    res.end()
})

app.listen(1000, () => {
    console.log('App is running on port 1000')
});

I tried to add some loops or smthng but it didn’t worked.

React google maps: TS2769: No overload matches this call

I am using reactjs with the typescript and trying to integrate the react google maps library.

Here is my map component file

import {
  withGoogleMap,
  GoogleMap,
  Marker,
} from "react-google-maps";

interface MapProps {
  // Define any additional props for the Map component, if needed
}

const MapWithAMarker = withGoogleMap<MapProps>(() =>
  <GoogleMap  //here I am getting the error
    defaultZoom={8}
    defaultCenter={{ lat: -34.397, lng: 150.644 }}
  >
    <Marker
      position={{ lat: -34.397, lng: 150.644 }}
    />
  </GoogleMap>
);

const maps = () => <MapWithAMarker
  containerElement={<div style={{ height: `800px` }} />}
  mapElement={<div style={{ height: `100%` }} />}
/> 
export default maps;

The Error message:

import GoogleMap
No overload matches this call.
  Overload 1 of 2, '(props: GoogleMapProps | Readonly<GoogleMapProps>): GoogleMap', gave the following error.
    Type '{ children: Element; defaultZoom: number; defaultCenter: { lat: number; lng: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMap> & Readonly<GoogleMapProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMap> & Readonly<GoogleMapProps>'.
  Overload 2 of 2, '(props: GoogleMapProps, context: any): GoogleMap', gave the following error.
    Type '{ children: Element; defaultZoom: number; defaultCenter: { lat: number; lng: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMap> & Readonly<GoogleMapProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<GoogleMap> & Readonly<GoogleMapProps>'.ts(2769)

bulk updating in inner array with mongodb and node.js

The below given is my document

{
        "_id": 7,
        "sections": [
            {
                "sectionData": {
                    "media": [
                        {
                            "_id": {
                                "$oid": "64a691e0c91b64aa2c0446ce"
                            },
                            "image": "1.jpg"
                        },
                        {
                            "_id": {
                                "$oid": "64a6922ac91b64aa2c0446d1"
                            },
                            "image": "1.jpg"
                        },
                        {
                            "_id": {
                                "$oid": "64a69240c91b64aa2c0446d2"
                            },
                            "image": "1.jpg"
                        },
                        {
                            "_id": {
                                "$oid": "64a6927dc91b64aa2c0446d3"
                            },
                            "image": "1.jpg"
                        }
                    ]
                },
                "_id": {
                    "$oid": "648847b944e80a387f627028"
                }
            },
            {
                "sectionData": {
                    "media": []
                },
                "_id": {
                    "$oid": "648aa5442b511184130685c7"
                }
            }
        ]
    }

I wanted to update a field inside media array by matching _id in the objects.

i will recieve a array of ids and values like this

let ids = [
  { _id: "64a691e0c91b64aa2c0446ce", eligible: false },
  { _id: "64a6922ac91b64aa2c0446d1", eligible: false },
  { _id: "64a69240c91b64aa2c0446d2", eligible: true },
];

I wanted to match the _id in the object and update the eligible value respectively.

here is my code,

   const albumId = 7;
    const sectionId = "648847b944e80a387f627028";
    let ids = [
      { _id: "64a691e0c91b64aa2c0446ce", eligible: false },
      { _id: "64a6922ac91b64aa2c0446d1", eligible: false },
      { _id: "64a69240c91b64aa2c0446d2", eligible: true },
    ];
        await uploadAlbumSchema.updateMany(
      { _id: albumId, "sections._id": sectionId, "sections.sectionData.media._id": { $in: ids.map(obj => mongoose.Types.ObjectId(obj._id)) } },
      { $set: { "sections.$[outer].sectionData.media.$[inner].eligible": ids.map(obj => obj.eligible)  } },
      { arrayFilters: [{ "outer._id": sectionId }, { "inner._id": { $in: ids.map(obj => mongoose.Types.ObjectId(obj._id)) } }] }
    )

using this code its not working as expected its updating the eligible field as a array. so I need only to update the corresponding field with the respective value like this.

 {
    "_id": {
           "$oid": "64a691e0c91b64aa2c0446ce"
           },
    "image": "1.jpg",
    "eligible":false
  }

Thanks in advance

Is there any good method to resize and reposition pictures?

I have a big background picture with two black blocks and two small pictures to cover the black blocks in a div tag. I want to implement the result that I can use the input tag as range to resize all pictures and two small pictures will be repositioned to cover the black block. The size will be increased correctly, but the positions are not correct.

when the zoom is 40%

when the zoom is 50%

when the zoom is 100%

the code is shown below:

<!DOCTYPE html>
<html>
<head>
<style>
    #box {
        width:300px;
        height:300px;
    }
</style>

<script>
function load()
{
    var range = document.getElementById('range');
    var zoom = document.getElementById('zoom');

    zoom.innerHTML = range.value + "%";
}

function get()
{
    var range = document.getElementById('range');
    var zoom = document.getElementById('zoom');
    var box = document.getElementById('box');
    var new_w;
    var new_h;
    var new_top;
    var new_left;
    zoom.innerHTML = range.value + "%";

    var myimg = box.getElementsByTagName('img');
    for(var i=0; i < myimg.length; i++){
        if(i == 0){
            new_w = (300 * 2 * range.value / 100);
            new_h = (300 * 2 * range.value / 100);
        }
        else if(i == 1){
            new_w = 58 * 2 * range.value / 100;
            new_h = 48 * 2 * range.value / 100;
            new_top = 37 * 2 * range.value / 100;
            new_left = 17 * 2 * range.value / 100;
        }
        else{
            new_w = 76 * 2 * range.value / 100;
            new_h = 88 * 2 * range.value / 100;
            new_top = 65 * 2 * range.value / 100;
            new_left = 223 * 2 * range.value / 100;
        }

        myimg[i].width = new_w ;
        myimg[i].height = new_h ;

        myimg[i].style.top = new_top + "px";
        myimg[i].style.left = new_left + "px";

    }
}

</script>
</head>

<body onload="load();">
    zoom : <input type="range" min="1" max="100" value="50" id="range" onmousemove="get();"></input><span id="zoom"></span>
    <div id="box">
        <img src="img_back.jpg" alt="Girl in a jacket" alt="green" width=100% height=100%>
        <img src="img_chania.jpg" alt="Flowers in Chania" width=58px height=48px alt="green" style="position:absolute;top:37px;left:17px">
        <img src="pic_trulli.jpg" alt="Trulli" width=76px height=88px alt="green" style="position:absolute;top:65px;left:223px">
    </div>
</body>
</html>

By the way, is there any other method to implement resize and reposition pictures by using one div tag? I don’t want to resize and reposition them one by one by loop. In fact, my project has one background pictures and some small pictures(not only two).

Format of link is changing whenever trying to add it inside the generated document in Spring

http://localhost:3000/document?id={document.id}&pin={document.pin}

I am trying to add the link for my generated document at the end of my document in a format like above using DocumentBuilder and jsEngine.eval() method in Spring. But the link is being changed to the format below when it is being added at the end of my document.

http://localhost:3000/document?id={document.id}
in={document.pin} 

Is &p a special character in DocumentBuilder any ideas?

Converting UTF-8 data to UTF-16 with BOM

I have a variable called csv and it contains all the data I require. I want to convert this data to UTF-16LE as I want Excel to recognize the data by just opening the file, without the need of the Get Data button.

I tried using this solution, and while LibreOffice Calc does recognize it is a UTF-16 file, Excel does not decode the greek characters correctly.

Here is the JavaScript code I have:

csv = csvRows.join('rn')

      var byteArray = new Uint8Array(csv.length * 2);
      for (var i = 0; i < csv.length; i++) {
        byteArray[i * 2] = csv.charCodeAt(i) // & 0xff;
        byteArray[i * 2 + 1] = csv.charCodeAt(i) >> 8 // & 0xff;
      }

      var blob = new Blob([byteArray], { type: 'text/csv', encoding: "UTF-16LE" });
      var url = URL.createObjectURL(blob);
      sendFileToClient(url, this.el.id + ".csv")

A similar problem I had in Elixir I solved by using the :unicode module like so:

csv =
      :unicode.characters_to_binary(
        :unicode.encoding_to_bom(:utf8) <> build_csv(data),
        :utf8,
        {:utf16, :little}
      )

I tried also adding a uFEFF BOM character at the beginning of the file but that makes it so its recognized as UTF-8 BOM file (according to Notepad++). When I tried uFFFE which is the `UTF-BOM character was turned into different letters.

LibreOffice Calc opening the file without BOM

LibreOffice Calc opening the file with ufeff BOM

Excel opening the file without BOM

Excel opening the file with BOM

How to programmatically disable or avoid closing gesture on webpage that is running inside Facebook webview on iOS

I have webpage that majority of traffic coming through Facebook webview. On this page I have Swiper component edge to edge. Unfortunately, users are not able to swipe left because webview has the same gesture that closes webview. Swiping right works fine but swiping left closes view. It works as usual on regular, non-facebook-webview browsers e.g mobile Safari.
I tried to use event.preventDefault() in onTouchStart and onTouchMove handlers, CSS touch-actions: none but none of those worked. Also, none of Swiper properties – edgeSwipeDetection='prevent', touchStartForcePreventDefault={true} helped.

I want to disable gesture only when user is interacting with Swiper, basically doing swipe left gesture on slides.