Why datatables customization does not work at double letter columns?

I have a monthly timesheet datatable, which I export to Excel. But when I open the Excel, the row contains the days of the month (header row) is shown as number. I want to display as date.

Here is the displayed Excel

I added the following code snippet. It works but only until the Z column, and it doesn’t work in AA, AB, AC, etc. columns.

customize: function(xlsx, row) {
       var sheet = xlsx.xl.worksheets['sheet1.xml'];
                            
        // Add date format to first line - not work for AA, AB,etc.
        $('row:eq(1) c', sheet).attr('s', '67')

        // Add number format for column A excel recognized as date
        // this work on every column
        $('row c[r*="A"]', sheet).attr('s', '0')

},

Is there any other way to do this?

From getElementById to getElementsByClassName and get same result?

Looking at the code below, you will notice when I click the arrow icons an “Added!” text will appear in green to the left, but in one spot only.

I want the “Added!” text to appear next to each arrow icon, for each icon that is clicked, without removing the fade/animations.

(Example:
If I click the top arrow icon, text will appear and fade to the left of that only; if I click the middle arrow icon only, text appears and fades to the left of that icon only; if I click the bottom arrow icon, text appears and fades to the left of that icon only)

How can I achieve this? Do I need to change the ID elements to Class elements? (I am willing to use whatever code works as long as it keeps the fade/animations).

  function showAdded() {
    let message = document.getElementById('notification-text');

    if (message.classList.contains('noDisplay')) {
      message.classList.remove('noDisplay');
    }

    // message.classList.add('noDisplay');
    message.style.animation = 'none';
    message.offsetHeight;
    message.style.animation = null;
  }
  .shopping-cart-add-on {
    background-image: url("https://upload.wikimedia.org/wikipedia/commons/9/9e/Plus_symbol.svg");
    background-repeat: no-repeat;
    background-size: 29px 29px;
    background-position: center;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 24px;
    padding: 8px;
    cursor: pointer;
    position: relative;
    top: -25px;
    left: 124px;
    transition: all .3s;
  }

  #notification-text {
    position: absolute;
    text-wrap: nowrap;
    animation-name: msgSuccess;
    animation-duration: 1s;
    opacity: 0;
    transition-delay: 4ms;
    color: green;
  }

  .noDisplay {
    display: none;
  }

  @keyframes msgSuccess {
    50% {
      opacity: 1;
    }

    99% {
      opacity: 0;
    }

    100% {
      opacity: 0;
      display: none;
    }
  }
  <br>

  <div class="shopping-cart-add-on" onclick="showAdded()" style="height: 28px; width: 28px"></div>
  <div id="notification-text" class="noDisplay">Added!</div>
  </div>

  <br><br>

  <div class="shopping-cart-add-on" onclick="showAdded()" style="height: 28px; width: 28px"></div>
  <div id="notification-text" class="noDisplay">Added!</div>
  </div>

  <br><br>

  <div class="shopping-cart-add-on" onclick="showAdded()" style="height: 28px; width: 28px"></div>
  <div id="notification-text" class="noDisplay">Added!</div>
  </div>

How can I pass an object from an EJS file to a JavaScript file? [closed]

Using expresses res.render I am passing an object called cards to my ejs file. From there, I need to access cards in a javascript file included in script tags at the top of the ejs file. How can I do this? My first idea was to create a js function that assigned cards to a variable in the js file, but I can’t find a way to call it from the ejs file. I also tried calling that function from where I use the render function, but can’t find a way to do it there either. Any ideas are appreciated.

Not able to change the background color of header using Chakra-UI component

I am using Chakra-UI’s styling conventions to try to style the background color of the header. The styles for the header is located in Header.js:

export default {
    baseStyle: {
        container: {
            minWidth: 'xs',
            width: 'full',
            boxShadow: 'base',
            backgroundColor: 'blue'
        },
        content: {
            maxWidth: 'container.xxxl',
            marginLeft: 'auto',
            marginRight: 'auto',
            paddingLeft: [4, 4, 6, 8],
            paddingRight: [4, 4, 6, 8],
            paddingTop: [1, 1, 2, 4],
            paddingBottom: [3, 3, 2, 4]
        },
    },
    parts: ['container', 'content', 'searchContainer', 'bodyContainer', 'logo', 'icons', 'signout']
}

