Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 21 2018 17:11
    @MadLittleMods banned @OmarAlmaqtri
  • Jun 05 2018 23:13
    @MadLittleMods banned @LWSS
  • May 25 2018 16:50
    @MadLittleMods banned @TheRedstoneTaco
Marco Colia
@justoverclockl
guys, need a little help from you expert

 extend(DiscussionHero.prototype, 'oninit', function () {

    const GameApi = fetch('https://api.rawg.io/api/games/call-of-duty-modern-warfare?page_size=1&page=1&key=myapi')
      .then(response => response.json())
      .then(data => {
        this.gameDet = data;
        console.log(data)
        console.log(this.gameDet.name)
        console.log(this.gameDet.description_raw)
        console.log(this.gameDet.metacritic)
      })
  })
  extend(DiscussionHero.prototype, 'items', function (items) {
    items.add(
      'aaaa',
      <div className="myclass">
              <div class="myclass">
              // <------------------------------------------------ I WANT TO DISPLAY this.gameDet.name HERE
              </div>
      </div>
    );
  });
3 replies
but i can't access the json from there, console.log shows details correctly
Chris
@Valadone
Hey, someone using knexJS here ?
I can't find how I can retrieve my data from my DB
How I can retrieve everything from my database first
  knexClient.schema.createTable("events", (table) => {
    table.increments();
    table.dateTime("starts_at").notNullable();
    table.dateTime("ends_at").notNullable();
    table.enum("kind", ["appointment", "opening"]).notNullable();
    table.boolean("weekly_recurring");
  });
Marco Colia
@justoverclockl

guys, i have no experience with this, so i need help from an expert developer. i'm currently fetching an api, that return a string. i have this string into a div like:


<p class="card-text" id="google_translate_element">{this.gameDet.description_raw}</p>

there's a way to auto translate this string into navitator.language of the user?

1 reply
Dominic Watson
@intellix
iOS14 - scrollTo(0, 1) keeps Safari Browser UI collapsed
iOS15 - scrollTo(0, 1) causes Safari Browser UI to expand (URL bar etc)
anyone found a way around the new behaviour in iOS15?
cyberquarks
@cyberquarks

Hi I have a quick question

Given this code:

de = () => {
           ce(),
           r.ipcMain.handle("someIPCFunction", (async () => !!oe().someValue))
         }

How can I make it so I can window.alert the value returned by the r.ipcMain.handle("someIPCFunction", (async () => !!oe().someValue))

As such I can see the value returned by r.ipcMain.handle... as it is getting applied.

Just to know what's the response data of the IPC function
Julian Gonggrijp
@jgonggrijp
@cyberquarks if you mean you want to see what's inside oe().someValue, put the alert inside the same callback.
cyberquarks
@cyberquarks
Hi @jgonggrijp I figured it out,
de = () => {
           ce(),
             () => { 
                  let value = r.ipcMain.handle("someIPCFunction", (async () => !!oe().someValue)); 
                  window.alert('something');
                  return value; 
             }
         }
cyberquarks
@cyberquarks
Julian Gonggrijp
@jgonggrijp
@cyberquarks Not on my own, but I've used plyr which worked quite well.
Anurag Vohra
@anuragvohraec
Hi do any one know how to "setTimeout to break an "for await ...of" loop, if loop do not complete within a given time?"
https://stackoverflow.com/questions/69541047/javascript-settimeout-to-break-an-for-await-of-loop-if-loop-do-not-comple
Marco Colia
@justoverclockl
guys anyone know why i can't access my json data into the div?

 extend(CommentPost.prototype, 'oncreate', function () {

    let AmILoggedIn = app.session.user;
    if (AmILoggedIn) {

      const ipApi = fetch('https://ipinfo.io/json?token=MYAPIKEY')
        .then((response) => response.json())
        .then((data) => {
          this.ipData = data;
          console.log(data)
        })
        .catch((error) => console.log('Something went wrong...'));
    }
  })
  extend(CommentPost.prototype, 'headerItems', function (items) {
    items.add(
      "ipinfo",
      <div className="ipinfo" id="countryCode">{ipData.country}</div>
    )
  })
