[Solved] changing track color if found keyword in comment

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

Andre_H
Posts: 415
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

[Solved] changing track color if found keyword in comment

Post by Andre_H »

Hi guys,

i try to color-code tracks (all fields of the track would be nice, but just the title would also be ok) in the main view, if a keyword is found in the tracks comment (example here "DUPLIKAT"). I used the "Highlight Bitrate" addon as a template, but the syntax of "includes" seems to fail me.

Code: Select all

// highlight track if comment contains 'DUPLIKAT'

uitools.tracklistFieldDefs.title.override({
    bindData: function ($super, div, item) {
        $super(div, item);

	var CommentCheck = item.comment;
        div.style.fontWeight = '';
        if (CommentCheck.includes('DUPLIKAT')) {
            div.style.color = 'blue';
        } else
            div.style.color = '';
    	}

});
"Application throw an exception "Cannot read properties of undefined (reading 'includes')".

Can anyone show me, what's wrong?
Last edited by Andre_H on Thu Feb 09, 2023 7:40 am, edited 1 time in total.
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
Ludek
Posts: 4947
Joined: Fri Mar 09, 2007 9:00 am

Re: Help - changing track color if found keyword in comment

Post by Ludek »

See the api reference: https://www.mediamonkey.com/docs/api/classes/Track.html

The is no comment, the is either commentShort or getCommentAsync : https://www.mediamonkey.com/docs/api/cl ... mmentAsync

So replacing by item.commentShort should work to get the comment synchronously, but is limited to 200 chars
Barry4679
Posts: 2398
Joined: Fri Sep 11, 2009 8:07 am
Location: Australia
Contact:

Re: Help - changing track color if found keyword in comment

Post by Barry4679 »

Ludek wrote: Mon Feb 06, 2023 7:51 am The is no comment, the is either commentShort or getCommentAsync
So replacing by item.commentShort should work to get the comment synchronously, but is limited to 200 chars
those documents don't list a property named commentShort.
You meant summary?
summary String
Defined in native\BaseMedia.js:1614
Gets shortened version of the track comment, max 200 characters, shortened with ellipses. Read-only. To get/set the full comment, use [[getCommentAsync]] and [[setCommentAsync]].
Want a dark skin for MM5? This is the one that works best for me .. elegant, compact & clear.
Andre_H
Posts: 415
Joined: Thu Jan 21, 2021 2:04 pm
Location: Germany

Re: Help - changing track color if found keyword in comment

Post by Andre_H »

Ludek wrote: Mon Feb 06, 2023 7:51 am So replacing by item.commentShort should work to get the comment synchronously, but is limited to 200 chars
This works, thank you.
- MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 2016 # only essential addons # my 24/7 media server
- MMW MMW 5.0.4.2690 (non-portable, shared DB & files) on Windows 10 # playing, testing skins & addons # my desktop app
- MMA Pro (2.0.0.1063) on Android 10, 11, 12 Phones & Tabs # WiFi Sync # playing

- MP3Tag, MP3Diags, MP3DirectCut, IrfanView
Post Reply