not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

65 lines
9.7 KiB

{
"BLOCKPLUGINS": [
[
"push",
"var pushBlk = new ProtoBlock('push');pushBlk.palette = palettes.dict['extras'];blocks.protoBlockDict['push'] = pushBlk;pushBlk.staticLabels.push(_('push'));pushBlk.adjustWidthToLabel();pushBlk.oneArgBlock();pushBlk.dockTypes[1] = 'anyin';"
],
[
"pop",
"var popBlk = new ProtoBlock('pop');popBlk.palette = palettes.dict['extras'];blocks.protoBlockDict['pop'] = popBlk;popBlk.staticLabels.push(_('pop'));popBlk.adjustWidthToLabel();popBlk.parameterBlock();"
],
[
"showHeap",
"var showHeap = new ProtoBlock('showHeap');showHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['showHeap'] = showHeap;showHeap.staticLabels.push(_('show heap'));showHeap.adjustWidthToLabel();showHeap.zeroArgBlock();"
],
[
"heapEmpty",
"var heapEmpty = new ProtoBlock('heapEmpty');heapEmpty.palette = palettes.dict['extras'];blocks.protoBlockDict['heapEmpty'] = heapEmpty;heapEmpty.staticLabels.push(_('heap empty?'));heapEmpty.adjustWidthToLabel();heapEmpty.booleanZeroArgBlock();"
],
[
"emptyHeap",
"var emptyHeap = new ProtoBlock('emptyHeap');emptyHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['emptyHeap'] = emptyHeap;emptyHeap.staticLabels.push(_('empty heap'));emptyHeap.adjustWidthToLabel();emptyHeap.zeroArgBlock();"
],
[
"saveHeap",
"var saveHeap = new ProtoBlock('saveHeap');saveHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['saveHeap'] = saveHeap;saveHeap.staticLabels.push(_('save heap'));saveHeap.adjustWidthToLabel();saveHeap.oneArgBlock();saveHeap.defaults.push('heap.json');saveHeap.dockTypes[1] = 'textin';"
],
[
"loadHeap",
"var loadHeap = new ProtoBlock('loadHeap');loadHeap.palette = palettes.dict['extras'];blocks.protoBlockDict['loadHeap'] = loadHeap;loadHeap.staticLabels.push(_('load heap'));loadHeap.adjustWidthToLabel();loadHeap.oneArgBlock();loadHeap.dockTypes[1] = 'filein';loadHeap.defaults = [[null, null]];"
]
],
"GLOBALS": "turtleHeaps = {};",
"ARGPLUGINS": [
[
"pop",
"var block = logo.blocks.blockList[blk];if (turtle in turtleHeaps && turtleHeaps[turtle].length > 0) { block.value = turtleHeaps[turtle].pop();} else { logo.errorMsg(_('empty heap')); block.value = null;}"
],
[
"heapEmpty",
"var block = logo.blocks.blockList[blk];if (turtle in turtleHeaps) { block.value = (turtleHeaps[turtle].length == 0);} else { block.value = true;}"
]
],
"FLOWPLUGINS": [
[
"showHeap",
"var block = logo.blocks.blockList[blk];logo.textMsg(JSON.stringify(turtleHeaps[turtle]));"
],
[
"emptyHeap",
"turtleHeaps[turtle] = [];"
],
[
"push",
"var block = logo.blocks.blockList[blk];var conns = block.connections;var arg = logo.parseArg(logo, turtle, conns[1]);if (!(turtle in turtleHeaps)) { turtleHeaps[turtle] = [];}turtleHeaps[turtle].push(arg);"
],
[
"saveHeap",
"function downloadFile(filename, mimetype, content) { var download = document.createElement('a'); download.setAttribute('href', 'data:' + mimetype + ';charset=utf-8,' + content); download.setAttribute('download', filename); document.body.appendChild(download); download.click(); document.body.removeChild(download);};var block = logo.blocks.blockList[blk];var conns = block.connections;var arg = logo.parseArg(logo, turtle, conns[1]);if (arg && turtle in turtleHeaps) { downloadFile(arg, 'text/json', JSON.stringify(turtleHeaps[turtle]));};"
],
[
"loadHeap",
"var block = logo.blocks.blockList[blk];var conns = block.connections;var arg = logo.parseArg(logo, turtle, conns[1]);if (turtle in turtleHeaps) { var oldHeap = turtleHeaps[turtle];} else { var oldHeap = [];}if (blocks.blockList[conns[1]].name == 'loadFile') { if (!arg) { logo.errorMsg(_('You need to select a file.')); } else { if (arg.length != 2) { logo.errorMsg(_('You need to select a file.')); } else { try { turtleHeaps[turtle] = JSON.parse(arg[1]); if (!Array.isArray(turtleHeaps[turtle])) { throw 'is not array'; } } catch (e) { turtleHeaps[turtle] = oldHeap; logo.errorMsg(_('The file you selected does not contain a valid heap.')); } } }}else { logo.errorMsg(_('The loadHeap block needs a loadFile block.'))};"
]
]
}