--- /dev/null
+$(function() {\r
+ var body = $('body'), form = $('form'), notes = $('.notes');\r
+ \r
+ // remove no js error\r
+ body.find('.nojs').remove();\r
+ \r
+ // Do some fancy fading in, and get rid of that damn error.\r
+ body.hide().fadeIn()\r
+ \r
+ // remove previous notifications\r
+ var remove_notes = function() {\r
+ notes.find('p').remove();\r
+ notes.hide();\r
+ };\r
+ \r
+ // Check when the MySQL form has been submitted, and AJAX a request off.\r
+ var check = function() { \r
+ // remove previous notifications\r
+ remove_notes();\r
+ \r
+ // dim fieldset\r
+ $('#diagnose').animate({'opacity': 0.5}, 250, function() {\r
+ $.ajax({\r
+ 'type': 'POST',\r
+ 'url': 'diagnose.php',\r
+ 'data': form.serialize(),\r
+ 'success': check_result\r
+ });\r
+ });\r
+ \r
+ return false;\r
+ };\r
+ \r
+ var check_result = function(data) {\r
+ $('#diagnose').animate({'opacity': 1});\r
+\r
+ if(data == 'good') {\r
+ notes.show().append('<p class="success">✓ Database test successful.</p>').fadeIn();\r
+ } else {\r
+ notes.show().append('<p class="error">' + data + '</p>').fadeIn();\r
+ }\r
+ };\r
+ \r
+ var submit = function() {\r
+ $.ajax({\r
+ 'type': 'POST',\r
+ 'url': 'installer.php',\r
+ 'data': form.serialize(),\r
+ 'dataType': 'json',\r
+ 'success': submit_result\r
+ });\r
+\r
+ return false;\r
+ };\r
+ \r
+ var submit_result = function(data) {\r
+ // remove previous notifications\r
+ remove_notes();\r
+\r
+ if(data.installed) {\r
+ var content = $('.content');\r
+ \r
+ content.animate({'opacity': 0}, function() {\r
+ var btn_text = 'Continue to your site.';\r
+\r
+ var html = '<h2>Thanks for installing!</h2>';\r
+ html += '<p>We created an account for you.<br>The username is <b>admin</b>, and the password is <strong>' + data.password + '</strong>.</p>';\r
+\r
+ if(data.warnings.length) {\r
+ btn_text = 'OK, I understand, Continue to your site.';\r
+\r
+ html += '<ul style="padding-bottom: 1em;">';\r
+\r
+ for(var i = 0; i < data.warnings.length; i++) {\r
+ var warn = data.warnings[i];\r
+ html += '<li>' + warn + '</li>';\r
+ }\r
+\r
+ html += '</ul>';\r
+ }\r
+\r
+ html += '<p><a href="../" class="button" style="float: none; display: inline-block;">' + btn_text + '</a></p>';\r
+\r
+ content.html(html).animate({'opacity': 1});\r
+ });\r
+ } else {\r
+ notes.show().append('<p class="error">' + data.errors.join(', ') + '</p>').fadeIn();\r
+ }\r
+ };\r
+ \r
+ // Bind normal form submit\r
+ form.bind('submit', submit);\r
+ \r
+ // Bind db check\r
+ $('a[href$=#check]').bind('click', check);\r
+});\r