How to filter and delete an item by using redux toolkit

When I click the delete button on each item, I want to remove the item with a filter. But I don’t know how to solve it correctly. I’m a bit confused at this point. hope someone can explain this. Thanks a lot.

cartSlice.js

const cartSlice = createSlice({
  name: 'cart',
  initialState:{
      products: [],
      quantity: 0,
      total: 0,
    },
  reducers: {
    deleteItem: (state, action) => {
    //filter right here
      state.products = action.payload.idItem;
      state.quantity -= 1;
      state.total -= action.payload.price * action.payload.quantity;
    },
  },
});

Cart.jsx

const Cart = (props) => {
  const dispatch = useDispatch();

  const cart = useSelector((state) => state.cart);
  const items = useSelector((state) => state.cart.products);

  const handleDeleteItem = (idItem, price, quantity) => {
    const filter = items.filter((item) => item.itemId !== idItem);
    console.log('idItem', idItem);
    console.log('filter', filter);
    dispatch(deleteItem({ idItem, price, quantity }));
  };

  return (
    <>
     {cart.products.map((product) => (
                      <tr className={styles.body} key={product._id}>
                        <td className={styles.column}>
                          <span className={styles.quantity}>{product.quantity}</span>
                        </td>
                        <td className={styles.column}>
                          <span className={styles.total}>${product.price * product.quantity}</span>
                        </td>
                        <td className={styles.column}>
                          <button
                            onClick={() => handleDeleteItem(product.idItem, product.price, product.quantity)}
                            className={styles.deleteItem}
                          >
                            Delete
                          </button>
                        </td>
                      </tr>
                    ))}               
    </>
  );
};

export default Cart;

Button Image

getMessaging failing – Uncaught SyntaxError: Cannot use import statement outside a module (at firebase-messaging-sw.js:1:1)

I’m trying to integrate firebase messaging into my NextJS web app but getting errors that potentially look like they’re coming from the serverside. To get registrations working in _app.tsx I do the following:

  useEffect(() => {
    if ("serviceWorker" in navigator) {
      window.addEventListener("load", function () {
        const config = process.env.NEXT_PUBLIC_FIREBASE;
        navigator.serviceWorker.register("/firebase-messaging-sw.js?firebaseConfig=" + Buffer.from(config).toString('base64'), {
          type: 'module'
        }).then(
          function (registration) {
            console.log("Service Worker registration successful with scope: ", registration.scope);
          },
          function (err) {
            console.log("Service Worker registration failed: ", err);
          }
        );
      });
    }
  }, [])

Where NEXT_PUBLIC_FIREBASE is the firebase config object.

Then in public/firebase-messaging-sw.js I have this:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-app.js";
import { getMessaging } from "https://www.gstatic.com/firebasejs/9.8.1/firebase-messaging.js";

const swScriptUrl = new URL(self.location);

const base64Config = swScriptUrl.searchParams.get('firebaseConfig')
let decoded = atob(base64Config);

const firebaseConfig = JSON.parse(decoded);
const app = initializeApp(firebaseConfig);


// Retrieve an instance of Firebase Messaging so that it can handle background
const messaging = getMessaging(app);

When getMessaging is called I get this error:

Uncaught SyntaxError: Cannot use import statement outside a module (at firebase-messaging-sw.js:1:1)
index.esm2017.js?f614:823 Uncaught (in promise) FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:3000/firebase-cloud-messaging-push-scope') with script ('http://localhost:3000/firebase-messaging-sw.js'): ServiceWorker script evaluation failed (messaging/failed-service-worker-registration).
    at registerDefaultSw (index.esm2017.js?f614:823:1)
    at async updateSwReg (index.esm2017.js?f614:847:1)
    at async getToken$1 (index.esm2017.js?f614:910:1)
    at async FirebaseMessagingWeb.getToken (web.js?00d2:24:1)
