Posts by Salomão Neto • 673 points
24 posts
-
0
votes0
answers82
viewsQ: Algorithm of Habbo walls
I’m developing a Javascript game and its environment is very similar to that of Habbo: A floor and walls only at the bottom of the floor. The game map is dynamic and represented by a matrix of…
-
1
votes2
answers33
viewsA: How do I change the title of the browser tab repeatedly?
function alternateTitle (...titles) { let currentIndex = 0; return setInterval(() => { if (currentIndex === titles.length) { currentIndex = 0 } document.title = titles[currentIndex++] }, 1000) }…
-
2
votes1
answer141
viewsQ: Perspective effect with Javascript Canvas
I need to fill this figure so that the image is slightly distorted, giving a perspective effect. I believe it is possible with the setTransform(), but I still don’t understand how it works to…
-
1
votes1
answer146
viewsQ: Move Sprite to the mouse position with Phaser
I need to move a Sprite to the mouse position, I used the function game.physics.arcade.moveToPointer(), but only works with sprites who have the body of the type Phaser.Physics.Arcade. How do I use…
-
1
votes0
answers95
viewsQ: Change color according to the beat of the song
I’m creating a music player and I need the frequency bars to change color as the beats stronger. I managed to do it https://codepen.io/salomaosnff/pen/eezgVL but it’s too fast.…
-
2
votes1
answer91
viewsQ: Convert path (String) to object
I need a function that converts: "/home/username/Documentos/app.txt" for an object: { "home": { "username":{ "Documentos": "app.txt":{} } } } ` I was thinking of breaking the string by the "/", but…
-
1
votes1
answer96
viewsQ: Sort records containing numbers at the end
I have a table with the following records: +----+------------+--------------+ | id | title | url | +----+------------+--------------+ | 1 | Olá Mundo! | ola-mundo-1 | | 5 | Olá Mundo! | ola-mundo-3…
-
1
votes0
answers192
viewsQ: How to model a system of friends with Mongodb?
I’m creating a small social network and I need to create the friendships part. I have two ideas: A Collection Friendships containing the fields sender, destnatary and answer and make a populate with…
-
4
votes3
answers155
viewsA: Access a property’s value through a String
I finally managed to solve! var obj = { nome: "João", animais: { gato: "Foo", cachorro: "Bar" } }; function acessar(obj, prop){ var tmp = obj; var campos = prop.split("."); for(var i in campos){…
-
3
votes3
answers155
viewsQ: Access a property’s value through a String
Suppose I have the following object: var pessoa = { nome: "João", animais: { cachorro: "Rex", gato: "Pipoca", } } I need a function to do something like this: var gatoDoJoao =…
-
1
votes1
answer194
viewsQ: Function to create buttons from an Object
I need to create a function similar to this: criarBotoes({ "Abrir": function(dados){ alert("Abrindo..."); console.log(dados); }, "Fechar": function(dados){ alert("Fechar..."); console.log(dados); },…
-
1
votes1
answer541
viewsQ: Calculate the diameter of a circle to fill the rectangle according to the mouse position
My question is more for math than programming. but Anyway... I am creating a small script to determine the position (which is done by the mouse) and the diameter of a circle that is inside a…
-
7
votes1
answer1595
viewsQ: Is it right to create my HTML tags?
I’m creating a website and I don’t really like adding classes and id’s because I think it makes HTML a little dirty. The system I am developing will not be indexed by the search engines, because it…
-
4
votes1
answer150
viewsQ: Create an instance of jQuery from an array
I have the following array: var elementos = [$("#elemento1"), $("#elemento2"), $("#elemento3")] I need to create a function that "converts" this array into a jQuery instance, so I can use jQuery…
-
4
votes1
answer505
viewsQ: Search Matrix index from json value using the index
I have the following matrix: var usuarios = [ {nome: "João", id: 1}, {nome: "Maria", id: 2}, {nome: "José", id: 3}, {nome: "Ana", id: 4}, ]; I need to return the José user index. I tried using the…
-
3
votes1
answer148
viewsQ: Wait variable value to return function
I’m trying to create a function that turns a file into a Data URL. But I am facing a problem: The return value of the function is not what I expected. Just follow my code: File.prototype.toData =…
-
5
votes3
answers296
viewsQ: Function that converts this string to a json
I have a string in the following format: "a=123 b="ABC" c="Olá Mundo!"" need to create a function that transforms this string in this json: { a : 123, b : "ABC", c : "Olá Mundo!" } I think it has a…
-
1
votes2
answers1268
viewsQ: Add Date methods using typescript
I’m trying to create a date format method. Something like var minhaData = new Date(); console.log(minhaData.format('[d]/[m]/[Y]')); I searched the internet and managed to develop this excerpt:…
-
0
votes1
answer51
viewsQ: Select only items that contain the number in their value
I have a table conversas: STRUCTURE +--------+---------+ | Nome | Tipo | +--------+---------+ | id | int | | users | text | | titulo | varchar | +--------+---------+ I need to select items that…
-
1
votes1
answer164
viewsQ: List posts of friends
I have a database with the following structure: Table users: usuario_id Primária int(11) nome varchar(128) nascimento date Table friendships: id_amizade Primária int(11) id_remenente int(11)…
-
1
votes1
answer1923
viewsA: Return javascript object
What a mess I made, just put a Return! var Mensagem = function(opcoes){ var padrao = { titutlo: "", msg: "", lido: false } var config = $.extend(padrao, opcoes); return config; } var msg = new…
-
1
votes1
answer1923
viewsQ: Return javascript object
var Mensagem = function(opcoes){ var padrao = { titutlo: "", msg: "", lido: false } var config = $.extend(padrao, opcoes); this.prototype = config; } var msg = new Mensagem({ titulo: "Olá mundo!",…
-
7
votes1
answer216
viewsQ: Undefined error using replace()
I’m trying to make a sort of a people appointment, I made an attempt, but I was unsuccessful. Where is the error?? var nome =["Ana", "João", "Maria", "José"]; var frase = "@[1] é casado com @[0], e…
-
1
votes1
answer43
viewsQ: Return CSS file classes using Regex and PHP
I have the Following CSS: .icon-a{ background:black; color:white; } .icon-b{ backgroundwhite; color:black; } .icon-c{ background:blue; color:yellow; } I wanted a PHP script that could read the CSS…