+1
-125
@@ -5,12 +5,6 @@
|
||||
const form = document.getElementById('generator-form');
|
||||
if (!form) return;
|
||||
const $ = id => document.getElementById(id);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const ARTICLE_50_START = '2026-08-02';
|
||||
let renderSequence = 0;
|
||||
let renderTimer = 0;
|
||||
>>>>>>> ec58fc30f840ce85ea06eb3d07457640a84f941c
|
||||
const presets = {
|
||||
'no-ai': {extent:'none', activities:'', review:'editorial'},
|
||||
research: {extent:'assisted', activities:'research', review:'editorial'},
|
||||
@@ -23,97 +17,6 @@
|
||||
return el && !el.disabled ? el.value.trim() : '';
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
function validValue(id) {
|
||||
const el = $(id);
|
||||
if (!el || el.disabled) return '';
|
||||
const v = el.value.trim();
|
||||
return v && (!el.validity || el.validity.valid) ? v : '';
|
||||
}
|
||||
|
||||
function setHidden(id, hidden) {
|
||||
const el = $(id);
|
||||
if (!el) return;
|
||||
el.hidden = hidden;
|
||||
el.querySelectorAll?.('input,select,textarea').forEach(input => { input.disabled = hidden; });
|
||||
}
|
||||
|
||||
function hexRGB(value) {
|
||||
if (!/^#[0-9a-f]{6}$/i.test(value || '')) return null;
|
||||
return [1, 3, 5].map(i => parseInt(value.slice(i, i + 2), 16) / 255);
|
||||
}
|
||||
|
||||
function relativeLuminance(value) {
|
||||
const rgb = hexRGB(value);
|
||||
if (!rgb) return null;
|
||||
const channels = rgb.map(c => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
|
||||
return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2];
|
||||
}
|
||||
|
||||
function contrastRatio(foreground, background) {
|
||||
const a = relativeLuminance(foreground);
|
||||
const b = relativeLuminance(background);
|
||||
if (a == null || b == null) return null;
|
||||
const lighter = Math.max(a, b);
|
||||
const darker = Math.min(a, b);
|
||||
return (lighter + 0.05) / (darker + 0.05);
|
||||
}
|
||||
|
||||
function emojiBackground() {
|
||||
if (articleMode()) return '#7c3aed';
|
||||
const presetColors = {'no-ai':'#2f855a', research:'#2b6cb0', summary:'#b7791f', full:'#c53030'};
|
||||
const extentColors = {none:'#2f855a', assisted:'#2b6cb0', partial:'#b7791f', mostly:'#c05621', full:'#c53030'};
|
||||
return presetColors[$('preset').value] || extentColors[$('extent').value] || '#4a5568';
|
||||
}
|
||||
|
||||
function updateContrastStatus(locale) {
|
||||
const target = $('badge-contrast-status');
|
||||
if (!target) return;
|
||||
target.hidden = true;
|
||||
target.textContent = '';
|
||||
if ($('theme').value !== 'emoji') return;
|
||||
const foreground = validValue('left-color') || '#ffffff';
|
||||
const background = validValue('right-color') || emojiBackground();
|
||||
const ratio = contrastRatio(foreground, background);
|
||||
if (ratio != null && ratio < 3) {
|
||||
target.textContent = locale.text.contrast_adjusted || 'The selected emoji colours have insufficient contrast; the icon will automatically use black or white.';
|
||||
target.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleRenderedArtifacts(params, theme, locale) {
|
||||
const sequence = ++renderSequence;
|
||||
clearTimeout(renderTimer);
|
||||
const rendering = locale.text.embed_rendering || 'Rendering embed …';
|
||||
$('html-code').value = rendering;
|
||||
$('markdown-code').value = rendering;
|
||||
$('json-code').value = rendering;
|
||||
renderTimer = setTimeout(async () => {
|
||||
const renderParams = new URLSearchParams(params);
|
||||
renderParams.set('theme', theme);
|
||||
try {
|
||||
const response = await fetch(`${base}/v1/render?${renderParams}`, {headers: {'Accept': 'application/json'}});
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(payload.detail || `HTTP ${response.status}`);
|
||||
if (sequence !== renderSequence) return;
|
||||
$('html-code').value = payload.embedHtml || payload.html || '';
|
||||
$('markdown-code').value = payload.markdown || '';
|
||||
$('json-code').value = payload.jsonLd ? JSON.stringify(payload.jsonLd, null, 2) : '';
|
||||
if (payload.accessibleText) $('preview-text').textContent = payload.accessibleText;
|
||||
if (payload.declarationUrl) $('preview-link').href = payload.declarationUrl;
|
||||
if (payload.badgeUrl) $('preview-badge').src = payload.badgeUrl;
|
||||
} catch (error) {
|
||||
if (sequence !== renderSequence) return;
|
||||
const message = locale.text.embed_render_error || 'The embed could not be rendered.';
|
||||
$('html-code').value = `${message} ${error.message}`;
|
||||
$('markdown-code').value = message;
|
||||
$('json-code').value = message;
|
||||
}
|
||||
}, 140);
|
||||
}
|
||||
|
||||
>>>>>>> ec58fc30f840ce85ea06eb3d07457640a84f941c
|
||||
function setArticleParams(params) {
|
||||
params.set('mode', 'article');
|
||||
const fields = {
|
||||
@@ -193,27 +96,14 @@
|
||||
badgeParams.set('theme', $('theme').value);
|
||||
badgeParams.set('link', declarationURL);
|
||||
const badgeURL = `${base}/v1/badge.svg?${badgeParams}`;
|
||||
<<<<<<< HEAD
|
||||
const manifestURL = `${base}/v1/declaration.json?${params}`;
|
||||
let alt = articleMode ? (locale.text.badge_article || 'Article transparency') : (locale.text.ai_label || 'AI usage disclosure');
|
||||
if ($('deepfake')?.checked) alt = locale.text.badge_article50_deepfake || alt;
|
||||
else if ($('public-interest-text')?.checked && !($('substantial-review')?.checked && $('editorial-responsibility-confirmed')?.checked)) alt = locale.text.badge_article50_text || alt;
|
||||
=======
|
||||
const assessment = legalAssessment(locale);
|
||||
renderAssessment(locale, assessment);
|
||||
|
||||
const badgeText = assessment.legal
|
||||
? assessment.badge
|
||||
: (isArticle
|
||||
? (locale.text.badge_article || 'Article transparency')
|
||||
: ((locale.presets[preset] && locale.presets[preset].title) || locale.extents[$('extent').value] || 'AI usage disclosure'));
|
||||
const accessibleText = `${badgeText} – ${locale.text.embed_details || 'AI usage details'}`;
|
||||
>>>>>>> ec58fc30f840ce85ea06eb3d07457640a84f941c
|
||||
|
||||
$('preview-badge').src = badgeURL;
|
||||
$('preview-badge').alt = '';
|
||||
$('preview-badge').alt = alt;
|
||||
$('preview-link').href = declarationURL;
|
||||
<<<<<<< HEAD
|
||||
$('html-code').value = `<a href="${declarationURL}"><img src="${badgeURL}" alt="${alt}"></a>`;
|
||||
$('markdown-code').value = `[](${declarationURL})`;
|
||||
$('json-code').value = manifestURL;
|
||||
@@ -229,20 +119,6 @@
|
||||
reviewSelect.value = 'none';
|
||||
} else if (reviewSelect.value === 'none') {
|
||||
reviewSelect.value = 'editorial';
|
||||
=======
|
||||
$('preview-text').textContent = accessibleText;
|
||||
updateContrastStatus(locale);
|
||||
scheduleRenderedArtifacts(params, $('theme').value, locale);
|
||||
const bulkLink = $('bulk-template-link');
|
||||
if (bulkLink) {
|
||||
bulkLink.hidden = !cfg.bulkURL;
|
||||
if (cfg.bulkURL) {
|
||||
const bulkParams = new URLSearchParams(params);
|
||||
bulkParams.delete('subject');
|
||||
bulkParams.delete('link');
|
||||
const payload = {version: 1, query: bulkParams.toString(), theme: $('theme').value};
|
||||
bulkLink.href = `${cfg.bulkURL}/#template=${encodeURIComponent(JSON.stringify(payload))}`;
|
||||
>>>>>>> ec58fc30f840ce85ea06eb3d07457640a84f941c
|
||||
}
|
||||
update(false);
|
||||
});
|
||||
|
||||
@@ -69,25 +69,4 @@
|
||||
display: grid;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
.assessment-findings li { line-height: 1.55; }
|
||||
=======
|
||||
.compliance-notice { margin-top: 14px; }
|
||||
|
||||
/* Article 50 context and cautious assessment */
|
||||
.legal-context-builder{border:1px solid var(--line);border-radius:14px;padding:22px;background:#fbfaf7}.legal-context-builder legend{padding:0 8px;font-weight:800}.legal-context-builder>p{margin-top:0;color:var(--muted)}.generator-grid .check-row{display:grid;grid-template-columns:22px 1fr;gap:10px;align-items:start;padding:10px 0;font-weight:400}.check-row input{width:18px;height:18px;margin-top:3px}.check-row span{display:flex;flex-direction:column;gap:3px}.check-row strong{font-weight:800}.legal-assessment{margin-top:14px;border-radius:12px;padding:16px 18px;background:#eeeae2;display:flex;flex-direction:column;gap:6px}.legal-assessment[data-level="attention"]{border-left:4px solid #8f2d1f}.legal-assessment[data-level="info"]{border-left:4px solid #5d5a50}.legal-assessment-section{margin-top:32px}.legal-assessment-card{border:1px solid var(--line);border-radius:14px;padding:20px;background:#fbfaf7}.legal-assessment-card.attention{border-left:5px solid #8f2d1f}.legal-assessment-card.info{border-left:5px solid #5d5a50}
|
||||
|
||||
/* Conditional generator workflow */
|
||||
[hidden]{display:none!important}
|
||||
.form-step{border:1px solid var(--line);border-radius:16px;padding:22px;background:#fff}.form-step>legend{padding:0 10px;font-weight:900;font-size:1.05rem}.form-step>p{margin-top:0;color:var(--muted)}
|
||||
.field-badge{display:inline-flex;width:max-content;align-items:center;border-radius:999px;padding:2px 8px;margin-left:6px;font-size:.68rem;line-height:1.5;font-weight:800;vertical-align:middle;background:#eeeae2;color:#4a473f}.field-badge.required{background:#fff0ed;color:#7a261c}.field-badge.best-practice{background:#eef4ff;color:#294f85}.field-badge.optional{background:#f2f1ed;color:#5d5a50}
|
||||
.field-help{font-weight:400;margin-top:2px}.field-help summary{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:1px solid var(--line);border-radius:999px;cursor:pointer;font-weight:900;color:var(--muted);list-style:none}.field-help summary::-webkit-details-marker{display:none}.field-help[open] summary{margin-bottom:7px}.field-help span{display:block;padding:10px 12px;border-radius:10px;background:#f3f1ec;color:var(--muted);line-height:1.5}
|
||||
.legal-category-list{display:grid;gap:10px;margin-top:18px}.legal-question{border:1px solid var(--line);border-radius:12px;padding:14px 16px;background:#fff}.legal-question label{display:block}.legal-question small{display:block;margin-top:6px;color:var(--muted);font-weight:400;line-height:1.45}.legal-question select{margin-top:10px}.conditional-block{margin-top:18px}.conditional-panel{border:1px solid var(--line);border-radius:14px;padding:18px;background:#fbfaf7}.conditional-panel h3{margin:0 0 6px;font-size:1rem}.conditional-panel>p{margin:.3rem 0 1rem;color:var(--muted);font-size:.92rem}
|
||||
.validation-messages{display:grid;gap:8px;margin-top:12px}.validation-message{margin:0;padding:12px 14px;border-radius:10px;background:#fff6ed;border-left:4px solid #9a5d14;font-size:.9rem}.validation-message.info{background:#eef4ff;border-left-color:#4f6f9f}.assessment-consequence{margin-top:5px;padding-top:8px;border-top:1px solid rgba(0,0,0,.09);font-weight:650}
|
||||
input:required,select:required{border-left-width:3px}.article-component label[hidden]{display:none!important}
|
||||
@media(max-width:760px){.form-step{padding:17px}.field-badge{margin-left:0;margin-top:3px}.conditional-panel{padding:15px}}
|
||||
.legal-consequences{margin-top:16px;border:1px solid var(--line);border-radius:12px;background:#f7f4ee;padding:14px 16px}.legal-consequences summary{cursor:pointer;font-weight:850}.legal-consequences p{margin:.8rem 0 0;color:var(--muted);font-size:.9rem;line-height:1.55}.legal-consequences .form-warning{color:#5b3029}
|
||||
|
||||
/* Accessible first-exposure disclosure preview */
|
||||
.disclosure-preview-link{display:inline-flex;align-items:center;gap:.55rem;min-height:36px;padding:4px 7px;max-width:100%;border-radius:7px;text-decoration:underline;text-underline-offset:.16em;line-height:1.35}.disclosure-preview-link img{flex:0 0 auto}.disclosure-preview-link span{font-weight:700}.contrast-status{margin:0;padding:12px 14px;border-left:4px solid #8a5a11;border-radius:10px;background:#fff4e5;color:#5b3b0b;font-size:.9rem;line-height:1.5}.code-tabs textarea#html-code,.code-tabs textarea#json-code{height:180px}
|
||||
>>>>>>> ec58fc30f840ce85ea06eb3d07457640a84f941c
|
||||
|
||||
Reference in New Issue
Block a user