registerDefaultSw @ index.esm2017.js?f614:823
Promise.then (async)
asyncGeneratorStep @ ios-notification.ts?89f7:2
_next @ ios-notification.ts?89f7:2
eval @ ios-notification.ts?89f7:2
eval @ ios-notification.ts?89f7:2
addListeners @ ios-notification.ts?89f7:4
eval @ notification-context.tsx?dccb:38
Promise.then (async)
registerForNotifications @ notification-context.tsx?dccb:37
registerForNotifications @ notification-context.tsx?dccb:62
onClick @ profile-box.tsx?a1b7:280
callCallback @ react-dom.development.js?ac89:4161
invokeGuardedCallbackDev @ react-dom.development.js?ac89:4210
invokeGuardedCallback @ react-dom.development.js?ac89:4274
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js?ac89:4288
executeDispatch @ react-dom.development.js?ac89:9038
processDispatchQueueItemsInOrder @ react-dom.development.js?ac89:9070
processDispatchQueue @ react-dom.development.js?ac89:9083
dispatchEventsForPlugins @ react-dom.development.js?ac89:9094
eval @ react-dom.development.js?ac89:9285
batchedUpdates$1 @ react-dom.development.js?ac89:26096
batchedUpdates @ react-dom.development.js?ac89:3988
dispatchEventForPluginEventSystem @ react-dom.development.js?ac89:9284
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js?ac89:6462
dispatchEvent @ react-dom.development.js?ac89:6454
dispatchDiscreteEvent @ react-dom.development.js?ac89:6427
firebase-messaging-sw.js:1 Uncaught SyntaxError: Cannot use import statement outside a module (at firebase-messaging-sw.js:1:1)

I’ve checked the config object and it definitely is correct and making it to the service worker (also tried just copying the config in to no avail).

Have tried getting this to work both locally and on a https server to no avail, I’ve also tried a none module import which produced the same error.

Reassign a variable with a random number upon meeting condition (vanilla Javascript)

I would like to know how to generate a new random number once the condition of the if statement is met. Once the length of the array reaches 3, reassign the “randomNumber” variable a new number. As of now I don’t see any changes when the randomNumber variable is logged to the console and the condition is met, the number doesn’t change without refreshing the page.

let randomNumber = Math.floor(Math.random() * 100);

console.log(randomNumber);

const numberArr = [];

const form1 = document.getElementById("form1");

if (numberArr.length === 3) {
        arr.splice(0, 3);
        randomNumber = Math.floor(Math.random() * 100);
};

form1.addEventListener("submit", e => {
    const values = document.getElementsByName("number")[0].value;
    numberArr.push(values);
    e.preventDefault();
    form1.reset();
});
          <form id="form1">

                <div class="row w-100 d-flex justify-content-between div1">

                    <div class="col-12 d-flex justify-content-center">
                            <input type="number" name="number" id="number" min="1" max="100">
                    </div>

                    <div class="col-12 d-flex justify-content-center">
                        <button type="submit" form="form1" id="sub1">Submit</button>
                    </div>

                </div>

        </form>

Stackoverflow-error when executing a POST with Angular HttpClient instead of VanillaJS fetch()

Consider a Java Spring Boot backend with two entities: Client and ClientDetails:

Client:

@Entity
@Table(name = "clients")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Client{

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @Column(name = "first_name", nullable = false)
  private String firstName;
  @Column(name = "last_name", nullable = false)
  private String lastName;

  @OneToOne(mappedBy = "client", cascade = CascadeType.ALL)
  @JsonBackReference(value = "client-details")
  private ClientDetails clientDetails;
}

Client-Details:

@Entity
@Table(name = "client_details")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ClientDetails {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @Column(name = "e_mail")
  private String eMail;
  @Column(name = "phone")
  private String phone;

  @OneToOne(cascade = CascadeType.ALL)
  @JoinColumn(name = "client_id")
  @JsonManagedReference(value = "client-details")
  private Client client;
}

