Why did you choose to close the question instead of accepting my answers? You asked if a concept was possible and I gave you plenty of resources plus my own ideas on how you could make it work.
From your finished example it looks like you took the functions and events I mentioned and gave you reference examples of and got something working.