As you can see, I tried changing the background color to blue, but it doesn’t do anything. See below for the code in the Header file for the markup:

import React, {useRef, useState} from 'react'
import PropTypes from 'prop-types'
import {useIntl} from 'react-intl'
import {
    useMultiStyleConfig,
    Box,
    Flex,
    IconButton,
    Badge,
    Button,
    Popover,
    PopoverHeader,
    PopoverTrigger,
    PopoverContent,
    PopoverBody,
    PopoverFooter,
    PopoverArrow,
    Stack,
    Text,
    Divider,
    useDisclosure,
    useMediaQuery
} from '@salesforce/retail-react-app/app/components/shared/ui'
import {AuthHelpers, useAuthHelper, useCustomerType} from '@salesforce/commerce-sdk-react'

import {useCurrentBasket} from '@salesforce/retail-react-app/app/hooks/use-current-basket'

import Link from '@salesforce/retail-react-app/app/components/link'
import withRegistration from '@salesforce/retail-react-app/app/components/with-registration'
import {
    AccountIcon,
    BrandLogo,
    BasketIcon,
    HamburgerIcon,
    ChevronDownIcon,
    HeartIcon,
    SignoutIcon,
    SearchIcon
} from '@salesforce/retail-react-app/app/components/icons'

import {navLinks, messages} from '@salesforce/retail-react-app/app/pages/account/constant'
import useNavigation from '@salesforce/retail-react-app/app/hooks/use-navigation'
import LoadingSpinner from '@salesforce/retail-react-app/app/components/loading-spinner'
import {isHydrated, noop} from '@salesforce/retail-react-app/app/utils/utils'

const IconButtonWithRegistration = withRegistration(IconButton)

const Header = ({
    children,
    onMenuClick = noop,
    onSearchClick = noop,
    onMyAccountClick = noop,
    onLogoClick = noop,
    onMyCartClick = noop,
    onMiniCartClick = noop,
    onWishlistClick = noop,
    ...props
}) => {
    const intl = useIntl()
    const {
        derivedData: {totalItems},
        data: basket
    } = useCurrentBasket()
    const {isRegistered} = useCustomerType()
    const logout = useAuthHelper(AuthHelpers.Logout)
    const navigate = useNavigation()
    const {
        getButtonProps: getAccountMenuButtonProps,
        getDisclosureProps: getAccountMenuDisclosureProps,
        isOpen: isAccountMenuOpen,
        onClose: onAccountMenuClose,
        onOpen: onAccountMenuOpen
    } = useDisclosure()
    const [isDesktop] = useMediaQuery('(min-width: 992px)')

    const [showLoading, setShowLoading] = useState(false)
    // tracking if users enter the popover Content,
    // so we can decide whether to close the menu when users leave account icons
    const hasEnterPopoverContent = useRef()

    const styles = useMultiStyleConfig('Header')

    const onSignoutClick = async () => {
        setShowLoading(true)
        await logout.mutateAsync()
        navigate('/login')
        setShowLoading(false)
    }

    const handleIconsMouseLeave = () => {
        // don't close the menu if users enter the popover content
        setTimeout(() => {
            if (!hasEnterPopoverContent.current) onAccountMenuClose()
        }, 100)
    }

    return (
        <Box {...styles.container} {...props}>
            <Box {...styles.content}>
                
            </Box>
        </Box>
    )
}

Header.propTypes = {
    children: PropTypes.node,
    onMenuClick: PropTypes.func,
    onLogoClick: PropTypes.func,
    onSearchClick: PropTypes.func,
    onMyAccountClick: PropTypes.func,
    onWishlistClick: PropTypes.func,
    onMyCartClick: PropTypes.func,
    onMiniCartClick: PropTypes.func,
    searchInputRef: PropTypes.oneOfType([
        PropTypes.func,
        PropTypes.shape({current: PropTypes.elementType})
    ])
}

