setup.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. };
  9. $('#selectDbType').buttonset();
  10. // change links inside an info box back to their default appearance
  11. $('#selectDbType p.info a').button('destroy');
  12. if($('#hasSQLite').val()){
  13. $('#use_other_db').hide();
  14. $('#use_oracle_db').hide();
  15. } else {
  16. $('#sqliteInformation').hide();
  17. }
  18. $('#adminlogin').change(function(){
  19. $('#adminlogin').val($.trim($('#adminlogin').val()));
  20. });
  21. $('#sqlite').click(function() {
  22. $('#use_other_db').slideUp(250);
  23. $('#use_oracle_db').slideUp(250);
  24. $('#sqliteInformation').show();
  25. $('#dbname').attr('pattern','[0-9a-zA-Z$_-]+');
  26. });
  27. $('#mysql,#pgsql').click(function() {
  28. $('#use_other_db').slideDown(250);
  29. $('#use_oracle_db').slideUp(250);
  30. $('#sqliteInformation').hide();
  31. $('#dbname').attr('pattern','[0-9a-zA-Z$_-]+');
  32. });
  33. $('#oci').click(function() {
  34. $('#use_other_db').slideDown(250);
  35. $('#use_oracle_db').show(250);
  36. $('#sqliteInformation').hide();
  37. $('#dbname').attr('pattern','[0-9a-zA-Z$_-.]+');
  38. });
  39. $('#showAdvanced').click(function(e) {
  40. e.preventDefault();
  41. $('#datadirContent').slideToggle(250);
  42. $('#databaseBackend').slideToggle(250);
  43. $('#databaseField').slideToggle(250);
  44. });
  45. $("form").submit(function(){
  46. // Save form parameters
  47. var post = $(this).serializeArray();
  48. // Show spinner while finishing setup
  49. $('.float-spinner').show(250);
  50. // Disable inputs
  51. $(':submit', this).attr('disabled','disabled').val($(':submit', this).data('finishing'));
  52. $('input', this).addClass('ui-state-disabled').attr('disabled','disabled');
  53. // only disable buttons if they are present
  54. if($('#selectDbType').find('.ui-button').length > 0) {
  55. $('#selectDbType').buttonset('disable');
  56. }
  57. $('.strengthify-wrapper, .tipsy')
  58. .css('-ms-filter', '"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"')
  59. .css('filter', 'alpha(opacity=30)')
  60. .css('opacity', 0.3);
  61. // Create the form
  62. var form = $('<form>');
  63. form.attr('action', $(this).attr('action'));
  64. form.attr('method', 'POST');
  65. for(var i=0; i<post.length; i++){
  66. var input = $('<input type="hidden">');
  67. input.attr(post[i]);
  68. form.append(input);
  69. }
  70. // Add redirect_url
  71. var redirectURL = getURLParameter('redirect_url');
  72. if (redirectURL) {
  73. var redirectURLInput = $('<input type="hidden">');
  74. redirectURLInput.attr({
  75. name: 'redirect_url',
  76. value: redirectURL
  77. });
  78. form.append(redirectURLInput);
  79. }
  80. // Submit the form
  81. form.appendTo(document.body);
  82. form.submit();
  83. return false;
  84. });
  85. // Expand latest db settings if page was reloaded on error
  86. var currentDbType = $('input[type="radio"]:checked').val();
  87. if (currentDbType === undefined){
  88. $('input[type="radio"]').first().click();
  89. }
  90. if (
  91. currentDbType === 'sqlite' ||
  92. (dbtypes.sqlite && currentDbType === undefined)
  93. ){
  94. $('#datadirContent').hide(250);
  95. $('#databaseBackend').hide(250);
  96. $('#databaseField').hide(250);
  97. $('.float-spinner').hide(250);
  98. }
  99. $('#adminpass').strengthify({
  100. zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
  101. titles: [
  102. t('core', 'Very weak password'),
  103. t('core', 'Weak password'),
  104. t('core', 'So-so password'),
  105. t('core', 'Good password'),
  106. t('core', 'Strong password')
  107. ],
  108. drawTitles: true,
  109. nonce: btoa(OC.requestToken),
  110. });
  111. });