mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-04 02:53:06 +00:00 
			
		
		
		
	Properly fix no-unused-vars warning
This commit is contained in:
		@@ -39,21 +39,21 @@ $(function () {
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
function createQuickNotif (msg) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function createQuickNotif (msg) {
 | 
			
		||||
  const el = document.createElement('li')
 | 
			
		||||
  el.textContent = msg
 | 
			
		||||
  el.addEventListener('click', () => el.parentNode.removeChild(el))
 | 
			
		||||
  document.getElementById('quick_notif').appendChild(el)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function deleteQuickNotifs () { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function deleteQuickNotifs () {
 | 
			
		||||
  const el = document.getElementById('quick_notif')
 | 
			
		||||
  while (el.firstChild) {
 | 
			
		||||
    el.removeChild(el.firstChild)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function display_notif () { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function display_notif () {
 | 
			
		||||
  $('#header_notif').toggle().parent().toggleClass('white')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -63,11 +63,11 @@ function display_notif () { // eslint-disable-line no-unused-vars
 | 
			
		||||
// Sadly, getting the cookie is not possible with CSRF_COOKIE_HTTPONLY or CSRF_USE_SESSIONS is True
 | 
			
		||||
// So, the true workaround is to get the token from the dom
 | 
			
		||||
// https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-true
 | 
			
		||||
function getCSRFToken () { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function getCSRFToken () {
 | 
			
		||||
  return $('[name=csrfmiddlewaretoken]').val()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const initialUrlParams = new URLSearchParams(window.location.search) // eslint-disable-line no-unused-vars
 | 
			
		||||
export const initialUrlParams = new URLSearchParams(window.location.search)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @readonly
 | 
			
		||||
@@ -85,7 +85,7 @@ const History = {
 | 
			
		||||
 * @param {History} action
 | 
			
		||||
 * @param {URL | null} url
 | 
			
		||||
 */
 | 
			
		||||
function update_query_string (key, value, action = History.REPLACE, url = null) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function update_query_string (key, value, action = History.REPLACE, url = null) {
 | 
			
		||||
  if (!url) {
 | 
			
		||||
    url = new URL(window.location.href)
 | 
			
		||||
  }
 | 
			
		||||
@@ -116,7 +116,7 @@ function update_query_string (key, value, action = History.REPLACE, url = null)
 | 
			
		||||
 * @param {string} url The paginated endpoint to fetch
 | 
			
		||||
 * @return {Promise<Object[]>}
 | 
			
		||||
 */
 | 
			
		||||
async function fetch_paginated (url) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export async function fetch_paginated (url) {
 | 
			
		||||
  const max_per_page = 199
 | 
			
		||||
  const paginated_url = new URL(url, document.location.origin)
 | 
			
		||||
  paginated_url.searchParams.set('page_size', max_per_page.toString())
 | 
			
		||||
 
 | 
			
		||||
@@ -158,7 +158,7 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @param {Select2Options} options
 | 
			
		||||
 */
 | 
			
		||||
function sithSelect2 (options) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function sithSelect2 (options) {
 | 
			
		||||
  const elem = $(options.element)
 | 
			
		||||
  return elem.select2({
 | 
			
		||||
    theme: elem[0].multiple ? 'classic' : 'default',
 | 
			
		||||
@@ -180,7 +180,7 @@ function sithSelect2 (options) { // eslint-disable-line no-unused-vars
 | 
			
		||||
 * @param {Select2Object[]} source The array containing the data
 | 
			
		||||
 * @param {RemoteSourceOptions} options
 | 
			
		||||
 */
 | 
			
		||||
function local_data_source (source, options) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function local_data_source (source, options) {
 | 
			
		||||
  if (options.excluded) {
 | 
			
		||||
    const ids = options.excluded()
 | 
			
		||||
    return { data: source.filter((i) => !ids.includes(i.id)) }
 | 
			
		||||
@@ -203,7 +203,7 @@ function local_data_source (source, options) { // eslint-disable-line no-unused-
 | 
			
		||||
 * @param {string} source The url of the endpoint
 | 
			
		||||
 * @param {RemoteSourceOptions} options
 | 
			
		||||
 */
 | 
			
		||||
function remote_data_source (source, options) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function remote_data_source (source, options) {
 | 
			
		||||
  jQuery.ajaxSettings.traditional = true
 | 
			
		||||
  const params = {
 | 
			
		||||
    url: source,
 | 
			
		||||
@@ -231,7 +231,7 @@ function remote_data_source (source, options) { // eslint-disable-line no-unused
 | 
			
		||||
  return { ajax: params }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function item_formatter (user) { // eslint-disable-line no-unused-vars
 | 
			
		||||
export function item_formatter (user) {
 | 
			
		||||
  if (user.loading) {
 | 
			
		||||
    return user.text
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user