removing the “ion-activatable” class from an ion-item

I am using ionic 6 with angular. I have been trying to remove the ion-activatable class from an ion-item. I have tried getting the ElementRef of the ion-item and using “ionItemElementRef.nativeElement.classList.remove(“ion-activatable”)”. It doesn’t work. Similarly,
“ionItemElementRef.nativeElement.classList.contains(“ion-activatable”)” returns FALSE.
Whats interesting is that the output to the console of the classList is:

DOMTokenList [value: ‘’]

0: “item-interactive”

1: “item-select”

2: “item-has-placeholder”

3: “ion-color”

4: “ion-color-gainsboro”

5: “item”

6: “md”

7: “item-lines-none”

8: “item-fill-none”

9: “ion-activatable”

10: “ion-focusable”

11: “hydrated”

length: 12

value: “item-interactive item-select item-has-placeholder ion-color ion-color-gainsboro item md item-lines-none item-fill-none ion-activatable ion-focusable hydrated”

so the class clearly exists yet classList methods do nothing to it.

Then I tried using [ngClass]=”{‘ion-activated’:false}” in the ion-item in the html template. That doesn’t work either.

Finally, I tried [class.ion-activatable]=“false” in the ion-item in the html template, which also doesn’t work.

My question is , in general, how do you remove or add a class to an ionic component at runtime?

Thanks for your help everyone.

How to display data from another source in Javascript

I am trying to wrap my head around this. I just started learning javascript. Basically on my site, I have a plugin/script that asks the user a bunch of questions and at the end, it asks for their email address. I am using emailjs to send the info (well that’s what I am trying to do) but can’t figure out the proper javascript code.

In the code, if I put my email address in the variable templateParams under to_name: The email gets sent when the user enters their email and I receive it but it’s blank with no data. I don’t know how to grab the data with the info below from the plugin documentation.

 onSendEmail: function(emailData) {
           // User clicked send button on share by email. You have to manage sending
           // the email yourself with the following data received in the parameter:
           console.log(emailData);
       /*
      {
        "data": {
          "cvData": [
            {
              "name": "overall",
              "value": 71,
              "feedback": "Excellent"
            },
            {
              "name": "smoothness",
              "value": 52,
              "tip": "Smoothness can be affected by using correct products.",
              "info": "Healthy skin is free of dryness, hyperpigmentation, ...",
              "feedback": "Good"
            },
            {
              "name": "radiance",
              "value": 73,
              "info": "Skin radiance is the glowy, vibrant look we ...",
              "feedback": "Excellent"
            },
            ...
          ],
          "products": {
            "morning": {
              "highend": [{product1},{product2},{product3}],
              "economy": [{product4}, {product5}, {product6}],
              "standard": [{product7}, {product8}, {product9}]
            },
            "evening": {
              "highend": [{product1},{product2},{product3}],
              "economy": [{product4}, {product5}, {product6}],
              "standard": [{product7}, {product8}, {product9}]
            }
          },
          "activeRoutine": "evening",
          "activePriceGroup": "standard",
          "activeFilters": {
            "skin_type": { "value": "normal" },
            "gender_ui": { "value": "female" },
            "age_ui": { "value": 31 },
            "eyebags_ui": { "value": 1 },
            "dull_tired_ui": { "value": 1 },
            "redness_ui": { "value": 1 },
            "lat": { "value": 39.47504 },
            "lon": { "value": -0.4117344 },
            "darkspots_ui": { "value": 1 },
            "wrinkles_ui": { "value": 1 }
          },
          "activeSelections": {
            "userAllowsCamera": true,
            "locationData": {
              "status": "done",
              "location": {
                "lat": 39.47504, "lon": -0.4117344,
                "city": "Valencia", "country": "Spain", "area": "Valencia",
                "uvIndex": 9, "pollution": 30, "humidity": 77
              }
            },
            "skin_type": "normal",
            "skin_concerns": ["dull_tired", "redness"],
            "eyebags": 1,
            "darkspots": 1,
            "wrinkles": 1,
            "gender": "female",
            "age": "31",
            "selfieSource": "video"
          },
        },
        "email": "[email protected]",
        "locale": "en",
        "partnerId": "XXXXXXX",
        ...
      }
      */
                
           let templateParams = {
            to_name: 'email',
            from_name: 'abc',
            message: 'random message'
            
          };

       emailjs.send('SERVICE_ID', 'TEMPLATE_ID', templateParams)
       .then(function(response) {
       console.log('SUCCESS!', response.status, response.text);
        }, function(error) {
       console.log('FAILED...', error);
       });
        }, 
       };

