diff --git a/Frontend Angular 4/src/app/layout/functions/function.services.result.ts b/Frontend Angular 4/src/app/layout/functions/function.services.result.ts deleted file mode 100644 index eb4d8fb3715ff3b7e227c1f698007a48e4d90c13..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/function.services.result.ts +++ /dev/null @@ -1,4 +0,0 @@ -export class FunctionServicesResult { - code: number; - msg: string; -} \ No newline at end of file diff --git a/Frontend Angular 4/src/app/layout/functions/function.ts b/Frontend Angular 4/src/app/layout/functions/function.ts deleted file mode 100644 index 764863fd9a8465e33813b39a09df4bb2ae64e3b8..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/function.ts +++ /dev/null @@ -1,5 +0,0 @@ -export class Function { - id: number; - name: string; - str: string; -} \ No newline at end of file diff --git a/Frontend Angular 4/src/app/layout/functions/functions.component.html b/Frontend Angular 4/src/app/layout/functions/functions.component.html deleted file mode 100644 index c8a5596b905e00a961645ddbb7ce4852bafd02e4..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/functions.component.html +++ /dev/null @@ -1,50 +0,0 @@ - - - <div class="panel panel-success"> - - <div class="card"> - <h4 class="card-header">Mis funciones</h4> - <div class="card-block"> - <ul class="list-group list-group-flush"> - - <li *ngFor="let f of _funcs" class="list-group-item"> - <div class="card-block"> - <div class="checkbox"> - <label for="checkbox"> - {{f.str}} - </label> - </div> - <div class="pull-right action-buttons"> - <button (click)="modifyFunc(f.name)" class="btn btn-success"> - <i class="fa fa-pencil" ></i> - </button> - <button (click)="removeFunc(f.name)" class="btn btn-success"> - <i class="fa fa-remove" ></i> - </button> - </div> - </div> - </li> - - - - </ul> - </div> - </div> - - - - <div class="panel-footer"> - <div class="row"> - <div class="col-md-12"> - <div class="input-group input-group"> - <input [(ngModel)]="_newFunction.str" placeholder="nueva función" class="form-control" > - <span class="input-group-btn"> - <button class="btn btn-primary" [disabled]="this._newFunction.str==''" type="button" (click)="handleAddFunction()">Cargar función</button> - </span> - </div> - </div> - - </div> - <!-- <button (click)="popToast()">pop toast</button> --> - </div> - </div> diff --git a/Frontend Angular 4/src/app/layout/functions/functions.component.ts b/Frontend Angular 4/src/app/layout/functions/functions.component.ts deleted file mode 100644 index aec0c51f8c4cd4d66787c389d6512264b24b0097..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/functions.component.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Function } from './function'; -import { FunctionServices } from './functions.service'; -import { FunctionServicesResult } from './function.services.result'; -//import {ToasterModule, ToasterService,ToasterConfig} from 'angular2-toaster'; - -@Component({ - selector: 'functions', - templateUrl: './functions.component.html', - styleUrls: ['./functions.css'], - providers: [] -}) -export class FunctionsComponent implements OnInit { - title = 'Módulo de funciones'; - _funcs: Function[]; - _newFunction :Function = {'id':2,'name':'g','str':'g(x)=x+41'}; - //_toasterService: ToasterService; - // - constructor(private functionServices: FunctionServices) { - // this._toasterService = toasterService; - } - getFuncs(): void { - this.functionServices.getAll().then(result => this._funcs = result); - } - removeFunc(name:string): void{ - this.functionServices.delete(name); - this.getFuncs(); - } - modifyFunc(name:string): void{ - var f = this.functionServices.get(name); - console.log(f); - this._newFunction = f; - - } - - ngOnInit(): void { - this.getFuncs(); - } - - handleAddFunction(): void{ - if(this._newFunction.str.length>4){ - this._newFunction.id =1; - } - var _f:Function = {'id':this._newFunction.id,'name':this._newFunction.str.split('(')[0], 'str':this._newFunction.str}; - var response = this.functionServices.add(_f); - this._newFunction.id=0; - this._newFunction.name=''; - this._newFunction.str = ''; - - } - -} diff --git a/Frontend Angular 4/src/app/layout/functions/functions.css b/Frontend Angular 4/src/app/layout/functions/functions.css deleted file mode 100644 index 7f08fa988273ceed7bebc1a77209bd4b1f0642bd..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/functions.css +++ /dev/null @@ -1,13 +0,0 @@ -.trash { - color:rgb(209, 91, 71); -} -.flag { - color:rgb(248, 148, 6); -} -.panel-body { padding:0px; } -.panel-footer .pagination { margin: 0; } -.panel .glyphicon,.list-group-item .glyphicon { margin-right:5px; } -.panel-body .radio, .checkbox { display:inline-block;margin:0px; } -.panel-body input[type=checkbox]:checked + label { text-decoration: line-through;color: rgb(128, 144, 160); } -.list-group-item:hover, a.list-group-item:focus {text-decoration: none;background-color: rgb(245, 245, 245);} -.list-group { margin-bottom:0px; } \ No newline at end of file diff --git a/Frontend Angular 4/src/app/layout/functions/functions.module.ts b/Frontend Angular 4/src/app/layout/functions/functions.module.ts deleted file mode 100644 index 46bbe37e1e2fb9aefaae7edcef4394996a4d2c73..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/functions.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { NgModule } from '@angular/core'; - -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { FunctionsComponent } from './functions.component'; -//import {ToasterModule, ToasterService} from 'angular2-toaster'; - -@NgModule({ - imports: [ - CommonModule, - FormsModule - //,ToasterModule - ], - declarations: [ - FunctionsComponent - ], - exports:[FunctionsComponent] -}) -export class FunctionsModule { } diff --git a/Frontend Angular 4/src/app/layout/functions/functions.routes.ts b/Frontend Angular 4/src/app/layout/functions/functions.routes.ts deleted file mode 100644 index 7ebc6616a48ee803e6d48297915e9495dec64f12..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/functions.routes.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Route } from '@angular/router'; - -import { FunctionsComponent } from './index'; - -export const FunctionsRoutes: Route[] = [ - { - path: 'functions', - component: FunctionsComponent - } -]; diff --git a/Frontend Angular 4/src/app/layout/functions/functions.service.ts b/Frontend Angular 4/src/app/layout/functions/functions.service.ts deleted file mode 100644 index 4d5cffa7be96e1acb0272f6fa3a01189d3b60f4b..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/functions.service.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Injectable } from '@angular/core'; - -import { Function } from './function'; -import { FunctionServicesResult }from './function.services.result'; - - -const regex = /^\w+\(((\w+(\s)*)?|((\w+(\s)*),(\s)*)*(\w+(\s)*))\)(\s)*=(\s)*$/g; - -@Injectable() -export class FunctionServices { - getAll(): Promise<Function[]>{ - return Promise.resolve(this.allfunctions); - }; - delete(functionName:String):void{ - console.log("deleting" + functionName); - this.allfunctions = this.allfunctions.filter(function(f){return f.name!=functionName}); - }; - add(f: Function): FunctionServicesResult{ - console.log(f); - if(f.id!=0){ - this.allfunctions.push(f); - var result : FunctionServicesResult = {'code':200,'msg':'' }; - } else { - var result : FunctionServicesResult = {'code':500,'msg':'Función no válida' }; - } - return result; - - }; - get(name:string){ - try{ - return this.allfunctions.filter(function(f){return f.name===name})[0]; - } catch(err){ - return null; - } - }; - getToPlot(name:string){ - console.log("Functions: "); - console.log(this.allfunctions); - try{ - return this.allfunctions.filter(function(f){return f.name===name})[0].str.split("=")[1]; - } catch(err){ - return null; - } - }; - - private allfunctions : Function[] = [{'id':12,'name':'f', 'str':'f(x)=x+5'}]; -} \ No newline at end of file diff --git a/Frontend Angular 4/src/app/layout/functions/index.ts b/Frontend Angular 4/src/app/layout/functions/index.ts deleted file mode 100644 index 46cafb423a5f0e921ee3a6a1761f9a422d8ab924..0000000000000000000000000000000000000000 --- a/Frontend Angular 4/src/app/layout/functions/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This barrel file provides the export for the lazy loaded BlankpageComponent. - */ -export * from './functions.component'; -export * from './functions.routes'; diff --git a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts index 837dc7c54c6c800ef20500e38391447a8f81588c..724cecdff5baaeb9d3a7627ad81a1fe185039e03 100644 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.component.ts @@ -1,12 +1,9 @@ import { Component, NgModule, ViewChild, HostListener, ElementRef, ComponentRef, TemplateRef } from '@angular/core'; import { CanvasModule} from '../canvas/canvas.module'; import { CanvasComponent } from '../canvas/canvas.component'; -import { FunctionsModule } from '../functions/functions.module'; -import { FunctionsComponent } from '../functions/functions.component'; import { Http, JsonpModule } from '@angular/http'; import { Headers, RequestOptions } from '@angular/http'; import { HaskellService } from '../../shared/services/haskell.service'; -import { FunctionServices } from '../functions/functions.service'; import { WebsocketService } from '../../shared/services/websocket.service'; import { UsuarioService } from '../../shared/services/usuario.service'; import { SessionService } from '../../shared/services/session.service'; @@ -47,7 +44,7 @@ var focus: any; selector: 'matefun', templateUrl: './matefun.component.html', styleUrls: ['./matefun.component.scss'], - providers: [ WebsocketService, FunctionServices, NgbPopoverConfig, UsuarioService ] + providers: [ WebsocketService, NgbPopoverConfig, UsuarioService ] }) @@ -92,7 +89,6 @@ export class MateFunComponent { private ghciService: GHCIService, private elRef: ElementRef, private notifService: NotificacionService, - private functionServices: FunctionServices, private sessionService: SessionService, private dialogService:DialogService, private usuarioService: UsuarioService) { @@ -149,473 +145,455 @@ export class MateFunComponent { codeMirrorRef.options.readOnly = false; componentRef.editDialogFired = true; } - }); - //We can close dialog calling disposable.unsubscribe(); - //If dialog was not closed manually close it by timeout - /* setTimeout(()=>{ - disposable.unsubscribe(); - },10000);*/ - } - - /* Panel para la posición del cursor */ - makePanel() { + }); + } - var node = document.createElement("div"); - node.id = "cursorpos-panel"; - node.className = "panel bottom"; - this.cursorPanelLabel = node.appendChild(document.createElement("span")); - var cm = this.codemirror.instance; + /* Panel para la posición del cursor */ + makePanel() { + + var node = document.createElement("div"); + node.id = "cursorpos-panel"; + node.className = "panel bottom"; + this.cursorPanelLabel = node.appendChild(document.createElement("span")); + var cm = this.codemirror.instance; + var x = cm.getCursor().line; + var y = cm.getCursor().ch; + x = (Number(x) + 1).toString(); + y = (Number(y) + 1).toString(); + this.cursorPanelLabel.textContent = "Posición del cursor: (" + x + "," + y + ")"; + + + this.cursorPanel = this.codemirror.instance.addPanel(node, {position: "bottom", stable: true}); + var that = this; + //agregamos el evento que setea la posición + this.codemirror.instance.on("cursorActivity",function(cm){ var x = cm.getCursor().line; var y = cm.getCursor().ch; x = (Number(x) + 1).toString(); y = (Number(y) + 1).toString(); - this.cursorPanelLabel.textContent = "Posición del cursor: (" + x + "," + y + ")"; - - - this.cursorPanel = this.codemirror.instance.addPanel(node, {position: "bottom", stable: true}); - var that = this; - //agregamos el evento que setea la posición - this.codemirror.instance.on("cursorActivity",function(cm){ - var x = cm.getCursor().line; - var y = cm.getCursor().ch; - x = (Number(x) + 1).toString(); - y = (Number(y) + 1).toString(); - that.cursorPanel.node.innerText = "Posición del cursor: (" + x + "," + y + ")"; - }); + that.cursorPanel.node.innerText = "Posición del cursor: (" + x + "," + y + ")"; + }); - this.codemirror.instance.on("keyHandled",function(cm,name,evt){ - if(name.code==="Digit1" && name.ctrlKey && name.shiftKey){ - that.seleccionarDirectorio(); - } else if(name.code==="Digit2" && name.ctrlKey && name.shiftKey){ - that.saveConfig(); - } - }); - /* - this.codemirror.instance.on("gutterClick", function(cm, n) { - var info = cm.lineInfo(n); - var makeMarker = function() { - var marker = document.createElement("div"); - marker.style.width = "15px"; - marker.style.height = "15px"; - marker.style.marginLeft = "-5px"; - marker.style.cursor = "pointer"; - marker.style["background-image"] = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=')"; - marker.innerHTML = "<a href='@' title='cuidado , advertencia matefun'></a>"; - return marker; - } - cm.setGutterMarker(n, "breakpoints", info.gutterMarkers ? null : makeMarker()); - });*/ - - this.codemirror.instance.on("keypress",function(cm,name,evt){ - - if(!that.editDialogFired && JSON.parse(sessionStorage.currentUser).tipo === "docente" && cm.options.readOnly){ - codeMirrorRef = that.codemirror.instance; - componentRef = that; - that.showConfirm(); - } + this.codemirror.instance.on("keyHandled",function(cm,name,evt){ + if(name.code==="Digit1" && name.ctrlKey && name.shiftKey){ + that.seleccionarDirectorio(); + } else if(name.code==="Digit2" && name.ctrlKey && name.shiftKey){ + that.saveConfig(); + } + }); - }); - } - - saveConfig(){ - var config = new Configuracion(); - config.themeEditor = this.configCodeMirror.theme; - config.fontSizeEditor = this.configCodeMirror.fontSize; - var confUser = this.authService.getUserConfig(); - var reiniciar = confUser.argumentoF != this.argumentoF || confUser.argumentoI != this.argumentoI; - config.argumentoF = this.argumentoF; - config.argumentoI = this.argumentoI; - this.usuarioService.actualizarConfiguracion(this.authService.getUser().cedula,config) - .subscribe( - success=> { - //this.ghciService.consoleRef.Write("Configuración guardada" + "\n"); - this.popover.close(); - this.authService.setUserConfig(success); - if(reiniciar){ - this.reiniciarInterprete(); - } + this.codemirror.instance.on("keypress",function(cm,name,evt){ - }, - error=> { - this.notifService.error(error); - this.popover.close(); + if(!that.editDialogFired && JSON.parse(sessionStorage.currentUser).tipo === "docente" && cm.options.readOnly){ + codeMirrorRef = that.codemirror.instance; + componentRef = that; + that.showConfirm(); + } + + }); + } + + saveConfig(){ + var config = new Configuracion(); + config.themeEditor = this.configCodeMirror.theme; + config.fontSizeEditor = this.configCodeMirror.fontSize; + var confUser = this.authService.getUserConfig(); + var reiniciar = confUser.argumentoF != this.argumentoF || confUser.argumentoI != this.argumentoI; + config.argumentoF = this.argumentoF; + config.argumentoI = this.argumentoI; + this.usuarioService.actualizarConfiguracion(this.authService.getUser().cedula,config) + .subscribe( + success=> { + //this.ghciService.consoleRef.Write("Configuración guardada" + "\n"); + this.popover.close(); + this.authService.setUserConfig(success); + if(reiniciar){ + this.reiniciarInterprete(); } - ); - } - aumentarFuente(){ - if(this.configCodeMirror.fontSize<30){ - this.configCodeMirror.fontSize++; + }, + error=> { + this.notifService.error(error); + this.popover.close(); } + ); + } + + aumentarFuente(){ + if(this.configCodeMirror.fontSize<30){ + this.configCodeMirror.fontSize++; } + } - disminuirFuente(){ - if(this.configCodeMirror.fontSize>8){ - this.configCodeMirror.fontSize--; - } + disminuirFuente(){ + if(this.configCodeMirror.fontSize>8){ + this.configCodeMirror.fontSize--; } + } - @HostListener('document:click', ['$event']) - private documentClicked(event: MouseEvent): void { + @HostListener('document:click', ['$event']) + private documentClicked(event: MouseEvent): void { - // Popover is open - if (this.popover && this.popover.isOpen()) { + // Popover is open + if (this.popover && this.popover.isOpen()) { - // Not clicked on self element - if (!(this.popover as any)._elementRef.nativeElement.contains(event.target)) { + // Not clicked on self element + if (!(this.popover as any)._elementRef.nativeElement.contains(event.target)) { - // Hacking typescript to access private member - const popoverWindowRef: ComponentRef<NgbPopoverWindow> = (this.popover as any)._windowRef; + // Hacking typescript to access private member + const popoverWindowRef: ComponentRef<NgbPopoverWindow> = (this.popover as any)._windowRef; - // If clicked outside popover window - if (!popoverWindowRef.location.nativeElement.contains(event.target)) { - this.popover.close(); - } + // If clicked outside popover window + if (!popoverWindowRef.location.nativeElement.contains(event.target)) { + this.popover.close(); } } } + } - ngOnInit() { - - this.ghciService.rendered(); - - - this.haskellService.getArchivos(this.authService.getUser().cedula) - .subscribe( - archivos => { - //.filter(function(a){return !a.eliminado}) - this.buildTreeFromList(archivos); - - }, - error => console.log("Error al obtener los archivos del alumno") - ); - - function KeyPress(e) { - - var evtobj = window.event? event : e - if (evtobj.keyCode == 90 && evtobj.ctrlKey){ - //alert("Ctrl+z") - }; - if(evtobj.key.toLowerCase() ==="a" && evtobj.ctrlKey){ - componentRef.seleccionarDirectorio(); - return false; - }else if(evtobj.key.toLowerCase() ==="e" && evtobj.ctrlKey){ - componentRef.downloadFile(); - return false; - } else if(evtobj.key.toLowerCase() ==="r" && evtobj.ctrlKey){ - componentRef.reiniciarInterprete(); - return false; - } else if(evtobj.key.toLowerCase() ==="g" && evtobj.ctrlKey){ - componentRef.guardarArchivo(); - return false; - } else if(evtobj.key.toLowerCase() ==="o" && evtobj.ctrlKey){ - document.getElementById("popover").click(); - return false; - } else if(evtobj.ctrlKey && evtobj.altKey && evtobj.key.toLowerCase() ==="p"){ - document.getElementById("ProgramBtn").click(); - var that = componentRef; - setTimeout(function() { - that.codemirror.instance.focus(); - },250); - componentRef.codemirror.instance.focus(); - focus ="program"; - return false; - } else if(evtobj.ctrlKey && evtobj.altKey && evtobj.key.toLowerCase() ==="c"){ - componentRef.ghciService.focusConsole(); - focus = "consola"; - return false; - } else if(evtobj.ctrlKey && evtobj.altKey && evtobj.key.toLowerCase() ==="f"){ - document.getElementById("FigurasBtn").click() - componentRef.ghciService.focusConsole(); - focus = "graficas"; - return false; - } else if(evtobj.key.toLowerCase() ==="p" && evtobj.ctrlKey && !evtobj.altKey){ - componentRef.runCode(); - return false; - } - } - document.onkeydown = KeyPress; + ngOnInit() { + + this.ghciService.rendered(); + + + this.haskellService.getArchivos(this.authService.getUser().cedula) + .subscribe( + archivos => { + //.filter(function(a){return !a.eliminado}) + this.buildTreeFromList(archivos); + + }, + error => console.log("Error al obtener los archivos del alumno") + ); + + function KeyPress(e) { + + var evtobj = window.event? event : e + if (evtobj.keyCode == 90 && evtobj.ctrlKey){ + //alert("Ctrl+z") + }; + if(evtobj.key.toLowerCase() ==="a" && evtobj.ctrlKey){ + componentRef.seleccionarDirectorio(); + return false; + }else if(evtobj.key.toLowerCase() ==="e" && evtobj.ctrlKey){ + componentRef.downloadFile(); + return false; + } else if(evtobj.key.toLowerCase() ==="r" && evtobj.ctrlKey){ + componentRef.reiniciarInterprete(); + return false; + } else if(evtobj.key.toLowerCase() ==="g" && evtobj.ctrlKey){ + componentRef.guardarArchivo(); + return false; + } else if(evtobj.key.toLowerCase() ==="o" && evtobj.ctrlKey){ + document.getElementById("popover").click(); + return false; + } else if(evtobj.ctrlKey && evtobj.altKey && evtobj.key.toLowerCase() ==="p"){ + document.getElementById("ProgramBtn").click(); + var that = componentRef; + setTimeout(function() { + that.codemirror.instance.focus(); + },250); + componentRef.codemirror.instance.focus(); + focus ="program"; + return false; + } else if(evtobj.ctrlKey && evtobj.altKey && evtobj.key.toLowerCase() ==="c"){ + componentRef.ghciService.focusConsole(); + focus = "consola"; + return false; + } else if(evtobj.ctrlKey && evtobj.altKey && evtobj.key.toLowerCase() ==="f"){ + document.getElementById("FigurasBtn").click() + componentRef.ghciService.focusConsole(); + focus = "graficas"; + return false; + } else if(evtobj.key.toLowerCase() ==="p" && evtobj.ctrlKey && !evtobj.altKey){ + componentRef.runCode(); + return false; + } } - ngAfterViewInit() { - componentRef = this; - if(this.codemirror.instance!=null && !this.cursorLabelInit){ - this.cursorLabelInit = true; - this.codemirror.instance.setOption('theme', this.configCodeMirror.theme); - this.makePanel(); - } - if(!this.editableLoaded && this.codemirror.instance!=null &&(this.sessionService.archivo.editable!==undefined)){ - try{ - var editable = this.sessionService.archivo.editable && (this.sessionService.archivo.estado == 'Edicion' || this.sessionService.archivo.estado == 'Devuelto'); - this.codemirror.instance.options.readOnly = !editable; - this.editableLoaded = true; - + document.onkeydown = KeyPress; + } - } catch(err) { - return; + ngAfterViewInit() { + componentRef = this; + if(this.codemirror.instance!=null && !this.cursorLabelInit){ + this.cursorLabelInit = true; + this.codemirror.instance.setOption('theme', this.configCodeMirror.theme); + this.makePanel(); + } + if(!this.editableLoaded && this.codemirror.instance!=null &&(this.sessionService.archivo.editable!==undefined)){ + try{ + var editable = this.sessionService.archivo.editable && (this.sessionService.archivo.estado == 'Edicion' || this.sessionService.archivo.estado == 'Devuelto'); + this.codemirror.instance.options.readOnly = !editable; + this.editableLoaded = true; - } - } - } - htmlEncode(value:string){ - return value - .replace('Prelude> ','') - .replace(/&/g, '&') - .replace(/\s/g, ' ') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(/</g, '<') - .replace(/>/g, '>'); + } catch(err) { + return; + + } } - @ViewChild(CanvasComponent) canvasC: CanvasComponent; + } + + htmlEncode(value:string){ + return value + .replace('Prelude> ','') + .replace(/&/g, '&') + .replace(/\s/g, ' ') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/</g, '<') + .replace(/>/g, '>'); + } - funcionSTR: string = 'Math.sin(x)*x*x-20'; - consola: string = ''; - command: string = ''; - tipo: number = 1; + @ViewChild(CanvasComponent) canvasC: CanvasComponent; - private onKey = function (value: string) { - this.funcionSTR = value; - this.archivo.contenido = value; - } + funcionSTR: string = 'Math.sin(x)*x*x-20'; + consola: string = ''; + command: string = ''; + tipo: number = 1; - private writeCommand = function (value: string){ - this.command = value.split("\n")[value.split("\n").length - 1]; - } + private onKey = function (value: string) { + this.funcionSTR = value; + this.archivo.contenido = value; + } - private selectFunction = function() { - this.tipo = 1; - this.funcionSTR = "Math.sin(x)*x*x-20"; - } + private writeCommand = function (value: string){ + this.command = value.split("\n")[value.split("\n").length - 1]; + } - private selectElipse = function() { - this.tipo = 2; - this.funcionSTR = "elipse(x,y,radioX, radioY, rotacion_en_grados)"; - } + private selectFunction = function() { + this.tipo = 1; + this.funcionSTR = "Math.sin(x)*x*x-20"; + } - private selectCircle = function() { - this.tipo = 3; - this.funcionSTR = "circulo(x,y,radio)"; - } + private selectElipse = function() { + this.tipo = 2; + this.funcionSTR = "elipse(x,y,radioX, radioY, rotacion_en_grados)"; + } - private elipse = function(x: number, y: number, radiusX: number, radiusY: number, rotation: number) { - return [x, y, radiusX, radiusY, rotation]; - } + private selectCircle = function() { + this.tipo = 3; + this.funcionSTR = "circulo(x,y,radio)"; + } - private circulo = function(x: number, y: number, radius: number) { - return [x, y, radius]; - } + private elipse = function(x: number, y: number, radiusX: number, radiusY: number, rotation: number) { + return [x, y, radiusX, radiusY, rotation]; + } - inputConsola(text:any){ - this.entrada = text; - } - newFile(){ - this.archivo = new Archivo(); - this.archivo.cedulaCreador = this.authService.getUser().cedula; - this.archivo.contenido = ""; - this.archivo.nombre = ""; - this.copiaNombreArchivo = ''; - this.copiaContenidoArchivo = ''; + private circulo = function(x: number, y: number, radius: number) { + return [x, y, radius]; + } + + inputConsola(text:any){ + this.entrada = text; + } + newFile(){ + this.archivo = new Archivo(); + this.archivo.cedulaCreador = this.authService.getUser().cedula; + this.archivo.contenido = ""; + this.archivo.nombre = ""; + this.copiaNombreArchivo = ''; + this.copiaContenidoArchivo = ''; + } + + archivoModificado(){ + if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){ + this.modificado = true; + }else{ + this.modificado = false; } + } - archivoModificado(){ - if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){ - this.modificado = true; + guardarArchivo(){ + var regex = /^[A-Z]/ + if(this.archivo.nombre.trim() == ""){ + this.notifService.error("Nombre de archivo sin especificar"); + }else if (!regex.test(this.archivo.nombre)){ + this.notifService.error("Nombre de archivo debe iniciar con mayusula.") + }else{ + if(this.archivo.id){ + this.haskellService.editarArchivo(this.archivo.id, this.archivo) + .subscribe( + archivo => { + //this.ghciService.consoleRef.Write("Editar archivo: " + this.archivo.nombre + "\n"); + this.archivo = archivo; + this.lockSaveButton(); + }, + error => { + this.notifService.error(error); + }); }else{ - this.modificado = false; + this.haskellService.crearArchivo(this.archivo) + .subscribe( + archivo => { + //this.ghciService.consoleRef.Write("Archivo creado: " + this.archivo.nombre + "\n"); + this.archivo = archivo; + this.lockSaveButton(); + }, + error => { + this.notifService.error(error); + }); + } } - - guardarArchivo(){ - var regex = /^[A-Z]/ - if(this.archivo.nombre.trim() == ""){ - this.notifService.error("Nombre de archivo sin especificar"); - }else if (!regex.test(this.archivo.nombre)){ - this.notifService.error("Nombre de archivo debe iniciar con mayusula.") - }else{ - if(this.archivo.id){ + } + runCode(){ + + this.ghciService.setCodemirrorRef(this.codemirror.instance); + this.ghciService.resetGutters(); + var regex = /^[A-Z]/ + if(this.archivo.nombre.trim() == ""){ + this.notifService.error("Nombre de archivo sin especificar"); + }else if (!regex.test(this.archivo.nombre)){ + this.notifService.error("Nombre de archivo debe iniciar con mayusula.") + }else{ + + var resultado = this.sessionService.cargarDependencias(this.archivo); + if(resultado["status"]==="miss"){ + this.ghciService.outputConsole("Error: No se encuentra el archivo " + resultado["nombre"] + "\n"); + return; + } + if(this.archivo.id){ + if(this.archivo.editable || this.authService.getUser().tipo == 'docente'){ this.haskellService.editarArchivo(this.archivo.id, this.archivo) .subscribe( archivo => { - //this.ghciService.consoleRef.Write("Editar archivo: " + this.archivo.nombre + "\n"); this.archivo = archivo; + var list = this.sessionService.getDependencias(), + idList = []; + for(var l in list){ + idList.push(list[l].id); + } + if(!idList.some(id => id ==archivo.id)){ + idList.push(archivo.id); + } this.lockSaveButton(); + this.ghciService.loadFile(archivo.id,idList); }, error => { this.notifService.error(error); }); }else{ - this.haskellService.crearArchivo(this.archivo) - .subscribe( - archivo => { - //this.ghciService.consoleRef.Write("Archivo creado: " + this.archivo.nombre + "\n"); - this.archivo = archivo; - this.lockSaveButton(); - }, - error => { - this.notifService.error(error); - }); - - } - } - } - runCode(){ - - this.ghciService.setCodemirrorRef(this.codemirror.instance); - this.ghciService.resetGutters(); - var regex = /^[A-Z]/ - if(this.archivo.nombre.trim() == ""){ - this.notifService.error("Nombre de archivo sin especificar"); - }else if (!regex.test(this.archivo.nombre)){ - this.notifService.error("Nombre de archivo debe iniciar con mayusula.") - }else{ - - var resultado = this.sessionService.cargarDependencias(this.archivo); - if(resultado["status"]==="miss"){ - this.ghciService.outputConsole("Error: No se encuentra el archivo " + resultado["nombre"] + "\n"); - return; - } - if(this.archivo.id){ - if(this.archivo.editable || this.authService.getUser().tipo == 'docente'){ - this.haskellService.editarArchivo(this.archivo.id, this.archivo) - .subscribe( - archivo => { - this.archivo = archivo; - var list = this.sessionService.getDependencias(), - idList = []; - for(var l in list){ - idList.push(list[l].id); - } - if(!idList.some(id => id ==archivo.id)){ - idList.push(archivo.id); - } - this.lockSaveButton(); - this.ghciService.loadFile(archivo.id,idList); - }, - error => { - this.notifService.error(error); - }); - }else{ - var list = this.sessionService.getDependencias(), - idList = []; - for(var l in list){ - idList.push(list[l].id); - } - if(!idList.some(id => id ==this.archivo.id)){ - idList.push(this.archivo.id); - } - this.ghciService.loadFile(this.archivo.id,idList); + var list = this.sessionService.getDependencias(), + idList = []; + for(var l in list){ + idList.push(list[l].id); } - }else{ - this.haskellService.crearArchivo(this.archivo) - .subscribe( - archivo => { - this.archivo = archivo; - this.lockSaveButton(); - this.ghciService.loadFile(archivo.id,[]); - }, - error => { - this.notifService.error(error); - }); + if(!idList.some(id => id ==this.archivo.id)){ + idList.push(this.archivo.id); + } + this.ghciService.loadFile(this.archivo.id,idList); } + }else{ + this.haskellService.crearArchivo(this.archivo) + .subscribe( + archivo => { + this.archivo = archivo; + this.lockSaveButton(); + this.ghciService.loadFile(archivo.id,[]); + }, + error => { + this.notifService.error(error); + }); } - this.ghciService.focusConsole(); - } - download(filename, text) { - var element = document.createElement('a'); - element.setAttribute('href', 'data:application/octet-stream,' + encodeURIComponent(text)); - element.setAttribute('download', filename+ ".mf"); + this.ghciService.focusConsole(); - element.style.display = 'none'; - document.body.appendChild(element); + } + download(filename, text) { + var element = document.createElement('a'); + element.setAttribute('href', 'data:application/octet-stream,' + encodeURIComponent(text)); + element.setAttribute('download', filename+ ".mf"); - element.click(); + element.style.display = 'none'; + document.body.appendChild(element); - document.body.removeChild(element); - } - downloadFile(){ - var nom = this.archivo.nombre; - var content = this.archivo.contenido; - if(nom!= undefined && nom!="" && content!= undefined && content !=""){ - this.download(nom , content); - } + element.click(); - } - reiniciarInterprete(){ - this.ghciService.reiniciarInterprete(); + document.body.removeChild(element); + } + downloadFile(){ + var nom = this.archivo.nombre; + var content = this.archivo.contenido; + if(nom!= undefined && nom!="" && content!= undefined && content !=""){ + this.download(nom , content); } - toggleConsole(){ - this.consolaVisible = !this.consolaVisible; - } + } + reiniciarInterprete(){ + this.ghciService.reiniciarInterprete(); + } - seleccionarDirectorio(){ - this.archivosTree = this.sessionService.getArchivos(undefined); - var that = this; - let disposable = this.dialogService.addDialog(SeleccionarDirectorioComp, { - title:'', - message:'', - archivos:this.archivosTree, - directorioActual:this.archivosTree, - nombre:'', - parent:this}) - .subscribe((isConfirmed)=>{ + toggleConsole(){ + this.consolaVisible = !this.consolaVisible; + } - if(isConfirmed) { + seleccionarDirectorio(){ + this.archivosTree = this.sessionService.getArchivos(undefined); + var that = this; + let disposable = this.dialogService.addDialog(SeleccionarDirectorioComp, { + title:'', + message:'', + archivos:this.archivosTree, + directorioActual:this.archivosTree, + nombre:'', + parent:this}) + .subscribe((isConfirmed)=>{ + if(isConfirmed) { - //codeMirrorRef.options.readOnly = false; - //componentRef.editDialogFired = true; - } - }); - } + //codeMirrorRef.options.readOnly = false; + //componentRef.editDialogFired = true; + } + }); + } - buildTreeFromList (archivos){ + buildTreeFromList (archivos){ - this.sessionService.setArchivosList(archivos); - var root :Archivo; - for(var a in archivos){ - var arch = archivos[a]; - if(arch.padreId===-1){ - root = arch; - } - } - this.idRecorridos = [root.id]; - var archivos2 = archivos.filter( - function(a){ - return a.id!==root.id; - } - ); - var tree = this.buildTree(archivos2,root); - this.archivosTree = tree; - this.sessionService.setArchivosTree(tree); + this.sessionService.setArchivosList(archivos); + var root :Archivo; + + for(var a in archivos){ + var arch = archivos[a]; + if(arch.padreId===-1){ + root = arch; + } } + this.idRecorridos = [root.id]; + var archivos2 = archivos.filter( + function(a){ + return a.id!==root.id; + } + ); + var tree = this.buildTree(archivos2,root); + this.archivosTree = tree; + this.sessionService.setArchivosTree(tree); + } - buildTree(archivos, root){ - root.archivos = this.getArchivos(root.id,archivos); - for(var a in root.archivos){ - if(root.archivos[a].directorio && this.idRecorridos[root.archivos[a].id] === undefined){ - var id = root.archivos[a].id; - var archivos2 = archivos.filter(function(a){return a.id!==id}); - root.archivos[a] = this.buildTree(archivos2 ,root.archivos[a]); - } + buildTree(archivos, root){ + root.archivos = this.getArchivos(root.id,archivos); + for(var a in root.archivos){ + if(root.archivos[a].directorio && this.idRecorridos[root.archivos[a].id] === undefined){ + var id = root.archivos[a].id; + var archivos2 = archivos.filter(function(a){return a.id!==id}); + root.archivos[a] = this.buildTree(archivos2 ,root.archivos[a]); } - return root; } + return root; + } - getArchivos(id,archivos){ - return archivos.filter( - function(a){ - return a.padreId === id; - }); - } + getArchivos(id,archivos){ + return archivos.filter( + function(a){ + return a.padreId === id; + }); + } - } +} diff --git a/Frontend Angular 4/src/app/layout/matefun/matefun.module.ts b/Frontend Angular 4/src/app/layout/matefun/matefun.module.ts index 838a75b5583601ee96c5d6dc3886739cbc39518b..850c3c3679a86f6294f43a90b7c31aaf40ebc2b1 100644 --- a/Frontend Angular 4/src/app/layout/matefun/matefun.module.ts +++ b/Frontend Angular 4/src/app/layout/matefun/matefun.module.ts @@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { CanvasModule } from '../canvas/canvas.module' import { MateFunComponent } from './matefun.component'; -import { FunctionsModule } from '../functions/functions.module' import { BootstrapModalModule } from 'ng2-bootstrap-modal'; import { ConfirmComponent } from './confirm.component'; import { SeleccionarDirectorioComp } from './seleccionarDirectorio.component'; @@ -17,7 +16,6 @@ import { NotificacionModule } from '../../notificacion/notificacion.module'; FormsModule, CanvasModule, NotificacionModule, - FunctionsModule, MateFunRoutingModule, CodemirrorModule, NgbModule,