install.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (function($,History){
  2. var State = History.getState(),
  3. returnToIndex = function(){
  4. History.replaceState({},'Bugs','..');
  5. location = '..';
  6. };
  7. $(document).ready(function(){
  8. if($.isEmptyObject(State.data)){
  9. History.replaceState({
  10. type: 'install',
  11. id: 'config'
  12. },'Bugs');
  13. }
  14. $(window).on('statechange',function(){
  15. State = History.getState();
  16. $.get('api.php',State.data,function(d){
  17. $('body').html(d);
  18. $('#config').submit(function(){
  19. $('#install').attr('disabled','disabled');
  20. $.get('api.php?'+$("#config").serialize()+'&dbtemplate=install&type=install&id=run',function(d){
  21. if(d != "pass"){
  22. alert(d);
  23. $('#install').removeAttr('disabled');
  24. }else{
  25. if(confirm("Installation successful!\nDo you want to delete the installation files?")){
  26. $.get('api.php?&dbtemplate=install&type=install&id=cleanup',function(d){
  27. if(d != ''){
  28. alert('Error: '+d);
  29. }
  30. returnToIndex();
  31. });
  32. }else{
  33. returnToIndex();
  34. }
  35. }
  36. },'text');
  37. return false;
  38. });
  39. },'html');
  40. }).trigger('statechange');
  41. });
  42. })(jQuery,History);