// The builder page: file, mods with their dependencies, the two
// confirmations, build and download (the work is in builder.js).
(function () {
'use strict';
var MODS = [
{ id: 'extended_bpm', name: 'Extended BPM', by: 'arnoldasr', state: 'stable',
what: 'BPM with two decimals: the tenths as a small digit above, the hundredths below.' },
{ id: 'phasemeter', release: '2.0', name: 'Phase meter', by: 'arnoldasr', state: 'experimental',
what: 'UTILITY › PHASE METER (was SLIP FLASHING): STOCK (the four boxes), V1 (two lines), V1 REVERSE or V2 (beat rulers running past a centre line, as on the newer players). The bar countdown moved clear of the lines.' },
{ id: 'advanced_waveforms', name: 'Advanced waveforms', by: 'ours', state: 'experimental',
what: 'The big waveform in rekordbox’s RGB colours, the overview as a red-to-white gradient; UTILITY › WAVEFORM: BLUE, RGB or 3BAND (lows, mids, highs).' },
{ id: 'beatjump', name: 'Beat jump', by: 'ours', state: 'experimental', needs: 'hotcuekeys',
what: 'TRACK SEARCH ◀◀ ▶▶ jumps 1/2/4/8 beats along the beat grid, at once and in phase. UTILITY › BEAT JUMP (was SCREEN SAVER).' },
{ id: 'cuecolours', name: 'Cue colours', by: 'ours', state: 'stable',
what: 'Memory cues in their rekordbox colours; rekordbox hot cues shown as lettered boxes.' },
{ id: 'hotcuekeys', name: 'Hot cue keys', by: 'ours', state: 'experimental', needs: 'cuecolours',
what: 'Hot cues A–C on the BEAT DIVIDE keys: play, gate, set and delete, saved on the USB, loaded in the background.' },
{ id: 'ledsaver', name: 'LED animation', by: 'ours', state: 'stable',
what: 'While the screen saver dims the display, the button LEDs and the jog rings play an animation. UTILITY › LED ANIMATION.' },
{ id: 'keynotation', name: 'Key notation', by: 'ours', state: 'stable',
what: 'Every key in one notation and in its Camelot wheel colour, whatever rekordbox exported: Camelot, Open Key or classic, also in BROWSE › KEY. UTILITY › KEY NOTATION.' },
{ id: 'cuenames', name: 'Cue names', by: 'ours', state: 'stable', needs: 'cuecolours',
what: 'The rekordbox comment of the next memory cue or hot cue (“Drop”) in the title bar, in the cue’s colour.' },
{ id: 'played', name: 'Played tracks', by: 'ours', state: 'stable',
what: 'Tracks loaded tonight green in BROWSE; with modded players on Pro DJ Link also theirs, and [n] for a deck that has the track loaded now.' },
{ id: 'endwarn', name: 'End warning', by: 'ours', state: 'stable',
what: 'The bar under the overview blinks red instead of white in the last 30 seconds.' },
{ id: 'quicksearch', name: 'Quick search', by: 'ours', state: 'experimental',
what: 'BROWSE held: SEARCH; BROWSE twice: the list the playing track came from, the track picked. The screen stands still while the player finds its way there.' },
{ id: 'usbautoload', name: 'USB auto load', by: 'ours', state: 'experimental',
what: 'MY SETTINGS on a stick loaded the moment the player finds them, without the MY SETTINGS menu showing. UTILITY › USB AUTO LOAD.' },
{ id: 'wide_waveform', name: 'Wide waveform', by: 'ours', state: 'stable',
what: 'The big waveform runs on to the right edge where the ZOOM/GRID wheel was; a small grey box over the BPM display says ZOOM or GRID.' },
{ id: 'browseinfo', release: '2.0', name: 'Browse info', by: 'ours', state: 'experimental',
what: 'BPM and key on the right of every track row in BROWSE, read from the stick’s rekordbox export (the key in KEY NOTATION’s colours).' },
{ id: 'divhold', release: '2.0', name: 'Divide hold', by: 'ours', state: 'experimental',
what: 'A BEAT DIVIDE key held down keeps its divide only while it is held; a short press turns it on and off as before. UTILITY › DIVIDE HOLD.' },
{ id: 'flacplay', release: '2.0', name: 'FLAC', by: 'ours', state: 'experimental',
what: 'FLAC tracks play like WAVs: 16 and 24 bit, up to 192 kHz (above 48 kHz brought down to 44.1 or 48). Search, cues, loops, hot cues and LINK work as with a WAV.' },
{ id: 'exfatfs', release: '2.0', name: 'exFAT sticks', by: 'ours', state: 'experimental',
what: 'Sticks formatted exFAT (Windows from 64 GB, macOS) work like FAT32 ones: browse, play, and what the player writes to a stick goes onto them too.' },
{ id: 'credit', name: 'Boot text', by: 'ours', state: 'stable',
what: 'The boot screen says “Pionaarr Mods 2.0.2” instead of “Ver 1.31”.' }
];
var chosen = {};
MODS.forEach(function (m) { chosen[m.id] = true; }); // every mod ticked at the start
var stock = false, before = null; // the stock switch, and the picks it put away
function setStock(on) {
stock = on;
if (on) {
before = {};
MODS.forEach(function (m) { before[m.id] = chosen[m.id]; chosen[m.id] = false; });
} else if (before) {
MODS.forEach(function (m) { chosen[m.id] = before[m.id]; });
}
byId('stock').setAttribute('aria-pressed', on ? 'true' : 'false');
byId('picks').classList.toggle('collapsed', on); // stock: the mods folded away
byId('pick-note').textContent = on ? 'Stock: the update will have no mods.' : '';
render();
}
var file = null;
function byId(id) { return document.getElementById(id); }
function needsOf(id) { var m = MODS.filter(function (x) { return x.id === id; })[0]; return m && m.needs; }
// A mod ticked ticks what it needs (and what that needs); one unticked
// unticks every mod that needs it, directly or not.
function toggle(id, on) {
chosen[id] = on;
var notes = [];
if (on) {
for (var n = id; needsOf(n); n = needsOf(n)) {
if (!chosen[needsOf(n)]) { chosen[needsOf(n)] = true; notes.push('Ticked ' + needsOf(n) + ' too: ' + n + ' needs it.'); }
}
} else {
var changed = true;
while (changed) {
changed = false;
MODS.forEach(function (m) {
if (m.needs && !chosen[m.needs] && chosen[m.id]) { chosen[m.id] = false; changed = true; notes.push('Unticked ' + m.id + ' too: it needs ' + m.needs + '.'); }
});
}
}
byId('pick-note').textContent = notes.join(' ');
render();
}
function render() {
var box = byId('picks');
box.innerHTML = '';
MODS.forEach(function (m) {
var row = document.createElement('label');
row.className = 'pick' + (chosen[m.id] ? ' on' : '') + (stock ? ' off' : '');
row.innerHTML =
'' +
'' + m.name + ' ' + m.id + '' +
(window.CDJ_VERSIONS && window.CDJ_VERSIONS.mods[m.id] ? ' v' + window.CDJ_VERSIONS.mods[m.id] + '' : '') + '' +
'' + m.what + '' +
'' + (m.by === 'ours' ? 'Pionaarr mod · made with Claude Code' : 'by arnoldasr') +
(m.needs ? ' · needs ' + m.needs + '' : '') + '' +
'' + (m.release ? 'Pionaarr ' + m.release + '' : '') +
'' + m.state + '' +
(share(m.id) !== null ? '' + (share(m.id) < 103 ? '' : '≈ ') + kb(share(m.id)) + '' : '') + '';
row.querySelector('input').disabled = stock;
row.querySelector('input').addEventListener('change', function (e) { toggle(m.id, e.target.checked); });
box.appendChild(row);
});
flashBar();
ready();
}
// The flash bar: the application is stored packed in 7.6 MiB of the
// player's flash; the firmware itself, the mods ticked and what is left.
var FL = window.BUILDER_DATA && window.BUILDER_DATA.flash;
function share(id) { return FL && FL.mods[id] !== undefined ? FL.mods[id] : null; }
function kb(n) { return n < 103 ? '< 0.1 KB' : (n / 1024).toFixed(n < 10240 ? 1 : 0) + ' KB'; }
function mb(n) { return (n / 1048576).toFixed(2) + ' MB'; }
function flashBar() {
var el = byId('flash');
if (!el || !FL) return;
var picked = MODS.filter(function (m) { return chosen[m.id] && share(m.id) !== null; });
var common = picked.length ? (FL.common || 0) : 0; // what every build with mods brings once
var mods = common + picked.reduce(function (a, m) { return a + share(m.id); }, 0);
var used = FL.stock + mods, free = FL.size - used;
var pct = function (n) { return (100 * n / FL.size).toFixed(3) + '%'; };
var segs = '' +
(common ? '' : '');
picked.forEach(function (m, i) {
segs += '';
});
var zoom = '', was = el.querySelector('.fl-zoom'), open = was && was.open; // a tick keeps the list open
picked.slice().sort(function (a, b) { return share(b.id) - share(a.id); }).forEach(function (m) {
zoom += '' + m.name + '' + kb(share(m.id)) + '';
});
el.innerHTML =
'
Sizes as the player stores the firmware (packed), about: the packer shares a lot between mods. Exact with none and with all; the build’s checks give the exact total.
'; } function ready() { var why = !file ? 'Choose the update file first.' : !byId('agree-risk').checked || !byId('agree-ai').checked ? 'Confirm both points above to build.' : ''; byId('build').disabled = !!why; byId('build-why').textContent = why; } function setFile(f) { file = f; byId('file-state').textContent = f ? f.name + ' · ' + (f.size / 1048576).toFixed(1) + ' MB (checked when you build)' : 'No file yet'; byId('drop').classList.toggle('has', !!f); byId('result').hidden = true; ready(); } function log(msg, cls) { var l = byId('log'); l.hidden = false; var p = document.createElement('div'); if (cls) p.className = cls; p.textContent = msg; l.appendChild(p); l.scrollTop = l.scrollHeight; } var url = null; function run() { var names = MODS.map(function (m) { return m.id; }).filter(function (id) { return chosen[id]; }); byId('build').disabled = true; byId('result').hidden = true; byId('log').innerHTML = ''; log('mods: ' + (names.length ? names.join(', ') : 'none (stock)')); file.arrayBuffer().then(function (buf) { return window.CDJBuilder.build(new Uint8Array(buf), names, log); }).then(function (r) { log('done: every check passed', 'ok'); if (url) URL.revokeObjectURL(url); url = URL.createObjectURL(new Blob([r.upd], { type: 'application/octet-stream' })); byId('download').href = url; byId('sum').innerHTML = 'SHA-256 of the file' + r.updSha + '' + r.appSha + '';
var ul = byId('checks');
ul.innerHTML = '';
r.checks.forEach(function (c) { var li = document.createElement('li'); li.textContent = c; ul.appendChild(li); });
byId('result').hidden = false;
}).catch(function (e) {
log('stopped: ' + e.message, 'bad');
}).then(ready);
}
document.addEventListener('DOMContentLoaded', function () {
render();
byId('file').addEventListener('change', function (e) { setFile(e.target.files[0] || null); });
var drop = byId('drop');
['dragenter', 'dragover'].forEach(function (t) { drop.addEventListener(t, function (e) { e.preventDefault(); drop.classList.add('over'); }); });
['dragleave', 'drop'].forEach(function (t) { drop.addEventListener(t, function (e) { e.preventDefault(); drop.classList.remove('over'); }); });
drop.addEventListener('drop', function (e) { if (e.dataTransfer.files[0]) setFile(e.dataTransfer.files[0]); });
byId('agree-risk').addEventListener('change', ready);
byId('agree-ai').addEventListener('change', ready);
byId('build').addEventListener('click', run);
byId('stock').addEventListener('click', function () { setStock(!stock); });
});
})();