Need to call list users api and extract the user details from api response and create Excel file and write user data
I want to do with java
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
Need to call list users api and extract the user details from api response and create Excel file and write user data
I want to do with java
class User{
username
password
constructor(username, password){
this.username = username
this.password = password
}
get password(){
return this.password.replace(/./g, '*')
}
set password(newPassword){
const passwordRegex = /^(?=.*d)(?=.*[A-Z]).{8,}$/
if(passwordRegex.test(newPassword)){
this.password = newPassword
}else{
console.error("Password must be at least 8 characters long and contain at least one number and one uppercase letter")
}
}
}
const user = new User(‘username’, ‘myPassword’)
console.log(user.password);
I am trying to print the “*********” of password matched the condition or it print the else message but insted it printing the password. please tell what is happening
In the below code you cant add any new ids or class names.
If the user clicks the button then if the errorUL exists then I want to add a message to the existing li or create a new li and add the message. Either way I want to show the extra message. “The card has been declined for an unknown reason. Please contact support”.
<button id = 'place_order'>button</button>
<ul class="woocommerce-error" role="alert">
<li>
The card has been declined for an unknown reason.</li>
</ul>
<Script>document.getElementById('place_order').onclick = function() {
var errorUl = document.getElementsByClassName('woocommerce-error');
if(errorUl.length > 0) {
{{NEED to access the li and add a message}}
}
}</Script>
I want to create temporary pages for public events that appear and disappear every 5 seconds bu html css javascript
I tried settimeout function
This a continuation of question asked here Refresh same tabs in javascript/react instead of opening new tab on browser window but a response was not received so i tried to follow different approaches myself.
I decided to go with the approach of saving the window references and closing the tabs using the same. What works here is:
When i am able to open the new tabs immediately in browser for the same task. I save it in an array. I am able to close them immediately for same task:
CODE BLOCK A:
const openInNewTab = (url) => {
const newWindow = window.open(url, '_blank');
prevWindow.push(newWindow);
if (newWindow) newWindow.opener = null
}
...
...
...
popUpTabUrlArray.forEach((url,ind) => {
if(url && common.isValidHttpUrl(url))
openInNewTab(url);
});
console.log("PREV WINDOW IS:", prevWindow); <<<<<< line 2
if(prevWindow.length>0)
{
prevWindow.forEach((win,ind)=>{
win.close();
});
prevWindow.current = [];
}
In the above, when a task is fetched on my tool, the 3 new tabs open but they get closed immediately because i added the close function just below the open. It was added to check the close functionality.
However, i want it to close when i fetch new task. So when a new task is fetched:
let prevWindow = useRef([]);
const openInNewTab = (url) => {
const newWindow = window.open(url, '_blank');
prevWindow.current.push(newWindow);
if (newWindow) newWindow.opener = null
}
...
...
return(
console.log("Previous window before opening new tab is:", prevWindow.current); <<<<<< line 3
if(prevWindow.current.length>0)
{
prevWindow.current.forEach((win,ind)=>{ <<<<<<<<<<<<<<< line 1
win.close();
});
prevWindow.current = [];
}
popUpTabUrlArray.forEach((url,ind) => {
if(url && common.isValidHttpUrl(url))
openInNewTab(url);
})
What i want to achieve with above code is:
What i am seeing here with above code execution is:
The new tabs open as expected but when the next task is fetched and line 1 is executed for win.close(). This error is thrown:
Unsafe attempt to initiate navigation for frame with origin ‘https://www.amazon.co.jp’ from frame with URL ‘http://localhost:3000/abc’. The frame attempting navigation is neither same-origin with the target, nor is it the target’s parent or opener.
Can someone help me with this or suggest an alternative? I tried multiple approaches.
Additional
PREV WINDOW IS: (3) [Window, Window, Window]
Previous window before opening new tab is: (3) [global, global, global]
DOes this global instead of window references has anything to do with the error?
I use Laravel 9 stack with ViteJS and Vue3. Trying to export components from bootstrap-vue-3 0.4.6 package. It is an old version maybe but there is no way to upgrade it because there is a lot of dependencies. Import of modules like BCollapse works but directives doesn’t. So I tried it like:
import {BootstrapVue3, BAlert, BProgress, BButton, BTab, BCarousel, BCarouselSlide, BCollapse, vBToggle} from 'bootstrap-vue-3'
const app = createApp({});
app.use(BCollapse)
app.directive('b-toggle', vBToggle)
And got an error
vue-router.mjs:3451 SyntaxError: The requested module '/node_modules/.vite/deps/bootstrap-vue-3.js?v=6da47c56' does not provide an export named 'VBToggle'
Docs say to do it excact this way https://bootstrap-vue.org/docs/directives/toggle and this export does exist in node_modules/bootstrap-vue-3/dist/BootstrapVue.d.ts
So how to import it properly to use in components like this
<b-card-header header-tag="header" class="p-1" role="tab">
<b-button block v-b-toggle.accordion-1 variant="info">Accordion 1</b-button>
</b-card-header>
This is my package.json
"devDependencies": {
"@popperjs/core": "^2.11.6",
"@vitejs/plugin-vue": "^3.1.0",
"axios": "^0.27",
"bootstrap": "^5.2.2",
"laravel-echo": "^1.14.0",
"laravel-vite-plugin": "^0.6.0",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"sass": "^1.32.11",
"vite": "^3.0.0",
"vue": "^3.2.36"
},
"dependencies": {
"@devindex/vue-mask": "^2.0.3",
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-brands-svg-icons": "^6.2.0",
"@fortawesome/free-regular-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/vue-fontawesome": "^3.0.2",
"@vue/cli": "^5.0.8",
"@vuepic/vue-datepicker": "^3.6.8",
"bootstrap-icons": "^1.10.2",
"bootstrap-vue-3": "^0.4.6",
"moment": "^2.29.4",
"pusher-js": "github:pusher/pusher-js",
"swiper": "^9.0.1",
"unplugin-auto-import": "^0.11.4",
"unplugin-vue-components": "^0.22.9",
"vue-i18n": "^9.2.2",
"vue-image-crop-upload": "^3.0.3",
"vue-loader": "^17.0.0",
"vue-router": "^4.1.5",
"vue3-carousel": "^0.2.9",
"vuex": "^4.0.2",
"vuex-persistedstate": "^4.1.0"
}
I have two select2 fields that are working as dynamic search engine inside a form. I need to clone this form so the user can add multiple entries and filtering inside these two fields that are working as search engine.
HTML:
<div class="form-group">
<label>{% trans "Departure Aerodrome" %}</label>
<select class="form-control adep" name="adep" id="adep">
{% if not base_airport %}
<option disable="">{% trans "Choose one Airport" %}</option>
{% else %}
<option value="{{base_airport.icao_code}}">{{base_airport.icao_code}} - {{base_airport.name}} </option>
{% endif %}
</select>
</div>
<div class="form-group">
<label>{% trans "Arrival Aerodrome" %}</label>
<select class="form-control ades" name="ades" id="ades">
{% if not base_airport %}
<option disable="">{% trans "Choose one Airport" %}</option>
{% else %}
<option value="{{base_airport.icao_code}}">{{base_airport.icao_code}} - {{base_airport.name}} </option>
{% endif %}
</select>
</div>
<div class="col">
<button class="btn btn-primary" id="addFlightBtn">{% trans "Add New Flight" %}</button>
</div>
My form is inside a forloop, so there can be 1 item as many other items. So I initialize the select fields with this function:
$(document).ready(function () {
searchAirports(".adep", "adep-");
searchAirports(".ades", "ades-");
});
function searchAirports(className, idName) {
$(className).each(function (index) {
var id = idName + index;
$(this).attr("id", id);
$("#" + id).select2({
ajax: {
url: "/flight/search_airports",
dataType: "json",
data: function (params) {
return {
search_value: params.term, // search term
};
},
processResults: function (data) {
return {
results: $.map(data, function (obj) {
return {
text: obj.code + " " + obj.name,
id: obj.code,
};
}),
};
},
cache: true,
},
minimumInputLength: 3,
placeholder: gettext("Search for a airport"),
theme: "classic",
tags: true,
templateSelection: function (obj) {
return obj.id;
},
allowClear: true,
});
});
}
Everything works fine. But, if I click on the Add New Flight button, a function is triggered and, basically it clones the form into a new one. The function is this one:
addFlightBtn.addEventListener("click", (e) => {
e.preventDefault();
// creiamo un nuovo form
const newForm = createFlightForm();
// inseriamo il nuovo form nel div "newForm"
const newFormContainer = document.querySelector("#newForm");
newFormContainer.appendChild(newForm);
});
// funzione per creare un nuovo form
function createFlightForm() {
const formContainer = document.querySelector("#formContainer");
// cloniamo il contenuto del div "formContainer"
const newForm = formContainer.cloneNode(true);
// creiamo un bottone "Remove"
const removeBtn = document.createElement("button");
removeBtn.classList.add("btn", "btn-danger", "mt-3");
removeBtn.textContent = "Remove";
removeBtn.addEventListener("click", () => {
// rimuoviamo il form corrispondente quando viene cliccato il bottone "Remove"
newForm.remove();
});
// inseriamo il bottone "Remove" nel form appena creato
newForm.appendChild(removeBtn);
return newForm;
}
What I do know, at the moment, is that I should use the destroy functionality to destroy the select2 element and create a new one, but basically everything I tried so far didn’t work. Is there anybody who had the same situation before and can help me out?
The thing that is getting me hard life, in fact, is to understand how to clone the new select elements, give them another unique id and make them work.
As the title says, all of the code works fine in development. I’m not entirely sure how to explain my problem properly simply because I can’t exactly locate the problem. I would run npm run build which works perfectly fine. But when I put it into production npm run start, it works fine till it needs to fetch data from my API Route Handlers. Both dev and production mode should be essentially the same thing right?
Here’s the errors I’d get:
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11118:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED ::1:3000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 3000
}
}
An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error
I’ve looked around for answers and I found that others are having a similar problem but unanswered for the most part or comments saying to simply get rid of the fetch request from the server component. That’s not exactly ideal to do as I still need to fetch data and fetching data from the client would increase loading time.
Here’s my next.config.js just in case if it helps:
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
onDemandEntries: {
// period (in ms) where the server will keep pages in the buffer
maxInactiveAge: 360 * 1000,
// number of pages that should be kept simultaneously without being disposed
pagesBufferLength: 10,
},
}
module.exports = nextConfig
var codestring;
highlightedcode = hljs.highlightAuto(codestr).value; //using highlight.js for programming language code
letters = codestr.split(”);
…..
$(‘.result’).last().append(letters[i]);
Please help to how to add letters[i] one by one to class result and still keep the color of letter?
Thanks!!!
I have tried many ways: using charAt but not work
I would like to have some instructions here.
When loading my site, Javascript won’t run. The dev tools returns
Loading failed for the <script> with source “https://catchingstardust.github.io/index.js
The code in question:
<script src="/index.js"></script>
Tried disabling add block and adding a typescript.
I have two images.
Can you show how to achieve this.
Thank you stack family.
//This, I can choose to see any of the four options
Image 1
enter image description here
//This one, is a stepwise feature. whereby step one must be completed to access step 2, then 3…4
for image 1: I want it to be like this.
enter image description here
for image 2: I want it to be like this.
enter image description here
I’m exploring PlayWright tool for automating our application suit. It consist of both Web and Windows based applications. so would like to know if I can use PlayWright to automate Standalone Desktop applications? basically these were developed C# and MFC Controls.
Tried Web application it works fine. need to understand if I can use PlayWright to automate Desktop applications.
So let’s imagine I am deserializing JSON into a javascript object at runtime, for instance the body of a REST api response:
const json = await response.json()
Let’s say I expect this object to conform to an interface I have declared:
interface ResponseRecord {
foo: string,
bar: number
}
How can I validate, at runtime, that json is a valid instance of the interface ResponseRecord?
I’m trying to get list of users from string.
What I want:
String: “Hello, @alice”
I got users arr: [“alice”]
My code:
export const getRecepientsArrFromMessage = (value: string): string[] | [] => {
if (value) {
const REGEX = /(^@)([wа-я]|@|.)/gi
return value
.trim()
.split(' ')
.filter((el) => el.length > 0 && REGEX.test(el))
.map((el) => el.slice(1, el.length))
}
return []
}
What I got:
If my string is:
Hello @user1 @user2 @[email protected] @user2 @user1 @user1 @user2
I got users only through one: ['@user1', '@[email protected]', '@user1', '@user2']
What is wrong here?
I tried different variations of the regular expression, but the answer remained the same
Here is the sample code,
let user =
{
fullName: "Guest User"
cart:
[
{
subTotal: 300,
product:
[
{
productName: "apple",
quantity: 3
}
]
},
{
subtTotal: 1000,
product:
[
{
productName: "orange",
quantity: 5
}
]
}
]
}
let store =
[
{
name: 'apple',
stocks: 10
},
{
name: 'apple',
stocks: 10
}
]
then I want to know the correct array methods to use to show the difference of store[index].stocks and user.cart[index].quantity and the result will reflect on store
I just can’t seem to know the right way to access each element in an array especially the nested ones
hope someone can help me.
Thank you in Advance! 🙂