diff --git a/blockly-dom.js b/blockly-dom.js index 6af800f..b9fc490 100644 --- a/blockly-dom.js +++ b/blockly-dom.js @@ -186,7 +186,7 @@ Blockly.defineBlocksWithJsonArray([ { type: "field_input", name: "ID", - text: "button", + text: "save-button", }, { type: "field_label_serializable", @@ -299,7 +299,7 @@ Blockly.defineBlocksWithJsonArray([ { type: "field_input", name: "ID", - text: "text", + text: "new-todo", }, ], output: "String", @@ -507,7 +507,7 @@ Blockly.Blocks["with_element_by_id"] = { this.setColour(45); this.appendDummyInput() .appendField("find the element with id") - .appendField(new Blockly.FieldTextInput("list"), "ID"); + .appendField(new Blockly.FieldTextInput("fruits"), "ID"); this.appendStatementInput("STACK").appendField("and"); }, }; @@ -534,7 +534,7 @@ Blockly.Blocks["with_element_by_selector"] = { this.setColour(45); this.appendDummyInput() .appendField("find the element using css selector") - .appendField(new Blockly.FieldTextInput("#list"), "QUERY"); + .appendField(new Blockly.FieldTextInput("#fruits"), "QUERY"); this.appendStatementInput("STACK").appendField("and"); }, }; @@ -561,7 +561,7 @@ Blockly.Blocks["with_elements_by_selector"] = { this.setColour(45); this.appendDummyInput() .appendField("find all the elements using css selector") - .appendField(new Blockly.FieldTextInput("#list"), "QUERY"); + .appendField(new Blockly.FieldTextInput("#fruits"), "QUERY"); this.appendStatementInput("STACK").appendField("and with each"); }, }; diff --git a/index.html b/index.html index 0acdab1..f05cefc 100644 --- a/index.html +++ b/index.html @@ -301,13 +301,13 @@
<ul id="list">
<li>Apple</li>
</ul><ul id="fruits">
<li>Apple</li>
</ul>list)fruits)<ul id="list"></ul>) in the static html.
+ <ul id="links"></ul>) in the static html.
http://www.codeyourfuture.io)<ul>) and a button to add apples to the list (<button>) in the static html.
<ul id="list"></ul>
<button id="button">add an apple</button><ul id="fruits"></ul>
<button id="add-apple-button">add an apple</button><input />) and a button to that says "speak" in the static html.
<input id="text" />
<button id="button">speak</button><input id="text-to-say" />
<button id="speak-button">speak</button><p>Things to do:</p>
<ul id="list"></ul>
<input id="text" />
<button id="button">add Todo Item</button><p>Things to do:</p>
<ul id="todo-list"></ul>
<input id="new-todo" />
<button id="add-todo">add Todo Item</button><li> with that value to the list. To do the visible outcome first, we're going to do these in reverse order.<button>) that has been clicked 0 times in the static html. <button id="button">0</button><button>) that has been clicked 0 times in the static html. <button id="counting-button">0</button>click_count<p>There have been <span id="sheep_count">0</span> sheep 🐑 and <span id="other_count">0</span> others.</p>
<input id="text" />
<button id="button">add animal</button><p>There have been <span id="sheep_count">0</span> sheep 🐑 and <span id="other_count">0</span> others.</p>
<input id="animal-kind" />
<button id="add-animal-button">add animal</button><span> with id sheep_count should increase by one.<li>).
<ul id="list"></ul>) in the static html.<ul id="fruits"></ul>) in the static html.The most common something with all the items in an array is to use a loop, as we saw in the previous exercise. Sometimes, a loop just doesn't do what we need, for example if we wanted to make the list of fruit appear gradually.
<ul id="list"></ul>
<button id="button">reveal next fruit</button>)<ul id="fruits"></ul>
<button id="reveal-fruit-button">reveal next fruit</button>)Using the blocks from the previous exercise and a different kind of loop gives us an alternative way to loop through all the items of an array. Let's see a case where it might be useful.
<ul id="list"></ul>) in the static html.<ul id="fruits"></ul>) in the static html.We are now going to learn how to add items to, remove items from, and get the sum of, an array of numbers. We're going to keep a running sum of the last five numbers (this can be a way of keeping track of how a value trends over time, e.g. the last 5 times you weighed yourself, or the last 5 times you went running).
<p>Total of the last 5 numbers: <span id="total"></span> </p>
<input id="number" />
<button id="add_number">add value</button><p>Total of the last 5 numbers: <span id="total"></span> </p>
<input id="number" />
<button id="add-number">add value</button>We are now going to use all the array blocks we have learned about. We're going to create a game where you roll dice and your goal is to not total more than 11.
<p>So far you have rolled:</p>
<ul id="list"></ul>
<button id="button_roll">Roll the dice</button>
<p>Total: <span id="total">0</span>. <span id="info">Keep playing!</span></p>
<button id="button_remove">Remove the last roll</button>
<button id="button_restart">Start again</button><p>So far you have rolled:</p>
<ul id="previous-rolls"></ul>
<button id="roll-button">Roll the dice</button>
<p>Total: <span id="total">0</span>. <span id="info">Keep playing!</span></p>
<button id="remove-roll-button">Remove the last roll</button>
<button id="restart-button">Start again</button><span id="info">