The image will be located on the canvas, to quickly change the picture. Implemented convolution with matrix [0, -1, 0, -1, 5, -1.0, -1, 0]. I can not implement a change in the intensity of sharpening with the help of increasing the mix. Please tell me how to implement it. by using the processing of buffered typed arrays.
Category: javascript
Category Added in a WPeMatico Campaign
How to create a level checker in JS?
I’m facing a problem, let me explain :
- I have 20 levels
- I have users ( id )
I need to check which level is the user. How I do that in my use case :
- I get the ID of the user and I need to check which level he has in order to assign him a special discount.
I can do 20 if(level1.include(id))... but that’s not clean, how could I do that in a better way ?
Best way to pass data back from class to react component?
So I have a react app, I want to include a file for websockets (currently a class) but I want to be able to call things in App from it (when the WS provides messages). I’m looking for something like a react callback prop, but I don’t think using a component is necessary since this class will not render anything.
Whats the best way to implement this?
class App extends React.Component {
constructor() {
super()
this.ws = undefined;
}
sendMessage(data) {
console.log(data)
}
connect = () => {
this.ws = new Websocket();
};
render() {
return <div>
<button onClick={this.connect}>Connect</button>
</div>
}
}
let ws = new WebSocket("ws://localhost:8080/");
export default class Websocket {
componentDidMount() {
ws.addEventListener("message", this.getPosition);
}
componentWillUnmount() {
ws.removeEventListener("message", this.getPosition);
}
giveData = ({data}) => {
//here I want to send the data to sendMessage in App component
};
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
how to submit multiple dropdowns using one button
I am working with Laravel blade. The form has 3 dropdowns, a checkbox, and a date text box. When I submit the form only the date value is retrieved. I know that I must use jQuery for multiple text boxes but I don’t know how to implement it.
<form class="form-group" id="#infoform" method="POST" action="/calender">
{{csrf_field()}}
<div class="form-group">
<div class="card-body">
<h3 class="card-title">Basic Info</h3>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label> Post Type <small class="text-muted"> Academic calender </small></label>
<select id="type" class="select form-select shadow-none" style="width: 100%; height: 36px">
<option value="calender"> Academic calender </option>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label> Publish Date <small class="text-muted"> When the calender will be published </small></label>
<input type="date" class="form-control" name="publishDate" id="publishDate">
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group" id="mark">
<div class="form-check mr-sm-2">
<input type="checkbox" class="form-check-input" id="Featured-News form-control ">
<label class="form-check-label mb-0" for="customControlAutosizing1"> <i class="mdi mdi-pin"></i> Mark as Featured Announcements for </label>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="form-group" id="duration">
<select class="select form-select shadow-none">
<option value="Abu Kir"> 5 day </option>
<option value="Smart Village"> 10 days </option>
<option value="Elalamein"> 15 days </option>
<option value="Other"> Other </option>
</select>
</div>
<button type="button" form="#infoform" class="btn btn-labeled btn-success" onclick="document.getElementById('#infoform').submit();">
<span class="btn-label"><i class="far fa-paper-plane"></i> </span>Publish</button>
</div>
</div>
<div>
</form>
Cannot set environment variables when using Windows Terminal
When I am trying to set environment variables using Windows Terminal with command “set test1=value1” I get no errors but when I try to check all env. variables calling “set” I get the following prompt:
cmdlet Set-Variable at command pipeline position 1
Supply values for the following parameters:
Name[0]:
I read that when using powershell (or its byproducts) you set env. vars using this:
$Env:test1 = "value1";
I want to set the variables so that on my backend in custom-environment-variables.json
I can store a name by which config can extract it using config.get(“test”);
custom-environment-variables.json:
{
"test": "test1",
}
But everytime I try this, it says Error: Configuration property “test” is not defined
Doing the same procedure but in cmd I get no issues whatsoever. Any ideas what might be causing this?
moment.js How to get the exact hour from seconds?
I have a timer in my project, I have time format in seconds 90000 I want to transform seconds in hours and minutes (HH:mm) using moment.js, I wonder how I can get the exact time, if time is less than 86399 moment works as expected, but my aim is to get such a result 25:00, is this possible with moment?
const secs = 90000;
const formatted = moment.utc(secs*1000).format('HH:mm');
document.write(formatted);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
jQuery collapsible div causes white space below main menu on mobile and tablet
I’m a newbie when it comes to almost everything when it comes to building websites. I would be very thankful if someone could point me in the right direction toward a solution to my problem.
I’ve used snippets of jQuery and css in order to create a collapsible section on my site, this is the jQuery:
<!-- javascript för collapsible sections -->
<script type="text/javascript">
jQuery(document).ready(function() {
// Hide the div
jQuery('#reveal').hide();
jQuery('.rv_button').click(function(e){
e.preventDefault();jQuery("#reveal").slideToggle();
jQuery('.rv_button').toggleClass('opened closed');
jQuery('.opened').html('Stäng');
jQuery('.closed').html('Ladda fler');
});
});
</script>
This is the css:
/* css för collapsible section*/
.rv_button.closed:after {content:"33";}
.rv_button.opened:after{content:"32";}
The section is closed when you first enter the site. When you press a button, you reveal more content.
On laptop it works fine. On mobile and tablet however, it leaves a white space just below the main menu after you’ve activated the collapsed section. Like this:
This is the website: https://www.principcasino.se
I need help in flutter installation
I am trying to install flutter and android studio,
I have also seen several tutorials on youtube but even if I carry out the same steps I always get the same two errors.
These are the mistakes:
Android toolchain – develop for Android devices (Android SDK version 32.1.0-rc1)
X cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
I have already downloaded the cmdline through android studio and changed different paths but even doing so it doesn’t keep me going.
while for the licenses it tells me that I have to install the cmdline first.
so it brings me back to the first mistake
help me please
Is there any way to get the request made, instead of the response?
In the geolocator API, the function navigator.geolocation.getCurrentPosition() sends a POST request to the Google geolocator API, with the following json body:
{
"wifiAccessPoints":[
//insert the listening access points here
]
}
What I want is not the response from the API, but instead this JSON in the request it made. Is there any way to save this request in a variable? Or will I have to intercept it with a proxy?
Unable to select text in resizable grid
I need to have Ext.panel.Grids (v6.2.0) that are both resizable and allow users to select the cell values.
I have a bunch grids that I’ve set to be resizable with:
resizable: {
pinned: true,
handles: 's'
}
the problem now, even with overrides on the Table view…
Ext.override(Ext.view.Table, {
enableTextSelection: true
})
… I can no longer select the text within the grids. If I remove the resizing the grids allow me to select the record values to copy and paste later.
I’ve tried overriding the column’s enableTextSelection, too, but that still didn’t work.
Как поместить в переменную данные из нескольких вложенных массивов и объектов?
У меня есть массив shop, в который встроен массив displayAssets.
Мне надо из массива shop получить значения по ключам:
const {mainId, displayName, displayDescription, price, full_background}.
Проблема в том что я не могу из массива displayAssets получить
ссылку по ключу full_background.
Обращаясь к массиву shop, я получаю ключ full_background.
Но дальше:
console.log (shop[1]) // undefined, console.log(shop[“displayAssets”]) // undefined, console.log(shop.displayAssets)// undefined
const shop = [
{
"mainId": "CID_503_Athena_Commando_F_TacticalWoodlandFuture",
"displayName": "Recon Ranger",
"displayDescription": "Expert field intel ranger. ",
"displayType": "Outfit",
"mainType": "outfit",
"offerId": "v2:/6f7d47a2e6083acee98b562185341e7fb4116982a130588009c635d69ac4a360",
"displayAssets": [
{
"displayAsset": "DAv2_CID_503_F_TacticalWoodlandFuture",
"materialInstance": "MI_CID_503_F_TacticalWoodlandFuture",
"url": "https://media.fortniteapi.io/images/displayAssets/v2/DAv2_CID_503_F_TacticalWoodlandFuture/MI_CID_503_F_TacticalWoodlandFuture.png",
"flipbook": null,
"background": "https://media.fortniteapi.io/images/cosmetics/8923a07422e55406ab361357f7a20707/v2/MI_CID_503_F_TacticalWoodlandFuture/background.png",
"full_background": "https://media.fortniteapi.io/images/cosmetics/8923a07422e55406ab361357f7a20707/v2/MI_CID_503_F_TacticalWoodlandFuture/info.en.png"
}
],
"firstReleaseDate": "2019-08-17",
"previousReleaseDate": "2022-01-29",
"giftAllowed": true,
"buyAllowed": true,
"price": {
"regularPrice": 800,
"finalPrice": 800
},
"rarity": {
"id": "Uncommon",
"name": "UNCOMMON"
},
"series": null,
"banner": null,
"offerTag": null,
"granted": [
{
"id": "CID_503_Athena_Commando_F_TacticalWoodlandFuture",
"type": {
"id": "outfit",
"name": "Outfit"
},
"name": "Recon Ranger",
"description": "Expert field intel ranger. ",
"rarity": {
"id": "Uncommon",
"name": "UNCOMMON"
},
"series": null,
"images": {
"icon": "https://media.fortniteapi.io/images/8923a07422e55406ab361357f7a20707/transparent.png",
"featured": "https://media.fortniteapi.io/images/8923a07422e55406ab361357f7a20707/full_featured.png",
"background": "https://media.fortniteapi.io/images/cosmetics/8923a07422e55406ab361357f7a20707/v2/background.png",
"icon_background": "https://media.fortniteapi.io/images/cosmetics/8923a07422e55406ab361357f7a20707/v2/icon_background.png",
"full_background": "https://media.fortniteapi.io/images/cosmetics/8923a07422e55406ab361357f7a20707/v2/info.en.png"
},
"video": null,
"audio": null,
"gameplayTags": [
"Cosmetics.Source.ItemShop",
"Cosmetics.Set.AdvancedForces",
"Cosmetics.Filter.Season.10",
"SoundLibrary.ID.StepType.BootsCombat",
"SoundLibrary.ID.ClothingType.GearTactical",
"SoundLibrary.ID.HandType.Glove"
],
"set": {
"id": "AdvancedForces",
"name": "Advanced Forces",
"partOf": "Part of the Advanced Forces set."
}
}
],
"priority": -1,
"section": {
"id": "Featured",
"name": "Featured",
"landingPriority": 70
},
"groupIndex": 0,
"storeName": "BRWeeklyStorefront",
"tileSize": "Normal",
"categories": [
"Panel 01"
]
},
]
function using initial state object instead of using the updated state react
this is my first question, so basically i’ve a notification object and I’ve attached a firebase onValue listners which fires the handleNotification function everytime a new value is being added, problem is that the handleNotification fn is not using the updated notification state
const [notification, setNotification] = useState({
id: '',
total: '',
lastTotal: '',
count: '',
});
const handleNotification = (channelId, snap, notification) => {
console.log('notification before -------', notification);
if (notification.id === '') {
let obj = {
id: channelId,
total: snap.size,
lastKnownTotal: snap.size,
count: 0,
};
setNotification({ ...obj });
return console.log('notification after -------', notification);
}
// the above if statement runs even when notification.id is already populated, the below code should run instead of that
let obj2 = {
...notification,
};
if (snap.size - obj2.total > 0) {
setNotification((prev) => ({ ...prev, count: snap.size - obj2.total }));
}
};
useEffect(() => {
const unsubscribe = onValue(
ref(db, 'messages' + '/' + channel.id),
(snap) => {
if (channel) {
handleNotification(channel.id, snap, notification);
} else {
console.log('////');
}
}
);
return () => {
unsubscribe();
};
}, []);


html special character conversions of ‘&’ into ‘amp;’ issue
So I have an array that is used to swap the values of a keyboard app Im building on a click of a button. It works perfectly but in the text field when ‘&’ is selected it shows on screen as ‘amp;’ how do I get around this ?
in my HTML I have an input and
<textarea
name="text"
id="textIn"
class="textbox"
></textarea>
<button>Swap<button>
<div class="row k2">
<div class="key">q</div>
<div class="key">w</div>
<div class="key">e</div>
<div class="key">r</div>
<div class="key">t</div>
<div class="key">y</div>
<div class="key">u</div>
<div class="key">i</div>
<div class="key">o</div>
<div class="key">p</div>
</div>
and in javascript my code I have this event listener:
fucntionalKey.forEach((funcKey) => {
funcKey.addEventListener("click", () => {
if (funcKey.classList.contains("shift")) {
const k2 = Array.from(document.querySelector(".k2").children);
// k2
const shiftK2 = ["-", "/", "_", ":", ";", "(", ")", "$", "&", "@", '"'];
const copyK2 = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"];
if (k2[0].innerHTML === "q") {
k2.map((key, index) => {
key.innerHTML = shiftK2[index];
});
} else if (k2[0].innerHTML === "-") {
k2.map((key, index) => {
key.innerHTML = copyK2[index];
});
}
})}});
so this function when any key in that div is clicked it adds the value/innerHTML into the textArea’s value and appears on screen. Then when the swap button is clicked it swaps the values of the innerHTML with the shiftcopy. Everything works as intended until I click ‘&’ in the textArea it appears as ‘amp;’ and it I need it to just appear as ‘&’. Any help would be appreciated and I hope this repost makes a bit more sense.
Capture and Remove URL segment in custom JS – GTM
I need a custom JS variable for GTM that excludes everything from “/p/” until the end or the next “/”, what happens first.
The url after the /p/ can be anything, any length, and have nothing afterwards.
Before:
- hostname/category/brand/some-snicker-model/p/NIBQ5448001
- hostname/campaign/some-snicker-model/p/AB434222/?device=type
After:
- hostname/category/brand/some-snicker-model
- hostname/campaign/some-snicker-model/?device=type
TSQL to generate the dynamic SQL statement before execution
If I have a list of column names a,b,c is it possible to generate a SQL statement as string (to be executed inside EXEC as a dynamic SQL) based on the number of items in that column names.
So, if I have a table called @src
DECLARE @src AS TABLE
(
list VARCHAR(max)
)
INSERT INTO @src
SELECT 'a'
UNION
SELECT 'b'
UNION
SELECT 'c'
SELECT *
FROM @src
how can I generate a string dynamically for each element in @src to give a string a,b,c
which will be further utilized inside a EXEC statement like EXEC('select'+a,b,c(coming from dynamic string)+'from mainTbl
To better demonstrate this with a javascript string generator
var src = ['a','b','c'];
var target =['e','f','g'];
var beginning ='select';
var end = 'from mainTbl';
var newArray=[];
src.forEach((x,i,r)=>{newArray.push(x+' '+'as '+target[i]);});
var dynamicStr = beginning+' '+newArray.reduce(function(prev,current){return prev+', '+current;})+' '+end; //to be utilized inside SQL EXEC
This is in javascript but is it possible for TSQL to generate this string for each element of @src so that whenever I edit @src the final result dynamically changes.
