diff --git a/batch-add-recording-relationships.user.js b/batch-add-recording-relationships.user.js
index 837ca61..0b4a3fe 100644
--- a/batch-add-recording-relationships.user.js
+++ b/batch-add-recording-relationships.user.js
@@ -14,6 +14,25 @@ scr.textContent = "(" + batch_recording_rels + ")();";
document.body.appendChild(scr);
function batch_recording_rels() {
+
+ function make_element(el_name, args) {
+ var el = $("<"+el_name+">"+el_name+">");
+ el.append.apply(el, args);
+ return el;
+ }
+ function td() {
+ return make_element("td", arguments);
+ }
+ function tr() {
+ return make_element("tr", arguments);
+ }
+ function table() {
+ return make_element("table", arguments);
+ }
+ function goBtn(func) {
+ return $("").click(func);
+ }
+
var $recordings = $("tr:has([href*='musicbrainz.org/recording/'])").data("filtered", false);
if (!$recordings.length) {
@@ -501,51 +520,36 @@ function batch_recording_rels() {
';
// Add button to manage performance ARs
+ var $relate_table = table(
+ tr(td("New work with this title:"),
+ td('',
+ goBtn(relate_to_new_titled_work))),
+ tr(td("Existing work (URL/MBID):"),
+ td(entity_lookup($(''), "work"),
+ goBtn(relate_to_existing_work))),
+ tr(td("New works using recording titles"),
+ td(goBtn(relate_to_new_works))),
+ tr(td("Their suggested works"),
+ td(goBtn(relate_to_suggested_works))),
+ tr(td(''),
+ td(work_type_options)),
+ tr(td(''),
+ td(work_language_options))).hide();
- var $relate_table = $("
").append(
- $("
").append(
- "New work with this title: | ",
- $(" | ").append(
- '',
- $("").click(relate_to_new_titled_work))),
- $("
").append(
- "Existing work (URL/MBID): | ",
- $(" | ").append(
- entity_lookup($(''), "work"),
- $("").click(relate_to_existing_work))),
- $("
").append(
- "New works using recording titles | ",
- $(" | ").append(
- $("").click(relate_to_new_works))),
- $("
").append(
- "Their suggested works | ",
- $(" | ").append(
- $("").click(relate_to_suggested_works))),
- $("
").append(
- ' | ',
- $(' | ').append(work_type_options)),
- $("
").append(
- ' | ',
- $(' | ').append(work_language_options))).hide();
-
- var $works_table = $("").append(
+ var $works_table = table(
$('
').append(
- "Load another artist’s works (URL/MBID): | ",
- $(" | ").append(
- entity_lookup($(''), "artist"),
- $("").click(load_artist_works_btn)))
- .hide());
+ td("Load another artist’s works (URL/MBID):"),
+ td(entity_lookup($(''), "artist"),
+ goBtn(load_artist_works_btn)))
+ .hide());
- var $container = $("").append(
- $("
").append(
- "Relate checked recordings to… | ",
- $(" | ").append(
- "Cached works
",
- $("(These are used to auto-suggest works.)")
- .css("font-size", "0.9em"))),
- $("
").append(
- $(" | ").append($relate_table),
- $(" | ").append($works_table)))
+ var $container = table(
+ tr(td("Relate checked recordings to…
"),
+ td("Cached works
",
+ $("(These are used to auto-suggest works.)")
+ .css("font-size", "0.9em"))),
+ tr(td($relate_table),
+ td($works_table)))
.css({"margin": "0.5em", "background": "#F2F2F2", "border": "1px #999 solid"})
.insertAfter($("div#content h2")[0]);
@@ -556,24 +560,21 @@ function batch_recording_rels() {
var hide_performed_recs = $.cookie('hide_performed_recs') === 'true' ? true : false;
var hide_pending_edits = $.cookie('hide_pending_edits') === 'true' ? true : false;
- var $display_table = $("").append(
- $("
").append(
- $(" | ").append(
- $("").append(
- "Filter recordings list: ",
- $('').bind("input", filter_recordings))),
- $(" | ").append(
- $("").append(
- $('')
- .bind("change", toggle_performed_recordings)
- .attr("checked", hide_performed_recs),
- "Hide recordings with performance ARs"),
- " ",
- $("").append(
- $('')
- .bind("change", toggle_pending_edits)
- .attr("checked", hide_pending_edits),
- "Hide recordings with pending edits"))))
+ var $display_table = table(
+ tr(td($("").append(
+ "Filter recordings list: ",
+ $('').bind("input", filter_recordings))),
+ td($("").append(
+ $('')
+ .bind("change", toggle_performed_recordings)
+ .attr("checked", hide_performed_recs),
+ "Hide recordings with performance ARs"),
+ " ",
+ $("").append(
+ $('')
+ .bind("change", toggle_pending_edits)
+ .attr("checked", hide_pending_edits),
+ "Hide recordings with pending edits"))))
.css("margin", "0.5em")
.insertAfter($container);