Posts by Lauro Moraes • 3,871 points
143 posts
-
1
votes1
answer288
viewsA: Place EJS files in the Service Worker cache
Supposing you are using Express can use the function express.Static() which serves precisely to "serve static files". This function has the following structure: express.static(root, [options]) You…
-
1
votes1
answer1379
viewsA: 'Can’t set headers after they are sent. ' Express.js
This error consists because you are trying to send twice information to the customer as a response. After responding to the customer’s header HEADER is sent... cannot overwrite or send another. If…
-
0
votes2
answers1370
viewsA: How to keep selected checkbox after refresh on page with localstorage JS
The problem is that you are setting values to a global variable that when reloading the page will be "empty" until there is a new iteration with a checkbox. In addition it is not necessary to pass a…
-
4
votes2
answers59
viewsQ: Fetch values in an object
I’m trying to access properties of an object, a dictionary. However the references are in format {String} and its concatenation through a point (.) and I’m using split() to break this {String} in a…
-
1
votes1
answer381
viewsA: Calculate horizontal distance of an element
I thank you in advance for the reply and comments I received on this question, helped me to guide the reasoning and find the solution. The problem consisted of two distinct errors: 1: i was defining…
-
0
votes1
answer63
viewsA: How to get link inside the textarea?
Use the value since there is content in your <textarea>... use match() to return a {Array} of parties found in accordance with the search condition. let msg = $('#x').val() let subStr =…
jqueryanswered Lauro Moraes 3,871 -
21
votes1
answer83416
viewsA: Send a message to Whatsapp via site
Interesting normal question from the point of view that there is possibility yes to write a message on a website and using the official mechanisms of WhatsApp to send it. In a comment by @Gabriel…
-
2
votes1
answer381
viewsQ: Calculate horizontal distance of an element
I’m trying to customize a button submit using Bootstrap 4 Beta 3. The idea was to do something stylish "slide to Unlock"; however, it is only working in a resolution above 992px... I believe this is…
-
0
votes2
answers1316
viewsA: Login Form Screen Flashes
This is because your image is being added "dynamically" at the documento... in short it is not loaded at the same time as the page content is loaded. This "effect" only happens while the image is…
-
4
votes2
answers3822
viewsA: Create my own Push mail server
Preface¹: First it should be understood that the services of Push Notification in the mobile (mobile) scope are implemented by the software manufacturer (normally integrated via OS). The basis of…
-
1
votes1
answer1897
viewsA: Entire and centralized Modal Bootstrap
Bootstrap modals have been designed to overlay all document content <body> in order to be able to scroll its contents. Bootstrap does not support modal "nesting" as well as its documentation…
-
2
votes1
answer53
viewsA: Unable to validate "Undefined" - JS
Following your example: var a = {f : 1} console.log(a) // output: {f:1} console.log(a.b) // output: undefined console.log(a.b.c) // Uncaught TypeError: Cannot read property 'c' of undefined This is…
javascriptanswered Lauro Moraes 3,871 -
0
votes2
answers317
viewsA: Personalize PHP session cookie
Based on a reply I received on ONLY in a matter related to RFC6265 defining the specification of the cookie "same-site" I bring here the solution presented: Response in ONLY In free translation: It…
-
5
votes1
answer10470
viewsA: How to step enctype="Multipart/form-data" by $.post?
Short answer: does not pass! The method jQuery.post() "aka" $.post() was designed to "load data from the server using a request HTTP POST" the parameters of the type String or Plainobject are…
jqueryanswered Lauro Moraes 3,871 -
0
votes1
answer632
viewsA: Assign function to dynamically generated button
The easiest way to work with events in dynamically created elements is by using jQuery see: $('body').on('click', '.uma-classe-qualquer', function(evt) { // aqui é possível pegar qualquer informação…
-
1
votes2
answers1212
viewsA: Check out of Base64?
Using javascript the most correct approach to check whether a given {String} was (is) coded in Base64 on the front end is enveloping in a block try\catch the return of function atob() compared to…
-
1
votes1
answer1669
viewsA: Modal of specific Confirmation
According to your example using the class ".Alert-confirm" and the method querySelector is not the most recommended practice because if there is more than one declaration of this class on the same…
-
2
votes0
answers487
viewsQ: Calculate file size of a dataURL (cost)
I’m uploading an image to Base64 (dataURL) for an application that uses express. As the user is doing the "cropping" of this image on the front end I found no other way to send but by dataURL... the…
-
0
votes0
answers35
viewsQ: Express.js check if request is made by iframe
How to check if request is made by iframe in "express js."? Example: WEBSITE TO: <iframe src="http://siteb.com/router"> site B: app.get('/router', (req, res, next) => // logica... }) The…
-
8
votes1
answer969
viewsA: What is the difference between Service Worker and Web Worker?
Basically, what’s the difference between the two? Basically Web Worker was designed to perform high-consumption functions without this interfering in the execution of the main code, that is, does…
-
1
votes1
answer336
viewsQ: Socket connection between servers
I have studied the communication between two (or more) servers raised in Nodejs via REST as I searched for content (references, explanations, benchmarks, etc.) I found indications of REST would…
-
2
votes1
answer327
viewsA: Node.js V6.11.5 error in Windows 10
Apparently you’re executing the command npm start at wrong location... you are running inside the installation folder on NodeJs. You should create a folder for your project and add the file to it…
-
0
votes2
answers836
viewsA: Get position of an element
You can find the element coordinates in relation to window current... the function below returns the "coordinates" in pixels where x represents the horizontal line (based on left measures) and y the…
jqueryanswered Lauro Moraes 3,871 -
1
votes2
answers8130
viewsA: Is it possible to read a. txt file in Javascript?
Although XMLHttpRequest be supported by the widest range of browsers I would recommend using the API Fetch she works on XMLHttpRequest and is more recent abstracting in much the heavy work. Like…
-
2
votes2
answers303
viewsQ: Download attribute, new line in text file
I’m trying to download a text file with information coming from a array but would like to separate these values in new line... tried some bad approaches unsuccessfully the result remains in only one…
-
1
votes0
answers119
viewsQ: List shared folder items
How to list items from a specific shared folder with an application created by developer console? The problem I’m using the package googleapis in Node to get a file system and upload images more…
-
0
votes1
answer129
viewsA: How to turn email object into Stream, Buffer or String?
If the object email for literally a object javascript (in memory) you can convert it to string using JSON and then use Buffer: const simpleParser = require('mailparser').simpleParser; let…
-
1
votes1
answer2654
viewsA: HTML pages: fill in form and make this data appear on a second page both HTML, but how?
You can use localStorage or sessionStorage of the API Web Storage For this just filter your form by saving the data "required" and store in JSON on the "next" page just check if the entry exists and…
-
4
votes1
answer706
viewsA: Earth distance calculation: URI - 1721
First the radius of the earth’s circumference in KM is of 6371 and not of 6378 as you put it in the example. To calculate the distance between two points using latitude and longitude you can use the…
pythonanswered Lauro Moraes 3,871 -
3
votes1
answer327
viewsA: Desktop Notifications - Javascript
According to the description you gave you need to use Push API instead of just Notifications API. Think about the API Push as a Notifications with "steroids". Whether your site is static or dynamic…
-
0
votes4
answers2232
viewsA: Select option selected
Assuming you fill your form with entries in the table you could have a specific field for this type select with on or off or by checking the same example item: <?php // sua lógica de acesso ao…
-
16
votes3
answers1013
viewsA: What is blockchain and how does it work?
What is blockchain and how it works? The basic concept of blockchain is quite simple: a distributed database that maintains a list of ordered records in an increasing sequence. This concept was…
-
8
votes2
answers431
viewsQ: Check if git is installed using Node
I’m starting in a desktop application with the use of Electron however I need to check if there is Git installed on the system because it must use git As the idea is to distribute on Windows, Linux…
-
0
votes1
answer149
viewsQ: Doubt Javascript Date() [front-end]
I’m building a personal blog using Github Pages and a desktop app con NWJS to do the back-end administration however I have a big question when presenting dates on the front-end. As it comes to a…
-
0
votes5
answers1042
viewsA: centralize a Nav menu
Remove the float and position of li and add display: inline-block; add a padding: 0; and text-align: center; at the ul ul { margin: 0; padding: 0; list-style: none; text-align: center; } a {…
-
2
votes1
answer411
viewsA: Set a text file on the server to be read every time you run . html (with embedded Javascript language)
You can store the information in a file json in the "static server" and query using the API Fetch which already returns a parsed json result for an object javascript(if there is a file with valid…
-
1
votes0
answers62
viewsQ: Serve custom . js file in Express route
I have a specific "home" page for authenticated user that is served by a router however this authentication is made via cookie if there is this cookie "session" (created after user login and set…
-
0
votes2
answers218
viewsA: Group tags separated by PHP comma
I don’t know "mysqli" bad knowing that its return brings all tags grouped can do something like: $raw = 'exemplo1,exemplo2,exemplo3,exemplo2'; $string = implode(',', array_unique(explode(',',…
-
3
votes1
answer129
viewsQ: calculate percentage of iterated items in a loop
How to get the percentage of total items in an array that have been processed in a loop? Example: // array fictício (238 itens) var arr =…
-
1
votes1
answer131
viewsQ: Convert strings to boolean
I’m dynamically adding one javascript and its src need to pass some parameters... the following function creates this "querystring": var querystring = {a:'b',b:true,c:'d',e:false}; var query =…
-
0
votes2
answers457
viewsA: Count and compare number of keys and values between objects
Knowing that: the object "original" possesses properties and that these possess other properties themselves and all end values are of type string and without addressing validation issues (outside…
-
1
votes2
answers457
viewsQ: Count and compare number of keys and values between objects
I am using Javascript objects to transcribe the interface of an app, however, I would like to create a tool for collaborative transcription but do not know how to proceed. Simplistically the object…
-
0
votes1
answer284
viewsA: Windows Service on Node
You can use NW.js to compile a cross-platform executable (Windows, Linux and Mac) based on nodejs and at its source make a call to the package os-service (which is also cross-platform) and configure…
-
0
votes2
answers578
viewsA: Function to create hash in SRI pattern
When searching in the community about SRI did not get results so I leave my own answer. In a practical way I arrived at the result in two ways PHP: <?php $file = file_get_contents('./main.js');…
-
2
votes2
answers578
viewsQ: Function to create hash in SRI pattern
I was looking at a new specification W3C SRI (Subresource Integrity) which roughly means Integrity of the Sub-resource that promises to bring more security to resources hosted on third-party servers…
-
4
votes1
answer893
viewsA: How to get javascript file content in string form?
When using XMLHttpRequest asynchronous you should use a function of callback to return the answer (if any) because Return always returns undefined because he doesn’t expect "the answer" to the…
-
2
votes1
answer265
viewsQ: What is the "right way" to use PHP destructors
When searching for references of good practices in PHP for memory management I came across several intentions of how to use destructors. I know the leading actor is Garbage Collector but this is not…
-
2
votes1
answer433
viewsA: Adjust Background as per resolution
I use Foundation also and the following excerpt tested in Chrome and Firefox updated: // supondo um identificador tipo classe para sua div .my-div{ background-image: url(../img/fundos/fundo.png);…
cssanswered Lauro Moraes 3,871 -
2
votes2
answers666
viewsA: Problems with Bcrypt password
When registering an entry (user) you encrypt... which will be stored a hash. When performing the check you must re-encrypt the provided input which will generate a new value (other than the old one)…
-
0
votes3
answers362
viewsA: how best to create a cookie for the user voting system to vote once
Good I do not know open voting system (for users not registered) that ensures data reliability. If this is the case only with the use of cookies or data on localStorage in both cases can be easily…
phpanswered Lauro Moraes 3,871