mirror of
https://github.com/murdos/musicbrainz-userscripts
synced 2025-03-17 23:16:56 +00:00
discogs_importer: add_mblinks() function
This commit is contained in:
parent
52a6b17908
commit
6ac8a4f740
1 changed files with 33 additions and 0 deletions
|
@ -140,6 +140,39 @@ function insertMBLinks($root) {
|
|||
}
|
||||
}
|
||||
|
||||
var add_mblinks_counter = 0;
|
||||
function add_mblinks(_root, selector, types) {
|
||||
// types can be:
|
||||
// 'discogs type 1'
|
||||
// ['discogs_type 1', 'discogs_type 2']
|
||||
// [['discogs_type 1', 'mb type 1'], 'discogs_type 2']
|
||||
// etc.
|
||||
if (!$.isArray(types)) {
|
||||
// just one string
|
||||
types = [types];
|
||||
}
|
||||
$.each(types,
|
||||
function (idx, val) {
|
||||
if (!$.isArray(val)) {
|
||||
types[idx] = [val, undefined];
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
LOGGER.debug('add_mblinks: ' + selector + ' / ' + JSON.stringify(types));
|
||||
|
||||
_root.find(selector).each(function() {
|
||||
var node = $(this).get(0);
|
||||
magnifyLinks(node);
|
||||
debug_color(this, ++add_mblinks_counter, selector);
|
||||
var that = this;
|
||||
$.each(types, function (idx, val) {
|
||||
var discogs_type = val[0];
|
||||
var mb_type = val[1];
|
||||
searchAndDisplayMbLinkInSection($(that), discogs_type, mb_type);
|
||||
});
|
||||
});
|
||||
}
|
||||
var n = 0;
|
||||
$root.find('div.profile').each(function() {
|
||||
debug_color(this, n);
|
||||
|
|
Loading…
Add table
Reference in a new issue