Why is slice not slicing an array Discord JS 13?

I’ve used slice for awhile now with no issue, my problem lies with .slice() not slicing.
Code: (why does it smash the code??)

let data data = await Models.find().sort([['points', 'descending']]) console.log(data.length) // output: 179 data.slice(0,5) console.log(data.length) // output: 179

Here is what data returns as:

{
points: 100,
commandsUsed: 0,
tipDifficulty: ‘Not Set.’,
mapDifficulty: ‘Not Set.’,
stateDifficulty: ‘Not Set.’,
gameType: ‘Not Set.’,
items: [],
_id: 623d29b01fde8a4b347eadb7,
difficulty: ‘Not Set.’,
userID: ‘1234567890’,
serverID: ‘1234567890’,
__v: 0
},

Repeated over and over again (179 times)

I’ve tried splice(), .filter() but splice should work, it always has before(discord js 12).

How to get one or two of data value in Controller Codeigniter when using AJAX Post

can someone help me with my code, i have AJAX json type POST and i wanto to get one or two of data send to controller in codeigniter, i wanto to add conditional function where the data from json.

My JSON

$('#add_people').submit(function(e){
   e.preventDefault();
    var id_people = $('#id_people').val();
    var name_people = $('#name_people').val();
    var phone_people = $('#phone_people').val();
    $.ajax({
        type : "POST",
        url  : "<?php echo base_url('add_people_data')?>",
        dataType : "JSON",
        data : {id_people:id_people , name_people:name_people, phone_people:phone_people},
        success: function(data){
            $("#show_people").html('<img src="assets/img/user/spinner.gif"> <h4>Loading data...</h4>');
            $('#modal-add_people').modal('hide');
            $('.modal-backdrop').remove();
            $('[name="id_people"]').val("");
            $('[name="name_people"]').val("");
            $('[name="phone_people"]').val("");
            var loadUrl = "<?php echo base_url('show-people-data')?>";
            $("#show_people").load(loadUrl);
        }
    });
    return false;
});

My Controler

public function add_people_data()
        {
    $id_people = $this->input->post('id_people');
    $name_people = $this->input->post('name_people');
    $phone_people = $this->input->post('phone_people');
    
    $cekassignreviewer=$this->Model_reviewer->checkassignreviewer('data_people', $id_people, $name_people, $phone_people);
    
    if ($cekassignreviewer > 0) {
        $this->session->set_flashdata('failed',
        "<script>swal({
            title:'Failed!',
            text: 'Number of people has been added',
            icon: 'error',
            confirmButtonText: 'Ok',
            confirmButtonClass: 'btn btn-success'
        });
        </script>");
        redirect(base_url('setting-reviewer'));
    }else{
        $data=$this->Model_reviewer->add_people();
        echo json_encode($data);
    }

My Model

function add_people()
{
    $data = array(
            'id_people'    => $this->input->post('uniid_reviewer'), 
            'name_people'   => $this->input->post('name_people'), 
            'phone_people'   => $this->input->post('phone_people'), 
        );
    $result=$this->db->insert('data_people',$data);
    return $result;
}

Thank you in advance

document.getElementsByTagName() not working properly

i was trying to change all the element by using document.getElementsByTagName() method but it was not working. I was using a for loop

function fun(idorclass,index){
   if(idorclass != null){
     return document.getElementsByTagName(idorclass)[index];
   }
   else{
    var fwe = document.getElementsByTagName(x);
    for (let i = 0; i < fwe.length; i++) {
      return fwe[i];
   }
}
}
fun('p').innerHTML='hi';
<p>hey</p><br>
<p>hey</p><br>
<p>hey</p><br>
<p>hey</p><br>

i was able to see an error that was ‘Uncaught TypeError: Cannot set properties of undefined.’ please help!

I need to get the value from the selected item to the PHP function

I have a problem with some HTML, Javascript and PHP code. I tried a few things with some AJAX calls which did not work.

What I want to happen: When I change the selected option it needs to update the function with the value from the option, so the PHP function gets the “id” from the selected option. And this need to happen without any refresh on the page.

So I need to get the value from the selected item to the PHP function.

Code:

<label>Channels</label>
  <div class="input-group mb-3">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
      $(function (){' '}
      {$('#login.component').change(function () {
        if ($(this).val() == 3) {
          $('#txtOther').removeAttr('disabled');
          $('#txtOther').focus();
        } else {
          $('#txtOther').attr('disabled', 'disabled');
        }
      })}
      );
    </script>
    <select class="form-select" id="login.component">
      <option selected>Choose..</option>
      <option value="0">Whatsapp</option>
      <option value="1">Telegram</option>
      <option value="2">Slack</option>
      <option value="3">Custom</option>
    </select>
  </div>
  <div className="form-group">
    <label>Channel Name</label>
    <input type="text" className="form-control" id="txtOther" placeholder="Enter Channel Name" disabled="disabled" />
  </div>

