Posts by Luiz Felipe • 32,886 points
746 posts
-
4
votes1
answer1359
viewsA: Postgresql md5 encryption
Utilize: MD5('String') For example: INSERT INTO users (username, password) VALUES ('Luiz', MD5('Segredo'));
-
2
votes3
answers290
viewsA: Change scrollbar positioning in a div
If you are using jQuery, you can use the method scrollLeft(). An example: $('.btn').on('click', function () { var $target = $('.content'); $target.scrollLeft($target.outerWidth() + 20); }); .content…
-
4
votes1
answer512
viewsA: How to use index()?
To remove an element from a array by index, you must use the method splice. An example: const arr = ['A', 'B', 'C', 'D', 'E']; arr.splice(3, 1); // Remove o elemento de índice 3 ('D')…
javascriptanswered Luiz Felipe 32,886 -
2
votes1
answer38
viewsA: How to separate errors from a query in an expressjs api
There’s no way to change the output error generated by driver Mysql. You need to create some way to turn error codes into friendlier messages. An example to do this: function beautifyError(code) {…
-
17
votes4
answers701
viewsA: How to create and use custom events
Basically, to create a custom event and listen to it, you must: Create the event by instantiating a new one Event. As in new Event('eventName'); Trigger the event using the method dispatchEvent -…
-
1
votes1
answer565
viewsA: Retrieve JSON values in Javascript
First Form: You can create a custom function to format the data the way you want. In the example below, the function formatJSON creates an object with two initial properties (timestamp and revenue).…
-
5
votes1
answer67
viewsA: Error in serialize jquery
You are using the wrong method. The method .serialize(), according to the documentation, it is used to create a string in the pattern URL-encoded through a jQuery object that has selected form…
jqueryanswered Luiz Felipe 32,886 -
2
votes1
answer36
viewsA: Resume a #div via PHP jo Ajax file
You do not have the option to request only one element as you did (unless you create a server-side treatise). However, in order not to need it, you can select directly from the front end using…
-
6
votes2
answers694
viewsQ: What are semantic messages in Git?
Eventually, when I browse some of the Github repositories, I come across certain messages from commit standardized: feat(*): initiate re-write Or: refactor(*): remove unwanted files What are these…
-
2
votes3
answers324
viewsA: Check which p has no text
If you don’t want to use jQuery, you can do so: const els = document.querySelectorAll('p'); els.forEach(el => { if (! el.textContent) { el.style.setProperty('display', 'none'); } }); <!DOCTYPE…
-
0
votes2
answers115
viewsQ: Sort object array with relation to each other
I came across a problem: I have data from a database that is related to each other so that each field has two others - one that refers to the previous field (in the table) and the other to the next…
-
3
votes1
answer71
viewsQ: What is and what is the "Proxy" Javascript constructor for?
I know the builder Proxy was added in Javascript version 6 (ES6). My questions are: What is? What is its main purpose and how to use it?
-
10
votes2
answers93
viewsA: Do you really need to specify the HTML element before the class in the selector of a CSS rule?
The difference is that in the first case, you will only select the divs containing the class classe1, unlike the second example, which will select any element with class classe1. A brief example:…
-
1
votes1
answer1126
viewsA: Node.js: How to extract database information and display in HTML pages
Callbacks: The data cannot go outside the scope of this function since it represents a callback, that is, it is not executed in code order, but is called only when data is loaded from the database.…
-
0
votes2
answers72
viewsA: Contrast application on the page via cookies
Since I don’t know where the object comes from Cookies, I will create an example using the native API sessionStorage: const button = document.querySelector('#change-contrast'); const link =…
-
0
votes1
answer74
viewsA: Doubt with Function in Java
The purpose of the function in question is to Handle of the event click (attribute onclick in HTML). With this in mind, the parameter in question (ev) is the event interface of Javascript, which has…
-
1
votes1
answer768
viewsA: How to create Divs inside php
You can do so, for example: <div class="list-wrapper"> <ul> <?php foreach ($items as $item): ?> <li><?php echo $item; ?></li> <?php endforeach; ?>…
-
2
votes2
answers37
viewsA: Enabling and disabling input
You are selecting, through jQuery, a non-existent element: $("nome"); // Não existe no DOM The selector above is selecting this: <nome>...</nome> Which is probably not what you want. If…
-
2
votes1
answer132
viewsA: Disable field by clicking the checkbox
A simple example to do what you want: $('#control').on('change', function () { $('#target').prop('disabled', $(this).is(':checked')); }); <script…
-
2
votes2
answers1296
viewsA: How to create a cool color input?
How to use jQuery is an option, you can do something more or less like this: $('#color-input').on('change', function () { $(this) .next('#pseudo-color-input') .css('background-color',…
-
5
votes2
answers205
viewsA: Best way to generate a dynamically read with pure javascript
If you have a JSON in the form of Array, can iterate over the items and create a <li> using Javascript: const data = [{ name: 'Adalbeto', age: 23 }, { name: 'Bdalbeto', age: 45 }, { name:…
javascriptanswered Luiz Felipe 32,886 -
1
votes3
answers1210
viewsA: How to organize a project in Ode
Not long ago I met a framework with MVC standard for Nodejs. It is called Adonis. It is extremely organized and inherits a bit of Laravel style. The only harm is that it does not support Mongodb,…
-
0
votes1
answer31
viewsA: Ajax script does not work
You have a syntax error in your Javascript code. In your script, simply remove the semicolon from that line: url: '../ibico/php/carregaMunicipios.php'; Staying, then: url:…
-
1
votes1
answer91
viewsQ: Mysql Error: ER_TOO_LONG_KEY
I’m getting the error in Mysql and don’t know how to fix it. Below is listed the output: code: 'ER_TOO_LONG_KEY', errno: 1071, sqlMessage: 'Specified key was too long; max key length is 767 bytes',…
mysqlasked Luiz Felipe 32,886 -
0
votes2
answers254
viewsA: How to redirect the user to a specific PHP page?
You must use the function header, for example: /** Redirecionar o usuário para /home.php: */ header('Location: /home.php'); Link to the documentation. An important observation: You can only use this…
-
2
votes3
answers628
viewsQ: Create a custom SQL order
I have a table (groups) in SQL with the following structure: id | name | description | display_order | ... The field display_order was defined as UNIQUE and must be an integer. Its main function is…
-
1
votes1
answer23
viewsA: Make form open within a link
You can make use of the pseudo-selector :selected to make a toggle CSS-only: #toggle-form { position: absolute; opacity: 0; } .toggle-form { width: auto; color: blue; cursor: pointer; } #formu {…
-
1
votes2
answers1814
viewsA: How to remove vowels from a JS string?
Functional example with regular expressions: const example = 'Olá, mundo!'; console.log(example.replace(/(a|e|i|o|u)/gi, '')); Adding more characters If you want to add more characters to be…
javascriptanswered Luiz Felipe 32,886 -
9
votes4
answers2034
viewsQ: Does React affect SEO?
Since HTML is generated via Javascript and until the page is loaded there is no useful HTML in it, SEO can be affected if I make a 100% web application in React - a call single page application?…
-
5
votes1
answer3134
viewsA: Which password encryption should I use with Node.js? which one is more secure?
A good package for this type of action is the bcrypt, that generates passwords using salt. https://www.npmjs.com/package/bcryptjs The operation is simple. I will demonstrate using the following…
-
3
votes2
answers488
viewsQ: Best way to relate two tables
I have two tables (groups and roles): Table groups: +----+------+-------+------+ | id | name | color | role | +----+------+-------+------+ Table roles: +----+------+-------+-------------+ | id |…
-
2
votes1
answer121
viewsQ: Always start Mongodb
Whenever I will use Mongodb in a local development environment, I have to open the terminal and type: mongod So you can use Mongodb’s services. Since my operating system is Windows10 (64 bit), how…
-
0
votes0
answers20
viewsQ: Customizing the search bar?
How can I do that? -> http://prntscr.com/ja75k5 It seems to have some relationship with SSL certificate. But I could not understand nor find anything that says how it is done.…
urlasked Luiz Felipe 32,886 -
1
votes1
answer854
viewsQ: Timers on Node.js: their differences and their relationship to process.nextTick
What’s the difference between setInterval, setTimeout and setImmediate in Node.js? I know that setTimeout creates a single timer, such as a delay, and the setInterval creates a gap. But…
-
0
votes2
answers31
viewsA: Javascript - Objects
You must set first Circulo. The moment you create the instance of Circulo, he is, in that context, undefined. You must first create your class: // Criando a classe: function Circulo(p1, p2, p3) {…
javascriptanswered Luiz Felipe 32,886 -
0
votes2
answers313
viewsA: Focus Textbox function and Check if it is filled
Try this: function valid(element) { $(element) .closest('.control-group') .removeClass('error') .addClass('success'); } function notValid(element) { $(element) .closest('.control-group')…
-
0
votes3
answers801
viewsA: Filter string array
If you want to use regular expressions, I leave here an example of how to do it: const nomes = ['Thiago Carvalho', 'Renata Carvalho', 'Alexandre Otoni', 'Guilherme Otoni de Carvalho']; const filtro…
javascriptanswered Luiz Felipe 32,886 -
1
votes1
answer37
viewsA: Is it possible to fire a file inside a server through a web page?
I think in that case you should look for a dependency if you do not want to create something very complicated. With a few minutes of research, I found this: node-command-line. I don’t know much…
-
1
votes3
answers1174
viewsA: How to validate numeric fields in javascript?
By default, all input values come in as string, see: document.getElementById('check').addEventListener('click', function() { var field = document.getElementById('input'); // Mostra o valor e em…
javascriptanswered Luiz Felipe 32,886 -
0
votes2
answers2334
viewsA: How to get the input value in real time?
You can do it through an AJAX request: The script you could use on the client side would be: $('#id-do-input').on('change', function() { var $this = $(this); $.post('update.php', { param:…
-
0
votes1
answer53
viewsQ: Detect if it’s inside a callback?
Basically I want a function to behave differently if it is inside a callback. See the example: import Test from './test ;' Test.say('Olá!'); // Deve imprimir: "Olá!" Test.group(() => {…
-
1
votes1
answer17
viewsA: How to identify the closing event in Magnificpopup
You can use this property: close: function() { console.log('Acabo de fechar.'); } In your case, I would: $.magnificPopup.open({ items: { src: '#thanksModal', }, type: 'inline', close: function() {…
-
1
votes1
answer3316
viewsQ: How to create a local SSL certificate in Windows?
How can I create a local SSL certificate in Windows?
-
2
votes2
answers1910
viewsA: Hide elements according to screen size
You can use a CSS3 feature called media queries. The operation is simple, see an example: .menu-toggler { display: none; } @media screen and (max-width: 500px) { .menu-toggler { display: block; } }…
cssanswered Luiz Felipe 32,886 -
0
votes2
answers114
viewsA: Jquery - include variables in ajax
You can modify your script for this: $('form').on('submit', function(event) { event.preventDefault(); var email = $('#email').val(); var senha = $('#senha').val(); $.ajax({ url: 'verificar.php',…
-
0
votes2
answers110
viewsA: Jquery - Identify automatic text
I don’t understand the "automatically puts the text". Otherwise, it takes care? function typed() { var val = $(this).val(); if (! val) { $(this).removeClass('inputtyped'); } else {…
-
6
votes2
answers569
viewsA: Constructors in PHP 7
This was a change that happened in PHP 7. You can read more about it on documentation. Had some change? According to the documentation cited above: Old style constructors have become OBSOLETE in PHP…
-
1
votes0
answers1093
viewsQ: Session at Node.JS
I was reading that the middleware Express Session it is not ideal to work in production, because it archives the sessions in memory. I also read that storing session data in memory is not a good…
-
3
votes1
answer39540
viewsQ: Error. Unhandledpromiserejectionwarning
In the browser, the following code works normally: const get = async () => { return Promise.reject('Oops!') } get() .then(console.log) .catch((err) => { throw new Error(err) }) But on Node.js…
node.jsasked Luiz Felipe 32,886 -
17
votes2
answers311
viewsQ: Regular expression to detect nested structures in a template
I’m trying to create a template engine using Javascript. The syntax will be more or less similar to that of Laravel (Blade), with some modifications. I’m at the part of creating the expressions. The…