- Timestamp:
- 03/13/14 17:50:13 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
js/viewer-f0/js/main.js
r149 r172 1 var geneWindow=1 var Viewer = 2 2 { 3 4 Mode: { 5 LINK: 0, 6 EMBEDDED: 1, 7 TEXTAREA: 2, 8 CODE : 3 9 }, 3 10 context: undefined, 4 urlToXML: "f0def.xml", 5 debugCreatureName: "test", 11 urlToXML: "f0def.xml",//"http://www.framsticks.com/files/apps/config/f0def.xml", 6 12 xml: undefined, 7 13 model: new Model(), … … 14 20 neurons: [], 15 21 neuroConns: [], 16 neuroClasses: [],22 neuroClasses: {}, 17 23 modelOne: undefined, 18 24 _graphicsEngine: new GraphicsEngine(), … … 21 27 var local = this; 22 28 $.ajax({ 23 url: "http://www.framsticks.com/files/apps/config/f0def.xml",29 url: local.urlToXML, 24 30 dataType: "xml", 25 31 async: false, … … 66 72 { 67 73 var neuroClass = new NeuroClass(); 74 this.neuroClasses[data[i].attributes[0].value] = neuroClass; 68 75 neuroClass.setModel(data); 69 this.neuroClasses.push(neuroClass);70 } 76 } 77 71 78 }, 72 79 analyseLine: function (line) { … … 119 126 }) 120 127 }, 121 downloadCreature: function () { 122 var lines; 128 getCreature: function (mode, content) { 129 130 var lines = undefined; 131 if(mode == this.Mode.LINK) 132 lines = this._getCreatureFromLink(content); 133 else if(mode == this.Mode.EMBEDDED) 134 lines = this._getCreatureFromEmbeddedCode(content); 135 else if (mode == this.Mode.TEXTAREA) 136 lines = this._getCreatureFromTextArea(content); 137 else if(mode == this.Mode.CODE) 138 lines = this._getCreatureFromCode(content); 139 else 140 { 141 throw "Wrong mode in function getCreature"; 142 } 143 return lines; 144 }, 145 _getCreatureFromLink: function(link){ 146 var lines = undefined; 123 147 $.ajax({ 124 url: "http://localhost:63343/FramestickFavi/creatures/" + this.debugCreatureName + ".txt",148 url: link, 125 149 async: false, 126 150 dataType: "text", … … 132 156 alert("Can't download creature"); 133 157 } 134 135 }); 136 137 //lines = $("#geno").val(); 138 //lines = lines.split("\n"); 139 140 return lines; 141 }, 142 parseCreature: function () { 143 var lines = this.downloadCreature(); 158 }); 159 return lines; 160 }, 161 _getCreatureFromTextArea: function(area){ 162 var lines = undefined; 163 lines = area.val(); 164 lines = lines.split("\n"); 165 return lines; 166 }, 167 _getCreatureFromCode: function(code){ 168 var lines = code; 169 lines = lines.split("\n"); 170 return lines; 171 }, 172 _getCreatureFromEmbeddedCode: function(link){ 173 var lines = undefined; 174 175 $.ajax({ 176 url: link, 177 async: false, 178 dataType: "html", 179 success: function (data) { 180 var geno = $($(data).find("div")[0]).comments().html(); 181 geno = geno.replace("FRED_GEN", ""); 182 lines = geno.split("\n"); 183 }, 184 error: function () { 185 alert("Can't download creature"); 186 } 187 }); 188 189 return lines; 190 }, 191 parseCreature: function (mode, content) { 192 var lines = this.getCreature(mode, content); 144 193 lines.splice(0, 1); 145 194 var local = this; … … 164 213 this._graphicsEngine.initializeScene(); 165 214 this.renderCreature(); 166 //this._graphicsEngine.debugTest();215 this._graphicsEngine.debugTest(); 167 216 this._graphicsEngine.renderScene(); 168 217 169 218 this._neuronDrawer.initializeScene(); 170 219 new SmartLayout(this.neurons, this.neuroConns); 171 this._neuronDrawer.drawNetwork(this.neurons, this.neuroConns, einfos );220 this._neuronDrawer.drawNetwork(this.neurons, this.neuroConns, einfos, this.neuroClasses); 172 221 this._neuronDrawer.renderScene(); 173 222 174 223 } 175 176 224 } 177 225 178 226 function openWindow() { 179 geneWindow.downloadXML(); 180 geneWindow.parseGeneXml(); 181 geneWindow.parseCreature(); 182 geneWindow.mainLoop(); 227 var debugCreatureName = "example4"; 228 Viewer.downloadXML(); 229 Viewer.parseGeneXml(); 230 //Viewer.parseCreature(Viewer.Mode.LINK, "http://localhost:63343/FramestickFavi/creatures/" + debugCreatureName + ".txt"); 231 //Viewer.parseCreature(Viewer.Mode.TEXTAREA, $("#geno")); 232 //Viewer.parseCreature(Viewer.Mode.CODE, "//0\np:\np: x=1"); 233 Viewer.parseCreature(Viewer.Mode.EMBEDDED, "http://ec.framsticks.com/www/index.php?PAGE=view_genotype&ID=55") 234 Viewer.mainLoop(); 235 236 183 237 184 238 }
Note: See TracChangeset
for help on using the changeset viewer.