-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add smart auto subjects and more animations
- Loading branch information
Showing
10 changed files
with
119 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* TODO:Add english smart subjects | ||
*/ | ||
|
||
type SmartDetectRule = { | ||
subject: string; | ||
pattern: RegExp; | ||
}; | ||
|
||
const genRegex = (str: string) => new RegExp(`^${str.toLowerCase()}`); | ||
|
||
const exactPairs = [ | ||
'Chemie', | ||
'Physik', | ||
'Latein', | ||
'Deutsch', | ||
'Musik', | ||
'Sport', | ||
'Spanisch', | ||
'Kunst', | ||
'Französisch' | ||
]; | ||
|
||
const rules: SmartDetectRule[] = [ | ||
...exactPairs.map((subject) => ({ subject, pattern: genRegex(subject) })), | ||
{ | ||
subject: 'Mathemathik', | ||
pattern: /^math?e/ | ||
}, | ||
{ | ||
subject: 'Informatik', | ||
pattern: /^info(rmatik)?/ | ||
}, | ||
{ | ||
subject: 'Darstellendes Spiel', | ||
pattern: /^(ds|darstellendes\s*spiel)/ | ||
}, | ||
{ | ||
subject: 'PoWi', | ||
pattern: /^(powi|politik\s+(und|&)\s+wirtschaft)/ | ||
}, | ||
{ | ||
subject: 'Geschichte', | ||
pattern: /^geschi/ | ||
}, | ||
{ | ||
subject: 'Biologie', | ||
pattern: /^bio/ | ||
}, | ||
{ | ||
subject: 'Biologie', | ||
pattern: /^reli/ | ||
} | ||
]; | ||
|
||
export function smartSubject(course: string) { | ||
const found = rules.find(({ pattern }) => pattern.test(course.toLowerCase())); | ||
return found?.subject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters