Skip to content

Instantly share code, notes, and snippets.

View MrSwitch's full-sized avatar
💭
I may be slow to respond.

Andrew Dodson MrSwitch

💭
I may be slow to respond.
View GitHub Profile
@MrSwitch
MrSwitch / httpRequest.js
Created October 20, 2012 07:05
httpRequest, quick and easy
//
// httpRequest
// Make Cross Origin http requests for JSON data.
// The first path is url, the second is a callback, as a JSON object.
// If XHR CORS is not supported then JSONP is used. "&callback=" is appended to the request URL.
// @author Andrew Dodson
function httpRequest(url,callback){
// IE10, FF, Chrome
if('withCredentials' in new XMLHttpRequest()){
@MrSwitch
MrSwitch / saveAs.js
Created August 31, 2012 13:55
FileSaver window.saveAs shim
// window.saveAs
// Shims the saveAs method, using saveBlob in IE10.
// And for when Chrome and FireFox get round to implementing saveAs we have their vendor prefixes ready.
// But otherwise this creates a object URL resource and opens it on an anchor tag which contains the "download" attribute (Chrome)
// ... or opens it in a new tab (FireFox)
// @author Andrew Dodson
// @copyright MIT, BSD. Free to clone, modify and distribute for commercial and personal use.
window.saveAs || ( window.saveAs = (window.navigator.msSaveBlob ? function(b,n){ return window.navigator.msSaveBlob(b,n); } : false) || window.webkitSaveAs || window.mozSaveAs || window.msSaveAs || (function(){