I’m making an app using react navigation-drawer for native, and I was wondering if it is possible to hide just the header title without hiding other things with for example
headerShown: false
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I’m making an app using react navigation-drawer for native, and I was wondering if it is possible to hide just the header title without hiding other things with for example
headerShown: false
I am using nodejs and mysql2. I am storing all my queries inside a class. When I console.log the results I am able to view the data correctly, however when I use a return statment to return the data, I am getting undefined. I believe I need to use promises, but am uncertain how to do so correctly. Here is what I have currently which is returning undefined,
viewManagerChoices() {
const sql = `SELECT CONCAT(first_name, ' ', last_name) AS manager, id FROM employee WHERE manager_id IS NULL`;
db.query(sql, (err, rows) => {
if (err) throw err;
const managers = rows.map(manager => ({ name: manager.manager, value: manager.id }));
managers.push({ name: 'None', value: null });
return managers;
});
};
This is my attempt at using promises which is returning as Promise {<pending>},
viewManagers() {
return new Promise((resolve, reject) => {
const sql = `SELECT CONCAT(first_name, ' ', last_name) AS manager FROM employee WHERE manager_id IS NULL`;
db.query(sql,
(error, results) => {
if (error) {
console.log('error', error);
reject(error);
}
const managers = [];
for (let i = 0; i < results.length; i++) {
managers.push({ name: results[i].manager, value: i+1 });
}
managers.push({ name: "None", value: null });
resolve(managers);
}
)
})
}
My class is called Query and I am calling these methods by doing,
const query = new Query();
query.viewManagerChoices();
query.viewManagers();
Currently Im working on a website that allows users to create images by layering different images on each other and then they will be allowed to download their creation.
Currently the way we manipulate images is using a HTML canvas which is working well for us except for one problem.
Since we have a large amount of images we want to use for the canvas creation we must opt to store the images in a separate bucket (tried google cloud and firebase so far) however when we try to add an image from another source the canvas becomes tainted and the user can no longer download their image.
Basically were looking for a way to host a bulk amount of images off of our main site so that they can be used in the canvas and not taint them.
I have also tried putting our bucket on a subdomain but we are still having the same issue
Thanks for help!
I have the following problem when using ngprime, when the page loads the input is buggy. If I click on the input it is correct, according to the second photo.
Can you help me with this?
I installed prime flex, prime ng. I imported the styles in angular.json
formulario: FormGroup = this.fb.group({
email: [null, [Validators.email, Validators.required]],
password: [null, Validators.required]
});
<form [formGroup]="formulario" class="p-fluid mt-5">
<fieldset class="field">
<label for="password" class="block">Email</label>
<span class="p-input-icon-left my-2">
<i class="pi pi-user"></i>
<input id="email" formControlName="email" type="email" pInputText placeholder="Email">
</span>
</fieldset>
<fieldset class="field mt-2">
<label for="password" class="block">Password</label>
<p-password id="password" formControlName="password" [toggleMask]="true" promptLabel="Ingresa tu contraseña"
weakLabel="Débil" goodLabel="Buena" strongLabel="Fuerte">
</p-password>
</fieldset>
</form>
I have a <select> element, and <option> elements.
Rather than hardcoding the width to 90px, im looking for a way to set the width to fit a regex’d portion of the <option> contents
The preferred regex would be LOREMIPSUM#d{0,5}
In other words,
max-width and min-width of the <select> to fit nicely around just the LOREUMIPSUM# part?<select> to fit all the content, just the first part by that regex pattern. <select
id="someId"
name="someName"
class="someClass"
size="1"
onchange="someMethod();"
style="width:90px;">
<option value="a0D3u00000BhNCxEAN">LOREMIPSUM#0263 abcabcabcabcabcabcabcabcabcabcabcabc</option>
<option value="a0D3u00000Bh7qFEAR">LOREMIPSUM#0262 user tests</option>
<option value="a0D3u00000BgovaEAB">LOREMIPSUM#0258 dogs</option>
<option value="a0D3u00000BgovVEAR">LOREMIPSUM#0257 cats</option>
<option value="a0D3u00000BgovVEAR">LOREMIPSUM#10000 some text</option>
</select>
I’m currently working with a csv and am importing it so that I have three columns: DateTime, Month, and Count.
If I create a line graph using DateTime and Count everything works just fine. When I switch to using Month and Count, however, I get the error seen above.
I’ve found some other posts that are similar and tried a few different options such as switching the x scale from scaleTime() to scaleOrdinal(). I also tried adding the tickformat to my xaxis like so:
var xAxis_a = d3.axisBottom(xScale)
.tickFormat(d3.time.format("%b-%y"))
.ticks(15);
Unfortunately, none of these changes have worked. So, how can I get a line plot with my x-axis displaying an abbreviated month and year?
I want it to look like this
{question:"",choice1:"",choice2:"",choice3:"",choice4:""}
i have a web page that get locations of mobile phone , every time i want to see the change of the location i should make a page reload , i want to have a refresh for the marker itself not all the page in a simple way ….
<?php
use AppUser;
use AppModelProposals;
use AppModelFavoriteUser;
//$Customers = User::find($orders->order_name_customer)->customers_name;
use CarbonCarbon;
$fav=FavoriteUser::get();
$pro=Locations::take('100')->orderBy('created_at','DESC')->get();
?>
</head>
<body>
<script type="text/javascript">
window.onload = setupRefresh;
function setupRefresh() {
setTimeout("refreshPage();", 15000); // milliseconds
}
function refreshPage() {
window.location = location.href;
}
</script>
<script>
var locations = [
@foreach($pro as $s)
@php ($p = $pro->where('user_id', $s->user_id)->first())
@php ($time1 = Carbon::now())
@php( $time2 = Carbon::parse($p->created_at))
@php ($diff = $time1->diffInMinutes($time2))
@if( $diff<=1)
['{{ AppUser::find($p->user_id)->customers_name}}', {{ $p->long}},{{$p->lat}}],
@endif
@endforeach
];
I support several churches that don’t have musicians, by providing a little website with a bunch of pure Javascript so they can select music for their services from a collection of about 1100 mp3 and m4a music files. Previously, they created playlists in iTunes or Media Player, but after a track completed, the player would immediately start the next track unless they quickly clicked ‘Stop’. So my website allows them to select all their music ahead of time (up to 10 tracks), with a separate “Play” button for each. Hit “Play” and it plays that one track and stops. (Duh.)
I’m encountering delays in loading the files into my “audio” tags – and I need the file to load when they select it so I can display the track duration, which is frequently important to the selection of the music for the service. A delay doesn’t occur very often, but often enough to be annoying. Also, the load will occasionally time out completely, even after several attempts. I’ve experimented played with various techniques, like using setTimeout with different values to allow several seconds before checking if it’s loaded, or, loading 5 or 10 times with shorter timeout values until it’s loaded. I created a test page that indicates that the timeouts vary greatly – from 2% to 5% of the time, to upwards of 25% occasionally (during tests of 1,000 to 10,000 random loads).
My first technique was relying on events (I tried both ‘canplay’ and ‘canplaythrough’ events with minimal difference):
const testAudio = document.getElementById('test-audio');
let timeStart = Date.now();
function loadMusic(p_file) {
testAudio.src = p_file;
testAudio.addEventListener('canplaythrough', musicLoaded);
timeStart = Date.now();
testAudio.load();
}
function musicLoaded() {
console.log('music loaded in ' + (Date.now()-timeStart) + 'ms');
testAudio.removeEventListener('canplaythrough', musicLoaded);
/* should I add/remove the listener each time I change the source file ? */
}
My second approach (from a post here: https://stackoverflow.com/questions/10235919/the-canplay-canplaythrough-events-for-an-html5-video-are-not-called-on-firefox) is to check the ‘readyState’ of the audio element after a specified timeout, rather than relying on an event. This question specifically addressed Firefox, so I should mention that in my tests Firefox has horrible load times for both the “events” and the “readyState” techniques. Chrome and Edge vary in the range of 2% to 6% load failure due to timeout and Firefox has 27% to 39% load timeouts.
let myTimeout = '';
function loadMusic(p_file) {
myTimeout = setTimeout(fileTimeout, 1000); /* I've tried various values here */
testAudio.src = p_file;
timeStart = Date.now();
testAudio.load();
}
function fileTimeout() {
if (testAudio.readyState > 3) {
console.log('music loaded in ' + (Date.now()-timeStart) + 'ms');
} else {
/* here, I've tried calling loadMusic again 5 to 10 times, which sometimes works */
/* or, just reporting that the load failed... */
console.log('music FAILED to load!');
}
}
I have a shared server hosting plan, and I suspect the delay might be due to traffic on my server. Unfortunately, my hosting service turns a deaf ear to anything that might be application or content related (not surprising). And this isn’t worth upgrading to a dedicated server just to eliminate that variable. But I suspect that might be a major factor here.
I need a technique that will always work – even if it takes 30 seconds or more. As long as I can display an intermittent “Still loading…” type message I (and my users) would be satisfied. The “track X won’t load” messages happen often enough to be annoying. Early on, I had a few files with bad characters in the file name that needed to be fixed before they would load. So the users think that problem persists. But I know I’ve fixed all them now.
Any and all suggestions are welcome – but I’d love to keep everything in plain Javascript.
i’m facing a problem in react app whenever i save the document.
The error is
Plugin “react” was conflicted between “package.json » eslint-config-react-app
i tried to solve this error with lot of methods but it’s not going.
my package.json
{
"name": "chat",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.4.2",
"@mui/material": "^5.4.3",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {}
}
I’m trying to implement a mouse hover functionality and below is my jsp;
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<%@ include file="/include/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>hover example</title>
</head>
<script>
$(document).ready(function () {
$(".hover").each(function () {
$(this).mouseover(function() {
console.log('in');
$("#popup").dialog({
autoOpen: true,
title: 'Title',
width: '100px',
height: '100px',
modal: true
});
})
.mouseout(function() {
console.log('out');
});
});
});
</script>
<div class="hover">
this is the test hover...
</div>
<div id="popup" style="display:none; width: 100px; height:100px;">
<b>yasgfshdfhsdhf</b>
<b>yasgfshdfhsdhf</b>
<b>yasgfshdfhsdhf</b>
</div>
</html>
But I keep getting a .dialog is not a function error. I have tried many solutions from stackoverflow but still can’t get rid of the error. Can someone please point out what is causing the error.
How can I show div’s based on KeyValues? People can select stuff via radio buttons which then will be saved in a KeyValue, (eg. ["1.1","2.1","3.2","4.1","5.2","6.2"]), how do I show div’s based on that KeyValue?
As the title says, my local Strapi project doesn’t show the content of the post in API. Permissions are granted, I tried several times deleting and starting from scratch.
As you can see, I have access to a single post “/api/post-templates/1”
and I have access to several posts if I had them. “/api/post-templates”
The issue is, I can’t see any content of the post fields I entered.
Picture of Strapi-side which doesn’t show its content
And which shows its content in API.
I want to access content to use it on the front-end as I did in postCards case.
In my project I have 12 top users ranking by point, I got them from an api rest.
I create 2 button (showMor) and (showLess).
So in my code by default the first three users appear on the list, when i click the button showmore three users are added to the first users, each time i press the button show more three users are added until the end ( 12 users ). and vice versa when pressing the button showless, decrease three users from the list …
the problem was when i press the button showmore 4 times, i have all the 12 users, but when i click on this button for the fifth-sixth-seventh time it is added space for other users doesn’t exist, and the same for button showless when i click on this button on the first time he is hiding the first three users appear on the list by default.
I want to create a condition for the two button’s :
when i click the button showless, i don’t want it to hiding the first three users.
when i click the button showmore, i don’t want it to add more space the the space allotted to the 12 users.
code html :
<div class="col-md-6 text-center">
<h2><strong>TOP 12 FANS</strong></h2>
<div *ngFor="let top of top2" class="rank" style="width: 74%;">
<div class="data-row">
<div class="row-user">
<div class="col-lg-4 col-md-7 col-sm-7 col-7">
<div class="rank-row">
<span class="logo-wrapper ">
<img src={{top.photoUrl}}>
</span>
<div class="td-wrap"><a class="uni-link">{{top.firstname}} {{top.familyname}}</a>
</div>
<div class="location "> <img width="10px" src="../assets/localisation.png">
france</div>
</div>
</div>
<div
class="col-lg-4 offset-lg-0 col-md-12 offset-md-0 col-sm-11 offset-sm-1 text-center">
<span><img width="25px" src="../assets/golden.png"> {{top.point}} PT</span>
</div>
</div>
</div>
<button (click)="showMore()">show more</button>
<button (click)="showLess()">show less</button>
</div>
code ts :
import { Component, OnInit } from '@angular/core';
import { ApiService } from './api.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
top2 = [];
result = [];
i=0;
perChunk = 3;
constructor(private apiService: ApiService) { }
ngOnInit() {
this.getTop2();
}
getTop2() {
this.apiService.gettop2().subscribe((res: []) => {
var inputArray = res;
this.result = inputArray.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index/this.perChunk)
if(!resultArray[chunkIndex]) {
resultArray[chunkIndex] = [] // start a new chunk
}
resultArray[chunkIndex].push(item)
return resultArray
}, [])
this.top2 = this.result[0];
console.log(res)
});
}
showMore() {
this.i++;
this.top2 = this.top2.concat(this.result[this.i])
console.log(this.top2)
}
showLess() {
this.i--;
let length = this.top2.length;
this.top2.length = length-this.perChunk;
}
}
I have a angular application where I wnat to route the user to a new page after succesfull login. But the webpage is not loading just the url is changing, I tried router-outlet but it renders the component under my login component. What I want is to route to a complete new page.
App-routing module:
const routes: Routes = [
{path: 'dashboard' , component: DashboardComponent, canActivate: [AuthGuard]},
{path: 'authenticate', component: LoginComponent},
{path: '' , redirectTo: 'authenticate', pathMatch: 'full'}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: [AuthGuard]
})
export class AppRoutingModule {
}
App component.html
<nb-layout-header fixed >
Moniesta
</nb-layout-header>
<nb-layout-column>
<moniesta-login></moniesta-login>
<router-outlet></router-outlet>
</nb-layout-column>
<nb-layout-footer fixed>
<!-- Insert footer here -->
</nb-layout-footer>
</nb-layout>
Method in my service to load to new url and webpage:
authenticateUser(login: LoginModel){
return this.http.post(environment.rootUrl + 'authenticate', {
username: login.username,
password: login.password,
}).subscribe({
next: (data) => {
localStorage.setItem('token', data.toString())
this.router.navigate(['/dashboard'])
}, error: (error) => {
this.isAuthenticated = false
}
})
}
Could someone help me out and tell me what is wrong?