Skip to content
Snippets Groups Projects
Select Git revision
  • 6b3f3feaebda1f098765d568c51654537ca77129
  • master default
  • dja
  • dja_fix_animations
  • dja_various_fixes
  • dja_differentiate_same_user_connections
  • dja_fix_bugs
  • dja_guest
  • dja_guests
  • dja_sign_out_without_race_conditions
  • dja_subgroups
  • dua_subgroups
  • dja_groups_2
  • dja_groups
  • dja_heroku_11_7_2024
  • dja_share_files
  • dja_execute_files_aux_2
  • dja_execute_files_aux
  • dja_execute_files
  • dja_files_page
  • dja-create-main-button
  • v2.0
  • v1.0
23 results

ghci.service.ts

Blame
  • ghci.service.ts 13.89 KiB
    import { Injectable,ViewChild,ElementRef } from '@angular/core';
    import { Router } from '@angular/router';
    import { Observable, Subject } from 'rxjs/Rx';
    import { WebsocketService } from './websocket.service';
    import { AuthenticationService } from './authentication.service';
    import { GHCI_URL } from '../config';
    import { TranslateService } from '@ngx-translate/core';
    
    declare var $:any;
    declare var that :any ;
    const regex = /^color (errores|input|output|logs) (\d)$/g;
    
    import 'tippy.js/dist/tippy';
    
    @Injectable()
    export class GHCIService {
    	public messages: Subject<any> = new Subject<any>();
    	private connection = undefined;
    	private cons = undefined;
    	private modoAvanzado: boolean = false;     // indica si debe mostrarse todo lo que ocurre en el intérprete.
    	private clear:boolean = false;
    	private error :string ="";
    	private warnings: any = [];
    	private codemirrorRef :any = null;
    	private warningStepReaded :number = 0;
    	private waitingForError : boolean = false;
    	private waitingForWarning : boolean = false;
    	private waitingForWarning2 : boolean = false;
    	private warningText :string = "";
    	private lastError : number = -1;
    	private lastWarning :number = -1;
        translateService: any;
    
    	private console_error_class : string = "jqconsole-asd";
    
    	consoleBuffer = [];
    
    	constructor(private authService:AuthenticationService,private router: Router, public translate: TranslateService){
    		this.translateService = translate;
    		console.log("contructor ghci");
    		this.conectarWS(GHCI_URL, authService.getUser().cedula, authService.getToken(), authService.getLanguage());
    		setInterval( this.checkConnection.bind(this), 5000);	
    		setInterval( this.doPing.bind(this), 30000);	
    	}
    
    	setCodemirrorRef(instance){
    		this.codemirrorRef = instance;
    	}
    
    	clearWarnings(){
    		this.warnings = [];
    	}
    
    	getWarnings(){
    		return this.warnings;
    	}
    
    	loadFile(fileId, dependencias) {
    		this.waitingForWarning = true;
    		var message = {
    			'token': this.authService.getToken(),
    			'load': fileId,
    			'dependencias' :[]
    
    		};
    		for(var i in dependencias){
    			message.dependencias.push(dependencias[i]);
    		};
    		this.connection.send(JSON.stringify(message));
    	}