In my frontend, I want to execute a POST request. For this purpose, I am reading in a form using the FormData API. The result is a JSON looking like this:

{eMail: "[email protected]", phone: "1234-5678910", client: {firstName: "myFirstName", lastName: "myLastName"}}

In my backend, I have added a controller for POST requests.

I used to send the POST request using Vanilla JS and the fetch method. Everything used to work fine back then. Now, I have switched to Angular. I am using the HTTPClient to send the POST request now:

I have created a CRUD-service with the following method:

  addClient(clientDetails: any): Observable<any> {
    return this.httpClient.post<any>(this.URL, JSON.stringify(clientDetails), this.httpOptions);
  }

Upon clicking a button, I subscribe to this method and the POST request is executed:

  onButtonClick() {
    this.clientDetailsCrudService.addClient(this.readFormData()).subscribe((returnValue) => console.log(returnValue));
  }

The addClient() method is passed the correct JSON, I have verified this. However, it seems that my backend is having troubles with the JsonBackReference and JsonManagedReference variables, as I am running into a stackoverflow error, which seems to be related to some toString method:

at com.company.example.entity.Client.toString(Client.java:20)

So my question really is: Is there a difference between the way the fetch() method and the HttpClient.post() method are executing a POST request? Because the exact same backend used to work allright with fetch(). Does anyone have a suggestion as on how to solve this problem?

visibility hidden after playing animation

I’m trying to add effects on modal. over here

I want to make like this:

  • When modal--show class added, visibility set to visible and opacity continues to grow 0% to 100%.
  • When modal--show class removed, opacity continues to decrease 100% to 0%, and after then, visibility set to hidden.

Showing modal animation works well, but hiding modal animation doesn’t. When hiding animation plays, visibility becomes hidden immediately when animation starts.

How to set visibility: hidden after opacity: 0% with CSS or pure JS?

Error: Cannot find module ‘react-dom/server.browser’

I have these dependencies in package.json:

  "dependencies": {
    ...
    "@builder.io/partytown": "^0.5.4",
    "@mantine/core": "^4.2.5",
    "@mantine/dates": "^4.2.5",
    "@mantine/dropzone": "^4.2.5",
    "@mantine/form": "^4.2.5",
    "@mantine/hooks": "^4.2.5",
    "@mantine/modals": "^4.2.5",
    "@mantine/next": "^4.2.5",
    "@mantine/notifications": "^4.2.5",
    "@mantine/prism": "^4.2.5",
    "@mantine/rte": "^4.2.5",
    "@mantine/spotlight": "^4.2.5",
    "dayjs": "^1.11.2",
    "next": "12.1.6",
    "next-seo": "^5.4.0",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-icons": "^4.3.1",
    "react-query": "^3.39.0",
    "zod": "^3.16.0",
    ...
  },

And when install them with pnpm install using [email protected], it throws error:

$ pnpm install
Scope: all 2 workspace projects
apps/web                                 |  WARN  deprecated [email protected]
Packages: +792
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are cloned from the content-addressable store to the virtual store.
  Content-addressable store is at: /home/mymachine/.local/share/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 814, reused 791, downloaded 0, added 792, done
