“Click here” to design and build your UAV

This blog post summarizes the work I have been doing the past 8 months or so on an automated design system for (civillian) UAVs.  Ive been meaning to do this post for a long time but wanted the tools to be in a beta quality state before writing about them.  In good software engineering tradition there have been a few hiccups and detours along the way but Im happy to say beta stage has been reached.

I will go over the vision behind the system, its architecture, and the various tools I have used to put it together.  For the impatient, this is the idea: we need a system that allows us to rapidly go through this process:

Agile UAV design if you want to call it that. Tools I will talk about include PythonNumpy, RabbitMQ, Redis, Flask, Django, Bootstrap,  Knockout.jsVagrant and how they link up with application specific codes such as Ansys Fluent, SolidWorks, Vanguard and Anylogic.

This post is an extension of the talk I gave at PyConUK 2011 a couple of months ago and is also what I will cover in my upcoming talk at Imperial College and at the upcoming AIAA conference in Honolulu in April 2012.

Continue reading

jQuery confirmation dialog with bootstrap

Ive been using Twitters Bootstrap for putting together a web UI for our UAV design system (that will be partially opened up to the general public at some point).  jQuery also plays a role in this and at some point I needed an easy confirmation dialog.  I could easily have used jQueryUI as I have in the past, but I found this great plugin by Damian Antipa that does exactly what I needed & uses just jQuery and Bootstrap.

The only thing I needed to change was that I wanted the confirmation dialog (on ok) to trigger the original click() handle instead of redirecting to a different URL.  My basic patch is:

@@ -52,6 +52,17 @@
                                var o = options;
                                var $elem = $(this)
 
+                               //is there an existing click handler registered
+                               if ($elem.data('events') && $elem.data('events').click) {
+                                       //save the handler (TODO: assumes only one)
+                                       var targetClickFun = $elem.data('events').click[0].handler;
+                                       //unbind it to prevent it firing
+                                       $elem.unbind('click');
+                               }else{
+                                       //assume there is a href attribute to redirect to
+                                       var targetClickFun = function() {window.location.href = $elem.attr('href');};
+                               }
+
                                $elem.bind('click', function(e) {
                                        e.preventDefault();
                                        if(!$('#confirm-dialog').length) {
@@ -89,7 +100,8 @@
                                                $dialog.find('p.message').html(o.message);
 
                                                $dialog.find('a.btn:eq(0)').text($elem.text()).bind('click', function(e) {
-                                                       window.location.href = $elem.attr('href');
+                                                       $dialog.remove();
+                                                       targetClickFun();
                                                });
 
                                                $dialog.find('a.btn:eq(1)').text(o.cancelButton).bind('click', function(e) {

Cleaner would be to add some options and what have you.  And maybe I will come to that.  For now I put the full code in a public gist on github.  So fork ahead 🙂

–Dirk