export default Header

I tried things like inline styles, which work, but that isn’t ideal when I have an external styles file for this component.

Problem with adding image avatar on three.js globe

I am preparing a 3d globe with three.js and I already achieve the rotating globe with below code.

HTML

<canvas id="canvas"></canvas>

JS

let camera;
let renderer;


function main()
{
    const canvas = document.querySelector('#canvas');


    scene = new THREE.Scene();

    camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1000);
    camera.position.z = 2;
    scene.add(camera);

    renderer = new THREE.WebGLRenderer({canvas: canvas, antialias: true,});
    renderer.setSize(window.innerWidth, window.innerHeight);
    renderer.setPixelRatio(window.devicePixelRatio);

    renderer.autoClear = false;
    renderer.setClearColor(0x00000, 0.0);


    // create earthgeometry

    const earthgeometry = new THREE.SphereGeometry(0.6,32,32);

    const eatrhmaterial = new THREE.MeshPhongMaterial({
        roughness : 1,
        metalness:0,
        map: THREE.ImageUtils.loadTexture('texture/earthmap1k.jpg'),
        bumpMap: THREE.ImageUtils.loadTexture('texture/earthbump.jpg'),
        bumpScale: 0.3,
    });

    const earthmesh = new THREE.Mesh(earthgeometry,eatrhmaterial);

    scene.add(earthmesh);

    // set ambientlight

    const ambientlight = new THREE.AmbientLight(0xffffff, 0.1);
    scene.add(ambientlight);

    // set point light

    const pointerlight =  new THREE.PointLight(0xffffff,0.9);

    // set light position

    pointerlight.position.set(5,3,5);
    scene.add(pointerlight);

    const animate = () =>{
        requestAnimationFrame(animate);
        earthmesh.rotation.y += 0.0015;
        render();
    }

    const render = () => {
        renderer.render(scene,camera);
    }

    animate();
}

window.onload = main;

Now I want to add some image avatar which will also attached with globe and rotate with globe. Reference: https://zinannadeem.sirv.com/Images/globe.gif (What I am looking for)

I am seeking some help how can i add some image avatar on the three.js globe which will rotate with globe itself ?

If you want to test with my globe images here you can grab (https://zinannadeem.sirv.com/Images/earthmap1k.jpg https://zinannadeem.sirv.com/Images/earthbump.jpg)

How can I make sure that my graph’s y-axis always starts at zero, hiding any numbers that are negative from view?

var fireCtx = document.getElementById('fireNumberChart').getContext('2d');
var fireChart = new Chart(fireCtx, {
    type: 'line',
    data: {
        labels: [], // Add your labels here
        datasets: [{
            label: 'Sensor Value',
            data: [], // Add your sensor data here
            backgroundColor: 'rgba(54, 162, 235, 0.2)',
            borderColor: 'rgba(54, 162, 235, 1)',
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    suggestedMin: 0, // Ensure the y-axis starts at 0
                    beginAtZero: true,
                    precision: 0 // Display whole numbers only
                }
            }]
        }
    }
});

I want to ensure that the lowest number on the y-axis is always fixed to 0. this is the JavaScript code I’m using for the chart

Loading PPTX file in frontend from base64 encoded data in react

I am getting base64 encoded data for a PPTX file from an API in react and I need to load the PPTX in an tag in UI.

import * as React from 'react';
import axios from 'axios';
import { useLocation  } from 'react-router-dom';

import Header from '../components/header.js';

