How can i integrate an API on a website to display on discord bot?

I’m have been trying to integrate an API on https://map.lemoncloud.org/survival. I need a discord bot that will scan through all the claims (the green boxes) check if a player has been offline for more than 30 days and if so send me a DM. I have never worked with APIs before and any help would be very appreciated. The screenshot is of the bot a player has created. I would also like to note that i cannot find anything regarding this on google. Looking to create something like this.

How can i trigger a function on the actual tab comming from my poup.html extension manifest.json

Probably I’m having a misunderstanding about how to use the browser_action, but basically I need to trigger an action on the actual tab opened on the browser via the popup.html opened when I click my extension icon and inside of this html I have a button for this trigger.

This is my code below, what I’m doing wrong?

manifest.json

{
  "name": "Test",
  "description": "Test",
  "version": "1.0.0",
  "manifest_version": 2,
  "minimum_chrome_version": "46",
  
  "permissions": ["tabs", "<all_urls>"],
 
  "background":{
    "scripts":["script.js"]
  },
  "browser_action": {
    "default_title": "Test",
    "default_popup": "popup.html",  
    "default_icon": {
      "16": "/images/icon-16.png",
      "48": "/images/icon-48.png",
      "128": "/images/icon-128.png"
    }
  },
  
}

script.js

document.getElementById("myButton").addEventListener("click", test());
function test() {
  alert("Message")
}

popup.html

<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-    scale=1.0">
    <title>Document</title>
  </head>
<body>
  <h1>Ruiz Careca</h1>
  <button id="myButton"> Show password</button>

  <script type="text/javascript" src="./script.js" ></script>
</body>
</html>

Google Tag Manager – Custom Variable – Get Header text when click a link

I’m having an issue right now with getting the right element for a variable.

Here is what I want to accomplish

When a user click on a link from the sidebar, I want the following info :

  • Click text
  • Click URL
  • Click ID
  • Click Element
  • Click Classes
  • Page URl

At this moment I can have all but Click Classes which is empty “”

But I also want when I click the link or the button, I also want the title that is in the elementor container.

Image link : https://i.imgur.com/NoDv2wh.jpg

I already setup my TAG and Triggers

So I tried following some of the info I found one the forum, but clearly I have no idea how to accomplish that and I search a lot on Google without clear indications.

Here the code for my custom JS

function() {     
return {{Click Element}}.closest(".elementor-widget-container").find('h4').text();}

Right now, I just want to be able to create a custom variable to get the header text when I click on a button or a link.

Need help in flattening indeterminate deeply nested JSON Object in JavaScript

I have been trying to figure this out for a couple hours now, I think this has taken me too long and I gave up.. So I decided to ask for some helps here. This is just a sample data, the real data has indeterminate nesting so the solution needs to be dynamic.

I have this data structure:

{
  "data": {
    "children": [
      {
        "data": {
          "body": "3 and 4 are pretty much the answer",
          "replies": {
            "data": {
              "children": [
                {
                  "data": {
                    "body": "can be expressed in a nicer way",
                    "replies": {
                      "data": {
                        "children": [
                          {
                            "data": {
                              "body": "yes",
                              "replies": ""
                            }
                          }
                        ]
                      }
                    }
                  }
                },
                {
                  "data": {
                    "body": "can be expressed in second way",
                    "replies": ""
                  }
                }
              ]
            }
          }
        }
      }
    ]
  }
}

And I would like to flatten the object to be like this:

{
    "body": "3 and 4 are pretty much the answer",
    "replies": [
        {
            "body": "can be expressed in a nicer way",
            "replies": [
                "body": "yes",
                "replies": ""
            ]
        },
        {
            "body": "can be expressed in second way",
            "replies": ""
        }
    ]
}

Any help would be much appreciated, thank you so much in advance!

Calling useNavigation hook from TouchableOpacity inside a DrawerNavigator from react-navigation pkg throwing error, full source on question body

I’m learning react and react-native last 4 days because need build an mobile app and having the following problem when coding a react-native app:
After some research I found a way to embed a TouchableOpacity inside the top bar of DrawerNavigator, just after the hamburger button and it works giving me an alert.
The problem comes when I try to replace the alert with a call to useNavigation().navigate('Login'); from inside it onPress attribute, it throw the error below.
I want mirror the behavior of menu item on the TouchableOpacity doing the navigation.

 Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem., js engine: hermes
