Skip to content

Commit

Permalink
Handle hyperlinks searching for albums with " - [Deluxe Edition]" app…
Browse files Browse the repository at this point in the history
…ended to album name
  • Loading branch information
kbuffington committed Jul 11, 2020
1 parent 25fda9e commit 77f2bc1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions js/hyperlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Hyperlink(text, font, type, x_offset, y_offset, container_w) {
this.y = y_offset;
this.container_w = container_w;
this.state = HyperlinkStates.Normal;

var link_dimensions;

this.get_w = function () {
Expand Down Expand Up @@ -59,7 +59,7 @@ function Hyperlink(text, font, type, x_offset, y_offset, container_w) {
this.hoverFont = gdi.font(font.Name, font.Size, font.Style | g_font_style.underline);
link_dimensions = this.updateDimensions();
}

this.setFont(font);
}

Expand Down Expand Up @@ -89,6 +89,18 @@ Hyperlink.prototype.repaint = function () {

Hyperlink.prototype.click = function () {
var query = this.type + ' IS ' + this.text;
var populatePlaylist = function (query) {
var handle_list = fb.GetQueryItems(fb.GetLibraryItems(), query);
if (handle_list.Count) {
var pl = plman.FindOrCreatePlaylist('Search', true);
plman.ClearPlaylist(pl);
plman.InsertPlaylistItems(pl, 0, handle_list);
plman.SortByFormat(pl, '$if2(%artist sort order%,%album artist%) $if3(%album sort order%,%original release date%,%date%) %album% %edition% %codec% %discnumber% %tracknumber%');
plman.ActivePlaylist = pl;
return true;
}
return false;
}

if (this.type === 'update') {
// get update
Expand All @@ -97,13 +109,12 @@ Hyperlink.prototype.click = function () {
if (this.type === 'date') {
query = '"$year(%date%)" IS ' + this.text;
}
var handle_list = fb.GetQueryItems(fb.GetLibraryItems(), query);
if (handle_list.Count) {
var pl = plman.FindOrCreatePlaylist('Search', true);
plman.ClearPlaylist(pl);
plman.InsertPlaylistItems(pl, 0, handle_list);
plman.SortByFormat(pl, '$if2(%artist sort order%,%album artist%) $if3(%album sort order%,%original release date%,%date%) %album% %edition% %codec% %discnumber% %tracknumber%');
plman.ActivePlaylist = pl;
if (!populatePlaylist(query)) {
var start = this.text.indexOf('[');
if (start) {
query = this.type + ' IS ' + this.text.substr(0, start - 3); // remove ' - [...]' from end of string
populatePlaylist(query);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
* ~Hide large date if none was found.~ (implemented in 1.1.9)
* ~If too many label/genre tags ensure hyperlinks do not overlap in playlist~ (implemented in 1.1.9)
* Add option to draw labels directly on background
* Handle issues with hyperlink searching with extra information (i.e. "[Deluxe Edition]")
* ~Handle issues with hyperlink searching with extra information (i.e. "[Deluxe Edition]")~ (implemented in 1.1.9)

0 comments on commit 77f2bc1

Please sign in to comment.