Bcrypt.hashSync returns false when checking updated password

    async login(req: Request, res: Response) {
    let email = req.body.email
    const user = await User.findOne({ email: email })
    if (user) {
      if (user.schema.methods.isVerified) {
        let password: string = req.body.password
        let hashedPassword = user.password
        console.log(password, hashedPassword)
        console.log(user.schema.methods.checkPassword(password, hashedPassword))
        if (user.schema.methods.checkPassword(password, hashedPassword)) {
          res.json(dataResponse({ userId: user.id }, 200, 'Login sucess'))
        } else {
          res.json(dataResponse('', 200, 'Invalid email or password'))
        }
      } else {
        const tokenItem = await Token.findOne({ userId: user.id })
        if (tokenItem) {
          if (tokenItem.schema.methods.isNotExpired) {
            await Token.deleteMany().where({ userId: user._id })
            await tokenController.create({ userId: user._id, email: email })
            res.json(
            dataResponse(null, 406, 'Your'e account is not verified,a new token has been sent to your email')
          )
          } else {
            await Token.deleteMany().where({ userId: user.id })
            await User.deleteMany().where({ _id: user.id })
            res.json(
              dataResponse(
                '',
                401,
                "Your account doesn't exist, please sign up "
              )
            )
          }
        } else{
            await tokenController.create({ userId: user._id, email: email })
            res.json(
                dataResponse(null, 406, 'Your'e account is not verified,a new token has been sent to your email')
            )
        }
      }
    } else{
        res.json(dataResponse('', 401, 'This account doesn't exist, please sign up'))
    }
  }

  async forgotPassword(req: Request, res: Response) {
    let email = req.body.email 
    let password = req.body.password
    const user = await User.findOne({email:email})
    if(user){
      if(user.schema.methods.isVerified){
        await user.updateOne({ password })
        await user.save()
        res.json(dataResponse('', 200, 'Password reset successful'))
      } else {
        res.json(dataResponse('', 401, 'Your account is not verified please try logging in'))
      }
    } else {
      res.json(dataResponse('', 401, 'This account does not exist.'))
    }
  }

Above is the login functionality that I created to get the user logged in. I am using mongoose middleware to hash the password and check the hashed password

    userSchema.pre('save', function (next) {
  this.password = bcrypt.hashSync(this.password, 10)
  next()
})

For hashing password

    userSchema.methods.checkPassword = function (
  password: string,
  hashedPassword: string
) {
return bcrypt.compareSync(password, hashedPassword)
}

For updating password. Now the problem is when I register and login, it works. However, when I update the password, then the login function doesn’t work. More specifically the checkPassword method returns false. And, yes the password is changed sucessfully, it is saved in database but the method returns false.

    async forgotPassword(req: Request, res: Response) {
    let email = req.body.email 
    let password = req.body.password
    const user = await User.findOne({email:email})
    if(user){
      if(user.schema.methods.isVerified){
        await user.updateOne({ password })
        await user.save()
        res.json(dataResponse('', 200, 'Password reset successful'))
      } else {
        res.json(dataResponse('', 401, 'Your account is not verified please try logging in'))
      }
    } else {
      res.json(dataResponse('', 401, 'This account does not exist.'))
    }
  }

That is the method I used to update password.

I wanted the login to be successful but even though the password is changed and is being displayed as change the comparesync on bcrypt returns false. Only while updating but works while registering.

What’s the purpose of lodash invoke in this code?

I am seeing a piece of code:

const format = _invoke(Intl, 'DateTimeFormat')

And for me it looks like it can be replaced by a simpler variant:

const format = Intl.DateTimeFormat

However, I am afraid it can work in a different way when changed to latter because it’s not just a function but a method of an object?

So, why the author of the code could’ve used it that way?

How do i configure data labels that automatically shown in the chart using Chart.js?

I have some problems in configuring the data labels. I wanted to show its value, but it seems that these data labels cannot be changed nor be deleted as you can see in the image attached that I circled yellow, that’s the data label that cannot be changed. I have tried every possible way to change or delete it but it is still there and I don’t know why.

Bar-line chart

Please help me. This is the function for generating this chart:

        function renderChart() {
            // var ctx = document.getElementById('rocsChart').getContext('2d');
        
            let data = {
                labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agt', 'Sep', 'Okt', 'Nov', 'Des'],
                datasets: [{
                        label: 'ROCS',
                        // type: 'bar',
                        data: [-3971030560.1713, -3658191029.3873, -7636333358.9906, 2550158674.6845],
                        backgroundColor: 'rgba(75, 192, 192, 0.5)',
                        yAxisID: 'test1'
                    },
                    {
                        label: 'ROCS%',
                        type: 'line',
                        data: [-13, -12, -26, -8],
                        borderColor: 'rgba(255, 99, 132, 1)',
                        borderWidth: 2,
                        fill: false,
                        yAxisID: 'test2'
                    }
                ]

            };
        
            const options = {
                scales: {
                    yAxes: [{
                        id: 'test1',
                        type: 'linear',
                        position: 'left',
                        ticks: {
                            callback: function(value, index, values) {
                                return value;
                            }
                        }
                    }, 
                    {
                        id: 'test2',
                        type: 'linear',
                        position: 'right',
                        ticks: {
                            callback: function(value, index, values) {
                                return value;
                            }
                        }
                    }]
                },
                plugins: {
                    datalabels: {
                        align: 'end',
                        anchor: 'end',        
                        backgroundColor: function(context) {
                            return context.dataset.backgroundColor;
                        },
                        borderRadius: 4,
                        color: 'white',
                        formatter: function(value, context) {
                            return value;
                        }
                    }
                },
                tooltips: {
                    enabled: false
                }
            };

For added context, this is the plugins ive been using:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
    <script src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    <script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-title"></script>

Thank you in advance.

I expecting that the data labels can be changed to the data values

Script Not Changing Based On Year or Type of Stats Selected

https://www.eastvanbaseball.com/statistics/leaders The dropdown menus should change the year and type of stats, but it’s not working.

Here is the javascript:

var m,pushStat,z,count,assignTeam,getYear=2023,statsFile="/assets/stats/EVBL-stats-"+getYear+".json?nocache="+(new Date).getTime(),teamNameData=[{fullName:"East Van Black Sox",lastName:"Black Sox",abbr:"SOX",logoPath:"Black_Sox.png"},{fullName:"Little Mtn Blasters",lastName:"Blasters",abbr:"LM",logoPath:"blasters.png"},{fullName:"Clark Park Brawlers",lastName:"Brawlers",abbr:"CP",logoPath:"brawlers.png"},{fullName:"Chinatown Cobras",lastName:"Cobras",abbr:"CHN",logoPath:"Cobras.png"},{fullName:"Sunrise Cosmos",lastName:"Cosmos",abbr:"COS",logoPath:"cosmos.png"},{fullName:"Gastown Gaolers",lastName:"Gaolers",abbr:"GAS",logoPath:"Gaolers.png"},{fullName:"Vancouver Isotopes",lastName:"Isotopes",abbr:"VAN",logoPath:"isotopes.png"},{fullName:"Mt Pleasant Murder",lastName:"Murder",abbr:"MT",logoPath:"Murder.png"},{fullName:"Railtown Spikers",lastName:"Spikers",abbr:"RT",logoPath:"Spikers_alt.png"},{fullName:"Strathcona Stevedores",lastName:"Stevedores",abbr:"STR",logoPath:"Stevedores.png"},{fullName:"Sunset Stilettos",lastName:"Stilettos",abbr:"SET",logoPath:"Stilettos.png"}],logoRootURL="/assets/team_logos/",battingStatsTabs=[20,11,12,28,23,22,21,9,10],pitchingStatsTabs=[69,67,70,54,57,59,101,99],tablelength=15,qualifyPA=0,qualifyBF=0,batHeaderLine=[],pitchHeaderLine=[],batNameTable=[],pitchNameTable=[],batTeamTable=[],pitchTeamTable=[],batStatTable=[],pitchStatTable=[],playerPA=[],playerBF=[],batTableHtmlMobile="",pitchTableHtmlMobile="",batHtml='<div id="batting_leaders"><h3>BATTING LEADERS</h3>',pitchHtml='<div id="pitching_leaders"><h3>PITCHING LEADERS</h3>',batHtmlMobile='<div id="batting_leadersMobile"><h3>BATTING LEADERS</h3><div id="bat_tabs">',pitchHtmlMobile='<div id="pitching_leadersMobile"><h3>PITCHING LEADERS</h3><div id="pitch_tabs">',batTabsHtml="<ul>",pitchTabsHtml="<ul>";for(m=0;m<battingStatsTabs.length;m++)batStatTable[m]=[];for(m=0;m<pitchingStatsTabs.length;m++)pitchStatTable[m]=[];$.ajax({type:"GET",url:statsFile,async:!1}).done(function(t){for(var a=0;a<t.player.length;a++){if(0==a)for(l in t.player[a])batHeaderLine.push(l);if("Ringer"!=t.player[a].Last.substr(0,6)&&"0"!=t.player[a].Last.substr(0,1)&&0<t.player[a].Last.length&&t.player[a].Number.length<3){batNameTable.push(t.player[a].Last),assignTeam=-1;for(var e=0;teamNameData[e].lastName==t.player[a].team&&(assignTeam=e,batTeamTable.push(assignTeam)),e++,assignTeam<0;);for(qualifyPA+=Number(t.player[a].PA),playerPA.push(t.player[a].PA),m=0;m<battingStatsTabs.length;m++)pushStat=batHeaderLine[battingStatsTabs[m]],batStatTable[m].push(Number(t.player[a][pushStat]))}}(qualifyPA=Math.round(qualifyPA/batNameTable.length*.5))<1&&(qualifyPA=0),0<qualifyPA&&(batHtml+="<p>*Minimum "+qualifyPA+" plate appearances</p>");for(a=0;a<t.player.length;a++){var l;if(0==a)for(l in t.player[a])pitchHeaderLine.push(l);if("Ringer"!=t.player[a].Last.substr(0,6)&&"0"!=t.player[a].Last.substr(0,1)&&0<t.player[a].Last.length&&t.player[a].Number.length<3&&0<t.player[a].IP){pitchNameTable.push(t.player[a].Last),assignTeam=-1;for(e=0;teamNameData[e].lastName==t.player[a].team&&(assignTeam=e,pitchTeamTable.push(assignTeam)),e++,assignTeam<0;);for(qualifyBF+=Number(t.player[a].BF),playerBF.push(t.player[a].BF),m=0;m<pitchingStatsTabs.length;m++)pushStat=pitchHeaderLine[pitchingStatsTabs[m]],pitchStatTable[m].push(Number(t.player[a][pushStat]))}}for((qualifyBF=Math.round(qualifyBF/pitchNameTable.length*.6))<1&&(qualifyBF=0),0<qualifyBF&&(pitchHtml+="<p>*Minimum "+qualifyBF+" batters faced</p>"),m=0;m<battingStatsTabs.length;m++){29==battingStatsTabs[m]&&(batHeaderLine[battingStatsTabs[m]]="RISP"),batTabsHtml+='<li><a href="#fragment-'+(m+1)+'"><span>'+batHeaderLine[battingStatsTabs[m]]+"</span></a></li>",batTableHtmlMobile+='<div id="fragment-'+(m+1)+'">',batHtml+='<div class = "statTable"><table class="leaders"><thead><tr><th colspan="4" valign="middle">'+batHeaderLine[battingStatsTabs[m]]+"</th></tr></thead><tbody>";var i=batStatTable[m].length,b=new Array(i);for(a=0;a<i;++a)b[a]=a,b.sort(function(t,a){return batStatTable[m][t]>batStatTable[m][a]?-1:batStatTable[m][t]<batStatTable[m][a]?1:playerPA[m][t]>playerPA[m][a]?-1:playerPA[m][t]<playerPA[m][a]?1:0});for(batTableHtmlMobile+='<table class="leadersMobile"><thead><tr><th class="rank" valign="middle"></th><th class="team"></th><th class="player" valign="middle"></th><th class="stat" valign="middle"></th></tr></thead><tbody>',count=z=0;count<tablelength;)playerPA[b[z]]>qualifyPA&&(batTableHtmlMobile+="<tr",batHtml+="<tr","HR"!=batHeaderLine[battingStatsTabs[m]]&&"RBI"!=batHeaderLine[battingStatsTabs[m]]&&"SB"!=batHeaderLine[battingStatsTabs[m]]&&"2B"!=batHeaderLine[battingStatsTabs[m]]&&"3B"!=batHeaderLine[battingStatsTabs[m]]||0==batStatTable[m][b[z]]&&(batTableHtmlMobile+=' class="hidden"',batHtml+=' class="hidden"'),batTableHtmlMobile+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[batTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[batTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+batNameTable[b[z]]+'</td><td class="stat" valign="middle">',batHtml+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[batTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[batTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+batNameTable[b[z]]+'</td><td class="stat" valign="middle">',"AVG"==batHeaderLine[battingStatsTabs[m]]||"SLG"==batHeaderLine[battingStatsTabs[m]]||"OBP"==batHeaderLine[battingStatsTabs[m]]||"RISP"==batHeaderLine[battingStatsTabs[m]]||"OPS"==batHeaderLine[battingStatsTabs[m]]?.999<Number(batStatTable[m][b[z]])?(batTableHtmlMobile+=Number(batStatTable[m][b[z]]).toFixed(3),batHtml+=Number(batStatTable[m][b[z]]).toFixed(3)):(batTableHtmlMobile+=Number(batStatTable[m][b[z]]).toFixed(3).toString().substr(1),batHtml+=Number(batStatTable[m][b[z]]).toFixed(3).toString().substr(1)):(batTableHtmlMobile+=batStatTable[m][b[z]],batHtml+=batStatTable[m][b[z]]),batTableHtmlMobile+="</td></tr>",batHtml+="</td></tr>",count++),z++;batTableHtmlMobile+="</tbody></table></div>",batHtml+="</tbody></table></div>"}for(batTabsHtml+="</ul>",batHtml+="</div>",m=0;m<pitchingStatsTabs.length;m++){67==pitchingStatsTabs[m]&&(pitchHeaderLine[pitchingStatsTabs[m]]="K"),99==pitchingStatsTabs[m]&&(pitchHeaderLine[pitchingStatsTabs[m]]="K/7"),pitchTabsHtml+='<li><a href="#fragment-'+(m+1)+'"><span>'+pitchHeaderLine[pitchingStatsTabs[m]]+"</span></a></li>",pitchTableHtmlMobile+='<div id="fragment-'+(m+1)+'">',pitchHtml+='<div class = "statTable"><table class="leaders"><thead><tr><th colspan="4" valign="middle">'+pitchHeaderLine[pitchingStatsTabs[m]]+"</th></tr></thead><tbody>";i=pitchStatTable[m].length,b=new Array(i);for(a=0;a<i;++a)b[a]=a,"ERA"==pitchHeaderLine[pitchingStatsTabs[m]]||"WHIP"==pitchHeaderLine[pitchingStatsTabs[m]]?b.sort(function(t,a){return pitchStatTable[m][t]<pitchStatTable[m][a]?-1:pitchStatTable[m][t]>pitchStatTable[m][a]?1:playerBF[m][t]>playerBF[m][a]?-1:playerBF[m][t]<playerBF[m][a]?1:0}):b.sort(function(t,a){return pitchStatTable[m][t]>pitchStatTable[m][a]?-1:pitchStatTable[m][t]<pitchStatTable[m][a]?1:playerBF[m][t]>playerBF[m][a]?-1:playerBF[m][t]<playerBF[m][a]?1:0});for(pitchTableHtmlMobile+='<table class="leadersMobile"><thead><tr><th class="rank" valign="middle"></th><th class="team" valign="middle"></th><th class="player" valign="middle"></th><th class="stat" valign="middle"></th></tr></thead><tbody>',count=z=0;count<tablelength;)playerBF[b[z]]>qualifyBF&&(pitchTableHtmlMobile+="<tr",pitchHtml+="<tr","K"!=pitchHeaderLine[pitchingStatsTabs[m]]&&"W"!=pitchHeaderLine[pitchingStatsTabs[m]]&&"SV"!=pitchHeaderLine[pitchingStatsTabs[m]]||0==pitchStatTable[m][b[z]]&&(pitchTableHtmlMobile+=' class="hidden"',pitchHtml+=' class="hidden"'),pitchTableHtmlMobile+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[pitchTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[pitchTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+pitchNameTable[b[z]]+'</td><td class="stat" valign="middle">',pitchHtml+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[pitchTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[pitchTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+pitchNameTable[b[z]]+'</td><td class="stat" valign="middle">',"ERA"==pitchHeaderLine[pitchingStatsTabs[m]]?(pitchTableHtmlMobile+=(7*Number(pitchStatTable[m][b[z]])/7).toFixed(2),pitchHtml+=(7*Number(pitchStatTable[m][b[z]])/7).toFixed(2)):"WHIP"==pitchHeaderLine[pitchingStatsTabs[m]]||"K/BB"==pitchHeaderLine[pitchingStatsTabs[m]]||"K/7"==pitchHeaderLine[pitchingStatsTabs[m]]?(pitchTableHtmlMobile+=Number(pitchStatTable[m][b[z]]).toFixed(2),pitchHtml+=Number(pitchStatTable[m][b[z]]).toFixed(2)):"IP"==pitchHeaderLine[pitchingStatsTabs[m]]?(pitchTableHtmlMobile+=Number(pitchStatTable[m][b[z]]).toFixed(1),pitchHtml+=Number(pitchStatTable[m][b[z]]).toFixed(1)):(pitchTableHtmlMobile+=pitchStatTable[m][b[z]],pitchHtml+=pitchStatTable[m][b[z]]),pitchTableHtmlMobile+="</td></tr>",pitchHtml+="</td></tr>",count++),z++;pitchTableHtmlMobile+="</tbody></table></div>",pitchHtml+="</tbody></table></div>"}pitchHtml+="</div>",batHtmlMobile+=batTabsHtml+batTableHtmlMobile+"</div>",pitchHtmlMobile+=(pitchTabsHtml+="</ul>")+pitchTableHtmlMobile+"</div>",$("#leadersTableMobile").html(""),$("#leadersTableMobile").append(batHtmlMobile),$("#leadersTableMobile").append(pitchHtmlMobile),$("#bat_tabs").tabs(),$("#pitch_tabs").tabs(),$("#leadersTable").html(""),$("#leadersTable").append(batHtml),$("#leadersTable").append(pitchHtml)});

I want to Set a origin in chrome console

Im trying to set a origin with this code in chrome console

var xhr = new XMLHttpRequest();

xhr.open('PUT', url, true);

xhr.setRequestHeader('Origin','https://andromeda');

But chrome is saying “Refused to set unsafe header “Origin””
How can i handle this error

i tried using “Access-Control-Allow-Origin: *”
And i tried some chrome extensions

Overlay one image over another with bit of image processing based on different shapes

I am working on a project where user will upload a design(image in .png, .jpg, .jpeg) and we will automatically create multiple images of that design on different products like tshrit, mugs, mobile case.
For example here is the design and here are the images I have created by me using photoshop. and I am creating this again and again for every design which requires a bit of zooming, croping, curving and color correction etc and saving it in .webp. But I have created a placeholder which makes things easy in photoshop but I am planning to introduce more designs and more images of single product. And with every design, my work increases exponentially.

So I want to automate this process using nextJS(typescript) and create all images on the server after user uploads a design.

If possible, can anybody share any library or the approach. I am open to creating lamda function in other programming languages also if work can be reduced substantially but always prefer javascript/typescript as here community is huge.

I have an approach in mind.
As I have the photoshop file with me, so I have the bottom and top layers with me. I can merge the uploaded designs with bottom and top layer and then do the remaining processing, but don’t know, how to move image with reference to another image, how to curve it like in case of shower curtain or tshirt, how to give 3d effect like given in tshirt.

Incase you want to try/test it, you can see redbubble.com, register as artist and upload any image, they are already doing it successfully. I want the same functionality.

Any help would be highly appreciated.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

How can i use APISetu to get documents from digilocker

I am trying to integrate digilocker apis in my program where i am confused about lots of things, I need stepwise details to use digilocker to perform the following tasks:

  • First open digilocker page for user registration
  • When user registers ask consent for required documents (Aadhar and driving license)
  • After that collect the document and store in my database and in website give a success response

I am successful in first two tasks using the generated api key from api setu partners and i am also sure that it is calling a callback api after the consent is given. But i have no idea from where that callback api is coming. I can also change the api but i am not sure how can i alter it to get the desired files.

Rowlayout and Flickable in qml

I have been trying to implement flickable along with in a rowlayout…But i am not able to implement the functionality.
Flickable {
id: flickableRow
width: parent.width
height: 200
contentWidth: rowLayout.width
flickableDirection: Flickable.HorizontalFlick
boundsBehavior: Flickable.StopAtBounds

    RowLayout {
        id: rowLayout
        x: 149
        y: 750
        spacing: 20

        // Image 2
        Image {
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            source: frameSources[1]

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    valueSource.currentIndex = 1;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    image.source = parent.source;
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        // Image 3
        Image {
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            source: frameSources[2]

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    valueSource.currentIndex = 2;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    image.source = parent.source;
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }
        Rectangle{
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200

        }
        Rectangle{
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200

        }

        // Image 4
        Image {
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            source: frameSources[3]

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    valueSource.currentIndex = 3;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    image.source = parent.source;
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        // Image 5
        Image {
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            source: frameSources[4]

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    valueSource.currentIndex = 4;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    image.source = parent.source;
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        Image {
            id: image8
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            fillMode: Image.PreserveAspectFit
            source: frameSources[5]
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    valueSource.currentIndex = 5;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    image.source = parent.source;
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        Image {
            id: image9
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            fillMode: Image.PreserveAspectFit
            source: frameSources[6]
            MouseArea {
                anchors.bottomMargin: -8
                anchors.leftMargin: 0
                anchors.rightMargin: 0
                anchors.topMargin: 8
                anchors.fill: parent
                onClicked: {
                    image.source = parent.source;
                    valueSource.currentIndex = 6;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        Image {
            id: image10
            x: 1228
            y: 715
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            fillMode: Image.PreserveAspectFit
            source: frameSources[7]
            MouseArea {
                anchors.bottomMargin: -8
                anchors.leftMargin: 0
                anchors.rightMargin: 0
                anchors.topMargin: 8
                anchors.fill: parent
                onClicked: {
                    image.source = parent.source;
                    valueSource.currentIndex = 7;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        Image {
            id: image11
            x: 1440
            y: 715
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            fillMode: Image.PreserveAspectFit
            source: frameSources[8]
            MouseArea {
                anchors.bottomMargin: -8
                anchors.leftMargin: 0
                anchors.rightMargin: 0
                anchors.topMargin: 8
                anchors.fill: parent
                onClicked: {
                    image.source = parent.source;
                    valueSource.currentIndex = 8;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }

        Image {
            id: image1
            Layout.preferredWidth: 200
            Layout.preferredHeight: 200
            source: frameSources[0]
            fillMode: Image.PreserveAspectFit

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    valueSource.currentIndex = 0;
                    mediaPlayer.source = valueSource.selectedFilePaths[valueSource.currentIndex];
                    mediaPlayer.play();
                    image.source = parent.source;
                    music_file.clickCounts[valueSource.currentIndex]++;
                    music_file.updateMostClickedFrames();
                }
            }
        }


    }

} 

I tried a with a function to automaically swipe left,the function is being called every 1 sec … that was working fine.

Input field to accept text automatically without having to click on it in HTML

I am using a popup container in HTML, that contains one label (input) option for text, and a few buttons. I want the user to be able to start typing into the input field when the popup opens (which is triggered by a keybaord shortcut I am using), not necessarily having to click on it. how can i do so?

This is my HTML code snippet of the Popup menu:

   <div id="popupContainer">
        <div id="popupContent">
            <label for="AnnotateLabel">Label:
            <input type="text" id="AnnotateLabel" autocomplete="off" required>
            </label><br>    
            <button id="saveButton">Save</button>
            <button id="deleteButton">Delete</button><br><br>
            <!--<button id="closeButton">Close</button><br>-->
            <label for="loopRegion">Loop Region:
            <input type="checkbox" id="loopRegion" checked> </label><br>
            <!--<button id="playPopup">Play</button>-->
            <span>Playback Rate: </span>
            <button class="play-quarterx" data-action="play-quarterx">0.25x</button>
            <button class="play-halfx" data-action="play-halfx">0.5x</button>
            <button class="play-1x" data-action="play-1x">1.0x</button>
            
        </div>
    </div>

On screen keyboard in safari and chrome coming over fixed Input bottomsheet

I have in a portal position: fixed; bottom: 0; top: initial; right:0; left: 0; bottomsheet element
which comes up as a click to action. Which has an input box for providing input for login.

When tapped on, it gets focused and the default soft keyboard comes up on the safari and chrome as expected.

On some instances the keyboard comes up the fixed input bottomsheet moves up along with keyboard but on some the keyboard comes over the input bottomsheet hiding it completely.

I tried few things:

  1. i kept user-scalable="no" in the viewport meta.
  2. I added margin-bottom: calc( 20px + env(keyboard-inset-height)); but this is not supported on safari but did not work on chrome either.
  3. i added window.visualViewport.addEventListener('resize', resizeFunction);
    in this function i added
(initialVisualViewPortHeight - finalVisualViewPortHeight); // this height as the visible viewport

// added this as the current bottom value of the bottomsheet

But in the third case for few times this hack works just fine enough but in some cases safari also pushed the input box bringing it up into the view and due to this code it also moves up little which introduces extra space in the view overall.

Let me know if i am missing something. Or if there is another thing that i should try.

Is there anyway to convert svg string to jsx string

I’ve svg jsx components that i want as string so i can copy it. on the website i’m working on, i’ve provided two options to copy the svg element. one i achieved by using renderToString function from react-dom/server, that gives me svg string, and other one i want as jsx component string,

the component


const SvgComponent1 = (props) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    width={100}
    height={100}
    fill="none"
    {...props}
  >
    <path
      fill="#D9D9D9"
      stroke="#000"
      strokeWidth={5}
      d="M2.5 2.5h95v95h-95z"
    />
  </svg>
)

renderToString function result

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" fill="none"><path fill="#D9D9D9" stroke="#000" stroke-width="5" d="M2.5 2.5h95v95h-95z"></path></svg>

is this possible to convert this svg string back to the jsx string, similar to svgr playground at runtime? do i have to store the string version with the jsx code, not possible at runtime? i have many svgs.

How do i pass the parameter in url with XMLHTTPRequest for Rest API Post Method?

I am trying to add custom button in my oracle application using html markup(java script) and when its been clicked it needs to invoke the rest api with parameters passed in the url

Below is the code i have written

<html>
<head/>
<style>
   button#CallButton{
     color: #000000;
     border-color: #c4ced7;
     background-color: #f1f3f3;
     background-image: none;
     border-radius: 3px;
     border: 1px solid #c4ced7;
     text-shadow: none;
     font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
     font-size: 12px;
     font-weight: bold;
     min-height: 28px;
     margin-right: 2px;
     margin-left: 20px;
     padding-left:6px;
     padding-right:6px;
     padding-botton:50px;
    }
</style>

<body>
<button align="right" id="CallButton" onclick="(function(POid){var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
         if (this.readyState == 4 && this.status == 200) {
             alert(this.responseText);
         }};
    var url = 'https://****************.integration.ocp.oraclecloud.com:443/ic/api/integration/v1/flows/rest/poststatus/1.0/poststatus?PO='+POid;
    console.log('created url:::'+url );
    xhttp.open('Post', url, true);
    xhttp.setRequestHeader('Authorization', 'Basic ' + window.btoa('oicuser:OicPassword###'));
    xhttp.send();})(917274);this.disabled=false;return false">Call PaaS Build</button>
</body>
</html>

Appreciate any help

How to halt/pause other iframes if one iframe is already playing iframe source has externally hosted video?

I have hosted my videos in bunny cdn for faster bandwidth, Now embedding 5 videos in a single HTML web page, The problem is I am unable halt/pause other iframes automatically if one iframe is already playing?iframe source has externally hosted video?

I have tried give the external link in video source tag but it’s not working.
Can anyone quickly give me JS or Jquery to solve my problem

On click function is not working in script

In product_detail.html:

{% extends 'partials/base.html'%}


{%load static%}

{% block content %}
    <style>
            /* Basic Styling */
      html, body {
        height: 100%;
        width: 100%;
        margin: 0;
        font-family: 'Roboto', sans-serif;
      }

      .containerbox {
        max-width: 1200px;
        margin: 0 auto;
        padding: 15px;
        display: flex;
      }

      /* Columns */
      .left-column {
        width: 65%;
        position: relative;
      }

      .right-column {
        width: 35%;
        margin-top: 60px;
      }


      /* Left Column */
      .left-column img {
        width: 70%;
        position: absolute;
        left: 0;
        top: 0;
        opacity: 0;
        transition: all 0.3s ease;
      }

      .left-column img.active {
        opacity: 1;
      }


      /* Right Column */

      /* Product Description */
      .product-description {
        border-bottom: 1px solid #E1E8EE;
        margin-bottom: 20px;
      }
      .product-description span {
        font-size: 12px;
        color: #358ED7;
        letter-spacing: 1px;
        text-transform: uppercase;
        text-decoration: none;
      }
      .product-description h1 {
        font-weight: 300;
        font-size: 52px;
        color: #43484D;
        letter-spacing: -2px;
      }
      .product-description p {
        font-size: 16px;
        font-weight: 300;
        color: #86939E;
        line-height: 24px;
      }

      /* Product Configuration */
      .product-color span,
      .cable-config span {
        font-size: 14px;
        font-weight: 400;
        color: #86939E;
        margin-bottom: 20px;
        display: inline-block;
      }

      /* Product Color */
      .product-color {
        margin-bottom: 30px;
      }

      .color-choose div {
        display: inline-block;
      }

      .color-choose input[type="radio"] {
        display: none;
      }

      .color-choose input[type="radio"] + label span {
        display: inline-block;
        width: 40px;
        height: 40px;
        margin: -1px 4px 0 0;
        vertical-align: middle;
        cursor: pointer;
        border-radius: 50%;
      }

      .color-choose input[type="radio"] + label span {
        border: 2px solid #FFFFFF;
        box-shadow: 0 1px 3px 0 rgba(0,0,0,0.33);
      }

      .color-choose input[type="radio"]#red + label span {
        background-color: #C91524;
      }
      .color-choose input[type="radio"]#blue + label span {
        background-color: #314780;
      }
      .color-choose input[type="radio"]#black + label span {
        background-color: #323232;
      }

      .color-choose input[type="radio"]:checked + label span {
        background-image: url(images/check-icn.svg);
        background-repeat: no-repeat;
        background-position: center;
      }

      /* Cable Configuration */
      .size-choose {
        margin-bottom: 20px;
      }

      .size-choose button {
        border: 2px solid #E1E8EE;
        border-radius: 6px;
        padding: 13px 20px;
        font-size: 14px;
        color: #5E6977;
        background-color: #fff;
        cursor: pointer;
        transition: all .5s;
      }

      .size-choose button:hover,
      .size-choose button:active,
      .size-choose button:focus {
        border: 2px solid #86939E;
        outline: none;
      }

      .size-config {
        border-bottom: 1px solid #E1E8EE;
        margin-bottom: 20px;
      }

      .size-config a {
        color: #358ED7;
        text-decoration: none;
        font-size: 12px;
        position: relative;
        margin: 10px 0;
        display: inline-block;
      }
      .size-config a:before {
        content: "?";
        height: 15px;
        width: 15px;
        border-radius: 50%;
        border: 2px solid rgba(53, 142, 215, 0.5);
        display: inline-block;
        text-align: center;
        line-height: 16px;
        opacity: 0.5;
        margin-right: 5px;
      }

      /* Product Price */
      /*.product-price {
        display: flex;
        align-items: center;
      }

      .product-price span {
        font-size: 26px;
        font-weight: 300;
        color: #43474D;
        margin-right: 20px;
      }*/

      .cart-btn {
        display: inline-block;
        background-color: #FFB6C1;
        border-radius: 6px;
        font-size: 16px;
        color: #FFFFFF;
        text-decoration: none;
        padding: 12px 30px;
        transition: all .5s;
      }
      .cart-btn:hover {
        background-color:  #ff0000;
      }
      .buynow-btn {
        display: inline-block;
        background-color: #FFB6C1;
        border-radius: 6px;
        font-size: 16px;
        color: #FFFFFF;
        text-decoration: none;
        padding: 12px 30px;
        transition: all .5s;
      }
      .buynow-btn:hover {
        background-color:  #ff0000;
      }

      /* Responsive */
      @media (max-width: 940px) {
        .container {
          flex-direction: column;
          margin-top: 60px;
        }

        .left-column,
        .right-column {
          width: 100%;
        }

        .left-column img {
          width: 300px;
          right: 0;
          top: -65px;
          left: initial;
        }
      }

      @media (max-width: 535px) {
        .left-column img {
          width: 220px;
          top: -85px;
        }
      }
        .product-price {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
        }

        .price {
            font-size: 24px;
            font-weight: bold;
            color: #333; /* Price color */
            margin-bottom: 5px;
        }

        del {
            color: #999; /* Old price color */
            font-size: 18px;
        }


    </style>
    <meta name="robots" content="noindex,follow" />

  </head>

  <body>
    <main class="containerbox">

      <!-- Left Column / Headphones Image -->
      <div class="left-column">
        {%  for p in p_image  %}
        <img data-image="black" src="{{  p.images.url  }}" alt="Hi1">
        {%  endfor  %}
        <!-- {%  for q in p_image  %}
        <img data-image="blue" src="{{  q.images.url  }}" alt="Hi2">
        {%  endfor  %} -->
        <img data-image="red" class="active" src="{{p.image.url}}" alt="Hi">
        <!-- <p class="showcase-badge">{{p.get_percentage|floatformat:0}}% off</p> -->
      </div>


      <!-- Right Column -->
      <div class="right-column">

        <!-- Product Description -->
        <div class="product-description">
          <span>{{p.vendor}}</span>
          <h1>{{p.title}}</h1>
          <p>{{p.description}}</p>
        </div>

        <!-- Product Configuration -->
        <div class="product-configuration">

          <!-- Product Color -->
          <div class="product-color">
            <span>Color</span>

            <div class="color-choose">
                {% for c in colors %}
              <div>
                <input data-image="{{c.code}}" type="radio" id="{{c.code}}" name="color" value="{{c.code}}" checked>
                <label for="red"><span></span></label>
              </div>
              {% endfor %}
              <!-- <div>
                <input data-image="blue" type="radio" id="blue" name="color" value="blue">
                <label for="blue"><span></span></label>
              </div>
              <div>
                <input data-image="black" type="radio" id="black" name="color" value="black">
                <label for="black"><span></span></label>
              </div> -->
            </div>

          </div>

          <!-- Cable Configuration -->
          <div class="size-config">
            {% for s in sizes %}
            <span>Sizes</span>

            <div class="size-choose">
              <button>{{s.name}}</button>
            </div>
            {% endfor %}

            <a href="#">How to configurate your headphones</a>
          </div>
        </div>

        <!-- Product Pricing -->
        <div class="product-price">
          <p class="price">New Price: {{p.price}} </p>

          <del>Old Price: {{p.old_price}}</del>
        </div>
          <a href="#" class="cart-btn">Add to cart</a>
          <a href="#" class="buynow-btn">Buy Now</a>
        <!-- </div> -->
      </div>
    </main>

    <!-- Scripts -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" charset="utf-8"></script>
    <script>
            $(document).ready(function() {

      $('.color-choose input').on('click', function() {
          var productColor = $(this).attr('data-image');

          $('.active').removeClass('active');
          $('.left-column img[data-image = ' + productColor + ']').addClass('active');
          $(this).addClass('active');
      });

      });

    </script>
  </body>
{% endblock content %}

I created this product-details html page Where I created checkbox(radio) but when I am clicking on the checkboxs it is not working
In the original template all the things are working perfectly. My views and model also are working

To see my problem in detail please click the link:

https://youtu.be/SAfs2UepWqc

you can see in the video that when I add a new color in products it is working(I mean previously in page page there are four colors after adding one there is five colors) but when I am clicking on the colors it is not changing the images.

Though I uploded more than one image you can see In the below video by visting the link:

https://youtu.be/BtRq0XeijmY