YaWK  24.1
Yet another WebKit
setupHelper.js
Go to the documentation of this file.
1 $(document).ready(function() { // wait until document is ready
2  $(function() {
3  $('[data-toggle="tooltip"]').tooltip();
4  });
5 
6 // This file is a helper to check the database credentials via xhr
7 // Get the form element
8  const form = document.getElementById('installerForm');
9 // Add an event listener to the form submit event
10  form.addEventListener('submit', (event) => {
11  event.preventDefault(); // prevent the form from submitting
12 
13  // store save button in variable
14  const saveBtn = $("#savebutton");
15 
16  // Get the form data
17  const formData = new FormData(form);
18 
19  // Send an AJAX request to the server
20  fetch('system/setup/checkDatabaseCredentials.php', {
21  method: 'POST',
22  body: formData
23  })
24  // Get the response as JSON
25  .then(response => response.json()) // Parse the JSON response
26  .then(data => {
27  // Handle the response data
28  if (data.success)
29  { // Credentials are valid, continue with installation
30 
31  // indicate loading state, change button text and icon
32  $(saveBtn).removeClass('btn btn-success').html('<small>2/5</small> '+data.DB_IMPORT_BTN+' &nbsp;<i class=\"fa fa-spinner fa-spin fa-fw\"></i>').addClass('btn btn-warning disabled');
33 
34  // submit form
35  form.submit();
36 
37  // disable save button to prevent double submission if user clicks multiple times
38  $(saveBtn).prop('disabled', true);
39 
40  // credentials are valid, display success message
41  $.notify({
42  // options
43  title: '<h4><i class=\"fa fa-database\"></i>&nbsp; '+data.message+'</h4>',
44  message: '<b>'+data.importmsg+'</b>',
45  }, {
46  // settings
47  type: 'success',
48  element: 'body',
49  position: null,
50  allow_dismiss: 'false',
51  newest_on_top: 'true',
52  placement: {
53  from: 'top',
54  align: 'center'
55  },
56  offset: {
57  x: 10,
58  y: 62
59  },
60  spacing: 10,
61  z_index: 9999,
62  delay: 6200,
63  timer: 420,
64  mouse_over: 'pause',
65  animate: {
66  enter: 'animated fadeInDown',
67  exit: 'animated fadeOutUp'
68  }
69  });
70  }
71  else
72  { // Credentials are invalid, display error message
73  $.notify({
74  // options
75  title: '<h4><i class=\"fa fa-database\"></i>&nbsp; '+data.message+'</h4>',
76  message: '<b>'+data.subline+'</b>',
77  }, {
78  // settings
79  type: 'danger',
80  element: 'body',
81  position: null,
82  allow_dismiss: 'false',
83  newest_on_top: 'true',
84  placement: {
85  from: 'top',
86  align: 'center'
87  },
88  offset: {
89  x: 10,
90  y: 62
91  },
92  spacing: 10,
93  z_index: 9999,
94  delay: 4200,
95  timer: 420,
96  mouse_over: 'pause',
97  animate: {
98  enter: 'animated fadeInDown',
99  exit: 'animated fadeOutUp'
100  }
101  });
102 
103  // change button text and icon
104  $(saveBtn).html('2/5 '+data.checkagain+' &nbsp;<i id="savebuttonIcon" class="fa fa-refresh"></i>').removeClass().addClass('btn btn-success pull-right');
105  }
106  })
107  .catch(error => {
108  // Handle any errors that occurred during the request
109  console.error(error);
110  });
111  });
112 }); // END document ready
c jPlayer event
c jPlayer error
type
Definition: menu-new.php:35
exit
print $page title
Definition: page-edit.php:377
function y(e, n)
Definition: plyr.js:1
function x()
Definition: plyr.js:1
document ready(function() { $('a[data-confirm]').click(function(ev) { modal='#dataConfirmModal';var href=$(this).attr('href');var title=$(this).attr('title');var icon=$(this).attr('data-icon');if(!icon) { icon='fa fa-trash-o';} if(!$(modal).length) { $('body').append('< div id="dataConfirmModal" class="modal fade" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true">< div class="modal-dialog">< div class="modal-content">< div class="modal-header">< button type="button" class="close" data-dismiss="modal" aria-hidden="true">< i class="fa fa-times"></i ></button >< br >< div class="col-md-1">< h3 class="modal-title">< i class="'+icon+'"></i ></h3 ></div >< div class="col-md-11">< h3 class="modal-title" id="dataConfirmLabel">'+title+'</h3 ></div ></h3 ></div >< div class="modal-body"></div >< div class="modal-footer">< button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Abbrechen</button >< a type="button" class="btn btn-danger" id="dataConfirmOK">< i class="'+icon+'"></i > L &ouml;schen</a ></div ></div ></div ></div >');} $(modal).find('.modal-body').text($(this).attr('data-confirm'));$('#dataConfirmOK').attr('href', href);$(modal).modal({show:true});return false;});$('#terminateUser').click(function() { var terminate=window.confirm("ACHTUNG!\nDas wird Deinen Account permanent deaktivieren.\n"+"Bist Du Dir sicher, dass Du das tun willst?");if(terminate===true) { var terminateUser=window.confirm("Bist Du Dir wirklich ganz sicher?\n"+"Diese Aktion kann nicht rueckgaengig gemacht werden.");if(terminateUser===true) { $.get('system/templates/YaWK-bootstrap3/js/terminate-user.php', function(data) { if(data==="true") { setTimeout("window.location='logout.html'", 0);} else { alert("Fehler: "+data);} });} } });function dismissNotifications() { $.ajax({ url:'js/dismiss-notifications.php', type:'POST', success:function(data) { if(!data) { alert('Something went wrong!');return false;} } });$("#bell-label").fadeOut();$('#notification-header').html('You have 0 notifications');$('#notification-menu').fadeOut();} $("#dismiss").click(function() { dismissNotifications();});function disableButtons(delay) { $('#loginButton').removeClass().addClass('btn btn-success disabled').attr('id', 'LOGIN_FORBIDDEN');$('#resetPasswordButton').removeClass().addClass('btn btn-danger disabled');setTimeout(function() { $('#LOGIN_FORBIDDEN').attr('id', 'loginButton').removeClass().addClass('btn btn-success');$('#resetPasswordButton').removeClass().addClass('btn btn-danger');}, delay);} $("#loginButton").click(function(){ if($('#loginButton').length > 0) { if($('#loginButton').hasClass('btn') &&$('#loginButton').hasClass('btn-success') &&$('#loginButton').hasClass('disabled')) { } else { $("#loginForm").submit();disableButtons(10000);} } else if($('#LOGIN_FORBIDDEN').length > 0) { if($('#LOGIN_FORBIDDEN').hasClass('btn') &&$('#LOGIN_FORBIDDEN').hasClass('btn-success') &&$('#LOGIN_FORBIDDEN').hasClass('disabled')) { } else { } } });$("#blockedBtn").hover(function() { $("#blockedBtn").hide();$("#askBtn").fadeIn(820);});})