From 1a07a7577450778e8e7c5fda9be163eb740663c6 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Sun, 14 Jun 2015 21:57:57 +0200 Subject: [PATCH] import_functions: add searchUrlFor() which returns an url for search of given entity --- lib/import_functions.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/import_functions.js b/lib/import_functions.js index 7bc9d78..f9f561c 100644 --- a/lib/import_functions.js +++ b/lib/import_functions.js @@ -101,6 +101,17 @@ var MBReleaseImportHelper = (function() { return 'Search in MusicBrainz'; } + function fnSearchUrlFor(type, what) { + type = type.replace('-', '_'); + + var params = [ + 'query=' + luceneEscape(what), + 'type=' + type, + 'indexed=1' + ]; + return '//musicbrainz.org/search?' + params.join('&'); + } + // compute HTML of import form function fnBuildFormHTML(parameters) { @@ -345,6 +356,7 @@ var MBReleaseImportHelper = (function() { guessReleaseType: fnGuessReleaseType, hmsToMilliSeconds: hmsToMilliSeconds, ISO8601toMilliSeconds: fnISO8601toMilliSeconds, + searchUrlFor: fnSearchUrlFor, URL_TYPES: url_types }; })();