Mute the video on clicking the swiper next or swiper prev button in brightcove player

<div class="swiper mySwiper">
  <div class="swiper-wrapper">
    <div class="swiper-slide">
      <video-js
        id="overlayVideo"
        class="overlayVideo"
        data-account="6269594386001"
        data-player="oHG2GzKTGk"
        data-embed="default"
        controls=""
        data-video-id="6304418462001"
        data-playlist-id=""
        data-application-id=""
        data-object-fit="cover"
        autoplay
        muted loop
        playsinline
      >
      </video-js>
      <script src="https://players.brightcove.net/6269594386001/oHG2GzKTGk_default/index.min.js"></script>
    </div>
    <div class="swiper-slide">
      <video-js
        id="overlayVideo"
        class="overlayVideo"
        data-account="6269594386001"
        data-player="oHG2GzKTGk"
        data-embed="default"
        controls=""
        data-video-id="6304418462001"
        data-playlist-id=""
        data-application-id=""
        data-object-fit="cover"
        autoplay
        muted loop
        playsinline
      >
      </video-js>
      <script src="https://players.brightcove.net/6269594386001/oHG2GzKTGk_default/index.min.js"></script>
    </div>
  </div>
  <div class="swiper-button-next"></div>
  <div class="swiper-button-prev"></div>
  <div class="swiper-pagination"></div>
</div>


$(document).ready(function () {
  var swiper = new Swiper(".mySwiper", {
    spaceBetween: 30,
    centeredSlides: true,
    autoplay: {
      delay: 2500,
      disableOnInteraction: false,
    },
    pagination: {
      el: ".swiper-pagination",
      clickable: true,
    },
    navigation: {
      nextEl: ".swiper-button-next",
      prevEl: ".swiper-button-prev",
    },
  });

  $(".swiper-button-prev, .swiper-button-next").click(function () {
    videojs.getPlayer("overlayVideo").ready(function () {
      var myPlayers = this;
      myPlayers.muted(true);
    });
  });
});

By default I am playing the video as muted and when I unmute the video manually and click on swiper next or prev button, the video should go on mute, but currently it is happening only on clicking previous button but not muting on clicking next button. Can someone help me in achieving this. Thanks in advance

how to delete or update script on cdn.jsdelivr.com?

I wrote a script to read URL parameters with github and I input it into jsdelivr.com, but I see someone else is using that script, my question is can the script that has been entered into cdn.jsdelivr.com be changed or updated?

the thing i have done is change the code in github, but after i check in cdn.jsdelivr.com it is still the same and not changed.

Github: code on github after change

jsdelivr: code on jsdelivr.com still not change

Format time zone to Vi Locale use Moment in React-Native

i am having a date problem when using Moment in React-Native.
Specifically, after I formatted the date to en locale, but now I want it to support the locale in my country is vi locale as well:

Moment('2022-09-02T02:00:00+00:00')
        .local()
        .format('dddd, DD MMM);

the out put:

Friday, 02 Sep

But I want the above result about our language in Vietnam as follows:

Thứ 7, 02 tháng 9

i tried as follows:

Moment('2022-09-02T02:00:00+00:00')
        .local()
        .format('dddd, DD MMM).locale('vi')

But it not slove this issue, so Does you guys help me this issue:
Thanks,

How can I save multiple arrays with sheetjs with javascript?

I have a query, I want to save a set of arrays in javascript and save it in an excel with sheetjs, when the excel file is generated, it only saves 1 array, but when doing console.log it shows me all the arrays,My array is generated from a function, and this is the code I use to save the excel file

var wb = XLSX.utils.book_new();
wb.Props = {
Title: "SheetJS Tutorial",
Subject: "Test",
Author: "Red Stapler",
CreatedDate: new Date(2022,7,4)
};
wb.SheetNames.push("Test Sheet");
var ws_data = [[cartesian(pares , paresAd)]];
var ws = XLSX.utils.aoa_to_sheet(ws_data);
wb.Sheets["Test Sheet"] = ws;
var wbout = XLSX.write(wb, {bookType:'xlsx',  type: 'binary'});
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
$("#queeetes").click(function(){
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), 'test.xlsx');
});
}

