setup.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var dbtypes;
  2. $(document).ready(function() {
  3. dbtypes={
  4. sqlite:!!$('#hasSQLite').val(),
  5. mysql:!!$('#hasMySQL').val(),
  6. postgresql:!!$('#hasPostgreSQL').val(),
  7. oracle:!!$('#hasOracle').val(),
  8. mssql:!!$('#hasMSSQL').val()
  9. };
  10. $('#selectDbType').buttonset();
  11. if($('#hasSQLite').val()){
  12. $('#use_other_db').hide();
  13. $('#use_oracle_db').hide();
  14. }
  15. $('#adminlogin').change(function(){
  16. $('#adminlogin').val($.trim($('#adminlogin').val()));
  17. });
  18. $('#sqlite').click(function() {
  19. $('#use_other_db').slideUp(250);
  20. $('#use_oracle_db').slideUp(250);
  21. });
  22. $('#mysql,#pgsql,#mssql').click(function() {
  23. $('#use_other_db').slideDown(250);
  24. $('#use_oracle_db').slideUp(250);
  25. });
  26. $('#oci').click(function() {
  27. $('#use_other_db').slideDown(250);
  28. $('#use_oracle_db').show(250);
  29. });
  30. $('input[checked]').trigger('click');
  31. $('#showAdvanced').click(function() {
  32. $('#datadirContent').slideToggle(250);
  33. $('#databaseBackend').slideToggle(250);
  34. $('#databaseField').slideToggle(250);
  35. });
  36. $("form").submit(function(){
  37. // Save form parameters
  38. var post = $(this).serializeArray();
  39. // Disable inputs
  40. $(':submit', this).attr('disabled','disabled').val($(':submit', this).data('finishing'));
  41. $('input', this).addClass('ui-state-disabled').attr('disabled','disabled');
  42. $('#selectDbType').buttonset('disable');
  43. // Create the form
  44. var form = $('<form>');
  45. form.attr('action', $(this).attr('action'));
  46. form.attr('method', 'POST');
  47. for(var i=0; i<post.length; i++){
  48. var input = $('<input type="hidden">');
  49. input.attr(post[i]);
  50. form.append(input);
  51. }
  52. // Submit the form
  53. form.appendTo(document.body);
  54. form.submit();
  55. return false;
  56. });
  57. // Expand latest db settings if page was reloaded on error
  58. var currentDbType = $('input[type="radio"]:checked').val();
  59. if (currentDbType === undefined){
  60. $('input[type="radio"]').first().click();
  61. }
  62. if (currentDbType === 'sqlite' || (dbtypes.sqlite && currentDbType === undefined)){
  63. $('#datadirContent').hide(250);
  64. $('#databaseBackend').hide(250);
  65. $('#databaseField').hide(250);
  66. }
  67. $('#adminpass').strengthify({
  68. zxcvbn: OC.linkTo('3rdparty','zxcvbn/js/zxcvbn.js'),
  69. titles: [
  70. t('core', 'Very weak password'),
  71. t('core', 'Weak password'),
  72. t('core', 'So-so password'),
  73. t('core', 'Good password'),
  74. t('core', 'Strong password')
  75. ]
  76. });
  77. });