Questions tagged as 'javascript'

2
answers

Syntax, meaning

$("#add_city_btn2").click(function() { var city = $("#add_city2").val(); $("#cities2").append($("<option>", { text: city, selected: "selected"})).change(); $("#add_city2").val(''); return false; }); What does the line...
asked by 13.10.2015 / 17:42
1
answer

EaselJS isometric map, problem in code, can identify

window.onload = function() { var stage = new createjs.Stage("canvas"); var bmp; var board; var img; var data; var tileClone; var x,y; var mapWidth; var mapHeight; img = new createjs.SpriteSheet({ "images": ["images/tiles.png"], "frames...
asked by 01.05.2014 / 22:06
2
answers

___ ___ erkimt What are the data transfer forms available to JavaScript? ______ qstntxt ___

It is common to find questions, answers and tutorials talking about AJAX, which is nothing more than %code% , as a way of transferring data between two computers.

I would like to know if there are other forms , whether standard or proprietary, limited in some condition or open to any user and site. An example of a limited form, if any, would be an API restricted to extensions.

In particular, but not restricting, I'm looking for a way to transfer data - something between 10 and 30 bytes - in the fastest way possible between two computers within the same network. Peer-to-Peer would be ideal, but I do not know if JS supports it. I have already tried testing services such as Firebase , which allowed a minimum response time, however, using a server out of network and with occasional loss of data.

Knowing other ways I wanted to find one that would fit better with what I'm developing. It does not look like the answer will be anything big: the options seem to be quite limited, since it looks like only AJAX is used.

    
______ azszpr8188 ___

There are several APIs that will allow you to transport data via Javascript.

Some will only allow you to receive data, others will allow you to send and receive.

The ones that allow you to send and receive data are:

  • %code%
    • Requests via HTTP protocol
  • %code%
    • It is a cross-compatible HTTP protocol focused on message exchanges lighter and faster than request, but it does not have a state resolution as efficient as %code%
    • W3C Specification
  • %code%
    • Peer-to-peer data exchange protocol was created to solve the problem of video and audio transmissions between browsers.
    • W3C Specification

If the data transmission needs to be p2p, the ideal is to use WebRTC, but it is still rather complex to create a server that will make the handshake between two browsers and start communication.

A simpler solution is to use WebSockets , but all information will go through a server that will receive data from one client and send it to another or other clients. But the websocket has the constraint of working with UTF-8, however it is possible to use data converters to convert binary data to UTF-8 before being transmitted and back to the original format when received, there are several ways, one of them is using the %code% .

    
______ azszpr8194 ___

I suggest using Socket IO, a javascript extension already adapted for use in cross-browser and that has an extra advantage, it chooses the most efficient way to carry data between the technologies below (which are the answer to your question) :

1) WebSocket;
2) Adobe Flash Socket;
3) AJAX long polling;
4) AJAX multipart streaming;
5) Forever iframe;
6) JSONP Polling.

Still, this extension has excellent compatibility: IE 5.5+; Safari 3+; Chrome 4+; Firefox 3+; Opera 10.61+; Iphone / Ipad Safari; Android Webkit and Webkits Webkit.

link

I have had excellent experiences with this extension. When you opt for a path where fallbacks are already included, everything gets easier!

Good Luck!

    
___

It is common to find questions, answers and tutorials talking about AJAX, which is nothing more than XMLHttpRequest , as a way of transferring data between two computers. I would like to know if there are other forms , whether standard...
asked by 06.03.2014 / 01:30
2
answers

Find Element tr of a certain content

I'd like to know how to find a particular <tr> element in a numbered table. For example: In a table where each <tr> line has its <td> cells numbered 1-5, containing 4 lines <tr> , if I pass the...
asked by 30.03.2015 / 17:09
1
answer

How to create a glass pane in JavaScript?

I'm trying to create a " glass pane " in JavaScript, similar to or supported by Java . The goal is to offer a kind of interactive help to the user, where information about each element is superimposed on the screen, and all elements except the...
asked by 15.06.2014 / 08:31
3
answers

Solution for scanning documents by browser

I want users to% direct from the browser to then pro server . I found APIS that do this but all are paid and the costly licenses! Can anyone present a solution? Even if the client has to install a plugin or something that outputs...
asked by 05.03.2016 / 07:37
3
answers

Is referring to an element via its id considered bad?

In Javascript, you can reference any element that has a id (and in some cases a name ) by simply using an identifier with the same name - without having to declare it: / p> <div id="teste">Teste</div> console.log(test...
asked by 26.06.2014 / 20:41
3
answers

How is the math calculation of the module (%) done in JavaScript?

I'm trying to use "reverse engineering" to understand what the calculation is for the module ( % ), but I can not understand and wanted to understand and clarify myself, to clarify this part, before moving forward and start doing exercises...
asked by 18.10.2015 / 17:21
2
answers

Replacement performance in string

I need to do some bulk replacement with Javascript. For my specific problem, let's assume I need to replace a specific substring. I need to change every occurrence of "blue" to "green." So, I have two ways to do it: var foo = pegaTexto(); /...
asked by 10.02.2014 / 22:07
2
answers

How to let the page background degrade with JavaScript?

It would look something like the image below; I have no idea how to do this. I do not want to use image, I want to generate with code.     
asked by 17.09.2014 / 04:22