I am seeking a solution to my problem: it is stating: cash is less than the price

Could someone assist me, and help me understand why it is telling me: Cash is less than the price, and how I can resolve it.

Here is the code that I have:

const checkCashRegister = (price, cash, cid) => {
    const UNIT_AMOUNT = {
    "PENNY": .01,
    "NICKEL": .05,
    "DIME": .10,
    "QUARTER": .25,
    "ONE": 1.00,
    "FIVE": 5.00,
    "TEN": 10.00,
    "TWENTY": 20.00,
    "ONE HUNDRED": 100.00
    }
    let totalCID = 0;
    for (let element of cid) {
    totalCID += element[1];
    }
    totalCID = totalCID.toFixed(2);
    let changeToGive = cash - price;
    const changeArray = [];
    if (changeToGive > totalCID) {
    return { status: "INSUFFICIENT_FUNDS", change: changeArray };
    } else if (changeToGive.toFixed(2) === totalCID) {
    return { status: "CLOSED", change: cid };
    } else {
    cid = cid.reverse();
    for (let elem of cid) {
    let temp = [elem[0], 0];
    while (changeToGive >= UNIT_AMOUNT[elem[0]] && elem[1] > 0) {
    temp[1] += UNIT_AMOUNT[elem[0]];
    elem[1] -= UNIT_AMOUNT[elem[0]];
    changeToGive -= UNIT_AMOUNT[elem[0]];
    changeToGive = changeToGive.toFixed(2);
    }
    if (temp[1] > 0) {
    changeArray.push(temp);
    }
    }
    }
    if (changeToGive > 0) {
    return { status: "INSUFFICIENT_FUNDS", change: [] };
    }
    return { status: "OPEN", change: changeArray};
    }

react mui datables, can’t put icons the the left

I’m using react mui datables and i want to add buttons to the toolbar.

I want to put an icon to the right .

My full options :

  const options = {
    filter: false,
    filterType: "checkbox",
    download: isAdmin,
    sort: false,
    responsive: "vertical", // standard | vertical | simple
    selectToolbarPlacement: "none", // above | none | ...
    // searchPlaceholder: "Your Custom Search Placeholder",
    selectableRows: "multiple",
    selectableRowsOnClick: true,
    elevation: 0,
    print: false,
    viewColumns: false,
    searchOpen: false,
    search: true,
    page: 0,
    pageSize: 10,
    // rowsPerPage: 10,
    rowsPerPageOptions: [],
    // TODO customize on download
    // onDownload: (buildHead, buildBody, columns, rows) => {
    //   return (
    //     buildHead(columns) +
    //     buildBody(
    //       rows.map((row, index) => ({
    //         index,
    //         data: row.data.map((data) =>
    //           typeof data === "object" ? data.alias : data
    //         ),
    //       }))
    //     )
    //   );
    // },
    textLabels: {
      body: {
        noMatch: "Aucun enregistrement correspondant trouvé",
      },
      pagination: {
        next: "Suivant",
        previous: "Précédent",
        rowsPerPage: "Rows per page:",
        displayRows: "sur",
      },
      toolbar: {
        search: "Recherche",
        downloadCsv: "Télécharger CSV",
        print: "Imprimer",
        viewColumns: "Afficher les colonnes",
        filterTable: "Tableau de filtrage",
      },
      selectedRows: {
        text: "ligne(s) sélectionnée(s)",
        delete: "Supprimer",
        deleteAria: "Supprimer les lignes sélectionnées",
      },
    },
    customToolbarSelect: (selectedRows, displayData, setSelectedRows) => {
      return (
        <Box mr={4}>
          <Fab
            variant="extended"
            size="small"
            color="primary"
            aria-label="add"
            onClick={() => console.log(selectedRows)}
          >
            <FileDownloadRounded />
            Exporter
          </Fab>
        </Box>
      );
    },
    customToolbar: () => {
      return (
        <Link to="/project/add">
          <Tooltip title="Ajouter un nouveau dossier">
            <Button
              variant="contained"
              startIcon={<FontAwesomeIcon icon={faAdd} />}
              className="float-start"
            >
              Ajouter un dossier
            </Button>
          </Tooltip>
        </Link>
      );
    },
  };

How can i correctly put custom buttons inside the toolbar and control position (to the right, to the left ..)

enter image description here

How to return data from .this in js

