MediaWiki:Common.js: Difference between revisions
Client-side filter: hide bare NG non-graduate research-note markers |
Add Internet Archive click-to-play embeds for interview watchlist |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 664: | Line 664: | ||
ev.preventDefault(); | ev.preventDefault(); | ||
playSoundCloud($slot, trackId, title); | playSoundCloud($slot, trackId, title); | ||
}); | |||
}); | |||
}()); | |||
(function buildAviaryEmbeds() { | |||
var AV_MEDIA = /^[0-9]{4,12}$/; | |||
function playAviary($slot, mediaId, title) { | |||
var src = 'https://milken.aviaryplatform.com/embed/media/' + | |||
encodeURIComponent(mediaId) + | |||
'?embed=true&media_player=true'; | |||
var $iframe = $('<iframe class="aviary-embed-frame" allowfullscreen allow="autoplay; encrypted-media; fullscreen; picture-in-picture"></iframe>') | |||
.attr({ | |||
src: src, | |||
title: title || 'Aviary media', | |||
loading: 'lazy' | |||
}); | |||
$slot.empty().append($iframe).addClass('aviary-embed-playing'); | |||
} | |||
$('.mw-parser-output .aviary-embed[data-aviary-media]').each(function () { | |||
var $slot = $(this); | |||
if ($slot.data('rbAviaryEmbed')) { | |||
return; | |||
} | |||
var mediaId = String($slot.attr('data-aviary-media') || ''); | |||
if (!AV_MEDIA.test(mediaId)) { | |||
return; | |||
} | |||
$slot.data('rbAviaryEmbed', 1); | |||
var title = String($slot.attr('data-title') || 'Aviary media'); | |||
var playLabel = String($slot.attr('data-play-label') || 'Play video'); | |||
var $fallback = $slot.find('.aviary-embed-fallback').first(); | |||
var $btn = $('<button type="button" class="aviary-embed-play"></button>') | |||
.attr('aria-label', playLabel + ' — ' + title) | |||
.append($('<span class="aviary-embed-play-icon" aria-hidden="true"></span>')) | |||
.append($('<span class="aviary-embed-play-text"></span>').text(playLabel)); | |||
var $poster = $('<div class="aviary-embed-poster"></div>').append($btn); | |||
if ($fallback.length) { | |||
$fallback.before($poster); | |||
$fallback.hide(); | |||
} else { | |||
$slot.prepend($poster); | |||
} | |||
$poster.on('click', function (ev) { | |||
ev.preventDefault(); | |||
playAviary($slot, mediaId, title); | |||
}); | |||
}); | |||
}()); | |||
(function buildInternetArchiveEmbeds() { | |||
// archive.org item identifiers (e.g. RobertA.Potash13january2012YiddishBookCenter) | |||
var IA_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{5,120}$/; | |||
function playInternetArchive($slot, itemId, title) { | |||
var src = 'https://archive.org/embed/' + encodeURIComponent(itemId); | |||
var $iframe = $('<iframe class="ia-embed-frame" allowfullscreen allow="autoplay; encrypted-media; fullscreen; picture-in-picture"></iframe>') | |||
.attr({ | |||
src: src, | |||
title: title || 'Internet Archive media', | |||
loading: 'lazy' | |||
}); | |||
$slot.empty().append($iframe).addClass('ia-embed-playing'); | |||
} | |||
$('.mw-parser-output .ia-embed[data-archive-id]').each(function () { | |||
var $slot = $(this); | |||
if ($slot.data('rbIaEmbed')) { | |||
return; | |||
} | |||
var itemId = String($slot.attr('data-archive-id') || ''); | |||
if (!IA_ID.test(itemId)) { | |||
return; | |||
} | |||
$slot.data('rbIaEmbed', 1); | |||
var title = String($slot.attr('data-title') || 'Internet Archive media'); | |||
var playLabel = String($slot.attr('data-play-label') || 'Play interview'); | |||
var $fallback = $slot.find('.ia-embed-fallback').first(); | |||
var $btn = $('<button type="button" class="ia-embed-play"></button>') | |||
.attr('aria-label', playLabel + ' — ' + title) | |||
.append($('<span class="ia-embed-play-icon" aria-hidden="true"></span>')) | |||
.append($('<span class="ia-embed-play-text"></span>').text(playLabel)); | |||
var $poster = $('<div class="ia-embed-poster"></div>').append($btn); | |||
if ($fallback.length) { | |||
$fallback.before($poster); | |||
$fallback.hide(); | |||
} else { | |||
$slot.prepend($poster); | |||
} | |||
$poster.on('click', function (ev) { | |||
ev.preventDefault(); | |||
playInternetArchive($slot, itemId, title); | |||
}); | }); | ||
}); | }); | ||
| Line 1,336: | Line 1,429: | ||
{ key: 'death_year', label: 'Death year', hint: 'Four digits, e.g. 2001' }, | { key: 'death_year', label: 'Death year', hint: 'Four digits, e.g. 2001' }, | ||
{ key: 'nativity', label: 'Nativity (birthplace)' }, | { key: 'nativity', label: 'Nativity (birthplace)' }, | ||
{ key: 'religion', label: 'Religion | { key: 'religion', label: 'Religion' } | ||
] | ] | ||
}, | }, | ||
| Line 1,362: | Line 1,451: | ||
collapsed: true, | collapsed: true, | ||
fields: [ | fields: [ | ||
{ key: 'other_class', label: 'Other class' }, | { | ||
key: 'other_class', | |||
label: 'Other class', | |||
hint: 'Roster code, e.g. SC8, DC36, MITU4 (shown expanded on the page)' | |||
}, | |||
{ key: 'division', label: 'Unit / division' }, | { key: 'division', label: 'Unit / division' }, | ||
{ key: 'loc', label: 'LOC | { key: 'loc', label: 'LOC' } | ||
] | ] | ||
} | } | ||