123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813 |
- var deferred = Deferred();
- function StartCtrl(){
- }
- function CommCtrl($scope, $rootScope){
- $scope.valor = 123;
- $scope.getSource = function(){
- return JSON.stringify($rootScope.getSource());
- }
- $scope.getEvaluation = function(){
- return $rootScope.getEvaluation();
- }
- }
- function IvProgCreateCtrl($scope, $rootScope, IvProgSource, $filter){
- $rootScope.trackAction = function(action){
- $.post(ilaParams.MA_PARAM_addresPOST+"&track=1", { trackingData: "html=1;"+action }, function(d){
- });
- }
- $rootScope.getSource = function(){
- $rootScope.trackAction("getSource");
- return {
- mapping: $rootScope.mapping,
- src: $scope.program,
- testCases: $scope.testCases
- };
- }
- $rootScope.getEvaluation = function(){
- $rootScope.trackAction("getEvaluation");
- $scope.run(true);
- }
- $rootScope.itemCount = 0;
- $scope.vars = [];
- $scope.params = [];
- $scope.testCases = [];
- $scope.addTestCase = function(){
- $rootScope.trackAction("addTestCase");
- $scope.testCases.push({ input: "", output: "", currentIndex: 0 });
- }
- $scope.removeTestCase = function(i){
- $rootScope.trackAction("removeTestCase");
- $scope.testCases.splice(i, 1);
- }
- $rootScope.mapping = {};
- $scope.getTeste = function(){
- return 1;
- }
- // undo - redo control
- $scope.historyStack = -1;
- $scope.actionsHistory = [];
- $scope.addSnap = true;
- $scope.takeSnap = function(friendlyName, applying, sp){
- if(sp){
- $scope.actionsHistory.splice($scope.historyStack, $scope.actionsHistory.length-$scope.historyStack);
- }
- $scope.actionsHistory.push({name: friendlyName, src: JSON.stringify($scope.program)});
- $scope.historyStack = $scope.actionsHistory.length;
- }
- $rootScope.snapshot = function(friendlyName, applying){
- if(!applying){
- $scope.$apply(function(){
- $scope.takeSnap(friendlyName, applying, true);
- });
- }else{
- $scope.takeSnap(friendlyName, applying, true);
- }
- $scope.addSnap = true;
- }
- $scope.undo = function(){
- if($scope.historyStack>0){
- if($scope.addSnap){
- // salvando o estado atual
- $scope.takeSnap('', 1);
- $scope.historyStack--;
- $scope.addSnap = false;
- }
- $scope.historyStack--;
- var obj = JSON.parse($scope.actionsHistory[$scope.historyStack].src);
- $scope.program = obj;
- }
- }
- $scope.redo = function(){
- if($scope.historyStack < $scope.actionsHistory.length-1){
- $scope.historyStack++;
- var obj = JSON.parse($scope.actionsHistory[$scope.historyStack].src);
-
- $scope.program = obj;
- }
- }
- $scope.currentFunction = 0;
- $scope.program = {
- programName: "firstProgram",
- functions: [
- {
- isMain: true,
- name: "Principal",
- vars: {},
- params: {},
- type: "main", // int, void, float
- nodes:[]
- }/*,
- {
- isMain: false,
- name: "fatorial",
- vars: {},
- varss: {
- "var_1":
- { name: 'newVar1', type: 'int', initialValue: 0, id: "var_1" }
- },
- params: {},
- type: "int", // int, void, float
- nodes:[],
- nodess: [
- {
- id: "attr_1",
- type: "attr",
- name: "attr",
- parent: null,
- variable: "",
- exp: []
- }
- ]
- }*/
- ]
- };
- $scope.setCurrentFunction = function(ind){
- $scope.currentFunction = ind;
- }
- $scope.addElVar = function(v){
- v.push({
- t: "var",
- v: "",
- o: "",
- p: ''//v
- });
- }
- $scope.addElVal = function(v){
- v.push({
- t: "val",
- v: 0,
- o: "",
- p: ''//v
- });
- }
- $scope.addElExpB = function(v){
- v.push({
- t: "expB",
- v: {
- op1: {
- t: "v",
- v: ""
- },
- op2: {
- t: "v",
- v: ""
- },
- op: ">"
- },
- o: "&&",
- p: ''//v
- });
- }
- $scope.isolar = function(item){
- item.t = "exp";
- item.v = "";
- item.exp = [];
- }
- $scope.addExp = function(parent){
- parent.push({ t: "val", v: "a", o: "+"});
- }
-
- $scope.getTemplate = function(x){
- return 'partials/elements/'+x.type+'.html'+"?t="+cacheTime;
- }
- $scope.addParam = function(){
- //var ind = $scope.params.length;
- var ind = $scope.programs[$scope.currentProgram].functions[0].params.length;
- //$scope.params.push({ name: 'newParam'+ind, type: 'int', initialValue: 0 } );
- $scope.programs[$scope.currentProgram].functions[0].params.push({ name: 'newParam'+ind, type: 'int', initialValue: 0 } );
- }
- $scope.removeParam = function(v){
- $scope.params.splice($scope.params.indexOf(v), 1);
- }
- $scope.varSetType = function(v, type){
- $rootScope.trackAction("changeVarType");
- var previousType = v.type;
- v.type = type;
- if(type=="string"){
- v.initialValue = "Olá mundo!";
- }else if(type=="float"){
- v.initialValue = 1.0;
- }else if(type=="int"){
- v.initialValue = 1;
- }else if(type=="boolean"){
- v.initialValue = true;
- }
- $scope.checkChangeTypeConsequences(v, $scope.program.functions[$scope.currentFunction].nodes, previousType);
- }
- // quando alterar o tipo de uma variavel, checar as consequencias
- $scope.checkChangeTypeConsequences = function(variable, where, previous){
- angular.forEach(where, function(item, key){
- if(item.type=="attr"){
- if(item.variable==variable.id){
- if(variable.type!=previous){
- var compatibility = ["int", "float"];
- if((compatibility.indexOf(variable.type)==-1)||(compatibility.indexOf(previous)==-1)){
- if(where[key].exp.length>0){
- where[key].exp = [];
- }
- }
- }
- }
- }
- if(item.nodes && item.nodes.length>0){
- $scope.checkChangeTypeConsequences(variable, item.nodes);
- }
- });
- }
- $scope.addVar = function(){
- $rootScope.trackAction("addVar");
- // TODO: checar se alterou o valor
- $rootScope.snapshot('Variável adicionada', true);
- var ind = $scope.itemCount;
- var id = "var"+$scope.itemCount++;
- $scope.program.functions[$scope.currentFunction].vars[id] = ({ name: 'newVar'+ind, type: 'int', initialValue: 1, id: id });
- }
- $scope.removeVarRec = function(nodes, id){
- $rootScope.trackAction("removeVar");
- angular.forEach(nodes, function(node, key){
- if(node.type=="write"){
- if(node.variable==id){
- node.variable = '';
- }
- }
- if(node.type!="attr"){
- if(node.nodes.length>0){
- $scope.removeVarRec(node.nodes, id);
- }
- }
- });
- }
- $scope.removeVar = function(v){
- $rootScope.trackAction("removeVar");
- $rootScope.snapshot('Variável removida', true);
- $scope.removeVarRec($scope.program.functions[$scope.currentFunction].nodes, v.id);
- delete $scope.program.functions[$scope.currentFunction].vars[v.id];
- }
- $scope.removeItem = function(parent, item){
- $rootScope.trackAction("removeItem");
- parentId = parent;
- // TODO: tratar para os outros functions
- if(parent=="root_0"){
- parent = $scope.program.functions[0].nodes;
- }else{
- parent = $rootScope.mapping[parent].nodes;
- }
- if($.isArray(parent)) {
- parent.splice(parent.indexOf(item),1);
- }
- if($rootScope.mapping[parentId]){
- var p1 = $rootScope.mapping[parentId].nodes1;
- if($.isArray(p1)) {
- p1.splice(p1.indexOf(item),1);
- }
- var p2 = $rootScope.mapping[parentId].nodes2;
- if($.isArray(p2)) {
- p2.splice(p2.indexOf(item),1);
- }
- }
- delete $rootScope.mapping[item.id];
-
-
- }
- $scope.isValidAttr = function(attr){
- var isValid = true;
- angular.forEach(attr, function(a, k){
- if(a.type=="var"){
- }
- });
- return false;
- }
- $scope.sortableOptions = {
- handle: '.handle',
- placeholder: "apps",
- connectWith: ".apps-container"
- };
- $scope.delete = function(data) {
- $rootScope.trackAction("delete");
- data.nodes = [];
- };
- $scope.run = function(useTestCases){
- cleanOutput();
- $rootScope.trackAction("run="+useTestCases);
-
- if(!$scope.validateEverything($scope.program)){
- writer("<i class='fa fa-exclamation-triangle'></i> Existem campos vazios. Preencha os campos com borda vermelha para executar o algoritmo corretamente.", false);
- }else{
- if(useTestCases){
- totalCasesEvaluated = 0;
- totalCasesPassed = 0;
- totalTestCases = $scope.testCases.length;
- angular.forEach($scope.testCases, function(item, key){
- $scope.testCases[key].currentIndex = 0;
- })
- testCases = $scope.testCases;
- var code = "";
- angular.forEach($scope.testCases, function(item, key){
- code += $scope.genCode($scope.program, true, key);
- });
- console.log(code);
- window.eval(code);
-
-
- }else{
- $rootScope.trackAction("run");
- var code = $scope.genCode($scope.program, false, 0);
- window.eval(code);
- }
-
- $("#valor").unbind('keydown');
- $("#valor").keydown(function( event ) {
- if ( event.which == 13 ) {
- $('#readData').modal('hide');
- var valor = $("#valor").val();
- $("#valor").val("");
- deferred.call(valor);
- event.preventDefault();
- }
- });
- $("#btnOk").unbind('click');
- $("#btnOk").click(function(){
- $('#readData').modal('hide');
- var valor = $("#valor").val();
- $("#valor").val("");
- deferred.call(valor);
- });
- }
- }
- $scope.clearOutput = function(){
- $rootScope.trackAction("cleanOutput");
- $(".output").html("");
- }
- $scope.validateEverything = function(funcs){
- $(".node-with-error").removeClass("node-with-error");
- var ret = true;
- angular.forEach(funcs.functions, function(func, key){
- ret = ret && $scope.validateNode(func.nodes, func.vars);
- });
- return ret;
- }
- $scope.validateNode = function(nodes, vars){
- var ret = true;
- angular.forEach(nodes, function(node, key){
- if (node.type=="write"){
- if(node.variable==""){
- $("#node"+node.id).find(".select").addClass("node-with-error");
- ret = false;
- }
- }
- if(node.type=="read"){
- if(node.variable==""){
- $("#node"+node.id).find(".select").addClass("node-with-error");
- ret = false;
- }
- }
- if(node.type=="for"){
- if(node.forType==1){
- if((node.limitType=="var")&&(node.limit=="")){
- $("#node"+node.id).find(".for1").find(".select").addClass("node-with-error");
- ret = false;
- }
- }
- if(node.forType==2){
- if((node.limitType=="var")&&(node.limit=="")){
- $("#node"+node.id).find(".for1").find(".select").addClass("node-with-error");
- ret = false;
- }
- if(node.using==""){
- $("#node"+node.id).find(".for2").addClass("node-with-error");
- ret = false;
- }
- }
- if(node.forType==3){
- if((node.limitType=="var")&&(node.limit=="")){
- $("#node"+node.id).find(".for1").find(".select").addClass("node-with-error");
- ret = false;
- }
- if(node.using==""){
- $("#node"+node.id).find(".for2").addClass("node-with-error");
- ret = false;
- }
- if((node.initialType=="var")&&(node.initial=="")){
- ret = false;
- }
- if((node.initialType=="val")&&(node.limitType=="val")&&(node.initial>node.limit)){
- ret = false;
- }
- if((node.stepType=="var")&&(node.step=="")){
- $("#node"+node.id).find(".for3").find(".select").addClass("node-with-error");
- ret = false;
- }
- }
- }
- });
- return ret;
- }
- $scope.genCode = function(funcs, useTestCases, testCaseIndex){
- var strCode = "var t"+testCaseIndex+" = function(){";
- var i = 0;
- angular.forEach(funcs.functions, function(func, key){
- if(i++==0){
- strCode+= "function "+func.name+"(){";
- angular.forEach(func.vars, function(variable, key){
- if(variable.type=="string"){
- strCode+="var var_"+variable.id+" = \""+variable.initialValue+"\";";
- }else{
- strCode+="var var_"+variable.id+" = "+variable.initialValue+";";
- }
- });
-
- strCode+= 'next(function(){';
- strCode+='/*return deferred;*/';
- strCode+='})';
- // correcao automatica - false
- strCode+=$scope.genNode(useTestCases, func.nodes, func.vars, testCaseIndex);
- if(useTestCases){
- // correcao automatica
- strCode+= '.next(function(){';
- //strCode+=' console.log("OUT "+getOutput());'
- strCode+=' endTest('+testCaseIndex+');'
- strCode+='});';
- }
- strCode+= "}";
- if(func.type=="main"){
- strCode+=func.name+"()";
- }
- }
- });
- strCode+="}; t"+testCaseIndex+"();";
-
- return strCode;
- }
- $scope.genNode = function(isEvaluating, nodes, vars, testCaseIndex){
- var strCode = "";
- angular.forEach(nodes, function(node, key){
- if(node.type=="write"){
- if(node.variable!=''){
- var v = $scope.program.functions[$scope.currentFunction].vars[node.variable];
- strCode += ".next(function(){";
-
- if(v.type=="boolean"){
- strCode+="if(var_"+node.variable+"){ writer('Verdadeiro', "+isEvaluating+"); }else{ writer('Falso', "+isEvaluating+"); }";
- }else{
- strCode += "writer(";
- strCode += "var_"+node.variable;
- strCode += ","+isEvaluating+");";
- }
- strCode += "})";
- }
- }
- if(node.type=="while"){
- // while
- strCode+= '.next(function(){';
- //strCode+= 'var i'+node.id+ ' = 0;';
- strCode+= 'function loop'+node.id+'(){';
- strCode+= ' return next(function(){})'; // apenas para poder encadear
- if(node.nodes.length>0){
- strCode+= $scope.genNode(isEvaluating, node.nodes, vars);
- }
- strCode+=' .next(function(){';
- //strCode+=' ++i'+node.id+';';
-
- strCode+=' if('+$scope.genExp(node.exp, 'boolean')+'){';
-
- strCode+=' return loop'+node.id+'();';
- strCode+=' }'
- strCode+=' });';
- strCode+='}';
- strCode+=' if('+$scope.genExp(node.exp, 'boolean')+'){';
- strCode+='return loop'+node.id+'();';
- strCode+='}';
- strCode+='})';
- }
- if(node.type=="for"){
-
- if(node.forType==1){
- // for simples
- strCode+= '.next(function(){';
- strCode+= 'var i'+node.id+ ' = 0;';
- strCode+= 'function loop'+node.id+'(){';
- strCode+= ' return next(function(){})'; // apenas para poder encadear
- if(node.nodes.length>0){
- strCode+= $scope.genNode(isEvaluating, node.nodes, vars);
- }
- strCode+=' .next(function(){';
- strCode+=' ++i'+node.id+';';
- if(node.limitType=="val"){
- strCode+=' if(i'+node.id+'<'+node.limit+'){';
- }else{
- strCode+=' if(i'+node.id+'<'+' var_'+node.limit+'){';
- }
- strCode+=' return loop'+node.id+'();';
- strCode+=' }'
- strCode+=' });';
- strCode+='}';
- if(node.limitType=="val"){
- strCode+=' if(i'+node.id+'<'+node.limit+'){';
- }else{
- strCode+=' if(i'+node.id+'<'+' var_'+node.limit+'){';
- }
- strCode+='return loop'+node.id+'();';
- strCode+='}';
- strCode+='})';
- }else if(node.forType==2){
- // for mediano
- strCode+= '.next(function(){';
- strCode+= ' var_'+node.using+ ' = 0;';
- strCode+= 'function loop'+node.id+'(){';
- strCode+= ' return next(function(){})'; // apenas para poder encadear
- if(node.nodes.length>0){
- strCode+= $scope.genNode(isEvaluating, node.nodes, vars);
- }
- strCode+=' .next(function(){';
- strCode+=' ++var_'+node.using+';';
- if(node.limitType=="val"){
- strCode+=' if(var_'+node.using+'<'+node.limit+'){';
- }else{
- strCode+=' if(var_'+node.using+'<'+' var_'+node.limit+'){';
- }
- strCode+=' return loop'+node.id+'();';
- strCode+=' }'
- strCode+=' });';
- strCode+='}';
- if(node.limitType=="val"){
- strCode+=' if(var_'+node.using+'<'+node.limit+'){';
- }else{
- strCode+=' if(var_'+node.using+'<'+' var_'+node.limit+'){';
- }
- strCode+='return loop'+node.id+'();';
- strCode+='}';
- strCode+='})';
- }else if(node.forType==3){
- // for hard rs
- strCode+= '.next(function(){';
- if(node.initialType=="val"){
- strCode+= ' var_'+node.using+ ' = '+node.initial+';';
- }else{
- strCode+= ' var_'+node.using+ ' = var_'+node.initial+';';
- }
- strCode+= 'function loop'+node.id+'(){';
- strCode+= ' return next(function(){})'; // apenas para poder encadear
- if(node.nodes.length>0){
- strCode+= $scope.genNode(isEvaluating, node.nodes, vars);
- }
- strCode+=' .next(function(){';
- if(node.stepType=="val"){
- strCode+=' var_'+node.using+'+= '+node.step+';';
- }else{
- strCode+=' var_'+node.using+'+= var_'+node.step+';';
- }
-
- if(node.limitType=="val"){
- strCode+=' if(var_'+node.using+'<'+node.limit+'){';
- }else{
- strCode+=' if(var_'+node.using+'<'+' var_'+node.limit+'){';
- }
- strCode+=' return loop'+node.id+'();';
- strCode+=' }'
- strCode+=' });';
- strCode+='}';
- if(node.limitType=="val"){
- strCode+=' if(var_'+node.using+'<'+node.limit+'){';
- }else{
- strCode+=' if(var_'+node.using+'<'+' var_'+node.limit+'){';
- }
- strCode+='return loop'+node.id+'();';
- strCode+='}';
- strCode+='})';
- }
- }
- if(node.type=="attr"){
- if(node.variable!=""){
- strCode+= '.next(function () {';
- strCode+=" var_"+node.variable+"=";
- strCode+=" ("+$scope.genExp(node.exp, vars[node.variable].type)+")";
- strCode+=" ;";
- strCode+= '})';
- }
- }
- if(node.type=="read"){
- var v = $scope.program.functions[$scope.currentFunction].vars[node.variable];
-
- if(!isEvaluating){
- strCode+= '.next(function () {';
- strCode+= ' $("#msgRead").html("'+node.message+'");';
- strCode+= ' $("#readData").modal();';
- strCode+= ' $("#valor").focus();';
- strCode+= ' return deferred;';
- strCode+= '}).';
- strCode+= 'next(function(a){';
- strCode+= ' console.log("Valor lido: "+a);';
- strCode+= '/* '+v.type+' */';
- }else{
- strCode+= '.next(function () {';
- strCode+= ' var a = "'+readerInput(testCaseIndex)+'";';
- }
- if(v.type=="int"){
- strCode+= " var_"+node.variable +" = parseInt(a);";
- }else if(v.type=="float"){
- strCode+= " var_"+node.variable +" = parseFloat(a); /* pq cai aqui */";
- }else if(v.type=="boolean"){
- // tratar boolean depois
- strCode+= " var_"+node.variable +" = a;";
- }else if(v.type=="string"){
- // tratar boolean depois
- strCode+= " var_"+node.variable +" = a;";
- }else{
- strCode+= " var_"+node.variable +" = a; ";
- }
-
- strCode+= '})';
- }
- if(node.type=="if"){
- strCode+= '.next(function () {';
- strCode+= 'if('+$scope.genExp(node.exp, 'boolean')+'){';
- strCode+= 'return next(function () {})'+$scope.genNode(isEvaluating, node.nodes1, vars);
- strCode+= '}else{';
- strCode+= 'return next(function () {})'+$scope.genNode(isEvaluating, node.nodes2, vars);
- strCode+= '}';
- strCode+= '})';
- }
- });
- return strCode;
- }
- $scope.genExp = function(exp, type){
- var strCode = "";
- console.log(exp);
- angular.forEach(exp, function(ex, key){
- if(ex.t == "var"){
- strCode+=" var_"+ex.v+" ";
- }else if(ex.t == "val"){
- if(type=="string"){
- strCode+=" \" "+ex.v+"\" ";
- }else{
- strCode+=" "+ex.v+" ";
- }
- }else if(ex.t=="exp"){
- strCode+=" ( "+$scope.genExp(ex.v, type)+" ) ";
- }else if(ex.t=="expB"){
- strCode+=" ( "+$scope.genExp(ex.v, type)+" ) ";
- }else if(ex.t=="op"){
- strCode+= ex.v;
- }else if(ex.t=="opB"){
- strCode+= ex.v;
- }
- });
- return strCode;
- }
-
- $scope.changeForType = function(node, v){
- node.forType +=v;
- }
- $scope.changeForValue = function(node){
- node.isValue = !node.isValue;
- if(!node.isValue){
- node.simpleVariable = "";
- }
- writer(node.isValue, false);
- }
- $scope.childrenVisible = function(node){
- node.isChildrenVisible = !node.isChildrenVisible;
- }
- $scope.add = function(parent, parentId, type, name) {
- $rootScope.trackAction("add;type="+type);
- var newNode = {
- id: $scope.itemCount++,
- type: type,
- name: name,
- nodes: [],
- parent: parentId
- };
- // especifico de cada estrutura
- if(type=="if"){
- newNode.id = "if_"+newNode.id;
- newNode.exp = [/*
- { t: 'expB',
- v: [{"t":"val","v":""},{"t":"opB","v":""},{"t":"val","v":""}]
- }*/
- ];
- newNode.isChildrenVisible = true;
- newNode.nodes1 = [];
- newNode.nodes2 = [];
- }
- if(type=="read"){
- newNode.id = "read_"+newNode.id;
- newNode.message = "Por favor digite um valor:";
- newNode.variable = "";
- }
- if(type=="write"){
- newNode.id = "write_"+newNode.id;
- newNode.variable = "";
- }
- if(type=="while"){
- newNode.id = "while_"+newNode.id;
- newNode.exp = [];
- newNode.isChildrenVisible = true;
- newNode.nodes = [];
- }
- if(type=="for"){
- newNode.id = "for_"+newNode.id;
- newNode.forType = 1; // 1 SIMPLE, 2 +-, 3 COMPLETE
- newNode.initial = 1;
- newNode.initialType = "val";
- newNode.limit = 5;
- newNode.limitType = "val";
- newNode.using = "";
- newNode.step = 1;
- newNode.stepType = "val";
- newNode.isChildrenVisible = true;
- newNode.times = 5;
- newNode.timesType = 5;
- newNode.simple = true;
- newNode.isValue = true;
- newNode.simpleVariable = "";
- newNode.initialValue = 0;
- newNode.endValue = 5;
- newNode.increment = 1;
- newNode.variable = "";
-
- }
- if(type=="attr"){
- newNode.id = "attr_"+newNode.id;
- newNode.variable = "";
- //newNode.exp = [];
- /*newNode.exp = {
- op1: '',
- op1T : '',
- op: '',
- op2: '',
- op2T: ''
- };*/
- delete newNode.nodes;
- newNode.exp = [];
- newNode.isLocked = false;
- }
- parent.push(newNode);
- $rootScope.mapping[newNode.id] = newNode;
- };
- $scope.save = function(){
- $.post('save.php', { src: JSON.stringify($scope.program) }, function(id) {
- $("body").append("<iframe src='get.php?id=" + id + "' style='display: none;' ></iframe>");
- });
- }
- if(ilaParams.MA_PARAM_Proposition!=null){
- $.get(ilaParams.MA_PARAM_Proposition, function(d){
- if(d!=null){
- $scope.mapping = d.mapping;
- $scope.program = d.src;
- $scope.testCases = d.testCases;
- $scope.$apply()
- }
- }, "json");
- }
- }
- function IvProgAbertoCtrl($scope){
- $scope.delete = function(data) {
- data.nodes = [];
- };
- $scope.add = function(data) {
- var post = data.nodes.length + 1;
- var newName = data.name + '-' + post;
- data.nodes.push({name: newName,nodes: []});
- };
- $scope.tree = [{name: "Node", nodes: []}];
- }
|