How to extract modified text of p tag to python

I tried whole day but unable to extract the overwritten texts of p tag.
For example:

<p id='demo'><p>
<Script>
  Var = document.getElementById('demo').innerHTML = 'some context'
<Script>

I need the text ‘some context’ into python.
I tried with beautifulsoup

page = soup.find('p').getText()

I’m getting nothing. Is there any way to get changed text of p tag. Any Help will be appreciated.

How to print a new array from existing array of object javascript

I need to create a new array of objects from the existing array on vuejs.

example first array :

import { ref } from 'vue';

const base_array = ref([
  {id: 1, name: Pill, timing: [morning, noon, evening, night]},
  {id: 2, name: Tablet, timing: [morning, evening]},
])

expected result :

const modified_array = ref([
  {id: 1, name: Pill, timing: [morning]},
  {id: 2, name: Pill, timing: [noon]},
  {id: 3, name: Pill, timing: [evening]},
  {id: 4, name: Pill, timing: [night]},
  {id: 5, name: Tablet, timing: [morning]},
  {id: 6, name: Tablet, timing: [evening]},
])

I’ve tried forEach and looping the array, but seems can’t find the right function.
Thank youu

ERROR: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘data’)

I am writing applications in spring boot and react. I am running a server and want to submit a form from the client side. The form should be saved in the database.

I fill out the form and it is saved in the database, but after filling out the form and clicking the “submit” button the page should switch to the main screen of the application, i.e. the /dashboard address, but I still stay with the form and when I enter the devtools I get a ERROR: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data').

That is, it comes out that the application itself works, the data is transferred between the client and the server and stored in the database. So the problem lies on the frontend side, specifically on the react side. The message also points to the specific file where the problem is , namely in the file projectActions.js

However, I do not know too much about what the problem is specifically, where I made a mistake, that the page after submitting the form is not “reloaded” and returns to the specified address.

Below I send the class referenced in the error.

I also provide the versions of the packages I use:

    "axios": "^0.27.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-redux": "^8.0.2",
    "react-router-dom": "^6.3.0",
    "react-scripts": "5.0.1"

projectActions.js

import axios from "axios";
import { GET_ERRORS } from "./types";

export const createProject = (project, history) => async (dispatch) => {
  try {
    const res = await axios.post("http://localhost:8080/api/project", project);
    history.push("/dashboard");
  } catch (error) {
    dispatch({
      type: GET_ERRORS,
      payload: error.response.data,
    });
  }
};

Leaflet layer control ordering plugin doesn´t work

I don´t know why the layer ordering doesn´t work. I´m using the code from http://elesdoar.github.io/leaflet-control-orderlayers/ so that users could change the order of the layers. I´m new to all of this, so I don´t really know what is the problem. It doesn´t even show the layer control on the map after using L.control.orderlayers. Here is my code -> https://github.com/Paulina-N/Map

RXJS: How do I add new values to an ovservable after creation?

Im working through the basics of observables [here][1]

The examples here show Observasbles as functions with multiple returns e.g.

import { Observable } from 'rxjs';
 
const foo = new Observable(subscriber => {
  console.log('Hello');
  subscriber.next(42);
  subscriber.next(100); // "return" another value
  subscriber.next(200); // "return" yet another
});
 
foo.subscribe(x => {
  console.log(x);
});

// outputs 42, 100, 200

Question: Is it possible to add new values to an observable AFTER it has been created e.g. something like this pseudo code:

import { Observable } from 'rxjs';
 
const foo = new Observable(subscriber => {
  subscriber.next(200);
});
 
// this is pseudocode so wont work, but is the basis of this post.
...

foo.next(400);

...

foo.subscribe(x => {
  console.log(x);
});

// is it possible to output 200 and 400 by calling next after instantiation?

Or do I need to use a Subject to do that?

prebid.js ad is not getting rendered

I have setup prebid.js with single adaptor configured on test page. I am getting the ad response from adaptor and I can see the pbjs.getBidResponses() object is present still ad is not getting rendered on the page.

you can visit test page

standard prebid setup as follows

JAVSCRIPT

var sizes = [
  [300, 250]
];
var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 3000;

var adUnits = [{
  code: '/19968336/header-bid-tag-1',
  mediaTypes: {
    banner: {
      sizes: sizes
    }
  },
  bids: [{
    bidder: 'incrementx',
    params: {
      placementId: 'PNX-HB-R787915V41024E'
    }
  }]
}];

// ======== DO NOT EDIT BELOW THIS LINE =========== //
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
  googletag.pubads().disableInitialLoad();
});

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function () {
  pbjs.addAdUnits(adUnits);
  pbjs.requestBids({
    bidsBackHandler: initAdserver,
    timeout: PREBID_TIMEOUT
  });
});