pdf maker зеркалит текст pdf

Столкнулся с такой проблемой, что при использовании библиотеки pdf maker.js сам текст в pdf отражается. Периодически возникает проблема, что при открытии модального окна с pdf файлом внутри, текст внутри самого pdf отзеркаливается.

function contractAddition(contract_id, chat_id){
var pdfDocGenerator;
$.ajax({
    c_id: contract_id,
    type:'GET',
    url: '/server/getAppDataByChatId.php',
    async: false,
    dataType: 'json',
    data: {chat_id: chat_id},
    success: function (data) {
        console.log("data:");
        console.log(data);
        if(data[1].app_time == "Ставка"){
            var time = 1;
        }
        else{
            var time = data[1].app_time;
        }
        
        let x = data[0] * time;
        if(this.c_id == null){
            this.c_id = "_______";
        }
        var printContract = {
            content: [
                {
                    columns:[
                        {
                            image: "ЗДЕСЬ ДОЛЖНА  БЫТЬ КАРТИНКА",
                            height:45,
                            width:45
                        },
                        {
                            stack:[
                                {
                                    text: 'ПРИЛОЖЕНИЕ 1 К ДОГОВОРУ №'+ this.c_id,
                                    style: 'header' ,
                                },
                            ],
                            margin:[100,0,0,0]
                        }
                    ]  
                },
                 {
                    style: 'tableExample',
                    table: {
                        heights: 40,
                        body: [
                            ['Вид услуги', data[1].service_name],
                            ['Требования к исполнителю', data[1].type_vehicle_name],
                            ['Полная стоимость услуги(руб):', x] //session_price * app_time
                        ]
                    }
                },
        ],
        }
        pdfDocGenerator = pdfMake.createPdf(printContract);
    }
});
return pdfDocGenerator;

}

enter image description here

Post data value when Span on click to AJAX

i am trying to create a treeview inside a table.

<table class="table table-condensed">
   <tbody>
        <tr id="tr-detail" class="tr-detail hidden">
            <td></td>
                <td colspan="4">
                    <div class="detail-content">
                    <ul>
                       <li>
                         <div class="detail">

                         </div>
                         <div class="detail detail-main">
                         <fieldset>
                              <legend>
                                   <span class="label label-primary label-inline font-weight-bold">Data Proyek</span>
                              </legend>
                                 <div class="data-proyek"></div>
                         </fieldset>
                         </div>
                        </li>
                     </ul>
                 </div>
                </td>
           </tr>
           <tr>
              <td>
                 <span class="fa fa-chevron-right fa-fw" balai="BL001"></span>
               </td>
               <td colspan="5">Data 1</td>
              </tr>
       </tbody>
</table>

i want to filter the data i have with “<span class="fa fa-chevron-right fa-fw" balai="BL001">” when clicked, and display it in <div class="data-proyek"> there.
I have tried in the following way, but still not working.

My JS :

$(document).ready(function() {
    $("span.fa").on("click", function() {
        var $span = $(this),
            $parentTr = $span.closest("tr");
            var kodeBalai = $(this).attr('balai');
            $.ajax({
                    type: 'POST',
                    url: 'src/proyek-prioritas/content/data.php',
                    data: 'kode_balai=' + kodeBalai ,
                    success: function(data) {
                         $('.data-proyek').html(data);
                     },
                });
        if ($span.hasClass("fa-rotate-90")) {
            $span.removeClass("fa-rotate-90");
            $parentTr
                .next()
                .children("td")
                .animate({ padding: 0 })
                .wrapInner("<div />")
                .children()
                .slideUp(function() {
                    var $tr = $(this).closest("tr");
                    $tr.remove();
                $parentTr.removeClass("tr-selected");
                });
            return;
        }
        $span.addClass("fa-rotate-90");
        if ($parentTr.next().hasClass("tr-detail")) return;
        $parentTr.addClass("tr-selected");
        $("#tr-detail")
            .clone()
            .removeClass("hidden")
            .insertAfter($parentTr)
            .children("td")
            .animate()
            .wrapInner("<div style='display:none'/>")
            .children()
            .slideDown();
    });
})();