info Reloading app...

The full source follow as:

import * as React from 'react';
import { Button, Image, StyleSheet, Text, TouchableOpacity, View, Alert  } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import {
  createDrawerNavigator,
  DrawerContentScrollView,
  DrawerItemList,
} from '@react-navigation/drawer';
// https://reactnavigation.org/docs/use-navigation/
import { useNavigation } from '@react-navigation/native';

const getScreenCtx = content => {
  return (<View style={stl.boxCtx}>{content}</View>);
}

const Home = ({ navigation }) => {
  return ( getScreenCtx(<Text style={stl.boxDescr}>Home</Text>) );
}
const Login = ({ navigation }) => {
  return ( getScreenCtx(<Text style={stl.boxDescr}>Login</Text>) );
}
const Logout = ({ navigation }) => {
  return ( getScreenCtx(<Text style={stl.boxDescr}>Logout</Text>) );
}

const navToLogin = () => {
  useNavigation().navigate('Login');
}

const NestedTabBar = props => {
  return (
  <>
    <TouchableOpacity
      style={stl.itemNav}
      onPress={
        () => {
          //Alert.alert('NavigateToLogin');
          navToLogin();
        }
    } >
      <Text>[NavigateToLogin]</Text>
    </TouchableOpacity>
  </>
  );
}

const ContentTopWideHamburgBar = props => {
  return <NestedTabBar />;// <Text style={stl.hamburgBar}>ContentTopHamburgBar</Text>
}
const ContentColapsibleSideBarMenuHeader = props => {
  return <Text style={stl.sideMenuHeader}>SideBarMenuHeader</Text>
}
const ContentColapsibleSideBarMenuFooter = props => {
  return <Text style={stl.sideMenuFooter}>SideBarMenuFooter</Text>
}

const ContentColapsibleSideBarMenu = props => {
  return (
    <View style={stl.sideBarMenu}>
      <DrawerContentScrollView {...props}>
        <ContentColapsibleSideBarMenuHeader/>
        <DrawerItemList {...props} />
      </DrawerContentScrollView>
      <ContentColapsibleSideBarMenuFooter/>
    </View>
  );
}

const Drawer = createDrawerNavigator();

const ContentItensNavigationRouteMap = () => {
  return (
    <>
      <Drawer.Screen component={Home} name='Home' />
      <Drawer.Screen component={Login} name='Login' />
      <Drawer.Screen component={Logout} name='Logout' />
    </>
  );
}

const DrawerNavigator = () => {
  return (
    <Drawer.Navigator
        screenOptions={
          {
            headerStyle: { backgroundColor: 'magenta', },
            headerTintColor: 'white', // hamburg color
            headerTitleStyle: { fontWeight: 'bold', },
            headerTitle: (props) => <ContentTopWideHamburgBar {...props} />
          }
        }
        contentOptions={
          {
            activeTintColor: 'red',
            activeBackgroundColor: 'red',
            inactiveTintColor: 'red',
            inactiveBackgroundColor: 'red',
          }
        }
        drawerContent={props => <ContentColapsibleSideBarMenu {...props} />} >
          {ContentItensNavigationRouteMap()}
    </Drawer.Navigator>
  );
};

export default function ShellNavigator() {
  return (
    <NavigationContainer>
      <DrawerNavigator />
    </NavigationContainer>
  );
}

const stl = StyleSheet.create({
  boxDescr: {
    fontSize: 30,
    margin: 10,
    padding:10,
    backgroundColor: 'lightblue',
    color: 'red',
  },
  boxCtx:{
    display: 'flex',
    flex: 1,
    fontSize: 30,
    margin: 0,
    backgroundColor: 'yellow',
  },
  hamburgBar: {
    fontSize: 20,
    margin: 10,
    backgroundColor: 'pink',
  },
  sideMenuHeader: {
    fontSize: 20,
    margin: 10,
    backgroundColor: 'blueviolet',
  },
  sideMenuFooter: {
    fontSize: 20,
    margin: 10,
    backgroundColor: 'purple',
  },
  sideBarMenu: {
    flex: 1,
    fontSize: 20,
    margin: 10,
    backgroundColor: 'greenyellow',
  },
  itemNav: {
    fontSize: 40,
    padding: 10,
    backgroundColor: 'red',
  },
});