. prepare$ husky install
│ husky - Git hooks installed
└─ Done in 179ms
apps/web postinstall$ pnpx next telemetry disable
│ ../..                                    | Progress: resolved 1, reused 0, downloaded 0, added 0
│ ../..                                    | Progress: resolved 20, reused 9, downloaded 0, added 0
│ ../..                                    |  +10 -783 +--------------------------
│  WARN  Issues with peer dependencies found
│ ../../.local/share/pnpm/store/v3/tmp/dlx-32135
│ └─┬ next
│   ├── ✕ missing peer react@"^17.0.2 || ^18.0.0-0"
│   ├── ✕ missing peer react-dom@"^17.0.2 || ^18.0.0-0"
│   └─┬ styled-jsx
│     └── ✕ missing peer react@">= 16.8.0 || 17.x.x || ^18.0.0-0"
│ Peer dependencies that should be installed:
│   react-dom@"^17.0.2 || ^18.0.0-0"
│   react@">=17.0.2 <18.0.0 || >=18.0.0-0 <19.0.0"
│ ../..                                    | Progress: resolved 20, reused 10, downloaded 0, added 2, do
│ The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'pack
│ The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your '
│ node:internal/modules/cjs/loader:942
│   throw err;
│   ^
│ Error: Cannot find module 'react-dom/server.browser'
│ Require stack:
│ - /home/mymachine/myfolder/myproject/node_modules/.pnpm/[email protected]/node_modules/next/dist/bin/next
│     at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
│     at Module._load (node:internal/modules/cjs/loader:780:27)
│     at Module.require (node:internal/modules/cjs/loader:1005:19)
│     at require (node:internal/modules/cjs/helpers:102:18)
│     at Object.<anonymous> (/home/mymachine/myfolder/myproject/node_modules/.pnpm/[email protected]/node_modules/next/d
│     at Module._compile (node:internal/modules/cjs/loader:1105:14)
│     at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
│     at Module.load (node:internal/modules/cjs/loader:981:32)
│     at Module._load (node:internal/modules/cjs/loader:827:12)
│     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
│   code: 'MODULE_NOT_FOUND',
│   requireStack: [
│     '/home/mymachine/myfolder/myproject/node_modules/.pnpm/[email protected]/node_modules/next/dist/bin/next'
│   ]
│ }
│ Node.js v18.1.0
│  ERROR  Command failed with exit code 1: /home/mymachine/.local/share/pnpm/store/v3/tmp/dlx-32135/node_modul
└─ Failed in 3.3s
 ELIFECYCLE  Command failed with exit code 1.

I tried creating a new next-typescript template project and it installed fine.

$ pnpm install
Lockfile is up-to-date, resolution step is skipped
Packages: +228
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are cloned from the content-addressable store to the virtual store.
  Content-addressable store is at: /home/mymachine/.local/share/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 228, reused 228, downloaded 0, added 228, done

dependencies:
+ next 12.1.6
+ react 18.1.0
+ react-dom 18.1.0

devDependencies:
+ @types/node 17.0.33
+ @types/react 18.0.9
+ @types/react-dom 18.0.4
+ eslint 8.15.0
+ eslint-config-next 12.1.6
+ typescript 4.6.4

Please help me, what I am doing wrong?

How can I display a data from firebase in a mapbox marker?

So I am working on a project that parking lot owners enters a data about their parking lots (Capacity,price)

Here is the user data from firebase realtime database

And I am using mapbox to interact with the user. So recently I added some locations and popup texts like this:
Parking lot popups

How can I implement a code to add the capacity and price info in my database to the related parking lot in map.

My location markers below:

//Adding markers
const marker1 = L.marker([36.888840095155494, 30.70452564170324]).addTo(mymap);
//Adding pop-up message
marker1.bindPopup('VIAPARK OTOPARK&YIKAMA');


//Adding markers
const marker2 = L.marker([36.8863901771444, 30.7104513107456]).addTo(mymap);
//Adding pop-up message
marker2.bindPopup('MEKANIK KATLI OTOPARK');


//Adding markers
const marker3 = L.marker([36.88717964482887, 30.695473855822975]).addTo(mymap);
//Adding pop-up message
marker3.bindPopup('GUVEN OTOPARK');

Config.get() fetching default.json value for the environment variable after setting the variable value in powershell

In index.js I want to get the value of an environment variable. But I am not able to read custom-environment-variable.json file, instead I am getting the value of the variable from default.json

index.js