data.php

<table class="table table-head-custom table-head-bg table-hover">
    <thead>
        <tr>
            <th>Nama Proyek</th>
            <th>Pagu Total</th>
            <th>Nilai Kontrak</th>
            <th>Serapan Tahun 2022</th>
            <th>Sisa Pagu Tahun 2022</th>
        </tr>
    </thead>
    <tbody>
        <?php
        include_once '../../../config/database.php';
        $db = new database();
        $mysqli = $db->connect();
        if (!empty($_POST["kode_balai"])) {
            $balai = $_POST['kode_balai'];
            $sql = "SELECT * FROM data_proyek WHERE kode_balai = '$balai'";
            $result = $mysqli->query($sql);
            if ($result->num_rows > 0) {
                while ($row = $result->fetch_assoc()) {
        ?>
        <tr>
            <td width="10%"><?= $row['nama_proyek']; ?></td>
            <td><?= number_format($data['kontrak'], 0, ".", "."); ?></td>
            <td><?= number_format($data['pagu'], 0, ".", ".");; ?></td>
            <td>0</td>
            <td>0</td>
        </tr>
        <?php
                }
            } else {
                echo '<td colspan="5">Data not available !</td>';
            }
        }
        ?>
    </tbody>
</table>

from what i have done above can someone tell me what i can fix, Or maybe there is a simpler way that I can do.

Why when I convert a regex non-capturing group to a capturing group the result totally changes?

Here’s the initial RegExp:

/(?:s(?:[^'"/s><]+?)[s/>])|(?:S+(?:s*=s*(?:(?:(['"])[sS]*?1|([^s>]+))|(?:[^'"s>]+))))/g

The result: https://regexr.com/6p82g

Then if I convert (?:[^'"/s><]+?) to ([^'"/s><]+?) by removing the ?:,

/(?:s(?:[^'"/s><]+?)[s/>])|(?:S+(?:s*=s*(?:(?:(['"])[sS]*?1|([^s>]+))|(?:[^'"s>]+))))/g

the result changes:

https://regexr.com/6p8bp

Why is that?

Radio type not following the ‘required’ element

I just have a single radio type to accept, but I can’t figure out why it isn’t working?

<div class="radio">
    <input type="radio" name="radioTOS" required><p>Accept</p> 
</div>

Script:

const radio = document.querySelector(".radioTOS");

payment.addEventListener("submit", (e) => {
    e.preventDefault();
    if (radio.checked == null) {
        confirmBtn.style.display = 'none';
        checkout.innerHTML = 'Booked!'
    }else{
        console.log("no");
    }
})

Cannot read properties of undefined using Map in React

I am trying to populate the data from my mock data which is in json format. When I am trying to run the component I am getting undefined reading map error. I have checked that my component is rendering with the value only. Even it’s rendering with the value I am getting this undefined error. I have tried to applied conditional rendering but that doesn’t help me. When I am trying to apply conditional rendering on createCells For Row, I am getting “Reference Error” Cell is not defined. “CreateCellsForRow” is making an issue I need to check whether it’s getting an values or not if values are not there I need to return null. Could any one assist me what I am doing wrong. Thanks in advance.

const createCell = cell => ({ key: cell.key, children: cell.title });

//Actual code
const createCellsForRow = cells => cells.map(cell => createCell(cell)); -----> I am getting error from here(undefined reading map)

//applied conditional Rendering(getting cells is not defined reference error)
const createCellsForRow = cells.length > 0 ? cells => cells.map(cell => createCell(cell)) : null