function initAdserver() {
  if (pbjs.initAdserverSet) return;
  pbjs.initAdserverSet = true;
  googletag.cmd.push(function () {
    pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync();
    googletag.pubads().refresh();
  });
}

// in case PBJS doesn't load
setTimeout(function () {
  initAdserver();
}, FAILSAFE_TIMEOUT);

googletag.cmd.push(function () {
  googletag.defineSlot('/19968336/header-bid-tag-1', sizes, 'div-1')
    .addService(googletag.pubads());

  googletag.pubads().collapseEmptyDivs();
  googletag.pubads().enableSingleRequest();
  googletag.enableServices();
});

HTML

<div id='div-1'>
    <script type='text/javascript'>
        googletag.cmd.push(function () {
            googletag.display('div-1');
        });
    </script>
</div>

ADAPTOR Response

{
    "vzhPlacementId": "<placement-id>",
    "bid": "<bid>",
    "adWidth": "300",
    "adHeight": "250",
    "cpm": "0.017442",
    "ad": "<ad-tag>",
    "slotBidId": "<slot-id>",
    "statusText": "Vertoz:Success"
}

pbjs.getBidResponses() output

{
    "/19968336/header-bid-tag-1": {
        "bids": [
            {
                "bidderCode": "incrementx",
                "width": 300,
                "height": 250,
                "statusMessage": "Bid available",
                "adId": "389575b4d6d5f1",
                "requestId": "2b7446c2969f1f",
                "transactionId": "a6a81b3e-8cf7-4d71-bc7e-34c283e1a746",
                "auctionId": "4455d9a4-4364-4f9d-bd1a-d7f0a7fd56e4",
                "mediaType": "banner",
                "source": "client",
                "cpm": 0.017442,
                "currency": "USD",
                "ttl": 300,
                "creativeId": 0,
                "netRevenue": false,
                "meta": {
                    "mediaType": "banner",
                    "advertiserDomains": [],
                    "dchain": {
                        "ver": "1.0",
                        "complete": 0,
                        "nodes": [
                            {
                                "name": "incrementx"
                            }
                        ]
                    }
                },
                "ad": "<ad-tag>",
                "adapterCode": "incrementx",
                "originalCpm": "0.017442",
                "originalCurrency": "USD",
                "responseTimestamp": 1656921876245,
                "requestTimestamp": 1656921875927,
                "bidder": "incrementx",
                "adUnitCode": "/19968336/header-bid-tag-1",
                "timeToRespond": 318,
                "pbLg": "0.00",
                "pbMg": "0.00",
                "pbHg": "0.01",
                "pbAg": "0.00",
                "pbDg": "0.01",
                "pbCg": "",
                "size": "300x250",
                "adserverTargeting": {
                    "hb_bidder": "incrementx",
                    "hb_adid": "389575b4d6d5f1",
                    "hb_pb": "0.00",
                    "hb_size": "300x250",
                    "hb_source": "client",
                    "hb_format": "banner",
                    "hb_adomain": ""
                },
                "status": "targetingSet"
            }
        ]
    }
}

pbjs.getAllPrebidWinningBids() & pbjs.getAllWinningBids() output

[]

this is the output I am getting

enter image description here

not able to find the issue, there is only 1 adaptor integrated so in all cases the bid should win, not sure am I missing something in setup?. Any help would be appreciated, thank you

Preload heavy gif image

I have a heavy process that requires several seconds to complete.

That’s why I’ve added an animated loading page to make the wait acceptable.

<style>
   .modal_gif {
      display:    none;
      position:   fixed;
      z-index:    1000;
      top:        0;
      left:       0;
         height:     100%;
         width:      100%;
         background: rgba( 255, 255, 255, .8 ) 
         url('static/loading.gif') 
         50% 50% 
         no-repeat;
         background-size: 80%, auto;
        }
    body.loading .modal_gif {
         overflow: hidden;   
         }
         body.loading .modal_gif {
         display: block;
         }
        
 </style>
<script>
       $(document).on({
          ajaxStart: function() { $body.addClass("loading");    },
          ajaxStop: function() { $body.removeClass("loading"); }    
    });
</script>

However, the gif weigh about 1MB and it is not displayed after the first request: there is only a semi-transparent veil on the screen.

The second and following requests are working well, which makes me think that it is a gif loading problem.

I’d like the animated loading gif to be always displayed when requested, even for the first request.

Do you know how to preload a gif animated file as hidden and display it even for the first request?

