Questions tagged as 'javascript'

2
answers

Generate a random profession for Online Players

I am creating a small game (Android) to play me some more friends of mine. The game is called "Cops and Thieves". At least it is necessary to have 4 players in which one of them will be the POLICE, another will be the CRIMINAL, another will be t...
asked by 23.12.2016 / 10:05
2
answers

How do I make a function wait for the $ http result?

I'm having trouble with the following code: $http({ method: 'POST', url: '/publicacao/', data: $scope.publicacao, headers: {'Content-Type': 'application/json'} }).success(function(publicacao) { $scope.publicacao = publicaca...
asked by 29.01.2017 / 21:29
2
answers

Long click with JavaScript

On Android there is the OnLongClickListener method in which you can hold your finger on a View and an action is triggered (if the developer sets an action) if that click stays for a little over 1 second. p> I have this small tabl...
asked by 19.06.2017 / 02:24
2
answers

Function () X Function.call () [duplicate]

When parsing Javascript / jQuery plugins, I usually see functions being invoked with .call() . Home I understand that by calling functions in this way, the first parameter passed is this (in this case, the function call provider)....
asked by 25.08.2017 / 19:43
2
answers

Key code does not hold the ESC key

I'm making a function so that when a keyboard key is pressed, it performs another function. With the letter keys, numbers and until Enter works. However, the ESC key does not work. Has anyone ever had to do something similar? Follow the code...
asked by 10.08.2017 / 14:52
1
answer

How to transform an asynchronous function into a synchronous one?

I have an asynchronous function and would like it to become synchronous, as being asynchronous it is sending the data to the client before even completing the necessary steps, it follows code: imap.once('ready', function () { openInbox(fun...
asked by 30.08.2017 / 14:35
2
answers

Should I use a variable that takes an HTML element as global or local?

function message (className, text) { /*Esta variável*/var message = document.getElementById("message");/*Esta variável*/ message.className = className; message.innerHTML = text; setTimeout(function () { message.innerHTML =...
asked by 12.07.2017 / 13:32
1
answer

How to detect the collision between two squares / rectangles

Anyone who provides a response that explains all the nuances required to do so in javascript will earn the points.     
asked by 15.03.2017 / 14:53
2
answers

Find 2 date attributes in a single element

How can I find a particular attribute that contains another specific attribute attribute? for example: <a class="fc-draggable" data-belongs="3" data-target="2"></a> I can select all elements that contain a given attribute using:...
asked by 23.09.2016 / 20:47
1
answer

How to synchronize two scroll bars based on percentage?

I have a <DIV> with overflow and a <TEXTAREA> , the problem is that the element that will be synchronized ends up rolling over than expected, instead of following a percentage basis . What I've done so far: f...
asked by 13.08.2016 / 22:18