I have some issue about “ERR_ACCESS_DENIED”, I deploy a website server, and there is a upload file function,but recently it doesn’t work, I checked the chrome console, in Network tab, it shows “(failed)net::ERR_ACCESS_DENIED”, I don’t known why because I do not change my code recently, and the request didn’t arrive my background program which is a java web process(debug breakpoint), even the nginx, so what’s ths meaning of “ERR_ACCESS_DENIED”, Does this have anything to do with the chrome version? please give me some help
Category: javascript
Category Added in a WPeMatico Campaign
How to write functions when type of values are different?
I have a problem with making my function smarter. I achieve good results, but I think about the other solution.
I can take boolean
or object
as parameter. When the parameter is the object
I’d like to keep it as now. When the parameter is a boolean
value, I’d like to create an object, where keys are taken from another variable (less important) and values are this boolean
.
My solution assumes
- adding an empty items object at the beginning
- reading what is a value type and setting items according to the conditions
- taking items and converting to an array
- saving the array in state
Is that OK?
Check my code
const onAddAll = value => {
let items = {}
if (typeof value === 'boolean') {
terms.forEach(term => items[ term ] = value)
}
if (typeof value === 'object') {
items = value
}
const checked = Object.keys(items).filter(k => items[ k ])
setChecked(checked)
}
Imo, I wouldn’t need the second condition and make it smarter, bot no idea how. Please help!
MUI textfield loses focus when selected
At one stage this textfield was working fine but now every time it is selected it just loses focus immediately, so I am unable to input any text.
<InputField
fullWidth
placeholder="enter text"
value={text}
onChange={(e) => setText(e.value)}
onFocus={undefined}
/>
This causes loss of focus:
const InputField = ({ onChange, onFocus, ...textFieldProps }) => {
if (onFocus) {
return (
<TextField
onChange={(event) => onChange(event.target.value)}
onFocus={(event) => onFocus(event.currentTarget)}
{...textFieldProps}
/>
);
} else {
return (
<TextField
onChange={(event) => onChange(event.target.value)}
{...textFieldProps}
/>
);
}
};
Without the conditional it works fine:
const InputField = ({ onChange, onFocus, ...textFieldProps }) => {
return (
<TextField
onChange={(event) => onChange(event.target.value)}
{...textFieldProps}
/>
);
};
Vue Prevent form submit when pressing enter inside form
I have a webapp with multiple forms and inside these forms multiple custom made components: input, textarea, selectbox, datepicker, radiobutton, checkbox, … .
I found out that the submit function is fired when pressing the enter key inside a child component of a form tag. Something I don’t want. I want to be able to use the enter key for other things like conforming a selection in a dropdown.
Form example
<template>
<form @submit.prevent="handleLogin">
<fieldset :disabled="isSubmitting" class="space-y-6">
<Input :label="$tc('email', 1)" type="email" id="email" v-model="user.email" :error="errors.email" />
<Input :label="$tc('password', 1)" type="password" id="password" v-model="user.password" :error="errors.password" />
<Select :label="$tc('role', 1)" id="role" :options="roles" displayProperty="display_name" valueProperty="id" v-model="user.role" :error="errors.role" />
<SubmitButton :label="$tc('register', 1)" :submittingLabel="$tc('register_loader', 1)" :isSubmitting="isSubmitting" />
</fieldset>
</form>
</template>
SubmitButton.vue
<button type="submit">{{ isSubmitting ? submittingLabel : label }}</button>
Therefore I’m looking for a way to prevent the default behaviour. Adding a keydown function and checking if the enter key is being pressed inside all the custom components followed by an event.preventDefault()
didn’t do the trick.
A working solution should be to change the type of the button from ‘submit’ to ‘button’ and use an @click but that doesn’t sound like semantic html.
Any other suggestions?
Iam traying to add google maps to my angular project but the component keep give me errors from node module when serve in development mode anguler 10
the error log
eclare namespace google.maps {
~~~~~~~
Conflicts are in this file.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:130:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘anchorPoint’ must be of type ‘Point | null | undefined’, but here has type ‘Point | undefined’.
130 anchorPoint?: Point;
~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4265:5
4265 anchorPoint?: google.maps.Point|null;
~~~~~~~~~~~
‘anchorPoint’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:135:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘animation’ must be of type ‘Animation | null | undefined’, but here has type ‘Animation | undefined’.
135 animation?: Animation;
~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4269:5
4269 animation?: google.maps.Animation|null;
~~~~~~~~~
‘animation’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:141:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘clickable’ must be of type ‘boolean | null | undefined’, but here has type ‘boolean | undefined’.
141 clickable?: boolean;
~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4274:5
4274 clickable?: boolean|null;
~~~~~~~~~
‘clickable’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:147:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘crossOnDrag’ must be of type ‘boolean | null | undefined’, but here has type ‘boolean | undefined’.
147 crossOnDrag?: boolean;
~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4284:5
4284 crossOnDrag?: boolean|null;
~~~~~~~~~~~
‘crossOnDrag’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:154:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘cursor’ must be of type ‘string | null | undefined’, but here has type ‘string | undefined’.
154 cursor?: string;
~~~~~~
node_modules/@types/google.maps/index.d.ts:4288:5
4288 cursor?: string|null;
~~~~~~
‘cursor’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:160:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘draggable’ must be of type ‘boolean | null | undefined’, but here has type ‘boolean | undefined’.
160 draggable?: boolean;
~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4293:5
4293 draggable?: boolean|null;
~~~~~~~~~
‘draggable’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:167:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘icon’ must be of type ‘string | Icon | Symbol | null | undefined’, but here has type ‘string | Icon | Symbol | undefined’.
167 icon?: string | Icon | google.maps.Symbol;
~~~~
node_modules/@types/google.maps/index.d.ts:4298:5
4298 icon?: string|null|google.maps.Icon|google.maps.Symbol;
~~~~
‘icon’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:173:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘label’ must be of type ‘string | MarkerLabel | null | undefined’, but here has type ‘string | MarkerLabel | undefined’.
173 label?: string | MarkerLabel;
~~~~~
node_modules/@types/google.maps/index.d.ts:4308:5
4308 label?: string|null|google.maps.MarkerLabel;
~~~~~
‘label’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:178:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘map’ must be of type ‘Map | StreetViewPanorama | null | undefined’, but here has type ‘Map | StreetViewPanorama | undefined’.
178 map?: Map | StreetViewPanorama;
~~~
node_modules/@types/google.maps/index.d.ts:4314:5
4314 map?: google.maps.Map|null|google.maps.StreetViewPanorama;
~~~
‘map’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:184:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘opacity’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
184 opacity?: number;
~~~~~~~
node_modules/@types/google.maps/index.d.ts:4318:5
4318 opacity?: number|null;
~~~~~~~
‘opacity’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:192:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘optimized’ must be of type ‘boolean | null | undefined’, but here has type ‘boolean | undefined’.
192 optimized?: boolean;
~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4326:5
4326 optimized?: boolean|null;
~~~~~~~~~
‘optimized’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:198:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘position’ must be of type ‘LatLng | LatLngLiteral | null | undefined’, but here has type ‘LatLng | LatLngLiteral | undefined’.
198 position?: LatLng | LatLngLiteral;
~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4333:5
4333 position?: google.maps.LatLng|null|google.maps.LatLngLiteral;
~~~~~~~~
‘position’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:203:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘shape’ must be of type ‘MarkerShape | null | undefined’, but here has type ‘MarkerShape | undefined’.
203 shape?: MarkerShape;
~~~~~
node_modules/@types/google.maps/index.d.ts:4337:5
4337 shape?: google.maps.MarkerShape|null;
~~~~~
‘shape’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:209:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘title’ must be of type ‘string | null | undefined’, but here has type ‘string | undefined’.
209 title?: string;
~~~~~
node_modules/@types/google.maps/index.d.ts:4344:5
4344 title?: string|null;
~~~~~
‘title’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:215:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘visible’ must be of type ‘boolean | null | undefined’, but here has type ‘boolean | undefined’.
215 visible?: boolean;
~~~~~~~
node_modules/@types/google.maps/index.d.ts:4348:5
4348 visible?: boolean|null;
~~~~~~~
‘visible’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:224:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘zIndex’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
224 zIndex?: number;
~~~~~~
node_modules/@types/google.maps/index.d.ts:4356:5
4356 zIndex?: number|null;
~~~~~~
‘zIndex’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:276:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘anchor’ must be of type ‘Point | null | undefined’, but here has type ‘Point | undefined’.
276 anchor?: Point;
~~~~~~
node_modules/@types/google.maps/index.d.ts:2388:5
2388 anchor?: google.maps.Point|null;
~~~~~~
‘anchor’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:283:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘labelOrigin’ must be of type ‘Point | null | undefined’, but here has type ‘Point | undefined’.
283 labelOrigin?: Point;
~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:2394:5
2394 labelOrigin?: google.maps.Point|null;
~~~~~~~~~~~
‘labelOrigin’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:289:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘origin’ must be of type ‘Point | null | undefined’, but here has type ‘Point | undefined’.
289 origin?: Point;
~~~~~~
node_modules/@types/google.maps/index.d.ts:2399:5
2399 origin?: google.maps.Point|null;
~~~~~~
‘origin’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:295:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘scaledSize’ must be of type ‘Size | null | undefined’, but here has type ‘Size | undefined’.
295 scaledSize?: Size;
~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:2404:5
2404 scaledSize?: google.maps.Size|null;
~~~~~~~~~~
‘scaledSize’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:302:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘size’ must be of type ‘Size | null | undefined’, but here has type ‘Size | undefined’.
302 size?: Size;
~~~~
node_modules/@types/google.maps/index.d.ts:2410:5
2410 size?: google.maps.Size|null;
~~~~
‘size’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:438:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘anchor’ must be of type ‘Point | null | undefined’, but here has type ‘Point | undefined’.
438 anchor?: Point;
~~~~~~
node_modules/@types/google.maps/index.d.ts:5866:5
5866 anchor?: google.maps.Point|null;
~~~~~~
‘anchor’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:446:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘fillColor’ must be of type ‘string | null | undefined’, but here has type ‘string | undefined’.
446 fillColor?: string;
~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5873:5
5873 fillColor?: string|null;
~~~~~~~~~
‘fillColor’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:452:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘fillOpacity’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
452 fillOpacity?: number;
~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5877:5
5877 fillOpacity?: number|null;
~~~~~~~~~~~
‘fillOpacity’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:461:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘labelOrigin’ must be of type ‘Point | null | undefined’, but here has type ‘Point | undefined’.
461 labelOrigin?: Point;
~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5884:5
5884 labelOrigin?: google.maps.Point|null;
~~~~~~~~~~~
‘labelOrigin’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:477:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘rotation’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
477 rotation?: number;
~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5898:5
5898 rotation?: number|null;
~~~~~~~~
‘rotation’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:486:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘scale’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
486 scale?: number;
~~~~~
node_modules/@types/google.maps/index.d.ts:5906:5
5906 scale?: number|null;
~~~~~
‘scale’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:493:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘strokeColor’ must be of type ‘string | null | undefined’, but here has type ‘string | undefined’.
493 strokeColor?: string;
~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5913:5
5913 strokeColor?: string|null;
~~~~~~~~~~~
‘strokeColor’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:500:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘strokeOpacity’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
500 strokeOpacity?: number;
~~~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5919:5
5919 strokeOpacity?: number|null;
~~~~~~~~~~~~~
‘strokeOpacity’ was also declared here.
Error: node_modules/@types/googlemaps/reference/marker.d.ts:505:9 – error TS2717: Subsequent property declarations must have the same type. Property ‘strokeWeight’ must be of type ‘number | null | undefined’, but here has type ‘number | undefined’.
505 strokeWeight?: number;
~~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:5924:5
5924 strokeWeight?: number|null;
~~~~~~~~~~~~
‘strokeWeight’ was also declared here.
Error: node_modules/@types/googlemaps/reference/max-zoom.d.ts:6:11 – error TS2300: Duplicate identifier ‘MaxZoomService’.
6 class MaxZoomService {
~~~~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4415:9
4415 class MaxZoomService {
~~~~~~~~~~~~~~
‘MaxZoomService’ was also declared here.
Error: node_modules/@types/googlemaps/reference/max-zoom.d.ts:52:10 – error TS2300: Duplicate identifier ‘MaxZoomResult’.
52 type MaxZoomResult = MaxZoomResultError | MaxZoomResultOk;
~~~~~~~~~~~~~
node_modules/@types/google.maps/index.d.ts:4397:13
4397 interface MaxZoomResult {
~~~~~~~~~~~~~
‘MaxZoomResult’ was also declared here.
Error: node_modules/@types/googlemaps/reference/max-zoom.d.ts:65:9 – error TS2300: Duplicate identifier ‘ERROR’.
65 ERROR = ‘ERROR’,
~~~~~
**
package.json
**
},
“private”: true,
“dependencies”: {
“@angular/animations”: “~12.2.0”,
“@angular/cdk”: “^12.2.11”,
“@angular/common”: “~12.2.0”,
“@angular/compiler”: “~12.2.0”,
“@angular/core”: “~12.2.0”,
“@angular/forms”: “~12.2.0”,
“@angular/google-maps”: “^13.0.2”,
“@angular/localize”: “~12.2.0”,
“@angular/material”: “^12.2.11”,
“@angular/platform-browser”: “~12.2.0”,
“@angular/platform-browser-dynamic”: “~12.2.0”,
“@angular/router”: “~12.2.0”,
“@craco/craco”: “^6.3.0”,
“@ng-bootstrap/ng-bootstrap”: “^10.0.0”,
“@swimlane/ngx-datatable”: “^20.0.0”,
“@types/core-js”: “^0.9.39”,
“angular-paginator”: “^7.0.0”,
“bootstrap”: “^5.1.3”,
“ng-bootstrap-table”: “0.0.17”,
“ngx-bootstrap”: “^7.1.0”,
“rxjs”: “~6.6.0”,
“tslib”: “^2.3.0”,
“zone.js”: “~0.11.4”
},
“devDependencies”: {
“@angular-devkit/build-angular”: “^12.2.11”,
“@angular/cli”: “~12.2.11”,
“@angular/compiler-cli”: “~12.2.0”,
“@fortawesome/fontawesome-free”: “^5.15.4”,
“@types/googlemaps”: “^3.39.12”,
“@types/jasmine”: “~3.8.0”,
“@types/node”: “^12.11.1”,
“jasmine-core”: “~3.8.0”,
“karma”: “~6.3.0”,
“karma-chrome-launcher”: “~3.1.0”,
“karma-coverage”: “~2.0.3”,
“karma-jasmine”: “~4.0.0”,
“karma-jasmine-html-reporter”: “~1.7.0”,
“tailwindcss”: “^2.2.17”,
“typescript”: “~4.3.5”
}
tsConig
“baseUrl”: “./”,
“outDir”: “./dist/out-tsc”,
“forceConsistentCasingInFileNames”: true,
“strict”: true,
“noImplicitReturns”: true,
“noFallthroughCasesInSwitch”: true,
“sourceMap”: true,
“declaration”: false,
“downlevelIteration”: true,
“experimentalDecorators”: true,
“moduleResolution”: “node”,
“importHelpers”: true,
“target”: “es2017”,
“module”: “es2020”,
“lib”: [
“es2018”,
“dom”
]
},
“angularCompilerOptions”: {
“enableI18nLegacyMessageIdFormat”: false,
“strictInjectionParameters”: true,
“strictInputAccessModifiers”: true,
“strictTemplates”: true
}
<div style="height: 200px; width: max-content;">
<google-map></google-map>
</div>
I want to make a toggle button in a check box somewhere else
I’d like to inquire.
I created a page with a product list.
If you press the “Inquiry” button at the top, the inquiry form comes down, and there is a product list check box in it.
In the list of products outside, click the “Add to Inquiry” button in the list to check the check box of the inquiry form.
At this time, I want to release the checkbox check by pressing the “Add to Inquiry” button again. It functions like “Toggle”.
https://thepagegallery49.cafe24.com/wp/publication/
The code I used is as follows.
List ‘Inquire Button’
<div class="news-text-box">
<span class="addbtn" id="<?php the_sub_field('pbtag'); ?>"><span class="addon active">Add in Inquire</span><span class="addoff">Added</span></span> </div>
Javascript
document.getElementById("<?php the_sub_field('pbtag'); ?>").addEventListener("click", () => {
document.querySelector('input[value="<?php the_sub_field('pbtitle'); ?>"]').checked = true;
document.querySelector('input[value="<?php the_sub_field('pbtitle'); ?>"]').parentElement.classList.toggle('active');
})
Checkbox
<ul id="wpforms-187-field_28">
<li class="choice-1 depth-1"><input type="checkbox" id="wpforms-187-field_28_1" name="wpforms[fields][28][]" value="Matters of Life and Death"><label class="wpforms-field-label-inline" for="wpforms-187-field_28_1">Matters of Life and Death</label></li>
<li class="choice-2 depth-1 active"><input type="checkbox" id="wpforms-187-field_28_2" name="wpforms[fields][28][]" value="Displacements"><label class="wpforms-field-label-inline" for="wpforms-187-field_28_2">Displacements</label></li>
...
</ul>
Video does not stop playing when clicking out the popped up box in JWPlayer
I’m using jwplayer
and I have coded this at the end of body:
<script src="{{asset('js/jwplayer/jwplayer.js')}}"></script>
<script type="text/JavaScript">
jwplayer("video1").setup({
sources: [{
file: "http://video.sitename.com/filename.mp4",
label: "360",
"default": "true"
}],
});
</script>
And this is the html part:
<!-- Modal body 1 -->
<div class="modal-body">
<div id="video1"></div>
</div>
So it loads the video perfectly but when the user clicks outside the box or clicks the close link (x), the video sound can be still heard!
However, the video is closed.
So how can I properly fix this so that if the user clicks anywhere outside of the Modal box or if he clicks on x, the video will be closed COMPLETEY?
Are there javascript commands to determine the first and last fully visible line in an html-textarea?
A part of a very large file is loaded and shown in an textarea. When the user hits the page up or down button, the javascript should determine the last fully shown line with a line break visible in the textare, respectivly the first fully shown line visible, and which cursor position that last line break or first shown character is of the textareas text. Then I could determine what to do next (only scroll the textarea or load a new part of the very large file).
Check an number in an array is a powers number
Can you give me a example for this solution by javascript?
arr = [16, 32, 72, 96]
output: [16, 32].
Because 16 = 4^2 and 32 = 2^5
Thank you for your time to help me!!
how do I make a 2d level in javascript [closed]
i have a character and a movement system how do i make a stage for my game
function border:
Blockquote ps. this is all i know about 2d game stages
How can I add search bar or a special element like search bar in Tamper monkey extension?
I have task in which I want to write a script to run on the tamper monkey. Purpose of this script is to make a search bar in which user will type a word and Script will find it from the webpage.
Question is how can a make such Search bar (not on page but in extension)
reference Image Reference Image with setting menu
how to position items inside css grid?
I’m learning the CSS grid and trying to position the items inside grid?
can get and see data from javascript:
const profileImg = document.createElement('img');
var profilePhotoUrl = post.user.get("photo").url();
profileImg.src = profilePhotoUrl;
profileImg.className = "profile";
const username = document.createElement('username');
username.className = "user";
username.innerText = post.name;
const content = document.querySelector('.content');
content.append(profileImg, username);
from CSS
body {
display: grid;
margin: 0;
grid-template-columns: 20% auto;
grid-template-rows: 60px auto 100px;
grid-template-areas:
"header header"
"sidebar content"
"sidebar footer";
}
.content {
grid-area: content;
justify-self: center;
}
and it looks like this. how can I position them vertically?
(profile username) <–like this
(profile username)
(profile username)
Node – GifEncoder has a delay or lags when creating a gif
i want to render a Gif with GifEncoder (older version), but unfortunately the gif output is jittery or so to say, it lags. This is my code:
import GIFEncoder from "gif-encoder-2";
import fs from "fs";
import pkg from "canvas";
const { createCanvas } = pkg;
let frame = 0;
const size = 200;
const fr = 60; //starting FPS
const encoder = new GIFEncoder(size, size);
encoder
.createReadStream()
.pipe(fs.createWriteStream("my.gif"));
encoder.start();
encoder.setRepeat(0); // 0 for repeat, -1 for no-repeat
encoder.setDelay(0); // frame delay in ms
encoder.setQuality(10); // image quality. 10 is default.
var canvas = createCanvas(size, size),
cw = canvas.width,
ch = canvas.height,
cx = null,
fps = 60,
bX = 30,
bY = 30,
mX = 10,
mY = 20,
interval = null;
function gameLoop() {
cx.clearRect(0, 0, cw, cw);
cx.beginPath();
cx.fillStyle = "red";
cx.arc(bX, bY, 20, 0, Math.PI * 360);
cx.fill();
if (bX >= cw || bX <= 0) {
mX *= -1;
}
if (bY >= ch || bY <= 0) {
mY *= -1;
}
bX += mX;
bY += mY;
encoder.addFrame(cx);
console.log(frame);
if (frame > 60) {
clearInterval(interval);
encoder.finish();
}
++frame;
}
if (typeof canvas.getContext !== undefined) {
cx = canvas.getContext("2d");
interval = setInterval(gameLoop, 1000 / fps);
}
This is the output
I took the example from this fiddle, where you can see, how smooth the ball should look like.
What I tried so far without success,
- Not creating a stream, when using GifEncoder
- Collecting
cx
in an array and use GifEncoder afterwards, but it seems thectx
is a reference object and I could not find a way how to copy it - Playing around with P5 in hope, they have an internal calculation, when the deltaTime is to high between the frames
Can anyone help me here or give me an advice what to do?
Connecting mongodb to nodejs
-
Restarted MongoDB server (it keeps running when error occurs).
-
Using MongoDB server on windows as a service (started it manually)
Established the connection via MongoDB Shell CLI Package by hitting enter in the comand prompt to establish the default connection. -
(mongodb://127.0.0.1:27017/directConnection=true&serverSelectionTimeoutMS=2000 )
Called npm install and npm start (my dependencies are listed below) -
Checked that MongoDB is running
-
Checked via the windows resource monitor that the port 27017 is occupied by mongod.exe using TCP and is not restricted by the firewall
-
Checked that I am not using a VPN nor a proxy connection that could interfere.
-
Then I opened http://localhost:3000/ to which I am listening (app.listen(3000);)
Why am i still getting this error even after trying all of the above steps?
MongoServerSelectionError: connect ECONNREFUSED ::1:27017
at Timeout._onTimeout (C:UsersridwaanDocumentsweb devtestnode_modulesmongodblibsdamtopology.js:330:38)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) {
'localhost:27017' => ServerDescription {
_hostAddress: HostAddress { isIPv6: false, host: 'localhost', port: 27017 },
address: 'localhost:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 1717487,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (C:UsersridwaanDocumentsweb devtestnode_modulesmongodblibcmapconnect.js:293:20)
at Socket.<anonymous> (C:UsersridwaanDocumentsweb devtestnode_modulesmongodblibcmapconnect.js:267:22)
at Object.onceWrapper (node:events:510:26)
at Socket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
logicalSessionTimeoutMinutes: undefined
}
}
Node.js v17.1.0
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. React JS error
Hope you all are doing well.
I have deployed my react app in Bluehost, having a URL https://lanterncapitalpartners.com/
Now I am facing an issue while reloading pages, it throws an error
Not Found
The requested URL was not found on this server.Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
For the homepage, it reloads ok, while for other pages, it throws the error mentioned above.
I don’t know whether it’s a server issue or an app issue.
Help in that matter would really be appreciated.