export default function MainPage() {
    const [PPT_SRC, setPPT_SRC] = React.useState('');
    const location = useLocation();

    React.useEffect(() => {

        let url = 'get_data';
        url = url+'?id='+1;

        axios.get(url).then((response) => {
            console.log(response.data.message.PPT_SRC);

            //const linkSource = `data:application/pptx;base64,${response.data.message.PPT_SRC}`;
            //const downloadLink = document.createElement("a");
            //const fileName = "file.pptx";
        
            //downloadLink.href = linkSource;
            //downloadLink.download = fileName;
            //downloadLink.click();

            setPPT_SRC(response.data.message.PPT_SRC);

        }); 

    }, [location]);

    return (
        <div>
            <Header />
            <br /><br />
            
            <div id={"second"} style={{ padding: '30px 0' }}>
                <iframe 
                    title='CI'
                    src={`data:application/pptx;base64,${PPT_SRC}`}
                    style={{ height: '80vh', width: '70vw' }}
                >
                </iframe>
                {PPT_SRC}
            </div>
        </div>
    )
}

The above code is not loading the PPTX file in the , but when I uncomment the code inside the axios.get() method which creates the pdf file and downloads it, it forms the PPTX and downloads it propely.

Is there a way to load the PPTX in iframe ?

Any help is much appreciated.

Thanks,

Using React-Resizeable

I have been trying to get my code to resize images for a project I am working on. So the supposed to be able to resize images that was uploaded but I cant seem to get the library to work. I am using react-resizable library.

      <ResizableBox
        width={500}
        height={400}
        minConstraints={[100, 100]}
        maxConstraints={[300, 300]}>
        <span
          style={{
            backgroundColor: "yellow",
            width: "400px",
            height: "300px",
          }}>
          <img src={image} alt="" />
        </span>
      </ResizableBox>

Noob needs help google app script with incrementing cells with variables [closed]

