Vue.js can’t v-bind:multiple in

<script>
export default {
  props: { multiple: { type: Boolean, default: false } }
}
</script>

<template>
  <input type="file" :multiple="multiple" />
</template>

does not work. Maybe because Vue sets the attribute after the DOM is build. And HTML does not recheck for attributes.

How do I fix this? I already tried v-once and duplicating the input element with a v-if, both failed. I need to set the multiple Attribute dynamically on component creation.

thank you.

trigger windows key + period with jquery or js [duplicate]

Since Windows 10 there is an integrated emoji collection that can be accessed with a combination (Windows logo key + . (period))

What I am trying to figure out is if there is a way to trigger that combination on an element click with either jQuery or pure JS.

I have tried searching to see if someone already has a solution for that, but can’t seem to find anything apart from that thread Is it possible to simulate key press events programmatically? but not sure how to do it.

So, for example, let say that with have this element <span id="emoji">Open Emoji</span>, how do we trigger (Windows logo key + . (period)) on click?

How to insert big HTML block in Javascript? Django JS

I have custom.js file in my django website. I need to create django – div in .js

catalog.html

                <div class="row px-3" id="products-section">

                       #-----------------
                       # This block should be placed from js
                       #-----------------
                        <div class="col-sm-4">
                            <article class="post post-medium border-0 pb-0 mb-5">
                                <div class="post-image">
                                    <a href="{% url 'product' product.url %}">
                                        <img src="media/{{product.img}}" class="img-fluid img-thumbnail img-thumbnail-no-borders rounded-0" alt="" />
                                    </a>
                                </div>

                                <div class="post-content">
                                    <h2 class="font-weight-semibold text-5 line-height-6 mt-3 mb-2"><a href="{% url 'product' product.url_dop %}">{{product.name}}</a></h2>

                                    <p>{{product.description}}</p>

                                    <div class="post-meta">
                                        <span><i class="far fa-user"></i> by <a href="{% url 'brandpage' product.manufacturer_url %}">{{product.manufacturer_name}}</a> </span>
                                        <span class="d-block mt-2"><a href="{% url 'product' product.url %}" class="btn btn-xs btn-light text-1 text-uppercase">Подробнее</a></span>
                                    </div>

                                </div>
                            </article>
                        </div>
                       #-----------------
                       # End block
                       #-----------------

                </div>

custom.js

var parent_div = document.getElementById("products-section");
var product_node = document.createElement("div");
product_node.className = "col-sm-4";
product_node.innerHTML = "Big html block here";
parent_div.append(product_node);

How i can add so big block? And also i need to replace django variables by js variables in this block.

How do I get the previous button to work as a undo button for each Tic Tac Toe move?

Why is it that when I recordBoardState(), the previous pushed board to boardState is updated to the latest board in the Google Chrome Live Server? This is preventing my previousMove() from applying the changes to the HTML document. Is there something I can do that will prevent this from happening?

let board = [
  ["", "", ""],
  ["", "", ""],
  ["", "", ""]
]


const boardState = []

