From 3cf9ec77b069b09d978983ec38b48314f8d6187b Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Mon, 10 Dec 2018 16:14:39 -0600 Subject: [PATCH] Finished --- 09week/towers-of-hanoi/index.html | 22 +++++++++++++++------- 09week/towers-of-hanoi/script.js | 20 +++++++++++++++++++- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/09week/towers-of-hanoi/index.html b/09week/towers-of-hanoi/index.html index 2c7189c758..9f4731f04d 100644 --- a/09week/towers-of-hanoi/index.html +++ b/09week/towers-of-hanoi/index.html @@ -1,23 +1,31 @@ + Towers of Hanoi + -
-
-
-
-
+

Towers of Hanoi

+
+
+
+
+
-
+
-
+
+ + +
+ + diff --git a/09week/towers-of-hanoi/script.js b/09week/towers-of-hanoi/script.js index ba46e37e29..3ab32508f9 100644 --- a/09week/towers-of-hanoi/script.js +++ b/09week/towers-of-hanoi/script.js @@ -1,5 +1,23 @@ 'use strict'; $(document).ready(function() { - // Put app logic here + $('.draggable').draggable({ + revert: "invalid" + }); + + $('#dropArea, #dropArea2, #dropArea3').droppable({ + drop: function(event, ui) { + let drag = $(ui.draggable).data('block'); + console.log(`current block ${drag}`); + let last = $(this).children().last().data('block'); + console.log(`last ${last}`); + if ((drag) > (last)) { + $(ui.draggable).draggable('option', 'revert', true); + } else { + $(ui.draggable).appendTo($(this)).attr('style', 'position: relative'); + } + } + }); }); + +