kopia lustrzana https://github.com/backface/turtlestitch
4 wiersze
1.8 KiB
XML
4 wiersze
1.8 KiB
XML
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="%'method' url: %'url' send: %'payload' headers: %'headers'" type="reporter" category="sensing"><header></header><code></code><inputs><input type="%s" readonly="true">GET<options>GET
|
|
POST
|
|
PUT
|
|
DELETE</options></input><input type="%s">http://snap.berkeley.edu</input><input type="%s"></input><input type="%mult%l" readonly="true"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>method</l><l>url</l><l>data</l><l>headers</l><l>proc</l></list><l>var response, i, header;
if (!proc.httpRequest) {
 proc.httpRequest = new XMLHttpRequest();
 proc.httpRequest.open(method, url, true);
 proc.assertType(headers, 'list');
 for (i = 1; i <= headers.length(); i += 1) {
 header = headers.at(i);
 proc.assertType(header, 'list');
 proc.httpRequest.setRequestHeader(
 header.at(1),
 header.at(2)
 );
 }
 proc.httpRequest.send(data || null);
} else if (proc.httpRequest.readyState === 4) {
 response = proc.httpRequest.responseText;
 proc.httpRequest = null;
 return response;
}
proc.pushContext('doYield');
proc.pushContext();</l></block><list><block var="method"/><block var="url"/><block var="payload"/><block var="headers"/></list></block></block></script></block-definition><block-definition s="key: %'key' value: %'value'" type="reporter" category="operators"><header></header><code></code><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><block var="key"/><block var="value"/></list></block></block></script></block-definition></blocks> |