Convert multiple if/else conditions to a object literal to simplify my JavaScript code

I really didn’t want to come to you guys for this one but I cannot wrap my head around this! How can return a true condition using object literals. My original code has multiple if/else statements I only made an example here to understand this better! I know there are other examples out there but it is not helping me!!!

///
if (cond1,cond2,cond3) {
//return ask question
}else if (cond1, cond2, cond3) {
//return if condition is false
}else if (cond1, cond2, cond3) {
//return if other conditions is false
}else if (cond1, cond2, cond3) {
//return if conditions are true
}else{
//return another 
}
///

I want to know if this is on the right path!


obj1 {
  cond1:"",
  cond2:"",
  cond3:""
}

obj2 {
  cond1:"",
  cond2:"",
  cond3:""
}

return this || that || another

Duplicate Section

I have a generated table elements that I get from my Google Spreadsheet and in each table will have generated button that will pop up modal from Bootstrap.

What I want to achieve is whenever I click the button depend on the row, I want to get that row number and change data in Google Spreadsheet. For example clicking button in first row will pop up a confirmation modal, if I click “YES” button using my modal it then will change data in first row of the Spreadsheet and return “row 1” in the console. My problem is if I click button row 1, then close the modal after it pop up, then click button in row 2 and click “YES”, the code somehow duplicate and return result “row 1 ” and “row 2” but what I want is “row 2” only.

As image above, I click button row number 1, console will show 1, then I close the modal and then click button row 2, console will show 2 but when I click “YES” on my modal, console will show 1 and 2 but what I want is only 2.

This issue will cause sending duplicate email because my code also include Mailapp services.

Any solution or advice?

Modal and Table HTML

    <!-- Modal Cancel Leave Application -->
    <div class="modal fade" id="cancelModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Leave Cancellation</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body">
            <p class="edit__title">Current Leave Application</p>
            <p class="edit__subtitle" id="currentApplication2"></p>
            <p class="edit__subtitle" id="currentDateApplication2"> Date : #currentDate</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary" id="cancelConfirm">YES</button>
            <button class="btn btn-primary hide" type="button" id="btndisabledCancel" disabled>
              <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
              Cancelling...
            </button>
          </div>
        </div>
      </div>
    </div>

      <div id="manageLeaveSection" class="hide">
        <main class="manage__main">
          <section>
            <h2 class="manage__title">Manage Leave</h2>
            <div class="upcoming__leave">
                <div class="upcoming__header">
                  <table class="table__design" id="manageTable">
                    <thead>
                      <tr class="tr__design">
                        <th class="th__design">From</th>
                        <th class="th__design">Until</th>
                        <th class="th__design">Type Of Leave</th>
                        <th class="th__design">Status</th>
                      </tr>
                    </thead>
                    <tbody id="manageTableBody">

                    </tbody>
                    </table>
                  </div>
                </div>
          </section>
        </main>
      </div>

