Changing an innerText through Javascript after a CSS animation

I am trying to create a foldable menu, through CSS and JS. Css works (almost) correctly (the menu folds and unfolds, even if the class is not correctly applied) but not the JS code, which should change the innerText of the <li> acting as a button from “>” to “<” and opposite.

I have been messing around with js code for a while (making sure that document.getElementById is not undefined), but neither element.innerText or element.innerHTML seem to work properly.

I have two questions:

  1. When applying an animation, and having two classes, shouldn’t respect both classes (I mean, the navbar should be red)? Should I add nav class AFTER the animation is done, or fill the navbar in red color through the animation?

  2. Why does ignore InnerText/InnerHTML instructions?? I have debugged the code and definitely goes through that instruction and I cannot understand why the change is not done…

var navButton; 
var navbar;


const init = ()=>{
    navbar = document.getElementById("navbar"); 
    navButton = document.getElementById("foldButton");
    navButton.addEventListener('click', function(){
        if(navbar.className==="init nav" || navbar.className==="fade-out-right nav"){
            navButton.InnerText=`<p>&lt</p>`;
            toggleFold();
        }
        else{
            navButton.InnerText=`<p>&gt</p>`;
            toggleFold();
        }
    });
}


const toggleFold = () => {
    if(navbar.className==="init nav" || navbar.className==="fade-out-right nav"){
        navbar.className="fade-in-left nav";
    }else{
        navbar.className="fade-out-right nav";
    }
};
* {
  margin: 0;
  padding: 0;
}

html {
  box-sizing: border-box;
  font-size: 62.5%;
  scroll-behavior: smooth;
}

/* Base styles */

