Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the order of text in the title #107

Open
unreal4u opened this issue Dec 9, 2020 · 1 comment
Open

Change the order of text in the title #107

unreal4u opened this issue Dec 9, 2020 · 1 comment

Comments

@unreal4u
Copy link

unreal4u commented Dec 9, 2020

Hi! Thanks for this great plugin, it looks very good on my magic monitor, and it loads multiple calendars just fine :)

I recently discovered that the Formula 1 had their own calendar, so I added it to the monitor.

My problem is that currently, the title will be something like this:
FORMULA 1 ETIHAD AIRWAYS ABU DHABI GRAND PRIX 2020 - PRACTICE 1

So a few replaceTitle's later I ended up with the following:

            replaceTitle: [
              ["FORMULA 1", ""],
              ["GRAND PRIX ", ""],
              ["2020 ", ""],
              ["2021 ", ""],
              ["2022 ", ""],
              // Yes I do realize I can capture the year with a regex :$
              ["PRACTICE ", "FP"],
              ["QUALIFYING", "Q"],
            ]

Result:
ETIHAD AIRWAYS ABU DHABI - FP1

Now I want to change it to the following:

FP1 Etihad Airways Abu Dhabi

Is there any way to:
a) Change the order of the text (regex probably capturing each group and displaying them in another order?)
b) Change the CamelCasing of the text

Thanks in advance!

@klaernie
Copy link
Contributor

I'd say, add another RegExp at the end:
[/^(.+)\s+\s(.+)$/, "$2 - $1"]

For changing the case I have no good idea yet, but you might be able to do it in full javascript using transform:
https://github.com/MMM-CalendarExt2/MMM-CalendarExt2/blob/master/docs/Filtering-and-Sorting.md#transforming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants