thekabal / tki

The Kabal Invasion - A web based space exploration (4x) game
Other
11 stars 7 forks source link

JQuery or other JavaScript library or framework? #50

Open urbndecay opened 8 years ago

urbndecay commented 8 years ago

I wanted to find out if there is any consideration for any specific JavaScript libraries or frameworks? Currently there is very little JS used within the project (news ticker and round ticker) which isn't a bad thing but it does limit which options are available especially later on if/when the project moves to a modern PHP framework like Symfony2 as has been discussed.

For example I am currently working on the registration page(s) (new.php, new2.php). I would like to use an AJAX form submission and validation as well as DOM manipulation for errors (password to short, name in use, etc.) and move away from the multi-page validation, error display system currently in use. Now I can do it with straight JS but requires very page specific code, less functionality and overall re-creating the wheel, while using JQuery or other library will give us overall tried and true functionality that can be re-used though the rest of the site. This is something that also couldn't be template specific either since we would still need to all templates to confirm to specific functionality (cannot use AJAX, use multi-page submissions, etc.).

This is something that we could only be included in specific pages but with something like a JavaScript library it would seem best to include it though the entire site instead of just a few pages, or worse, using multiple libraries though the site which seems like a bad idea.

I'm also not suggesting the only option is JQuery. Personally I would be happy with pretty much anything as long as we can get some modern capabilities you know? I'm just suggesting JQuery since its popular, common, easy to use and pretty much everyone will have libraries already cached in their browsers so performance shouldn't be an issue.

thekabal commented 8 years ago

Can you elaborate a bit on this part: " This is something that also couldn't be template specific either since we would still need to all templates to confirm to specific functionality (cannot use AJAX, use multi-page submissions, etc.)."

I'm not sure I follow that bit.

urbndecay commented 8 years ago

I've tried for like 20 minutes and like 5 different ways to explain why it wouldn't work, but its just too different. With the current system the 2nd page displays a template page, all the errors, and redirects you on success. With an AJAX based system a secondary page just sends/receives information. It's two totally different ways of doing something.

I mean we could continue to use the same new.php and new2.php pages and have two different ways of registering depending on if it was AJAX or not AJAX, or include a 3rd page, but that's just a bad way of doing it.

Basicaly the registration pages have to change and it can be AJAX, not AJAX, or badly both.

thekabal commented 8 years ago

I'm not opposed to the idea, in general, of using AJAX, and definitely supportive of moving away from new/new2 style pages.

That said, I'm closing in on trying to tackle adding a router to the game. I suspect that either effort would be easier to take on after that.

Lets keep this issue open and tackle it after the router issue, and https://github.com/thekabal/tki/issues/36 , I think they will all dove-tail together nicely.

jakecleary commented 8 years ago

I think your best bet is to first work on encapsulating the game's core mechanics in an API (routing!) and then hooking up a front end that just interacts with the API via AJAX calls. This came is the perfect candidate for being a single page app using ember or the like, as you can create a much more fluid experience, vital for a game to not fell too clunky.