.nav {
  display: flex;
  justify-content: flex-end;
  position: fixed;
  top: 0;
  left: 0;
  width: 4%;
  background: red;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.nav-list {
  display: flex;
  margin-right: 2rem;
  list-style: none;
}

.nav-list li {
  display: block;
  font-size: 2.2rem;
  padding: 2rem;
}

.nav-list a{
  color:black
}

.nav-list a:hover {
  background: blue;
}

.fade-in-left {
  animation-name: fade-in-left;
  animation-duration: 2s;
  animation-timing-function: ease;
  animation-fill-mode: forwards;
}
@keyframes fade-in-left {
  from {
    opacity: 1;
    transform: translateX(-4%);

  }
  to {
    opacity: 1;
    transform: translateX(305px);
  }
}

.fade-out-right {
  animation-name: fade-out-right;
  animation-duration: 2s;
  animation-timing-function: ease;
  animation-fill-mode: forwards;
}


@keyframes fade-out-right {
  from {
    opacity: 1;
    transform: translateX(305px);
  }
  to {
    opacity: 1;
    transform: translateX(-4%);
  }
}
    <body onload="init()">
        <nav id="navbar" class="init nav">
          <ul class='nav-list'>
            <li><a href='#welcome-section'>About</a></li>
            <li><a href='#projects'>Work</a></li>
            <li><a href='#contact'>Contact</a></li>
            <li id="foldButton"><p>&gt</p></li>
          </ul>
        </nav>
    </body>

Thank you for helping me out.

Get File Name from list of URL’s – Google Drive

So I’m needing to get the list of file names from a range of Google Drive URLs in a spreadsheet. Browsing around the net, I came across the code below. It works but only for the old style urls, which I heard Google changed in September 2021.
Note that links are not fully functional, please replace with real links to check!

The old style is:
https://drive.google.com/file/d/1GMUwYxZxsNpLiaYOiVMBwl41LpreQ-fc/view?usp=sharing
This works correctly from the code below.

What I’d like though is two things.

It should handle a range of a couple of columns, currently reading AE2:AE, and printing out on AM2:AM. What I’d like is to go through the range: AE2:AL and print out: AM2:AT

Secondly it should also handle the newer form urls:
https://drive.google.com/file/d/0B9EZQqsLDEqDUGlsdy1oVEtETGs/view?usp=sharing&resourcekey=0-h7HOcxayPaHJ5r6dAAslVQ

Current Code:

    function getNames() {
  var activeRange = SpreadsheetApp.getActiveSheet().getDataRange();
  var height = activeRange.getHeight();
  var links = SpreadsheetApp.getActiveSheet()
    .getRange("AE2:AE" + height)
    .getValues();

  var nameValues = [];

  links.forEach((row) => {
    try {
      var link = row[0];
      var fileID = getIdFromLink(link);
      var name = DriveApp.getFileById(fileID).getName();
      nameValues.push([name]);
    } catch (e) {
      nameValues.push(["NO NAME FOUND"]);
    }
  });

  var nameRange = SpreadsheetApp.getActiveSheet().getRange("AM2:AM" + height);
  nameRange.setValues(nameValues);
}

function getIdFromLink(link) {
  var regex = new RegExp(
    /(?<=https://drive.google.com/file/d/)(.+)(?=/)/
    );
  return regex.exec(link)[0];
}

How should the code above be modified to enable what I’m wanting. Sorry, I tried a couple of if/else statements, but my Javascript knowledge is severely limited.
Any help would be greatly appreciated.

Current “screenshot” showing:
(1) – Old style url – correctly picking up file name (2)
(3) – New style url – not picking up file name (4)

enter image description here

EasyPaisa MA Transaction Error: Incomplete merchant information

I am trying to initiate an MA transaction using easy paisa api. The response error I get after executing the following code is as follows.

'RESPOSNE: '{"orderId": "XYZ123", "responseCode": "0017", "responseDesc": "Incomplete merchant information", "storeId": "xxxxx"}

The response code “0017” is not even mentioned in the documentation.
This is my code

const otcTransaction = async () => {
    try {
      let url = `https://easypaystg.easypaisa.com.pk/easypay-service/rest/v4/initiate-ma-transaction`
      let body = {
        emailAddress: '[email protected]',
        mobileAccountNo: '03xxxxxxxxx',
        orderId: 'XYZ123',
        storeId: XXXXX,
        transactionAmount: 10.0,
        transactionType: 'MA',
      }
      const response = await axios.post(
        url,
        body,
        {
          headers: {
            'Credentials': 'base64(username:password)'  
     },
        })
      console.log('RESPOSNE: ', response.data)
    } catch (error) {
      console.log(error.message)
    }
  }

Let me know if anyone has worked on EasyPaisa MA Transaction
Thanks in advance!

show and hide java script

General Paragraph

Facebook Paragraph

Hello everyone

I do use elementor pro

  1. When I do not click with the cursor on all icons it shows the general paragraph “Lorem Ipsum…etc”

  2. When I click with the cursor on the Facebook icon so it show facebook’s paragraph and it hides the general paragraph “Lorem Ipsum…etc”

  3. When I get the cursor away again from Facebook’s icon it must show the general paragraph “Lorem Ipsum…etc” again

I have used this code but the only issue I do not know how to show and hide the general paragraph “Lorem Ipsum…etc”

Can anyone advise me?

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
var $ = jQuery
$(document).ready(function(){
    $('[data-showme]').hover( function(){
        event.preventDefault();
        var showme = $(this).attr('data-showme')
        
        $('.all-img').hide()
        $('.' + showme).show()
        
    })
})
</script>

Problem creating a mongoose schema from a JSON file

Is it possible to create this JSON file structure as a mongoose schema? mongoose doesn’t offer an object type and I don’t know how to implement it.

{
  "Mountainbike": {
    "Cross": {
      "size": [
        "395 mm",
        "440 mm",
        "480 mm",
        "535 mm"
      ],
      "color": [
        "Himmelblau",
        "Grasgrün",
        "Stahlgrau",
        "Weinrot"
      ],
      "brake": [
        "Shimano Deore BRM6000",
        "Shimano Deore BRM7000",
        "Shimano RX810 1x11"
      ],
}
}
}

Check another user’s balance

With the bot and code I have right now, users can check their own balance but not each others. How can I go about modifying this?

module.exports = {
    name: "rep",
    description: "Checks the user reputation",
    execute(client, message, args, Discord, profileData, cmd){
        message.channel.send(`${message.author.username}, you currently have ${profileData.reputation} reputation, keep training!`);
    }
}

Thanks.

ev.preventDefault is not a function when using dispatch

I got something weird when I’m submitting a form.
When I’m using ev.preventDefault() as is, everything working as expected but when I’m adding dispatch to the function two lines later I’m getting the error: ev.preventDefault is not a function.
here are my code thanks in advance!

const addReview = async ev => {
  ev.preventDefault()
  if (!email || !message) return alert('All fields are required')
  await dispatch(addReview({email,message}))
  console.log('Adding review!');
}

<form onSubmit={addReview}>
  <input value={email} placeholder="Email" type="email" id="email" name="email" onChange={handleChange}/>
  <textarea
    name="message"
    placeholder="Message"
    rows="4"
    cols="50"
    onChange={handleChange}
    value={message}
  ></textarea>
  <button>Submit</button>
</form>

How to choose my next programming language to learn I am very confused about it [closed]

Currently, I working on Vanilla JavaScript, Vue js, Nuxt js, and Node js a mid-level programmer can tell. I came to JavaScript from PHP, Laravel about 3 years ago. Now I think I need to learn a new programming language with the future in mind. I am very worried about which programming language to learn. I have chosen 3 programming languages: Go, Rust and Python. Now I want to know which of these 3 will be better in the future.

One more thing, I don’t feel comfortable doing design-related work.

Thanks

How to use the `setTimeout` with Angular hooks?

I am trying to use a setTimeout under the hook. But I am getting that, the page keep hanging. what is the correct way to use the setTimeout under the angular hooks?

here is my code :

 ngAfterViewChecked() {
    const myTimeout = window.setTimeout(() => {
      console.log("3");
      clearTimeout(myTimeout); //on clearing no impact
    }, 5000);
  }

any one help me?

Live demo

How to get html structure with user input in php in order to download pdf

I am trying to save HTML div as pdf in javascript and PHP. I have tried a lot of libraries, but all of them are returning to the pdf-only HTML structure. The page I want to convert to pdf is generated from a database table in which I have put everything for well structure HTML. Now I am at the point where I can serialize all my input data in string like action=saveWorkPermit&text_CLMC_491=1515&date_CLMC_494l495d=2021-12-06&time_CLMC_496l497t=10%3A34&. I also can get them in array as {“action”: “saveWorkPermit”, “text_CLMC_491”: “1515” …}. I have my HTML structure also and then. I am stuck. I do not know how to input in the HTML the values and then get this result HTML and put it in some pdf function. I will really appreciate your answers if you can help me. Here is the Ajax code:

                case "GeneratePdf":
                    var ex = data.details.structure ; // here it is the html
    
                    var array = data.details.data; // this is the data as array
                    for (var key in array) {
                        var type = key.split("_")[0];
                        var value = array[key];
                        if(type == 'check' && value == 'on') {
                            $("#"+key).prop("checked", true);
                        } else if (type == 'gr'){
                            $("input[name="+key+"][value=" + value + "]").prop('checked', true);
                        } else {
                            $("[name='"+key+"']").val(value);
                        }
                        
                    }

                    let mywindow = window.open('', 'SAVE', 'height=650,width=900,top=100,left=150');
                    mywindow.document.write(`<html><head><title>MyPdf</title>`);
                    mywindow.document.write('</head><body >');
                    var params2 = $("#AllWP").serialize();
                    mywindow.document.write(document.getElementById("AllWP").innerHTML); // one more time the html structure
                    mywindow.document.write(params2);   // this is the serialized data
                    mywindow.document.write(ex);    // because of this line it is not working
                    mywindow.document.write('</body></html>');
                    mywindow.document.close(); 
                    mywindow.focus(); 
                    mywindow.print();
                    mywindow.close();
                break;

This is one of the forms I want to export as pdf:
form

If there is no way to do that in javascript, I can also get the above data in PHP and loop them there.

Exclude property in checking empty properties

Below I have a code to check for empty property, it will return true if one property is empty. My question is how do we exclude other property on checking ?

for example I still wanna check for empty property but I dont want or I want to exclude properties like generalRealEstateConcernsorChallenges, majorPositiveAttributes , summary from checking.

So code below will only check empty property except generalRealEstateConcernsorChallenges, majorPositiveAttributes , summary. But I dont want to delete those property.

Thanks.

code

const hasEmptyProperty = Object.values((this.dealDispositionFormFields)).some((v => v === null || v === ""))

object – this.dealDispositionFormFields

{
   
    "dealName": "12743-J",
    "summary": "A",
    "majorPositiveAttributes": "b",
    "generalRealEstateConcernsorChallenges": "c",
    "terminationPayment": 23,
    "effectiveDate": "2021-12-15T00:00:00",
    "brokerCommission": 232,
    "brokerRebate": 23233,
    "isPharmacyRestriction": false,
    "netEffectiveBrokerCommission": -23001,
}