📜 ⬆️ ⬇️

Several finds

Cross Domain Queries with YQL


As a client web developer, I always want to reduce the cost of consuming server resources. Maybe I'm the only one I do not know. But there is a group of tasks that are simply not feasible on the client side. One of these tasks: a request for a foreign domain. We have to create a server script, which acts as an intermediary between the browser and the server from which we want to pull the data, giving the data as if from its domain.

The day before yesterday, one respected person from the javascript.ru forum with the nickname melky casually mentioned some strange, at first glance, jQuery plugin called jquery.xdomainajax.js
The inquisitive mind of the programmer doesn’t like all sorts of plugins, without understanding the essence, so I picked out the most necessary part:
var query = 'select * from html where url="http://javascript.ru/" and xpath="*"' var url = 'http://query.yahooapis.com/v1/public/yql?q='+encodeURI(query)+'&format=xml&callback=callback'; var script = document.createElement('script'); script.src = url; document.body.appendChild(script); function callback(data) { console.log(data); //     data.result[0] } 


Open the console and run the code. As you can see, the url of the site is being pushed into the request and the XML request is in the form of xpath, the answer comes in the form of jsonp. If you write format = json in the URL, the answer comes in the form of an object with tags.
I didn’t go further than this application, so it’s better to study the hardware yourself here: developer.yahoo.com/yql
')
In the comments, they insist on specifying restrictions on the number of requests from a single IP and requests using accesskey, which we don’t have (so you can probably score :)).


Cross-domain loading of image data


Not so interesting, but just in case
getImageData - jQuery plugin that allows you to extract image data from other domains, for use on canvas or WebGL. By default, the author allows you to use your server as a proxy, but you can also deploy such a server on your own using node.js, php or AppEngine

SVG → Canvas with Canvg


Render SVG to Canvas based on specification. SVG is a very handy tool for designing some buttons, complex winding lines and gradients with the usual DOM manipulation. Now you can generate vector graphics in the browser and save directly on the client or server, without using the server converter.

Using the History API in older browsers using history.js


No, I’ll disappoint you, for old browsers the hash is used as before, but now you can use the same functions to change the address without reloading the page.

Downloading client-generated files


There is such a problem: if the file is generated on the browser side, then it will not be possible to give it a normal name and extension. The problem is well described here: jszip.stuartk.co.uk . A breathable flash with a crutch called Downloadify comes to the rescue: github.com/dcneiner/Downloadify
An example of the work can be found here: pixelgraphics.us/downloadify/test.html

Very nice substitute select ("select")


No comments: D
Chosen , Example

Source: https://habr.com/ru/post/135413/


All Articles