wavesurfer tag () is not work

I want to use wavesurfer.js and use the <wavesurfer> tag, but I do not know how and whatever I do, the sound does not load.

<wavesurfer
  data-url="http://127.0.0.1:8000/media/post/audio/4095c5f534c74f10951da8259772b549.mp3"
  data-plugins="minimap,timeline"
  data-minimap-height="30"
  data-minimap-wave-color="#ddd"
  data-minimap-progress-color="#999"
  data-timeline-font-size="13px"
  data-timeline-container="#timeline"
></wavesurfer>
<div id="timeline"></div>

where is the problem?

Browser sending request for already buffered video data

Problem

As the title says, I’m seeing an issue where the browser (when seeking through a video) is constantly making requests for ranges of bytes it should already have.

enter image description here

Code

I’ve provided a minimal code sample; to replicate the issue, whip around the current time control on the video and look at your network log.

window.onload = function() {

  var myVideo = document.getElementById('my-video');

  myVideo.addEventListener('progress', function() {
    var bufferedEnd = myVideo.buffered.end(myVideo.buffered.length - 1);
    var duration = myVideo.duration;
    if (duration > 0) {
      document.getElementById('buffered-amount').style.width = ((bufferedEnd / duration) * 100) + "%";
    }
  });

  myVideo.addEventListener('timeupdate', function() {
    var duration = myVideo.duration;
    if (duration > 0) {
      document.getElementById('progress-amount').style.width = ((myVideo.currentTime / duration) * 100) + "%";
    }
  });
}
.buffered {
  height: 20px;
  position: relative;
  background: #555;
  width: 300px;
}

#buffered-amount {
  display: block;
  height: 100%;
  background-color: #777;
  width: 0;
}

.progress {
  margin-top: -20px;
  height: 20px;
  position: relative;
  width: 300px;
}

#progress-amount {
  display: block;
  height: 100%;
  background-color: #595;
  width: 0;
}
<video id="my-video" controls preload="auto"><source src="https://media-dev.ozone.tech/media/e7ed8a40-cc10-4e8f-9ca4-f7ce2018e750/video_preview-1655242811.732922.mp4?Expires=1655683199&amp;Signature=GblI8GzddjxCP26Rqr0tfn1M1WzPrrdnKb5w7icjjFuughbV92Waz3tylFC3YZXU90u4wyD~VGeM5ThvbtbsGNf2YdkA0-z0xGdCMM0Uj9YpIbPi~SNccOjjCPXzCY~dYN4ANcdyN6~qlhTFammXuaE3-mfRceSeXXmDK76~wAa6VJLmPmKmrLNGYeULmd~XRGmGvxleT6LfFeAsmkSanue-AcV5amgARBeEVz5HHJMjAoy7OnnIWRsXJR2g6A7ZV9M77Szw-LGEzMVxspFak7pZj-BSAeTY~mUsXiMAfhINUcxiOf~dtJM8DBRaw3G5vGrWfueYtprcIbbRCHAI1Q__&amp;Key-Pair-Id=K16V0JZ9ZAOTC6" type="video/mp4"></video>
<div class="buffered">
  <span id="buffered-amount"></span>
</div>
<div class="progress">
  <span id="progress-amount"></span>
</div>

Question

Can someone explain why this is happening and how I can prevent it? Seems like this could potentially be a bug but since all the browsers are doing it, I wonder if it’s something on my end

Is there a way of sorting an array based on a field in another array before rendering it in React? [closed]

I have an array of users:

[
    {
        name: 'user1',
        _id: 'user1Id'
    },
    {
        name: 'user2',
        _id: 'user2Id'
    }
    {
        name: 'user3',
        _id: 'user3Id'
    }
]

And an array of chats, each containing two of the ‘users’:

[
    {
        latestMessage:
            {
                chat: 'chatId',
                content: 'some message'
            }
        users:
            {
                name: 'user2',
                _id: 'user2Id'
            },
            {
                name: 'user1',
                _id: 'user3Id'
            },
        updatedAt: 'date',
        _id: 'chatId'
    }
]

