refactor: migrate frontend todo page
This commit is contained in:
@@ -38,3 +38,18 @@ export function getWeekday(date: Date): number {
|
||||
if (day == 0) return 6;
|
||||
else return day - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape HTML special characters in the string and convert newlines to `<br />`
|
||||
* so it can be safely inserted via `v-html`. Port of the legacy jQuery-based
|
||||
* `LineBreaker2Br` (`$('<div>').text(strl).html().replace(/\n/g, '<br />')`).
|
||||
* @param strl The raw string to convert.
|
||||
* @returns The escaped, newline-broken HTML string.
|
||||
*/
|
||||
export function lineBreaker2Br(strl: string): string {
|
||||
return strl
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/\n/g, '<br />');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user