blocks_compressed.js 97 KB

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