You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
// This file contains definitions which help to reduce the amount
 | 
						|
// of redunant values in the main file, especially those that could
 | 
						|
// change in the foreseeable future.
 | 
						|
 | 
						|
export const dom = {
 | 
						|
	tbl_communities: () => document.getElementById("tbl_communities"),
 | 
						|
	last_checked: () => document.getElementById("last_checked_value"),
 | 
						|
	qr_modal: (communityID) => document.getElementById(`modal_${communityID}`),
 | 
						|
	join_urls: () => document.getElementsByClassName("td_join_url"),
 | 
						|
	servers_hidden: () => document.getElementById("servers_hidden"),
 | 
						|
	snackbar: () => document.getElementById("copy-snackbar")
 | 
						|
}
 | 
						|
 | 
						|
export const COLUMN = {
 | 
						|
	IDENTIFIER:   0,  LANGUAGE:     1,  NAME:         2,
 | 
						|
	DESCRIPTION:  3,  USERS:        4,  PREVIEW:      5,
 | 
						|
	QR_CODE:      6,  JOIN_URL:     7
 | 
						|
};
 | 
						|
 | 
						|
// Reverse enum.
 | 
						|
// Takes original key-value pairs, flips them, and casefolds the new values.
 | 
						|
// Should correspond to #th_{} and .td_{} elements in communities table.
 | 
						|
export const COLUMN_LITERAL = Object.fromEntries(
 | 
						|
	Object.entries(COLUMN).map(([name, id]) => [id, name.toLowerCase()])
 | 
						|
);
 | 
						|
 | 
						|
export const COMPARISON = {
 | 
						|
	GREATER: 1, EQUAL: 0, SMALLER: -1
 | 
						|
};
 | 
						|
 | 
						|
export const ATTRIBUTES = {
 | 
						|
	SORTING: {
 | 
						|
		ACTIVE: 'data-sort',
 | 
						|
		ASCENDING: 'data-sort-asc',
 | 
						|
		COLUMN: 'data-sorted-by',
 | 
						|
		COLUMN_LITERAL: 'sorted-by'
 | 
						|
	}
 | 
						|
};
 | 
						|
 | 
						|
export function columnAscendingByDefault(column) {
 | 
						|
	return column != COLUMN.USERS;
 | 
						|
}
 | 
						|
 | 
						|
export function columnIsSortable(column) { return column != COLUMN.QR_CODE; }
 | 
						|
 | 
						|
export function columnNeedsCasefold(column) {
 | 
						|
	return [
 | 
						|
		COLUMN.IDENTIFIER,
 | 
						|
		COLUMN.NAME,
 | 
						|
		COLUMN.DESCRIPTION
 | 
						|
	].includes(column);
 | 
						|
}
 | 
						|
 | 
						|
export function columnIsNumeric(column) {
 | 
						|
	return [
 | 
						|
		COLUMN.USERS
 | 
						|
	].includes(column);
 | 
						|
}
 | 
						|
 |