var square1 = document.getElementById("square1")
square1.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square1.innerHTML = "X"
    board[0].splice(0, 1, "X")
  } else {
    square1.innerHTML = "O"
    board[0].splice(0, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square2 = document.getElementById("square2")
square2.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square2.innerHTML = "X"
    board[0].splice(1, 1, "X")
  } else {
    square2.innerHTML = "O"
    board[0].splice(1, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square3 = document.getElementById("square3")
square3.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square3.innerHTML = "X"
    board[0].splice(2, 2, "X")
  } else {
    square3.innerHTML = "O"
    board[0].splice(2, 2, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square4 = document.getElementById("square4")
square4.addEventListener("click", function(el) {
  if (turnMove() % 2 === 0) {
    square4.innerHTML = "X"
    board[1].splice(0, 1, "X")
  } else {
    square4.innerHTML = "O"
    board[1].splice(0, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square5 = document.getElementById("square5")
square5.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square5.innerHTML = "X"
    board[1].splice(1, 1, "X")
  } else {
    square5.innerHTML = "O"
    board[1].splice(1, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square6 = document.getElementById("square6")
square6.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square6.innerHTML = "X"
    board[1].splice(2, 2, "X")
  } else {
    square6.innerHTML = "O"
    board[1].splice(2, 2, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square7 = document.getElementById("square7")
square7.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square7.innerHTML = "X"
    board[2].splice(0, 1, "X")
  } else {
    square7.innerHTML = "O"
    board[2].splice(0, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square8 = document.getElementById("square8")
square8.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square8.innerHTML = "X"
    board[2].splice(1, 1, "X")
  } else {
    square8.innerHTML = "O"
    board[2].splice(1, 1, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})

var square9 = document.getElementById("square9")
square9.addEventListener("click", function(el) {
  if ((turnMove() % 2 === 0)) {
    square9.innerHTML = "X"
    board[2].splice(2, 2, "X")
  } else {
    square9.innerHTML = "O"
    board[2].splice(2, 2, "O")
  }
  console.log(board)
  recordBoardState()
  checkRowWin()
  checkColWin()
  checkDiagWin()
})



// const turnMove = () => turns++;
let turns = 0;

function turnMove() {
  return turns++
}

function checkRowWin() {
  board.forEach((row, index) => {
    if (row.toString() === "X,X,X") {
      if (index === 0) {
        square1.style.backgroundColor = "yellow"
        square2.style.backgroundColor = "yellow"
        square3.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else if (index === 1) {
        square4.style.backgroundColor = "yellow"
        square5.style.backgroundColor = "yellow"
        square6.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else {
        square7.style.backgroundColor = "yellow"
        square8.style.backgroundColor = "yellow"
        square9.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      }
    }
    if (row.toString() === "O,O,O") {
      if (index === 0) {
        square1.style.backgroundColor = "yellow"
        square2.style.backgroundColor = "yellow"
        square3.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else if (index === 1) {
        square4.style.backgroundColor = "yellow"
        square5.style.backgroundColor = "yellow"
        square6.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      } else {
        square7.style.backgroundColor = "yellow"
        square8.style.backgroundColor = "yellow"
        square9.style.backgroundColor = "yellow"
        document.getElementById("buttons").style.display = "flex"
      }
    }
  })
}


function checkColWin() {
  if (board[0][0] === "X" && board[1][0] === "X" && board[2][0] === "X") {
    square1.style.backgroundColor = "yellow"
    square4.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][1] === "X" && board[1][1] === "X" && board[2][1] === "X") {
    square2.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square8.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "X" && board[1][2] === "X" && board[2][2] === "X") {
    square3.style.backgroundColor = "yellow"
    square6.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][0] === "O" && board[1][0] === "O" && board[2][0] === "O") {
    square1.style.backgroundColor = "yellow"
    square4.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][1] === "O" && board[1][1] === "O" && board[2][1] === "O") {
    square2.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square8.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "O" && board[1][2] === "O" && board[2][2] === "O") {
    square3.style.backgroundColor = "yellow"
    square6.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
}

function checkDiagWin() {
  if (board[0][0] === "X" && board[1][1] === "X" && board[2][2] === "X") {
    square1.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "X" && board[1][1] === "X" && board[2][0] === "X") {
    square3.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][0] === "O" && board[1][1] === "O" && board[2][2] === "O") {
    square1.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square9.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
  if (board[0][2] === "O" && board[1][1] === "O" && board[2][0] === "O") {
    square3.style.backgroundColor = "yellow"
    square5.style.backgroundColor = "yellow"
    square7.style.backgroundColor = "yellow"
    document.getElementById("buttons").style.display = "flex"
  }
}

function resetGame() {
  const squares = document.getElementsByClassName("square")
  for (let i = 0; i < squares.length; i++) {
    squares[i].textContent = ""
    squares[i].style.backgroundColor = "aliceblue"
  }
  for (let i = 0; i < board.length; i++) {
    board[i].splice(0, 3, ["", "", ""])
  }
  document.getElementById("buttons").style.display = "none"
  boardState = []
  console.log(board)
  console.log(boardState)
}

function recordBoardState() {
  boardState.push(board)
  console.log(boardState)
}

function previousMove() {
  boardState.pop()
  square1.textContent = boardState[boardState.length - 1][0][0]
  square2.textContent = boardState[boardState.length - 1][0][1]
  square3.textContent = boardState[boardState.length - 1][0][2]
  square4.textContent = boardState[boardState.length - 1][1][0]
  square5.textContent = boardState[boardState.length - 1][1][1]
  square6.textContent = boardState[boardState.length - 1][1][2]
  square7.textContent = boardState[boardState.length - 1][2][0]
  square8.textContent = boardState[boardState.length - 1][2][1]
  square9.textContent = boardState[boardState.length - 1][2][2]
  console.log(boardState)
  const squares = document.getElementsByClassName("square")
  for (let i = 0; i < squares.length; i++) {
    squares[i].style.backgroundColor = "aliceblue"
  }

}
#board {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  max-width: 40%;
  height: 40vw;
  margin: auto;
  border: 2px solid black;
  text-align: center;
  font-size: 5rem;
}

.square {
  background-color: aliceblue;
  border: 1px solid black;
}

#buttons {
  display: none;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

button {
  width: 10%;
  font-size: medium;
  margin: 1rem;
}
<html>

<head>
  <title>Tic Tac Toe Game</title>
  <link rel="stylesheet" href="style.css">
  <meta name="viewport" content="width-device-width initial-scale=1">
</head>

<body>
  <div id="board">
    <div id="square1" class="square"></div>
    <div id="square2" class="square"></div>
    <div id="square3" class="square"></div>

    <div id="square4" class="square"></div>
    <div id="square5" class="square"></div>
    <div id="square6" class="square"></div>

    <div id="square7" class="square"></div>
    <div id="square8" class="square"></div>
    <div id="square9" class="square"></div>
    <script type="text/javascript" src="script.js"></script>
  </div>

  <div id="buttons">
    <button id="previous" onclick="previousMove()">Previous</button>
    <button id="reset" onclick="resetGame()">Reset</button>
    <button id="next">Next</button>
  </div>
</body>

</html>

JavaScript encrypted xml throws error in JAVA application decryption: Given final block not properly padded. Such issues can arise if a bad key is

we have a sender application (node.js) which sends to a JAVA application some symmetric encrypted XML strings with an AES 128 key.

When the JAVA application tries to decrypt the content with the provided key the following error will be thrown:

javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
at com.sun.crypto.provider.CipherCore.unpad(CipherCore.java:975) at
com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1056)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:853) at
com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446) at
javax.crypto.Cipher.doFinal(Cipher.java:2168)

public generateKey(): Buffer {
    return crypto.generateKeySync('aes', { length: 128 }).export();
  }

// Encrypt content with key
public encryptSymmetric(content: string, encryptionKey: Buffer): Buffer {
    const iv = Buffer.from(crypto.randomBytes(this.IV_LENGTH)).toString('hex').slice(0, this.IV_LENGTH);
    const cipher = crypto.createCipheriv('aes-128-cbc', encryptionKey, iv);
    let encrypted = cipher.update(content);

    encrypted = Buffer.concat([encrypted, cipher.final()]);
    return encrypted;
    //return iv + ':' + encrypted.toString('hex');
  }

JAVA RECEIVER: Decrypt with key

private static byte[] decryptContent(SecretKeySpec key, byte[] content) throws GeneralSecurityException {
        Cipher cipher = Cipher.getInstance('AES');
        cipher.init(Cipher.DECRYPT_MODE, key);
        return cipher.doFinal(content); // EXCEPTION
      }

I have no idea to solve this specfi problem, at encryption level there many different optins like AES CBC or GCM, hope you can help me, we can change only the sender code!

SOAP Request with WSSE-Header in Javascript

I have the following code to execute a SOAP request with an wsse header but it seems not to work. I get a error response but I am not able to get the fault/error out of the response.

Does the below code look correct or do I miss something?

var request = "<soapenv:Envelope" +
    "xmlns:dlg='http://dlg123Lib'" +
    "xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
    "<soapenv:Header>" +
        "<wsse:Security" +
            "xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'" +
            "xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>" +
            "<wsse:UsernameToken wsu:Id='UsernameToken-BF09AFF37A2C36D4AB164000000000000000'>" +
                "<wsse:Username>BLABLABLA</wsse:Username>" +
                "<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>BLABLABLA</wsse:Password>" +
            "</wsse:UsernameToken>" +
        "</wsse:Security>" +
    "</soapenv:Header>" +
    "<soapenv:Body>" +
        "<dlg:getData>" +
            "<name>AB</name>" +
        "</dlg:getData>" +
    "</soapenv:Body>" +
"</soapenv:Envelope>"

jQuery.ajax({
        url: 'https://endpoint_url/dlg/data',
        type: "POST",
        data: request,
        dataType: "xml",
        contentType: "text/xml; charset='utf-8'",
        success: function (soapResponse) {
            alert("Success");
        },
        error: function (soapResponse) {
            alert("Error");
        }
});

thank you for any hint!

how to datatable select2 dropdown filter

enter image description here
enter image description here

initComplete: function () {
this.api().columns().every( function () {

            var select = $('<select  class="form-control select2 "><option value=""></option></select>');
                .appendTo( $(column.header()).empty() )
                .on( 'change', function () {
                    var val = $.fn.dataTable.util.escapeRegex(
                        $(this).val()
                    );

                    column
                        .search( val ? '^'+val+'$' : '', true, false )
                        .draw();
                } );
                
            column.data().unique().sort().each( function ( d, j ) {
                select.append( '<option value="'+d+'">'+d+'</option> ' )
            } );
           
        
        } );
        
    },

Transfer a onedimensional Array from .txt with more than one Value for each element into Javascript

I have been working on a Snake game and wanted to visualize it not only in python but also on a Website. So now I have the body of my snake (coordinates for each body part) wrote into a .txt file but I am not quite sure if I can transfer this sort of Array to JS because I am not very experienced in JS.

In case this sort of Array is not transferable to JS, is there another way i could visualize an Array like this?

Example of a 4 block long snake (one block = 20×20):
[(220, 420), (240, 420), (260, 420), (280, 420)]

why the selectionchange called twice in google chrome extension

I am using selectionchange to capture the user select in google chrome extension content script like this:

document.addEventListener(TransGlobal.SELECTION_CHANGE, fireSelection);

export async function fireSelection(e: MouseEvent) {
  if (selection && selection.toString().trim().length > 0) {
    // do some select logic
  }
}

I found when double click the web element and do some selection, the fireSelection triggered twice, two of the trigger both have selection content but the selection content be the same. why did this happen? what should I do to make it only triggered once?

ValueError: Excel does not support datetimes with timezones

When I try to run my sreamlit app having function:

def get_tweets(Topic,Count):
    i=0
    #my_bar = st.progress(100) # To track progress of Extracted tweets
    for tweet in tweepy.Cursor(api.search_tweets, q=Topic,count=100, lang="en",exclude='retweets').items():
        time.sleep(0.1)
        #my_bar.progress(i)
        df.loc[i,"Date"] = tweet.created_at
        df.loc[i,"User"] = tweet.user.name
        df.loc[i,"IsVerified"] = tweet.user.verified
        df.loc[i,"Tweet"] = tweet.text
        df.loc[i,"Likes"] = tweet.favorite_count
        df.loc[i,"RT"] = tweet.retweet_count
        df.loc[i,"User_location"] = tweet.user.location
        df.to_csv("TweetDataset.csv",index=False)
        df.to_excel('{}.xlsx'.format("TweetDataset"),index=False)   ## Save as Excel
        i=i+1
        if i>Count:
            break
        else:
            pass

I get this error: ValueError: Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel.

scroll on ios in mobile version

I have a scroll problem only on ios in mobile version.
Sometimes I get stuck on the top of my page if I scroll fast.
If you test this page on iphone http://www.espace-piano.ch/ESPACE_PIANO_WEB/FR/cours.awp you will sometimes have the same problem as I have. The problem is often after the page refresh.
If I switch to “computer version” on safari on my iphone, I no longer have a problem.

Is it possible in javascript to force the browser to “computer version”.

I already have this code to know if the user is on iphone…, I just miss the code to force in “computer version” on the browser.

let isIOS = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === ‘MacIntel’ && navigator.maxTouchPoints > 1);

I’m calling js in function file but it’s not working

Hi I’m trying to call javascript in WordPress function file but it seems it’s not working

<?php

function com_web() {
    wp_enqueue_script('main-cw-js', get_theme_file_uri('/build/index.js'), array('jquery'), '1.0', true);
    wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:100,300,400,400i,700,700i');
    wp_enqueue_script('font-awesome', 'https://kit.fontawesome.com/bd6f15565d.js');
    wp_enqueue_style('com_main_styles', get_theme_file_uri('/build/style-index.css'));
    wp_enqueue_style('com_extra_styles', get_theme_file_uri('/build/index.css'));
}
add_action('wp_enqueue_scripts', 'com_web');