Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,33 @@
if ( !labelEl || !block ) {
return;
}
var ts = blockToTimestamp( block );
var date = new Date( ts * 1000 );
labelEl.textContent = '≈ ' + date.toLocaleDateString( undefined, {
year: 'numeric', month: 'short', day: 'numeric'
} );
labelEl.textContent = '⏳';
var hexBlock = '0x' + block.toString( 16 );
fetch( 'https://ethereum-rpc.publicnode.com', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify( {
jsonrpc: '2.0',
method: 'eth_getBlockByNumber',
params: [ hexBlock, false ],
id: 1
} )
} )
.then( function ( r ) { return r.json(); } )
.then( function ( resp ) {
if ( resp.result && resp.result.timestamp ) {
var ts = parseInt( resp.result.timestamp, 16 );
var date = new Date( ts * 1000 );
labelEl.textContent = date.toLocaleDateString( undefined, {
year: 'numeric', month: 'short', day: 'numeric'
} );
} else {
labelEl.textContent = '';
}
} )
.catch( function () {
labelEl.textContent = '';
} );
}

function initBlockheightControls() {
Expand All @@ -102,7 +124,7 @@
updateBlockDateLabel( block, dateLabel );
} );

// Date picker → block height conversion
// Date picker → estimate block from date (local formula, day-level precision)
var dateInput = el( 'dv-date-input' );
if ( dateInput ) {
dateInput.addEventListener( 'change', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,33 @@
if ( !labelEl || !block ) {
return;
}
var ts = blockToTimestamp( block );
var date = new Date( ts * 1000 );
labelEl.textContent = '≈ ' + date.toLocaleDateString( undefined, {
year: 'numeric', month: 'short', day: 'numeric'
} );
labelEl.textContent = '⏳';
var hexBlock = '0x' + block.toString( 16 );
fetch( 'https://ethereum-rpc.publicnode.com', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify( {
jsonrpc: '2.0',
method: 'eth_getBlockByNumber',
params: [ hexBlock, false ],
id: 1
} )
} )
.then( function ( r ) { return r.json(); } )
.then( function ( resp ) {
if ( resp.result && resp.result.timestamp ) {
var ts = parseInt( resp.result.timestamp, 16 );
var date = new Date( ts * 1000 );
labelEl.textContent = date.toLocaleDateString( undefined, {
year: 'numeric', month: 'short', day: 'numeric'
} );
} else {
labelEl.textContent = '';
}
} )
.catch( function () {
labelEl.textContent = '';
} );
}

function initBlockheightControls() {
Expand Down Expand Up @@ -106,12 +128,11 @@
updateBlockDateLabel( block, dateLabel );
} );

// Date picker → block height conversion
// Date picker → estimate block from date (local formula, day-level precision)
var dateInput = el( 'dv-date-input' );
if ( dateInput ) {
dateInput.addEventListener( 'change', function () {
if ( dateInput.value ) {
// Parse date at noon local time to avoid timezone offset issues
var parts = dateInput.value.split( '-' );
var ts = Math.floor( new Date( parts[ 0 ], parts[ 1 ] - 1, parts[ 2 ], 12, 0, 0 ).getTime() / 1000 );
var block = timestampToBlock( ts );
Expand Down Expand Up @@ -360,8 +381,28 @@
if ( f.size_bytes ) {
lines.push( ' size_bytes: ' + f.size_bytes );
}
if ( f.creation_time ) {
lines.push( ' creation_time: ' + quoteYamlValue( f.creation_time ) );
}
} );

// If the user hasn't picked a date and the video has creation_time
// metadata, use it as the default content date.
var contentDateInput = el( 'dv-content-date' );
var contentBhInput = el( 'dv-content-blockheight' );
if ( contentDateInput && !contentDateInput.value && contentBhInput && !contentBhInput.value ) {
var firstFile = ( draft.files || [] )[ 0 ];
if ( firstFile && firstFile.creation_time ) {
// creation_time is ISO 8601, e.g. "2026-03-15T14:30:00.000000Z"
var dateStr = firstFile.creation_time.substring( 0, 10 );
if ( dateStr && /^\d{4}-\d{2}-\d{2}$/.test( dateStr ) ) {
contentDateInput.value = dateStr;
// Trigger change event so the blockheight converter picks it up
contentDateInput.dispatchEvent( new Event( 'change' ) );
}
}
}

return lines.join( '\n' ) + '\n';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,85 @@
border-radius: 4px;
}

/* Trim controls */
.rd-trim-controls {
margin: 0.75em 0 1.5em;
max-width: 800px;
}

.rd-trim-controls h4 {
margin: 0 0 0.5em;
font-size: 0.95em;
}

.rd-trim-row {
display: flex;
gap: 1.5em;
flex-wrap: wrap;
}

.rd-trim-field {
display: flex;
align-items: center;
gap: 0.5em;
}

.rd-trim-field label {
font-weight: bold;
font-size: 0.9em;
color: #54595d;
}

.rd-trim-input {
width: 5em;
text-align: center;
font-family: monospace;
}

.rd-trim-set-btn {
font-size: 0.85em;
padding: 0.25em 0.6em;
cursor: pointer;
}

.rd-trim-preview {
margin-top: 0.5em;
font-size: 0.85em;
color: #54595d;
font-style: italic;
}

/* Preview status */
.rd-preview-status {
margin: 0.75em 0;
padding: 0.5em 0.75em;
font-size: 0.9em;
color: #54595d;
background: #f8f9fa;
border-radius: 3px;
}

/* Preserve original checkbox */
.rd-preserve-label {
display: flex;
align-items: center;
gap: 0.4em;
font-size: 0.9em;
color: #54595d;
cursor: pointer;
}

/* More settings (collapsed) */
.rd-more-settings {
margin: 1em 0;
font-size: 0.9em;
}

.rd-more-settings summary {
cursor: pointer;
color: #72777d;
}

/* Raw YAML toggle */
.release-raw-yaml {
margin-top: 2em;
Expand Down
Loading