const config = require("config");
const mongoose = require('mongoose');
const genres = require('./routes/genres');
const customers = require('./routes/customers');
const rentals = require('./routes/rentals');
const movies = require('./routes/movies');
const users = require('./routes/users');
const auth = require('./routes/auth');
const express = require('express');
const { exist } = require('joi/lib/types/lazy');
const app = express();

if(!config.get('jwtPrivateKey1')){
  console.error("FATAL ERROR: jwtPrivateKey1 does not have a value");
  process.exit(1);
}


mongoose.connect("mongodb://localhost/vidly")
  .then(console.log("Connected to Vidly DB..."));

app.use(express.json());
app.use('/api/genres', genres);
app.use('/api/customers', customers);
app.use("/api/movies",movies);
app.use("/api/rentals",rentals);
app.use("/api/users",users);
app.use("/api/auth",auth);

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));

default.json

{
    "jwtPrivateKey1" : ""
}

custom-environment-variables.json

{
    "jwtPrivateKey1" :"vidly_jwtPrivateKey"
}

I have set the value of this environment variable using command in powershell also but still config.get() cannot show the value of this variable.

command for setting the environment variable

$env:jwtPrivateKey1 = 'pvt_key'

output:

**PS C:UsersshivaDocumentsnodejsvidly> $env:jwtPrivateKey**
pvt_key
**PS C:UsersshivaDocumentsnodejsvidly> node index.js**     
FATAL ERROR: jwtPrivateKey1 does not have a value

How can I set it so that the player can type out their name in my blackjack game? [closed]

I want to have it so the value of the input text goes to the p tag right below. I created input text and button tag within a form tag in my html and added them to my javascript using document.getElementById.

let chips = "$" + 5000 

let cards = []
let sum = 0
let hasBlackJack = false 
let isAlive = false
let message = ""
let messageEl = document.getElementById("message-el")
let sumEl = document.getElementById("sum-el")
let cardsEl = document.getElementById("cards-el")
let chipsEl = document.getElementById("chips-el")
const newGameBtn = document.getElementById("newgame-btn")

let formEL = document.getElementById("form-el")
let playerEl = document.getElementById("player-el")

chipsEl.textContent = chips

function getRandomCard() {
    let randomNumber = Math.floor (Math.random() * 13) + 1 
if (randomNumber > 10) {
    return 10
} else if (randomNumber === 1) {
    return 11
} else {
    return randomNumber
}
}

function startGame() {
    isAlive = true
    let firstCard = getRandomCard()
    let secondCard = getRandomCard()
        cards = [firstCard, secondCard]
        sum = firstCard + secondCard
    renderGame()
}

// beginning 2 cards where not showing up at first because I was using let befire cards and sum

function renderGame() {

    cardsEl.textContent = "Cards: " 
for (i = 0; i < cards.length; i++) {
    cardsEl.textContent += cards[i] + " "
}

sumEl.textContent = "Sum: " + sum   

    if (sum <= 20) {
    message = "Do you want to draw a new card?"
    isAlive = true
    } else if (sum === 21) {
    message = "Wohoo! You've got Blackjack!"
    isAlive = true
    } else if (sum > 21) {
    message = "You're out of the game!"
    isAlive = false
    }   

messageEl.textContent = message

}

function newCard() {
    if (isAlive === true && hasBlackJack === false){
    let card = getRandomCard()
    cards.push(card)
    sum += card
    renderGame()
}
}

newGameBtn.addEventListener("click", function() {
    location.reload()
})


function enterPlayer() {
    formEL = playerEl.textContent
}
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="Bj.css">
</head>
<body>
    <div>
    <h1>Blackjack<h1>
    </div>
        <p id="message-el">Want to play a round?</p>
        <p id="cards-el">Cards:</p>
        <p id="sum-el">Sum:</p>
        <button onclick="startGame()">START GAME</button>
        <button onclick="newCard()">NEW CARD</button>
        <br>
        <button id="newgame-btn">NEW GAME</button>
        <br>
            <form id="form-el">
                <input type="text" placeholder="Player name"> 
                <button onclick="enterPlayer()">Enter</button>
            </form>
        <p id="playername-el"></p>
        <p id = "chips-el"></p>
    <script src="Bj.js"></script>
