Skip to content

Commit c4b0dac

Browse files
author
Lauren McCarthy
committed
update to v 0.3.12
1 parent f399b15 commit c4b0dac

File tree

3 files changed

+14
-35
lines changed

3 files changed

+14
-35
lines changed

lib/p5.js

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! p5.js v0.3.11 November 23, 2014 */
1+
/*! p5.js v0.3.12 November 23, 2014 */
22
var shim = function (require) {
33
window.requestDraw = function () {
44
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
@@ -2423,7 +2423,7 @@ var imagepixels = function (require, core, filters, p5Color) {
24232423
else
24242424
context[name] = definition();
24252425
}('reqwest', this, function () {
2426-
var win = window, doc = document, httpsRe = /^http/, protocolRe = /(^\w+):\/\//, twoHundo = /^(20\d|1223)$/, byTag = 'getElementsByTagName', readyState = 'readyState', contentType = 'Content-Type', requestedWith = 'X-Requested-With', head = doc[byTag]('head')[0], uniqid = 0, callbackPrefix = 'reqwest_' + +new Date(), lastValue, xmlHttpRequest = 'XMLHttpRequest', xDomainRequest = 'XDomainRequest', noop = function () {
2426+
var win = window, doc = document, twoHundo = /^(20\d|1223)$/, byTag = 'getElementsByTagName', readyState = 'readyState', contentType = 'Content-Type', requestedWith = 'X-Requested-With', head = doc[byTag]('head')[0], uniqid = 0, callbackPrefix = 'reqwest_' + +new Date(), lastValue, xmlHttpRequest = 'XMLHttpRequest', xDomainRequest = 'XDomainRequest', noop = function () {
24272427
}, isArray = typeof Array.isArray == 'function' ? Array.isArray : function (a) {
24282428
return a instanceof Array;
24292429
}, defaultHeaders = {
@@ -2457,20 +2457,13 @@ var imagepixels = function (require, core, filters, p5Color) {
24572457
return data;
24582458
}
24592459
};
2460-
function succeed(r) {
2461-
var protocol = protocolRe.exec(r.url);
2462-
protocol = protocol && protocol[1] || window.location.protocol;
2463-
return httpsRe.test(protocol) ? twoHundo.test(r.request.status) : !!r.request.response;
2464-
}
24652460
function handleReadyState(r, success, error) {
24662461
return function () {
24672462
if (r._aborted)
24682463
return error(r.request);
2469-
if (r._timedOut)
2470-
return error(r.request, 'Request is aborted: timeout');
24712464
if (r.request && r.request[readyState] == 4) {
24722465
r.request.onreadystatechange = noop;
2473-
if (succeed(r))
2466+
if (twoHundo.test(r.request.status))
24742467
success(r.request);
24752468
else
24762469
error(r.request);
@@ -2480,10 +2473,9 @@ var imagepixels = function (require, core, filters, p5Color) {
24802473
function setHeaders(http, o) {
24812474
var headers = o['headers'] || {}, h;
24822475
headers['Accept'] = headers['Accept'] || defaultHeaders['accept'][o['type']] || defaultHeaders['accept']['*'];
2483-
var isAFormData = typeof FormData === 'function' && o['data'] instanceof FormData;
24842476
if (!o['crossOrigin'] && !headers[requestedWith])
24852477
headers[requestedWith] = defaultHeaders['requestedWith'];
2486-
if (!headers[contentType] && !isAFormData)
2478+
if (!headers[contentType])
24872479
headers[contentType] = o['contentType'] || defaultHeaders['contentType'];
24882480
for (h in headers)
24892481
headers.hasOwnProperty(h) && 'setRequestHeader' in http && http.setRequestHeader(h, headers[h]);
@@ -2515,6 +2507,7 @@ var imagepixels = function (require, core, filters, p5Color) {
25152507
script.src = url;
25162508
script.async = true;
25172509
if (typeof script.onreadystatechange !== 'undefined' && !isIE10) {
2510+
script.event = 'onclick';
25182511
script.htmlFor = script.id = '_reqwest_' + reqId;
25192512
}
25202513
script.onload = script.onreadystatechange = function () {
@@ -2575,15 +2568,9 @@ var imagepixels = function (require, core, filters, p5Color) {
25752568
this.fn = fn;
25762569
init.apply(this, arguments);
25772570
}
2578-
function setType(header) {
2579-
if (header.match('json'))
2580-
return 'json';
2581-
if (header.match('javascript'))
2582-
return 'js';
2583-
if (header.match('text'))
2584-
return 'html';
2585-
if (header.match('xml'))
2586-
return 'xml';
2571+
function setType(url) {
2572+
var m = url.match(/\.(json|jsonp|html|xml)(\?|$)/);
2573+
return m ? m[1] : 'js';
25872574
}
25882575
function init(o, fn) {
25892576
this.url = typeof o == 'string' ? o : o['url'];
@@ -2596,12 +2583,12 @@ var imagepixels = function (require, core, filters, p5Color) {
25962583
this._completeHandlers = [];
25972584
this._erred = false;
25982585
this._responseArgs = {};
2599-
var self = this;
2586+
var self = this, type = o['type'] || setType(this.url);
26002587
fn = fn || function () {
26012588
};
26022589
if (o['timeout']) {
26032590
this.timeout = setTimeout(function () {
2604-
timedOut();
2591+
self.abort();
26052592
}, o['timeout']);
26062593
}
26072594
if (o['success']) {
@@ -2627,7 +2614,6 @@ var imagepixels = function (require, core, filters, p5Color) {
26272614
}
26282615
}
26292616
function success(resp) {
2630-
var type = o['type'] || resp && setType(resp.getResponseHeader('Content-Type'));
26312617
resp = type !== 'jsonp' ? self.request : resp;
26322618
var filteredResponse = globalSetupOptions.dataFilter(resp.responseText, type), r = filteredResponse;
26332619
try {
@@ -2663,10 +2649,6 @@ var imagepixels = function (require, core, filters, p5Color) {
26632649
}
26642650
complete(resp);
26652651
}
2666-
function timedOut() {
2667-
self._timedOut = true;
2668-
self.request.abort();
2669-
}
26702652
function error(resp, msg, t) {
26712653
resp = self.request;
26722654
self._responseArgs.resp = resp;
@@ -2718,9 +2700,6 @@ var imagepixels = function (require, core, filters, p5Color) {
27182700
this._errorHandlers.push(fn);
27192701
}
27202702
return this;
2721-
},
2722-
'catch': function (fn) {
2723-
return this.fail(fn);
27242703
}
27252704
};
27262705
function reqwest(o, fn) {

0 commit comments

Comments
 (0)