i’m trying to make a function that works like this :
let elm = document.querySelector('section')
elm.gridify();
assuming the function gridify adds display: grid; to the element
My question is : Is that possible, and if so, how ?
Thanks !
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
i’m trying to make a function that works like this :
let elm = document.querySelector('section')
elm.gridify();
assuming the function gridify adds display: grid; to the element
My question is : Is that possible, and if so, how ?
Thanks !
witout click
<button type="button" class="plyr__control" data-plyr="play" aria-label="Play">
After click
<button type="button" class="plyr__control plyr__control--pressed" data-plyr="play" aria-label="Pause">
my javascript
const $featured =$('button.plyr__control').hasClass('plyr__control--pressed');
$featured.on('change', function() {
console.log('ok');
});
this player.js
player.on('play', event => {
$('a[data-link].active, a[data-playlist].active').addClass('play');
$('a[data-link].active, a[data-playlist].active').removeClass('pause');
});
player.on('pause', event => {
$('a[data-link].active, a[data-playlist].active').removeClass('play');
$('a[data-link].active, a[data-playlist].active').addClass('pause');
});
how to solve this problem.
how to solve this problem.how to solve this problem.how to solve this problem.how to solve this problem.
I am using a project that uses gatsby and react both. To do its setup I run npm install and then npm run develop. It gets stuck at this step all the time. How should I resolve this issue, I am new with gatsby.
Peace my friends
so i have an component in react which contains of approx. 12 constants like the following:
const postsOffCountry = <td>{props.posts.map((post => {return <input key={post.ref} defaultValue={post.oland} className={post.ref}
onBlur={(event) => props.variables.setOffCountry(event.target.value)}></input>}))}</td>;
and im rendering them like following:
return (
<>
<tbody>
<tr onClick={(e) => console.log(e.target.value)}>
<td>{postsRef}</td>
<td>{postsOpInf}</td>
<td>{postsState}</td>
<td>{postsInf}</td>
{/* <td>{postsLoadingDate}</td> */}
<td>{postsLoadingCountry}</td>
<td>{postsLoadingZip}</td>
<td>{postsLoadingCity}</td>
{/* <td>{postsOffDate}</td> */}
<td>{postsOffCountry}</td>
<td>{postsOffZip}</td>
<td>{postsOffCity}</td>
<td>{postsCustomerClearence}</td>
<td>{postsPalNumber}</td>
<td>{postsOrganiser}</td>
<td>{postsUpdateButton}</td>
<td>{postsMailButton}</td>
</tr>
</tbody>
</>
);
my problem is how can i select all the values of the input fields and set them to their correct useState variable which is passed over from the parentcomponent with props. (e.g. props.variables.setOffCity());
i have been stuck on this for days now any help would be highly appreciated!
I created a typescript project, that is run with Deno. Unfortunately all of the imports have to be defined with the full filename with .ts at the end, like:
import { MyClass } from "./my-class.ts"
That worked with deno run, but now I want to compile it with tsc to the web, and I get this error:
An import path cannot end with a '.ts' extension. Consider importing './my-class' instead.
How is it possible to solve it? How to keep using Deno while compiling some of the files with tsc as well? I need to run it in the browser.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
#filee{
visibility: hidden;
}
</style>
</head>
<body>
<input type="file" name="" id="filee">
<button onclick= "ftn()" id="btn">Choose a File</button>
<span id="filename"></span>
<script type="text/javascript">
let file = document.getElementById('filee');
let btn = document.getElementById("btn");
let filename = document.getElementById("filename");
function ftn(){
file.click();
let value = file.value;
filename.innerText = value;
}
</script>
</body>
</html>
This is my code. I’m getting value when i clicked button 2nd time. I want a value in span tag of my file when i click on button and open it. This giving value when i clicked again a button and show me previous value of file. Thanks if you get my point
So, I hope this makes sense. I’m new to script writing but know a few specific bits. I’m hoping to write a script that will allow me to copy data from a range and then paste it to specific rows based off an index. So I want the script to search down what would be column F on the link below, find the relevant index number to the first row of data in column A from row 11 downward, then copy the values from columns C and D (goals and assists) and paste it to that relevant row, then do the same for the second row, third etc. till all the “copy data” has been transferred over. This is a small version of what I’m using it for, the real data has 524 rows and 11 columns which is why I’m opting for a script over google sheet formulas, as they appeared to slow down the whole sheet with all those formulas.
https://docs.google.com/spreadsheets/d/1WucSaB3zm7bhCkRTdVe03CtZOu06NS7UNAeLC83E5xw/edit#gid=0
Any help would be greatly appreciated!
This is the apiCall where i am calling my api
export const getProducts = async (dispatch) => {
dispatch(getProductStart());
try {
const res = await publicRequest.get("/products");
dispatch(getProductSuccess(res.data));
} catch (err) {
dispatch(getProductFailure());
}
};
i had also updated the store.js
import { configureStore, combineReducers } from "@reduxjs/toolkit";
import userReducer from "./userRedux";
import productReducer from "./productRedux";
import {
persistStore,
persistReducer,
FLUSH,
REHYDRATE,
PAUSE,
PERSIST,
PURGE,
REGISTER,
} from "redux-persist";
import storage from "redux-persist/lib/storage";
const persistConfig = {
key: "root",
version: 1,
storage,
};
const rootReducer = combineReducers({
user: userReducer,
product: productReducer,
});
const persistedReducer = persistReducer(persistConfig, rootReducer);
export const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
},
}),
});
export let persistor = persistStore(store);
here in productsList.js i am using getProducts but while i am doing it is not showing me any data and when i am doing console.log(products); it is responding me an empty array
here is my productList.js file
import "./productList.css";
import { DataGrid } from "@material-ui/data-grid";
import { DeleteOutline } from "@material-ui/icons";
import { Link } from "react-router-dom";
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { getProducts } from "../../redux/apiCalls";
export default function ProductList() {
const dispatch = useDispatch();
const products = useSelector((state) => state.product.products);
console.log(products);
useEffect(() => {
getProducts(dispatch);
}, [dispatch]);
const handleDelete = (id) => {
//to be handeled
};
const columns = [
{ field: "_id", headerName: "ID", width: 220 },
{
field: "product",
headerName: "Product",
width: 200,
renderCell: (params) => {
return (
<div className="productListItem">
<img className="productListImg" src={params.row.img} alt="" />
{params.row.title}
</div>
);
},
},
{ field: "inStock", headerName: "Stock", width: 200 },
{
field: "price",
headerName: "Price",
width: 160,
},
{
field: "action",
headerName: "Action",
width: 150,
renderCell: (params) => {
return (
<>
<Link to={"/product/" + params.row._id}>
<button className="productListEdit">Edit</button>
</Link>
<DeleteOutline
className="productListDelete"
onClick={() => handleDelete(params.row._id)}
/>
</>
);
},
},
];
return (
<div className="productList">
<DataGrid
rows={products}
disableSelectionOnClick
columns={columns}
getRowId={(row) => row._id}
pageSize={8}
checkboxSelection
/>
</div>
);
}
i had also checked the data base there is proper amount of data available to be fetched during thunder client fetching the is fetched properly and here is my productsRedux.js file
import { createSlice } from "@reduxjs/toolkit";
export const productSlice = createSlice({
name:"product",
initialState:{
products:[],
isFetching:false,
error:false,
},
reducers:{
//GET ALL
getProductStart:(state)=>{
state.isFetching= true;
state.error=false;
},
getProductSuccess:(state,action)=>{
state.isFetching= false;
state.error=action.payload;
},
getProductFailure:(state)=>{
state.isFetching= false;
state.error= true;
},
},
});
export const { getProductFailure,getProductStart,getProductSuccess
} = productSlice.actions;
export default productSlice.reducer;
Whenever i clicked on button url is change but content doesn’t change and one more thing if i use <a> tag in exchange of <Link> tag then obviously page loading but content also load and update
but using <Link> tag it is not load data but url value is update so, please give me a solution for this
Thanks in advance
App.js
import "./App.css";
import "../node_modules/bootstrap/dist/css/bootstrap.css";
import Home from "./component/pages/Home";
import Contect from "./component/pages/Contect";
import About from "./component/pages/About";
import Navbar from "./component/layout/Navbar";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import React from "react";
function App() {
return (
<Router>
<Navbar title="title1" />
<Switch>
<Route exact path="/Contect" component={Contect}></Route>
<Route exact path="/" component={Home}></Route>
<Route exact path="/About" component={About}></Route>
</Switch>
</Router>
);
}
export default App;
Navbar.js
import React from "react";
import { Link } from "react-router-dom";
import {} from "react-router-dom";
const Navbar = (props) => {
return (
<nav class="navbar navbar-expand-lg navbar-light bg-dark">
<div className="container">
<Link class="navbar-brand bg-light" to="/contect">
{props.title}
</Link>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon "></span>
</button>
<div class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<Link class="nav-link bg-light" to="/">
Home
</Link>
</li>
<li class="nav-item active">
<Like class="nav-link bg-light" to="/About">
About
</Like>
</li>
</ul>
</div>
</div>
</nav>
);
};
export default Navbar;
Home.js
import React from "react";
const Home = () => {
return (
<>
<div className="container">
<div className="py-4">
<h1> Home page </h1>
</div>
</div>
</>
);
};
export default Home;
About.js and Contect.js is same as Home.js
I was exploring the internet when i came across this ENCRYPTED code.
I was curious to know which JS obfuscator or JS encyption mechanism they guys are using.
Here is the sample of the code.
function _0x5f46ac(_0x50cc87,_0x1c200e,_0x100366,_0x2dda23){return _0x5212(_0x50cc87-0x39c,_0x100366);}(function(_0xa4ca41,_0x440997){function _0x422ba6(_0x381c9e,_0x20446f,_0x2082c3,_0x9f802b){return _0x5212(_0x20446f-0x3dd,_0x381c9e);}const _0x1e3da0=_0xa4ca41();function _0x3f6d35(_0x121773,_0x427dc1,_0x4791b5,_0x379f12){return _0x5212(_0x4791b5-0x179,_0x427dc1);}while(!![]){try{const _0x3c3c3a=parseInt(_0x3f6d35(0x2eb,0x303,0x2f8,0x322))/(-0x1121+-0x2139+-0x325b*-0x1)+parseInt(_0x422ba6(0x58e,0x590,0x557,0x597))/(0xe5*-0xb+-0xc62+-0x163b*-0x1)*(parseInt(_0x3f6d35(0x389,0x331,0x35c,0x359))/(-0x356*0x2+0x2267+-0x1bb8))+-parseInt(_0x3f6d35(0x331,0x379,0x355,0x351))/(-0xc4d+-0x1*
Complete code is present in the cdn here . https://cdn.jsdelivr.net/gh/SagarVishnoi/HOB@main/CanvagenbyFineshop.js
I Will be really thankful to you if you if tell me which JS Obfuscator or JS encryption mechanism they are using.
im new to javascript and i just finished some video in youtube about it. so anyways i got a percentage bar what i want to do about it is its changes every 30minute randomly and i dont know how to figure it out
<script>var x=[0,106,69,33,1119,1474,585,1062,714,1038,1241,1091,218,403,132,1302,1027,1108,385,317,564,399,475,621,109,602,217,893,581,274,321,435,741,662,846,277,1,776,103,336,856,830,198,843,187,10,409,848,583,885,402,200,929,816,454,424,587,72,488,269,238,958,772,185,959,685,966,889,403,629,126,166,368,391,492,142,710,503,850,996,363,588,633,293,936,960,268,491,514,41,833,948,582,709,239,341,182,191,48,32,908,540,144,110,632,141,729,522,859,954,184,286,586,845,779,866,573,74,924,786,911,768,143,157,676,446,70,120,518,490,783,222,389,225,34,450,910,873,725,324,311,963,177,558,876,65,903,2,271,305,234,146,826,92,80,533,96,136,122,969,314,323,722,457,379,838,909,809,626,704,767,90,683,447,281,357,438,825,366,991,914,962,794,61,414,670,60,349,874,753,232,527,3,27,721,350,374,917,218];for(let i=1;i<=181;i++){const d=new Date();var date=d.getUTCDate();var day=d.getUTCDay()+1;var year=d.getUTCFullYear();var month=d.getUTCMonth()+1;var hour=d.getUTCHours();var min=d.getMinutes();if(min<30){min=1;}else{min=2;}
var xx=day+yearmonthdate;xx=Math.pow(xx,hourmin);xx=xxx[i];if(i==5||i==6||i==2||i==114||i==73||i==41||i==4||i==92||i==134||i==10||i==78||i==66){xx=xx%27;xx+=65;}else{xx=xx%83;xx+=8;}
const as=”percent-bar-“+i;const asd=”percent-txt-“+i;var percentTxt=document.getElementById(“percent-txt-“+i);var bar=document.getElementById(“percent-bar-“+i);const bartext=document.getElementById(“card-title”+i);percentTxt.innerHTML=xx+”%”;$(“#percent-bar-“+i).attr(“aria-valuenow”,xx).css(“width”,xx+”%”);if(xx<30){bar.classList.add(“red”);}else if(xx>70){bar.classList.add(“green”);}else{bar.classList.add(“yellow”);}}
46%
How to get information using the users method.get using node-vk-bot-api? I don’t understand how to work with execute. Why am I getting Promise { Pending }?
const token = "";
const VkBot = require("node-vk-bot-api"),
bot = new VkBot(token);
let id = msg.message.from_id
const response = bot.execute('users.get', {user_ids: id});
console.log(response) --> Promise { <pending> }
or
let id = msg.message.from_id
const api = require('node-vk-bot-api/lib/api');
let user = api('users.get', { user_ids: id, access_token: token });
console.log(user) --> Promise { <pending> }
C:Userssharmcodewebeth-to-do-list>npm run dev
npm WARN config global --global, --local are deprecated. Use --location=global instead.
[email protected] dev
lite-server
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module ‘./dist/rx’
Require stack:
I’ve gone over most other posts about this subject.
It seems that, everyone, has their own unique problem for their own unique implementation of the “Canvas topdown game”.
That makes it really hard finding a solution for your problem without refactoring your whole code.
So hopefully you guys will be able to help me this time.
Simple game (so far) – utilizing Vue3 btw but that’s besides the point – most of the code is just Vanilla stuff.
Simple topdown map.
X and Y Axis
What I’m doing in my implementation is taking a PNG I’ve created with the Tiled application
Zoomed in by about 400% – drawing it with ctx.drawImage
then I’m also setting boundaries
and then drawing the player
what I’m doing now is adding a “force” value to the x and y position on key pressed (WASD)
Which means the character moves on the map and collision detection works
what I want is the map to draw x amount of pixels based on where the character is positioned WITHOUT moving the map since I’m already implementing some SocketIO code to make this multiplayer
I’m really really lost here, not sure what I should be doing to make the map draw a viewport….
I hope some of this makes sense
Some code
function create() {
const canvas: HTMLCanvasElement = document.getElementById("game") as HTMLCanvasElement;
if (!canvas) return console.error("canvas is undefined");
const ctx: CanvasRenderingContext2D = canvas.getContext("2d") as CanvasRenderingContext2D;
ctx.imageSmoothingEnabled = false;
initializeGameWindow(canvas, ctx);
setEvents(canvas, ctx);
const playerSpriteWidth = 192;
const playerSpriteHeight = 68;
const spriteFrames = 4;
background = new Sprite();
player = new Sprite();
update(canvas, ctx);
}
function update(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D) {
window.requestAnimationFrame(() => update(canvas, ctx));
drawGame(canvas, ctx);
}
function drawGame(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D) {
background.draw(ctx);
boundaries.forEach((boundary) => {
boundary.draw(ctx);
});
player.value.draw(ctx);
let moving: boolean = true;
player.value.moving = false;
if (keys.w.pressed && lastKey.value === "w") {
player.value.moving = true;
player.value.image = player.value.sprites.up;
for (let i = 0; i < boundaries.length; i++) {
if (
rectengularCollision(player.value, {
...boundaries[i],
position: { x: boundaries[i].position.x, y: boundaries[i].position.y + Sprite.force },
})
) {
moving = false;
break;
}
}
if (!moving) return;
player.value.position.y -= Sprite.force;
} else if (keys.a.pressed && lastKey.value === "a") {
player.value.moving = true;
player.value.image = player.value.sprites.left;
for (let i = 0; i < boundaries.length; i++) {
if (
rectengularCollision(player.value, {
...boundaries[i],
position: { x: boundaries[i].position.x + Sprite.force, y: boundaries[i].position.y },
})
) {
moving = false;
break;
}
}
if (!moving) return;
player.value.position.x -= Sprite.force;
} else if (keys.s.pressed && lastKey.value === "s") {
player.value.moving = true;
player.value.image = player.value.sprites.down;
for (let i = 0; i < boundaries.length; i++) {
if (
rectengularCollision(player.value, {
...boundaries[i],
position: { x: boundaries[i].position.x, y: boundaries[i].position.y - Sprite.force },
})
) {
moving = false;
break;
}
}
if (!moving) return;
player.value.position.y += Sprite.force;
} else if (keys.d.pressed && lastKey.value === "d") {
player.value.moving = true;
player.value.image = player.value.sprites.right;
for (let i = 0; i < boundaries.length; i++) {
if (
rectengularCollision(player.value, {
...boundaries[i],
position: { x: boundaries[i].position.x - Sprite.force, y: boundaries[i].position.y },
})
) {
moving = false;
break;
}
}
if (!moving) return;
player.value.position.x += Sprite.force;
}
}
export class Sprite {
static force: number = 3; // speed, velocity, acceleration, etc.
frames: number;
spriteIteration: number = 0;
elapsed: number = 0;
defaultSrc: string;
image: HTMLImageElement;
sprites: { up: HTMLImageElement; down: HTMLImageElement; left: HTMLImageElement;
right: HTMLImageElement };
position: { x: number; y: number };
width: number = 0;
height: number = 0;
moving: boolean = false;
constructor(
position: { x: number; y: number },
src : string,
frames: number = 1,
sprites: { up: string; down: string; left: string; right: string } = { up:
"", down: "", left: "", right: "" },
) {
this.defaultSrc = src;
this.moving = false;
const { up, down, left, right } = this.initSprites(sprites);
this.sprites = { up, down, left, right };
this.image = down;
this.frames = frames;
this.position = position;
this.image.onload = () => {
this.width = this.image.width / this.frames;
this.height = this.image.height;
};
}
draw(ctx: CanvasRenderingContext2D) {
ctx.drawImage(
// src
this.image,
// crop from x axis
this.spriteIteration * this.width,
// crop from y axis
0,
// crop width
this.image.width / this.frames,
// crop height
this.image.height,
// x position on canvas
this.position.x,
// y position on canvas
this.position.y,
// width on canvas
this.image.width / this.frames,
// height on canvas
this.image.height,
);
}
initSprites(sprites: { up: string; down: string; left: string; right: string }) {
const up = new Image();
up.src = sprites.up;
const down = new Image();
down.src = sprites.down !== "" ? sprites.down : this.defaultSrc;
const left = new Image();
left.src = sprites.left;
const right = new Image();
right.src = sprites.right;
return { up, down, left, right };
}
}
I upgraded react native application to react version 17.0.1 and react-native 0.68.2.
Modals are no longer visible on the iOS application beyond that point. I’m using the react-native-modal: "^13.0.1" library to create those modals.
To confirm the issue, I replaced sample modal code react-native-modal-example on top of my existing code. However, the problem is still present.
There is a bug reported like this
Therefore, I used modal provided by react-native instead of using react-native-modal: "^13.0.1" but the same problem is occurred.
Is there any solution for this?
my code as follows,
import React, {useState} from 'react';
import {Image, View, Text, TouchableOpacity, Alert, Pressable, StyleSheet} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import Modal from 'react-native-modal'
const login = props => {
const [modalVisible, setModalVisible] = useState(false);
return (
<SafeAreaView style={styles1.centeredView}>
<Modal isVisible={true}>
<View style={styles1.centeredView}>
<View style={styles1.modalView}>
<Text style={styles1.modalText}>Hello World!</Text>
<Pressable
style={[styles1.button, styles1.buttonClose]}
onPress={() => setModalVisible(!modalVisible)}>
<Text style={styles1.textStyle}>Hide Modal</Text>
</Pressable>
</View>
</View>
</Modal>
<TouchableOpacity
style={[styles1.button, styles1.buttonOpen]}
onPress={() => setModalVisible(true)}>
<Text style={styles1.textStyle}>Show Modal</Text>
</TouchableOpacity>
</SafeAreaView>
);
};
const styles1 = StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView: {
margin: 20,
backgroundColor: "white",
borderRadius: 20,
padding: 35,
alignItems: "center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
button: {
borderRadius: 20,
padding: 10,
elevation: 2
},
buttonOpen: {
backgroundColor: "#F194FF",
},
buttonClose: {
backgroundColor: "#2196F3",
},
textStyle: {
color: "white",
fontWeight: "bold",
textAlign: "center"
},
modalText: {
marginBottom: 15,
textAlign: "center"
}
});
export default (login);