mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-11-04 01:12:08 +01:00 
			
		
		
		
	Format JS files
This commit is contained in:
		@@ -2,22 +2,22 @@
 | 
			
		||||
 * On form submit, create a new alias
 | 
			
		||||
 */
 | 
			
		||||
function create_alias (e) {
 | 
			
		||||
    // Do not submit HTML form
 | 
			
		||||
    e.preventDefault();
 | 
			
		||||
  // Do not submit HTML form
 | 
			
		||||
  e.preventDefault()
 | 
			
		||||
 | 
			
		||||
    // Get data and send to API
 | 
			
		||||
    const formData = new FormData(e.target);
 | 
			
		||||
    $.post("/api/note/alias/", {
 | 
			
		||||
        "csrfmiddlewaretoken": formData.get("csrfmiddlewaretoken"),
 | 
			
		||||
        "name": formData.get("name"),
 | 
			
		||||
        "note": formData.get("note")
 | 
			
		||||
    }).done(function () {
 | 
			
		||||
        // Reload table
 | 
			
		||||
        $("#alias_table").load(location.pathname + " #alias_table");
 | 
			
		||||
        addMsg("Alias ajouté", "success");
 | 
			
		||||
    }).fail(function (xhr, _textStatus, _error) {
 | 
			
		||||
        errMsg(xhr.responseJSON);
 | 
			
		||||
    });
 | 
			
		||||
  // Get data and send to API
 | 
			
		||||
  const formData = new FormData(e.target)
 | 
			
		||||
  $.post('/api/note/alias/', {
 | 
			
		||||
    csrfmiddlewaretoken: formData.get('csrfmiddlewaretoken'),
 | 
			
		||||
    name: formData.get('name'),
 | 
			
		||||
    note: formData.get('note')
 | 
			
		||||
  }).done(function () {
 | 
			
		||||
    // Reload table
 | 
			
		||||
    $('#alias_table').load(location.pathname + ' #alias_table')
 | 
			
		||||
    addMsg('Alias ajouté', 'success')
 | 
			
		||||
  }).fail(function (xhr, _textStatus, _error) {
 | 
			
		||||
    errMsg(xhr.responseJSON)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -25,19 +25,19 @@ function create_alias (e) {
 | 
			
		||||
 * @param Integer button_id Alias id to remove
 | 
			
		||||
 */
 | 
			
		||||
function delete_button (button_id) {
 | 
			
		||||
    $.ajax({
 | 
			
		||||
        url: "/api/note/alias/" + button_id + "/",
 | 
			
		||||
        method: "DELETE",
 | 
			
		||||
        headers: { "X-CSRFTOKEN": CSRF_TOKEN }
 | 
			
		||||
    }).done(function () {
 | 
			
		||||
        addMsg('Alias supprimé', 'success');
 | 
			
		||||
        $("#alias_table").load(location.pathname + " #alias_table");
 | 
			
		||||
    }).fail(function (xhr, _textStatus, _error) {
 | 
			
		||||
        errMsg(xhr.responseJSON);
 | 
			
		||||
    });
 | 
			
		||||
  $.ajax({
 | 
			
		||||
    url: '/api/note/alias/' + button_id + '/',
 | 
			
		||||
    method: 'DELETE',
 | 
			
		||||
    headers: { 'X-CSRFTOKEN': CSRF_TOKEN }
 | 
			
		||||
  }).done(function () {
 | 
			
		||||
    addMsg('Alias supprimé', 'success')
 | 
			
		||||
    $('#alias_table').load(location.pathname + ' #alias_table')
 | 
			
		||||
  }).fail(function (xhr, _textStatus, _error) {
 | 
			
		||||
    errMsg(xhr.responseJSON)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$(document).ready(function () {
 | 
			
		||||
    // Attach event
 | 
			
		||||
    document.getElementById("form_alias").addEventListener("submit", create_alias); 
 | 
			
		||||
})
 | 
			
		||||
  // Attach event
 | 
			
		||||
  document.getElementById('form_alias').addEventListener('submit', create_alias)
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user