Highcharts Error #16 But I’m not using Highstocks

I’m using multiple charts on the same page. I have a bar chart, an activity gauge chart and a map chart(they are loaded on different div ids).

Everything was working fine and no error messages until I added to code for the map and called the library that’s needed for this to work.

After that, I kept getting this Highcharts Error #16 msg and I know that commonly that happens if I call the highcharts.js more than once on the same page or If I call both Highstock and highcharts.js at the same time.

I know that everything from highcharts.js is already included in Highstocks and that there is no need to call both but this is not the case for me since I’m not even using Highstock

These are the libraries I’m currently working with

<script src="https://code.highcharts.com/maps/highmaps.js"></script>//I started getting that error msg after I added this but my map chart won't work without it
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

I couldn’t make my map chart to work when I first added this line

<script src="https://code.highcharts.com/maps/highmaps.js">

So what I did was, move it all the way to the top so it would load first and that fixed the problem with my map chart but while the map and the other charts are working fine. That Highcharts Error #16 error msg is still there in my console and it bothers me.

I don’t think I should just let it be because my charts are all working. There must be a solution.

I appreciate any help I can get.

EDIT: If additional code is required, let me know in the comments I will provide.

Copy to clipboard code in JavaScript doesn’t work

I’m trying to write in javascript and I want to understand why it doesn’t work?
sample order code that I want to copy: 593004485164756431

when I copy to clipboard : 593004485164756500

I checked for an error in the console, there was no error, does the browser affect the error? i use firefox

this my code

                function copyToClipboard(text) {
                if (navigator.clipboard && window.isSecureContext) {
                    return navigator.clipboard.writeText(text)
                } else {
                    // text area method
                    let textArea = document.createElement("textarea")
                    textArea.value = text
                    // make the textarea out of viewport
                    textArea.style.position = "fixed"
                    textArea.style.left = "-999999px"
                    textArea.style.top = "-999999px"
                    document.body.appendChild(textArea)
                    textArea.focus()
                    textArea.select()
                    return new Promise((res, rej) => {
                        // here the magic happens
                        document.execCommand('copy') ? res() : rej()
                        textArea.remove()
                    })
                }
            }

on button

<img onclick="copyToClipboard({{ $result['code_order'] }})" style="width:20px;cursor:pointer;" src="{{ url('img/copy-solid.svg') }}"/>

I hope I can find the solution to this problem. Thank you

Vue.js computed boolean incorrect

I need a computed property for whether startDate is less than endDate. For some reason when I code it as below, the computed property always computes as false even though the expression is correct. See Pen

HTML:

<div id="app">
  dateStart: {{ dateStart }} <br>
  dateEnd: {{ dateEnd }} <br>
  computed dateStart < dateEnd: {{ startLTEndDate }} <br>
  expr dateStart < dateEnd: {{ Date.parse(dateStart) < Date.parse(dateEnd) }} <br>
</div>

JS:

var app = new Vue ({
    el: "#app",
    data() {
        return {
          dateStart: '2010-01-01',
          dateEnd: '2011-01-01'
        }
    },
    computed: {
        startLTEndDate: () => {
            return Date.parse(this.dateStart) <                             Date.parse(this.dateEnd)
        }
    }
})

EJS – Pushing array from JS to Node

Here’s my app.js file:

const express = require('express');

const app = express();
app.use(express.static(__dirname + '/assets'));

app.set('view engine', 'ejs');

app.listen(3000);

app.get('/', (req, res) => {
    const toSearch = []
    res.render('index', {toSearch});
})

app.use((req, res) => {
    res.status(404).render('404');
});

And here’s a snippet of my JS file (on my index.js):

function addLatLng() {
  var name = document.getElementById('inputName').value();
  var lat = document.getElementById('latitude_input').value;
  var lng = document.getElementById('longitude_input').value;
  console.log('Name:'+name+'Latitude:' + lat + ', Longitude:' + lng);
}

I want to push the name, lat. lng data from my JS file into my app.js file. How do i achieve this? Im new to Node.js, and any help would be appreciated.

why bad promise syntax in this javascript class

