@nuxt/auth-next authentification with Google Oauth2

I need to make authentification with google oauth2.
I’ve installed nuxt/auth-next and created configuration for authentification like this.

  auth: {
    strategies: {
      google: {
        scope: ['profile', 'email'],
        endpoints: {
          userInfo: `${process.env.API_URL}/user`
        },
        codeChallengeMethod: '',
        token: {
          property: 'id_token'
        },
        refreshToken: {
          property: 'refresh_token'
        },
        prompt: 'consent',
        access_type: 'offline',
        responseType: 'id_token token',
        clientId: process.env.GOOGLE_CLIENT_ID
      }
    }
  }

The login part work, but the refresh_token is never added in local storage (auth._refresh_token.google = false).

I found only one thing. The refresh token is given only at the first authorization … but not for me. (Not receiving Google OAuth refresh token)
I have used https://myaccount.google.com/permissions to revert permission for my application.

Anyone faced the same problem ? Solution ?

Maybe the property of refresh_token is not good, but I didn’t find any doc about it.

Thanks for your help

How to get the label value from bar chart in javascript?

So I’ve got a bar chart which has two different bars for supply and demand and I want it to tell me which one it is when I click on the bar. Because right now it just gives me the same index and x axis when I click on the bars. So how can I fix this problem? Here is my code :

var canvas = document.getElementById('myChart');
var data = {
    labels: ["iOS", "Android", "React", "Angular", "SA", "BA", "Backbase"],
    datasets: [
        {
            label: "supply",
            fill: false,
            lineTension: 0.1,
            backgroundColor: "rgba(75,192,192,0.4)",
            borderColor: "rgba(75,192,192,1)",
            borderCapStyle: 'butt',
            borderDash: [],
            borderDashOffset: 0.0,
            borderJoinStyle: 'miter',
            pointBorderColor: "rgba(75,192,192,1)",
            pointBackgroundColor: "#fff",
            pointBorderWidth: 1,
            pointHoverRadius: 5,
            pointHoverBackgroundColor: "rgba(75,192,192,1)",
            pointHoverBorderColor: "rgba(220,220,220,1)",
            pointHoverBorderWidth: 2,
            pointRadius: 5,
            grouped: true,
            pointHitRadius: 10,
            data: [1, 2, 3, 4, 5, 6, 7],
        },
                {
            label: "demand",
            fill: false,
            lineTension: 0.1,
            backgroundColor: "rgba(75,29,192,0.4)",
            borderColor: "rgba(75,192,192,1)",
            borderCapStyle: 'butt',
            borderDash: [],
            borderDashOffset: 0.0,
            borderJoinStyle: 'miter',
            pointBorderColor: "rgba(75,192,192,1)",
            pointBackgroundColor: "#fff",
            pointBorderWidth: 1,
            pointHoverRadius: 5,
            pointHoverBackgroundColor: "rgba(75,192,192,1)",
            pointHoverBorderColor: "rgba(220,220,220,1)",
            pointHoverBorderWidth: 2,
            pointRadius: 5,
            grouped: true,
            pointHitRadius: 10,
            data: [5, 9, 8, 1, 6, 5, 4],
        }
        
    ]
};

var option = {
    showLines: true,
  onClick: function(evt) {
  
   console.log(myLineChart.getElementAtEvent(evt));
   alert(data.datasets[0].data[myLineChart.getElementAtEvent(evt)[0]._index]);
   alert(data.labels[myLineChart.getElementAtEvent(evt)[0]._index]);
  
    
    }
};
var myLineChart = Chart.Bar(canvas,{
    data:data,
  options:option
});

How can I split letters and animate its position property based on some condition

I am trying to make an alphabet soup like in this CodePen using react.

The problem i’m facing at present is that I want to display the split result inside my main component. At present i’m able to animate its CSS property a bit but unable to display the split result.

My present result inside CodeSandbox

My code is as below:

  import React from "react";

