<snapdata remixID="8668086"><project name='SnapCon19 - Project run counter, using an web API' app='Snap! 5.1, http://snap.berkeley.edu' version='1'>
  <notes>Uses the https://countapi.xyz/ API. Just change the key in the project to something unique and get your own stats.</notes>
  <thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAABnklEQVR4nO3Vsa3CUBAFUbqBwFRiB3abDigKCnk/QiIxhCP5nyNtfoOR9jIgdKkH8L8JkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQAD9xut7Hvez3j9AT4xbZtY13Xsa7rmKZpPJ/PetLpCPCHd4Cft23bWJalnnYKAvzhKMB5nutppyDALz5f8P1+H6/Xq550OgI8cL1ex+PxqGecngBJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEkJkJQASQmQlABJCZCUAEn9AXE1r8uAI+NYAAAAAElFTkSuQmCC</thumbnail>
  <stage inheritance='true' id='1' volume='100' height='360' tempo='60' lines='round' width='480' sublistIDs='false' name='Stage' threadsafe='false' codify='false' color='255,255,255,1' scheduled='false' pan='0' ternary='false' costume='0'>
    <pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAACtUlEQVR4nO3BMQEAAADCoPVPbQwfoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+Bo3+AAF/RMkcAAAAAElFTkSuQmCC</pentrails>
    <costumes>
      <list id='2' struct='atomic'/>
    </costumes>
    <sounds>
      <list id='3' struct='atomic'/>
    </sounds>
    <variables/>
    <blocks/>
    <scripts/>
    <sprites>
      <sprite x='0' pen='tip' id='8' y='0' name='Sprite' idx='1' volume='100' rotation='1' scale='1' heading='90' costume='0' color='80,80,80,1' pan='0' draggable='true'>
        <costumes>
          <list id='9' struct='atomic'/>
        </costumes>
        <sounds>
          <list id='10' struct='atomic'/>
        </sounds>
        <blocks/>
        <variables/>
        <scripts>
          <script x='10' y='10'>
            <block s='receiveGo'/>
            <block s='doSayFor'>
              <block s='reportJoinWords'>
                <list>
                  <l>This project has been run </l>
                  <block s='reportListItem'>
                    <l>2</l>
                    <block s='reportListItem'>
                      <l>1</l>
                      <custom-block s='listify %mlt'>
                        <block s='reportURL'>
                          <block s='reportJoinWords'>
                            <list>
                              <l>https://api.countapi.xyz/hit/</l>
                              <l>83369a26-7942-455f-bcb5-67bce12cf9bb</l>
                            </list>
                          </block>
                        </block>
                      </custom-block>
                    </block>
                  </block>
                  <l> of times! Nice.</l>
                </list>
              </block>
              <l>2</l>
            </block>
          </script>
        </scripts>
      </sprite>
    </sprites>
  </stage>
  <hidden/>
  <headers/>
  <code/>
  <blocks>
    <block-definition s='%&apos;method&apos; url: %&apos;url&apos; send: %&apos;payload&apos; headers: %&apos;headers&apos;' category='sensing' type='reporter'>
      <header/>
      <code/>
      <translations>pt:a resposta a _ de _ enviando _ e cabeçalhos _</translations>
      <inputs>
        <input readonly='true' type='%s'>GET<options>GETPOSTPUTDELETE</options>
        </input>
        <input type='%s'>https://snap.berkeley.edu</input>
        <input type='%s'/>
        <input readonly='true' type='%mult%l'/>
      </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, &apos;list&apos;);  for (i = 1; i &lt;= headers.length(); i += 1) {    header = headers.at(i);    proc.assertType(header, &apos;list&apos;);    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(&apos;doYield&apos;);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: %&apos;key&apos; value: %&apos;value&apos;' category='operators' type='reporter'>
      <header/>
      <code/>
      <translations>pt:um par (chave: _ , valor: _ )</translations>
      <inputs>
        <input type='%s'/>
        <input type='%s'/>
      </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' category='sensing' type='reporter'>
      <comment x='0' w='200' collapsed='false' y='0'>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/>
      <code/>
      <translations>pt:a localização actual do dispositivo</translations>
      <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(&apos;doYield&apos;);  proc.pushContext();}</l>
            </block>
            <list/>
          </block>
        </block>
      </script>
    </block-definition>
    <block-definition s='listify %&apos;jsonString&apos;' category='operators' type='reporter'>
      <header/>
      <code/>
      <translations>pt:os dados JSON _ em formato de lista</translations>
      <inputs>
        <input type='%mlt'/>
      </inputs>
      <script>
        <block s='doReport'>
          <block s='evaluate'>
            <block s='reportJSFunction'>
              <list>
                <l>jsonString</l>
              </list>
              <l>return listify(JSON.parse(jsonString));function listify(jsonObject) {  if (jsonObject instanceof Array) {    return new List(jsonObject.map(function(eachElement) { return listify(eachElement)}));  } else if (jsonObject instanceof Object) {    return new List(Object.keys(jsonObject).map(function(eachKey) { return new List([eachKey,listify(jsonObject[eachKey])])} ))  } else {    return jsonObject  }}</l>
            </block>
            <list>
              <block var='jsonString'/>
            </list>
          </block>
        </block>
      </script>
    </block-definition>
    <block-definition s='value at key %&apos;key&apos; of %&apos;lst&apos;' category='operators' type='reporter'>
      <header/>
      <code/>
      <translations>pt:o valor com chave _ em _</translations>
      <inputs>
        <input type='%s'/>
        <input type='%l'/>
      </inputs>
      <script>
        <block s='doWarp'>
          <script>
            <block s='doForEach'>
              <l>each item</l>
              <block var='lst'/>
              <script>
                <block s='doIf'>
                  <block s='reportEquals'>
                    <block s='reportListItem'>
                      <l>1</l>
                      <block var='each item'/>
                    </block>
                    <block var='key'/>
                  </block>
                  <script>
                    <block s='doReport'>
                      <block s='reportListItem'>
                        <l>2</l>
                        <block var='each item'/>
                      </block>
                    </block>
                  </script>
                </block>
              </script>
            </block>
          </script>
        </block>
        <block s='doReport'>
          <l/>
        </block>
      </script>
    </block-definition>
  </blocks>
  <variables/>
</project><media name="SnapCon19 - Project run counter, using an web API" app="Snap! 5.1, http://snap.berkeley.edu" version="1"></media></snapdata>