Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 4x 5x 5x 5x 4x 14x 14x 14x 4x 5x 6x 6x 6x 6x 4x 3x 3x 3x 3x 3x 3x 2x 1x 3x | import { getFileType, getFileName } from "./utils/helpers";
// Return an array of all the <audio> elements found on the page.
export const findAudio = context => {
// Get all the <audio> occurrences in the page.
let audioElements = context.getElementsByTagName("audio");
// Save our audioElements as an array (so we can manipulate the DOM but
// still access our items).
let items = [].slice.call(audioElements);
return items;
};
// Build an array of classes to add to each new "player" element
export const prepareClasses = (index, classes, theme) => {
const classesString = `picobel loading picobel--index-${index} ${classes}`;
const classesArray = classesString.trim().split(" ");
return [...classesArray, theme];
};
// Get the url for each audio file we want to load [using elements found by findAudio()]
export const getRawData = nodes =>
nodes.map((node, key) => {
node.key = key;
node.mute = false;
node.tmpVolume = 1;
return node;
});
// Get info about the audio track
export const getMeta = item => {
let meta = {};
// Get the filename and type
meta.url = item.currentSrc;
meta.fileType = getFileType(meta.url);
meta.fileName = getFileName(meta.url);
// If there is a valid title, get that title, otherwise get the file name.
meta.title =
item.title && item.title !== ""
? item.title
: `${meta.fileName}.${meta.fileType}`;
// If there is a valid 'artist', get the artist name.
if (item.dataset) {
meta.artist = item.dataset.artist ? item.dataset.artist : false;
} else {
meta.artist = false;
}
return meta;
};
|