@@ -248,7 +248,7 @@ export default {
248
248
},
249
249
computed: {
250
250
statusText : function () {
251
- if (this .$data . status ) {
251
+ if (this .status ) {
252
252
return ' Coderbot risulta online e funzionante. '
253
253
} else {
254
254
return ' Coderbot risulta offline e rotto'
@@ -258,17 +258,17 @@ export default {
258
258
mounted () {
259
259
260
260
let axios = this .$axios
261
- this .$data . status = null
261
+ this .status = null
262
262
this .pollStatus ();
263
263
setInterval (function () {
264
264
this .pollStatus ();
265
265
}.bind (this ), 1000 )
266
266
267
267
268
- axios .get (this .$data . CBv1 + ' /config' )
268
+ axios .get (this .CBv1 + ' /config' )
269
269
.then (function (response ) {
270
270
var settings = response .data
271
- this .$data . settings = settings
271
+ this .settings = settings
272
272
this .initBlockly (settings)
273
273
}.bind (this ))
274
274
@@ -287,7 +287,7 @@ export default {
287
287
var serializedToolbox = this .$base64 .decode (b64Toolbox)
288
288
289
289
// Initialise Blockly Instance
290
- this .$data . workspace = Blockly .inject (
290
+ this .workspace = Blockly .inject (
291
291
// Blockly container
292
292
this .$refs .blocklyDiv ,
293
293
// Options
@@ -312,7 +312,7 @@ export default {
312
312
313
313
// Initial resize
314
314
this .resizeWorkspace ()
315
- Blockly .svgResize (this .$data . workspace );
315
+ Blockly .svgResize (this .workspace );
316
316
317
317
318
318
},
@@ -322,8 +322,8 @@ export default {
322
322
},
323
323
getProgramData () {
324
324
console .log (" get" )
325
- let name = this .$data . programName
326
- let workspace = this .$data . workspace
325
+ let name = this .programName
326
+ let workspace = this .workspace
327
327
let xml_code = Blockly .Xml .workspaceToDom (Blockly .mainWorkspace );
328
328
let dom_code = Blockly .Xml .domToText (xml_code);
329
329
@@ -339,7 +339,7 @@ export default {
339
339
const blob = new Blob ([data], { type: ' text/json' })
340
340
const e = document .createEvent (' MouseEvents' ),
341
341
a = document .createElement (' a' );
342
- a .download = this .$data . programName + ' .json' || ' noname.json'
342
+ a .download = this .programName + ' .json' || ' noname.json'
343
343
a .href = window .URL .createObjectURL (blob);
344
344
a .dataset .downloadurl = [' text/json' , a .download , a .href ].join (' :' );
345
345
e .initEvent (' click' , true , false , window , 0 , 0 , 0 , 0 , 0 , false , false , false , false , 0 , null );
@@ -352,7 +352,7 @@ export default {
352
352
importProgram (e ) {
353
353
// Once the file is selected, read it and populate the Blockly
354
354
// workspace with the contained program
355
- let workspace = this .$data . workspace
355
+ let workspace = this .workspace
356
356
const files = e .target .files
357
357
if (files[0 ] !== undefined ) {
358
358
let fileName = files[0 ].name
@@ -371,18 +371,18 @@ export default {
371
371
}
372
372
},
373
373
saveProgramAs : function (e ) {
374
- if (this .$data . newProgramName != ' ' ) {
375
- this .$data . programName = this . $data .newProgramName
376
- this .$data . newProgramName = ' '
374
+ if (this .newProgramName != ' ' ) {
375
+ this .programName = this .newProgramName
376
+ this .newProgramName = ' '
377
377
this .saveProgram ()
378
378
} else {
379
- this .$data . unvalidName = true
379
+ this .unvalidName = true
380
380
}
381
381
},
382
382
saveProgram () {
383
- if (this .$data . programName != ' ' ) {
383
+ if (this .programName != ' ' ) {
384
384
let axios = this .$axios
385
- let CB = this .$data . CB
385
+ let CB = this .CB
386
386
console .log (" save" )
387
387
let data = this .getProgramData ()
388
388
axios .post (CB + ' /save' , {
@@ -394,25 +394,25 @@ export default {
394
394
console .log (" salvato" )
395
395
})
396
396
} else {
397
- this .$data . unvalidName = true
397
+ this .unvalidName = true
398
398
}
399
399
},
400
400
loadProgramList () {
401
401
let axios = this .$axios
402
- let CBv1 = this .$data . CBv1
403
- // let programList = this.$data. programList
402
+ let CBv1 = this .CBv1
403
+ // let programList = this.programList
404
404
axios .get (CBv1 + ' /program/list' )
405
405
.then (function (response ) {
406
- this .$data . carica = true ,
407
- this .$data . programList = response .data ;
406
+ this .carica = true ,
407
+ this .programList = response .data ;
408
408
}.bind (this ))
409
409
},
410
410
loadProgram (program ) {
411
411
let axios = this .$axios
412
- let CBv1 = this .$data . CBv1
413
- let workspace = this .$data . workspace
414
- this .$data . carica = false ;
415
- this .$data . programName = program
412
+ let CBv1 = this .CBv1
413
+ let workspace = this .workspace
414
+ this .carica = false ;
415
+ this .programName = program
416
416
axios .get (CBv1 + ' /program/load' , {
417
417
params: {
418
418
name: program,
@@ -425,17 +425,17 @@ export default {
425
425
}.bind (this ))
426
426
},
427
427
deleteProgramDlg (program ) {
428
- this .$data . newProgramName = program
429
- this .$data . del = true
428
+ this .newProgramName = program
429
+ this .del = true
430
430
},
431
431
deleteProgram (program ) {
432
- if (this .$data . programName == program) {
433
- this .$data . programName = ' '
434
- this .$data . code = ' '
435
- this .$data . workspace .clear ()
432
+ if (this .programName == program) {
433
+ this .programName = ' '
434
+ this .code = ' '
435
+ this .workspace .clear ()
436
436
}
437
437
let axios = this .$axios
438
- let CB = this .$data . CB
438
+ let CB = this .CB
439
439
console .log (" delete" )
440
440
axios .post (CB + ' /delete' , {
441
441
name: program
@@ -446,28 +446,28 @@ export default {
446
446
},
447
447
pollStatus () {
448
448
let axios = this .$axios
449
- let CB = this .$data . CB
450
- let status = this .$data . status
449
+ let CB = this .CB
450
+ let status = this .status
451
451
axios .get (CB + ' /status' )
452
452
.then (function (response ) {
453
- if (this .$data . status == 0 && response .status ) {
454
- this .$data . snackText = ' CoderBot è tornato online'
455
- this .$data . snackbar = true
453
+ if (this .status == 0 && response .status ) {
454
+ this .snackText = ' CoderBot è tornato online'
455
+ this .snackbar = true
456
456
}
457
457
458
458
// console.log(response)
459
- this .$data . statusData = response .data
460
- this .$data . status = response .status
459
+ this .statusData = response .data
460
+ this .status = response .status
461
461
}.bind (this ))
462
462
.catch (function (error ) {
463
463
// handle error
464
464
console .log (error);
465
465
466
- if (this .$data . status ) {
467
- this .$data . snackText = ' CoderBot irrangiungibile'
468
- this .$data . snackbar = true
466
+ if (this .status ) {
467
+ this .snackText = ' CoderBot irrangiungibile'
468
+ this .snackbar = true
469
469
}
470
- this .$data . status = 0
470
+ this .status = 0
471
471
}.bind (this ))
472
472
},
473
473
resizeWorkspace () {
@@ -483,25 +483,25 @@ export default {
483
483
this .$refs .blocklyDiv .style .height = ` ${ offsetHeight} px` ;
484
484
},
485
485
getProgramCode () {
486
- if (this .$data . experimental ) {
487
- this .$data . experimental = false ;
488
- this .blocksExtensions (this .$data . settings );
489
- this .$data . experimental = true ;
486
+ if (this .experimental ) {
487
+ this .experimental = false ;
488
+ this .blocksExtensions (this .settings );
489
+ this .experimental = true ;
490
490
}
491
491
492
492
Blockly .Python .STATEMENT_PREFIX = null ;
493
493
Blockly .Python .addReservedWords ();
494
494
Blockly .Python .INFINITE_LOOP_TRAP = null ;
495
- this .$data . code = Blockly .Python .workspaceToCode (this . $data .workspace );
496
- console .log (this .$data . code )
497
- this .$data . dialogCode = true
495
+ this .code = Blockly .Python .workspaceToCode (this .workspace );
496
+ console .log (this .code )
497
+ this .dialogCode = true
498
498
499
- if (this .$data . experimental ) {
500
- this .blocksExtensions (this .$data . settings )
499
+ if (this .experimental ) {
500
+ this .blocksExtensions (this .settings )
501
501
}
502
502
},
503
503
runProgramExperimental () {
504
- if (this .$data . status ) {
504
+ if (this .status ) {
505
505
var xml_code = Blockly .Xml .workspaceToDom (Blockly .mainWorkspace );
506
506
var dom_code = Blockly .Xml .domToText (xml_code);
507
507
Blockly .Python .INFINITE_LOOP_TRAP = null ;
@@ -514,21 +514,21 @@ export default {
514
514
name: ' Hello, World' ,
515
515
dom_code,
516
516
code: code_modified,
517
- mode: this .$data . execMode
517
+ mode: this .execMode
518
518
})
519
519
520
520
}
521
521
},
522
522
runProgram () {
523
- if (this .$data . status ) {
523
+ if (this .status ) {
524
524
let axios = this .$axios
525
- let CB = this .$data . CB
525
+ let CB = this .CB
526
526
// POST /program/save
527
- var xml_code = Blockly .Xml .workspaceToDom (this .$data . workspace );
527
+ var xml_code = Blockly .Xml .workspaceToDom (this .workspace );
528
528
var dom_code = Blockly .Xml .domToText (xml_code);
529
529
window .LoopTrap = 1000 ;
530
530
Blockly .Python .INFINITE_LOOP_TRAP = ' get_prog_eng().check_end()\n ' ;
531
- var code = Blockly .Python .workspaceToCode (this .$data . workspace );
531
+ var code = Blockly .Python .workspaceToCode (this .workspace );
532
532
Blockly .Python .INFINITE_LOOP_TRAP = null ;
533
533
534
534
axios .post (CB + ' /exec' , {
@@ -540,23 +540,23 @@ export default {
540
540
console .log (response);
541
541
})
542
542
} else {
543
- this .$data . generalDialog = true ;
544
- this .$data . generalDialogTitle = ' Errore' ,
545
- this .$data . generalDialogText = ' Il coderbot risulta offline, non puoi eseguire il programma.'
543
+ this .generalDialog = true ;
544
+ this .generalDialogTitle = ' Errore' ,
545
+ this .generalDialogText = ' Il coderbot risulta offline, non puoi eseguire il programma.'
546
546
}
547
547
},
548
548
runProgramLegacy () {
549
- if (this .$data . status ) {
549
+ if (this .status ) {
550
550
let axios = this .$axios
551
- let CB = this .$data . CB
551
+ let CB = this .CB
552
552
let qs = this .$qs
553
553
554
554
// POST /program/save
555
- var xml_code = Blockly .Xml .workspaceToDom (this .$data . workspace );
555
+ var xml_code = Blockly .Xml .workspaceToDom (this .workspace );
556
556
var dom_code = Blockly .Xml .domToText (xml_code);
557
557
window .LoopTrap = 1000 ;
558
558
Blockly .Python .INFINITE_LOOP_TRAP = ' get_prog_eng().check_end()\n ' ;
559
- var code = Blockly .Python .workspaceToCode (this .$data . workspace );
559
+ var code = Blockly .Python .workspaceToCode (this .workspace );
560
560
Blockly .Python .INFINITE_LOOP_TRAP = null ;
561
561
562
562
var valuesAsString = qs .stringify ({
@@ -565,15 +565,15 @@ export default {
565
565
' code' : code,
566
566
})
567
567
568
- axios .post (this .$data . CBv1 + ' /program/exec' , valuesAsString)
568
+ axios .post (this .CBv1 + ' /program/exec' , valuesAsString)
569
569
.then (function (response ) {
570
570
console .log (response)
571
571
})
572
572
573
573
}
574
574
},
575
575
blocksExtensions (settings ) {
576
- var settings = this .$data . settings
576
+ var settings = this .settings
577
577
var cfg = Object ();
578
578
579
579
// coderbot.cfg data (temp workaround, must be fetched from backend)
@@ -634,7 +634,7 @@ export default {
634
634
635
635
var sbsPrefix
636
636
637
- if (this .$data . experimental ) {
637
+ if (this .experimental ) {
638
638
// Append "Command." to enable stepbystep
639
639
sbsPrefix = " Command."
640
640
} else {
0 commit comments