kopia lustrzana https://github.com/backface/turtlestitch
fix typo in httpBlocks.xml
"Current blocks" was spelled "curent." Thanks Kartik for catching this.upd4.1
rodzic
8e33ab39c4
commit
23e8e018bd
|
@ -1,4 +1,4 @@
|
||||||
<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
|
<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
|
POST
|
||||||
PUT
|
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><block-definition s="curent location" type="reporter" category="sensing"><comment x="0" y="0" w="200" collapsed="false">Reports a three-item list containing the latitude and longitude of the user, and the precision of the measurements. Works only if the user allows snap.berkeley.edu access to location data. Some browsers also require an HTTPS connection to Snap!.</comment><header></header><code></code><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>proc</l></list><l>if (!proc.geostarted) {
 var geo = navigator.geolocation;
 var cords = [];
 var options = {
 enableHighAccuracy: false,
 };

 function success(pos) {
 console.log(pos);
 proc.geocords = [pos.coords.latitude,
 pos.coords.longitude,
 pos.coords.accuracy];
 }

 function error(err) {
 alert("ERROR " + err.code + ": " + err.message);
 }
 proc.geostarted = true;
 proc.geocords = null;
 console.log("starting geolocation")
 geo.getCurrentPosition(success, error, options);
} else if (proc.geocords) {
 var cords = proc.geocords;
 proc.geostarted = null;
 proc.geocords = null;
 console.log("returning");
 return new List(cords);
} else {
 console.log("yielding");
 proc.pushContext('doYield');
 proc.pushContext();
}</l></block><list></list></block></block></script></block-definition></blocks>
|
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><block-definition s="current location" type="reporter" category="sensing"><comment w="200" collapsed="false">Reports a three-item list containing the latitude and longitude of the user, and the precision of the measurements. Works only if the user allows snap.berkeley.edu access to location data. Some browsers also require an HTTPS connection to Snap!.</comment><header></header><code></code><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>proc</l></list><l>if (!proc.geostarted) {
 var geo = navigator.geolocation;
 var cords = [];
 var options = {
 enableHighAccuracy: false,
 };

 function success(pos) {
 console.log(pos);
 proc.geocords = [pos.coords.latitude,
 pos.coords.longitude,
 pos.coords.accuracy];
 }

 function error(err) {
 alert("ERROR " + err.code + ": " + err.message);
 }
 proc.geostarted = true;
 proc.geocords = null;
 console.log("starting geolocation")
 geo.getCurrentPosition(success, error, options);
} else if (proc.geocords) {
 var cords = proc.geocords;
 proc.geostarted = null;
 proc.geocords = null;
 console.log("returning");
 return new List(cords);
} else {
 console.log("yielding");
 proc.pushContext('doYield');
 proc.pushContext();
}</l></block><list></list></block></block></script></block-definition></blocks>
|
Ładowanie…
Reference in New Issue