</body>
</html>

/* It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
*/

Bootstrap Upgrade Error from Version 4 onwards (V3.37 Initial version)

Good Day everyone, I am currently trying to upgrade my Bootstrap version from version 3.3.7 to version 4 and subsequently version 5. I am able to upgrade to version 4 with very minor CSS changes on my website. However, when I try to upgrade to version 4.1.3. My index.html does not work, it does not load the main page of my project. And this error only occurs on the index.html page. And there is no error or whatsoever in my dev tool. It just doesn’t load anything.

Below is the index.html code with Bootstrap 4 (which works), the other components that are in the index.html does not require Bootstrap or Jquery, I am not sure what is the possible reason for this error; I have looked through the patch notice/changes and could not find anything different. Am I missing something?

<!doctype html>
<html lang="en"> 
<head>
<title>Project</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap 4 CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<link rel="stylesheet" href="./lib/calcite-bootstrap/css/calcite-bootstrap.css">
<link rel="stylesheet" href="./arcgis_js_api/library/3.25/3.25/esri/themes/calcite/dijit/calcite.css">
<link rel="stylesheet" href="./arcgis_js_api/library/3.25/3.25/esri/themes/calcite/esri/esri.css">
<link rel="stylesheet" href="./library/3.25/3.25/esri/dijit/metadata/css/gxe.css"/>
<link rel="stylesheet" href="./library/3.25/3.25/esri/dijit/metadata/css/gxe-calcite.css"/>
<link rel="stylesheet" href="./app/style/main.css">
<link rel="stylesheet" href="./lib/typeahead.css">
<link rel="stylesheet" href="./lib/bootoast.css">
<link rel="stylesheet" href="./custom/custom.css">
</head>

<body class="calcite">
<div id="custom-banner" class="custom-banner"></div>
<div id="app"></div>
<div id="app-loading-node" class="g-app-loading">
    <div class="progress">
      <div class="progress-bar progress-bar-striped active" 
        role="progressbar" style="width:100%">Loading...</div>
    </div>
</div>

<script type="text/javascript">
  var dojoConfig = {
    locale: "en",
    async: true,
    parseOnLoad: true,
    packages: [
      {
        name: 'app',
        location: location.pathname.replace(//[^/]*$/, '') + '/app',
      }
    ]
  };
</script>

<!--Scripts required for Bootstrap 4-->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<!--Old Versions-->
<!-- <script src="./lib/jquery-3.2.1.min.js"></script> -->
<!-- <script src="./lib/bootstrap-3.3.7.min.js"></script> -->

<!--Other Scripts-->
<script src="./lib/d3-3.5.5.js"></script>
<script src="./lib/c3.min.js"></script>
<script src="./lib/typeahead.js"></script>
<script src="./lib/bootoast.js"></script>
<script src="./arcgis_js_api/library/3.25/3.25/init.js"></script>
<script src="./arcgis_js_api/library/4.16/init.js"></script>

<script>
require(["app"],function() {
  require(["dojo/ready", "app/context/AppContext", "app/context/AppStarter"],
  function(ready, AppContext, AppStarter) {
    window.AppContext = new AppContext();
    ready(function() {
      esri.config.defaults.io.proxyUrl = "viewer/proxy.jsp";
      (new AppStarter()).startupApp();
    });
  });
});
</script>
</body>
</html>

how to assign each block an Id to differentiate between blocks inside a canvas and fetch data according to that id

Hello Fellow Developers,

I’m new to react and canvas api, I want to create 10k blocks(square) of particular dimensions and each block is different from one another by ID. I have created 10k blocks
of 100 * 100 rows and columns and each box is 10 * 10.

  1. Now what I want is to assign an ID to each box to identify that particular box that I select onClick and read data from smart contract

  2. Once the ID is selected I want to able to select multiple boxes using input fields, eg, I selected box# 4 and in input fields I have to select width and height, so when I select width 5 block numbers 5 6 7 8 9 in x-direction will also get selected, similarly if I select height 2 then including 4 one more box is selected in y-direction.

Now these selection can only happen if that box is available to select if its value is false, no-one can select that box no matter the height and width.

I don’t know how to assign an ID please anyone can help me in this, It’ll be great help

Reference Website to understand my points: https://milliondollartokenpage.com/

Code is attached that I've done so far:

https://jsfiddle.net/ahmedzafar/d3twnfe1/1/

Thanks in advance:)