Im trying to make a call type tracker where sheet1 would just be buttons with types of calls and one cell that displays the current month, when a button would be pressed it would add +1 to the associated month column on sheet 2 .sheet 2 would be where the information is stored. Thinking Columns Named the months and rows being types of calls. I would like the button to know the current month and match. The rows are not as important as they would be there own button for different call types. Sorry if i lost whoever trys to help.

        ("function calltype1() {           // Defines the cureent SpreadSheet//          const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();           var monthrange = spreadsheet.getRange("A1");           var monthvalue = monthrange.getValue();           //Defines to use Sheet2//           var sheet2 = spreadsheet.getSheetByName("Sheet2");            var jan = sheet2.getRange("B1");var jan = sheet2.getRange("B1");           var feb = sheet2.getRange("C1");          var mar = sheet2.getRange("D1");            var apr = sheet2.getRange("E1");            var may = sheet2.getRange("F1");          var jun = sheet2.getRange("G1");     var jul = sheet2.getRange("H1");     var aug = sheet2.getRange("I1");     var sept = sheet2.getRange("J1");     var oct = sheet2.getRange("K1");     var nov = sheet2.getRange("L1");     var dec = sheet2.getRange("M1");     //Defines current cell//     var cell = sheet2.getRange("B2");      //Defines Value of current cell//     var currentValue = cell.getValue();     var janvalue = jan.getValue();   if(monthvalue === janvalue)   {cell.setValue( + 1);   }   }

Dropzone Drag & Drop issue in Laravel

I’m encountering an issue with my Laravel application when using the Dropzone JavaScript library. If I remove id="dropzone-basic", I can add files and submit them, but it affects my design. However, if I add id="dropzone-basic", I can drag and drop files, but when I click submit, it doesn’t submit anything. The request is empty.

This is my form:

<form action="{{ route('import-file') }}" enctype="multipart/form-data" method="POST"  class="dropzone needsclick" id="dropzone-basic">
                            @csrf
                            <div class="dz-message needsclick">
                                Drop files here or click to upload
                                <span class="note needsclick">(This is just a demo dropzone. Selected files are <span class="fw-medium">not</span> actually uploaded.)</span>
                            </div>
                            <div class="fallback">
                                <input name="dataFile" class="form-control" id="dataFile" type="file" value="{{ old('dataFile') }}" />
                            </div>
                            <div class="col-12 mt-3 d-flex justify-content-end">
                                <button class="btn btn-primary" type="submit">Update</button>
                            </div>
                        </form>

and theme dropzone file:

"use strict";!function(){var e=`<div class="dz-preview dz-file-preview">
<div class="dz-details">
  <div class="dz-thumbnail">
    <img data-dz-thumbnail>
    <span class="dz-nopreview">No preview</span>
    <div class="dz-success-mark"></div>
    <div class="dz-error-mark"></div>
    <div class="dz-error-message"><span data-dz-errormessage></span></div>
    <div class="progress">
      <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuemin="0" aria-valuemax="100" data-dz-uploadprogress></div>
    </div>
  </div>
  <div class="dz-filename" data-dz-name></div>
  <div class="dz-size" data-dz-size></div>
</div>
</div>`,a=document.querySelector("#dropzone-basic"),a=(a&&new Dropzone(a,{previewTemplate:e,parallelUploads:1,maxFilesize:5,addRemoveLinks:!0,maxFiles:1}),document.querySelector("#dropzone-multi"));a&&new Dropzone(a,{previewTemplate:e,parallelUploads:1,maxFilesize:5,addRemoveLinks:!0})}();

How to form a querySelector from just a JavaScript HTML element reference

Ok, so I have this puppeteer project where I had done the research and was able to grab the ID tags from some username, password, and submit button elements on a login page and use them to target the elements to login. Now some changes has been requested where this needs to function on multiple different possible login pages that I may not know about.

One possible solution is when I have the user setup their parameters, and collect the URL of the login page they are wanting to use, I was going to open a new tab with Puppeteer to the page, and guide them through clicking on the username input, then the password input, then the submit button. When they do this, I can capture the click events, event.preventDefault() it, and then have an event.target reference to these input fields to validate the automation process.

If the input has an ID tag associated with it, that would be awesome and simple to store as a querySelector. If it has a class, I can test to see if only one element matches that class name or find the indexOf the input in the array of elements with that class.

What if it doesn’t have a class or ID tag though? What other reliable ways could I form a querySelector or way of targeting the same elements repeatedly? Should I think about finding the index of this element in documeny.querySelectorAll("input")?

I was also thinking of recording the x & y axis of the click event and then replicating a click at that point, and then grabbing the event.target again that way, but if a banner or something on this website I know nothing about, pops up, it would shift the layout of the page and make this an unreliable way of doing this as well.

I am curious to hear what other ideas this community can come up with. Lots of smart people in here!

Inline input field: input ‘pushes’ the second half of the sentence along

I am building a very simple website where the user enters information ‘natively’ into input fields in sentences. This means the input field has to act like it’s part of the sentence so if the data inputted exceeds the placeholder data, it will push the rest of the sentence along.

Here is an example. Where step 1. there is no interaction. The user then enters 5. When the user enters a second digit, 5 again, it moves ‘minutes’ along.

enter image description here

How can I achieve this?

I have attempted this in a mixture of Webflow and just HTML to try and troubleshoot but to no avail.

How to compile an Astro App with the development .env file

I have an app in Astro and I need to be able to compile but use the variables from the .env.development file since it goes to a dev server and not production. I have tried to modify the package.json file like this

  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro check && astro build --mode development",
    "preview": "astro preview",
    "astro": "astro"
  },

It also doesn’t work if I use

"build": "astro check && astro build --env=development"

But it doesn’t work, always using npm run build it takes the variables from the env.production file, how can I choose the file I want it to use

Sentry Userfeedback always shows incorrect environment

On the new User Feedback menu of the sentry dashboard, it always shows the production environment. But I set TEST_ENV using Browser JS.

Sentry.init({
dsn: dsn,
integrations: [
    Sentry.replayIntegration({
        maskAllText: false,
        maskAllInputs: false,
        blockAllMedia: false,
        unblock: [".unblock-me"],
        unmask: [".unmask-me"]
    })
],
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
environment: "TEST_ENV" });

Image here

But if I switch to Old User Feedback from the top right button, I find the correct feedback using Filter Environment.

Old View mage here

[Note: Always shows the correct environment in Link Error (event). I am using Blazor and I tried SentrySdk from Sentry.AspNetCore nuget]