The first user in the array of chats will always be the same, while the second one will always be different.

I am currently rendering the ‘users’ with the map function, but what I would like to do is sort the users before they are rendered, so that they appear based on the date of the updatedAt field in the array of chats. So that the seconduser (index 1) in the most recently updated chat is displayed first, and then the next one and so on.

When the most recently updated ‘chat’ object changes I would also like to reflect this update by re-rendering the `users’. Is anyone aware of the best way to achieve this?

primeReact Props and dropdown options problem

im new in Node, JavaScript and React.
I must show a list of data inside a dropdown, then the selected one save it in the database.
The problem is how to display the list of data to select

In this way they capture the data

                        <div className="p-field p-col">
                        <label className="p-col-fixed" htmlFor="to">Columna final </label>
                        <div className="p-col">
                            <Dropdown id={'to'} appendTo={document.body} value={selectedStatusTo} options={props.statuses} onChange={(e) => setSelectedStatusTo(e.value)} optionLabel="name" placeholder="Seleccione Estado"/>
                        </div>
                    </div>

I understand that value is the selected value of the dropdown and that I must save later, but how do I pass a different array in Options

const arra = [{name:”hello0″},{name:”hello1″},{name:”hello2″},{name:”hello3″}];

            <div>
                <h5>Tipo de reparto</h5>
                <hr/>
                <div className="p-fluid p-formgrid p-grid">

                    <div className="p-field p-col">
                        <label className="p-col-fixed" htmlFor="from">Reparto</label>
                        <div className="p-col">
                        <Dropdown id={'type'} appendTo={document.body} value={selectedStrategy} options={arra} onChange={(e) => setStrategy(e.value)} optionLabel="name" placeholder="Seleccione Tipo Reparto"/>

                        </div>
                    </div>
                </div>
            </div>

Arranging one image on top of another in CSS

I’m making a solitaire game in HTML/CSS/JavaScript and I have it so that when you click a card and then another it moves the first card to the same position as the second with the y value shifter 20px. The problem is when I move the first card(king) to the second card(queen) the king is beneath the queen. I would like to make it so that whenever you move a card, that card is put on top.

Here’s the relevant CSS:

.card {
  height:100px;
  position:fixed;
} 

Here’s the relevant HTML:

<div style='position:relative;'>
  
    <img class = 'card' style = 'left:150px;' id = 'KD' onclick = 'move("KD")' src='Cards/Diamonds/K.png'>
  
    <img class='card' id = 'QD' src="Cards/Diamonds/Q.png" onclick = 'move("QD")' style=''>
  </div>

Here’s the relevant JavaScript:

var x1 = '';
var x2 = '';
var y1 = '';
var y2 = '';
var img1 = '';
function move(id){
  var id = document.getElementById(id);
  Pr('0');
  if (img1 == ''){
    Pr('1');
    img1 = id;
    Pr(img1);
    var box1 = id.getBoundingClientRect();
    x1 = box1.left + box1.width * 0.5;
    y1 = box1.top + box1.height * 0.5;
  } else if (img1 != ''){
    Pr('2');
    img2 = id;
    Pr(img2);
    var box2 = id.getBoundingClientRect();
    x2 = box2.left;
    y2 = box2.top+20;
    img1.style.cssText = 'left:'+x2+'px;top:'+y2+'px;';
    
  };
  
  Pr('x1 = '+x1+' | y1 = '+y1+' | x2 = '+x2+' | y2 = '+y2);
};



//Making 'console.print(...)' quicker to type

function Pr(str) {
  console.log(str)
};

Start

The Problem

Here’s the link to the site

many checkbox that hide and show div in another html page

je voudrais créer un système qui quand on appuie sur 2 checkbox cela cache/show une div dans une autre page html. For the moment I have only this code but it works only in one file

 $(function () {
     $('#test').hide();
     $('.tos').click(function () {
         var checks = $("#my-checkbox, #my-checkbox4, #my-checkbox6");
         if (checks.filter(':checked').length == 3) {
             $('#test').show();
         } else if (checks.filter(':checked').length == 0) {
             $('#test').hide();
         } else {
             $('#test').hide();
         }
     });
 });