const StTable = () => {
  const [selectedKey, setSelectedKey] = useState([]);

  const handleRowToggle = (event, metaData) => {
    event.preventDefault();
    if (selectedKey !== metaData.key) {
      setSelectedKey(metaData.key);
    }
  };

  const createRow = rowData => (
    {
      key: rowData.key,
      cells: createCellsForRow(rowData.cells),
      toggleAction: {
        metaData: { key: rowData.key },
        onToggle: handleRowToggle,
        isToggled: selectedKey === rowData.key,
        toggleLabel: rowData.toggleText,
      },
    }
  );

  const createRows = data => data.map(childItem => createRow(childItem));

  return (
    <Table
      summaryId="example-single-select"
      summary="This table shows an implementation of single row selection."
      numberOfColumns={4}
      cellPaddingStyle="standard"
      rowStyle="toggle"
      dividerStyle="horizontal"
      headerData={{
        selectAllColumn: {
          checkLabel: 'Single Selection',
        },
        cells: [
          { key: 'cell-0', id: 'toggle-0', children: 'Name' },
          { key: 'cell-1', id: 'toggle-1', children: 'Address' },
          { key: 'cell-2', id: 'toggle-2', children: 'Phone Number' },
          { key: 'cell-3', id: 'toggle-3', children: 'Email Id' },
        ],
      }}
      bodyData={[
        {
          rows: createRows(mockData),
        },
      ]}
    />
  );
};

export default StTable;

//MockDataSample
[
{"SNO":001, "SregID":"SOO1", "Status": "Available"},
{"SNO":002, "SregID":"SOO2", "Status": "Not Available"},
{"SNO":003, "SregID":"SOO3", "Status": "Available"},
]

Script/plugin for dynamic list without re-rendering the list

I have a website where there is a playlist that is synched between multiple devices/users, updated dynamically when users add/remove items from the list. The current issue is the list update is not transparent: list vanishes and redisplays when there is an update. This can be distracting.
So I was wondering if there is a dynamic list script or plugin, free or non free to help with avoiding re-renders and help save development time?

Changing/Adding extra functions to this javascript wordle code

I’ve this javascript wordle like game code and I would like to change/add three functions

First of all, I would like to remove the randomization of result function, instead show the result from array one by one, ie, in order

I know Math.floor(Math.random() is doing the randomization, but how to change it and instead, pick answers one by one? Removing [Math.floor(Math.random() * wordList.length)].toUpperCase(); is displaying all the results in the array, not one at a time

Secondly, after one guess is over and the answer is shown, I want to show some other text along with the answer, from another array maybe. For example, if the answer is “abcde”, I want it to show abcde 1234

I know <h1 id="answer"></h1> and

if (!gameOver && row == height) {
        gameOver = true;
        document.getElementById("answer").innerText = word;
        setTimeout(function () {
            window.location.reload(false);
        }, 200000);
    }
}

