« first day (3693 days earlier)      last day (1238 days later) » 

3:53 AM
Hi All , dynamically if we add og:image tag the facebook when you share it desont take
checkOgEmpty()


function checkOgEmpty() {

var ogcheck = document.querySelector("meta[property='og:image']").getAttribute("content");

if (ogcheck.length == 0) {
if ($('#myCarousel').length == 1) {

var imageurl = $('#myCarousel .carousel-item .carousel-img').first().attr('data-bgset');
var ogSplit = imageurl.split("?");
var Currentcurl = $('meta[property="og:url"]').attr('content')
$('meta[property="og:image"]').attr('content', Currentcurl + ogSplit[0]);
$('meta[name="twitter:image"]').attr('content', Currentcurl + ogSplit[0]);
does any one know how to fix because the og:image is instially empty latter using script i am trying to apply the og:image tag dyna,ically but this doesnt show the image
 
 
3 hours later…
ABC
6:45 AM
Hello
I would like to ask if it's possible to make the content responsive in gridster item when resizing the item
 
7:02 AM
Hi
 
@Adithya Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
4 hours later…
11:20 AM
hello 0/
 
user12582392
11:39 AM
any one knows what this mean
 
user12582392
exports = module.exports = require("./src")
 
i think it means you are exporting all contents of ./src folder
 
user12582392
but it's in the index file, i'm not good in javascript but shouldn't a top level file be clean of exports?
 
user12582392
i mean the server
 
it depends on the way the code was structured
 
user12582392
11:48 AM
require("@babel/register")//don't know yet
require("dotenv").config() //loads shell data from .env file into process.env.VAR nodeJS variable.

exports = module.exports = require("./src")
 
user12582392
that;s the whole file
 
user12582392
src is indeed a folder
 
babel is mostly used to compile modern js syntax down to vanilla js
what are the contents of ./src
 
12:41 PM
Hello
I am trying to create simple React app
but I am struggling with fetching data
I am using XMLXttpRequest
I don't know how to fetch description for specific id
can you help me ?
 
use axios
 
it's the same as XMLHttpRequest
based on the same logic
??
I already have some code
but I don't have an idea how to continue
 
yes, one has a lot of work done already for you, the other you have to do all of it by your self
 
12:47 PM
useEffect(() => {
    const xhr = new XMLHttpRequest();

    const url = 'https://eonet.sci.gsfc.nasa.gov/api/v2.1/categories';
    const fetchData = async () => {
      xhr.open('GET', url);

      xhr.responseType = 'json';

      xhr.onload = () => {
        const data = xhr.response;
        setCategoryData(data.categories);
        setSelectedCategory(data.categories[0].title);

        console.log(Object.values(data.categories));

        setLoading(false);
      };

      xhr.send();
      return () => {
this works properly, it's not problem with this
I don't know how to fetch specific description
 
just loop through the data
 
  const handleChange = (event) => {
    setSelectedCategory(event.target.value);
  };

  return (
    <>
      {loading ? (
        <div>Loading...</div>
      ) : (
        <div>
          <header>
            <h1>{selectedCategory} Tracker (powered by NASA)</h1>
            <p>{selectedDescription}</p>

            <select onChange={handleChange} value={selectedCategory}>
              {categoryData.map(({ id, title }) => (
                <option key={id} value={title}>
                  {title}
I already did that
but on the place where I populating the options from select dropdown
How to display specific description outside of loop ?
Here - <p>{selectedDescription}</p>
 
have an onClick={(data)=>{ send data to state here}}
 
but <select> requires onChange instead of onClick
As I told you, complicated situation
 
it is not really complicated
the onChange is happing outside the loop
 
12:56 PM
Yes
 
but can still grab data from the options
 
I have
  const handleChange = (event) => {
    setSelectedCategory(event.target.value);
  };
this works for category title
 
your option can have another attribute
say <option key={id} value={title} anotherAttribute={description}>
then when it is selected to can getElementById(optionID)
optionID = event.target.key
or try event.target.anotherAttribute
hope that solved it :)
 
No man
As I told you
it's very complex
Does not work
What's about .find or .filder from JS
Can I use that in this specific case ?
 
@BobbyAxe Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
1 message moved to Trash can
 
1:08 PM
<option key={id} value={title} anotherAttribute={description}>

const handleChange = (event) => {
    console.log(event.target); // what does this show ??
    setSelectedCategory(event.target.value);
  };
 
No man , sorry , that's not the idea
Later I want to fetch and link based on id
 
@Minsky this will load './src/index.js'
 
What in the case if I have 100 properties, and I need all of that
option will have then 100 additional values
Any way to do that with .filter of .find or foor loop
??
1652
Q: Find object by id in an array of JavaScript objects

thugsbI've got an array: myArray = [{'id':'73','foo':'bar'},{'id':'45','foo':'bar'}, etc.] I'm unable to change the structure of the array. I'm being passed an id of 45, and I want to get 'bar' for that object in the array. How do I do this in JavaScript or using jQuery?

But I am not sure how to use this in my case
how to pass id dynamically
and based on that ID, I will get all possible data
there is no need to pass additional values in <option> ?
 
you have to loop through the array comparing the id's until you find the matching id
 
Yes, I know that
but that's easy to say, but hard to do
because , where to pass the id dynamically
where to call that function etc.
 
1:21 PM
I don't think you are describing what your issue is very well
 
I understand you, it's very complex, and based on that it's very unclear
 
if you are trying to display the description based on the option selected then the first approach I suggested will help
 
Please tell me did you see API ?
 
if you are trying to display the description at a later time then you just to loop over the array
 
let's imagine you have 10.000 additional properties of objects
 
1:24 PM
yes i did
 
And let's imagine that I need all 10.000 properties
a need to manually add all 10.000 on <option 'HERE'
	{
			"id": 6,
			"title": "Drought",
			"link": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/categories/6",
			"description": "Long lasting absence of precipitation affecting agriculture and livestock, and the overall availability of food and water.",
			"layers": "https://eonet.sci.gsfc.nasa.gov/api/v2.1/layers/6"
		},
lets imagine that I have 100.000 additional properties here
id, title, link, description, layers and 100.000 others
 
user12582392
@JBis thanks
 
Later I want based on that Id , to fetch data from link
You probably don't understand my idea, because it's very complex
it's not just loop through the array
 
user12582392
async function connection (){
    let testClient
    try {
      testClient = await MongoClient.connect(process.env.MFLIX_DB_URI, {
        useNewUrlParser: true,
      })
      const clientOptions = testClient.s.options
      console.log("options", clientOptions)
    } catch (e) {
     console.log(e)
    } finally {
      console.log(e)
    }
}
Is there anything wrong there? I received unhandled promise from Node
 
user12582392
oops the require shouldn't be there
 
user12582392
1:34 PM
the warning is Unhandled promise rejections are deprecated.
 
user12582392
oh i guess the finally doesn't make any sense.
 
1:47 PM
@MileMijatović I would say use array[id] assuming that the ids are integers and that the way the array objects is structured will always remain the same which is most unlikely
so I don't think what you want is possible in javascript currently
 
I don't know what to say
it's basically not big deal , but we don't know how to do that properly
 
array[5] will get you the object in that position
 
That's ok
 
but there is no guarantee that the object will remain in that position next time you call the api
 
I don't want to define id manually
id must be dynamic
array[id]
 
1:55 PM
yes, it is dynamic
can anyone help me with this code jsfiddle.net/bobbyaxe61/dqytxp0c/3
the code has been written in jsfiddle.net/bobbyaxe61/dqytxp0c/5 but if the number of invites goes more than 4 at depth of 10 it times out
any help is appreciated, please lower the dept before running the code else you might be stuck waiting for it to complete
how do i optimize the code to support greater values
 
 
1 hour later…
3:14 PM
Hi, I'm doing a socket.io application,
 
@Googlian Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
The issue I'm having is more bandwidth
My application is being connected by more than 3000 devices all the time 24/7
But network usage of android device got more than 70 mb
Can I know the reason or how can I optimize i
 
4:05 PM
i know my question is a bit difficult but I really need some inside to what I am doing wrong
 
@BobbyAxe do you have a specific issue or just trying to optimize it?
 
@JBis my issue is that it times out once the number is more than 3 and depth is more than 10
so I feel I might have used the wrong approach to it
 
recursive functions are slow, don't use them if you dont need to
 
so a regular loop would have been better, I just learned something
 
yes
 
4:17 PM
okay I will rewrite it with a regular loop and see what happens. thanks
 
@BobbyAxe also, logging is going to be quite slow if done in a loop. Consider adding a string variable and appending your log messages and then finally logging that string after the iteration is complete.
 
@JBis thank you so much
 
np
 
heyi do you think too its difficult to be freelancer with javascript,html,css? i think wordpress is more useful for that matter
 
@Tolima idk what you mean by too difficult
 
4:32 PM
finding a freelancer job
because in general people ask for ecommerce and it doesnt matter how you give them that site , they just need it asap
 
i mean
wordpress devs need good js html and css too
so.... do all 4
certainly better than just doin 3
 
hmm i never tried wp ,i was assuming it provides some prepared drafts and making it with less knowledge
 
It does, however, if you don't know more than the drag-n-drop features, you'll very quickly run into a situation where the client wants to do something, and you won't be able to do it.
you'd also need to know your way around php
 
nowadays i am into mern stack and following some udemy courses , but i still have doubts how people create features like discounts or coupons , keeping old price ,scratching it ,then featuring it with new price
and expiring it in time ,then again show it up in special day
from tutorials its hard to learn that i wish we could see codes of some popular website which use react and nodejs
 
4:57 PM
people use it for all sorts of things but imo wordpress is trash for anything beyond a blog site
you can add all the plugins you want, its not made for eCommerce or other things
 
seems to be way too resource intensive for anything small imo
 
user12582392
@JBis buy why not to use just require(./src) or something like that
 
because you need quotes? or is that a typo?
 
user12582392
yes it's a typo
 
user12582392
I mean exports = module.exports = require("./src")
 
user12582392
4:59 PM
isn't something you'd use to export?
 
user12582392
but instead it's like importing stuff
 
it imports and exports
 
5:59 PM
@JBis thanks for your help rewrote it with pure loops the best I got to was (10,10) double the performance thanks jsfiddle.net/bobbyaxe61/o6rqk37f/9
 
 
2 hours later…
user12582392
8:09 PM
when babel compiles functions, what's the JS-target?
 
user12582392
For example, I've tested this plugin:["babel-arrow-functions"] and compiles arrow functions to functions. So it's always ES1 or what?
 
9:00 PM
anyone know hot to display each line in textarea that starts with "-" as a individual <span> element
 
@ribosed Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
split by lines, then for each one that starts with "-", make a span
 
i know that i should use split but i cant make it .. i am trying var lines = $(this).val().split(/\W/g,'-');
 
9:17 PM
split on lines first, not \W or -
34
Q: Javascript: Convert textarea into an array

MatrymHow would you go about breaking up a textarea value into an array, based on the end of line separation? Use of jQuery is cool by me...

Then, based on wehtehr it starts with -, you can decide whether or not to use a span
during your loop that prints it to the page
 
9:34 PM
i still cant figure it out, i found this regex regex101.com/r/yCOvyR/1 should do what i want, but my js knowledge is low, i cant implement it in in may fiddle snipet... thank you anyway
 
user12582392
10:02 PM
Trying to load npm packages (js code) to the browser to play, which way would you use? ` Maybe <script src="node_modules/package"></script>` ? But this should be adjusted using babel first right?
 

« first day (3693 days earlier)      last day (1238 days later) »