export default function SlideCard(props) {
  const { id, idx, title } = props;
  const inputText = title;

  const scatter = {
    position: "absolute",
    top: "",
    left: "",
    zIndex: "initial",
    transition: "left 2s, top 2s"
  };

  if (id !== idx) {
    //(id !==idx) indicates not active//
    var randLeft = Math.floor(Math.random() * 400);
    var randTop = Math.floor(Math.random() * 200);
    scatter.top = +randTop + "px";
    scatter.left = +randLeft + "px";
  } else {
    scatter.top = "50%";
    scatter.left = "50%";
  }

  if (id !== idx) {
    //How can I use this split inside the main component
    inputText.split("").map((letter) => {
      return letter;
    });
  }

//main component
  return <div style={scatter}>{inputText}</div>;
}

How can I delete an element in Javascript

I am trying to implement this site to imitate a survey creation application. In this website you can add questions and then add some options to each question and edit the text in both Question Titles and Options.

But user should be able to remove an option as well. I have implemented the addition of the option but I don’t know how to let the user delete a specific option. After this I can imagine it will be the same to do for deletion of questions.

If someone has done or knows how this problem should be approached I would appreciate the help.

This is my code:

const questionnaire = document.getElementById('questionaire');
newQuestion();

function newQuestion() {
    questionnaire.insertAdjacentHTML('beforeend',
        `<div class="question">
    <div contenteditable="true">Your Question</div>
    <ul></ul>
    <button type="button">Add Option</button>
   </div>`);
    newOption(questionnaire.querySelector("div.question:last-child ul"));
}

function newOption(q) {
    q.insertAdjacentHTML('beforeend',
        `<li class="optionName">
      <span contenteditable="true">Option</span>
      <input type="checkbox">
     </li>`);
}

questionnaire.onclick = ev => {
    if (ev.target.tagName === "BUTTON") {
        newOption(ev.target.closest(".question").querySelector('ul'))
    }
}

document.getElementById("addQuButton").onclick = newQuestion
body {
    background-color: #00ffaa;
}

#myText {
    margin-top: 15px;
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    text-align: center;
}

.question {
    border: 3px solid black;
    border-radius: 25px;
    margin: 30px 200px 20px 200px;
    text-align: center;
}

.question ul li {
    display: block;
}
<h1 id="myText" contenteditable="true">Survey Name</h1>
  <button type="button" id="addQuButton">Add Question</button>
  <form>
    <div id="questionaire"></div>
  </form>

two txt files data how to getting and merge based on customerid how to getting the two txt files data using with node js?

i am newly learner nodejs developer

i have two txt files like file1.txt and file2.txt file1.text data is different and file2.txt data is different but customerid is same beased on customerid id how to getting two files data

file1.txt data is:
[{'customerid':12,
'name':'xyz',
'email':'[email protected]'
},
{'customerid':14,
'name':'def',
'email':'[email protected]'
},
{'customerid':15,
'name':'pqr',
'email':'[email protected]'}
,{'customerid':17,
'name':'abc',
'email':'[email protected]'}]

file2.txt data is:
[{
' customerid':12,
 'vachilenum':26789,
 'price':390900920,
 "phone":673648494894
 },
 {'customerid':14,
 'vachilenum':26789,
 'price':390900920,
 "phone":673648494894
 },
 {'customerid':15,
 'vachilenum':26789,
 'price':390900920,
 "phone":673648494894
 },
 {'customerid':17,
 'vachilenum':26789,
 'price':390900920,
 "phone":673648494894
 }];

i am trying this code but iam not getting expected out put any one please suggest me

const arr1 = fs.readFileSync('file1.txt', 'utf8').toString();
console.log(arr1)
const arr2 = fs.readFileSync('file2.text', 'utf8').toString();
console.log(arr2)

const merge = (arr1, arr2) => {
  const temp = []

  arr1.forEach(x => {
    arr2.forEach(y => {
      if (x.id === y.id) {
        temp.push({ ...x, ...y })
      }
    })
  })

  return temp
}
console.log(merge(arr1, arr2))




   expected outputt is
       {'customerid':12,
        'name':'xyz',
        'email':'[email protected]'
        'vachilenum':26789,
         'price':390900920,
         "phone":673648494894
        },