function update() {
    let guess = "";
    document.getElementById("answer").innerText = "";

are responsible for showing the correct answer but how to add another h1 and get some other text along with the answer? Naturally, I cant add more text to the answer array itself as it’ll break the game

Thirdly, I want to remove the letter limit from the game. ie, right now there are five boxes and I don’t want to limit the answers to an exact five letter word. I want it to accept the answer and move to next game even if the answer given is only a three letter word

Finally, I would like to display different titles each time a new game is loaded. I know <h1 id="title"> is responsible for adding the current title but how to show a different title when a new game is loaded? (A title that matches the answer given)

I’m not expecting anybody to give me solutions for all the questions, even if you can answer only one question, I’ll appreciate it, and if possible please give me the code in answer and tell me what changes should I make and where (or please add the code to the given code)

var height = 6;
var width = 5;

var row = 0;
var col = 0;

var gameOver = false;

var wordList = ['abcde',
  'fghij',
  'klmno',
  'pqrst'
]

var word = wordList[Math.floor(Math.random() * wordList.length)].toUpperCase();
console.log(word);

window.onload = function() {
  intialize();
}


function intialize() {

  // 
  for (let r = 0; r < height; r++) {
    for (let c = 0; c < width; c++) {
      // <span id="0-0" class="tile">P</span> 
      let tile = document.createElement("span");
      tile.id = r.toString() + "-" + c.toString();
      tile.classList.add("tile");
      tile.innerText = "";
      document.getElementById("board").appendChild(tile);
    }
  }

  // 
  let keyboard = [
    ["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
    ["A", "S", "D", "F", "G", "H", "J", "K", "L", "Ç"],
    ["Enter", "Z", "X", "C", "V", "B", "N", "M", "⌫"]
  ]

  for (let i = 0; i < keyboard.length; i++) {
    let currRow = keyboard[i];
    let keyboardRow = document.createElement("div");
    keyboardRow.classList.add("keyboard-row");

    for (let j = 0; j < currRow.length; j++) {
      let keyTile = document.createElement("div");

      let key = currRow[j];
      keyTile.innerText = key;
      if (key == "Enter") {
        keyTile.id = "Enter";
      } else if (key == "⌫") {
        keyTile.id = "Backspace";
      } else if ("A" <= key && key <= "Z") {
        keyTile.id = "Key" + key; // "Key" + "A";
      }

      keyTile.addEventListener("click", processKey);

      if (key == "Enter") {
        keyTile.classList.add("enter-key-tile");
      } else {
        keyTile.classList.add("key-tile");
      }
      keyboardRow.appendChild(keyTile);
    }
    document.body.appendChild(keyboardRow);
  }


  // 
  document.addEventListener("keyup", (e) => {
    processInput(e);
  })
}

function processKey() {
  e = {
    "code": this.id
  };
  processInput(e);
}

function processInput(e) {
  if (gameOver) return;

  // 
  if ("KeyA" <= e.code && e.code <= "KeyZ") {
    if (col < width) {
      let currTile = document.getElementById(row.toString() + '-' + col.toString());
      if (currTile.innerText == "") {
        currTile.innerText = e.code[3];
        col += 1;
      }
    }
  } else if (e.code == "Backspace") {
    if (0 < col && col <= width) {
      col -= 1;
    }
    let currTile = document.getElementById(row.toString() + '-' + col.toString());
    currTile.innerText = "";
  } else if (e.code == "Enter") {
    update();
  }

  if (!gameOver && row == height) {
    gameOver = true;
    document.getElementById("answer").innerText = word;
    setTimeout(function() {
      window.location.reload(false);
    }, 200000);
  }
}

function update() {
  let guess = "";
  document.getElementById("answer").innerText = "";

  //
  for (let c = 0; c < width; c++) {
    let currTile = document.getElementById(row.toString() + '-' + c.toString());
    let letter = currTile.innerText;
    guess += letter;
  }

  guess = guess.toLowerCase(); //
  console.log(guess);

  //
  let correct = 0;

  let letterCount = {}; //
  for (let i = 0; i < word.length; i++) {
    let letter = word[i];

    if (letterCount[letter]) {
      letterCount[letter] += 1;
    } else {
      letterCount[letter] = 1;
    }
  }

  console.log(letterCount);

  //
  for (let c = 0; c < width; c++) {
    let currTile = document.getElementById(row.toString() + '-' + c.toString());
    let letter = currTile.innerText;

    //
    if (word[c] == letter) {
      currTile.classList.add("correct");

      let keyTile = document.getElementById("Key" + letter);
      keyTile.classList.remove("present");
      keyTile.classList.add("correct");

      correct += 1;
      letterCount[letter] -= 1; //
    }

    if (correct == width) {
      gameOver = true;
      setTimeout(function() {
        window.location.reload(false);
      }, 2000000);
    }
  }

  console.log(letterCount);
  //
  for (let c = 0; c < width; c++) {
    let currTile = document.getElementById(row.toString() + '-' + c.toString());
    let letter = currTile.innerText;

    // 
    if (!currTile.classList.contains("correct")) {
      //
      if (word.includes(letter) && letterCount[letter] > 0) {
        currTile.classList.add("present");

        let keyTile = document.getElementById("Key" + letter);
        if (!keyTile.classList.contains("correct")) {
          keyTile.classList.add("present");
        }
        letterCount[letter] -= 1;
      } // 
      else {
        currTile.classList.add("absent");
        let keyTile = document.getElementById("Key" + letter);
        keyTile.classList.add("absent")
      }
    }
  }

  row += 1; //
  col = 0; //
}
@import url('https://fonts.googleapis.com/css2?family=Bitter&display=swap');
body {
  font-family: 'Bitter', serif;
  text-align: center;
}

hr {
  width: 600px;
}

#title {
  font-size: 36px;
  font-weight: bold;
  letter-spacing: 2px;
}

#board {
  width: 350px;
  height: 400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
}

