Choose dropdown list item in selenium webdriver using javascript

I’ve been struggling to choose dropdown list item in selenium webdriver using javascript.
I’m tasked to open https://pastebin.com/ then choose "10 Minutes" from dropdown list using selenium webdriver javascript.
I’ve achieved to open the dropdown list with the following method:

await driver.findElement(By.id(`postform-expiration`)).click()

Tried to select dropdown list item both li value and id:

await dropdown.findElement(By.css(`li[value="10 Minutes"]`)).click()
// and
await driver.findElement(By.css(`//*[@id="select2-postform-expiration-result-b5nq-10M"]`)).click()

But none of them could choose the dropdown list item.

The structure of the dropdown list is as follows:

<div class="col-sm-9 field-wrapper">
<select id="postform-expiration" class="form-control select2-hidden-accessible" name="PostForm[expiration]" data-s2-options="s2options_7ebc6538" data-krajee-select2="select2_a09a7382" style="width: 1px; height: 1px; visibility: hidden;" data-select2-id="postform-expiration" tabindex="-1" aria-hidden="true">
<option value="N" data-select2-id="4">Never</option>
<option value="B" data-select2-id="11">Burn after read</option>
<option value="10M" data-select2-id="12">10 Minutes</option>
<option value="1H" data-select2-id="13">1 Hour</option>
<option value="1D" data-select2-id="14">1 Day</option>
<option value="1W" data-select2-id="15">1 Week</option>
<option value="2W" data-select2-id="16">2 Weeks</option>
<option value="1M" data-select2-id="17">1 Month</option>
<option value="6M" data-select2-id="18">6 Months</option>
<option value="1Y" data-select2-id="19">1 Year</option>
</select><span class="select2 select2-container select2-container--default select2-container--open select2-container--above select2-container--focus" dir="ltr" data-select2-id="3" style="width: 100%;"><span class="selection"><span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="true" tabindex="0" aria-disabled="false" aria-labelledby="select2-postform-expiration-container" aria-owns="select2-postform-expiration-results" aria-activedescendant="select2-postform-expiration-result-e4wf-1D"><span class="select2-selection__rendered" id="select2-postform-expiration-container" role="textbox" aria-readonly="true" title="Never">Never</span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>

</div>

I appreciate your help. Thanks in advance!

change text input value based on check box, multiple fields with same class name

I have many checkboxes and below each there is a hidden date field.
I need to show the div with the date field and select different date.
in the begging I need to add 30 days from today when the checkbox is checked by deafutl, then the user can change the date.
When I click to first choice and change the date is ok….but when I click to another the first date field takes the default value. Any sggestions?

$('.chkPages').change(function () {
        
        if (this.checked)
        {
            var dateStr = new Date();
            dateStr.setDate(dateStr.getDate() + 30)
            dateStr = dateStr.getDate() + "/" + (dateStr.getMonth() + 1) + "/" + 
            dateStr.getFullYear();
           
            $(this).closest('div').next('.extrafields').fadeIn('slow');
           
            $(".DurationDate").val(dateStr);
        }

        else {
            dateStr = "";
            $(this).closest('div').next('.extrafields').fadeOut('slow');
            $(".DurationDate").val(dateStr);
        }

Why function is not returning the value [closed]

var y=0;
var x=0;
function randomNumber1(){
  x=Math.floor((Math.random())*6)+1;
  console.log(x);
  return x;
}
function randomNumber2(){
  y=Math.floor((Math.random())*6)+1;
console.log(y);
  return y;
}
randomNumber1();
randomNumber2();
console.log(randomNumber1);
console.log(randomNumber2);

Im not getting the returned value in the function. the function is displaying all the codes as its value.

function randomNumber1() and randomNumber2() are not being returned.

Dynamic PageNumbers for Flipbook using turn.js

So, I was given a task of creating a Custom Flipbook, where using images in div tags, I was successful in creating one. Users could turn pages using prev/next buttons or flipping through them by the corners like shown for other Flipbooks.

My concern is Displaying PageNumbers. Changing pages through the buttons, pages change dynamically but when flipping through turn.js the page number does not update.

I am providing the snippet of the code that I have used. Any kind of help and guidance is appreciated !!

<!DOCTYPE html>

<head>
  <title>Flipbook Demo</title>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
  <script type="text/javascript" src="turn.min.js"></script>
</head>
<style>
  body{
    background-color: #313131;
  }

  #flipbook {
    margin-top: 1.5%;
    margin-left: 6%;
    width: 1130px;
    height: 800px;
    position: relative;
    overflow: hidden;
  }

  #nav_controls{
      margin: 1.5%;
      margin-left: 44%;
  }
  
