how to bring page to first page in react paginate in react?

how to bring page to first page in react paginate in react?

<ReactPaginate
            className="pagination"
            nextLabel=">"
            previousLabel="<"
            pageCount={Math.ceil(totalCount / payload.params.size)}
            pageRangeDisplayed={6}
            renderOnZeroPageCount={null}
            onPageChange={handlePageClick}
            
          />

can anybody tell how to get to first page each time my data is changing? i have tried forcePage but it is not working

The div position changes when the screen starts to shrink

There is a tooltip that opens when hovering the cursor over the icon. But when the screen starts to shrink a little, the div starts to change position. How can I prevent this?

I have another question. As you can see in the image below, the tooltip that opens does not open exactly under the icon. I don’t want a space between the dropdown tooltip and the icon.

Note: The tooltip that opens should appear at the bottom left of the icon.

The picture I’m talking about;

enter image description here

html

<div className="installmentinfo__container">
  {
    props.installmentList?.map((e, i) => {
      return (
        <div className="installmentinfo">
          <div className="column">
            <div className="installmentnumber" >{(i + 1).toString()}</div>
            <div className="installmentdate">{e.date}</div>
            <div className="installmentamount">{e.amount} {e.currency}</div>
          </div>
        </div>
      );
    })
  }
</div>

css

.installmentinfo__container {
  border: 1px solid #d1d1d1;
  border-radius: 10px;
  max-width: 300px;
  box-shadow: 2px 2px 4px 4px #d1d1d1;
  position: absolute;
  right: 340px;
  background-color: white;

  &:last-of-type {
    border-bottom: none;
  }

  .installmentinfo {

    width: 280px;
    height: auto;
    padding: 0em 1em;

    .column {
      display: flex;
      margin: 5px;
      justify-content: space-between;
      font-size: 1.3rem;
      border-bottom: 1.5px solid #d1d1d1;
    }

    .installmentnumber {
      float: left;
    }

    .installmentdate {
      width: 50%;
      color: black !important;
    }

    .installmentamount {
      width: 50%;
      color: black !important;
      font-weight: 1000;
    }
  }
}

How to remove double quote in broken nested json values?

Am stuck with applying replace() with regex for broken nested json value. For example, i want to remove doublequote for origin value below.

How to change from this:

{
 "type" : "fruitList",
 "data" : [{
   "fruitName" : "test",
   "origin" : "[{"states" : "USA"}]"
 }]
}

To this:

{
 "type" : "fruitList",
 "data" : [{
   "fruitName" : "test",
   "origin" : [{"states" : "USA"}]
 }]
}

Simple Notes App Not Working With Local Storage

I have a bare bones project that displays a list of notes and a button that will add a new note to that list to be displayed. My issue is that the new notes are not added/retrieved from local storage and I’m not sure what is causing it.

import React, { useEffect, useState } from 'react'
function App() {

  const [notesList, setNotesList] = useState([])

  useEffect(() => {
    const notesJSON = localStorage.getItem('ayo')
    if (notesJSON != null) setNotesList(JSON.parse(notesJSON))
    console.log(notesList)
  }, [])

  useEffect(() => {
    localStorage.setItem('ayo', JSON.stringify(notesList))
  }, [notesList])

  function addNote(e) {
    e.preventDefault()

    const newNote = {
      id: Date.now() + Math.random(),
      text: 'this is a new note',
      status: false,
    }
    setNotesList([...notesList, newNote])
  }

  return (
    <>
      <h1>Hello</h1>
      {notesList.map((note) => {
        return <h1 key={note.id}>{note.text}</h1>
      })}
      <form onSubmit={addNote}>
        <button type='submit'>Add Note</button>
      </form>
    </>
  )
}

export default App;

bxSlider add google ad is possible?

bxSlider add google ad is possible?

I am using bxsldier and I want to show Google Adsense ad in BXslider

<div class="bxslider">
  <div><img src="/assets/images/coffee1.jpg" title="Funky roots"></div>
  <div><img src="/assets/images/coffee2.jpg" title="The long and winding road"></div>
  <div><img src="/assets/images/coffee3.jpg" title="Happy trees"></div>
</div>

$(function(){
  $('.bxslider').bxSlider({
    mode: 'fade',
    captions: true,
    slideWidth: 600
  });
});

enter image description here

How to center buttons in a div

Here is my CSS and HTML.

.btn-group button {
  border: 3px solid green;
  padding: 10px;
  background-color: #04AA6D;
  /* Green background */
  border: 1px solid green;
  /* Green border */
  color: white;
  /* White text */
  padding: 10px 24px;
  /* Some padding */
  cursor: pointer;
  /* Pointer/hand icon */
  float: left;
  /* Float the buttons side by side */
}

.btn-group button:not(:last-child) {
  border-right: none;
  /* Prevent double borders */
}


/* Clear floats (clearfix hack) */

.btn-group:after {
  content: "";
  clear: both;
  display: table;
}


/* Add a background color on hover */