So when we give this function getApiData something to fetch, we want it to actually return the fetched data. At the moment it returns “undefined” and we don’t understand why.

    console.log(name)
    if (`${restVar}` != `GET`) {
        bodyData = JSON.stringify(bodyData);
    }
    fetch(`${url}`, {
        method: `${restVar}`,
        headers: {
            'Content-Type': 'application/json'
        },
        body: bodyData
    })
        .then(response => response.json())
        .then(data => {
            console.log('Success:', data);
            return data;
        })
        .catch((error) => {
            console.error('Error:', error)
        });
}```

Any help would be much appreciated :)

Duplication of list while opening multi page using node JS

I build an html page linked to a node server.
This page include a hypertext list which is duplicated while other page are opened from the server. I don’t want this functionning, the list don’t have to be duplicated while other pages are opened.

I test some code, as : list.removeChild or list.replaceChild but the list disappear..
what I want to modify in order to not duplicate the list is :

                    var list = document.getElementById("messagesList");
                    socket.on('messageFromServer', function (data) {
                    var item = document.createElement('li');        
                    item.innerHTML = data.network;
                    list.appendChild(item);
                    });

Thanks for any help.

Here is the html full code :

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >

   <head>
        <meta name="description" content="Interface de Start and Stop du TrainLab" />
        <meta name="Copyright" CONTENT="Alstom" />
        <meta name="expires" CONTENT="never" />
        <meta name="audience" CONTENT="all" />
        <meta name="Language" CONTENT="Fr" />
   
       <title>H M I</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
       <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
       <link rel="stylesheet" media="screen" type="text/css" title="Design" href="form.css" />
       <link rel="SHORTCUT ICON" href="favicon.ico">
       
       <script src="/socket.io/socket.io.js"></script>
                    

   </head>
   <body>
        <div id="main">
        
            <div id="mainleft">
                    <img src="tom.png" class="favorite img1" title="" alt="  " />
            </div>
            
            <div id="maincenter">
                    
            </div>
            
            <div id="mainright">
                    <h1>  Interface </h1>
            </div>  

            <div id="mainrightright">
                <form action="/switchoff" method="post">
                    <input type="image"  alt="Off Button" src="pictures/off2.png" class="favorite img2" title="OFF" alt="  "/>
                </form>
            </div>          

            
            <div id="mastercenter">
            
                <div id="aboveleft">
                    <p> </p>
                </div>
                
                <div id="abovecenter">
                    <p> </p>
                </div>
                
                <div id="aboveright">
                    <p> </p>
                </div>
            
            
                <div id="left">
                    <p>Doors</p>
                        <div onClick="emit('unlock')" title="Clic to unlock doors" class="favorite styledbutton_unlock" type="submit" id="idunlock" value=""></div>
                    </br>
                        <div onClick="emit('open')" title="Clic to open doors" class="favorite styledbutton_open" type="submit" id="idopen" value=""></div>
                    </br>
                        <div onClick="emit('close')" title="Clic to close doors" class="favorite styledbutton_close" type="submit" id="idclose" value=""></div>
                </div>
                
                
                <div id="center">
                    <p>Light</p>
                        <div onclick="emit('light')" title="Clic to switch on the lights" class="favorite styledbutton_light_minus" type="submit" id="idlight" value=""></div>              
                    </br>
                        <div onClick="emit('lightmore')" title="Clic to switch on the lights" class="favorite styledbutton_light_more" type="submit" id="idlightplus" value=""></div>   
                    </br>
                        <div onClick="emit('micro')" title="Clic to speak with micro" class="favorite styledbutton_speak" type="submit" id="idmicro" value=""></div>        
                </div>              
                
                
                <div id="right">
                    <p>Announcements</p>
                    
                    <ul id="messagesList">
                        <!-- Dynamically generated list of messages sent from the different clients connected to the server -->
                    </ul>
                </div>
            
            </div>
            
            <div id="bottom">
                    </br>
                    </br>
                <div id="abovebottomleft">  
                    <form action="/upload" method="post">
                        <input title="Clic to open upload page" class="favorite styledupload" type="submit" id="state" value="Click here to open upload section">       
                    </form> 
                </div>  
                
                <div id="abovebottomcenter">        
                    <form action="/help" method="post">
                        <input title="Clic to open help page" class="favorite styledhelp" type="submit" id="state" value="Help">        
                    </form> 
                </div>              
                
                <div id="abovebottomright">     
                    <form action="/refresh" method="post">
                        <input title="Clic to refresh page" class="favorite styledrefresh" type="submit" id="state" value="Refresh">        
                    </form> 
                </div>
            </div>  
            
        
        </div> 
        <script defer>
                        var socket = io.connect();
                        
                        var lightmore = document.getElementById("idlightplus");
                        socket.on('etatLightmore', function (state_lightmore) {
                            if (state_lightmore ==1){
                                lightmore.classList.add("lightmore_enabled");
                            }else{
                                lightmore.classList.remove("lightmore_enabled");
                            }
                        });
                        
                        var light = document.getElementById("idlight");
                        socket.on('etatLight', function (state_light) {
                            if (state_light ==1){
                                light.classList.add("light_enabled");
                            }else{
                                light.classList.remove("light_enabled");
                            }
                        });
                        
                        var micro = document.getElementById("idmicro");
                        socket.on('etatMicro', function (state_micro) {
                            if (state_micro ==1){
                                micro.classList.add("micro_enabled");
                            }else{
                                micro.classList.remove("micro_enabled");
                            }
                        });
                        <!-- ici mettre une condition si la liste existe alors ne pas rajouter de liste -->
                        var list = document.getElementById("messagesList");
                        socket.on('messageFromServer', function (data) {
                        var item = document.createElement('li');        
                        item.innerHTML = data.network;
                        list.appendChild(item);
                        });
                        
                        var close = document.getElementById("idclose");
                        socket.on('etatClose', function (state_close) {
                            if (state_close ==1){
                                close.classList.add("close_enabled");
                            }else{
                                close.classList.remove("close_enabled");
                            }
                        });
                        
                        var unlock = document.getElementById("idunlock");
                        socket.on('etatUnlock', function (state_unlock) {
                            if (state_unlock ==1){
                                unlock.classList.add("unlock_enabled");
                            }else{
                                unlock.classList.remove("unlock_enabled");
                            }
                        });
                        
                        var open = document.getElementById("idopen");
                        socket.on('etatOpen', function (state_open) {
                            if (state_open ==1){
                                open.classList.add("open_enabled");
                            }else{
                                open.classList.remove("open_enabled");
                            }
                        });
                        
                        function emit(name){
                        console.log("click")
                            socket.emit("click",name)
                        }
                    </script>
    </body>
</html>

I am using the library phonegap-nfc to scan nfc but when I scan it opens other page

I’m using phonegap-nfc library in my vue project. Its working but I don’t know why it open the information I have on my NFC car in other page information. What I want to do is show all the information that NFC have in my app. So if anyone knows how to do it could you help me please?

Here is my code:

<template>
  <v-app>
    <v-card-actions>
      <div class="cardInfos">
        {{ tagId }}
        {{ message }}
      </div>
    </v-card-actions>
  </v-app>
</template>

<script>
export default {
  name: 'App',

  data: () => ({
    tagId: "",
    message: ""
  }),

  methods:{
    scanNFC(){
      window.nfc.enabled(
        () => {
          // NFC enabled
          this.registerTagEvent()
        },
        (error) => {
          if (error === 'NFC_DISABLED') {
            // Trigger the phone settings to enable the NFC settings
            window.nfc.showSettings()
          } else if (error === 'NO_NFC') {
            navigator.notification.alert('Cannot scan NFC', () => {}, 'No NFC', 'OK')
          }
        }
      )
    },

    registerTagEvent () {
      window.nfc.addTagDiscoveredListener(
        this.displayNdef,
        () => {
          console.log('succeess registering ndef listener')
        },
        (error) => {
          console.log('failure registering ndef listener', error)
        }
      )
    },

    displayNdef (nfcEvent) {
      // Decode tag data from the plugin
        const bgColor = document.getElementsByClassName(".v-application--wrap")
        bgColor.style.backgroudColor = "green"
        let tag = nfcEvent.tag
        let tagId = window.nfc.bytesToHexString(tag.id)
        let message = window.nfc.bytesToString(tag.ndefMessage[0].payload)
        this.tagId = tagId
        this.message = message

        window.ndefMessage(tagId, message)
      }
    },

    deactivated () {
      this.unregisterTagEvent()
    },

    unregisterTagEvent () {
      // Test if the plugin is defined
      if ((typeof nfc) !== 'undefined') {
        window.nfc.removeNdefListener(this.displayNdef)
      }
    },
};
</script>

Can anyone help me please 🙂

Destroying Credentials/ Revoking Tokens (ArcGIS API)

Good Day Everyone, I am having issues revoking/destroying my credentials upon logging out. Apparently the credentials are still stored and not destroyed.. Also how do I use the https:///users//invalidateSessions endpoint? There is no documentation on this.. The cookie is still accessible even after logging out of the website. Please do help!

Here is a snippet of my code please do take a look at it. Thank you!

signOut: function (isSessionTimeout) {
                console.log("Signout")
                var client = new AppClient();
                self.appClient = client;
                var actionToId = "";
                if (isSessionTimeout) {
                    actionToId = "Session Timeout";
                }
             
                var ctx = window.AppContext,
                    oauth;
                if (ctx.geoportal) oauth = ctx.geoportal.arcgisOAuth;

                var portalUrl = oauth.portalUrl;
                arcgisUtils.arcgisUrl = portalUrl;  // PortalImplementation
                esriId._arcgisUrl = portalUrl;
                this.removeCookie('esri_auth', "/");

                // window.sessionStorage.removeItem(itemName);
                // window.localStorage.removeItem("esriJSAPIOAuth");
                // window.localStorage.removeItem("torii-provider-arcgis");
                // window.sessionStorage.removeItem("userRole");
                // window.sessionStorage.removeItem("userOrganisation");
                // window.sessionStorage.removeItem("userObjectId");
                // window.sessionStorage.removeItem("contactOrganisation");
                // window.sessionStorage.removeItem("distributionOrganisation");
                // window.sessionStorage.removeItem("fileId");
                // window.sessionStorage.removeItem("announcementObjectId");

                esriId.destroyCredentials()
                // client.revokeToken(oauth.appId); 
                console.log(`HERE ${oauth.appId} ~~~~~${client.getPortalAccessToken()}`)
                window.location.reload();
            },

If ID contains Javascript

I have following JS

    var slider = new Slider("#testslider", {
        tooltip: 'always'
    });

To style my bootstrap slider by ID.
I want to style every slider in that area so I tried to put them all in one DIV like:

<div id="testslider">
//all sliders
</div>

That will only style the first slider.

I tried [id^="testslider"] and named every slider in this scheme: testslider1, testslider2 etc.

But that will only style the first slider.
Now with document.querySelectorAll([id^="testslider"]); I could select all IDs but I can’t figure out how to put that into

var slider = new Slider("#testslider", {
    tooltip: 'always'
});

Modal does not close from the phone

I ran into a problem that I do not close model windows associated with this script from the phone, fa-close button is not pressed. At the same time from the computer everything works fine

    function NpcObject(type){
    $.ajax({
        url: "/do/Npc/",
        type: "post",
        data: {
            type: type
        },
        success: function (response) {
            response = JSON.parse(response);
            if(!response['error']){
                var tpl = '<div class="model"><div class="header">'+response['title']+'<span onclick=$(".model").remove();><i class="fa fa-close"></i></span></div>';
                tpl += '<div class="content-model">';
                if(response['type'] == 'pokemarket'){
                    tpl+= response['html'];
                }else if(response['type'] == 'reproduction'){
                    tpl+= response['html'];
                }else if(response['type'] == 'lombard'){
                    tpl+= response['html'];
                }else{
                    tpl+= '<div class="pit"><input id="pitInput" placeholder="'+Lang.search_pokemon+'" onkeypress=if(event.keyCode==13)nursery("search"); type="text">';
                    tpl+= '<div class="pok-1">'+response['html'];
                    tpl+= '';
                    tpl+= '</div></div></div>';
                }
                tpl += '</div>';
                $("body").append(tpl);
                $('.model').draggabilly({
                    handle: '.header',
                    containment: true
                });
            }else{
                alert(Lang.error_no_way);
            }
        }
    });
}

Node js gives blank white screen when starting npm on Mac OS

there.
I’ve done huge mistake in my life.
I replaced Windows laptop with MacBook.
And Node.js was working just fine, on Windows.
But when i try to run npm start on Mac OS.
App gets loaded and it says Compiled succesfully
But in browser i see nothing but just blank screen.
Although it looks like app loaded just fine with no problems at all.
And i know that some people in my team use Linux and it works just fine

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "start-win": "react-scripts start",
 }

This is my scripts in package.json
Maybe anyone had problem like this.
I’ve seen a lot of people complaining about blank page which they see on Mac OS.
But i didnt find a single working solution

My Javascript code won’t work, what’s wrong with it?

My javascript code won’t work one bit and I honestly have no idea why. I’m still very new to javascript so if someone can point out where I’m going wrong, I’ll very much appreciate it! It’s supposed to be a pixel art maker where you can make a table based on user input and color each separate cell.

var table = document.getElementById("pixelCanvas");
var height = document.getElementById("inputHeight").value;
var width = document.getElementById("inputWidth").value;
var color = document.getElementById("colorPicker");
var submit = document.getElementById("submit");
var size = document.getElementById("sizePicker");

submit.addEventListener("click", makeGrid);

function makeGrid(height, width) {
  height,
  width.preventDefault();
  table.innerHTML = "";
  for (let x = 0; x < height; x++) {
    var tr = table.insertRow(x);
    for (let y = 0; y < width; y++) {
      var td = tr.insertCell(y);
      table.appendChild(tr);
      td.addEventListener("click", fillCell);
      tr.appendChild(td);
    }
    table.appendChild(tr);
  }
}

function fillCell(event) {
  event.preventDefault();
  event.style.backgroundColor = color.value;
}
body {
  text-align: center;
  background-color: white;
  color: plum;
  font-family: 'Roboto', sans-serif;
}

h1 {
  font-family: 'Roboto', sans-serif;
  font-size: 70px;
  margin: 0.2em;
}

h2 {
  margin: 1em 0 0.25em;
}

h2:first-of-type {
  margin-top: 0.5em;
}

table,
tr,
td {
  border: 2px solid black;
}

table {
  border-collapse: collapse;
  margin: 0 auto;
  color: black;
}

tr {
  height: 20px;
}

td {
  width: 20px;
}

input[type=number] {
  width: 6em;
}
<h1>Pixel Art Maker</h1>

<h2>Choose Grid Size</h2>
<form id="sizePicker">
  Grid Height:
  <input type="number" id="inputHeight" name="height" min="1" value="1"> Grid Width:
  <input type="number" id="inputWidth" name="width" min="1" value="1">
  <input type="submit" id="submit">
</form>

<h2>Pick A Color</h2>
<input type="color" id="colorPicker">

<h2>Design Canvas</h2>
<table id="pixelCanvas"></table>

Module Warning (from ./node_modules/laravel-mix/node_modules/postcss-loader/dist/cjs.js):

I am trying to install the laravel breeze package for default authentication.
Laravel mix error after npm run dev. I am in Laravel 9

WARNING in ./resources/css/app.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[1]!./node_modules/laravel-mix/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].use[2]!./resources/css/app.css)

composer.json:
{
   

     "name": "laravel/laravel",
        "type": "project",
        "description": "The Laravel Framework.",
        "keywords": ["framework", "laravel"],
        "license": "MIT",
        "require": {
            "php": "^8.0.2",
            "guzzlehttp/guzzle": "^7.2",
            "laravel/framework": "^9.2",
            "laravel/sanctum": "^2.14.1",
            "laravel/tinker": "^2.7"
        },
        "require-dev": {
            "fakerphp/faker": "^1.9.1",
            "laravel/breeze": "^1.9",
            "laravel/sail": "^1.0.1",
            "mockery/mockery": "^1.4.4",
            "nunomaduro/collision": "^6.1",
            "phpunit/phpunit": "^9.5.10",
            "spatie/laravel-ignition": "^1.0"
        },
        "autoload": {
            "psr-4": {
                "App\": "app/",
                "Database\Factories\": "database/factories/",
                "Database\Seeders\": "database/seeders/"
            }
        },
        "autoload-dev": {
            "psr-4": {
                "Tests\": "tests/"
            }
        },
        "scripts": {
            "post-autoload-dump": [
                "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
                "@php artisan package:discover --ansi"
            ],
            "post-update-cmd": [
                "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
            ],
            "post-root-package-install": [
                "@php -r "file_exists('.env') || copy('.env.example', '.env');""
            ],
            "post-create-project-cmd": [
                "@php artisan key:generate --ansi"
            ]
        },
        "extra": {
            "laravel": {
                "dont-discover": []
            }
        },
        "config": {
            "optimize-autoloader": true,
            "preferred-install": "dist",
            "sort-packages": true
        },
        "minimum-stability": "dev",
        "prefer-stable": true
    }



package.json:

    {
        "private": true,
        "scripts": {
            "dev": "npm run development",
            "development": "mix",
            "watch": "mix watch",
            "watch-poll": "mix watch -- --watch-options-poll=1000",
            "hot": "mix watch --hot",
            "prod": "npm run production",
            "production": "mix --production"
        },
        "devDependencies": {
            "@tailwindcss/forms": "^0.4.0",
            "alpinejs": "^3.4.2",
            "autoprefixer": "^9.8.8",
            "axios": "^0.25",
            "css-loader": "^5.2.7",
            "laravel-mix": "^6.0.6",
            "laravel-mix-postcss-config": "^1.4.0",
            "lodash": "^4.17.19",
            "postcss": "^8.3.1",
            "postcss-import": "^14.0.2",
            "postcss-loader": "^3.0.0",
            "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17"
        }
    }


 webpack.mix.js:
    
const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js').postCss('resources/css/app.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
    require('autoprefixer'),
]);