</style>
    <body> 
        <h1 style="color: white; margin-left: 43%">FITI5 WHITEPAPER</h1>
        <div id="flipbook">
            <!-- Include Pages into div that you want to include -->
        </div>
        
        <div id="nav_controls">
            <button id="startdoc"><-</button>
            <button id="prev_page"> PREV </button>
            <span id="pgnos" style="margin-left: 2%; color: white;">1</span>   
            <button id="next_page" style="margin-left: 2%;"> NEXT </button>
            <button id="enddoc">-></button>
            <!--
            <button id="zoom-in">+</button>
            <buton id="zoom-out">-</button>-->
        </div>

        <script type="text/javascript">
            const startButton = document.querySelector("#startdoc");
            const endButton = document.querySelector("#enddoc");
            const prevButton = document.querySelector("#prev_page");
            const nextButton = document.querySelector("#next_page");
            const showPG = document.querySelector("#pgnos");
            
            //magnify = document.querySelector("#zoom-in");
            //minify = document.querySelector("#zoom-out");

            /*
            magnify.addEventListener('click', function() {
                $("#flipbook").turn("zoom", 1.1, 1);
            });
            minify.addEventListener('click', function() {
                $("#flipbook").turn("zoom", 1, 1.1);
            })  
            */
            
            $("#flipbook").turn({
                gradients: true,
                page: 1,
                duration: 2000
            });


            const first_page = $("#flipbook").turn("page");
            const last_page = $("#flipbook").turn("pages");    
            
            
            startButton.addEventListener('click', function() {
                $("#flipbook").turn("page", first_page);
                showPG.innerHTML = first_page;
            });

            endButton.addEventListener('click', function() {
                $('#flipbook').turn("page", last_page);
                showPG.innerHTML = last_page;
            });

            nextButton.addEventListener('click', function() {
                $("#flipbook").turn("next");
                showPG.innerHTML = $("#flipbook").turn("page");
            });

            prevButton.addEventListener('click', function() {
                $("#flipbook").turn("previous");
                showPG.innerHTML = $("#flipbook").turn("page");             
            });


            if ( (($("#flipbook").turn("page") == first_page)) ) {
                $(nextButton).click(function() {
                    $("#flipbook").animate({left: "275"});
                });

                $(endButton).click(function() {
                    $("#flipbook").animate({left: "565"});
                });

                $(prevButton).click(function() {
                    $("#flipbook").animate({left: "275"});
                });

                $(startButton).click(function() {
                    $("#flipbook").animate({left: "0"});
                });
            } 


            if ( (($("#flipbook").turn("page") == last_page)) ) {
                $(prevButton).click(function() {
                    $("#flipbook").animate({left: "300"});
                });   
            }

      
        </script>
    </body>
</html>

What is a fast sort algorithm for a very, very long array of objects in JavaScript?

I have been trying to sort an array with 2000 elements in ReactJS using JavaScript. The array looks like this:

data = [

         {
    index: 0,
    id: "404449",
    product_name: "ette",
    brand_name: "Dyrberg/Kern",
    base_price: "55.000",
    actual_price: "55.000",
    filename:
      "http://images.booztx.com/dyrbergkern/400x523/329679_ette_sg_crystal.jpg",
  },
  {
    index: 1,
    id: "414661",
    product_name: "braided mobile chain",
    brand_name: "Octopus",
    base_price: "44.900",
    actual_price: "44.900",
    filename: "http://images.booztx.com/octopus/400x523/SC09-750MU.jpg",
  },

       ]

I tried sorting it by base_price with Array.sort( ) of JavaScript, like this:

 data.sort((a, b) => {
     
      return parseFloat(a.base_price) - parseFloat(b.base_price);
    });

