Blame view

sources/core/js/setup.js 2.62 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
  var dbtypes;
  $(document).ready(function() {
  	dbtypes={
  		sqlite:!!$('#hasSQLite').val(),
  		mysql:!!$('#hasMySQL').val(),
  		postgresql:!!$('#hasPostgreSQL').val(),
  		oracle:!!$('#hasOracle').val(),
  		mssql:!!$('#hasMSSQL').val()
  	};
6d9380f96   Cédric Dupont   Update sources OC...
10

03e52840d   Kload   Init
11
  	$('#selectDbType').buttonset();
6d9380f96   Cédric Dupont   Update sources OC...
12

31b7f2792   Kload   Upgrade to ownclo...
13
  	if($('#hasSQLite').val()){
03e52840d   Kload   Init
14
  		$('#use_other_db').hide();
31b7f2792   Kload   Upgrade to ownclo...
15
  		$('#use_oracle_db').hide();
6d9380f96   Cédric Dupont   Update sources OC...
16
17
  	} else {
  		$('#sqliteInformation').hide();
03e52840d   Kload   Init
18
19
20
21
22
23
  	}
  	$('#adminlogin').change(function(){
  		$('#adminlogin').val($.trim($('#adminlogin').val()));
  	});
  	$('#sqlite').click(function() {
  		$('#use_other_db').slideUp(250);
31b7f2792   Kload   Upgrade to ownclo...
24
  		$('#use_oracle_db').slideUp(250);
6d9380f96   Cédric Dupont   Update sources OC...
25
  		$('#sqliteInformation').show();
03e52840d   Kload   Init
26
  	});
31b7f2792   Kload   Upgrade to ownclo...
27
  	$('#mysql,#pgsql,#mssql').click(function() {
03e52840d   Kload   Init
28
  		$('#use_other_db').slideDown(250);
31b7f2792   Kload   Upgrade to ownclo...
29
  		$('#use_oracle_db').slideUp(250);
6d9380f96   Cédric Dupont   Update sources OC...
30
  		$('#sqliteInformation').hide();
03e52840d   Kload   Init
31
  	});
31b7f2792   Kload   Upgrade to ownclo...
32

03e52840d   Kload   Init
33
34
  	$('#oci').click(function() {
  		$('#use_other_db').slideDown(250);
31b7f2792   Kload   Upgrade to ownclo...
35
  		$('#use_oracle_db').show(250);
6d9380f96   Cédric Dupont   Update sources OC...
36
  		$('#sqliteInformation').hide();
03e52840d   Kload   Init
37
38
39
40
41
42
  	});
  
  	$('input[checked]').trigger('click');
  
  	$('#showAdvanced').click(function() {
  		$('#datadirContent').slideToggle(250);
6d9380f96   Cédric Dupont   Update sources OC...
43
  		$('#databaseBackend').slideToggle(250);
03e52840d   Kload   Init
44
45
46
47
48
49
50
  		$('#databaseField').slideToggle(250);
  	});
  	$("form").submit(function(){
  		// Save form parameters
  		var post = $(this).serializeArray();
  
  		// Disable inputs
31b7f2792   Kload   Upgrade to ownclo...
51
  		$(':submit', this).attr('disabled','disabled').val($(':submit', this).data('finishing'));
03e52840d   Kload   Init
52
53
  		$('input', this).addClass('ui-state-disabled').attr('disabled','disabled');
  		$('#selectDbType').buttonset('disable');
6d9380f96   Cédric Dupont   Update sources OC...
54
55
56
57
  		$('.strengthify-wrapper, .tipsy')
  			.css('-ms-filter', '"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"')
  			.css('filter', 'alpha(opacity=30)')
  			.css('opacity', .3);
03e52840d   Kload   Init
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  
  		// Create the form
  		var form = $('<form>');
  		form.attr('action', $(this).attr('action'));
  		form.attr('method', 'POST');
  
  		for(var i=0; i<post.length; i++){
  			var input = $('<input type="hidden">');
  			input.attr(post[i]);
  			form.append(input);
  		}
  
  		// Submit the form
  		form.appendTo(document.body);
  		form.submit();
  		return false;
  	});
6d9380f96   Cédric Dupont   Update sources OC...
75

31b7f2792   Kload   Upgrade to ownclo...
76
77
  	// Expand latest db settings if page was reloaded on error
  	var currentDbType = $('input[type="radio"]:checked').val();
6d9380f96   Cédric Dupont   Update sources OC...
78

31b7f2792   Kload   Upgrade to ownclo...
79
  	if (currentDbType === undefined){
03e52840d   Kload   Init
80
81
  		$('input[type="radio"]').first().click();
  	}
6d9380f96   Cédric Dupont   Update sources OC...
82
83
84
85
86
  
  	if (
  		currentDbType === 'sqlite' ||
  		(dbtypes.sqlite && currentDbType === undefined)
  	){
31b7f2792   Kload   Upgrade to ownclo...
87
  		$('#datadirContent').hide(250);
6d9380f96   Cédric Dupont   Update sources OC...
88
  		$('#databaseBackend').hide(250);
31b7f2792   Kload   Upgrade to ownclo...
89
90
  		$('#databaseField').hide(250);
  	}
6d9380f96   Cédric Dupont   Update sources OC...
91
92
93
94
95
96
97
98
99
100
101
  
  	$('#adminpass').strengthify({
  		zxcvbn: OC.linkTo('3rdparty','zxcvbn/js/zxcvbn.js'),
  		titles: [
  			t('core', 'Very weak password'),
  			t('core', 'Weak password'),
  			t('core', 'So-so password'),
  			t('core', 'Good password'),
  			t('core', 'Strong password')
  		]
  	});
03e52840d   Kload   Init
102
  });