.tile {
  /* Box */
  border: 2px solid lightgray;
  width: 60px;
  height: 60px;
  margin: 2.5px;
  border-radius: 15px;
  /* Text */
  color: black;
  font-size: 30px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.correct {
  background-color: #1ed760;
  color: white;
  border-color: white;
}

.present {
  background-color: #f9ba04;
  color: white;
  border-color: white;
}

.absent {
  background-color: #777e99;
  color: white;
  border-color: white;
}

.keyboard-row {
  width: 400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
}

.key-tile {
  width: 36px;
  height: 40px;
  margin: 1px;
  border: 1px solid lightgray;
  border-radius: 15px;
  cursor: pointer;
  /* Text */
  font-size: 20px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.key-tile:hover {
  transform: scale(1.1);
  transition: 100ms linear;
}

.enter-key-tile {
  width: 76px;
  height: 40px;
  margin: 1px;
  border: 1px solid lightgray;
  border-radius: 15px;
  cursor: pointer;
  /* Text */
  font-size: 20px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.enter-key-tile:hover {
  transform: scale(1.1);
  transition: 100ms linear;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Wordle Game</title>

  <link rel="stylesheet" href="style.css">
  <script src="script.js"></script>
</head>

<body>
  <main>
    <h1 id="title">Wordle Game</h1>
    <hr>
    <br>

    <div id="board">

    </div>

    <br>
    <h1 id="answer"></h1>
  </main>
</body>

</html>

I Can’t Hide/Show Textbox when radio button is checked

Here is my html code & jquery, I want to hide the no. bpjs textbox when bpjs radio is checked. I don’t think if my code is wrong, but i don’t know why my code doesn’t work.

                        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2 pt-0">Pengobatan</label>
                            <div class="col-sm-10">
                                <div class="custom-control custom-radio custom-control-inline">
                                    <input type="radio" id="umum" onclick="w3.show('#nomor_bpjs')" name="pengobatan" class="minimal" value="Umum" value="<?= set_value('pengobatan') ?>">
                                    <label class="detail" for="umum">Umum</label>
                                </div>
                                <div class="custom-control custom-radio custom-control-inline">
                                    <input type="radio" id="bpjs" onclick="w3.hide('#nomor_bpjs')" name="pengobatan" class="minimal" value="BPJS" value="<?= set_value('pengobatan') ?>">
                                    <label class="detail" for="bpjs">BPJS</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row" id="no_bpjs">
                            <label for="no_bpjs" class="col-sm-2 col-form-label">No. BPJS </label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="nobpjs" name="nobpjs" placeholder="Masukan Nomor BPJS" value="<?= set_value('no_bpjs') ?>">
                            </div>
                        </div>

And my jquery

        <script>
        $(function() {
            $('.nobpjs').hide();

            //show it when the checkbox is clicked
            $('input[id="bpjs"]').on('click', function() {
                if ($(this).prop('checked')) {
                    //show div with class="nama"
                    $('.nobpjs').fadeIn();
                } else if ($('input[id="umum"]').on('click')) {
                    //hide div with class= "nama"
                    $('.nobpjs').hide();
                } else {
                    $('.nobpjs').hide();
                }

            });
        });
    </script>

I want to hide the no. bpjs textbox when bpjs radio is checked

I dont know my code plz help me(in JavaScript) [closed]

long time ago I learned programming skill
so now I dont remember almost skill
and I want to know this code

I want yo insert name var and output my name

somebody help me

let name;

name = prompt(‘put your name’, ‘e.g., John’);

confirm(‘is your name ‘ + name +’?’);

if (!name) {
    alert(‘no, that is not my name’);
} else {
    alert(‘hello, ‘ + name);
}