In this snippet https://jsfiddle.net/tx2ac6kq/8/ I get an error about resolve not defined, really can’t see why :

class Test {
  #text; 
  #timerId;

  set text(text) {
    this.#text = text;
  }
  
  checkText = () =>  {
    let value = this.#text;
    console.log("checkText");
    if (value) {
      clearInterval(this.#timerId);
      resolve(value);
    }
    else {
      console.log("checkText")
    }
  }
  
  get text() {
      let value = (async () => await new Promise((resolve, reject) => {
        this.#timerId = setInterval(this.checkText, 1000);
      }))();
      return value;
  }
  
  constructor() {
    fetch("https://jsonplaceholder.typicode.com/posts/1")
      .then((response) => {
        response.text().then((response) => {
          this.text = response;
          // console.log(this.text);
        });
      });
  }
}

let test = new Test();
console.log(test.text);

How to set useState while checking propsType

hello I’m trying to set useState but it crashing the whole code. here I’m sending propstype from parent component to child component. so when propstype condition is checked/true then I’m trying to set useState but instead of setting it crashes. please checked below what I tried, Here I’ve removed unwanted code otherwise it’ll too big for readers and they might lost the focus from question. can anyone suggest me any new solution for this I’ve tried a lot of and then came here for the proper solution.

parent component (BillComponent)

const BillComponent = () => {
return(  
{/* Add Bill form */}
        <Drawer
          title={"Add Bill"}
          placement="right"
          onClose={onClose}
          visible={visible}
          className="ant-drawer-half"
        >
          <AddBill parentCallback={handleCallback} type="add" />          // <---This AddBill is child component and here I'm passing props type as add
        </Drawer>
    </>
    </>
  );
};
export default BillComponent;

child component (AddBill)

const AddBill = (props) => {
const [checked, setChecked] = useState(false);

if(props.type === "add"){                       
    setChecked(false);          //<---This is where main code is crashing. when I set useState 
  }else{
    setChecked(true);
  }

return( 
// divs of project
 );
};
export default AddBill;

How to props through the deeply nested child to parent data ? React

To explain the situation. I have a child component that has one chevron that spins on a click. I need to implement from child to parent and to grand parent props data.

<ChildComponent>
<ParentComponent>
<GrandParentComponent>

Inside ChildComponent I have arrow icon ( img )

  const [rotateIcon, setRotateIcon] = useState(false);

  const expandAttachment = useCallback(() => {
    setRotateIcon(!rotateIcon); 
  }, [rotateIcon]);


  <img src="assets/arrow" transform={rotateIcon ? 'rotate(90deg)' : 'rotate(0)'} >

And this is work but…. I need to props rotateIcon state to GrandParentComponent compoentent.

It’s not just the child to the parent. Than child to parent and from parent another level up to. GrandParent.

How do I do that? Is this a good way at all? What are my alternatives? I do not use redux in the system, but api context!

To be clear. All three components are connected.
Each to each is a child parent!

Async storage cannot retrieve data from react native

I am using AsyncStorage to keep user data to phone. After registering the user, i am trying to retrieve the user if exist one and automate redirect to profile page.
but I have problems with async storage because it returns only the word ‘user’ in the console…

in the login component ->
import AsyncStorage from ‘@react-native-async-storage/async-storage’;

const loggedUser = async () => {
    try {
        const u = await AsyncStorage.getItem('user');
        console.log(u);
    } catch (error) {
        console.log(error);
    }
};
/**
 * 
 * This function retrieve the data from the server and store it to the local database..
 * 
 */

const executeLogin = async (email, password) => {
    try 
        {
            // Get data and store in async storage
            const response = await data.post('/api/login', {email, password});    
            storeData('user', response.data); -> //Check the code bellow for the source
        } 
        // Catch all errors bellow
        catch (error) 
        {
            if (error.response.status === 404 && error.response.data === 'Wrong credentials') {
                Alert.alert('Whoops!', 'You entered the wrong credentials. Please try again.');
            }
            else {
                Alert.alert('Whoops!', 'Something went wrong. This is an unexpecred error. We will try to fix it as soon as possible');
            }
        }
};

export default executeLogin;

The code block above calls the axios and supose to store the data to async storage. But I have no ideea also if it worked because it gave me no error…

import AsyncStorage from '@react-native-async-storage/async-storage';

/**
 * 
 * This function must only accept serialised object with JSON.stringfy() method
 * 
 */
const storeData = async object => {
    try 
    {
        await AsyncStorage.setItem('user', object);
    } 
    
    catch (error) 
    {
        console.log(error);
    }
} 

export default storeData;

This is the store function

Cannot understand what I am doing wrong….
Thanks, Daniel

Find all unique values in array and than split it and return something else

My goal is to find all the unique years in this array and than return it as a array. I have almost done it but cant figure out how I will return the split value.

function findUniqueYears() {
  const arr = ['1973-11-01', '2001-01-01', '1999-10-01', '2007-10-01', '2016-06-01', '2005-08-01', '1973-09-01', '1979-12-01', '2001-08-01'];
  for (var i = 0; i < arr.length; i++) {
    for (var j = i + 1; j < arr.length; j++) {
      if (arr[i].split("-")[0] === arr[j].split("-")[0]) {
        arr.splice(j, 1);
      }
    }
  }
  console.log(arr)
}

Displaying modal when page has scroll (Vue)

Im new & i want a way to display a modal on Vue, when user scroll my page after scrolling around 400-500 px, so i try this :

PageOfMyModal.vue:

