Philipp Tiefenbacher avatar Philipp Tiefenbacher committed 9282af1

fixed bugs introduced by scriptacolous additional members that get iterated in foreach, mutation aleete works!

Comments (0)

Files changed (3)

hackathonAlpha.html

 <head>
 	<link type="text/css" rel="stylesheet" href="style.css" />
 	<script src="src/libs/DataView.js"></script>
+
 	<script src="src/libs/jquery-1.6.2.min.js"></script>
+	<script type="text/javascript">
+	  $.noConflict();
+	  // Code that uses other library's $ can follow here.
+	</script>
+	
+	<script src="src/libs/scriptaculous-js-1.9.0/prototype.js" type="text/javascript"></script>
+	<script src="src/libs/scriptaculous-js-1.9.0/scriptaculous.js" type="text/javascript"></script>
+	
+
 
 	<script src="src/helpers.js"></script>
 	<script src="src/evocell.js"></script>
 
 function setup()
 {
-	ctlXRes = $('#xres')[0];
-	ctlYRes = $('#yres')[0];
-	ctlNrSims = $('#nrSims')[0];
-	ctlRandomDensity = $('#randomDensity')[0];
-	ctlFramerate = $('#framerate')[0];
+	ctlXRes = jQuery('#xres')[0];
+	ctlYRes = jQuery('#yres')[0];
+	ctlNrSims = jQuery('#nrSims')[0];
+	ctlRandomDensity = jQuery('#randomDensity')[0];
+	ctlFramerate = jQuery('#framerate')[0];
 
 	document.getElementById('c').addEventListener('contextmenu', handleContextMenu, false);
 	document.getElementById('c').addEventListener('click', handleCanvasClick, false);
 
-	document.getElementById('floatingPalette').addEventListener('click', handleFloatingPaletteClick, false);
+	//document.getElementById('floatingPalette').addEventListener('click', handleFloatingPaletteClick, false);
+
+	new Draggable('floatingPalette');
 	
-	$('#evocellFile').change(handleFileSelect);
+	jQuery('#evocellFile').change(handleFileSelect);
 	clearInterval(timer);
 
-	caCanvas = new EvoCell.CACanvas($("#c")[0]);
+	caCanvas = new EvoCell.CACanvas(jQuery("#c")[0]);
 	
 	width = 1200;
 	height = 800;
 			caSims[i] = new EvoCell.CASimulation(caCanvas, evoCellData, colWidth, rowHeight);
 		}
 	}
+
+	fillPalette(caSims[0].ruleData);
 }
 
 var delay=5;
 		var mutTarget;
 		var mutTimes;
 
+		var rule = caSims[clickedCA].ruleData;
+
 		//if (evt.button == 0) 
 		{
 			mutReg = ["?", "?", "?", "?", "?", "?", 0, 0, 0];
 			mutReg = ["?", "3", "?", "3", "?", "?", 0, 0, 0];
 			mutTarget = "3";
 
+			mutReg = [];
+			for (i = 0; i < rule.neighbourhood.length; i++)
+			{
+				mutReg[i] = document.getElementById('nPattern_' + i).value;
+			}
+			mutTarget = document.getElementById('nPattern_target').value;
+
+			
+
 			mutTimes = 1300;
 		}
 		/*
 		*/
 
 		
-		var rule = caSims[clickedCA].ruleData;
+	
 		
 		for (var i = 0; i < nrSims; i++)
 		{
 	evt.stopPropagation();
 }  
 
+
+function fillPalette(evoCellData)
+{
+	var s="<div style=\"background-color:#ccf;\">Dont hesitate...MUTATE!</div>";
+
+	
+	for (var nIndex = 0; nIndex < evoCellData.neighbourhood.length; nIndex++)
+	{
+		var neighbour = evoCellData.neighbourhood[nIndex];
+		
+		var x = neighbour[0];
+		var y = neighbour[1];
+		var posx = 55 + x*55;
+		var posy = 45 + y*25;
+
+	 	s+= "<input type=\"text\" id=\"nPattern_" + nIndex + "\" value=\"?\" style=\"position:absolute; width:40px; left:" + posx + "px; top:" + posy + "px;\" />";
+	}
+
+	var posx = 55 + 2.5 * 55;
+	var posy = 45;
+	s+="<input type=\"text\" id=\"nPattern_target\" value=\"?\" style=\"position:absolute; width:40px; left:" + posx + "px; top:" + posy + "px;\" />";
+
+	var div = document.getElementById('floatingPalette');
+	div.innerHTML = s;
+	//alert(s);
+		
+}
 function handleFloatingPaletteClick(evt)
 {
 	var coords = document.relMouseCoords(evt);
+	
 }
 
 </script>
 </head>
 <body onload="setup()">
 
-	<div id="floatingPalette" style="position:fixed; left:200px; bottom:200px; background-color:#fdd;">hello world</div>
+	<div id="floatingPalette" style="position:fixed; width:240px; height:100px; left:200px; top:200px; background-color:#fdd; cursor:move;">hello world</div>
+
 	<canvas id="c" width="1000" height="3333"></canvas>
 
 	<form name="controls" action="">

src/evocellweb.js

 	var widthExpr = "";
 	var heightExpr = "";
 	
-	for (nIndex in evoCellData.neighbourhood)
+	for (var nIndex = 0; nIndex < evoCellData.neighbourhood.length; nIndex++)
 	{
 		var neighbour = evoCellData.neighbourhood[nIndex];
 		
 
 function mutRotSym(evoCellData, vals, targetState)
 {
-	for (sidx in evoCellData.symmetries) {
+	for (var sidx = 0; sidx < evoCellData.symmetries.length; sidx++) {
 		var s = evoCellData.symmetries[sidx];
 		var idx = 0;
 		for (var j = s.length-1; j >= 0; j--)
 	gl.shaderSource(shader, sourceText);
 	gl.compileShader(shader);
 	if (gl.getShaderParameter(shader, gl.COMPILE_STATUS) == 0)
+	{
 		alert(gl.getShaderInfoLog(shader));
+		alert(sourceText);
+		alert(sourceText.substr(500));
+		alert(sourceText.substr(1000));
+		alert(sourceText.substr(1500));
+		alert(sourceText.substr(2000));
+	}
 	return shader;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.