ipData is not defined
Julian Gonggrijp
@jgonggrijp
@justoverclockl Probably because headerInfo is being invoked before the response arrives. Bit difficult to be sure, though, because I'm not familiar with this coding style. Is this some flavor of React?
Marco Colia
@justoverclockl
@jgonggrijp is a forum platform based on extenders.
Marco Colia
@justoverclockl
and what about this? i cant display json output into the div

 extend(CommentPost.prototype, 'headerItems', function (items) {
    const giveMeInfo = fetch("https://ipinfo.io/json?token=mykey")
      .then((response) => response.json())
      .then((data) => {
        this.ipInfo = data;
        console.log(this.ipInfo.country)
        const flagImage = 'http://purecatamphetamine.github.io/country-flag-icons/3x2/' + data.country.toUpperCase() + '.svg';
      },
    items.add(
      "ipinfo",
      <div className="ipinfo" id="countryCode"></div>
    ))
  })
});
<div className="ipinfo" id="countryCode">{this.ipInfo.country}</div> not work
Julian Gonggrijp
@jgonggrijp
@justoverclockl Now you're passing the items.add expression as the second argument to the final then, which is almost certainly not what you want. You can try this instead:
extend(CommentPost.prototype, 'headerItems', function (items) {
  const giveMeInfo = fetch("https://ipinfo.io/json?token=mykey")
    .then((response) => response.json())
    .then((data) => {
      this.ipInfo = data;
      console.log(this.ipInfo.country)
      const flagImage = 'http://purecatamphetamine.github.io/country-flag-icons/3x2/' + data.country.toUpperCase() + '.svg';
      items.add(
        "ipinfo",
        <div className="ipinfo" id="countryCode">{this.ipInfo.country}</div>
      );
    });
});
Anurag Vohra
@anuragvohraec
Stephen James
@sjames1958gm
Interesting proposal. Running a spell check on it would be a good idea. Thinking maybe () rather than [] might be an option
Mayank Aggarwal
@Mayank0255_twitter
https://twitter.com/Mayank0255
Soon will start sharing some dev related stuff🎉
Metheny80
@Metheny80
Is there any way to manipulate dates/times (add, subtract days to dates etc.) without having to deal with timezones? I know about UTC, but it seems wrong as what I really need is the local time only without the timezone. Is that possible?
Julian Gonggrijp
@jgonggrijp
@Metheny80 Sure. If you mean you're looking for a library that can do it, consider Moment.js or one of the alternatives mentioned on its status page.
Pedro Ávila
@aviladev
@Metheny80 personally I like date-fns beacause of their functional approach.
Metheny80
@Metheny80
@jgonggrijp I know about moment.js, but the date always contains the timezone. For example, let's say I want to get the current local date without the timezone. How do I do it?
Julian Gonggrijp
@jgonggrijp
@Metheny80 what exactly do you mean by a date without a time zone? What problem are you trying to solve?
Metheny80
@Metheny80
@jgonggrijp the front end needs to load the date and display it the same, wherever in the world the page is loaded. If a person in the US chooses July 7th at 1 AM and saves it (in the DB), and another person views the page in Europe, I still want it to be displayed as July 7th at 1 AM (the location doesn't matter)
I think when loading a Date object, it always tries to figure out the local time according to the device's timezone, but I don't want that
Christopher Suchanek
@wsuchy
Can someone explain me this voodoo:
RegExp("<").test(() => "\x3c") // false
RegExp("<").test(() => "<") // true
RegExp("<").test("\x3c") // true
Julian Gonggrijp
@jgonggrijp
@Metheny80 Would just saving the datetime as an ISO string work for you? That's yyyy-mm-ddTHH:MM:SS with optional fractional seconds (and an optional time zone)
@wsuchy I can't explain the voodoo, but I don't think passing a function to RegExp.prototype.test is standard.
Metheny80
@Metheny80
@jgonggrijp it's possible. the question is what will happen when I load it into a Date object and use moment.js to do date math (e.g. subtract/add days)? Will it try to convert it to local time using the system's timezone?
Julian Gonggrijp
@jgonggrijp
@Metheny80 I think a library like Moment will give you control over that. If necessary, you can also explicitly pass the local time zone to the parser.
Metheny80
@Metheny80
@jgonggrijp that's the thing, I don't know the timezone and I don't want to deal with it. I just want an absolute time without having to deal with timezones.
1 reply
Julian Gonggrijp
@jgonggrijp
@Metheny80 You don't need to know it. Moment can tell you. https://momentjs.com/docs/#/manipulating/utc-offset/
Also, there is no such thing as "absolute time".
Metheny80
@Metheny80
@jgonggrijp when you say "i'm going to sleep at 12:00 and wake up at 15:00", do you think about what timezone you are in? See my point?
Julian Gonggrijp
@jgonggrijp
@Metheny80 I see your point. Do you understand that I have given you a technical solution?
Liam
@LiamK021
Hi
Mahedi Hassan
@mahadihassan-dev
Hi Is there anyone?
I need to discuss about something
Eric Eastwood
@MadLittleMods
@mahadihassan-dev Best to ask your question right away, don't ask to ask
Mahedi Hassan
@mahadihassan-dev
Oh I Don't have any idea about it
Is that Question Ask Forum?