basic Tab navigation is not working in html

Almost I done but it isn’t working. I think there is a small mistake. please correct my mistake.. thank you in advance

This is my html I did

<div class="nav">
            <button class="navlinks" onclick="socialMedia(media, 'Twitter')">Twitter</button>
            <button class="navlinks" onclick="socialMedia(media, 'Facebook')">Facebook</button>
            <button class="navlinks" onclick="socialMedia(media, 'Instagram')">Instagram</button>
        </div>

        <div id="Twitter" class="navcontent">
            <p>
                Look no more if you are after a venue to host thousands of delegates for highly 
                exclusive conferences and exhibitions. At Hamdan Sports Complex, you are given the 
                flexibility to customize the venue according to your space and event requirements.
            </p>
            <p>
                Look no more if you are after a venue to host thousands of delegates for highly 
                exclusive conferences and exhibitions. At Hamdan Sports Complex, you are given the 
                flexibility to customize the venue according to your space and event requirements.
            </p>
            <div class="sub">
                <a>#lorem</a>
                <a>#ipsum</a>
                <a>#lorem</a>
            </div>
        </div>

here I am showing only one navcontent. I alreay have Facebook and Instagram contents in my page.. that is not problem here

This is my css I did

.nav {
        overflow: hidden;
        margin-top: 50px;

        button{
            background-color: inherit;
            float: left;
            border: none;
            outline: none;
            cursor: pointer;
            padding: 15px 0px;
            height: 50px;
            width: 110px;
            transition: 0.3s;
            font-size: 17px;
            color: #360b9a;
            transition: .5s all;

            &:hover {
                font-weight: 700;
            }
        }

        .active {
            background-color: #ccc;
        }

    }
    .navcontent {
        display: none;
        padding: 6px 12px;
        border: 1px solid #ccc;
        border-top: none;
    }

and this is my JS I did

function socialMedia(media, mediaName) {
    var i, navcontent, navlinks;
    tabcontent = document.getElementsByClassName("navcontent");
    for (i = 0; i < navcontent.length; i++) {
        navcontent[i].style.display = "none";
    }
    navlinks = document.getElementsByClassName("navlinks");
    for (i = 0; i < navlinks.length; i++) {
        navlinks[i].className = navlinks[i].className.replace(" active", "");
    }
    document.getElementById(mediaName).style.display = "block";
    media.currentTarget.className += " active";
}

please correct my mistake.. thank you in advance

Rewriting a Regular Expression for use in JavaScript

How can this regular expression be rewritten for use in JavaScript? From an earlier post I learnt that it’s got several things that aren’t supported by JavaScript.

What it does is matches content between { & } and strips new lines inside them.

I plan on using this in Atom’s Find and Replace

preg_replace('/[rnt]+(?=[^}{]*(?:({(?:[^}{]++|(?1))*})[^}{]*)*})/m','',$x);

Example of what it does:

Before

.selector {
  border-radius: 2px;
  cursor: default;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
}

After

.selector {border-radius: 2px;cursor: default;font-size: 11px;font-weight: bold;text-align: center;white-space: nowrap;}