I have a fullcalendar in which i’m using a jquery timepicker.
On event click i need to take the start properties (example: “Wed May 04 2022 11:30:00 GMT+0200 (Ora legale dell’Europa centrale)”) but using the substring to only have HH:MM.
I tried doing: “var x= info.event.end.substring(16, 21);” but when i click an event this error occure: “Uncaught TypeError: info.event.end.substring is not a function”
How can i fix this?
Category: javascript
Category Added in a WPeMatico Campaign
Cannot use import statement outside a module when importing firebase in nodejs
I tried to import firebase in my NodeJS project as following
const {Builder, Browser, By, Key, until} = require('selenium-webdriver');
const fs = require('fs');
const Axios = require('axios');
import { initializeApp } from 'firebase/app';
I got an error
SyntaxError: Cannot use import statement outside a module
Construct a div in the shape of text selection to overlay a fake highlight over the text
I want to make a fake highlight divs in the shape of selected text. I tried Rangy but what it does is wrap the selection with span. But I don’t want to touch the HTML, I just want to overlay it with a new div/span in the shape of the selection.
Here is the end goal.
As you can see in the above image the two lines of text are highglighted with two divs.
How I get the year of a date? [closed]
I want to get the year to this of this date:
let birth_date = "2000-09-19T22:00:00.000Z"
I try to split the date with this.
const [birthDateYear] = birth_date.split('-');
But I have the following error:
const [birthDateYear] = birth_date.split('-');
^
TypeError: birth_date.split is not a function or its return value is not iterable
How can I get only the year?
I am working with wordpress, php, javascript and Flow-Flow Lite pluggin. How do I automate an existing javascript function
I am working Flow-Flow Lite pluggin to get facebook and instagram data. How do I automate an existing javascript function in the wordpress pluggin so that it runs every 24 hours?
right now it’s a manual process to clear the feed cache which needs to be done every 24-48 hours.
the path to the pluggin is:
wp-content/plugins/flow-flow-social-streams/js/admin.js
and the function near line 4118, as of the date of this post, looks like this:
resetFeedCache: function (e) {
var $t = $(e.target);
var uid = $t.closest('[data-uid]').attr('data-uid');
var changed = this.model.get('feeds_changed');
var feeds = this.model.get('feeds');
changed[ uid ] = _.clone( feeds[ uid ] );
changed[ uid ][ 'state' ] = 'reset_cache';
this.saveViaAjax();
},
I am also open to suggestions for well maintained automation plugins.
How to resolve Render Error while using react-native-skia
I am getting this error even when I have copy pasted the code from the documentation on the website
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.
Here’s the code :
import {Canvas, Box, BoxShadow, Fill, rrect, rect} from "@shopify/react-native-skia";
export const App = () => (
<Canvas style={{ width: 256, height: 256 }}>
<Fill color="#add8e6" />
<Box box={rrect(rect(64, 64, 128, 128), 24, 24)} color="#add8e6">
<BoxShadow dx={10} dy={10} blur={10} color="#93b8c4" inner />
<BoxShadow dx={-10} dy={-10} blur={10} color="#c7f8ff" inner />
<BoxShadow dx={10} dy={10} blur={10} color="#93b8c4" />
<BoxShadow dx={-10} dy={-10} blur={10} color="#c7f8ff" />
</Box>
</Canvas>
);
how to pass id for get data from api with axios.post?
I have the first two URL requests for the first page, the second to get the data of each item on the firstpage, and according to the image below in my postman, how to send the ID of each item with Axios.Post and display its data on the single page?
how to pass id in RequestID in raw?
firstPage.vue
<template>
<div class="articles">
<h2>featured articles</h2>
</div>
<div class="article-container">
<div class="article-grid" v-for="data3 in datas3" :key="data3.ContentID" >
<router-link to="/content" @click="getContent" >
<img :src="data3.LandscapeImage">
<div class="article-title">
<p>{{data3.Properties[5].Value}}</p>
<h3>{{data3.Title}}</h3>
</div>
</router-link>
</div>
</div>
<div class="number-container">
<a class="previous" href="">« <span>previous</span></a>
<a href="">1</a>
<a href="">2</a>
<a href="">3</a>
<a href="">4</a>
<a href="">...</a>
<a href="">10</a>
<a class="next" href="#"> <span>next</span> »</a>
</div>
</template>
<script>
export default {
name : "ThirdSection",
props : ['datas3'],
}
????
</script>
singlePage.vue
<template>
<div class="content">
<div class="content-sidebar">
<SideBar />
</div>
<section class="main-content">
<div class="content-container">
<div class="content-img"> <img src="" alt=""></div>
<div class="content-text" >
<h2></h2>
<p></p>
</div>
</div>
</section>
</div>
</template>
<script>
import SideBar from '../../components/Sidebar.vue'
export default {
components :{
SideBar
},
</script>
how to show data each items in single page ?
Should I be economical with JS-events at table cell level?
I’m interested in an opinion from a performance perspective:
If I have a table in which I want to react to table-cell events, is it better to put the event on the table-element and handle cell specific events with the help of i.e. closest("td"), or is it ok to put the event on the table cell? (I’m talking about tables with a large number of cells, all of which are visible.)
Define context of JS script in IntelliJ IDEA/WebStorm
I use IntelliJ to write JS scripts that are executed in an environment where several context variables are set implicitly, e.g. embeddingPage.
But IntelliJ does not know about the context so it marks these variables as unknown:
Unresolved variable or type embeddingPage
Additionally the script execution requires to return a config object at the end that the IDE complains about:
'return' outside function definition
Is there a way to make the context known to the IDE without breaking the execution of the script?
Getting error while running electronjs app
I am trying to run electron.js app but i am getting some error while running the application.
So, please help me to sort out this guys. I have attached the shot for your reference.
How to integrate Materialize’s modal in Navigation Bar?
I am currently working on a project using Materialize CSS where a popup login portal will appear overlaying the home screen after clicking the login button located in the navigation bar.
The issue is that the modal does not appear when I am trying to click the login button. Others suggest to include the JavaScript code for the Materialize modal which I did but it still does not work. I was hoping to ask if the issue lies with how the <div> tags is enclosed within the <ul> tags or I have overlooked something.
Below is the code I used and the design of the application:
nav.hbs
<nav>
<div class="nav-wrapper">
<a href="#" class="brand-logo">
<img src="/imgs/logo-white.png" width="200px" height="50px">
</a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li>
<a class="waves-effect waves-light btn modal-trigger" href="#modal1">Login</a>
</li>
<!-- Modal Structure -->
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Modal Header</h4>
<p>A bunch of text</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Agree</a>
</div>
</div>
</ul>
</div>
</nav>
<script type="text/javascript">
$(document).ready(function () {
$('#modal1').modal();
});
</script>
How to pass order ID to Paypal Button?
I create an order by my php sdk.
like this
……
……
$result = json_decode((string) $response->getBody());
echo $result->id; // id of the created order
and now i have this order id.
but … How to pass order ID to Paypal Button?
like this
`paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) { //I don't need create order,I have created an order
return actions.order.create({
purchase_units: [{
amount: {
value: '88.44'
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Successful capture! For demo purposes:
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
var transaction = orderData.purchase_units[0].payments.captures[0];
alert('Transaction '+ transaction.status + ': ' + transaction.id + 'nnSee console for all available details');
// Replace the above to show a success message within this page, e.g.
// const element = document.getElementById('paypal-button-container');
// element.innerHTML = '';
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
}
}).render('#paypal-button-container');`
I was creating an simon game using javascript but i got an error on console:
Please give me the solution for this code
I was creating an simon game using javascript but i got an error on console:
The error: Uncaught ReferenceError: randomChosenColour is not defined
at game.js:3:20
(anonymous) @ game.js:3
index.html file code:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Simon</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet">
</head>
<body>
<h1 id="level-title">Press A Key to Start</h1>
<div class="container">
<div lass="row">
<div type="button" id="green" class="btn green">
</div>
<div type="button" id="red" class="btn red">
</div>
</div>
<div class="row">
<div type="button" id="yellow" class="btn yellow">
</div>
<div type="button" id="blue" class="btn blue">
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="game.js"></script>
</body>
</html>
game.js code:
var buttonColours = ["red", "blue", "green", "yellow"];
var gamePattern = [randomChosenColour];
function nextSequence(params) {
var randomNumber = Math.floor(Math.random() * 4);
var randomChosenColour = buttonColours[randomNumber];
gamePattern.push(randomChosenColour);
}
Chrome Extention: Uncaught TypeError: Cannot set properties of undefined (setting ‘innerHTML’)
I’m trying to edit a place on a website to show text.
I’ve tried it in the websites console and it all works.
I get this error
Uncaught TypeError: Cannot set properties of undefined (setting ‘innerHTML’)
popup.js
let AnswerButton = document.getElementById("AnswerButton");
function ShowAnswers(answers) {
var ans = JSON.parse(answers)
var i = 0
let answersString = ""
ans.props.multiChoice.forEach(answer => {
answer.options.forEach(fanswer => {
if (fanswer.correct == 1) {
i += 1
answersString += `<p>[${i}] ${fanswer.option}</p>`
}
})
})
const collection = document.getElementsByClassName("text-gray-500 text-base");
collection[2].innerHTML = answersString
}
AnswerButton.addEventListener("click", () => {
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
var pathArray = tabs[0].url.split('/');
var QuizNum = pathArray[5]
if (tabs[0].url == `https://www.elearneconomics.com/student/multi-choice/${QuizNum}`) {
var url = `https://www.elearneconomics.com/student/multi-choice/${QuizNum}`;
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("authority", "www.elearneconomics.com");
xhr.setRequestHeader("method", "GET");
xhr.setRequestHeader("path", `/student/multi-choice/${QuizNum}`);
xhr.setRequestHeader("scheme", "https");
xhr.setRequestHeader("accept", "text/html, application/xhtml+xml");
xhr.setRequestHeader("accept-language", "en-US,en;q=0.9,ja-JP;q=0.8,ja;q=0.7");
xhr.setRequestHeader("content-type", "application/json;charset=utf-8");
xhr.setRequestHeader("x-inertia", "true");
xhr.setRequestHeader("x-inertia-version", "17fd9f7cedd585a570d50ad58164bdf6");
xhr.setRequestHeader("x-requested-with", "XMLHttpRequest");
xhr.setRequestHeader("x-xsrf-token", "Some Token");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
chrome.scripting.executeScript(tabs.id, { function: ShowAnswers(xhr.responseText) });
document.getElementById("Answers").innerHTML = "Scroll Down ;)";
}
};
xhr.send();
} else {
alert("Goto a multichoice section!")
}
});
});
Thanks in advance for helping.
How to loop through an object of arrays in Javascript?
For the below code,
const groupbysubject = {
"Mathematics":
[
{totalStudents: "23", average: "78", class: "2"},
{totalStudents: "25", average: "80", class: "3"}
],
"English":
[
{totalStudents: "33", average: "98", class: "2"},
{totalStudents: "35", average: "99", class: "3"}
],
"Science":
[
{totalStudents: "43", average: "65", class: "2"},
]
}
var isEnglishPresent = Object.fromEntries(
Object.entries(groupbysubject).filter(
([key, val])=> key.includes("English")
)
);
I want the following output :
“33”
“98”
“2”
“35”
“99”
“3”
I have filtered the above groupbysubject object into isEnglishPresent object.
How do I proceed further to iterate over isEnglishPresent and get the above output.
Please help
Thank you.