.btn-group button:hover {
  background-color: #3e8e41;
}
<div class="btn-group">
  <button type="button" class="button1">Faucet</button>
  <button type="button" class="button2">About Nano/Faucet</button>
  <button type="button" class="button3">Donate</button>
</div>

Image Of Buttons

I want to center these buttons under the text in the screen’s center!
I have tried so many things nothing works for me.

Vanilla JavaScript storaged locally the wrong attribution from a selected option to switch the theme when you refresh the site

My goal is to switch one of 4 theme files with one of two different folders and locally and permanently storage both folder and theme names.

Everything worked until I refreshed the site, localStorage stored the wrong folder name and the wrong theme name, for example, if you choose “ion” from “voxel”, then when you refresh, you’ll see “cyberpunk” selected, while the console showed “gusbemacbe/ion.css”

Here how tree is like:

assets/css/tokens
├── gusbemacbe
│   └── cyberpunk.css
└── voxel
    ├── ion.css
    ├── itau.css
    └── iti.css

And in the HTML code with explanations:

<!-- the "active_stylesheet" identifier will be caught to change the stylesheet address. Observe "voxel" (folder) and "ion" (theme) -->
<link rel="stylesheet" media="screen" type="text/css" href="assets/css/tokens/voxel/ion.css" id="active_stylesheet">

<!-- 
- the "ThemeSelect" identified will be caught to get the option value for the theme name.
- the 'onchange="setFolder()"' command will be caught to get "data-id" value for the folder name.
-->
<select id="ThemeSelect" onchange="setFolder()">
    <option data-id="gusbemacbe" value="cyberpunk" selected>cyberpunk</option>
    <option data-id="voxel"      value="ion">íon</option>
    <option data-id="voxel"      value="itau">itaú</option>
    <option data-id="voxel"      value="iti">iti</option>
</select>

<script src="assets/js/global.js"></script>

And in the JavaScript code with explanations:

// this function will change the stylesheet address with the folder and theme values
function changeCSS(sheet) {
    document.getElementById('active_stylesheet').setAttribute('href', sheet);
}

// this function will catch the function command at that select element to get the data-id value. 
function setFolder() {
    const e = document.getElementById("ThemeSelect");
    const folder = e.options[e.selectedIndex].getAttribute("data-id");

    return folder;
}

// this function will create the new address, catching the folder and theme values, and setting to store the values
function setTheme(theme) {

    changeCSS("assets/css/tokens/" + setFolder() + "/" + theme + ".css")

    localStorage.setItem('folder', setfolder());
    localStorage.setItem('theme', theme);
}

// this event will catch the option value with the identifider
ThemeSelect.addEventListener('change', function () {
    setTheme(this.value)
});

// this will store permanently the storages setted by the functions
const getTheme = () => {
    const theme = localStorage.getItem('theme');
    theme && setTheme(theme);

    const folder = localStorage.getItem('folder');
    folder && setFolder(folder);
}

getTheme();

enable Submit button on ckeditor validation

I have ckeditor 4 in one page. On page, submit button is by default disabled I want to put validation on ckeditor4 textarea on check whether it is empty or not if it is empty put button as disabled and if some text is in ckeditor textarea then button should be visible. So How can I Do it with Javascript?

Ckeditor Textarea code:

<textarea cols="10" id="editor1" name="editor1" rows="10" onchange="val()"></textarea>

Submit Button Code:

<input type="button" name="next" class="next action-button btn btn-primary sub" value="Submit" data-toggle="modal" data-target="#success-modal" id="nxtbtnwht1"  disabled/>

Javascript code:

function val()
  {
    
    var a = CKEDITOR.instances['editor1'].getData();
    
    
    if(a!==null || a!==""){
     
    document.getElementById("nxtbtnwht1").disabled = false;
    }
    else{
      document.getElementById("nxtbtnwht1").disabled = true;
    }
  }

this is the error i am getting…Server Error TypeError: Cannot convert undefined or null to object

import { getProviders, signIn } from "next-auth/react";

function Login({ providers }) {
  return (
    <div className="flex flex-col items-center bg-black min-h-screen w-full justify-center">
      <img className="w-52 mb-5" src="https://links.papareact.com/9xl" alt="" />

      {Object.values(providers).map((provider) => (
        <div key={provider.name}>
          <button
            className="bg-[#18D860] text-white p-5 rounded-full"
            onClick={() => signIn(provider.id, { callbackURL: "/" })}
          >
            Login with {provider.name}
          </button>
        </div>
      ))}
    </div>
  );
}

export default Login;

export async function getServerSideProps() {
  const providers = await getProviders();

  return {
    props: {
      providers,
    },
  };
}

Screen capture with javascript mediaDevices api

what I am trying to achieve is add an option to my webApp that the users can screeshot the screen. I tried out some ready2use libraries like html2canvas and rasterizeHTML but I am experiensing problems with them.
I found out a possible solution using the mediaDevices api, but there are several things that I want to change and not sure how.
Here is my code:

navigator.mediaDevices.getDisplayMedia().then(stream => 
{
  // Grab frame from stream
  let track = stream.getVideoTracks()[0];
  let capture = new ImageCapture(track);
  let canvas = document.createElement('canvas');  
  capture.grabFrame().then(bitmap => 
  {
    track.stop();
      
    canvas.width = bitmap.width;
    canvas.height = bitmap.height;
    canvas.getContext('2d').drawImage(bitmap, 0, 0);
      
    let a = document.createElement("a");
    document.body.appendChild(a);

    a.href = canvas.toDataURL(`image/png`);
    a.download = "screenshot.png";

    a.click();
  });
})
.catch(e => console.log(e));

Using this piece of code I am getting the options to choose from my available screens and pick what to screenshot.
I have 2 problems with this:

  1. The dialog that is poping has a button called share, I want to change it so it is saying screenshot. Is it possible to adjust the dialog and at least rename the primary button ?
  2. If I attach this code to a component inside my app – for example on button click, if I want to screenshot my current screen, the dialog for the screenshot is also visible in the image, but I don’t want it. Is it possible to ignore the pop-up while doing the screenshot?

Thanks in advance!

How to invoke JAVA function multiple times from inline Javascript Expression using ScriptEngine

I am evaluating an inline Javascript Expression using Java-8’s ScriptEngine.
Example Expression

(_tranxAmount > 100) && (profile.received('daily', 'avg', false) < 100)

Where profile is a global scope bind Java Class object and received() is its local function. I Successfully evaluated this expression using scriptingEngine.eval(script) and it is calling profile.received('daily', 'avg', false) I mean to say functionsManager.received('daily', 'avg', false) as well.

Question: But Scripting engine failed to evaluate Javascript expression if it contains Java functions more than one. In that case, only first Java function get called. So how to resolve this issue?
eg.

 (_tranxAmount > 100) && (profile.received('daily', 'avg', false) < 100) && (profile.sent('monthly', 'count', false) < 5)

Script Engine:

private static ScriptEngine scriptingEngine;

Inside Constructor of main class

scriptingEngine = new ScriptEngineManager().getEngineByName("JavaScript");
        scriptingEngine.getBindings(ScriptContext.GLOBAL_SCOPE).put(PROFILING_FUNCTIONS_PREFIX, functionsManager);

Evaluating Expression

Bindings bindings = new SimpleBindings(customMapOfVaraibles);
CompiledScript compiled = ((Compilable) scriptingEngine).compile(" (_tranxAmount > 100) && (profile.received('daily', 'avg', false) < 100) && (profile.sent('monthly', 'count', false) < 5)");
compiled .eval(bindings)

functionsManager‘s methods look like this

public BigDecimal received(String intervalType, String statisticsType, boolean considerTranxType)
            throws InvalidRequirementsException {
   //Do calculations
   return calculatedValue;
}

public BigDecimal sent(String intervalType, String statisticsType, boolean considerTranxType)
                throws InvalidRequirementsException {
       //Do calculations
       return calculatedValue;
    }

How to include an extracted variable in a raisefault message using apigee

{
“requestTimeStamp”:”2017-02-06T02:12:06.873Z”,
“correlationId”:”ID:EMS-SERVER.658217220235A:23″,
“eventType”:”Activation”,
“serviceId”:”[email protected]”
}

I used an extract variable policy in apigee to extract the “eventType”:”Activation”. I created a raise fault policy also that will return a response “Account has been set for Activation”. How do I add the extracted variable (eventType”:”Activation) in my raise fault message.

How can I call the boolean from c# to Javascript Ajax?

I was trying to call the boolean from my Controller which is true, But when I call it now on my Javascript ajax I can’t get it.

$.ajax({
    url: "/Shop/Accessories",
    contentType: "application/html; charset=utf-8",
    type: 'GET',
    dataType: "html",
    success: (function (result) {
        if (result) { //If I do result == true : still not working
            $('#owl1').html(result)
            $('#owl1').owlCarousel({
                loop: true,
                nav: false,
                dots: false,
                autoplay: false,
                margin: 10,
                responsive: {
                    0: {
                        items: 2
                    },
                    600: {
                        items: 3
                    },
                    1000: {
                        items: 4
                    }
                }
            })
        } else {
            $(".noItem1").html(result);
        }
    }),
    error: (function (xhr, status) {
        alert(status);
    })
})

I am using a dataType: html for the return View when the database doesn’t have any data

using (SqlConnection con = new SqlConnection(constring))
        {
            string command = "select item_image, item_name, item_price item_number, item_type, date_added from cooking_items";

            con.Open();
            using (SqlCommand cmd = new SqlCommand(command, con))
            {
                cmd.CommandTimeout = 60;
                SqlDataReader Creader1;
                Creader1 = cmd.ExecuteReader();
                if (Creader1.HasRows == true)
                {
                    con.Close();
                    con.Open();
                    DataTable dt = new DataTable();
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        da.Fill(dt);
                    }
                    con.Close();
                    return View("Cooking", dt);
                }
                else
                {
                    return View("Cooking"); //When there's no data, these is the one who should call my ajax.
                }
            }
        }