From 4e84c98a1b79b7b487dd1c223a11fa693caba89f Mon Sep 17 00:00:00 2001 From: Daniel Brunner <0xFEEDC0DE64@gmail.com> Date: Wed, 30 Nov 2016 12:02:18 +0100 Subject: [PATCH] Colors now can be changed --- index.html | 6 +++--- script.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 6c8aedd..b1e8518 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,6 @@ position: absolute; width: 30px; height: 30px; - background-color: #000; } @@ -98,7 +97,7 @@ -
+
Kollisionen: @@ -121,7 +120,7 @@
-
+
Segmente: @@ -133,6 +132,7 @@ ID Position Geschwindigkeit + Farbe Aktionen diff --git a/script.js b/script.js index be8edef..21523e5 100644 --- a/script.js +++ b/script.js @@ -144,14 +144,23 @@ $(document).ready(function($) { this.id = entityId++; this.position = new Vector2(); this.speed = new Vector2(); - this.elem = $('
').addClass('point').appendTo('body'); + var elem = this.elem = $('
').addClass('point').appendTo('body'); this.row = $('').appendTo('#table_entities'); this.columns = { id: $('').text(this.id).appendTo(this.row), position: $('').appendTo(this.row), speed: $('').appendTo(this.row), + color: $('').appendTo(this.row), actions: $('').appendTo(this.row), } + $('') + .attr('type', 'color') + .change(function(){ + console.log($(this).val()); + elem.css('background-color', $(this).val()); + }) + .appendTo(this.columns.color) + .change(); } };