kopia lustrzana https://github.com/backface/turtlestitch
Update localstorage_module.xml
Add reporter that finds a specified key.pull/95/head
rodzic
95b9be7284
commit
975292a92c
|
@ -1 +1 @@
|
|||
<blocks app="Snap! 6, https://snap.berkeley.edu" version="1"><block-definition s="store key: %'key' value: %'value' in browser" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>value</l><l>proc</l></list><l>proc.assertType(key, ['text', 'number']);
proc.assertType(value, ['text', 'number']);
window.localStorage.setItem('-snap-project-' + key, '' + value);</l></block><list><block var="key"/><block var="value"/></list></block></script></block-definition><block-definition s="stored data in browser" type="reporter" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list></list><l>var str = window.localStorage,
 len = str.length,
 result = [],
 key,
 i;
for (i = 0; i < len; i += 1) {
 key = str.key(i);
 if (key.startsWith('-snap-project-')) {
 result.push(new List([key.slice(14), str.getItem(key)]));
 }
}
return new List(result);</l></block><list></list></block></block></script></block-definition><block-definition s="remove key: %'key' in browser" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>proc</l></list><l>proc.assertType(key, ['text', 'number']);
window.localStorage.removeItem('-snap-project-' + key);</l></block><list><block var="key"/></list></block></script></block-definition><block-definition s="clear data in browser" type="command" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doWarp"><script><block s="doForEach"><l>item</l><custom-block s="stored data in browser"></custom-block><script><custom-block s="remove key: %s in browser"><block s="reportListItem"><l>1</l><block var="item"/></block></custom-block></script></block></script></block></script></block-definition></blocks>
|
||||
<blocks app="Snap! 6, https://snap.berkeley.edu" version="1"><block-definition s="store key: %'key' value: %'value' in browser" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>value</l><l>proc</l></list><l>proc.assertType(key, ['text', 'number']);
proc.assertType(value, ['text', 'number']);
window.localStorage.setItem('-snap-project-' + key, '' + value);</l></block><list><block var="key"/><block var="value"/></list></block></script></block-definition><block-definition s="stored data in browser" type="reporter" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list></list><l>var str = window.localStorage,
 len = str.length,
 result = [],
 key,
 i;
for (i = 0; i < len; i += 1) {
 key = str.key(i);
 if (key.startsWith('-snap-project-')) {
 result.push(new List([key.slice(14), str.getItem(key)]));
 }
}
return new List(result);</l></block><list></list></block></block></script></block-definition><block-definition s="remove key: %'key' in browser" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>key</l><l>proc</l></list><l>proc.assertType(key, ['text', 'number']);
window.localStorage.removeItem('-snap-project-' + key);</l></block><list><block var="key"/></list></block></script></block-definition><block-definition s="clear data in browser" type="command" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doWarp"><script><block s="doForEach"><l>item</l><custom-block s="stored data in browser"></custom-block><script><custom-block s="remove key: %s in browser"><block s="reportListItem"><l>1</l><block var="item"/></block></custom-block></script></block></script></block></script></block-definition><block-definition s="get value from key: %'key' in browser" type="reporter" category="other"><comment w="199.33333333333334" collapsed="false">Reports the value previously stored under
the input key in the browser's local storage.
Reports False if the key is not found.</comment><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>key</l></list><l>var str = window.localStorage,
 result = str.getItem('-snap-project-'+key);
if (!result) {
 return false;
}
return result;</l></block><list><block var="key"/></list></block></block></script></block-definition></blocks>
|
Ładowanie…
Reference in New Issue