| 1 |
<!DOCTYPE html> |
| 2 |
|
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta charset="utf-8"> |
| 6 |
<meta name="viewport" content="width=device-width,height=device-width, initial-scale=0.9, maximum-scale=1"> |
| 7 |
<script src="jquery.min.js"></script> |
| 8 |
<script src="Markdown.Converter.min.js"></script> |
| 9 |
<script src="semantic.min.js"></script> |
| 10 |
<link rel="stylesheet" type="text/css" href="semantic.min.css"> |
| 11 |
|
| 12 |
<script src="blockly_compressed.js"></script> |
| 13 |
<script src="blocks_compressed.js"></script> |
| 14 |
<script src="javascript_compressed.js"></script> |
| 15 |
<script src="python_compressed.js"></script> |
| 16 |
<link rel="stylesheet" type="text/css" href="style.css"> |
| 17 |
<script src="msg/js/en.js"></script> |
| 18 |
|
| 19 |
<link rel="stylesheet" type="text/css" href="piano.css"> |
| 20 |
|
| 21 |
|
| 22 |
<script src="blocks/api.js"></script> |
| 23 |
<script src="blocks/Plots.js"></script> |
| 24 |
<script src="blocks/Lists.js"></script> |
| 25 |
<script src="blocks/IO.js"></script> |
| 26 |
<script src="blocks/Games.js"></script> |
| 27 |
<script src="blocks/Sounds.js"></script> |
| 28 |
<script src="blocks/SEELab.js"></script> |
| 29 |
|
| 30 |
<script src="cv/cvutils.js"></script> |
| 31 |
|
| 32 |
|
| 33 |
<script src="blocks/acorn_interpreter.js"></script> |
| 34 |
<script src="qrc:///qtwebchannel/qwebchannel.js" type="text/javascript"></script> |
| 35 |
|
| 36 |
<link rel="stylesheet" type="text/css" href="uplot/uPlot.min.css" /> |
| 37 |
<script type="text/javascript" src="uplot/uPlot.iife.js"></script> |
| 38 |
<script type="text/javascript" src="plots.js"></script> |
| 39 |
|
| 40 |
</head> |
| 41 |
|
| 42 |
<body> |
| 43 |
|
| 44 |
|
| 45 |
<xml xmlns="https://developers.google.com/blockly/xml" id="samplexml" style="display:none;"> |
| 46 |
<block type="controls_repeat_ext" id="CaRiJ`PO7(C~_]{a,s,=" x="97" y="102"> |
| 47 |
<value name="TIMES"> |
| 48 |
<shadow type="math_number" id="s6Pd)]!)5ZCMLqGt8P2l"> |
| 49 |
<field name="NUM">200</field> |
| 50 |
</shadow> |
| 51 |
</value> |
| 52 |
<statement name="DO"> |
| 53 |
<block type="cs_print" id="NeP8KYH9a%tg;qUz;b9s"> |
| 54 |
<value name="TEXT"> |
| 55 |
<shadow type="text" id="o3Y`p9^!)%+Q8;!)Hs/j"> |
| 56 |
<field name="TEXT">hello</field> |
| 57 |
</shadow> |
| 58 |
<block type="get_voltage" id="#DtrcKI*rtD9?WHDu)5_"> |
| 59 |
<field name="CHANNEL">A1</field> |
| 60 |
</block> |
| 61 |
</value> |
| 62 |
</block> |
| 63 |
</statement> |
| 64 |
</block> |
| 65 |
</xml> |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
<xml xmlns="https://developers.google.com/blockly/xml" id="mytoolbox" style="display: none"> |
| 70 |
<category name="Minimize" colour="#f55" onClick="alert('asd');"> |
| 71 |
</category> |
| 72 |
<sep></sep> |
| 73 |
|
| 74 |
|
| 75 |
<category name="Variables" colour="#a55b80" custom="VARIABLE"> |
| 76 |
</category> |
| 77 |
<category name="Values" colour="#a55b80"> |
| 78 |
<block type="math_number"> |
| 79 |
<field name="NUM">0</field> |
| 80 |
</block> |
| 81 |
<block type="math_number"> |
| 82 |
<field name="NUM">1000</field> |
| 83 |
</block> |
| 84 |
<block type="text"> |
| 85 |
<field name="TEXT"></field> |
| 86 |
</block> |
| 87 |
<block type="logic_boolean"> |
| 88 |
<field name="BOOL">TRUE</field> |
| 89 |
</block> |
| 90 |
|
| 91 |
<block type="math_constant"> |
| 92 |
<field name="CONSTANT">PI</field> |
| 93 |
</block> |
| 94 |
|
| 95 |
</category> |
| 96 |
|
| 97 |
<category name="Operators" colour="#5b80a5"> |
| 98 |
|
| 99 |
|
| 100 |
<block type="math_arithmetic"> |
| 101 |
<field name="OP">ADD</field> |
| 102 |
<value name="A"> |
| 103 |
<shadow type="math_number"> |
| 104 |
<field name="NUM">1</field> |
| 105 |
</shadow> |
| 106 |
</value> |
| 107 |
<value name="B"> |
| 108 |
<shadow type="math_number"> |
| 109 |
<field name="NUM">1</field> |
| 110 |
</shadow> |
| 111 |
</value> |
| 112 |
</block> |
| 113 |
|
| 114 |
|
| 115 |
<block type="logic_compare"> |
| 116 |
<field name="OP">EQ</field> |
| 117 |
</block> |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
<block type="logic_operation"> |
| 122 |
<field name="OP">AND</field> |
| 123 |
</block> |
| 124 |
|
| 125 |
<block type="logic_negate"></block> |
| 126 |
<sep></sep> |
| 127 |
<block type="logic_boolean"> |
| 128 |
<field name="BOOL">TRUE</field> |
| 129 |
</block> |
| 130 |
|
| 131 |
|
| 132 |
</category> |
| 133 |
|
| 134 |
<category name="Logic" colour="#5b80a5"> |
| 135 |
|
| 136 |
<block type="controls_if"></block> |
| 137 |
|
| 138 |
<block type="logic_ternary"></block> |
| 139 |
|
| 140 |
</category> |
| 141 |
|
| 142 |
|
| 143 |
<category name="In / Out" colour="#5ba58c"> |
| 144 |
|
| 145 |
<block type="cs_print"> |
| 146 |
<value name="TEXT"> |
| 147 |
<shadow type="text"> |
| 148 |
<field name="TEXT">hello</field> |
| 149 |
</shadow> |
| 150 |
</value> |
| 151 |
</block> |
| 152 |
|
| 153 |
<block type="cs_sticker"> |
| 154 |
<value name="LABEL"> |
| 155 |
<shadow type="text"> |
| 156 |
<field name="TEXT">Parameter</field> |
| 157 |
</shadow> |
| 158 |
</value> |
| 159 |
<value name="TEXT"> |
| 160 |
<shadow type="text"> |
| 161 |
<field name="TEXT">Reading</field> |
| 162 |
</shadow> |
| 163 |
</value> |
| 164 |
</block> |
| 165 |
|
| 166 |
<block type="text_prompt_ext"> |
| 167 |
<mutation type="TEXT"></mutation> |
| 168 |
<field name="TYPE">TEXT</field> |
| 169 |
<value name="TEXT"> |
| 170 |
<shadow type="text"> |
| 171 |
<field name="TEXT">Enter Input</field> |
| 172 |
</shadow> |
| 173 |
</value> |
| 174 |
</block> |
| 175 |
|
| 176 |
<block type="text_join"> |
| 177 |
<mutation items="2"></mutation> |
| 178 |
</block> |
| 179 |
|
| 180 |
|
| 181 |
<block type="text_append"> |
| 182 |
<field name="VAR" id="NA?/#Ojn#=$$1[^`/^Dd">item</field> |
| 183 |
<value name="TEXT"> |
| 184 |
<shadow type="text"> |
| 185 |
<field name="TEXT"></field> |
| 186 |
</shadow> |
| 187 |
</value> |
| 188 |
</block> |
| 189 |
|
| 190 |
<block type="write_to_file"> |
| 191 |
</block> |
| 192 |
|
| 193 |
<block type="save_lists"> |
| 194 |
</block> |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
</category> |
| 199 |
|
| 200 |
<category name="Loops" colour="#5ba55b"> |
| 201 |
<block type="wait_seconds"> |
| 202 |
<field name="SECONDS">1</field> |
| 203 |
</block> |
| 204 |
<block type="controls_repeat_ext"> |
| 205 |
<value name="TIMES"> |
| 206 |
<shadow type="math_number"> |
| 207 |
<field name="NUM">10</field> |
| 208 |
</shadow> |
| 209 |
</value> |
| 210 |
</block> |
| 211 |
<block type="controls_whileUntil"> |
| 212 |
<field name="MODE">WHILE</field> |
| 213 |
</block> |
| 214 |
<block type="controls_for"> |
| 215 |
<field name="VAR" id="LbE2%mV/CRs,w^fwYIZy">i</field> |
| 216 |
<value name="FROM"> |
| 217 |
<shadow type="math_number"> |
| 218 |
<field name="NUM">1</field> |
| 219 |
</shadow> |
| 220 |
</value> |
| 221 |
<value name="TO"> |
| 222 |
<shadow type="math_number"> |
| 223 |
<field name="NUM">10</field> |
| 224 |
</shadow> |
| 225 |
</value> |
| 226 |
<value name="BY"> |
| 227 |
<shadow type="math_number"> |
| 228 |
<field name="NUM">1</field> |
| 229 |
</shadow> |
| 230 |
</value> |
| 231 |
</block> |
| 232 |
<block type="controls_forEach"> |
| 233 |
<field name="VAR" id="}KE@V7,)cpEQ-Df=Q3r(">j</field> |
| 234 |
</block> |
| 235 |
<block type="controls_flow_statements"> |
| 236 |
<field name="FLOW">BREAK</field> |
| 237 |
</block> |
| 238 |
</category> |
| 239 |
<sep></sep> |
| 240 |
|
| 241 |
|
| 242 |
<category name="Math" colour="#5b67a5"> |
| 243 |
<block type="math_number"> |
| 244 |
<field name="NUM">0</field> |
| 245 |
</block> |
| 246 |
|
| 247 |
<block type="math_arithmetic"> |
| 248 |
<field name="OP">ADD</field> |
| 249 |
<value name="A"> |
| 250 |
<shadow type="math_number"> |
| 251 |
<field name="NUM">1</field> |
| 252 |
</shadow> |
| 253 |
</value> |
| 254 |
<value name="B"> |
| 255 |
<shadow type="math_number"> |
| 256 |
<field name="NUM">1</field> |
| 257 |
</shadow> |
| 258 |
</value> |
| 259 |
</block> |
| 260 |
|
| 261 |
<block type="math_single"> |
| 262 |
<field name="OP">ROOT</field> |
| 263 |
<value name="NUM"> |
| 264 |
<shadow type="math_number"> |
| 265 |
<field name="NUM">9</field> |
| 266 |
</shadow> |
| 267 |
</value> |
| 268 |
</block> |
| 269 |
<block type="math_trig"> |
| 270 |
<field name="OP">SIN</field> |
| 271 |
<value name="NUM"> |
| 272 |
<shadow type="math_number"> |
| 273 |
<field name="NUM">45</field> |
| 274 |
</shadow> |
| 275 |
</value> |
| 276 |
</block> |
| 277 |
|
| 278 |
|
| 279 |
<block type="math_number_property"> |
| 280 |
<mutation divisor_input="false"></mutation> |
| 281 |
<field name="PROPERTY">EVEN</field> |
| 282 |
<value name="NUMBER_TO_CHECK"> |
| 283 |
<shadow type="math_number"> |
| 284 |
<field name="NUM">0</field> |
| 285 |
</shadow> |
| 286 |
</value> |
| 287 |
</block> |
| 288 |
<block type="math_round"> |
| 289 |
<field name="OP">ROUND</field> |
| 290 |
<value name="NUM"> |
| 291 |
<shadow type="math_number"> |
| 292 |
<field name="NUM">3.1</field> |
| 293 |
</shadow> |
| 294 |
</value> |
| 295 |
</block> |
| 296 |
<block type="math_on_list"> |
| 297 |
<mutation op="SUM"></mutation> |
| 298 |
<field name="OP">SUM</field> |
| 299 |
</block> |
| 300 |
<block type="math_modulo"> |
| 301 |
<value name="DIVIDEND"> |
| 302 |
<shadow type="math_number"> |
| 303 |
<field name="NUM">64</field> |
| 304 |
</shadow> |
| 305 |
</value> |
| 306 |
<value name="DIVISOR"> |
| 307 |
<shadow type="math_number"> |
| 308 |
<field name="NUM">10</field> |
| 309 |
</shadow> |
| 310 |
</value> |
| 311 |
</block> |
| 312 |
<block type="math_random_int"> |
| 313 |
<value name="FROM"> |
| 314 |
<shadow type="math_number"> |
| 315 |
<field name="NUM">1</field> |
| 316 |
</shadow> |
| 317 |
</value> |
| 318 |
<value name="TO"> |
| 319 |
<shadow type="math_number"> |
| 320 |
<field name="NUM">100</field> |
| 321 |
</shadow> |
| 322 |
</value> |
| 323 |
</block> |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
</category> |
| 328 |
<category name="Lists" colour="#745ba5"> |
| 329 |
<block type="lists_new"> |
| 330 |
</block> |
| 331 |
<block type="lists_split"> |
| 332 |
<mutation mode="SPLIT"></mutation> |
| 333 |
<field name="MODE">SPLIT</field> |
| 334 |
<value name="DELIM"> |
| 335 |
<shadow type="text"> |
| 336 |
<field name="TEXT">,</field> |
| 337 |
</shadow> |
| 338 |
</value> |
| 339 |
</block> |
| 340 |
|
| 341 |
|
| 342 |
<block type="lists_push"> |
| 343 |
</block> |
| 344 |
<block type="lists_push_time"> |
| 345 |
</block> |
| 346 |
|
| 347 |
<block type="lists_subtract"> |
| 348 |
</block> |
| 349 |
<block type="lists_subtract_return"> |
| 350 |
</block> |
| 351 |
|
| 352 |
<block type="lists_getIndex"> |
| 353 |
<mutation statement="false" at="true"></mutation> |
| 354 |
<field name="MODE">GET</field> |
| 355 |
<field name="WHERE">FROM_START</field> |
| 356 |
<value name="VALUE"> |
| 357 |
<block type="variables_get"> |
| 358 |
<field name="VAR" id="ZHzR_1b9[t1=F!y{a.VT">list</field> |
| 359 |
</block> |
| 360 |
</value> |
| 361 |
</block> |
| 362 |
<block type="lists_setIndex"> |
| 363 |
<mutation at="true"></mutation> |
| 364 |
<field name="MODE">SET</field> |
| 365 |
<field name="WHERE">FROM_START</field> |
| 366 |
<value name="LIST"> |
| 367 |
<block type="variables_get"> |
| 368 |
<field name="VAR" id="ZHzR_1b9[t1=F!y{a.VT">list</field> |
| 369 |
</block> |
| 370 |
</value> |
| 371 |
</block> |
| 372 |
<block type="lists_length"></block> |
| 373 |
<block type="lists_isEmpty"></block> |
| 374 |
<block type="lists_create_with"> |
| 375 |
<mutation items="0"></mutation> |
| 376 |
</block> |
| 377 |
<block type="lists_sort"> |
| 378 |
<field name="TYPE">NUMERIC</field> |
| 379 |
<field name="DIRECTION">1</field> |
| 380 |
</block> |
| 381 |
</category> |
| 382 |
<category name="PLOTS" colour="#995b95"> |
| 383 |
|
| 384 |
<block type="plot_scale"> |
| 385 |
</block> |
| 386 |
|
| 387 |
|
| 388 |
<block type="plot_datapoint"> |
| 389 |
</block> |
| 390 |
<block type="plot_xy"> |
| 391 |
</block> |
| 392 |
|
| 393 |
<block type="plot_xyarray"> |
| 394 |
</block> |
| 395 |
|
| 396 |
<block type="plot_xyyarray"> |
| 397 |
</block> |
| 398 |
|
| 399 |
<block type="plot_xyyyarray"> |
| 400 |
</block> |
| 401 |
|
| 402 |
<block type="plot_radar"> |
| 403 |
<value name="MAXRADIUS"> |
| 404 |
<shadow type="math_number"> |
| 405 |
<field name="NUM">30</field> |
| 406 |
</shadow> |
| 407 |
</value> |
| 408 |
</block> |
| 409 |
|
| 410 |
</category> |
| 411 |
<category name="Functions" colour="#995ba5" custom="PROCEDURE"></category> |
| 412 |
|
| 413 |
<sep></sep> |
| 414 |
|
| 415 |
|
| 416 |
<category name="ExpEYES" colour="#a55b80"> |
| 417 |
|
| 418 |
<block type="get_voltage"> |
| 419 |
<field name="CHANNEL">A1</field> |
| 420 |
</block> |
| 421 |
|
| 422 |
<block type="set_voltage"> |
| 423 |
<field name="CHANNEL">PV1</field> |
| 424 |
</block> |
| 425 |
|
| 426 |
<block type="set_sine_amp"> |
| 427 |
</block> |
| 428 |
|
| 429 |
<block type="set_frequency"> |
| 430 |
<field name="CHANNEL">WG</field> |
| 431 |
</block> |
| 432 |
<block type="get_freq"> |
| 433 |
<field name="CHANNEL">IN2</field> |
| 434 |
</block> |
| 435 |
<block type="get_resistance"> |
| 436 |
</block> |
| 437 |
<block type="get_capacitance"> |
| 438 |
</block> |
| 439 |
|
| 440 |
<block type="multi_r2r"> |
| 441 |
<field name="CHANNEL">IN2</field> |
| 442 |
<field name="EDGES">2</field> |
| 443 |
<field name="TIMEOUT">2</field> |
| 444 |
</block> |
| 445 |
|
| 446 |
<block type="set_state"> |
| 447 |
<field name="CHANNEL">OD1</field> |
| 448 |
</block> |
| 449 |
|
| 450 |
<block type="set_servo"> |
| 451 |
<field name="CHANNEL">SQ1</field> |
| 452 |
</block> |
| 453 |
|
| 454 |
<category name="Captures" colour="#5ba55b"> |
| 455 |
<block type="select_range"> |
| 456 |
</block> |
| 457 |
|
| 458 |
|
| 459 |
<block type="scope_trigger"> |
| 460 |
</block> |
| 461 |
<block type="capture1"> |
| 462 |
<field name="CHANNEL">A1</field> |
| 463 |
<field name="SAMPLES">100</field> |
| 464 |
<field name="TIMEGAP">1</field> |
| 465 |
</block> |
| 466 |
|
| 467 |
<block type="capture2"> |
| 468 |
<field name="CHANNEL">A1</field> |
| 469 |
<field name="SAMPLES">100</field> |
| 470 |
<field name="TIMEGAP">2</field> |
| 471 |
</block> |
| 472 |
|
| 473 |
<block type="capture4"> |
| 474 |
<field name="CHANNEL">A1</field> |
| 475 |
<field name="SAMPLES">200</field> |
| 476 |
<field name="TIMEGAP">5</field> |
| 477 |
</block> |
| 478 |
|
| 479 |
<block type="capture_plot"> |
| 480 |
<field name="CHANNEL">A1</field> |
| 481 |
</block> |
| 482 |
|
| 483 |
<block type="capture_action_plot"> |
| 484 |
<field name="CHANNEL">A1</field> |
| 485 |
<field name="SAMPLES">500</field> |
| 486 |
<field name="TIMEGAP">5</field> |
| 487 |
</block> |
| 488 |
|
| 489 |
</category> |
| 490 |
<category name="Analysis" colour="#5b67a5"> |
| 491 |
<block type="sine_fit_arrays"> |
| 492 |
</block> |
| 493 |
|
| 494 |
<block type="sine_fit_two_arrays"> |
| 495 |
</block> |
| 496 |
|
| 497 |
<block type="fourier_transform"> |
| 498 |
</block> |
| 499 |
</category> |
| 500 |
|
| 501 |
<category name="Sensors" colour="#5b67a5"> |
| 502 |
<block type="read_SR04"> |
| 503 |
</block> |
| 504 |
<block type="read_BMP280"> |
| 505 |
<field name="CHANNEL">1</field> |
| 506 |
</block> |
| 507 |
<block type="read_MPU6050"> |
| 508 |
<field name="CHANNEL">0</field> |
| 509 |
</block> |
| 510 |
<block type="read_VL53L0X"> |
| 511 |
<field name="CHANNEL">0</field> |
| 512 |
</block> |
| 513 |
<block type="read_HMC5883L"> |
| 514 |
<field name="CHANNEL">0</field> |
| 515 |
</block> |
| 516 |
<block type="read_MAX30100"> |
| 517 |
<field name="CHANNEL">0</field> |
| 518 |
</block> |
| 519 |
<block type="read_ML8511"> |
| 520 |
<field name="CHANNEL">0</field> |
| 521 |
</block> |
| 522 |
<block type="set_PCA9685"> |
| 523 |
<field name="CHANNEL">1</field> |
| 524 |
</block> |
| 525 |
|
| 526 |
|
| 527 |
</category> |
| 528 |
|
| 529 |
<category name="Sliders" colour="#5b67a5"> |
| 530 |
<block type="set_frequency_slider"> |
| 531 |
<field name="CHANNEL">WG</field> |
| 532 |
</block> |
| 533 |
<block type="set_voltage_slider"> |
| 534 |
<field name="CHANNEL">PV1</field> |
| 535 |
</block> |
| 536 |
|
| 537 |
|
| 538 |
</category> |
| 539 |
|
| 540 |
|
| 541 |
</category> |
| 542 |
|
| 543 |
<category name="Computer" colour="#5b67a5"> |
| 544 |
<block type="set_phone_frequency"> |
| 545 |
<value name="FREQUENCY"> |
| 546 |
<shadow type="math_number"> |
| 547 |
<field name="NUM">200</field> |
| 548 |
</shadow> |
| 549 |
</value> |
| 550 |
</block> |
| 551 |
|
| 552 |
<block type="set_phone_frequency_stereo"> |
| 553 |
<value name="FREQUENCY1"> |
| 554 |
<shadow type="math_number"> |
| 555 |
<field name="NUM">2800</field> |
| 556 |
</shadow> |
| 557 |
</value> |
| 558 |
<value name="FREQUENCY2"> |
| 559 |
<shadow type="math_number"> |
| 560 |
<field name="NUM">3000</field> |
| 561 |
</shadow> |
| 562 |
</value> |
| 563 |
</block> |
| 564 |
|
| 565 |
<block type="stop_phone_frequency"> |
| 566 |
</block> |
| 567 |
|
| 568 |
|
| 569 |
<block type="start_camera"> |
| 570 |
</block> |
| 571 |
|
| 572 |
<block type="get_frame"> |
| 573 |
</block> |
| 574 |
|
| 575 |
<block type="to_gray"> |
| 576 |
</block> |
| 577 |
<block type="subtract_bg"> |
| 578 |
</block> |
| 579 |
<block type="cv_subtract"> |
| 580 |
</block> |
| 581 |
|
| 582 |
<block type="choose_blob_shade"> |
| 583 |
</block> |
| 584 |
|
| 585 |
<block type="get_blobs"> |
| 586 |
<field name="NAME">src</field> |
| 587 |
</block> |
| 588 |
|
| 589 |
<block type="get_biggest_circle"> |
| 590 |
<field name="NAME">src</field> |
| 591 |
</block> |
| 592 |
<block type="get_lines"> |
| 593 |
<field name="NAME">src</field> |
| 594 |
</block> |
| 595 |
|
| 596 |
|
| 597 |
</category> |
| 598 |
|
| 599 |
|
| 600 |
<category name="Games" colour="#995b95"> |
| 601 |
|
| 602 |
|
| 603 |
<block type="add_game"> |
| 604 |
</block> |
| 605 |
<block type="stop_game"> |
| 606 |
</block> |
| 607 |
|
| 608 |
<block type="set_bird_y"> |
| 609 |
<value name="Y"> |
| 610 |
<shadow type="math_number"> |
| 611 |
<field name="NUM">200</field> |
| 612 |
</shadow> |
| 613 |
</value> |
| 614 |
|
| 615 |
</block> |
| 616 |
|
| 617 |
|
| 618 |
<block type="add_piano"> |
| 619 |
</block> |
| 620 |
|
| 621 |
<block type="play_piano"> |
| 622 |
<value name="NOTE"> |
| 623 |
<shadow type="text"> |
| 624 |
<field name="TEXT">C</field> |
| 625 |
</shadow> |
| 626 |
</value> |
| 627 |
|
| 628 |
</block> |
| 629 |
</category> |
| 630 |
|
| 631 |
|
| 632 |
</xml> |
| 633 |
|
| 634 |
<div class="ui icon error mini hidden message missingdevice" style="padding: 3px !important;margin:0px;"> |
| 635 |
<div class="content"> |
| 636 |
<p>Missing Hardware! Is a device Connected?</p> |
| 637 |
</div> |
| 638 |
</div> |
| 639 |
|
| 640 |
|
| 641 |
<div class="ui content mygrid" style="padding:0.2rem ! important;"> |
| 642 |
<div class="ui two column top aligned grid expand"> |
| 643 |
<div class= "ui row"> |
| 644 |
|
| 645 |
<div class="column ten wide expand"> |
| 646 |
<div id="toolbar" class="ui secondary menu mini "> |
| 647 |
<div class="item"> |
| 648 |
<a onclick="toggleRun()" class="ui mini primary button runbutton"><i class="play icon"></i><span class="text">Run!</span></a> |
| 649 |
</div> |
| 650 |
|
| 651 |
|
| 652 |
<div class="right menu"> |
| 653 |
|
| 654 |
<div class="ui right aligned item"> |
| 655 |
<a onclick="saveXML()" class="ui mini red button" ><i class="download icon"></i></a> |
| 656 |
</div> |
| 657 |
<div class="ui right aligned item"> |
| 658 |
<a onclick="getCachedXML()" class="ui mini teal button" ><i class="upload icon"></i></a> |
| 659 |
</div> |
| 660 |
|
| 661 |
<div class="ui right aligned item"> |
| 662 |
<a onclick="showHelp()" class="ui mini green button" ><i class="question icon"></i>Help </a> |
| 663 |
</div> |
| 664 |
|
| 665 |
<div class="item"> |
| 666 |
<div class="ui toggle checkbox bcast"> |
| 667 |
<label><i class="wifi icon"></i></label> |
| 668 |
<input type="checkbox" name="public"> |
| 669 |
</div> |
| 670 |
</div> |
| 671 |
|
| 672 |
|
| 673 |
</div> |
| 674 |
</div> |
| 675 |
|
| 676 |
|
| 677 |
<div id="blocklyArea"> |
| 678 |
<div id="blocklyDiv"> |
| 679 |
</div> |
| 680 |
</div> |
| 681 |
</div> |
| 682 |
|
| 683 |
<div class="column six wide scrolling content"> |
| 684 |
|
| 685 |
<div class="ui centered header"> |
| 686 |
Output |
| 687 |
</div> |
| 688 |
|
| 689 |
<div id="resplot" class="ui description resplot"> |
| 690 |
</div> |
| 691 |
|
| 692 |
|
| 693 |
<div class="ui celled list registers" style="color:#a33;"> |
| 694 |
</div> |
| 695 |
<div class="ui description cmdarea" style="color:darkgreen;"> |
| 696 |
</div> |
| 697 |
|
| 698 |
<div class="ui description cvarea" style="color:black;"> |
| 699 |
</div> |
| 700 |
<div class="ui scrolling content description printarea" style="color:black;scrollable:true;max-height:600px;"> |
| 701 |
</div> |
| 702 |
|
| 703 |
</div> |
| 704 |
</div> |
| 705 |
</div> |
| 706 |
|
| 707 |
</div> |
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
<div class="ui fullscreen modal help" style="height:100%;"> |
| 712 |
<i class="close icon"></i> |
| 713 |
<div class="column" style="height:95%;padding:10px;"> |
| 714 |
<div class="ui top attached tabular menu"> |
| 715 |
<a class="active item" data-tab="summary">Instructions</a> |
| 716 |
<a class="item" data-tab="edit"><i class="icon edit sign"></i></a> |
| 717 |
</div> |
| 718 |
|
| 719 |
<div class="ui tab active" data-tab="summary" style="height:99%;"> |
| 720 |
<div class="ui content" style="overflow-y:auto;height:100%;word-wrap:break-word;"> |
| 721 |
Instructions |
| 722 |
</div> |
| 723 |
</div> |
| 724 |
|
| 725 |
<div class="ui tab" data-tab="edit" style="height:99%;"> |
| 726 |
<textarea class = "edittext" style="height:100%;"></textarea> |
| 727 |
</div> |
| 728 |
</div> |
| 729 |
</div> |
| 730 |
|
| 731 |
|
| 732 |
<script type="text/javascript"> |
| 733 |
|
| 734 |
|
| 735 |
$('.ui.dropdown').dropdown(); |
| 736 |
$('.top.menu .item').tab({onVisible: function(a){switchHelp(a);}}) |
| 737 |
|
| 738 |
var workspaceHelp = ''; |
| 739 |
var workspaceMD = ''; |
| 740 |
var converter = new Markdown.Converter(); |
| 741 |
var results = $('.description.printarea'); |
| 742 |
var cvresults = $('.description.cvarea'); |
| 743 |
var resultModal = $('.modal.results'); |
| 744 |
var resplotarea = $('.resplotarea'); |
| 745 |
var resultplots = $('.description.resplot'); |
| 746 |
var mygrid = $('.content.mygrid'); |
| 747 |
|
| 748 |
var isRunning = false; |
| 749 |
|
| 750 |
var registers = $('.list.registers'); |
| 751 |
var regvals = []; |
| 752 |
var command = $('.description.cmdarea'); |
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
var JSBridge; |
| 760 |
var HWBridge; |
| 761 |
var devState = false; |
| 762 |
//For Python QWebChannel, wrap everything inside QWebchannel class |
| 763 |
window.onload = function() |
| 764 |
{ |
| 765 |
new QWebChannel(qt.webChannelTransport, function(channel) { |
| 766 |
JSBridge = channel.objects.backend; |
| 767 |
HWBridge = channel.objects.hwbackend; |
| 768 |
|
| 769 |
|
| 770 |
if(typeof JSBridge != 'undefined'){ |
| 771 |
JSBridge.loadXMLFile("xml",function(lxml) { |
| 772 |
localxml = lxml[0]; |
| 773 |
if(localxml.length>2) //To prevent loading, JSBridge can return an empty string |
| 774 |
loadXML(localxml); |
| 775 |
} |
| 776 |
); |
| 777 |
|
| 778 |
HWBridge.get_device_status(function(stat){ |
| 779 |
devState = stat; |
| 780 |
if(!devState){$('.message.missingdevice').closest('.message').transition('fade in','1000mS').transition('glow');} |
| 781 |
}); |
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
}else{ |
| 786 |
alert('no hardware bridge'); |
| 787 |
} |
| 788 |
|
| 789 |
|
| 790 |
}); |
| 791 |
} |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
var socket; |
| 802 |
var isTeacher=false; |
| 803 |
var roomname='none'; |
| 804 |
function registerClassroom(){ |
| 805 |
socket = io.connect('http://192.168.1.4:8000/classroom'); |
| 806 |
|
| 807 |
socket.on('connect', function(msg){ |
| 808 |
console.log(msg); |
| 809 |
roomname = document.getElementById("roomname").value; |
| 810 |
teacherConnected('room: ' + roomname, true); |
| 811 |
socket.emit('join',{room:roomname},function(msg){ |
| 812 |
console.log(msg); |
| 813 |
if(msg.owner){ |
| 814 |
alert('Created a new room '+roomname); |
| 815 |
isTeacher = true; |
| 816 |
}else{ |
| 817 |
alert('Joined a room '+roomname); |
| 818 |
isTeacher = false; |
| 819 |
} |
| 820 |
|
| 821 |
}); |
| 822 |
}); |
| 823 |
|
| 824 |
socket.on('message', function(msg){ |
| 825 |
console.log(msg); |
| 826 |
teacherConnected(msg, true); |
| 827 |
}); |
| 828 |
|
| 829 |
socket.on('update blockly', function(msg){ |
| 830 |
if(isTeacher)return; |
| 831 |
var parsedxml = Blockly.Xml.textToDom(msg); |
| 832 |
Blockly.Xml.clearWorkspaceAndLoadFromXml(parsedxml,workspacePlayground); |
| 833 |
}); |
| 834 |
socket.on('run blockly', function(msg){ |
| 835 |
if(isTeacher)return; |
| 836 |
if(msg.state) |
| 837 |
startStep(); |
| 838 |
else |
| 839 |
off(); |
| 840 |
}); |
| 841 |
|
| 842 |
} |
| 843 |
|
| 844 |
|
| 845 |
function teacherDisconnected(){ |
| 846 |
$('.teacherstatus').transition('fade out','300mS'); |
| 847 |
} |
| 848 |
|
| 849 |
function teacherConnected(message,dc){ |
| 850 |
$('.teacherstatus > .teachermsg').text(message); |
| 851 |
if(dc)$('.teacherstatus > .button').show(); |
| 852 |
else $('.teacherstatus > .button').hide(); |
| 853 |
$('.teacherstatus').transition('fade in','1000mS').transition('glow'); |
| 854 |
} |
| 855 |
|
| 856 |
function disconnectTeacher(){ |
| 857 |
socket.disconnect(); |
| 858 |
teacherDisconnected(); |
| 859 |
} |
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
function showReg(reg, val){ |
| 865 |
regclass = 'reg_'+reg.replace(/ /g,"_").replace(/-/g,"_"); |
| 866 |
if(regvals.indexOf(regclass)!=-1){ // Register is already shown in the results segment. update it. |
| 867 |
registers.find('.'+regclass).text(reg+"="+val); |
| 868 |
}else{ |
| 869 |
registers.append(`<div class="item ${regclass}">${reg}=${val}</div>`) |
| 870 |
regvals.push(regclass); |
| 871 |
} |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
var workspacePlayground = Blockly.inject('blocklyDiv', { |
| 877 |
media: 'media/', |
| 878 |
toolbox: mytoolbox, |
| 879 |
toolboxPosition : 'start', |
| 880 |
horizontal: true, |
| 881 |
trashcan: true, |
| 882 |
|
| 883 |
zoom: { |
| 884 |
startScale: 0.8, |
| 885 |
wheel: true, |
| 886 |
controls: false |
| 887 |
}, |
| 888 |
move:{ |
| 889 |
scrollbars: { |
| 890 |
horizontal: true, |
| 891 |
vertical: true |
| 892 |
}, |
| 893 |
drag: true, |
| 894 |
wheel: true |
| 895 |
}, |
| 896 |
drag: true, |
| 897 |
css : true |
| 898 |
} |
| 899 |
); |
| 900 |
|
| 901 |
var blocklyArea = document.getElementById('blocklyArea'); |
| 902 |
var onresize = function(e) { |
| 903 |
// Compute the absolute coordinates and dimensions of blocklyArea. |
| 904 |
var element = blocklyArea; |
| 905 |
var x = 0; |
| 906 |
var y = 0; |
| 907 |
do { |
| 908 |
x += element.offsetLeft; |
| 909 |
y += element.offsetTop+20; |
| 910 |
element = element.offsetParent; |
| 911 |
} while (element); |
| 912 |
// Position blocklyDiv over blocklyArea. |
| 913 |
blocklyDiv.style.left = x + 'px'; |
| 914 |
blocklyDiv.style.top = y + 'px'; |
| 915 |
blocklyDiv.style.width = blocklyArea.offsetWidth + 'px'; |
| 916 |
blocklyDiv.style.height = blocklyArea.offsetHeight + 'px'; |
| 917 |
Blockly.svgResize(workspacePlayground); |
| 918 |
}; |
| 919 |
window.addEventListener('resize', onresize, false); |
| 920 |
onresize(); |
| 921 |
Blockly.svgResize(workspacePlayground); |
| 922 |
|
| 923 |
|
| 924 |
Blockly.Xml.clearWorkspaceAndLoadFromXml($('#samplexml')[0], workspacePlayground); |
| 925 |
|
| 926 |
var toolboxButton = $("<a>", {id: "foo", "class": "ui tiny basic button teal","text":"Toolbox", "style":"display: none; position: absolute; z-index: 100;"}); |
| 927 |
toolboxButton.click(function(){ workspacePlayground.toolbox_.setVisible(true); toolboxButton.hide(); }).prependTo('.injectionDiv'); |
| 928 |
toolboxButton.hide(); |
| 929 |
var closeToolbox = function(){ |
| 930 |
workspacePlayground.toolbox_.setVisible(false); |
| 931 |
toolboxButton.show(); |
| 932 |
} |
| 933 |
workspacePlayground.scrollbar.vScroll.svgGroup_.style.display = 'none'; |
| 934 |
workspacePlayground.toolbox_.getToolboxItems()[0].getClickTarget().onclick = closeToolbox; |
| 935 |
|
| 936 |
function on() { |
| 937 |
isRunning = true; |
| 938 |
$('.runbutton').removeClass('primary').addClass('red'); |
| 939 |
$('.runbutton > .text').text('Stop'); |
| 940 |
$('.runbutton > .icon').removeClass('play').addClass('stop'); |
| 941 |
|
| 942 |
registers.empty(); |
| 943 |
regvals = []; |
| 944 |
results.html("");cvresults.html(""); |
| 945 |
} |
| 946 |
|
| 947 |
|
| 948 |
function playButtonOff(){ |
| 949 |
isRunning = false; |
| 950 |
$('.runbutton').removeClass('red').addClass('primary'); |
| 951 |
$('.runbutton > .text').text('Run!'); |
| 952 |
$('.runbutton > .icon').removeClass('stop').addClass('play'); |
| 953 |
} |
| 954 |
function off() { |
| 955 |
if(socket != null && isTeacher)socket.emit('run blockly', {state:false, room:roomname}); |
| 956 |
if(typeof JSBridge != 'undefined') |
| 957 |
if($('.checkbox.bcast').checkbox('is checked')) |
| 958 |
JSBridge.offBroadcast(); |
| 959 |
|
| 960 |
|
| 961 |
playButtonOff(); |
| 962 |
|
| 963 |
resetStepUi(); |
| 964 |
resetInterpreter(); |
| 965 |
if(typeof JSBridge != 'undefined') |
| 966 |
JSBridge.closeFiles(); |
| 967 |
stopGame(); |
| 968 |
stopCV(); |
| 969 |
} |
| 970 |
|
| 971 |
function resetInterpreter() { |
| 972 |
myInterpreter = null; |
| 973 |
if (runner) { |
| 974 |
clearTimeout(runner); |
| 975 |
runner = null; |
| 976 |
} |
| 977 |
} |
| 978 |
|
| 979 |
function showJSCode() { |
| 980 |
// Generate JavaScript code and display it. |
| 981 |
Blockly.JavaScript.INFINITE_LOOP_TRAP = null; |
| 982 |
var code = Blockly.JavaScript.workspaceToCode(workspacePlayground); |
| 983 |
} |
| 984 |
var myInterpreter; |
| 985 |
|
| 986 |
var runner; |
| 987 |
var highlightPause = false; |
| 988 |
var latestCode = ''; |
| 989 |
|
| 990 |
var autoScalingX = true; |
| 991 |
var autoScalingY = true; |
| 992 |
|
| 993 |
|
| 994 |
function highlightBlock(id) { |
| 995 |
workspacePlayground.highlightBlock(id); |
| 996 |
highlightPause = true; |
| 997 |
} |
| 998 |
|
| 999 |
function resetStepUi() { |
| 1000 |
workspacePlayground.highlightBlock(null); |
| 1001 |
highlightPause = false; |
| 1002 |
|
| 1003 |
} |
| 1004 |
|
| 1005 |
function deviceConnected(){ |
| 1006 |
$('.message.missingdevice').closest('.message').transition('fade out','300mS'); |
| 1007 |
} |
| 1008 |
function deviceDisconnected(){ |
| 1009 |
$('.message.missingdevice').closest('.message').transition('fade in','1000mS').transition('glow'); |
| 1010 |
} |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
function chatDisconnected(){ |
| 1015 |
$('.chatstatus').transition('fade out','300mS'); |
| 1016 |
} |
| 1017 |
function chatConnected(message,connect){ |
| 1018 |
$('.chatstatus > .chatmsg').text(message); |
| 1019 |
if(connect)$('.chatstatus > .button').show(); |
| 1020 |
else $('.chatstatus > .button').hide(); |
| 1021 |
$('.chatstatus').transition('fade in','1000mS').transition('glow'); |
| 1022 |
} |
| 1023 |
|
| 1024 |
|
| 1025 |
function toggleRun(){ |
| 1026 |
if(isRunning){ |
| 1027 |
off(); |
| 1028 |
}else{ |
| 1029 |
startStep(); |
| 1030 |
} |
| 1031 |
|
| 1032 |
|
| 1033 |
} |
| 1034 |
|
| 1035 |
function startStep() { |
| 1036 |
if(socket != null && isTeacher)socket.emit('run blockly', {state:true, room:roomname}); |
| 1037 |
if(typeof JSBridge != 'undefined') |
| 1038 |
if($('.checkbox.bcast').checkbox('is checked')) |
| 1039 |
JSBridge.startStepBroadcast(); |
| 1040 |
|
| 1041 |
|
| 1042 |
// Generate JavaScript code and parse it. |
| 1043 |
Blockly.JavaScript.STATEMENT_PREFIX = 'highlightBlock(%1);\n'; |
| 1044 |
Blockly.JavaScript.addReservedWords('highlightBlock'); |
| 1045 |
latestCode = Blockly.JavaScript.workspaceToCode(workspacePlayground); |
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
resetStepUi(); |
| 1050 |
on(); |
| 1051 |
clearPlot(); |
| 1052 |
resplotarea.show(); |
| 1053 |
|
| 1054 |
|
| 1055 |
if(latestCode.indexOf('plot_xy(')>=0) |
| 1056 |
addPlot('xy', autoScalingX, autoScalingY); // indicate XY |
| 1057 |
else if(latestCode.indexOf('plot_radar(')>=0) |
| 1058 |
addPolarPlot(); |
| 1059 |
else if(latestCode.indexOf('plot(')>=0) |
| 1060 |
addPlot('', autoScalingX, autoScalingY); |
| 1061 |
else if(latestCode.indexOf('plot_xyarray(')>=0) |
| 1062 |
addPlot('', autoScalingX, autoScalingY); |
| 1063 |
else if(latestCode.indexOf('plot_xyyarray(')>=0) |
| 1064 |
addPlot('xyy', autoScalingX, autoScalingY); |
| 1065 |
else if(latestCode.indexOf('plot_xyyyarray(')>=0) |
| 1066 |
addPlot('xyyy', autoScalingX, autoScalingY); |
| 1067 |
else |
| 1068 |
resplotarea.hide(); |
| 1069 |
|
| 1070 |
if(latestCode.indexOf("set_scale(\'x")>=0){ |
| 1071 |
autoScalingX = true; |
| 1072 |
} |
| 1073 |
if(latestCode.indexOf("set_scale(\'y")>=0){ |
| 1074 |
autoScalingY = true; |
| 1075 |
} |
| 1076 |
|
| 1077 |
runCode(); |
| 1078 |
} |
| 1079 |
|
| 1080 |
function initAllApis(interpreter, scope){ |
| 1081 |
initApi(interpreter, scope); |
| 1082 |
initLists(interpreter, scope); |
| 1083 |
initIO(interpreter, scope); |
| 1084 |
initPlots(interpreter, scope); |
| 1085 |
initGames(interpreter, scope); |
| 1086 |
initSEELab(interpreter, scope); |
| 1087 |
initSounds(interpreter, scope); |
| 1088 |
|
| 1089 |
initCV(interpreter, scope); //OPENCV |
| 1090 |
|
| 1091 |
} |
| 1092 |
|
| 1093 |
|
| 1094 |
function runCode() { |
| 1095 |
if (!myInterpreter) { |
| 1096 |
// First statement of this code. |
| 1097 |
// Clear the program output. |
| 1098 |
resetStepUi(); |
| 1099 |
|
| 1100 |
// And then show generated code in an alert. |
| 1101 |
// In a timeout to allow the outputArea.value to reset first. |
| 1102 |
setTimeout(function() { |
| 1103 |
// Begin execution |
| 1104 |
highlightPause = false; |
| 1105 |
myInterpreter = new Interpreter(latestCode, initAllApis); |
| 1106 |
if(latestCode.search("alert") != -1) // -1 means not found |
| 1107 |
on(); |
| 1108 |
|
| 1109 |
runner = function() { |
| 1110 |
if (myInterpreter) { |
| 1111 |
var hasMore = myInterpreter.run(); |
| 1112 |
if (hasMore) { |
| 1113 |
// Execution is currently blocked by some async call. |
| 1114 |
// Try again later. |
| 1115 |
setTimeout(runner, 10); |
| 1116 |
} else { |
| 1117 |
// Program is complete. |
| 1118 |
resetInterpreter(); |
| 1119 |
resetStepUi(); |
| 1120 |
playButtonOff(); |
| 1121 |
} |
| 1122 |
} |
| 1123 |
}; |
| 1124 |
runner(); |
| 1125 |
}, 1); |
| 1126 |
return; |
| 1127 |
} |
| 1128 |
} |
| 1129 |
|
| 1130 |
|
| 1131 |
function saveXML(){ |
| 1132 |
if(typeof JSBridge != 'undefined') |
| 1133 |
JSBridge.saveXML("expeyes",injectHelp()); |
| 1134 |
else |
| 1135 |
localStorage.setItem('expeyes', injectHelp()); |
| 1136 |
} |
| 1137 |
function saveXMLtoDisc(){ |
| 1138 |
//var xmlDom = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); |
| 1139 |
//var xmlText = Blockly.Xml.domToPrettyText(xmlDom); |
| 1140 |
JSBridge.saveXMLtoDisc("expeyes",injectHelp()); |
| 1141 |
} |
| 1142 |
function openFile(){ // Launch file open dialog |
| 1143 |
JSBridge.openFileDialog(); |
| 1144 |
} |
| 1145 |
|
| 1146 |
function getCachedXML(){ |
| 1147 |
if(typeof JSBridge != 'undefined') |
| 1148 |
JSBridge.loadLocalXML('expeyes',loadRawXml) |
| 1149 |
else |
| 1150 |
loadXML(localStorage.getItem('expeyes')); |
| 1151 |
} |
| 1152 |
|
| 1153 |
function loadXML(xml) { |
| 1154 |
// loadXML({{ include.id }} , (new XMLSerializer()).serializeToString(xml)); |
| 1155 |
//XML supplied as string by app. |
| 1156 |
|
| 1157 |
if (typeof xml != "string" || xml.length < 5) { |
| 1158 |
return false; |
| 1159 |
} |
| 1160 |
try { |
| 1161 |
var dom = Blockly.Xml.textToDom(xml); |
| 1162 |
Blockly.mainWorkspace.clear(); |
| 1163 |
Blockly.Xml.domToWorkspace(dom,Blockly.mainWorkspace); |
| 1164 |
|
| 1165 |
parser = new DOMParser(); |
| 1166 |
xmlDoc = parser.parseFromString(xml,"text/xml"); |
| 1167 |
loadhelp(xmlDoc); |
| 1168 |
return true; |
| 1169 |
} catch (e) { |
| 1170 |
console.log("XML Load Error",e); |
| 1171 |
console.log(xml) |
| 1172 |
return false; |
| 1173 |
} |
| 1174 |
} |
| 1175 |
function loadRawXml(msg){ |
| 1176 |
var parsedxml = Blockly.Xml.textToDom(msg); |
| 1177 |
loadhelp(parsedxml); |
| 1178 |
Blockly.Xml.clearWorkspaceAndLoadFromXml(parsedxml,workspacePlayground); |
| 1179 |
} |
| 1180 |
|
| 1181 |
function loadhelp(xml) { |
| 1182 |
try { |
| 1183 |
workspaceMD = $(xml).find('description').text(); |
| 1184 |
workspaceHelp = converter.makeHtml(workspaceMD); |
| 1185 |
return true; |
| 1186 |
} catch (e) { |
| 1187 |
console.log("Invalid xml",e); |
| 1188 |
return false; |
| 1189 |
} |
| 1190 |
} |
| 1191 |
function showHelp(){ |
| 1192 |
$('.fullscreen.modal.help .content').html(workspaceHelp); |
| 1193 |
$('.fullscreen.modal.help .edittext')[0].value = workspaceMD; |
| 1194 |
$('.fullscreen.modal.help') |
| 1195 |
.modal('show') |
| 1196 |
; |
| 1197 |
} |
| 1198 |
|
| 1199 |
function switchHelp(selected_tab){ |
| 1200 |
if(selected_tab === "summary"){ |
| 1201 |
workspaceMD = $('.fullscreen.modal.help .edittext')[0].value; |
| 1202 |
console.log(workspaceMD); |
| 1203 |
workspaceHelp = converter.makeHtml(workspaceMD); |
| 1204 |
$('.fullscreen.modal.help .content').html(workspaceHelp); |
| 1205 |
} |
| 1206 |
} |
| 1207 |
function injectHelp(){ |
| 1208 |
workspaceMD = $('.fullscreen.modal.help .edittext')[0].value; |
| 1209 |
var xmlDom = Blockly.Xml.workspaceToDom(workspacePlayground); |
| 1210 |
//node = document.createElement("description"); |
| 1211 |
//textnode = document.createTextNode("<![CDATA["+workspaceMD+"]]>"); // Are CDATA Tags required |
| 1212 |
//textnode = document.createTextNode(workspaceMD); |
| 1213 |
//node.appendChild(textnode); |
| 1214 |
//xmlDom.appendChild(node); |
| 1215 |
var text = Blockly.Xml.domToPrettyText(xmlDom); |
| 1216 |
if(workspaceMD.length) |
| 1217 |
return text.split('</xml')[0] + "<description><![CDATA[" + workspaceMD + "]]>" + "</description></xml>"; |
| 1218 |
else return text; |
| 1219 |
} |
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
function showCode() { |
| 1224 |
// Generate Python code and display it. |
| 1225 |
Blockly.Python.INFINITE_LOOP_TRAP = null; |
| 1226 |
Blockly.Python.init(workspacePlayground) |
| 1227 |
var code = Blockly.Python.workspaceToCode(workspacePlayground); |
| 1228 |
alert(code); |
| 1229 |
} |
| 1230 |
|
| 1231 |
|
| 1232 |
function myUpdateFunction(event) { |
| 1233 |
|
| 1234 |
//resetInterpreter(); |
| 1235 |
Blockly.Python.init(workspacePlayground) |
| 1236 |
Blockly.JavaScript.init(workspacePlayground) |
| 1237 |
|
| 1238 |
var xmlDom = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); |
| 1239 |
var xmlText = Blockly.Xml.domToPrettyText(xmlDom); |
| 1240 |
|
| 1241 |
if(typeof JSBridge != 'undefined'){ |
| 1242 |
JSBridge.updateCode(Blockly.Python.workspaceToCode(workspacePlayground)); |
| 1243 |
JSBridge.xmlCode(xmlText, $('.checkbox.bcast').checkbox('is checked')); |
| 1244 |
} |
| 1245 |
|
| 1246 |
} |
| 1247 |
|
| 1248 |
$('.checkbox.listen') |
| 1249 |
.checkbox({ |
| 1250 |
onChecked: function() { |
| 1251 |
$('.checkbox.bcast').checkbox('set unchecked') |
| 1252 |
if(typeof JSBridge != 'undefined') |
| 1253 |
JSBridge.listenBcast(true); |
| 1254 |
}, |
| 1255 |
onUnchecked: function() { |
| 1256 |
JSBridge.listenBcast(false); |
| 1257 |
} |
| 1258 |
}); |
| 1259 |
|
| 1260 |
$('.checkbox.bcast') |
| 1261 |
.checkbox({ |
| 1262 |
onChecked: function() { |
| 1263 |
$('.checkbox.listen').checkbox('set unchecked') |
| 1264 |
} |
| 1265 |
}); |
| 1266 |
|
| 1267 |
workspacePlayground.addChangeListener(myUpdateFunction); |
| 1268 |
|
| 1269 |
|
| 1270 |
if(typeof JSBridge != 'undefined'){ |
| 1271 |
var localxml = JSBridge.loadXMLFile("xml"); |
| 1272 |
if(localxml.length>2) //To prevent loading, JSBridge can return an empty string |
| 1273 |
loadXML(localxml); |
| 1274 |
} |
| 1275 |
|
| 1276 |
|
| 1277 |
function loadEditor(){ //Redirect to editor.html where the loadXMLFile will return contents of the current latestCode . courtesy JSBridge |
| 1278 |
Blockly.JavaScript.STATEMENT_PREFIX = null; |
| 1279 |
var xmlDom = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); |
| 1280 |
JSBridge.saveXML("eyescode",Blockly.JavaScript.workspaceToCode(workspacePlayground)); |
| 1281 |
JSBridge.saveXML("eyesxml",Blockly.Xml.domToPrettyText(xmlDom)); |
| 1282 |
|
| 1283 |
|
| 1284 |
window.location = "editor.html"; |
| 1285 |
} |
| 1286 |
|
| 1287 |
</script> |
| 1288 |
|
| 1289 |
</body> |
| 1290 |
|
| 1291 |
|
| 1292 |
</html> |