blocks_compressed.js 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202
  1. // Do not edit this file; automatically generated by build.py.
  2. 'use strict';
  3. Blockly.Blocks.colour = {};
  4. Blockly.Blocks.colour.HUE = 20;
  5. Blockly.Blocks.colour_picker = {
  6. init: function () {
  7. this.jsonInit({
  8. message0: "%1",
  9. args0: [{
  10. type: "field_colour",
  11. name: "COLOUR",
  12. colour: "#ff0000"
  13. }],
  14. output: "Colour",
  15. colour: Blockly.Blocks.colour.HUE,
  16. helpUrl: Blockly.Msg.COLOUR_PICKER_HELPURL
  17. });
  18. var a = this;
  19. this.setTooltip(function () {
  20. var b = a.getParent();
  21. return b && b.getInputsInline() && b.tooltip || Blockly.Msg.COLOUR_PICKER_TOOLTIP
  22. })
  23. }
  24. };
  25. Blockly.Blocks.colour_random = {
  26. init: function () {
  27. this.jsonInit({
  28. message0: Blockly.Msg.COLOUR_RANDOM_TITLE,
  29. output: "Colour",
  30. colour: Blockly.Blocks.colour.HUE,
  31. tooltip: Blockly.Msg.COLOUR_RANDOM_TOOLTIP,
  32. helpUrl: Blockly.Msg.COLOUR_RANDOM_HELPURL
  33. })
  34. }
  35. };
  36. Blockly.Blocks.colour_rgb = {
  37. init: function () {
  38. this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL);
  39. this.setColour(Blockly.Blocks.colour.HUE);
  40. this.appendValueInput("RED").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_TITLE).appendField(Blockly.Msg.COLOUR_RGB_RED);
  41. this.appendValueInput("GREEN").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_GREEN);
  42. this.appendValueInput("BLUE").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_BLUE);
  43. this.setOutput(!0, "Colour");
  44. this.setTooltip(Blockly.Msg.COLOUR_RGB_TOOLTIP)
  45. }
  46. };
  47. Blockly.Blocks.colour_blend = {
  48. init: function () {
  49. this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL);
  50. this.setColour(Blockly.Blocks.colour.HUE);
  51. this.appendValueInput("COLOUR1").setCheck("Colour").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_TITLE).appendField(Blockly.Msg.COLOUR_BLEND_COLOUR1);
  52. this.appendValueInput("COLOUR2").setCheck("Colour").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_COLOUR2);
  53. this.appendValueInput("RATIO").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_RATIO);
  54. this.setOutput(!0, "Colour");
  55. this.setTooltip(Blockly.Msg.COLOUR_BLEND_TOOLTIP)
  56. }
  57. };
  58. Blockly.Blocks.lists = {};
  59. Blockly.Blocks.lists.HUE = "#40bfe4";
  60. Blockly.Blocks.lists_create_empty = {
  61. init: function () {
  62. this.jsonInit({
  63. message0: Blockly.Msg.LISTS_CREATE_EMPTY_TITLE,
  64. output: "Array",
  65. colour: Blockly.Blocks.lists.HUE,
  66. tooltip: Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP,
  67. helpUrl: Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL
  68. })
  69. }
  70. };
  71. Blockly.Blocks.lists_create_with = {
  72. init: function () {
  73. this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);
  74. this.setColour(Blockly.Blocks.lists.HUE);
  75. this.itemCount_ = 3;
  76. this.updateShape_();
  77. this.setOutput(!0, "Array");
  78. this.setMutator(new Blockly.Mutator(["lists_create_with_item"]));
  79. this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)
  80. },
  81. mutationToDom: function () {
  82. var a = document.createElement("mutation");
  83. a.setAttribute("items", this.itemCount_);
  84. return a
  85. },
  86. domToMutation: function (a) {
  87. this.itemCount_ = parseInt(a.getAttribute("items"), 10);
  88. this.updateShape_()
  89. },
  90. decompose: function (a) {
  91. var b = a.newBlock("lists_create_with_container");
  92. b.initSvg();
  93. for (var c = b.getInput("STACK").connection, e = 0; e < this.itemCount_; e++) {
  94. var d = a.newBlock("lists_create_with_item");
  95. d.initSvg();
  96. c.connect(d.previousConnection);
  97. c = d.nextConnection
  98. }
  99. return b
  100. },
  101. compose: function (a) {
  102. var b = a.getInputTargetBlock("STACK");
  103. for (a = []; b;)
  104. a.push(b.valueConnection_),
  105. b = b.nextConnection && b.nextConnection.targetBlock();
  106. for (b = 0; b < this.itemCount_; b++) {
  107. var c = this.getInput("ADD" + b).connection.targetConnection;
  108. c && -1 == a.indexOf(c) && c.disconnect()
  109. }
  110. this.itemCount_ = a.length;
  111. this.updateShape_();
  112. for (b = 0; b < this.itemCount_; b++)
  113. Blockly.Mutator.reconnect(a[b], this, "ADD" + b)
  114. },
  115. saveConnections: function (a) {
  116. a = a.getInputTargetBlock("STACK");
  117. for (var b = 0; a;) {
  118. var c = this.getInput("ADD" + b);
  119. a.valueConnection_ = c && c.connection.targetConnection;
  120. b++;
  121. a = a.nextConnection && a.nextConnection.targetBlock()
  122. }
  123. },
  124. updateShape_: function () {
  125. this.itemCount_ && this.getInput("EMPTY") ? this.removeInput("EMPTY") : this.itemCount_ || this.getInput("EMPTY") || this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);
  126. for (var a = 0; a < this.itemCount_; a++)
  127. if (!this.getInput("ADD" + a)) {
  128. var b = this.appendValueInput("ADD" + a);
  129. 0 == a && b.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH)
  130. }
  131. for (; this.getInput("ADD" + a);)
  132. this.removeInput("ADD" + a),
  133. a++
  134. }
  135. };
  136. Blockly.Blocks.lists_create_with_container = {
  137. init: function () {
  138. this.setColour(Blockly.Blocks.lists.HUE);
  139. this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);
  140. this.appendStatementInput("STACK");
  141. this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);
  142. this.contextMenu = !1
  143. }
  144. };
  145. Blockly.Blocks.lists_create_with_item = {
  146. init: function () {
  147. this.setColour(Blockly.Blocks.lists.HUE);
  148. this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);
  149. this.setPreviousStatement(!0);
  150. this.setNextStatement(!0);
  151. this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP);
  152. this.contextMenu = !1
  153. }
  154. };
  155. Blockly.Blocks.lists_repeat = {
  156. init: function () {
  157. this.jsonInit({
  158. message0: Blockly.Msg.LISTS_REPEAT_TITLE,
  159. args0: [{
  160. type: "input_value",
  161. name: "ITEM"
  162. }, {
  163. type: "input_value",
  164. name: "NUM",
  165. check: "Number"
  166. }],
  167. output: "Array",
  168. colour: Blockly.Blocks.lists.HUE,
  169. tooltip: Blockly.Msg.LISTS_REPEAT_TOOLTIP,
  170. helpUrl: Blockly.Msg.LISTS_REPEAT_HELPURL
  171. })
  172. }
  173. };
  174. Blockly.Blocks.lists_length = {
  175. init: function () {
  176. this.jsonInit({
  177. message0: Blockly.Msg.LISTS_LENGTH_TITLE,
  178. args0: [{
  179. type: "input_value",
  180. name: "VALUE",
  181. check: ["String", "Array"]
  182. }],
  183. output: "Number",
  184. colour: Blockly.Blocks.lists.HUE,
  185. tooltip: Blockly.Msg.LISTS_LENGTH_TOOLTIP,
  186. helpUrl: Blockly.Msg.LISTS_LENGTH_HELPURL
  187. })
  188. }
  189. };
  190. Blockly.Blocks.lists_isEmpty = {
  191. init: function () {
  192. this.jsonInit({
  193. message0: Blockly.Msg.LISTS_ISEMPTY_TITLE,
  194. args0: [{
  195. type: "input_value",
  196. name: "VALUE",
  197. check: ["String", "Array"]
  198. }],
  199. output: "Boolean",
  200. colour: Blockly.Blocks.lists.HUE,
  201. tooltip: Blockly.Msg.LISTS_ISEMPTY_TOOLTIP,
  202. helpUrl: Blockly.Msg.LISTS_ISEMPTY_HELPURL
  203. })
  204. }
  205. };
  206. Blockly.Blocks.lists_indexOf = {
  207. init: function () {
  208. var a = [[Blockly.Msg.LISTS_INDEX_OF_FIRST, "FIRST"], [Blockly.Msg.LISTS_INDEX_OF_LAST, "LAST"]];
  209. this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);
  210. this.setColour(Blockly.Blocks.lists.HUE);
  211. this.setOutput(!0, "Number");
  212. this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST);
  213. this.appendValueInput("FIND").appendField(new Blockly.FieldDropdown(a), "END");
  214. this.setInputsInline(!0);
  215. this.setTooltip(function () {
  216. return Blockly.Msg.LISTS_INDEX_OF_TOOLTIP.replace("%1", this.workspace.options.oneBasedIndex ? "0" : "-1")
  217. })
  218. }
  219. };
  220. Blockly.Blocks.lists_getIndex = {
  221. init: function () {
  222. var a = [[Blockly.Msg.LISTS_GET_INDEX_REMOVE, "REMOVE"], [Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE, "GET_REMOVE"]];
  223. this.WHERE_OPTIONS = [[Blockly.Msg.LISTS_GET_INDEX_FROM_START, "FROM_START"], [Blockly.Msg.LISTS_GET_INDEX_FROM_END, "FROM_END"], [Blockly.Msg.LISTS_GET_INDEX_FIRST, "FIRST"], [Blockly.Msg.LISTS_GET_INDEX_LAST, "LAST"], [Blockly.Msg.LISTS_GET_INDEX_RANDOM, "RANDOM"]];
  224. this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
  225. this.setColour(Blockly.Blocks.lists.HUE);
  226. a = new Blockly.FieldDropdown(a, function (a) {
  227. this.sourceBlock_.updateStatement_("REMOVE" == a)
  228. }
  229. );
  230. this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);
  231. this.appendDummyInput().appendField(a, "MODE").appendField("", "SPACE");
  232. this.appendDummyInput("AT");
  233. Blockly.Msg.LISTS_GET_INDEX_TAIL && this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL);
  234. this.setInputsInline(!0);
  235. this.setOutput(!0);
  236. this.updateAt_(!0);
  237. var b = this;
  238. this.setTooltip(function () {
  239. var a = b.getFieldValue("MODE")
  240. , e = b.getFieldValue("WHERE")
  241. , d = "";
  242. switch (a + " " + e) {
  243. case "GET FROM_START":
  244. case "GET FROM_END":
  245. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;
  246. break;
  247. case "GET FIRST":
  248. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;
  249. break;
  250. case "GET LAST":
  251. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;
  252. break;
  253. case "GET RANDOM":
  254. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;
  255. break;
  256. case "GET_REMOVE FROM_START":
  257. case "GET_REMOVE FROM_END":
  258. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;
  259. break;
  260. case "GET_REMOVE FIRST":
  261. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;
  262. break;
  263. case "GET_REMOVE LAST":
  264. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;
  265. break;
  266. case "GET_REMOVE RANDOM":
  267. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;
  268. break;
  269. case "REMOVE FROM_START":
  270. case "REMOVE FROM_END":
  271. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;
  272. break;
  273. case "REMOVE FIRST":
  274. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;
  275. break;
  276. case "REMOVE LAST":
  277. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;
  278. break;
  279. case "REMOVE RANDOM":
  280. d = Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM
  281. }
  282. if ("FROM_START" == e || "FROM_END" == e)
  283. d += " " + ("FROM_START" == e ? Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP : Blockly.Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1", b.workspace.options.oneBasedIndex ? "#1" : "#0");
  284. return d
  285. })
  286. },
  287. mutationToDom: function () {
  288. var a = document.createElement("mutation");
  289. a.setAttribute("statement", !this.outputConnection);
  290. var b = this.getInput("AT").type == Blockly.INPUT_VALUE;
  291. a.setAttribute("at", b);
  292. return a
  293. },
  294. domToMutation: function (a) {
  295. var b = "true" == a.getAttribute("statement");
  296. this.updateStatement_(b);
  297. a = "false" != a.getAttribute("at");
  298. this.updateAt_(a)
  299. },
  300. updateStatement_: function (a) {
  301. a != !this.outputConnection && (this.unplug(!0, !0),
  302. a ? (this.setOutput(!1),
  303. this.setPreviousStatement(!0),
  304. this.setNextStatement(!0)) : (this.setPreviousStatement(!1),
  305. this.setNextStatement(!1),
  306. this.setOutput(!0)))
  307. },
  308. updateAt_: function (a) {
  309. this.removeInput("AT");
  310. this.removeInput("ORDINAL", !0);
  311. a ? (this.appendValueInput("AT").setCheck("Number"),
  312. Blockly.Msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT");
  313. var b = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function (b) {
  314. var c = "FROM_START" == b || "FROM_END" == b;
  315. if (c != a) {
  316. var d = this.sourceBlock_;
  317. d.updateAt_(c);
  318. d.setFieldValue(b, "WHERE");
  319. return null
  320. }
  321. }
  322. );
  323. this.getInput("AT").appendField(b, "WHERE");
  324. Blockly.Msg.LISTS_GET_INDEX_TAIL && this.moveInputBefore("TAIL", null)
  325. }
  326. };
  327. Blockly.Blocks.lists_setIndex = {
  328. init: function () {
  329. var a = [[Blockly.Msg.LISTS_SET_INDEX_SET, "SET"], [Blockly.Msg.LISTS_SET_INDEX_INSERT, "INSERT"]];
  330. this.WHERE_OPTIONS = [[Blockly.Msg.LISTS_GET_INDEX_FROM_START, "FROM_START"], [Blockly.Msg.LISTS_GET_INDEX_FROM_END, "FROM_END"], [Blockly.Msg.LISTS_GET_INDEX_FIRST, "FIRST"], [Blockly.Msg.LISTS_GET_INDEX_LAST, "LAST"], [Blockly.Msg.LISTS_GET_INDEX_RANDOM, "RANDOM"]];
  331. this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);
  332. this.setColour(Blockly.Blocks.lists.HUE);
  333. this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);
  334. this.appendDummyInput().appendField(new Blockly.FieldDropdown(a), "MODE").appendField("", "SPACE");
  335. this.appendDummyInput("AT");
  336. this.appendValueInput("TO").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO);
  337. this.setInputsInline(!0);
  338. this.setPreviousStatement(!0);
  339. this.setNextStatement(!0);
  340. this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP);
  341. this.updateAt_(!0);
  342. var b = this;
  343. this.setTooltip(function () {
  344. var a = b.getFieldValue("MODE")
  345. , e = b.getFieldValue("WHERE")
  346. , d = "";
  347. switch (a + " " + e) {
  348. case "SET FROM_START":
  349. case "SET FROM_END":
  350. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;
  351. break;
  352. case "SET FIRST":
  353. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;
  354. break;
  355. case "SET LAST":
  356. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;
  357. break;
  358. case "SET RANDOM":
  359. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;
  360. break;
  361. case "INSERT FROM_START":
  362. case "INSERT FROM_END":
  363. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;
  364. break;
  365. case "INSERT FIRST":
  366. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;
  367. break;
  368. case "INSERT LAST":
  369. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;
  370. break;
  371. case "INSERT RANDOM":
  372. d = Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM
  373. }
  374. if ("FROM_START" == e || "FROM_END" == e)
  375. d += " " + Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1", b.workspace.options.oneBasedIndex ? "#1" : "#0");
  376. return d
  377. })
  378. },
  379. mutationToDom: function () {
  380. var a = document.createElement("mutation")
  381. , b = this.getInput("AT").type == Blockly.INPUT_VALUE;
  382. a.setAttribute("at", b);
  383. return a
  384. },
  385. domToMutation: function (a) {
  386. a = "false" != a.getAttribute("at");
  387. this.updateAt_(a)
  388. },
  389. updateAt_: function (a) {
  390. this.removeInput("AT");
  391. this.removeInput("ORDINAL", !0);
  392. a ? (this.appendValueInput("AT").setCheck("Number"),
  393. Blockly.Msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT");
  394. var b = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function (b) {
  395. var c = "FROM_START" == b || "FROM_END" == b;
  396. if (c != a) {
  397. var d = this.sourceBlock_;
  398. d.updateAt_(c);
  399. d.setFieldValue(b, "WHERE");
  400. return null
  401. }
  402. }
  403. );
  404. this.moveInputBefore("AT", "TO");
  405. this.getInput("ORDINAL") && this.moveInputBefore("ORDINAL", "TO");
  406. this.getInput("AT").appendField(b, "WHERE")
  407. }
  408. };
  409. Blockly.Blocks.lists_getSublist = {
  410. init: function () {
  411. this.WHERE_OPTIONS_1 = [[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START, "FROM_START"], [Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END, "FROM_END"], [Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST, "FIRST"]];
  412. this.WHERE_OPTIONS_2 = [[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START, "FROM_START"], [Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END, "FROM_END"], [Blockly.Msg.LISTS_GET_SUBLIST_END_LAST, "LAST"]];
  413. this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);
  414. this.setColour(Blockly.Blocks.lists.HUE);
  415. this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);
  416. this.appendDummyInput("AT1");
  417. this.appendDummyInput("AT2");
  418. Blockly.Msg.LISTS_GET_SUBLIST_TAIL && this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL);
  419. this.setInputsInline(!0);
  420. this.setOutput(!0, "Array");
  421. this.updateAt_(1, !0);
  422. this.updateAt_(2, !0);
  423. this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)
  424. },
  425. mutationToDom: function () {
  426. var a = document.createElement("mutation")
  427. , b = this.getInput("AT1").type == Blockly.INPUT_VALUE;
  428. a.setAttribute("at1", b);
  429. b = this.getInput("AT2").type == Blockly.INPUT_VALUE;
  430. a.setAttribute("at2", b);
  431. return a
  432. },
  433. domToMutation: function (a) {
  434. var b = "true" == a.getAttribute("at1");
  435. a = "true" == a.getAttribute("at2");
  436. this.updateAt_(1, b);
  437. this.updateAt_(2, a)
  438. },
  439. updateAt_: function (a, b) {
  440. this.removeInput("AT" + a);
  441. this.removeInput("ORDINAL" + a, !0);
  442. b ? (this.appendValueInput("AT" + a).setCheck("Number"),
  443. Blockly.Msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL" + a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT" + a);
  444. var c = new Blockly.FieldDropdown(this["WHERE_OPTIONS_" + a], function (c) {
  445. var d = "FROM_START" == c || "FROM_END" == c;
  446. if (d != b) {
  447. var e = this.sourceBlock_;
  448. e.updateAt_(a, d);
  449. e.setFieldValue(c, "WHERE" + a);
  450. return null
  451. }
  452. }
  453. );
  454. this.getInput("AT" + a).appendField(c, "WHERE" + a);
  455. 1 == a && (this.moveInputBefore("AT1", "AT2"),
  456. this.getInput("ORDINAL1") && this.moveInputBefore("ORDINAL1", "AT2"));
  457. Blockly.Msg.LISTS_GET_SUBLIST_TAIL && this.moveInputBefore("TAIL", null)
  458. }
  459. };
  460. Blockly.Blocks.lists_sort = {
  461. init: function () {
  462. this.jsonInit({
  463. message0: Blockly.Msg.LISTS_SORT_TITLE,
  464. args0: [{
  465. type: "field_dropdown",
  466. name: "TYPE",
  467. options: [[Blockly.Msg.LISTS_SORT_TYPE_NUMERIC, "NUMERIC"], [Blockly.Msg.LISTS_SORT_TYPE_TEXT, "TEXT"], [Blockly.Msg.LISTS_SORT_TYPE_IGNORECASE, "IGNORE_CASE"]]
  468. }, {
  469. type: "field_dropdown",
  470. name: "DIRECTION",
  471. options: [[Blockly.Msg.LISTS_SORT_ORDER_ASCENDING, "1"], [Blockly.Msg.LISTS_SORT_ORDER_DESCENDING, "-1"]]
  472. }, {
  473. type: "input_value",
  474. name: "LIST",
  475. check: "Array"
  476. }],
  477. output: "Array",
  478. colour: Blockly.Blocks.lists.HUE,
  479. tooltip: Blockly.Msg.LISTS_SORT_TOOLTIP,
  480. helpUrl: Blockly.Msg.LISTS_SORT_HELPURL
  481. })
  482. }
  483. };
  484. Blockly.Blocks.lists_split = {
  485. init: function () {
  486. var a = this
  487. , b = new Blockly.FieldDropdown([[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT, "SPLIT"], [Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST, "JOIN"]], function (b) {
  488. a.updateType_(b)
  489. }
  490. );
  491. this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);
  492. this.setColour(Blockly.Blocks.lists.HUE);
  493. this.appendValueInput("INPUT").setCheck("String").appendField(b, "MODE");
  494. this.appendValueInput("DELIM").setCheck("String").appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER);
  495. this.setInputsInline(!0);
  496. this.setOutput(!0, "Array");
  497. this.setTooltip(function () {
  498. var b = a.getFieldValue("MODE");
  499. if ("SPLIT" == b)
  500. return Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;
  501. if ("JOIN" == b)
  502. return Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN;
  503. throw "Unknown mode: " + b;
  504. })
  505. },
  506. updateType_: function (a) {
  507. "SPLIT" == a ? (this.outputConnection.setCheck("Array"),
  508. this.getInput("INPUT").setCheck("String")) : (this.outputConnection.setCheck("String"),
  509. this.getInput("INPUT").setCheck("Array"))
  510. },
  511. mutationToDom: function () {
  512. var a = document.createElement("mutation");
  513. a.setAttribute("mode", this.getFieldValue("MODE"));
  514. return a
  515. },
  516. domToMutation: function (a) {
  517. this.updateType_(a.getAttribute("mode"))
  518. }
  519. };
  520. Blockly.Blocks.logic = {};
  521. Blockly.Blocks.logic.HUE = "#4c97ff";
  522. Blockly.Blocks.controls_if = {
  523. init: function () {
  524. this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL);
  525. this.setColour(Blockly.Blocks.logic.HUE);
  526. this.appendValueInput("IF0").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
  527. this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
  528. this.setPreviousStatement(!0);
  529. this.setNextStatement(!0);
  530. this.setMutator(new Blockly.Mutator(["controls_if_elseif", "controls_if_else"]));
  531. var a = this;
  532. this.setTooltip(function () {
  533. if (a.elseifCount_ || a.elseCount_) {
  534. if (!a.elseifCount_ && a.elseCount_)
  535. return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;
  536. if (a.elseifCount_ && !a.elseCount_)
  537. return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;
  538. if (a.elseifCount_ && a.elseCount_)
  539. return Blockly.Msg.CONTROLS_IF_TOOLTIP_4
  540. } else
  541. return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;
  542. return ""
  543. });
  544. this.elseCount_ = this.elseifCount_ = 0
  545. },
  546. mutationToDom: function () {
  547. if (!this.elseifCount_ && !this.elseCount_)
  548. return null;
  549. var a = document.createElement("mutation");
  550. this.elseifCount_ && a.setAttribute("elseif", this.elseifCount_);
  551. this.elseCount_ && a.setAttribute("else", 1);
  552. return a
  553. },
  554. domToMutation: function (a) {
  555. this.elseifCount_ = parseInt(a.getAttribute("elseif"), 10) || 0;
  556. this.elseCount_ = parseInt(a.getAttribute("else"), 10) || 0;
  557. this.updateShape_()
  558. },
  559. decompose: function (a) {
  560. var b = a.newBlock("controls_if_if");
  561. b.initSvg();
  562. for (var c = b.nextConnection, e = 1; e <= this.elseifCount_; e++) {
  563. var d = a.newBlock("controls_if_elseif");
  564. d.initSvg();
  565. c.connect(d.previousConnection);
  566. c = d.nextConnection
  567. }
  568. this.elseCount_ && (a = a.newBlock("controls_if_else"),
  569. a.initSvg(),
  570. c.connect(a.previousConnection));
  571. return b
  572. },
  573. compose: function (a) {
  574. var b = a.nextConnection.targetBlock();
  575. this.elseCount_ = this.elseifCount_ = 0;
  576. a = [null];
  577. for (var c = [null], e = null; b;) {
  578. switch (b.type) {
  579. case "controls_if_elseif":
  580. this.elseifCount_++;
  581. a.push(b.valueConnection_);
  582. c.push(b.statementConnection_);
  583. break;
  584. case "controls_if_else":
  585. this.elseCount_++;
  586. e = b.statementConnection_;
  587. break;
  588. default:
  589. throw "Unknown block type.";
  590. }
  591. b = b.nextConnection && b.nextConnection.targetBlock()
  592. }
  593. this.updateShape_();
  594. for (b = 1; b <= this.elseifCount_; b++)
  595. Blockly.Mutator.reconnect(a[b], this, "IF" + b),
  596. Blockly.Mutator.reconnect(c[b], this, "DO" + b);
  597. Blockly.Mutator.reconnect(e, this, "ELSE")
  598. },
  599. saveConnections: function (a) {
  600. a = a.nextConnection.targetBlock();
  601. for (var b = 1; a;) {
  602. switch (a.type) {
  603. case "controls_if_elseif":
  604. var c = this.getInput("IF" + b)
  605. , e = this.getInput("DO" + b);
  606. a.valueConnection_ = c && c.connection.targetConnection;
  607. a.statementConnection_ = e && e.connection.targetConnection;
  608. b++;
  609. break;
  610. case "controls_if_else":
  611. e = this.getInput("ELSE");
  612. a.statementConnection_ = e && e.connection.targetConnection;
  613. break;
  614. default:
  615. throw "Unknown block type.";
  616. }
  617. a = a.nextConnection && a.nextConnection.targetBlock()
  618. }
  619. },
  620. updateShape_: function () {
  621. this.getInput("ELSE") && this.removeInput("ELSE");
  622. for (var a = 1; this.getInput("IF" + a);)
  623. this.removeInput("IF" + a),
  624. this.removeInput("DO" + a),
  625. a++;
  626. for (a = 1; a <= this.elseifCount_; a++)
  627. this.appendValueInput("IF" + a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),
  628. this.appendStatementInput("DO" + a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
  629. this.elseCount_ && this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)
  630. }
  631. };
  632. Blockly.Blocks.controls_if_if = {
  633. init: function () {
  634. this.setColour(Blockly.Blocks.logic.HUE);
  635. this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);
  636. this.setNextStatement(!0);
  637. this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP);
  638. this.contextMenu = !1
  639. }
  640. };
  641. Blockly.Blocks.controls_if_elseif = {
  642. init: function () {
  643. this.setColour(Blockly.Blocks.logic.HUE);
  644. this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF);
  645. this.setPreviousStatement(!0);
  646. this.setNextStatement(!0);
  647. this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP);
  648. this.contextMenu = !1
  649. }
  650. };
  651. Blockly.Blocks.controls_if_else = {
  652. init: function () {
  653. this.setColour(Blockly.Blocks.logic.HUE);
  654. this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE);
  655. this.setPreviousStatement(!0);
  656. this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP);
  657. this.contextMenu = !1
  658. }
  659. };
  660. Blockly.Blocks.logic_compare = {
  661. init: function () {
  662. var a = [["=", "EQ"], ["\u2260", "NEQ"], ["\u200f<\u200f", "LT"], ["\u200f\u2264\u200f", "LTE"], ["\u200f>\u200f", "GT"], ["\u200f\u2265\u200f", "GTE"]]
  663. , b = [["=", "EQ"], ["\u2260", "NEQ"], ["<", "LT"], ["\u2264", "LTE"], [">", "GT"], ["\u2265", "GTE"]];
  664. a = this.RTL ? a : b;
  665. this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL);
  666. this.setColour(Blockly.Blocks.logic.HUE);
  667. this.setOutput(!0, "Boolean");
  668. this.appendValueInput("A");
  669. this.appendValueInput("B").appendField(new Blockly.FieldDropdown(a), "OP");
  670. this.setInputsInline(!0);
  671. var c = this;
  672. this.setTooltip(function () {
  673. var a = c.getFieldValue("OP");
  674. return {
  675. EQ: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ,
  676. NEQ: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,
  677. LT: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT,
  678. LTE: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE,
  679. GT: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT,
  680. GTE: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE
  681. }[a]
  682. });
  683. this.prevBlocks_ = [null, null]
  684. },
  685. onchange: function (a) {
  686. var b = this.getInputTargetBlock("A")
  687. , c = this.getInputTargetBlock("B");
  688. if (b && c && !b.outputConnection.checkType_(c.outputConnection)) {
  689. Blockly.Events.setGroup(a.group);
  690. for (a = 0; a < this.prevBlocks_.length; a++) {
  691. var e = this.prevBlocks_[a];
  692. if (e === b || e === c)
  693. e.unplug(),
  694. e.bumpNeighbours_()
  695. }
  696. Blockly.Events.setGroup(!1)
  697. }
  698. this.prevBlocks_[0] = b;
  699. this.prevBlocks_[1] = c
  700. }
  701. };
  702. Blockly.Blocks.logic_operation = {
  703. init: function () {
  704. var a = [[Blockly.Msg.LOGIC_OPERATION_AND, "AND"], [Blockly.Msg.LOGIC_OPERATION_OR, "OR"]];
  705. this.setHelpUrl(Blockly.Msg.LOGIC_OPERATION_HELPURL);
  706. this.setColour(Blockly.Blocks.logic.HUE);
  707. this.setOutput(!0, "Boolean");
  708. this.appendValueInput("A").setCheck("Boolean");
  709. this.appendValueInput("B").setCheck("Boolean").appendField(new Blockly.FieldDropdown(a), "OP");
  710. this.setInputsInline(!0);
  711. var b = this;
  712. this.setTooltip(function () {
  713. var a = b.getFieldValue("OP");
  714. return {
  715. AND: Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND,
  716. OR: Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR
  717. }[a]
  718. })
  719. }
  720. };
  721. Blockly.Blocks.logic_negate = {
  722. init: function () {
  723. this.jsonInit({
  724. message0: Blockly.Msg.LOGIC_NEGATE_TITLE,
  725. args0: [{
  726. type: "input_value",
  727. name: "BOOL",
  728. check: "Boolean"
  729. }],
  730. output: "Boolean",
  731. colour: Blockly.Blocks.logic.HUE,
  732. tooltip: Blockly.Msg.LOGIC_NEGATE_TOOLTIP,
  733. helpUrl: Blockly.Msg.LOGIC_NEGATE_HELPURL
  734. })
  735. }
  736. };
  737. Blockly.Blocks.logic_boolean = {
  738. init: function () {
  739. this.jsonInit({
  740. message0: "%1",
  741. args0: [{
  742. type: "field_dropdown",
  743. name: "BOOL",
  744. options: [[Blockly.Msg.LOGIC_BOOLEAN_TRUE, "TRUE"], [Blockly.Msg.LOGIC_BOOLEAN_FALSE, "FALSE"]]
  745. }],
  746. output: "Boolean",
  747. colour: Blockly.Blocks.logic.HUE,
  748. tooltip: Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP,
  749. helpUrl: Blockly.Msg.LOGIC_BOOLEAN_HELPURL
  750. })
  751. }
  752. };
  753. Blockly.Blocks.logic_null = {
  754. init: function () {
  755. this.jsonInit({
  756. message0: Blockly.Msg.LOGIC_NULL,
  757. output: null,
  758. colour: Blockly.Blocks.logic.HUE,
  759. tooltip: Blockly.Msg.LOGIC_NULL_TOOLTIP,
  760. helpUrl: Blockly.Msg.LOGIC_NULL_HELPURL
  761. })
  762. }
  763. };
  764. Blockly.Blocks.logic_ternary = {
  765. init: function () {
  766. this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL);
  767. this.setColour(Blockly.Blocks.logic.HUE);
  768. this.appendValueInput("IF").setCheck("Boolean").appendField(Blockly.Msg.LOGIC_TERNARY_CONDITION);
  769. this.appendValueInput("THEN").appendField(Blockly.Msg.LOGIC_TERNARY_IF_TRUE);
  770. this.appendValueInput("ELSE").appendField(Blockly.Msg.LOGIC_TERNARY_IF_FALSE);
  771. this.setOutput(!0);
  772. this.setTooltip(Blockly.Msg.LOGIC_TERNARY_TOOLTIP);
  773. this.prevParentConnection_ = null
  774. },
  775. onchange: function (a) {
  776. var b = this.getInputTargetBlock("THEN")
  777. , c = this.getInputTargetBlock("ELSE")
  778. , e = this.outputConnection.targetConnection;
  779. if ((b || c) && e)
  780. for (var d = 0; 2 > d; d++) {
  781. var f = 1 == d ? b : c;
  782. f && !f.outputConnection.checkType_(e) && (Blockly.Events.setGroup(a.group),
  783. e === this.prevParentConnection_ ? (this.unplug(),
  784. e.getSourceBlock().bumpNeighbours_()) : (f.unplug(),
  785. f.bumpNeighbours_()),
  786. Blockly.Events.setGroup(!1))
  787. }
  788. this.prevParentConnection_ = e
  789. }
  790. };
  791. Blockly.Blocks.loops = {};
  792. Blockly.Blocks.loops.HUE = "#9d64fd";
  793. Blockly.Blocks.controls_repeat_forever = {
  794. init: function () {
  795. this.jsonInit({
  796. message0: Blockly.Msg.CONTROLS_REPEAT_FOREVER,
  797. previousStatement: null,
  798. nextStatement: null,
  799. colour: Blockly.Blocks.loops.HUE,
  800. tooltip: Blockly.Msg.CONTROLS_REPEAT_FOREVER_TOOLTIP,
  801. helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL
  802. });
  803. this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
  804. }
  805. };
  806. Blockly.Blocks.controls_repeat_ext = {
  807. init: function () {
  808. this.jsonInit({
  809. message0: Blockly.Msg.CONTROLS_REPEAT_TITLE,
  810. args0: [{
  811. type: "input_value",
  812. name: "TIMES",
  813. check: "Number"
  814. }],
  815. previousStatement: null,
  816. nextStatement: null,
  817. colour: Blockly.Blocks.loops.HUE,
  818. tooltip: Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
  819. helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL
  820. });
  821. this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
  822. }
  823. };
  824. Blockly.Blocks.controls_repeat = {
  825. init: function () {
  826. this.jsonInit({
  827. message0: Blockly.Msg.CONTROLS_REPEAT_TITLE,
  828. args0: [{
  829. type: "field_number",
  830. name: "TIMES",
  831. value: 10,
  832. min: 0,
  833. precision: 1
  834. }],
  835. previousStatement: null,
  836. nextStatement: null,
  837. colour: Blockly.Blocks.loops.HUE,
  838. tooltip: Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
  839. helpUrl: Blockly.Msg.CONTROLS_REPEAT_HELPURL
  840. });
  841. this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)
  842. }
  843. };
  844. Blockly.Blocks.controls_whileUntil = {
  845. init: function () {
  846. var a = [[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE, "WHILE"], [Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL, "UNTIL"]];
  847. this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);
  848. this.setColour(Blockly.Blocks.loops.HUE);
  849. this.appendValueInput("BOOL").setCheck("Boolean").appendField(new Blockly.FieldDropdown(a), "MODE");
  850. this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO);
  851. this.setPreviousStatement(!0);
  852. this.setNextStatement(!0);
  853. var b = this;
  854. this.setTooltip(function () {
  855. var a = b.getFieldValue("MODE");
  856. return {
  857. WHILE: Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,
  858. UNTIL: Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL
  859. }[a]
  860. })
  861. }
  862. };
  863. Blockly.Blocks.controls_for = {
  864. init: function () {
  865. this.jsonInit({
  866. message0: Blockly.Msg.CONTROLS_FOR_TITLE,
  867. args0: [{
  868. type: "field_variable",
  869. name: "VAR",
  870. variable: null
  871. }, {
  872. type: "input_value",
  873. name: "FROM",
  874. check: "Number",
  875. align: "RIGHT"
  876. }, {
  877. type: "input_value",
  878. name: "TO",
  879. check: "Number",
  880. align: "RIGHT"
  881. }, {
  882. type: "input_value",
  883. name: "BY",
  884. check: "Number",
  885. align: "RIGHT"
  886. }],
  887. inputsInline: !0,
  888. previousStatement: null,
  889. nextStatement: null,
  890. colour: Blockly.Blocks.loops.HUE,
  891. helpUrl: Blockly.Msg.CONTROLS_FOR_HELPURL
  892. });
  893. this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO);
  894. var a = this;
  895. this.setTooltip(function () {
  896. return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1", a.getFieldValue("VAR"))
  897. })
  898. },
  899. customContextMenu: function (a) {
  900. if (!this.isCollapsed()) {
  901. var b = {
  902. enabled: !0
  903. }
  904. , c = this.getFieldValue("VAR");
  905. b.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1", c);
  906. c = goog.dom.createDom("field", null, c);
  907. c.setAttribute("name", "VAR");
  908. c = goog.dom.createDom("block", null, c);
  909. c.setAttribute("type", "variables_get");
  910. b.callback = Blockly.ContextMenu.callbackFactory(this, c);
  911. a.push(b)
  912. }
  913. }
  914. };
  915. Blockly.Blocks.controls_forEach = {
  916. init: function () {
  917. this.jsonInit({
  918. message0: Blockly.Msg.CONTROLS_FOREACH_TITLE,
  919. args0: [{
  920. type: "field_variable",
  921. name: "VAR",
  922. variable: null
  923. }, {
  924. type: "input_value",
  925. name: "LIST",
  926. check: "Array"
  927. }],
  928. previousStatement: null,
  929. nextStatement: null,
  930. colour: Blockly.Blocks.loops.HUE,
  931. helpUrl: Blockly.Msg.CONTROLS_FOREACH_HELPURL
  932. });
  933. this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO);
  934. var a = this;
  935. this.setTooltip(function () {
  936. return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1", a.getFieldValue("VAR"))
  937. })
  938. },
  939. customContextMenu: Blockly.Blocks.controls_for.customContextMenu
  940. };
  941. Blockly.Blocks.controls_flow_statements = {
  942. init: function () {
  943. var a = [[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK, "BREAK"], [Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE, "CONTINUE"]];
  944. this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL);
  945. this.setColour(Blockly.Blocks.loops.HUE);
  946. this.appendDummyInput().appendField(new Blockly.FieldDropdown(a), "FLOW");
  947. this.setPreviousStatement(!0);
  948. var b = this;
  949. this.setTooltip(function () {
  950. var a = b.getFieldValue("FLOW");
  951. return {
  952. BREAK: Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,
  953. CONTINUE: Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE
  954. }[a]
  955. })
  956. },
  957. onchange: function (a) {
  958. if (!this.workspace.isDragging()) {
  959. a = !1;
  960. var b = this;
  961. do {
  962. if (-1 != this.LOOP_TYPES.indexOf(b.type)) {
  963. a = !0;
  964. break
  965. }
  966. b = b.getSurroundParent()
  967. } while (b); a ? (this.setWarningText(null),
  968. this.isInFlyout || this.setDisabled(!1)) : (this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING),
  969. this.isInFlyout || this.getInheritedDisabled() || this.setDisabled(!0))
  970. }
  971. },
  972. LOOP_TYPES: "controls_repeat_forever controls_repeat controls_repeat_ext controls_forEach controls_for controls_whileUntil tello_repeat_forever".split(" ")
  973. };
  974. Blockly.Blocks.math = {};
  975. Blockly.Blocks.math.HUE = "#5472ea";
  976. Blockly.Blocks.math_number = {
  977. init: function () {
  978. this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL);
  979. this.setColour(Blockly.Blocks.math.HUE);
  980. this.appendDummyInput().appendField(new Blockly.FieldNumber("0"), "NUM");
  981. this.setOutput(!0, "Number");
  982. var a = this;
  983. this.setTooltip(function () {
  984. var b = a.getParent();
  985. return b && b.getInputsInline() && b.tooltip || Blockly.Msg.MATH_NUMBER_TOOLTIP
  986. })
  987. }
  988. };
  989. Blockly.Blocks.math_arithmetic = {
  990. init: function () {
  991. this.jsonInit({
  992. message0: "%1 %2 %3",
  993. args0: [{
  994. type: "input_value",
  995. name: "A",
  996. check: "Number"
  997. }, {
  998. type: "field_dropdown",
  999. name: "OP",
  1000. options: [[Blockly.Msg.MATH_ADDITION_SYMBOL, "ADD"], [Blockly.Msg.MATH_SUBTRACTION_SYMBOL, "MINUS"], [Blockly.Msg.MATH_MULTIPLICATION_SYMBOL, "MULTIPLY"], [Blockly.Msg.MATH_DIVISION_SYMBOL, "DIVIDE"], [Blockly.Msg.MATH_POWER_SYMBOL, "POWER"]]
  1001. }, {
  1002. type: "input_value",
  1003. name: "B",
  1004. check: "Number"
  1005. }],
  1006. inputsInline: !0,
  1007. output: "Number",
  1008. colour: Blockly.Blocks.math.HUE,
  1009. helpUrl: Blockly.Msg.MATH_ARITHMETIC_HELPURL
  1010. });
  1011. var a = this;
  1012. this.setTooltip(function () {
  1013. var b = a.getFieldValue("OP");
  1014. return {
  1015. ADD: Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,
  1016. MINUS: Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,
  1017. MULTIPLY: Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,
  1018. DIVIDE: Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,
  1019. POWER: Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER
  1020. }[b]
  1021. })
  1022. }
  1023. };
  1024. Blockly.Blocks.math_single = {
  1025. init: function () {
  1026. this.jsonInit({
  1027. message0: "%1 %2",
  1028. args0: [{
  1029. type: "field_dropdown",
  1030. name: "OP",
  1031. options: [[Blockly.Msg.MATH_SINGLE_OP_ROOT, "ROOT"], [Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE, "ABS"], ["-", "NEG"], ["ln", "LN"], ["log10", "LOG10"], ["e^", "EXP"], ["10^", "POW10"]]
  1032. }, {
  1033. type: "input_value",
  1034. name: "NUM",
  1035. check: "Number"
  1036. }],
  1037. output: "Number",
  1038. colour: Blockly.Blocks.math.HUE,
  1039. helpUrl: Blockly.Msg.MATH_SINGLE_HELPURL
  1040. });
  1041. var a = this;
  1042. this.setTooltip(function () {
  1043. var b = a.getFieldValue("OP");
  1044. return {
  1045. ROOT: Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT,
  1046. ABS: Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS,
  1047. NEG: Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG,
  1048. LN: Blockly.Msg.MATH_SINGLE_TOOLTIP_LN,
  1049. LOG10: Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10,
  1050. EXP: Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP,
  1051. POW10: Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10
  1052. }[b]
  1053. })
  1054. }
  1055. };
  1056. Blockly.Blocks.math_trig = {
  1057. init: function () {
  1058. this.jsonInit({
  1059. message0: "%1 %2",
  1060. args0: [{
  1061. type: "field_dropdown",
  1062. name: "OP",
  1063. options: [[Blockly.Msg.MATH_TRIG_SIN, "SIN"], [Blockly.Msg.MATH_TRIG_COS, "COS"], [Blockly.Msg.MATH_TRIG_TAN, "TAN"], [Blockly.Msg.MATH_TRIG_ASIN, "ASIN"], [Blockly.Msg.MATH_TRIG_ACOS, "ACOS"], [Blockly.Msg.MATH_TRIG_ATAN, "ATAN"]]
  1064. }, {
  1065. type: "input_value",
  1066. name: "NUM",
  1067. check: "Number"
  1068. }],
  1069. output: "Number",
  1070. colour: Blockly.Blocks.math.HUE,
  1071. helpUrl: Blockly.Msg.MATH_TRIG_HELPURL
  1072. });
  1073. var a = this;
  1074. this.setTooltip(function () {
  1075. var b = a.getFieldValue("OP");
  1076. return {
  1077. SIN: Blockly.Msg.MATH_TRIG_TOOLTIP_SIN,
  1078. COS: Blockly.Msg.MATH_TRIG_TOOLTIP_COS,
  1079. TAN: Blockly.Msg.MATH_TRIG_TOOLTIP_TAN,
  1080. ASIN: Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN,
  1081. ACOS: Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS,
  1082. ATAN: Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN
  1083. }[b]
  1084. })
  1085. }
  1086. };
  1087. Blockly.Blocks.math_constant = {
  1088. init: function () {
  1089. this.jsonInit({
  1090. message0: "%1",
  1091. args0: [{
  1092. type: "field_dropdown",
  1093. name: "CONSTANT",
  1094. options: [["\u03c0", "PI"], ["e", "E"], ["\u03c6", "GOLDEN_RATIO"], ["sqrt(2)", "SQRT2"], ["sqrt(\u00bd)", "SQRT1_2"], ["\u221e", "INFINITY"]]
  1095. }],
  1096. output: "Number",
  1097. colour: Blockly.Blocks.math.HUE,
  1098. tooltip: Blockly.Msg.MATH_CONSTANT_TOOLTIP,
  1099. helpUrl: Blockly.Msg.MATH_CONSTANT_HELPURL
  1100. })
  1101. }
  1102. };
  1103. Blockly.Blocks.math_number_property = {
  1104. init: function () {
  1105. var a = [[Blockly.Msg.MATH_IS_EVEN, "EVEN"], [Blockly.Msg.MATH_IS_ODD, "ODD"], [Blockly.Msg.MATH_IS_WHOLE, "WHOLE"], [Blockly.Msg.MATH_IS_POSITIVE, "POSITIVE"], [Blockly.Msg.MATH_IS_NEGATIVE, "NEGATIVE"], [Blockly.Msg.MATH_IS_DIVISIBLE_BY, "DIVISIBLE_BY"]];
  1106. this.setColour(Blockly.Blocks.math.HUE);
  1107. this.appendValueInput("NUMBER_TO_CHECK").setCheck("Number");
  1108. a = new Blockly.FieldDropdown(a, function (a) {
  1109. this.sourceBlock_.updateShape_("DIVISIBLE_BY" == a)
  1110. }
  1111. );
  1112. this.appendDummyInput().appendField(a, "PROPERTY");
  1113. this.setInputsInline(!0);
  1114. this.setOutput(!0, "Boolean");
  1115. this.setTooltip(Blockly.Msg.MATH_IS_TOOLTIP)
  1116. },
  1117. mutationToDom: function () {
  1118. var a = document.createElement("mutation")
  1119. , b = "DIVISIBLE_BY" == this.getFieldValue("PROPERTY");
  1120. a.setAttribute("divisor_input", b);
  1121. return a
  1122. },
  1123. domToMutation: function (a) {
  1124. a = "true" == a.getAttribute("divisor_input");
  1125. this.updateShape_(a)
  1126. },
  1127. updateShape_: function (a) {
  1128. var b = this.getInput("DIVISOR");
  1129. a ? b || this.appendValueInput("DIVISOR").setCheck("Number") : b && this.removeInput("DIVISOR")
  1130. }
  1131. };
  1132. Blockly.Blocks.math_change = {
  1133. init: function () {
  1134. this.jsonInit({
  1135. message0: Blockly.Msg.MATH_CHANGE_TITLE,
  1136. args0: [{
  1137. type: "field_variable",
  1138. name: "VAR",
  1139. variable: Blockly.Msg.MATH_CHANGE_TITLE_ITEM
  1140. }, {
  1141. type: "input_value",
  1142. name: "DELTA",
  1143. check: "Number"
  1144. }],
  1145. previousStatement: null,
  1146. nextStatement: null,
  1147. colour: Blockly.Blocks.variables.HUE,
  1148. helpUrl: Blockly.Msg.MATH_CHANGE_HELPURL
  1149. });
  1150. var a = this;
  1151. this.setTooltip(function () {
  1152. return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1", a.getFieldValue("VAR"))
  1153. })
  1154. }
  1155. };
  1156. Blockly.Blocks.math_round = {
  1157. init: function () {
  1158. this.jsonInit({
  1159. message0: "%1 %2",
  1160. args0: [{
  1161. type: "field_dropdown",
  1162. name: "OP",
  1163. options: [[Blockly.Msg.MATH_ROUND_OPERATOR_ROUND, "ROUND"], [Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP, "ROUNDUP"], [Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN, "ROUNDDOWN"]]
  1164. }, {
  1165. type: "input_value",
  1166. name: "NUM",
  1167. check: "Number"
  1168. }],
  1169. output: "Number",
  1170. colour: Blockly.Blocks.math.HUE,
  1171. tooltip: Blockly.Msg.MATH_ROUND_TOOLTIP,
  1172. helpUrl: Blockly.Msg.MATH_ROUND_HELPURL
  1173. })
  1174. }
  1175. };
  1176. Blockly.Blocks.math_on_list = {
  1177. init: function () {
  1178. var a = [[Blockly.Msg.MATH_ONLIST_OPERATOR_SUM, "SUM"], [Blockly.Msg.MATH_ONLIST_OPERATOR_MIN, "MIN"], [Blockly.Msg.MATH_ONLIST_OPERATOR_MAX, "MAX"], [Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE, "AVERAGE"], [Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN, "MEDIAN"], [Blockly.Msg.MATH_ONLIST_OPERATOR_MODE, "MODE"], [Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV, "STD_DEV"], [Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM, "RANDOM"]]
  1179. , b = this;
  1180. this.setHelpUrl(Blockly.Msg.MATH_ONLIST_HELPURL);
  1181. this.setColour(Blockly.Blocks.math.HUE);
  1182. this.setOutput(!0, "Number");
  1183. a = new Blockly.FieldDropdown(a, function (a) {
  1184. b.updateType_(a)
  1185. }
  1186. );
  1187. this.appendValueInput("LIST").setCheck("Array").appendField(a, "OP");
  1188. this.setTooltip(function () {
  1189. var a = b.getFieldValue("OP");
  1190. return {
  1191. SUM: Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM,
  1192. MIN: Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN,
  1193. MAX: Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX,
  1194. AVERAGE: Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE,
  1195. MEDIAN: Blockly.Msg.MATH_ONLIST_TOOLTIP_MEDIAN,
  1196. MODE: Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE,
  1197. STD_DEV: Blockly.Msg.MATH_ONLIST_TOOLTIP_STD_DEV,
  1198. RANDOM: Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM
  1199. }[a]
  1200. })
  1201. },
  1202. updateType_: function (a) {
  1203. "MODE" == a ? this.outputConnection.setCheck("Array") : this.outputConnection.setCheck("Number")
  1204. },
  1205. mutationToDom: function () {
  1206. var a = document.createElement("mutation");
  1207. a.setAttribute("op", this.getFieldValue("OP"));
  1208. return a
  1209. },
  1210. domToMutation: function (a) {
  1211. this.updateType_(a.getAttribute("op"))
  1212. }
  1213. };
  1214. Blockly.Blocks.math_modulo = {
  1215. init: function () {
  1216. this.jsonInit({
  1217. message0: Blockly.Msg.MATH_MODULO_TITLE,
  1218. args0: [{
  1219. type: "input_value",
  1220. name: "DIVIDEND",
  1221. check: "Number"
  1222. }, {
  1223. type: "input_value",
  1224. name: "DIVISOR",
  1225. check: "Number"
  1226. }],
  1227. inputsInline: !0,
  1228. output: "Number",
  1229. colour: Blockly.Blocks.math.HUE,
  1230. tooltip: Blockly.Msg.MATH_MODULO_TOOLTIP,
  1231. helpUrl: Blockly.Msg.MATH_MODULO_HELPURL
  1232. })
  1233. }
  1234. };
  1235. Blockly.Blocks.math_division_consult = {
  1236. init: function () {
  1237. this.jsonInit({
  1238. message0: Blockly.Msg.MATH_DIVISION_CONSULT_TITLE,
  1239. args0: [{
  1240. type: "input_value",
  1241. name: "DIVIDEND",
  1242. check: "Number"
  1243. }, {
  1244. type: "input_value",
  1245. name: "DIVISOR",
  1246. check: "Number"
  1247. }],
  1248. inputsInline: !0,
  1249. output: "Number",
  1250. colour: Blockly.Blocks.math.HUE,
  1251. tooltip: Blockly.Msg.MATH_DIVISION_CONSULT_TOOLTIP,
  1252. helpUrl: Blockly.Msg.MATH_DIVISION_CONSULT_HELPURL
  1253. })
  1254. }
  1255. };
  1256. Blockly.Blocks.math_constrain = {
  1257. init: function () {
  1258. this.jsonInit({
  1259. message0: Blockly.Msg.MATH_CONSTRAIN_TITLE,
  1260. args0: [{
  1261. type: "input_value",
  1262. name: "VALUE",
  1263. check: "Number"
  1264. }, {
  1265. type: "input_value",
  1266. name: "LOW",
  1267. check: "Number"
  1268. }, {
  1269. type: "input_value",
  1270. name: "HIGH",
  1271. check: "Number"
  1272. }],
  1273. inputsInline: !0,
  1274. output: "Number",
  1275. colour: Blockly.Blocks.math.HUE,
  1276. tooltip: Blockly.Msg.MATH_CONSTRAIN_TOOLTIP,
  1277. helpUrl: Blockly.Msg.MATH_CONSTRAIN_HELPURL
  1278. })
  1279. }
  1280. };
  1281. Blockly.Blocks.math_random_int = {
  1282. init: function () {
  1283. this.jsonInit({
  1284. message0: Blockly.Msg.MATH_RANDOM_INT_TITLE,
  1285. args0: [{
  1286. type: "input_value",
  1287. name: "FROM",
  1288. check: "Number"
  1289. }, {
  1290. type: "input_value",
  1291. name: "TO",
  1292. check: "Number"
  1293. }],
  1294. inputsInline: !0,
  1295. output: "Number",
  1296. colour: Blockly.Blocks.math.HUE,
  1297. tooltip: Blockly.Msg.MATH_RANDOM_INT_TOOLTIP,
  1298. helpUrl: Blockly.Msg.MATH_RANDOM_INT_HELPURL
  1299. })
  1300. }
  1301. };
  1302. Blockly.Blocks.math_random_float = {
  1303. init: function () {
  1304. this.jsonInit({
  1305. message0: Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM,
  1306. output: "Number",
  1307. colour: Blockly.Blocks.math.HUE,
  1308. tooltip: Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP,
  1309. helpUrl: Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL
  1310. })
  1311. }
  1312. };
  1313. Blockly.Blocks.math_convert = {
  1314. init: function () {
  1315. this.jsonInit({
  1316. message0: Blockly.Msg.MATH_CONVERT_MESSAGE0,
  1317. args0: [{
  1318. type: "field_dropdown",
  1319. options: [["int", "int"], ["float", "float"]],
  1320. name: "TYPE0"
  1321. }, {
  1322. type: "input_value",
  1323. name: "INPUT0",
  1324. check: ["Number", "String"]
  1325. }],
  1326. output: "Number",
  1327. colour: Blockly.Blocks.math.HUE,
  1328. tooltip: Blockly.Msg.MATH_CONVERT_TOOLTIP,
  1329. helpUrl: Blockly.Msg.MATH_CONVERT_HELPURL
  1330. })
  1331. }
  1332. };
  1333. Blockly.Blocks.math_number_bits_ops = {
  1334. init: function () {
  1335. this.jsonInit({
  1336. message0: Blockly.Msg.MATH_NUMBER_BITS_OPS_MESSAGE0,
  1337. args0: [{
  1338. type: "input_value",
  1339. name: "A",
  1340. check: "Number"
  1341. }, {
  1342. type: "field_dropdown",
  1343. options: [["|", " | "], ["&", " & "], ["^", " ^ "], ["<<", " << "], [">>", " >> "]],
  1344. name: "OP"
  1345. }, {
  1346. type: "input_value",
  1347. name: "B",
  1348. check: "Number"
  1349. }],
  1350. inputsInline: !0,
  1351. output: "Number",
  1352. colour: Blockly.Blocks.math.HUE,
  1353. tooltip: Blockly.Msg.MATH_NUMBER_BITS_OPS_TOOLTIP,
  1354. helpUrl: Blockly.Msg.MATH_NUMBER_BITS_OPS_HELPURL
  1355. })
  1356. }
  1357. };
  1358. Blockly.Blocks.procedures = {};
  1359. Blockly.Blocks.procedures.HUE = "#ff6381";
  1360. Blockly.Blocks.procedures_defnoreturn = {
  1361. init: function () {
  1362. var a = new Blockly.FieldTextInput(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE, Blockly.Procedures.rename);
  1363. a.setSpellcheck(!1);
  1364. this.setInputsInline(!0);
  1365. this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a, "NAME").appendField("", "PARAMS");
  1366. this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));
  1367. (this.workspace.options.comments || this.workspace.options.parentWorkspace && this.workspace.options.parentWorkspace.options.comments) && Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT && this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);
  1368. this.setColour(Blockly.Blocks.procedures.HUE);
  1369. this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
  1370. this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
  1371. this.arguments_ = [];
  1372. this.setStatements_(!0);
  1373. this.statementConnection_ = null
  1374. },
  1375. setStatements_: function (a) {
  1376. this.hasStatements_ !== a && (a ? (this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),
  1377. this.getInput("RETURN") && this.moveInputBefore("STACK", "RETURN")) : this.removeInput("STACK", !0),
  1378. this.hasStatements_ = a)
  1379. },
  1380. updateParams_: function () {
  1381. for (var a = !1, b = {}, c = 0; c < this.arguments_.length; c++) {
  1382. if (b["arg_" + this.arguments_[c].toLowerCase()]) {
  1383. a = !0;
  1384. break
  1385. }
  1386. b["arg_" + this.arguments_[c].toLowerCase()] = !0
  1387. }
  1388. a ? this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING) : this.setWarningText(null);
  1389. a = "";
  1390. this.arguments_.length && (a = Blockly.Msg.PROCEDURES_BEFORE_PARAMS + " " + this.arguments_.join(", "));
  1391. Blockly.Events.disable();
  1392. try {
  1393. this.setFieldValue(a, "PARAMS")
  1394. } finally {
  1395. Blockly.Events.enable()
  1396. }
  1397. },
  1398. mutationToDom: function (a) {
  1399. var b = document.createElement("mutation");
  1400. a && b.setAttribute("name", this.getFieldValue("NAME"));
  1401. for (var c = 0; c < this.arguments_.length; c++) {
  1402. var e = document.createElement("arg");
  1403. e.setAttribute("name", this.arguments_[c]);
  1404. a && this.paramIds_ && e.setAttribute("paramId", this.paramIds_[c]);
  1405. b.appendChild(e)
  1406. }
  1407. this.hasStatements_ || b.setAttribute("statements", "false");
  1408. return b
  1409. },
  1410. domToMutation: function (a) {
  1411. this.arguments_ = [];
  1412. for (var b = 0, c; c = a.childNodes[b]; b++)
  1413. "arg" == c.nodeName.toLowerCase() && this.arguments_.push(c.getAttribute("name"));
  1414. this.updateParams_();
  1415. Blockly.Procedures.mutateCallers(this);
  1416. this.setStatements_("false" !== a.getAttribute("statements"))
  1417. },
  1418. decompose: function (a) {
  1419. var b = a.newBlock("procedures_mutatorcontainer");
  1420. b.initSvg();
  1421. this.getInput("RETURN") ? b.setFieldValue(this.hasStatements_ ? "TRUE" : "FALSE", "STATEMENTS") : b.getInput("STATEMENT_INPUT").setVisible(!1);
  1422. for (var c = b.getInput("STACK").connection, e = 0; e < this.arguments_.length; e++) {
  1423. var d = a.newBlock("procedures_mutatorarg");
  1424. d.initSvg();
  1425. d.setFieldValue(this.arguments_[e], "NAME");
  1426. d.oldLocation = e;
  1427. c.connect(d.previousConnection);
  1428. c = d.nextConnection
  1429. }
  1430. Blockly.Procedures.mutateCallers(this);
  1431. return b
  1432. },
  1433. compose: function (a) {
  1434. this.arguments_ = [];
  1435. this.paramIds_ = [];
  1436. for (var b = a.getInputTargetBlock("STACK"); b;)
  1437. this.arguments_.push(b.getFieldValue("NAME")),
  1438. this.paramIds_.push(b.id),
  1439. b = b.nextConnection && b.nextConnection.targetBlock();
  1440. this.updateParams_();
  1441. Blockly.Procedures.mutateCallers(this);
  1442. a = a.getFieldValue("STATEMENTS");
  1443. if (null !== a && (a = "TRUE" == a,
  1444. this.hasStatements_ != a))
  1445. if (a)
  1446. this.setStatements_(!0),
  1447. Blockly.Mutator.reconnect(this.statementConnection_, this, "STACK"),
  1448. this.statementConnection_ = null;
  1449. else {
  1450. a = this.getInput("STACK").connection;
  1451. if (this.statementConnection_ = a.targetConnection)
  1452. a = a.targetBlock(),
  1453. a.unplug(),
  1454. a.bumpNeighbours_();
  1455. this.setStatements_(!1)
  1456. }
  1457. },
  1458. getProcedureDef: function () {
  1459. return [this.getFieldValue("NAME"), this.arguments_, !1]
  1460. },
  1461. getVars: function () {
  1462. return this.arguments_
  1463. },
  1464. renameVar: function (a, b) {
  1465. for (var c = !1, e = 0; e < this.arguments_.length; e++)
  1466. Blockly.Names.equals(a, this.arguments_[e]) && (this.arguments_[e] = b,
  1467. c = !0);
  1468. if (c && (this.updateParams_(),
  1469. this.mutator.isVisible())) {
  1470. c = this.mutator.workspace_.getAllBlocks();
  1471. e = 0;
  1472. for (var d; d = c[e]; e++)
  1473. "procedures_mutatorarg" == d.type && Blockly.Names.equals(a, d.getFieldValue("NAME")) && d.setFieldValue(b, "NAME")
  1474. }
  1475. },
  1476. customContextMenu: function (a) {
  1477. var b = {
  1478. enabled: !0
  1479. }
  1480. , c = this.getFieldValue("NAME");
  1481. b.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1", c);
  1482. var e = goog.dom.createDom("mutation");
  1483. e.setAttribute("name", c);
  1484. for (var d = 0; d < this.arguments_.length; d++)
  1485. c = goog.dom.createDom("arg"),
  1486. c.setAttribute("name", this.arguments_[d]),
  1487. e.appendChild(c);
  1488. e = goog.dom.createDom("block", null, e);
  1489. e.setAttribute("type", this.callType_);
  1490. b.callback = Blockly.ContextMenu.callbackFactory(this, e);
  1491. a.push(b);
  1492. if (!this.isCollapsed())
  1493. for (d = 0; d < this.arguments_.length; d++)
  1494. b = {
  1495. enabled: !0
  1496. },
  1497. c = this.arguments_[d],
  1498. b.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1", c),
  1499. e = goog.dom.createDom("field", null, c),
  1500. e.setAttribute("name", "VAR"),
  1501. e = goog.dom.createDom("block", null, e),
  1502. e.setAttribute("type", "variables_get"),
  1503. b.callback = Blockly.ContextMenu.callbackFactory(this, e),
  1504. a.push(b)
  1505. },
  1506. callType_: "procedures_callnoreturn"
  1507. };
  1508. Blockly.Blocks.procedures_defreturn = {
  1509. init: function () {
  1510. var a = new Blockly.FieldTextInput(Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE, Blockly.Procedures.rename);
  1511. a.setSpellcheck(!1);
  1512. this.setInputsInline(!0);
  1513. this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE).appendField(a, "NAME").appendField("", "PARAMS");
  1514. this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
  1515. this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));
  1516. (this.workspace.options.comments || this.workspace.options.parentWorkspace && this.workspace.options.parentWorkspace.options.comments) && Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT && this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);
  1517. this.setColour(Blockly.Blocks.procedures.HUE);
  1518. this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);
  1519. this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
  1520. this.arguments_ = [];
  1521. this.setStatements_(!0);
  1522. this.statementConnection_ = null
  1523. },
  1524. setStatements_: Blockly.Blocks.procedures_defnoreturn.setStatements_,
  1525. updateParams_: Blockly.Blocks.procedures_defnoreturn.updateParams_,
  1526. mutationToDom: Blockly.Blocks.procedures_defnoreturn.mutationToDom,
  1527. domToMutation: Blockly.Blocks.procedures_defnoreturn.domToMutation,
  1528. decompose: Blockly.Blocks.procedures_defnoreturn.decompose,
  1529. compose: Blockly.Blocks.procedures_defnoreturn.compose,
  1530. getProcedureDef: function () {
  1531. return [this.getFieldValue("NAME"), this.arguments_, !0]
  1532. },
  1533. getVars: Blockly.Blocks.procedures_defnoreturn.getVars,
  1534. renameVar: Blockly.Blocks.procedures_defnoreturn.renameVar,
  1535. customContextMenu: Blockly.Blocks.procedures_defnoreturn.customContextMenu,
  1536. callType_: "procedures_callreturn"
  1537. };
  1538. Blockly.Blocks.procedures_mutatorcontainer = {
  1539. init: function () {
  1540. this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
  1541. this.appendStatementInput("STACK");
  1542. this.appendDummyInput("STATEMENT_INPUT").appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new Blockly.FieldCheckbox("TRUE"), "STATEMENTS");
  1543. this.setColour(Blockly.Blocks.procedures.HUE);
  1544. this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
  1545. this.contextMenu = !1
  1546. }
  1547. };
  1548. Blockly.Blocks.procedures_mutatorarg = {
  1549. init: function () {
  1550. var a = new Blockly.FieldTextInput("x", this.validator_);
  1551. this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE).appendField(a, "NAME");
  1552. this.setPreviousStatement(!0);
  1553. this.setNextStatement(!0);
  1554. this.setColour(Blockly.Blocks.procedures.HUE);
  1555. this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);
  1556. this.contextMenu = !1;
  1557. a.onFinishEditing_ = this.createNewVar_;
  1558. a.onFinishEditing_("x")
  1559. },
  1560. validator_: function (a) {
  1561. return (a = a.replace(/[\s\xa0]+/g, " ").replace(/^ | $/g, "")) || null
  1562. },
  1563. createNewVar_: function (a) {
  1564. var b = this.sourceBlock_;
  1565. b && b.workspace && b.workspace.options && b.workspace.options.parentWorkspace && b.workspace.options.parentWorkspace.createVariable(a)
  1566. }
  1567. };
  1568. Blockly.Blocks.procedures_callnoreturn = {
  1569. init: function () {
  1570. this.appendDummyInput("TOPROW").appendField(this.id, "NAME");
  1571. this.setPreviousStatement(!0);
  1572. this.setNextStatement(!0);
  1573. this.setColour(Blockly.Blocks.procedures.HUE);
  1574. this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
  1575. this.arguments_ = [];
  1576. this.quarkConnections_ = {};
  1577. this.quarkIds_ = null
  1578. },
  1579. getProcedureCall: function () {
  1580. return this.getFieldValue("NAME")
  1581. },
  1582. renameProcedure: function (a, b) {
  1583. Blockly.Names.equals(a, this.getProcedureCall()) && (this.setFieldValue(b, "NAME"),
  1584. this.setTooltip((this.outputConnection ? Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP : Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1", b)))
  1585. },
  1586. setProcedureParameters_: function (a, b) {
  1587. var c = Blockly.Procedures.getDefinition(this.getProcedureCall(), this.workspace)
  1588. , e = c && c.mutator && c.mutator.isVisible();
  1589. e || (this.quarkConnections_ = {},
  1590. this.quarkIds_ = null);
  1591. if (b)
  1592. if (goog.array.equals(this.arguments_, a))
  1593. this.quarkIds_ = b;
  1594. else {
  1595. if (b.length != a.length)
  1596. throw "Error: paramNames and paramIds must be the same length.";
  1597. this.setCollapsed(!1);
  1598. this.quarkIds_ || (this.quarkConnections_ = {},
  1599. a.join("\n") == this.arguments_.join("\n") ? this.quarkIds_ = b : this.quarkIds_ = []);
  1600. c = this.rendered;
  1601. this.rendered = !1;
  1602. for (var d = 0; d < this.arguments_.length; d++) {
  1603. var f = this.getInput("ARG" + d);
  1604. f && (f = f.connection.targetConnection,
  1605. this.quarkConnections_[this.quarkIds_[d]] = f,
  1606. e && f && -1 == b.indexOf(this.quarkIds_[d]) && (f.disconnect(),
  1607. f.getSourceBlock().bumpNeighbours_()))
  1608. }
  1609. this.arguments_ = [].concat(a);
  1610. this.updateShape_();
  1611. if (this.quarkIds_ = b)
  1612. for (d = 0; d < this.arguments_.length; d++)
  1613. e = this.quarkIds_[d],
  1614. e in this.quarkConnections_ && (f = this.quarkConnections_[e],
  1615. Blockly.Mutator.reconnect(f, this, "ARG" + d) || delete this.quarkConnections_[e]);
  1616. (this.rendered = c) && this.render()
  1617. }
  1618. },
  1619. updateShape_: function () {
  1620. for (var a = 0; a < this.arguments_.length; a++) {
  1621. var b = this.getField("ARGNAME" + a);
  1622. if (b) {
  1623. Blockly.Events.disable();
  1624. try {
  1625. b.setValue(this.arguments_[a])
  1626. } finally {
  1627. Blockly.Events.enable()
  1628. }
  1629. } else
  1630. b = new Blockly.FieldLabel(this.arguments_[a]),
  1631. this.appendValueInput("ARG" + a).setAlign(Blockly.ALIGN_RIGHT).appendField(b, "ARGNAME" + a).init()
  1632. }
  1633. for (; this.getInput("ARG" + a);)
  1634. this.removeInput("ARG" + a),
  1635. a++;
  1636. if (a = this.getInput("TOPROW"))
  1637. this.arguments_.length ? this.getField("WITH") || (a.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, "WITH"),
  1638. a.init()) : this.getField("WITH") && a.removeField("WITH")
  1639. },
  1640. mutationToDom: function () {
  1641. var a = document.createElement("mutation");
  1642. a.setAttribute("name", this.getProcedureCall());
  1643. for (var b = 0; b < this.arguments_.length; b++) {
  1644. var c = document.createElement("arg");
  1645. c.setAttribute("name", this.arguments_[b]);
  1646. a.appendChild(c)
  1647. }
  1648. return a
  1649. },
  1650. domToMutation: function (a) {
  1651. var b = a.getAttribute("name");
  1652. this.renameProcedure(this.getProcedureCall(), b);
  1653. b = [];
  1654. for (var c = [], e = 0, d; d = a.childNodes[e]; e++)
  1655. "arg" == d.nodeName.toLowerCase() && (b.push(d.getAttribute("name")),
  1656. c.push(d.getAttribute("paramId")));
  1657. this.setProcedureParameters_(b, c)
  1658. },
  1659. renameVar: function (a, b) {
  1660. for (var c = 0; c < this.arguments_.length; c++)
  1661. Blockly.Names.equals(a, this.arguments_[c]) && (this.arguments_[c] = b,
  1662. this.getField("ARGNAME" + c).setValue(b))
  1663. },
  1664. onchange: function (a) {
  1665. if (this.workspace && !this.workspace.isFlyout)
  1666. if (a.type == Blockly.Events.CREATE && -1 != a.ids.indexOf(this.id)) {
  1667. var b = this.getProcedureCall();
  1668. b = Blockly.Procedures.getDefinition(b, this.workspace);
  1669. !b || b.type == this.defType_ && JSON.stringify(b.arguments_) == JSON.stringify(this.arguments_) || (b = null);
  1670. if (!b) {
  1671. Blockly.Events.setGroup(a.group);
  1672. a = goog.dom.createDom("xml");
  1673. b = goog.dom.createDom("block");
  1674. b.setAttribute("type", this.defType_);
  1675. var c = this.getRelativeToSurfaceXY()
  1676. , e = c.y + 2 * Blockly.SNAP_RADIUS;
  1677. b.setAttribute("x", c.x + Blockly.SNAP_RADIUS * (this.RTL ? -1 : 1));
  1678. b.setAttribute("y", e);
  1679. c = this.mutationToDom();
  1680. b.appendChild(c);
  1681. c = goog.dom.createDom("field");
  1682. c.setAttribute("name", "NAME");
  1683. c.appendChild(document.createTextNode(this.getProcedureCall()));
  1684. b.appendChild(c);
  1685. a.appendChild(b);
  1686. Blockly.Xml.domToWorkspace(a, this.workspace);
  1687. Blockly.Events.setGroup(!1)
  1688. }
  1689. } else
  1690. a.type == Blockly.Events.DELETE && (b = this.getProcedureCall(),
  1691. b = Blockly.Procedures.getDefinition(b, this.workspace),
  1692. b || (Blockly.Events.setGroup(a.group),
  1693. this.dispose(!0, !1),
  1694. Blockly.Events.setGroup(!1)))
  1695. },
  1696. customContextMenu: function (a) {
  1697. var b = {
  1698. enabled: !0
  1699. };
  1700. b.text = Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;
  1701. var c = this.getProcedureCall()
  1702. , e = this.workspace;
  1703. b.callback = function () {
  1704. var a = Blockly.Procedures.getDefinition(c, e);
  1705. a && a.select()
  1706. }
  1707. ;
  1708. a.push(b)
  1709. },
  1710. defType_: "procedures_defnoreturn"
  1711. };
  1712. Blockly.Blocks.procedures_callreturn = {
  1713. init: function () {
  1714. this.appendDummyInput("TOPROW").appendField("", "NAME");
  1715. this.setOutput(!0);
  1716. this.setColour(Blockly.Blocks.procedures.HUE);
  1717. this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
  1718. this.arguments_ = [];
  1719. this.quarkConnections_ = {};
  1720. this.quarkIds_ = null
  1721. },
  1722. getProcedureCall: Blockly.Blocks.procedures_callnoreturn.getProcedureCall,
  1723. renameProcedure: Blockly.Blocks.procedures_callnoreturn.renameProcedure,
  1724. setProcedureParameters_: Blockly.Blocks.procedures_callnoreturn.setProcedureParameters_,
  1725. updateShape_: Blockly.Blocks.procedures_callnoreturn.updateShape_,
  1726. mutationToDom: Blockly.Blocks.procedures_callnoreturn.mutationToDom,
  1727. domToMutation: Blockly.Blocks.procedures_callnoreturn.domToMutation,
  1728. renameVar: Blockly.Blocks.procedures_callnoreturn.renameVar,
  1729. onchange: Blockly.Blocks.procedures_callnoreturn.onchange,
  1730. customContextMenu: Blockly.Blocks.procedures_callnoreturn.customContextMenu,
  1731. defType_: "procedures_defreturn"
  1732. };
  1733. Blockly.Blocks.procedures_ifreturn = {
  1734. init: function () {
  1735. this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
  1736. this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
  1737. this.setInputsInline(!0);
  1738. this.setPreviousStatement(!0);
  1739. this.setNextStatement(!0);
  1740. this.setColour(Blockly.Blocks.procedures.HUE);
  1741. this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);
  1742. this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);
  1743. this.hasReturnValue_ = !0
  1744. },
  1745. mutationToDom: function () {
  1746. var a = document.createElement("mutation");
  1747. a.setAttribute("value", Number(this.hasReturnValue_));
  1748. return a
  1749. },
  1750. domToMutation: function (a) {
  1751. this.hasReturnValue_ = 1 == a.getAttribute("value");
  1752. this.hasReturnValue_ || (this.removeInput("VALUE"),
  1753. this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN))
  1754. },
  1755. onchange: function (a) {
  1756. if (!this.workspace.isDragging()) {
  1757. a = !1;
  1758. var b = this;
  1759. do {
  1760. if (-1 != this.FUNCTION_TYPES.indexOf(b.type)) {
  1761. a = !0;
  1762. break
  1763. }
  1764. b = b.getSurroundParent()
  1765. } while (b); a ? ("procedures_defnoreturn" == b.type && this.hasReturnValue_ ? (this.removeInput("VALUE"),
  1766. this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),
  1767. this.hasReturnValue_ = !1) : "procedures_defreturn" != b.type || this.hasReturnValue_ || (this.removeInput("VALUE"),
  1768. this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),
  1769. this.hasReturnValue_ = !0),
  1770. this.setWarningText(null),
  1771. this.isInFlyout || this.setDisabled(!1)) : (this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING),
  1772. this.isInFlyout || this.getInheritedDisabled() || this.setDisabled(!0))
  1773. }
  1774. },
  1775. FUNCTION_TYPES: ["procedures_defnoreturn", "procedures_defreturn"]
  1776. };
  1777. Blockly.Blocks.texts = {};
  1778. Blockly.Blocks.texts.HUE = "#33cc99";
  1779. Blockly.Blocks.text = {
  1780. init: function () {
  1781. this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
  1782. this.setColour(Blockly.Blocks.texts.HUE);
  1783. this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput, "TEXT").appendField(this.newQuote_(!1));
  1784. this.setOutput(!0, "String");
  1785. var a = this;
  1786. this.setTooltip(function () {
  1787. var b = a.getParent();
  1788. return b && b.getInputsInline() && b.tooltip || Blockly.Msg.TEXT_TEXT_TOOLTIP
  1789. })
  1790. },
  1791. newQuote_: function (a) {
  1792. return new Blockly.FieldImage(a == this.RTL ? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC", 12, 12, '"')
  1793. }
  1794. };
  1795. Blockly.Blocks.text_list = {
  1796. init: function () {
  1797. this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
  1798. this.setColour("#40bfe4");
  1799. this.setTooltip(Blockly.Msg.Text_List_TOOLTIP);
  1800. this.appendDummyInput().appendField(Blockly.Msg.TEXT_LIST_START).appendField(new Blockly.FieldTextInput(""), "TEXT").appendField(Blockly.Msg.TEXT_LIST_END);
  1801. this.setOutput(!0, "Array")
  1802. }
  1803. };
  1804. Blockly.Blocks.text_tuple = {
  1805. init: function () {
  1806. this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
  1807. this.setColour(192);
  1808. this.appendDummyInput().appendField(Blockly.Msg.TEXT_TUPLE_START).appendField(new Blockly.FieldTextInput(""), "TEXT").appendField(Blockly.Msg.TEXT_TUPLE_END);
  1809. this.setOutput(!0, "Array");
  1810. this.setTooltip(Blockly.Msg.Text_Tuple_TOOLTIP);
  1811. }
  1812. };
  1813. Blockly.Blocks.text_dict = {
  1814. init: function () {
  1815. this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL);
  1816. this.setColour(32);
  1817. this.appendDummyInput().appendField(Blockly.Msg.TEXT_DICT_START).appendField(new Blockly.FieldTextInput(""), "TEXT").appendField(Blockly.Msg.TEXT_DICT_END);
  1818. this.setOutput(!0, "Array");
  1819. this.setTooltip(Blockly.Msg.Text_Dict_TOOLTIP)
  1820. }
  1821. };
  1822. Blockly.Blocks.text_join = {
  1823. init: function () {
  1824. this.setHelpUrl(Blockly.Msg.TEXT_JOIN_HELPURL);
  1825. this.setColour(Blockly.Blocks.texts.HUE);
  1826. this.itemCount_ = 2;
  1827. this.updateShape_();
  1828. this.setOutput(!0, "String");
  1829. this.setMutator(new Blockly.Mutator(["text_create_join_item"]));
  1830. this.setTooltip(Blockly.Msg.TEXT_JOIN_TOOLTIP)
  1831. },
  1832. mutationToDom: function () {
  1833. var a = document.createElement("mutation");
  1834. a.setAttribute("items", this.itemCount_);
  1835. return a
  1836. },
  1837. domToMutation: function (a) {
  1838. this.itemCount_ = parseInt(a.getAttribute("items"), 10);
  1839. this.updateShape_()
  1840. },
  1841. decompose: function (a) {
  1842. var b = a.newBlock("text_create_join_container");
  1843. b.initSvg();
  1844. for (var c = b.getInput("STACK").connection, e = 0; e < this.itemCount_; e++) {
  1845. var d = a.newBlock("text_create_join_item");
  1846. d.initSvg();
  1847. c.connect(d.previousConnection);
  1848. c = d.nextConnection
  1849. }
  1850. return b
  1851. },
  1852. compose: function (a) {
  1853. var b = a.getInputTargetBlock("STACK");
  1854. for (a = []; b;)
  1855. a.push(b.valueConnection_),
  1856. b = b.nextConnection && b.nextConnection.targetBlock();
  1857. for (b = 0; b < this.itemCount_; b++) {
  1858. var c = this.getInput("ADD" + b).connection.targetConnection;
  1859. c && -1 == a.indexOf(c) && c.disconnect()
  1860. }
  1861. this.itemCount_ = a.length;
  1862. this.updateShape_();
  1863. for (b = 0; b < this.itemCount_; b++)
  1864. Blockly.Mutator.reconnect(a[b], this, "ADD" + b)
  1865. },
  1866. saveConnections: function (a) {
  1867. a = a.getInputTargetBlock("STACK");
  1868. for (var b = 0; a;) {
  1869. var c = this.getInput("ADD" + b);
  1870. a.valueConnection_ = c && c.connection.targetConnection;
  1871. b++;
  1872. a = a.nextConnection && a.nextConnection.targetBlock()
  1873. }
  1874. },
  1875. updateShape_: function () {
  1876. this.itemCount_ && this.getInput("EMPTY") ? this.removeInput("EMPTY") : this.itemCount_ || this.getInput("EMPTY") || this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));
  1877. for (var a = 0; a < this.itemCount_; a++)
  1878. if (!this.getInput("ADD" + a)) {
  1879. var b = this.appendValueInput("ADD" + a);
  1880. 0 == a && b.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH)
  1881. }
  1882. for (; this.getInput("ADD" + a);)
  1883. this.removeInput("ADD" + a),
  1884. a++
  1885. },
  1886. newQuote_: Blockly.Blocks.text.newQuote_
  1887. };
  1888. Blockly.Blocks.text_create_join_container = {
  1889. init: function () {
  1890. this.setColour(Blockly.Blocks.texts.HUE);
  1891. this.appendDummyInput().appendField(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN);
  1892. this.appendStatementInput("STACK");
  1893. this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP);
  1894. this.contextMenu = !1
  1895. }
  1896. };
  1897. Blockly.Blocks.text_create_join_item = {
  1898. init: function () {
  1899. this.setColour(Blockly.Blocks.texts.HUE);
  1900. this.appendDummyInput().appendField(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM);
  1901. this.setPreviousStatement(!0);
  1902. this.setNextStatement(!0);
  1903. this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP);
  1904. this.contextMenu = !1
  1905. }
  1906. };
  1907. Blockly.Blocks.text_append = {
  1908. init: function () {
  1909. this.setHelpUrl(Blockly.Msg.TEXT_APPEND_HELPURL);
  1910. this.setColour(Blockly.Blocks.texts.HUE);
  1911. this.appendValueInput("TEXT").appendField(Blockly.Msg.TEXT_APPEND_TO).appendField(new Blockly.FieldVariable(Blockly.Msg.TEXT_APPEND_VARIABLE), "VAR").appendField(Blockly.Msg.TEXT_APPEND_APPENDTEXT);
  1912. this.setPreviousStatement(!0);
  1913. this.setNextStatement(!0);
  1914. var a = this;
  1915. this.setTooltip(function () {
  1916. return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1", a.getFieldValue("VAR"))
  1917. })
  1918. }
  1919. };
  1920. Blockly.Blocks.text_length = {
  1921. init: function () {
  1922. this.jsonInit({
  1923. message0: Blockly.Msg.TEXT_LENGTH_TITLE,
  1924. args0: [{
  1925. type: "input_value",
  1926. name: "VALUE",
  1927. check: ["String", "Array"]
  1928. }],
  1929. output: "Number",
  1930. colour: Blockly.Blocks.texts.HUE,
  1931. tooltip: Blockly.Msg.TEXT_LENGTH_TOOLTIP,
  1932. helpUrl: Blockly.Msg.TEXT_LENGTH_HELPURL
  1933. })
  1934. }
  1935. };
  1936. Blockly.Blocks.text_isEmpty = {
  1937. init: function () {
  1938. this.jsonInit({
  1939. message0: Blockly.Msg.TEXT_ISEMPTY_TITLE,
  1940. args0: [{
  1941. type: "input_value",
  1942. name: "VALUE",
  1943. check: ["String", "Array"]
  1944. }],
  1945. output: "Boolean",
  1946. colour: Blockly.Blocks.texts.HUE,
  1947. tooltip: Blockly.Msg.TEXT_ISEMPTY_TOOLTIP,
  1948. helpUrl: Blockly.Msg.TEXT_ISEMPTY_HELPURL
  1949. })
  1950. }
  1951. };
  1952. Blockly.Blocks.text_indexOf = {
  1953. init: function () {
  1954. var a = [[Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST, "FIRST"], [Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST, "LAST"]];
  1955. this.setHelpUrl(Blockly.Msg.TEXT_INDEXOF_HELPURL);
  1956. this.setColour(Blockly.Blocks.texts.HUE);
  1957. this.setOutput(!0, "Number");
  1958. this.appendValueInput("VALUE").setCheck("String").appendField(Blockly.Msg.TEXT_INDEXOF_INPUT_INTEXT);
  1959. this.appendValueInput("FIND").setCheck("String").appendField(new Blockly.FieldDropdown(a), "END");
  1960. Blockly.Msg.TEXT_INDEXOF_TAIL && this.appendDummyInput().appendField(Blockly.Msg.TEXT_INDEXOF_TAIL);
  1961. this.setInputsInline(!0);
  1962. var b = this;
  1963. this.setTooltip(function () {
  1964. return Blockly.Msg.TEXT_INDEXOF_TOOLTIP.replace("%1", b.workspace.options.oneBasedIndex ? "0" : "-1")
  1965. })
  1966. }
  1967. };
  1968. Blockly.Blocks.text_charAt = {
  1969. init: function () {
  1970. this.WHERE_OPTIONS = [[Blockly.Msg.TEXT_CHARAT_FROM_START, "FROM_START"], [Blockly.Msg.TEXT_CHARAT_FROM_END, "FROM_END"], [Blockly.Msg.TEXT_CHARAT_FIRST, "FIRST"], [Blockly.Msg.TEXT_CHARAT_LAST, "LAST"], [Blockly.Msg.TEXT_CHARAT_RANDOM, "RANDOM"]];
  1971. this.setHelpUrl(Blockly.Msg.TEXT_CHARAT_HELPURL);
  1972. this.setColour(Blockly.Blocks.texts.HUE);
  1973. this.setOutput(!0, "String");
  1974. this.appendValueInput("VALUE").setCheck("String").appendField(Blockly.Msg.TEXT_CHARAT_INPUT_INTEXT);
  1975. this.appendDummyInput("AT");
  1976. this.setInputsInline(!0);
  1977. this.updateAt_(!0);
  1978. var a = this;
  1979. this.setTooltip(function () {
  1980. var b = a.getFieldValue("WHERE")
  1981. , c = Blockly.Msg.TEXT_CHARAT_TOOLTIP;
  1982. if ("FROM_START" == b || "FROM_END" == b)
  1983. c += " " + ("FROM_START" == b ? Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP : Blockly.Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1", a.workspace.options.oneBasedIndex ? "#1" : "#0");
  1984. return c
  1985. })
  1986. },
  1987. mutationToDom: function () {
  1988. var a = document.createElement("mutation")
  1989. , b = this.getInput("AT").type == Blockly.INPUT_VALUE;
  1990. a.setAttribute("at", b);
  1991. return a
  1992. },
  1993. domToMutation: function (a) {
  1994. a = "false" != a.getAttribute("at");
  1995. this.updateAt_(a)
  1996. },
  1997. updateAt_: function (a) {
  1998. this.removeInput("AT");
  1999. this.removeInput("ORDINAL", !0);
  2000. a ? (this.appendValueInput("AT").setCheck("Number"),
  2001. Blockly.Msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT");
  2002. Blockly.Msg.TEXT_CHARAT_TAIL && (this.removeInput("TAIL", !0),
  2003. this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_CHARAT_TAIL));
  2004. var b = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function (b) {
  2005. var c = "FROM_START" == b || "FROM_END" == b;
  2006. if (c != a) {
  2007. var d = this.sourceBlock_;
  2008. d.updateAt_(c);
  2009. d.setFieldValue(b, "WHERE");
  2010. return null
  2011. }
  2012. }
  2013. );
  2014. this.getInput("AT").appendField(b, "WHERE")
  2015. }
  2016. };
  2017. Blockly.Blocks.text_getSubstring = {
  2018. init: function () {
  2019. this.WHERE_OPTIONS_1 = [[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START, "FROM_START"], [Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END, "FROM_END"], [Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST, "FIRST"]];
  2020. this.WHERE_OPTIONS_2 = [[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START, "FROM_START"], [Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END, "FROM_END"], [Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST, "LAST"]];
  2021. this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL);
  2022. this.setColour(Blockly.Blocks.texts.HUE);
  2023. this.appendValueInput("STRING").setCheck("String").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);
  2024. this.appendDummyInput("AT1");
  2025. this.appendDummyInput("AT2");
  2026. Blockly.Msg.TEXT_GET_SUBSTRING_TAIL && this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL);
  2027. this.setInputsInline(!0);
  2028. this.setOutput(!0, "String");
  2029. this.updateAt_(1, !0);
  2030. this.updateAt_(2, !0);
  2031. this.setTooltip(Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP)
  2032. },
  2033. mutationToDom: function () {
  2034. var a = document.createElement("mutation")
  2035. , b = this.getInput("AT1").type == Blockly.INPUT_VALUE;
  2036. a.setAttribute("at1", b);
  2037. b = this.getInput("AT2").type == Blockly.INPUT_VALUE;
  2038. a.setAttribute("at2", b);
  2039. return a
  2040. },
  2041. domToMutation: function (a) {
  2042. var b = "true" == a.getAttribute("at1");
  2043. a = "true" == a.getAttribute("at2");
  2044. this.updateAt_(1, b);
  2045. this.updateAt_(2, a)
  2046. },
  2047. updateAt_: function (a, b) {
  2048. this.removeInput("AT" + a);
  2049. this.removeInput("ORDINAL" + a, !0);
  2050. b ? (this.appendValueInput("AT" + a).setCheck("Number"),
  2051. Blockly.Msg.ORDINAL_NUMBER_SUFFIX && this.appendDummyInput("ORDINAL" + a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)) : this.appendDummyInput("AT" + a);
  2052. 2 == a && Blockly.Msg.TEXT_GET_SUBSTRING_TAIL && (this.removeInput("TAIL", !0),
  2053. this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL));
  2054. var c = new Blockly.FieldDropdown(this["WHERE_OPTIONS_" + a], function (c) {
  2055. var d = "FROM_START" == c || "FROM_END" == c;
  2056. if (d != b) {
  2057. var e = this.sourceBlock_;
  2058. e.updateAt_(a, d);
  2059. e.setFieldValue(c, "WHERE" + a);
  2060. return null
  2061. }
  2062. }
  2063. );
  2064. this.getInput("AT" + a).appendField(c, "WHERE" + a);
  2065. 1 == a && this.moveInputBefore("AT1", "AT2")
  2066. }
  2067. };
  2068. Blockly.Blocks.text_changeCase = {
  2069. init: function () {
  2070. var a = [[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE, "UPPERCASE"], [Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE, "LOWERCASE"]];
  2071. this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL);
  2072. this.setColour(Blockly.Blocks.texts.HUE);
  2073. this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(a), "CASE");
  2074. this.setOutput(!0, "String");
  2075. this.setTooltip(Blockly.Msg.TEXT_CHANGECASE_TOOLTIP)
  2076. }
  2077. };
  2078. Blockly.Blocks.text_trim = {
  2079. init: function () {
  2080. var a = [[Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH, "BOTH"], [Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT, "LEFT"], [Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT, "RIGHT"]];
  2081. this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL);
  2082. this.setColour(Blockly.Blocks.texts.HUE);
  2083. this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(a), "MODE");
  2084. this.setOutput(!0, "String");
  2085. this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP)
  2086. }
  2087. };
  2088. Blockly.Blocks.text_print = {
  2089. init: function () {
  2090. this.jsonInit({
  2091. message0: Blockly.Msg.TEXT_PRINT_TITLE,
  2092. args0: [{
  2093. type: "input_value",
  2094. name: "TEXT"
  2095. }],
  2096. previousStatement: null,
  2097. nextStatement: null,
  2098. colour: "#33cc99",
  2099. tooltip: Blockly.Msg.TEXT_PRINT_TOOLTIP,
  2100. helpUrl: Blockly.Msg.TEXT_PRINT_HELPURL
  2101. })
  2102. }
  2103. };
  2104. Blockly.Blocks.text_prompt_ext = {
  2105. init: function () {
  2106. var a = [[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT, "TEXT"], [Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, "NUMBER"]];
  2107. this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
  2108. this.setColour(Blockly.Blocks.texts.HUE);
  2109. var b = this;
  2110. a = new Blockly.FieldDropdown(a, function (a) {
  2111. b.updateType_(a)
  2112. }
  2113. );
  2114. this.appendValueInput("TEXT").appendField(a, "TYPE");
  2115. this.setOutput(!0, "String");
  2116. this.setTooltip(function () {
  2117. return "TEXT" == b.getFieldValue("TYPE") ? Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT : Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER
  2118. })
  2119. },
  2120. updateType_: function (a) {
  2121. this.outputConnection.setCheck("NUMBER" == a ? "Number" : "String")
  2122. },
  2123. mutationToDom: function () {
  2124. var a = document.createElement("mutation");
  2125. a.setAttribute("type", this.getFieldValue("TYPE"));
  2126. return a
  2127. },
  2128. domToMutation: function (a) {
  2129. this.updateType_(a.getAttribute("type"))
  2130. }
  2131. };
  2132. Blockly.Blocks.text_prompt = {
  2133. init: function () {
  2134. var a = [[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT, "TEXT"], [Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, "NUMBER"]]
  2135. , b = this;
  2136. this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
  2137. this.setColour(Blockly.Blocks.texts.HUE);
  2138. a = new Blockly.FieldDropdown(a, function (a) {
  2139. b.updateType_(a)
  2140. }
  2141. );
  2142. this.appendDummyInput().appendField(a, "TYPE").appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput(""), "TEXT").appendField(this.newQuote_(!1));
  2143. this.setOutput(!0, "String");
  2144. this.setTooltip(function () {
  2145. return "TEXT" == b.getFieldValue("TYPE") ? Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT : Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER
  2146. })
  2147. },
  2148. newQuote_: Blockly.Blocks.text.newQuote_,
  2149. updateType_: Blockly.Blocks.text_prompt_ext.updateType_,
  2150. mutationToDom: Blockly.Blocks.text_prompt_ext.mutationToDom,
  2151. domToMutation: Blockly.Blocks.text_prompt_ext.domToMutation
  2152. };
  2153. Blockly.Blocks.variables = {};
  2154. Blockly.Blocks.variables.HUE = "#ffab2f";
  2155. Blockly.Blocks.variables_get = {
  2156. init: function () {
  2157. this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
  2158. this.setColour(Blockly.Blocks.variables.HUE);
  2159. this.appendDummyInput().appendField(new Blockly.FieldVariable(Blockly.Msg.VARIABLES_DEFAULT_NAME), "VAR");
  2160. this.setOutput(!0);
  2161. this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
  2162. this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET
  2163. },
  2164. contextMenuType_: "variables_set",
  2165. customContextMenu: function (a) {
  2166. var b = {
  2167. enabled: !0
  2168. }
  2169. , c = this.getFieldValue("VAR");
  2170. b.text = this.contextMenuMsg_.replace("%1", c);
  2171. c = goog.dom.createDom("field", null, c);
  2172. c.setAttribute("name", "VAR");
  2173. c = goog.dom.createDom("block", null, c);
  2174. c.setAttribute("type", this.contextMenuType_);
  2175. b.callback = Blockly.ContextMenu.callbackFactory(this, c);
  2176. a.push(b)
  2177. }
  2178. };
  2179. Blockly.Blocks.variables_set = {
  2180. init: function () {
  2181. this.jsonInit({
  2182. message0: Blockly.Msg.VARIABLES_SET,
  2183. args0: [{
  2184. type: "field_variable",
  2185. name: "VAR",
  2186. variable: Blockly.Msg.VARIABLES_DEFAULT_NAME
  2187. }, {
  2188. type: "input_value",
  2189. name: "VALUE"
  2190. }],
  2191. previousStatement: null,
  2192. nextStatement: null,
  2193. colour: Blockly.Blocks.variables.HUE,
  2194. tooltip: Blockly.Msg.VARIABLES_SET_TOOLTIP,
  2195. helpUrl: Blockly.Msg.VARIABLES_SET_HELPURL
  2196. });
  2197. this.contextMenuMsg_ = Blockly.Msg.VARIABLES_SET_CREATE_GET
  2198. },
  2199. contextMenuType_: "variables_get",
  2200. customContextMenu: Blockly.Blocks.variables_get.customContextMenu
  2201. };