 <template>
 <div id="app">

   <Modal v-on="handleScroll"/>
 
  </div>
</template>

<script>
 //import Modal from '@/component/Modal.vue';
 export default {
  methods: {
    handleScroll(event) {
    this.handleDebouncedScroll= (window.scrollY > 0);
   }
 },
},
</script>

and my Modal.vue :

<template>
 <transition name="modal-fade">
<div class="modal-backdrop">
  <div class="modal"
    role="dialog"
    aria-labelledby="modalTitle"
    aria-describedby="modalDescription"
  >
    <header
      class="modal-header"
      id="modalTitle"
    >
      <slot name="header">
        This is the default tile!
      </slot>
      <button
        type="button"
        class="btn-close"
        @click="close"
        aria-label="Close modal"
      >
        x
      </button>
    </header>

    <section
      class="modal-body"
      id="modalDescription"
    >
      <slot name="body">
        This is the default body!
      </slot>
    </section>

    <footer class="modal-footer">
      <slot name="footer">
        This is the default footer!
      </slot>
      <button
        type="button"
        class="btn-green"
        @click="close"
        aria-label="Close modal"
      >
        Close me!
      </button>
    </footer>
  </div>
  </div>
 </transition>
</template>

But i got this error :

@ ./src/router/index.js 9:0-39 54:15-20
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.16:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

back button gives error message when selected li is less than selected index?

So i’ve got some JS I use to switch tabs on a single page. hitting the next button until the end stops, and will not throw an error message. but when i use the back button to go all the way to the first selected li item, it gives me this error: VM6813 astral.php:844 Uncaught TypeError: Cannot read properties of undefined (reading ‘classList’)
at HTMLAnchorElement.btPrev.onclick (VM6813 astral.php:844:37)
btPrev.onclick @ VM6813 astral.php:844

Why would it give that error, when hitting next will not?

const
      navSub_LI = document.querySelectorAll('#navsub > li'),
      contents = document.querySelectorAll('#Contents > article'),
      btNext = document.querySelector('#bt-next'),
      btPrev = document.querySelector('#bt-prev'),
      setContent = ref => contents.forEach((article, i) => article.classList.toggle('noDisplay', article.dataset.ref !== ref));
    navSub_LI.refIndex = [...navSub_LI].findIndex(li => li.classList.contains('active'))
    setContent(navSub_LI[navSub_LI.refIndex].dataset.ref)