JS generated table. DataArray are data from Google Spreadsheet.

  const table = document.getElementById("manageTable");
  const newList = document.getElementById("manageTableBody");
  const confirmCancelButton = document.getElementById("cancelConfirm");
  let actualRowNum;
  let displayRowNum;

  dataArray[0].forEach(function(r){

    const row = document.createElement("tr");
          row.classList.add("tr__design");

      const col5 = document.createElement("td");
            col5.classList.add("td__design");
          
          // Get display table row number
          const getDisplayRow = table.rows.length;
          
          const cancelBtn = document.createElement("a");
                cancelBtn.innerHTML = "Cancel";

            // Cancel Button Protocol
            if(col3x.innerHTML === "Cancelled" || col3x.innerHTML === "Rejected"){
              cancelBtn.classList.add("disabled__btn");
            }else if(today >= checkDate){
              cancelBtn.classList.add("disabled__btn");
            }
            else{
              cancelBtn.classList.add("cancel__btn");
              cancelBtn.setAttribute("data-bs-toggle", "modal");
              cancelBtn.setAttribute("data-bs-target", "#cancelModal");
              cancelBtn.set
            }
            
            col5.appendChild(cancelBtn);

        // Click Cancel Button
        var setValue = getDisplayRow;
        cancelBtn.addEventListener('click',function(){
          document.getElementById("currentApplication2").innerHTML = `Leave Application :  ${r[1]}`;
          document.getElementById("currentDateApplication2").innerHTML = `Date : ${r[4]} - ${r[5]}`;
          
          console.log(setValue);//will log row number[in this case is 1]
          
          //Assign row number for every generated rows
            actualRowNum = dataArray[1][getDisplayRow-1];
            testNum = getDisplayRow;

              confirmCancelButton.addEventListener('click',function(){  

                console.log(setValue);
                
                    google.script.run
                    .withSuccessHandler(function(){
                      removeModal();                    
                    })
                     .cancelLeave(actualRowNum,setValue)
              });

        });

    row.appendChild(col5);
    newList.appendChild(row);

Very Basics of Using an API Link

To clarify, I understand what an API is, more or less understand how to pull and send data, and do have access to my API key.. the problem is the specific service I am attempting to use. The API links they provide have the format https://{your_app}.gingrapp.com/api/v1/reservations, but do not say where to put the key, and do not say what {your_app} is meant to be set to. I realize this is kind of a stupid problem but I am completely out of my depth and I’d really appreciate some help.

Grid alignment not functioning properly in React JS

I am following a youtube tutorial to develop a React JS application. My grid is malfunctioning completely when i go to mobile screen to check compatibility and I am unable to understand why.

I have created data.js, infoElements.js, and index.js which are then called into the main index.js file.

infoElements.js:



export const InfoContainer = styled.div`
color: #fff;
background: ${({lightBg}) => (lightBg ? '#f9f9f9' : '#010606')};

@media screen and (max-width: 768px){
   padding: 100px 0;
}
`;


export const InfoWrapper = styled.div`
display: grid;
z-index: 1;
height: 860px;
width: 100%;
max-width: 1100px;
margin-right: auto;
margin-left: auto;
padding: 0 24px;
justify-content: center;
`;



export const InfoRow = styled.div`
display: grid;
z-index: 10;
grid-auto-columns: auto;
align-items: center;
grid-template-areas: ${({imgStart}) => (imgStart ? `'col2 col1'` : `'col1 col2'`)};

@media screen and (max-width: 768px){
   grid-template-areas: ${({imgStart}) => (imgStart ? `'col1' 'col2'` : `'col1 col1' 'col2 col2'`)};
}
`;
export const TextWrapper = styled.div`
max-width: 540px;
padding-top: 0;
padding-bottom: 60px;
`;


export const Column1 = styled.div`
margin-bottom: 15px;
padding: 0 15px;
grid-area: col1;
border-right: 1px solid;
`;

export const Column2 = styled.div`
margin-bottom: 15px;
padding: 0 15px;
grid-area: col2;
border: 1px solid;
`;




export const TopLine = styled.p`
color: #01bf71;
font-size:16px;
line-height:16px;
font-weight: 700;
letter-spacing: 1.4px;
text-transform: uppercase;
margin-bottom: 16px;
`;


export const Heading = styled.h1`
margin-bottom: 24px;
font-size:48px;
line-height: 1.1;
font-weight: 600;
color: {({lightText}) => (lightText ? '#f7f8fa : '#010606')}

@media screen and (max-width: 480px){
   font-size: 32px;
}
`;



export const Subtitle = styled.p`
max-width: 440px;
margin-bottom:35px;
font-size:18px;
line-height: 24px;
color: ${({darkText}) => (darkText ? '#010606': '#fff')};
`;


export const BtnWrap = styled.div`
display: flex;
justify-content: flex-start;
`;


export const ImgWrap = styled.div`
max-width: 555px;
height:100%;
`;

export const Img = styled.img`

width: 100%;
margin: 0 0 10px 0;
padding-right: 0;
`;

data.js:


export const homeObjOne = {
id: 'about',
lightBg: false,
lightText: true,
lightTextDesc: true,
topLine: 'Premium Bank', 
headline: 'abcdefgh',
description: 'ywrchwbkrhvcbkcb',
buttonLabel: 'Lets go',
imgStart: false,
img: require("../../images/svg3.svg").default,
alt: 'Car',
dark:true,
primary: true,
darkText: false
};

index.js:

import React from 'react';
import {Button} from '../ButtonElements';


import { InfoContainer, 
    InfoWrapper, 
    InfoRow, TextWrapper, 
    Column1, 
   
    
    TopLine, 
    Heading, 
    Subtitle, 
    BtnWrap,
    Column2,  
    ImgWrap, 
    Img
   } from './InfoElements';
   
   const InfoSection = ({lightBg, id, imgStart, topLine, lightText, headline, darkText, description, buttonLabel, img, alt}) => {
  return (
      <>
    <InfoContainer lightBg={lightBg} id={id}>
        <InfoWrapper>
            <InfoRow imgStart={imgStart}>
                <Column1>
                 <TextWrapper>
                    <TopLine>{topLine}</TopLine>
                       <Heading lightText={lightText}> {headline}
                    </Heading>
                    <Subtitle darkText={darkText}>{description}</Subtitle>
                    <BtnWrap>
                        <Button to='home' >{buttonLabel}</Button>
                    </BtnWrap>
                    </TextWrapper>
                </Column1>
                <Column2>
                    <ImgWrap>
                        <Img src={img} alt={alt} />
                    </ImgWrap>
                </Column2>
            </InfoRow>

        </InfoWrapper>
    </InfoContainer>

</>


  )
}

export default InfoSection;

The imported button is as follows:

import styled from 'styled-components';
import {Link} from 'react-scroll';

export const Button = styled(Link)`
border-radius: 50px;
background: ${({primary}) => (primary ? '#b24d25' : '#010606')};
white-space: nowrap;
padding: ${({big}) => (big ? '1px 48px':'12px 30px')};
color: ${({dark}) => (dark ? '#010606' : '#fff')};
font-size: ${({fontBig}) => (fontBig ? '20px' : '16px')};
outline: none;
border: 3px solid #fff;
opacity: 60%;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;

transition: all 0.2s ease-in-out;


&: hover {
    transition: all 0.2s ease-in-out;
    background: ${({primary}) => (primary ? '#fff': '#be4d25' )};

}

This is the output that is showing:

its going out of screen and not fitting. the whole thing is misbehaving because of this

Need to two columns side by side if the window is expanded else (like in the case of a smaller screen) one below the other.

Note: It was working fine till I added .default at the end of img src in data.js.

Thank you for your help, I have spent a lot of time going through this.

Setting react object to object given in props

I am trying to set the state of of a an object (teethData.data) in react based on the props passed into the component (props.toothData). if the props passed object has length zero then it sets. If props.toothData is length zero then a default value is given to a variable givenToothData so that teethData.data has a default value otherwise, teethData.data is just set to props.toothData. However teethData.data doesn’t change the way i want it too if props.ToothData isn’t length zero

Below is my code, is there any advice?


function TableArray(props) {
  const navigate = useNavigate();
  console.log(props.toothData);

  var givenToothData = props.toothData;
  if (Object.keys(props.toothData).length === 0) {
    console.log("this happened", props.toothData);
    givenToothData = {
      1: {
        pp: false,
        C14: false,
        GI0: false,
        GI23: false,
        PDI: false,
        GR: false,
        F13: false,
        M03: false,
      },
      2: {
        AB: false,
        AT: false,
        EH: false,
        TI: false,
        TLUX: false,
        O: false,
        GH: false,
        OST: false,
        ONF: false,
        FX: false,
        CA: false,
        OM: false,
        D: false,
        DX: false,
      },
      3: { RTR: false, TR: false, SN: false, TA: false },
      4: {
        TFXUCF: false,
        TFXCCF: false,
        TFXUCRF: false,
        TNE: false,
        TPE: false,
      },
    }
    console.log("this happened", givenToothData);
  }

  const [teethData, setTeethData] = useState({
    tooth: props.tooth,
    data: givenToothData
  });

  console.log(teethData.data, "runthisfirst n", givenToothData, props.teethData);
  




MUI installation is stuck

I had the latest working node.js which is 16.14.2 LTS. However when I tried to install material UI it threw errors.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0" from @material-ui/[email protected]
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"^4.12.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:UsersnewayAppDataLocalnpm-cacheeresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersnewayAppDataLocalnpm-cache_logs2022-04-06T00_01_01_812Z-debug-0.log

Then I downgraded node.js to 14.17.3. Material UI didn’t throw errors. However at first, it said that the "npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!"

and it was stuck at: remove:react-dev-utils: sill remove C:Usersnewaytwitter-clonenode_modulesreact-dev-utils during installation

So i exit and i tried to install again, same thing was happening and now it’s stuck at: remove:@babel/preset-env: sill remove C:Usersnewaytwitter-clonenode_modules@babelpreset-env

So I went into the package-lock.json and changed the lockfileversion from 2 to 1. It doesn’t throw the warning anymore but it’s still stuck. Another one it was stuck at is: remove:@material-ui/core: sill remove C:Usersnewaytwitter-clonenode_modules@material-uicore

How can i stop it from getting stuck during installation? Also, i’m using Visual Studio Code