Changeset 015ce46 in Klonkt for src/views/pages
- Timestamp:
- 06/21/2026 04:32:54 PM (3 months ago)
- Branches:
- main
- Children:
- 9effb80
- Parents:
- 5a394e5
- File:
-
- 1 edited
-
src/views/pages/post-edit.ejs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/views/pages/post-edit.ejs
r5a394e5 r015ce46 215 215 <div id="pe-sched-fields" style="margin-top:6px;<%= _scheduled ? '' : 'display:none' %>"> 216 216 <label style="display:block;font-size:12.5px;opacity:.8;margin-bottom:4px"><%= t('pedit.publish_at_label') %></label> 217 <input type="datetime-local" name="publish_at" <%= _scheduled ? '' : 'disabled' %> value="<%= post.publish_at ? String(post.publish_at).replace(' ','T').slice(0,16) : '' %>" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit">218 <% if (post.status === 'scheduled' && post.publish_at) { %><div style="font-size:12px;opacity:.7;margin-top:4px"> ⏳ <%= t('pedit.scheduled_for', { d: post.publish_at }) %></div><% } %>217 <input type="datetime-local" id="pe-publish-at" name="publish_at" <%= _scheduled ? '' : 'disabled' %> data-iso="<%= post.publish_at || '' %>" value="" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit"> 218 <% if (post.status === 'scheduled' && post.publish_at) { %><div style="font-size:12px;opacity:.7;margin-top:4px"><span id="pe-sched-when" data-iso="<%= post.publish_at %>" data-label="<%= t('pedit.scheduled_prefix') %>">⏳ <%= t('pedit.scheduled_for', { d: post.publish_at }) %></span></div><% } %> 219 219 <div style="font-size:11.5px;opacity:.65;margin-top:4px"><%= t('pedit.schedule_hint') %></div> 220 220 </div> … … 224 224 var box = document.getElementById('pe-sched-fields'); 225 225 if (!cb || !box) return; 226 var inp = box.querySelector('input[name="publish_at"]'); 226 var inp = document.getElementById('pe-publish-at'); 227 var pad = function (n) { return String(n).padStart(2, '0'); }; 228 // Prefill: opgeslagen UTC → lokale datetime-local-waarde (zodat je je 229 // eigen tijdzone ziet, niet UTC). 230 if (inp && inp.dataset.iso) { 231 var d0 = new Date(inp.dataset.iso); 232 if (!isNaN(d0)) inp.value = d0.getFullYear() + '-' + pad(d0.getMonth() + 1) + '-' + pad(d0.getDate()) + 'T' + pad(d0.getHours()) + ':' + pad(d0.getMinutes()); 233 } 234 // "Ingepland voor" in leesbare lokale tijd i.p.v. ruwe UTC-ISO. 235 var when = document.getElementById('pe-sched-when'); 236 if (when && when.dataset.iso) { 237 var dw = new Date(when.dataset.iso); 238 if (!isNaN(dw)) when.textContent = '⏳ ' + when.dataset.label + ' ' + dw.toLocaleString(); 239 } 227 240 function sync() { box.style.display = cb.checked ? '' : 'none'; if (inp) inp.disabled = !cb.checked; } 228 241 cb.addEventListener('change', sync); sync(); 242 // Bij opslaan: lokale invoer → UTC-ISO via een hidden veld, zodat de 243 // server de juiste tijd opslaat (datetime-local heeft geen tijdzone). 244 var form = cb.closest('form'); 245 if (form) { 246 form.addEventListener('submit', function () { 247 if (inp) inp.removeAttribute('name'); 248 var old = form.querySelector('input[data-pa-utc]'); 249 if (old) old.remove(); 250 if (cb.checked && inp && inp.value) { 251 var d2 = new Date(inp.value); // geïnterpreteerd in browser-tijdzone 252 if (!isNaN(d2)) { 253 var h = document.createElement('input'); 254 h.type = 'hidden'; h.name = 'publish_at'; h.setAttribute('data-pa-utc', ''); 255 h.value = d2.toISOString(); 256 form.appendChild(h); 257 } 258 } 259 }); 260 } 229 261 })(); 230 262 </script>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)