    navSub_LI.forEach((li, indx, arr) => {
      li.onclick = () => {
        navSub_LI.refIndex = indx
        setContent(navSub_LI[indx].dataset.ref)
        arr.forEach(z => z.classList.toggle('active', z === li))
      }
    })
    btNext.onclick = () => {
      navSub_LI[navSub_LI.refIndex++].classList.remove('active')
      if (navSub_LI.refIndex >= navSub_LI.length) navSub_LI.refIndex--
      navSub_LI[navSub_LI.refIndex].classList.add('active')
      setContent(navSub_LI[navSub_LI.refIndex].dataset.ref)
    }
    btPrev.onclick = () => {
      navSub_LI[navSub_LI.refIndex--].classList.remove('active')
      if (navSub_LI.refIndex >= navSub_LI.length) navSub_LI.refIndex++
      navSub_LI[navSub_LI.refIndex].classList.add('active')
      setContent(navSub_LI[navSub_LI.refIndex].dataset.ref)
    }

create pinned products showcase section based on scroll in reactjs

I have a UI which looks like this”

UI

I have tabs on the left and product showcase on the right, in one of the sections of a page. The issue is, I want the default browser scroll to stop when it reaches this section in page until all the tabs are shown one by one. Once all tabs are complete, I want the default window scroll to continue.
Is there any react.js (or javascript/jquery) library for this type of functionality?

How to get or call Javascript var in HTML object tag or HTML embed tag from parent html page?

I have embedded a codmirror html file by 3 different way such as iframe tag, embed tag and object tag inside another html file on the same server.

<!-- The Codemirror Modal window-->
<div id="codeMirrorModal" class="modal">
  <!-- Modal content -->
  <div class="modal-content">
    <span class="close">&times;</span>
    <iframe id="cmIframeId" class="iframeStyle" name="cmiframe" src="../html/codemirror.html" ></iframe>
    
    <embed id="cmEmbed" type="text/html" src="../html/codemirror.html" width="800" height="500">
    
    <object id="cmObject" data="../html/codemirror.html" width="800" height="800" type="text/html"> </object>
    
  </div>
</div>

I can initialize the content of codemirror by iframe but I don’t know how to initialize it by embed and object tag.

function openAndInitializeCodeMirror() {
        var modal = document.getElementById("codeMirrorModal");
        modal.style.display = "block";
        
        var content = editor.getContent();

        // with success
        var iframe = document.getElementById("cmIframeId");         
        iframe.contentWindow.codeMirrorEditor.setValue(content);
        
        // no success           
        var embed = document.getElementById("cmEmbed");
        embed.contentDocument.codeMirrorEditor.setValue(content);

        // no success           
        var object = document.getElementById("cmObject");
        var myData = object.contentDocument.body.childNodes[0].innerHTML;

}
    

var codeMirrorEditor is an instance of codemirror on the embedded page.

How can I access or call the codeMirrorEditor instance on the embeded page from parent page to initialize it by my content?

Webpack+Babel | C:node_modules doesn’t exist or is not a directory | JS

hope you doing great.

I just tried using babel and webpack but for some reason it doesn’t work.
I even bought a new computer but no change…

Every time I start running the webpack command (node_modules/.bin/webpack). I am getting the error:
C:node_modules doesn’t exist or is not a directory

The same happens when I using babel without webpack:
The “node_modules” command is either misspelled or
could not be found.

(I am calling a start script from package.json file here – node_modules/.bin/babel ./src/index.js -o ./dist/assets/bundle.js)

The path clearly exsists on my computer.
Also I checked several times that I am in the correct folder in my terminal…
My package.json file looks like this:

{
      "name": "chapter_19",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "babel": "node_modules/.bin/babel ./src/index.js -o ./dist/assets/bundle.js"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "@babel/cli": "^7.2.3",
        "@babel/core": "^7.3.4",
        "@babel/preset-env": "^7.3.4"
      },
      "dependencies": {
        "webpack": "^5.72.1",
        "webpack-cli": "^4.9.2"
      }
    }

Here’s my webpack file:

  const path = require('path');

module.exports = {
    entry:':/src/index.js',
    output:{
        path: path.resolve(__dirname, 'dist/assets'),
        filename: 'bundle.js'
    }
}

And my files/folders
image

Does someome maybe what’s going on here?

Help would be greatly greatly appreciated.Thanks.