Next.js onChange is affecting my onClick how do I seperate the two

When I run the code the buttons don’t work unless I take out onChange. I can add () to the end of my functions inside the on click but that makes them run on every key stroke. How do I fix this. It wont’t let me post my question without more text so I am going to add some dummy text to post.

import React, { useState } from "react";


export default function Username(props) {
        const [userName, setUsername] = useState('');

        let userToken
        const address = props.address;

        function handleChange(event) {
            setUsername(event.target.value);
        }


        function loginAccount() {
            console.log('account created');
        }

        function createAccount() {
            console.log('logged in');
        }

        function hi(){
            console.log('hi');
        }

        while (userToken == null)
            return (
                <>
                    <div>
                        <p className = "account-Info" >address: {address}</p>
                    </div>
                    <div id="form">
                        <h2 className='user-Create' > Username </h2>
                        <form id='set-User'>
                        <input id='username' className="user-Create" type='text' value={userName} onChange={handleChange} 
                            required minLength='3' maxLength='30' pattern="[a-zA-Z0-9_]+" title='only letters, numbers, and underscores.'/>
                            <button className='user-Create' onClick={loginAccount}>Create Account</button>
                            <button className='user-Create' onClick={createAccount}>Login</button>
                            <button className='user-Create' onClick={hi}>hi</button>
                        </form>
                    </div>
                </>
        );

        while (userToken)
            return(
                <p>hello</p>
                );
}

Change value of input field on another field’s blur event in Strapi

I’ve been struggling with the docs of strapi for this.

There’s a collection of articles. When creating an article, there are 2 fields i.e Start Date and End Date. Now when a value of Start Date changes and user is done selecting an event, I want to update the value of End Date 6 months from that.

Ofcourse the calculations of value are not a problem but I’m unable to find anything to update the value on blur event.

Right now, I’m using beforeCreate and beforeUpdate lifecycle hooks but all these hooks mentioned in strapi doc run when a user clicks Save button.

This might solve the case but this is not an idea scenario for a user coming from WordPress or any other custom CMS where this is easily doable

about button.addEventListener

If there are about 10 buttons and the buttons are numbered from 1 to 10, if button 1 is clicked, object 1 is created. If button 2 is clicked, object 2 is created and the remaining objects 1, 3 and 4 are deleted. I want to become In the present case, it is implemented by hard coding, but I want to keep this code neat and short. Help.

this is my code

document.getElementById("leg_type2").addEventListener("click",
  function() {
    Group1.children[1].visible = !Group1.children[1].visible;
    Group1.children[0].visible = false;
    Group1.children[2].visible = false;
    Group1.children[0].scale.set(0, 0, 0)
    Group1.children[1].scale.set(1, 1, 1)
    Group1.children[2].scale.set(0, 0, 0)
  });

document.getElementById("leg_type3").addEventListener("click",
  function() {
    Group1.children[2].visible = !Group1.children[2].visible;
    Group1.children[1].visible = false;
    Group1.children[0].visible = false;
    Group1.children[0].scale.set(0, 0, 0)
    Group1.children[1].scale.set(0, 0, 0)
    Group1.children[2].scale.set(1, 1, 1)
  });

How do I know (el.scrollHeight – el.scrollTop +1).toFixed(0) >= el.clientHeight.toFixed(0) its greater than by 1 than return true onScroll?

How do I know (target.scrollHeight – target.scrollTop +1).toFixed(0) >= target.clientHeight.toFixed(0) its greater than by only 1 than return true if its greater than 1 or any other value than it will return false.

I was trying this code…

const handleScroll = (event) => {
    const target = event.target;

    if ((target.scrollHeight - target.scrollTop).toFixed(0) === target.clientHeight.toFixed(0)) {

      let pageNo = page + 1;
      if (pageNo <= pageCount) {
        fetchSuppliers(data , pageNo);
        setPage(pageNo);
      }
    }
  };

This code is not working on some chrome cause in some big screen resolution the value is 201 === 200 so that time this code not working..**