but since the array is very long, it has 2000 elements it takes a very long time to sort. It takes about 4 minutes. Does anyone have any solutions?

Treemap chart.js text wrap

In my code below, I am able to draw a Treemap and also display the tag in each tree cell. But the text is overflowing the tile if it’s a long word

I need to ensure the word stays in the tile even If it means putting …. after certain characters. How can I achieve them? Please have a look at the version of chart.js and Treemap I am using before providing the solution. Thanks a lot 🙂


  var topTags = [
  {tag:'android',num:42657},{tag:'reactjs',num:38844},{tag:'php',num:34381},{tag:'sql',num:29996},
];

var canvas = document.getElementById("treemap");
var ctx = canvas.getContext("2d");
var chart = window.chart = new Chart(ctx, {
  type: "treemap",
  data: {
    datasets: [{
      tree: topTags,
      key: "num",
      groups: ['tag'],
      spacing: 0.5,
      borderWidth: 1.5,
      fontColor: "black",
      borderColor: "grey"
    }]
  },
  options: {
    maintainAspectRatio: false,
    legend: { display: false },
    tooltips: { enabled: false }
  }
});

CHART.JS AND TREEMAP VERSION :

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

nativescript-firebase issue to get push token

I implemented the nativescript-firebase (https://github.com/EddyVerbruggen/nativescript-plugin-firebase) plugin in my mobile app. It used to work fine but since I updated to the 11.1.3 version I cannot get the push token. I tried to get back to the 10.6.3 version but it says it is not available anymore when I execute npm install.

Here is what I do in my main.js

import { messaging } from "@nativescript/firebase/messaging";
import { firebase } from "@nativescript/firebase"
firebase.init({
    onMessageReceivedCallback: function(message) {
      //do stuff
    }
}).then(function () {
    messaging.getCurrentPushToken().then(token => {
        console.log(token)
    }).catch(e => {
    console.log(e);
  })
},function (error) {
  console.log("firebase.init error: " + error);
});

This does not log the token but goes into the catch and logs this
Uncomment firebase-messaging in the plugin's include.gradle first

Here is my package.json

{
  "name": "*****",
  "main": "./src/main.js",
  "version": "4.4.0",
  "description": "A native application built with NativeScript-Vue",
  "author": "*****",
  "license": "Propriétaire",
  "dependencies": {
    "@carployee/openapp": "^1.0.1",
    "@nativescript-community/ui-material-bottomnavigationbar": "^6.2.4",
    "@nativescript/appavailability": "^2.0.0",
    "@nativescript/appversion": "^2.0.0",
    "@nativescript/camera": "^5.0.10",
    "@nativescript/core": "~8.1.5",
    "@nativescript/datetimepicker": "^2.1.9",
    "@nativescript/firebase": "^11.1.3",
    "@nativescript/imagepicker": "^1.0.6",
    "@nativescript/ios": "^8.1.0",
    "@nativescript/iqkeyboardmanager": "^2.0.0",
    "@nativescript/theme": "^3.0.2",
    "@nstudio/nativescript-cardview": "^2.0.1",
    "@nstudio/nativescript-loading-indicator": "^4.1.0",
    "@nstudio/nativescript-pulltorefresh": "^3.0.1",
    "@proplugins/nativescript-purchase": "git+https://gitlab.******",
    "@vue/devtools": "^5.3.4",
    "nativescript-dna-deviceinfo": "^3.7.3",
    "nativescript-feedback": "^2.0.0",
    "nativescript-google-maps-sdk": "^3.0.2",
    "nativescript-inappbrowser": "^3.1.2",
    "nativescript-open-app": "^0.3.0",
    "nativescript-phone": "^3.0.2",
    "nativescript-socketio": "^3.3.1",
    "nativescript-toasty": "^3.0.0-alpha.2",
    "nativescript-ui-dataform": "^8.0.1",
    "nativescript-ui-listview": "^10.0.2",
    "nativescript-ui-sidedrawer": "^10.0.2",
    "nativescript-vue": "^2.9.0",
    "nativescript-vue-devtools": "^1.5.1",
    "nativescript-vue-fonticon": "^1.0.3",
    "nativescript-websockets": "^2.0.0",
    "npm-check": "^5.9.2",
    "npm-check-updates": "^12.0.2"
  },
  "devDependencies": {
    "@babel/core": "^7.16.0",
    "@babel/preset-env": "^7.16.4",
    "@nativescript/android": "~8.1.1",
    "@nativescript/webpack": "~5.0.1",
    "babel-loader": "^8.2.3",
    "nativescript-vue-template-compiler": "^2.9.0",
    "nativescript-worker-loader": "~0.12.1",
    "sass": "^1.44.0",
    "vue-loader": "^15.9.8"
  }
}

How in JS to compare from an array of objects from all the results 2 keys are equal to 2 other variables

I’m trying to understand how to get from an array of objects 2 specific keys and compare them with 2 other values for a boolean statement.

What I need to achieve is that for all results from an array of objects I have to check if
ownerId or ownerType are equal to example this.ownerId or this.ownerType.

To give an example I have a result Obj as

const results = [
    {
        ownerId: '1'
        ownerType: SOME_TYPE,
        id: 1
        ...
        <other key_values>
        ...
    },
    {
        ownerId: '1'
        ownerType: SOME_TYPE,
        id: 2
        ...
        <other key_values>
        ...
    },
    ... more ...
];

From the results, I have to extract all ownerId and ownerType and check if all are equal to another value as example

(ownerType === 'USER' && ownerId === userId) ||
(ownerType === 'PARTICIPANT' && ownerId === participantId)

So that means where all ownerType === 'USER' && all ownerId === to this userId then is true.

like all ownerId in my examples are 1 and we suppose ‘USER’ as a type then that is true.

but

If the result doesn’t have all the same ownerId that is false.

I’m not sure what kind of function I need to write for it.

If any comments I’ll try to explain better m issue

Why ‘Get’ request is returning blank object for particular request?

This is the code in which the problem is occurring:
router.get("/", async(req, res) => {
    const username = req.query.user;
    const catName = req.query.cat;

    try {
        let posts;
        if (username) {
            posts = await Post.find({ username: username });
        } else if (catName) {
            posts = await Post.find({ categories: { $in: [catName], }, });
        } else {
            posts = await Post.find();
        }
        res.status.json(posts);
    } catch (err) {
        res.status(500).json(err)
    }
});
if I am using this its working fine
   router.get("/", async(req, res) => {
         try {
             const post = await Post.find()
    
             res.status(200).json(post)
    
         } catch (err) {
             res.status(500).json(err)
         }
     })
I want to use the first request with queries but that is returning a empty object I can’t find error!

Every other requests are working just fine in this route expect the first one!

Can’t pass JSON from PHP to Javascript in Laravel component

We have a Laravel 8 project.

In it, we have a Blade template, and from this Blade template we are including a Laravel component like this:

<x-key-figure-graph
    measure="IQ_TOTAL_REV"
    dividend-history="{{ json_encode($dividend_history) }}"
    show-last="10">
</x-key-figure-graph>

The $dividend_history is an associative array that looks like this:

['2002' => ['date' => '2002-06-30', 'IQ_CLOSEPRICE' => 27.35]],
['2003' => ['date' => '2003-06-30', 'IQ_CLOSEPRICE' => 33.81]],
...

I am doing json_encode on the array to transform it into a string so I can pass it as a prop to the x-key-figure-graph component.

Within the component is where problems arise. If I print out the passed prop:

{{ $dividendHistory }}

I get:

{&quot;2002&quot;:{&quot;date&quot;:&quot;2002-06-30&quot;,&quot;IQ_CLOSEPRICE&quot;:27.35 [...]

So this is a string with the quotes turned into their ASCII equivalents (&quot;). The thing is, now we need to pass this to a Javascript script inside this component. I have not found a way to convert this string back into a working JSON for Javascript.

Attempt 1:

let stock = JSON.parse({!! $dividendHistory !!});

Result:

Uncaught SyntaxError: Unexpected token '&'

Attempt 2:

let stock = JSON.parse("{!! $dividendHistory !!}");

Result:

Uncaught SyntaxError: Unexpected token & in JSON at position 1 at JSON.parse (<anonymous>)

Attempt 3:

let stock = JSON.parse({!! json_decode($dividendHistory) !!});

Result:

Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>)

I don’t know what else to try. Surely it should be possible to convert the string, which was encoded from JSON, back into JSON so it can be used by Javascript. How?

plugin:vite:import-analysis Failed to resolve import “../components/x.vue” from “srcrouterindex.js”. Does the file exist?

In my Vue JS application, I have the following js inside src/routes

index.js

import { createRouter, createWebHistory } from "vue-router";
import Dashboard from '../views/Dashboard.vue';
import Customers from '../views/Customers.vue';
import Login from '../views/Login.vue';
import Register from '../views/Register.vue';
import DefaultLayout from '../components/DefaultLayout.vue';
import AuthLayout from '../components/AuthtLayout.vue';
import store from "../store";

const routes = [
        {
        path : '/',
        redirect : '/dashboard',
        component : DefaultLayout,
        meta : { requiresAuth : true },
        children : [
            {path : '/dashboard', name : 'Dashboard', component : Dashboard},
            {path : '/customers', name : 'Customers', component : Customers}
        ]
    },

    {
        path : '/auth',
        redirect : '/login',
        name : 'Auth',
        component : AuthLayout,
        children:[

                {
                    path : '/login',
                    name : 'Login',
                    component : Login,
                },

                {
                    path : '/register',
                    name : 'Register',
                    component : Register,
                },
            
        ],
    },

    
];

const router = createRouter({
    history : createWebHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    if(to.meta.requiresAuth && !store.state.user.token){
        next({name : 'Login'})
    } else if (store.state.user.token && ( to.name === 'Login' || to.name === 'Register' )  ) {
        next({ name : 'Dashboard' });
    } else{
        next ()
    }
})

export default router;

And I have the following Login.vue inside src/views.

<template> 
      <div>
        <img class="mx-auto h-12 w-auto" src="https://tailwindui.com/img/logos/workflow-mark-indigo-600.svg" alt="Workflow" />
        <h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
          Sign in to your account
        </h2>
        <p class="mt-2 text-center text-sm text-gray-600">
          Or
          {{ ' ' }}
          <a href="#" class="font-medium text-indigo-600 hover:text-indigo-500">
            start your 14-day free trial
          </a>
        </p>
      </div>
      <form class="mt-8 space-y-6" action="#" method="POST">
        <input type="hidden" name="remember" value="true" />
        <div class="rounded-md shadow-sm -space-y-px">
          <div>
            <label for="email-address" class="sr-only">Email address</label>
            <input id="email-address" name="email" type="email" autocomplete="email" required="" class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" placeholder="Email address" />
          </div>
          <div>
            <label for="password" class="sr-only">Password</label>
            <input id="password" name="password" type="password" autocomplete="current-password" required="" class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" placeholder="Password" />
          </div>
        </div>

        <div class="flex items-center justify-between">
          <div class="flex items-center">
            <input id="remember-me" name="remember-me" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" />
            <label for="remember-me" class="ml-2 block text-sm text-gray-900">
              Remember me
            </label>
          </div>

          <div class="text-sm">
            <a href="#" class="font-medium text-indigo-600 hover:text-indigo-500">
              Forgot your password?
            </a>
          </div>
        </div>

        <div>
          <button type="submit" class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
            <span class="absolute left-0 inset-y-0 flex items-center pl-3">
              <LockClosedIcon class="h-5 w-5 text-indigo-500 group-hover:text-indigo-400" aria-hidden="true" />
            </span>
            Sign in
          </button>
        </div>
      </form>
</template>

<script>
import { LockClosedIcon } from '@heroicons/vue/solid'

export default {
  components: {
    LockClosedIcon,
  },
}
</script>

Then I have a component called, AuthLayout.vue inside src/components

<template> 
  <div class="min-h-full flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
    <div class="max-w-md w-full space-y-8">
      <div>
        <router-view></router-view>
    </div>
  </div>
</template>

<script>
import { LockClosedIcon } from '@heroicons/vue/solid'

export default {
  components: {
    LockClosedIcon,
  },
}
</script>

Every time I tried to run my application, it kept giving me the following errors.

[plugin:vite:import-analysis] Failed to resolve import “../components/AuthtLayout.vue” from “srcrouterindex.js”. Does the file exist?

When I comment import AuthLayout from '../components/AuthtLayout.vue'; from the index.js application runs fine. But every time I try to enable it, it gives me an error.

I’m using tailwind CSS and Vue 3

how do i put a three.js animation between html tags

how do I put a three.js animation between html syntax? I am trying to put my three.js animation in between the header and the footer but I can’t I tried putting it in a canvas or a div but still not working (I am using a bootstrap template and a grid of cubes animation) here is the code:

Html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
        <div class="container">
            <a class="navbar-brand" href="#page-top">Teamseas</a>
            <button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                    Menu
                    <i class="fas fa-bars"></i>
                </button>
                <div class="collapse navbar-collapse" id="navbarResponsive">
                    <ul class="navbar-nav ms-auto">
                        <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#portfolio">Portfolio</a></li>
                        <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#about">About</a></li>
                        <li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#contact">Contact</a></li>
                    </ul>
                </div>
      </div>
    </nav>








  <script type="module" src="script.js">
  </script>
 <footer class="footer text-center">
  <div class="container">
      <div class="row">
          <!-- Footer Location-->
          <div class="col-lg-4 mb-5 mb-lg-0">
              <h4 class="text-uppercase mb-4">Location</h4>
              <p class="lead mb-0">
                  2215 John Daniel Drive
                  <br />
                  Clark, MO 65243
              </p>
          </div>
          <!-- Footer Social Icons-->
          <div class="col-lg-4 mb-5 mb-lg-0">
              <h4 class="text-uppercase mb-4">Around the Web</h4>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-facebook-f"></i></a>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-twitter"></i></a>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-linkedin-in"></i></a>
              <a class="btn btn-outline-light btn-social mx-1" href="#!"><i class="fab fa-fw fa-dribbble"></i></a>
          </div>
          <!-- Footer About Text-->
          <div class="col-lg-4">
              <h4 class="text-uppercase mb-4">About Freelancer</h4>
              <p class="lead mb-0">
                  Freelance is a free to use, MIT licensed Bootstrap theme created by
                  <a href="http://startbootstrap.com">Start Bootstrap</a>
                  .
              </p>
          </div>
      </div>
  </div>
</footer>
<!-- Copyright Section-->
<div class="copyright py-4 text-center text-white">
  <div class="container"><small>Copyright &copy; Your Website 2021</small></div>
</div>
</body>
</html>

JavaScript

import * as THREE from "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js";
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js";
let s = prompt("g");
function animates(){ 
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
const controls = new OrbitControls(camera, renderer.domElement);

const grid = new THREE.Group();

const cubeSize = 0.5;
const size = Math.cbrt(s);
const gap = 0.01;

const geometry = new THREE.BoxBufferGeometry(
cubeSize,
cubeSize,
cubeSize
);
const material = new THREE.MeshNormalMaterial();
const cubes = new THREE.InstancedMesh(
geometry,
material,
Math.pow(size,3)
);

cubes.instanceMatrix.setUsage(THREE.DynamicDrawUsage);

grid.add(cubes);
scene.add(grid);

const cube = new THREE.Object3D();
const center = (size + gap * (size - 1)) * -0.5;

grid.position.set(center, center, center);
if(s <= 10000){
camera.position.z = 25;
}
else if (s <= 100000){
camera.position.z = 75;
}
else if (s <= 1000000){
    camera.position.z = 100;
    }
(function animate() {
requestAnimationFrame(animate);

let i = 0;
for (let x = 0; x < size; x++) {
for (let y = 0; y < size; y++) {
for (let z = 0; z < size; z++) {
  cube.position.set(x, y, z);
  cube.updateMatrix();
  cubes.setMatrixAt(i, cube.matrix);
  i++;

}
}
}
/*
grid.rotation.x+=0.003;
grid.rotation.y+=0.003;
grid.rotation.z+=0.003;
*/
cubes.instanceMatrix.needsUpdate = true;

controls.update();
renderer.render(scene, camera);
})();
animate();
}
animates();