Antd DatePicker with buddhist year

Summary:

  • I’ve managed to apply the Thai locale for my Antd DatePicker but the year display is invalid. It has to be buddhist year (=christian year + 543) for a Thai locale.

(see the image at https://i.stack.imgur.com/336b7.jpg)

What I’ve tried:

Some code:

// App.js
import React from 'react'
import {DatePicker} from 'antd'
import 'moment/locale/th'
import locale from 'antd/lib/locale-provider/th_TH'


function App() {
  return <DatePicker locale={locale}/>
}
  
export default App

how to display contents from console to webpage? [duplicate]

I have made a search button that fetches data from api and results are printed in the console but now I want to display some specific items of the printed result on my web page. How can I do that? Should I make another component for this or it can be done in the same page?


import React, {useState, useEffect} from 'react'
import axios from 'axios';
import Navbar from "./components/Navbar";

export default function App() {

  const [searchText ,setSearchText]=useState("");

  useEffect(() => {
    console.log(searchText); ;
    }, [searchText]); 
    
  function getData(){
      var config = {
          method: 'get',
          url: `/api/orders-lookup/services/v4/orders?orderNo=${searchText}`,
          headers: { 
            'Accept': 'application/json', 
            'Content-Type': 'application/json', 
            'WM_CONSUMER.ID': '2d0a30c7-b4cc-45d1-b451-d93535f5a92d', 
            'WM_CONSUMER.TENANT_ID': '0', 
            'WM_SVC.ENV': 'teflon', 
            'WM_SVC.NAME': 'order-service', 
            'WM_SVC.VERSION': '4.0.0', 
            'X-Request-ID': '1234_3bb32b5d-32e9-4d0a-ace6-e682edddd348', 
            'WM_QOS.CORRELATION_ID': '1234'
          }
      };
        
        axios(config)
        .then(function (response) {
          console.log(JSON.stringify(response.data));
        })
        .catch(function (error) {
          console.log(error);
        });
  }    



  return (
    <div className='fullscreen-container'>
      <div className='Navbar'>
        <Navbar/>
      </div>
      <div className='template'>
        <div className='search-form'>
            <div className='form-control'>
              <label htmlFor='number'>Search your order Number</label>
              <input
                type='name'
                name='OrderNo'
                id='OrderNo'
                value={searchText}
                onChange={e => setSearchText(e.target.value)}
              />
              <button onClick={getData} className='submit'>search</button>
            </div>
        </div>
      </div>
    </div>
  )
}

The api call is as follows:

"payload": [
        {
            "version": 4,
            "buyerInfo": {
                "id": "0aed8c49-d42d-4f39-8793-c8e875aad732",
                "isGuest": false,
                "associateInfo": {
                    "shouldApplyAssociateDiscount": false
                },
                "primaryContact": {
                    "name": {
                        "firstName": "Astro",
                        "lastName": "Test"
                    },
                    "phone": {
                        "completeNumber": "1234567890"
                    },
                    "email": {
                        "emailAddress": "[email protected]"
                    }
                },
                "customerType": "INDIVIDUAL"
            },
            "groupOrderNo": "100000006683259",
            "action": "CREATE",
            "orderNo": "100000006683259",
            "orderType": "DOMESTIC",
            "lastModified": "2022-06-12T03:06:58.000+0000",
            "originSystemId": "VekE0nCOeidm3pOPYS4pUs",
            "originSystemOrderId": "0",
            "orderSource": "PG_OMS",
            "paymentStatus": "AUTHORIZED",
            "paymentRuleId": "PLUTUS",
            "orderOrigin": "1",
            "orderTaxId": "53f24838-779a-4aea-820a-42a773182aa2",
            "tenantId": "0",
            "martId": "0",
            "verticalId": "0",
            "orderDate": "2022-06-10T11:22:35.000+0000"
}]

Can somebody please tell me how can I display some of the properties on my screen?
Thanks in advance

I’m using axios, How do i call a function after a function in the IonToggle button by using .then in react

function NewParkLayout({ name, status, cardClick, showModal, address, image, parkId }: ParkLayoutProps) {
  const [checked, setChecked] = useState(false);

  const offPark = (checked: any, parkId: any) => {
    var data = JSON.stringify({
      "parkId": parkId,
      "status": checked
    });
    axios.post(`api url here`, data).then(
      (response) => {
        console.log(response);
      }
    );
  };

  return (

      <div className="park-layout-address">
        <p>{address}</p>
        <IonLabel>Checked: {JSON.stringify(checked)}</IonLabel>
        <IonItem>
          <button onClick={() => showModal()}>Add New Park Price</button>

          <IonToggle onIonChange={e => setChecked(e.detail.checked).then(() => {offPark})} toggle-class="toggle-my-theme" slot="end"></IonToggle>
        </IonItem>






      </div>
    </div>
  );
}

export default NewParkLayout;

Font Awesome icon not changing color based on React state

Font awesome icon is not changing color based on react state, I have an app which shows random quotes and display random color in background, new quote button and twitter icon. On first reload twitter icon color is changing as intended, however, when new quote button is clicked it stays the same. Here is my code

import React from 'react';
import './style.scss';
import randomColor from 'randomcolor';
import '@fortawesome/fontawesome-free/css/all.css';
import '@fortawesome/fontawesome-free/js/all.js';

const quotes = [
    'I do not fear computers. I fear lack of them.',
    'A computer once beat me at chess, but it was no match for me at kick boxing.',
    'Computer Science is no more about computers than astronomy is about telescopes.',
    'The computer was born to solve problems that did not exist before.',
    'Software is like entropy: It is difficult to grasp, weighs nothing, and obeys the Second Law of Thermodynamics; i.e., it always increases.',
    'Software is a gas; it expands to fill its container.',
    "All parts should go together without forcing.  You must remember that the parts you are reassembling were disassembled by you.  Therefore, if you can't get them together again, there must be a reason.  By all means, do not use a hammer.",
    "Standards are always out of date.  That's what makes them standards.",
    "Physics is the universe's operating system.",
    "It's hardware that makes a machine fast.  It's software that makes a fast machine slow.",
    'Imagination is more important than knowledge.  For knowledge is limited, whereas imagination embraces the entire world.',
    'The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.',
    'The more you know, the more you realize you know nothing.',
    'Tell me and I forget.  Teach me and I remember.  Involve me and I learn.',
    "Real knowledge is to know the extent of one's ignorance.",
    'If people never did silly things, nothing intelligent would ever get done.',
    'Getting information off the Internet is like taking a drink from a fire hydrant.',
    'If you think your users are idiots, only idiots will use it.',
    "From a programmer's point of view, the user is a peripheral that types when you issue a read request.",
    "Where is the 'any' key?",
    'Computers are good at following instructions, but not at reading your mind.',
    "There is only one problem with common sense; it's not very common.",
    'Your most unhappy customers are your greatest source of learning.',
    'Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.',
];
const authors = [
    '- Isaac Asimov',
    '- Emo Philips',
    '- Edsger W. Dijkstra',
    '- Bill Gates',
    '- Norman Augustine',
    '- Nathan Myhrvold',
    '- IBM Manual, 1925',
    '- Alan Bennett',
    '- Steven R Garman',
    '- Craig Bruce',
    '- Albert Einstein',
    '- Stephen Hawking',
    '- Socrates',
    '- Benjamin Franklin',
    '- Confucius',
    '- Ludwig Wittgenstein',
    '- Mitchell Kapor',
    '- Linus Torvalds',
    '- P. Williams',
    '- Homer Simpson, in response to the message, “Press any key”',
    '- Donald Knuth',
    '- Milt Bryce',
    '- Bill Gates',
    '- Donald E. Knuth',
];

const random = Math.floor(Math.random() * quotes.length);
class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            quote: quotes[random],
            author: authors[random],
            color: randomColor(),
        };
        this.handleClick = this.handleClick.bind(this);
    }

    handleClick() {
        const clickRandom = Math.floor(Math.random() * quotes.length);
        this.setState({
            quote: quotes[clickRandom],
            author: authors[clickRandom],
            color: randomColor(),
        });
    }

    render() {
        return (
            <div
                id="bg"
                style={{
                    backgroundColor: this.state.color,
                }}
            >
                <div id="quote-box">
                    <p id="text">{this.state.quote}</p>
                    <p id="author">{this.state.author}</p>
                    <a id="tweet-quote" href="https://twitter.com/intent/tweet">
                        <i
                            className="fa-brands fa-twitter-square fa-2xl"
                            style={{
                                color: this.state.color,
                            }}
                        ></i>
                    </a>
                    <div style={{
                        width: 20,
                        height: 20,
                        backgroundColor: this.state.color
                    }}></div>
                    <button
                        id="new-quote"
                        onClick={this.handleClick}
                        style={{
                            backgroundColor: this.state.color,
                            border: 'solid 1px ' + this.state.color,
                        }}
                    >
                        New Quote
                    </button>
                </div>
            </div>
        );
    }
}

export default App;

To diagnose the problem I have specifically made a div box of 20 x 20px, every element is changing color upon click on new quote button except font awesome twitter icon.