install.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ready(function(){
  2. var log = dom.get('#log'),
  3. form = dom.get('form.hidden'),
  4. running = false;
  5. form.on('submit',function(e){
  6. if(!running){
  7. running = true;
  8. log.drop('*')
  9. .append(
  10. dom.create('li')
  11. .append('Running...')
  12. )
  13. .css({
  14. display: 'block'
  15. });;
  16. form.children
  17. .attr({
  18. disabled: 'disabled'
  19. });
  20. fetch('.',{
  21. method: 'post',
  22. body: new FormData(this),
  23. mode: 'cors',
  24. credentials: 'include'
  25. })
  26. .then(function(res){
  27. return res.json();
  28. })
  29. .then(function(data){
  30. if(data){
  31. for(var i in data){
  32. var ul = dom.create('ul'),
  33. step = dom.create('li').append('Step: '+i).append(ul);
  34. for(var ii in data[i]){
  35. var d = data[i][ii];
  36. ul.append(
  37. dom.create('li')
  38. .append(
  39. ii+': '+(d[0]?'<span style="color:green">PASS</span>':'<span style="color:red">FAIL</span> - '+d[1])
  40. )
  41. );
  42. }
  43. log.append(step);
  44. }
  45. log.append("<li>Don't forget to remove the install directory when you are finished</li>");
  46. }else{
  47. log.append("<li>Database Information incorrect</li>");
  48. }
  49. form.children
  50. .attr({
  51. disabled: ''
  52. });
  53. form.get('[name=uninstall]').value = '';
  54. running = false;
  55. })
  56. .catch(function(e){
  57. log.append(
  58. dom.create('li')
  59. .append('Error: '+e)
  60. );
  61. form.children
  62. .attr({
  63. disabled: ''
  64. });
  65. form.get('[name=uninstall]').value = '';
  66. running = false;
  67. });
  68. }
  69. e.stopPropagation();
  70. if(e.cancelable){
  71. e.preventDefault();
  72. }
  73. return false;
  74. })
  75. .css({
  76. display: 'block'
  77. });
  78. dom.get('#uninstall')
  79. .on('click',function(e){
  80. form.get('[name=uninstall]').value = 'Y';
  81. });
  82. });