so i have to try the greater than or equal condition but here has a fallback cause the left value will change on scroll like 800 >= 200 its giving true but i want when the value 201 or 202 >= 200 then it should return true otherwise return false

Help me on this regards
Thank you all

display available rooms and booked rooms in each day in fullcalander

i trying to create hotel room booking system using laravel and fullcalander. enter image description here

i am currently displaying all rooms in the hotel using one color and booked rooms in another color.
i recieved those data using 2 json objects. i need to know is how to display only available rooms and booked rooms insted display all rooms and booked rooms. (this is my first project in laravel)

this is controller

 $booked_rooms = array();
    $bookings = Booking::all();
   
    
    foreach($bookings as $booking){

       $booked_rooms[]=[

       'title'=>$booking->room_number,
       'start'=>$booking->checkin_date,
       'end'=>$booking->checkout_date
       

       ];

    }

   
    $available_rooms = array();
    $rooms = tbl_room::all();
    foreach($rooms as $room){

        $available_rooms[]=[

        'title'=>$room->room_number,
        'start'=>'2022-01-01',
        'end'=>'2023-06-16'
       
        
        ];
     }

    return view('calander.view_calander',['booked_rooms'=>$booked_rooms],['available_rooms'=>$available_rooms]);

this is my script

<script>
     var available_rooms  = @json($available_rooms);
     var booked_rooms  = @json($booked_rooms);
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calander');

var calendar = new FullCalendar.Calendar(calendarEl, {

eventSources: [
{"events":booked_rooms,
 "color":"green"   
},
{
 "events":available_rooms,
 "color":"brown"
}

],
});

calendar.render();

});

Why don’t people just use the core-js polyfill without Babel?

Both core-js and Babel enable you to write modern JS that is cross-browser compatible, core-js by polyfilling the browser and Babel by transcompiling the JS to an older version the browser understands. But my question is if core-js alone is sufficient for that purpose of cross-browser compatibility. So far as I understand, core-js alone is seemingly sufficient, while Babel alone is not (it still requires polyfilling with core-js). But then why don’t I see people just using core-js alone without Babel? Is there a cross-browser compatibility reason that makes it necessary to use Babel?

Supposing there’s no compatibility reason to use Babel and that core-js alone is sufficient for that purpose, then it seems the only reason to use Babel is for performance optimization. With Babel it will include only the parts of core-js that are needed, saving some KB and some unnecessary execution. But the full bundled & minified core-js file is still only 206KB https://cdnjs.cloudflare.com/ajax/libs/core-js/3.23.2/minified.js. Is this optimization really worth the added complexity of the extra tooling and extra transcompilation step? Why don’t people just write their modern JS and slap the core-js polyfill in a script tag and be done with it?

How to separate date and time in react native code?

I’m having issue on how to separate date and time in react native. Currently the format of the date and time is like this in API API Date & Time . I don’t know how to implement it in my react native code separating the date and time. Below i have attach the code. Pls do help me out.

const renderItem = ({item}) => (
                <View style={[GlobalStyle.AlignEventContainer]}>
                <TouchableOpacity style={[GlobalStyle.EventListContainer]} activeOpacity={0.8} onPress={() => {navigation.navigate('EventDetailScreen', {transferedData: item});}}>
                <Image style={[GlobalStyle.EventListImage]} source={{uri:item.main_image}}/>
                <View style={[GlobalStyle.EventListTitleContainer]}>
                    <Text style={[GlobalStyle.EventListTitle]}>{item.name}</Text>
                </View>
                <View style={[GlobalStyle.EventListBottomContainer]}>
                    <View style={[GlobalStyle.EventListLeftContainer]}>
                        <Text style={[GlobalStyle.EventListVenue]}>{item.venue}</Text>
                        <Text style={[GlobalStyle.EventDate]}>{item.starts_on}</Text>
                        <Text style={[GlobalStyle.EventTime]}>{item.starts_on}</Text>
                    </View>
                    <View style={[GlobalStyle.EventListRightContainer]}>
                        <Text style={[GlobalStyle.EventListFee]}>{item.price}</Text>
                    </View>
                </View>
            </TouchableOpacity>
            </View>
          )