Spaces:
Runtime error
Runtime error
PDF2, quelques scories, V samedi 3 mai 17:42
Browse files- templates/index.html +84 -65
templates/index.html
CHANGED
@@ -225,14 +225,19 @@
|
|
225 |
<label class="form-label">Generative AI</label>
|
226 |
<select id="aiModel" class="form-select" required>
|
227 |
<option value="" selected disabled>Select…</option>
|
228 |
-
<option>
|
229 |
-
<option>
|
230 |
-
<option>Flux (F‑LUX 1)</option>
|
231 |
<option>Canva Magic Media</option>
|
232 |
-
<option>
|
233 |
-
<option>
|
234 |
-
<option>
|
235 |
-
<option>
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
<option>Other</option>
|
237 |
</select>
|
238 |
</div>
|
@@ -272,48 +277,80 @@ document.getElementById('certForm').addEventListener('submit',e=>{
|
|
272 |
bootstrap.Modal.getInstance(document.getElementById('certModal')).hide();
|
273 |
generatePDF2();
|
274 |
});
|
275 |
-
/* PDF2 :
|
276 |
-
async function generatePDF2(){
|
277 |
-
const {jsPDF}=window.jspdf;
|
278 |
-
const pdf=new jsPDF({unit:'pt',format:'a4'});
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
pdf.
|
286 |
-
pdf.
|
287 |
-
y
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
|
|
|
|
292 |
document.body.appendChild(clone);
|
293 |
-
clone.style.
|
294 |
-
const canvas=await html2canvas(clone,{backgroundColor:null});
|
295 |
document.body.removeChild(clone);
|
296 |
-
const
|
297 |
-
const
|
298 |
-
const imgH=(
|
299 |
-
pdf.addImage(
|
300 |
-
y+=imgH+40;
|
301 |
-
/*
|
302 |
-
pdf.setFontSize(
|
303 |
-
pdf.text('
|
304 |
-
|
305 |
-
pdf.text(
|
306 |
-
|
307 |
-
pdf.text('
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
pdf.
|
313 |
-
pdf.text(
|
314 |
-
|
315 |
-
pdf.text(
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
}
|
318 |
|
319 |
function resetSelection(target) {
|
@@ -423,24 +460,6 @@ async function generatePDF2(){
|
|
423 |
const wrapped=pdf.splitTextToSize(urlText,usableW);
|
424 |
pdf.text(wrapped,margin,y+28);
|
425 |
window.open(pdf.output('bloburl'),'_blank');}
|
426 |
-
async function generatePDF2(){const {jsPDF}=window.jspdf;const pdf=new jsPDF({orientation:'portrait',unit:'pt',format:'a4'});
|
427 |
-
const pageW=pdf.internal.pageSize.getWidth();const margin=40;const usableW=pageW-margin*2;let y=100;
|
428 |
-
pdf.setFont('helvetica','normal');pdf.setFontSize(24);pdf.text('Fraud Score',pageW/2,y,{align:'center'});
|
429 |
-
y+=20;pdf.setFontSize(12);pdf.text('Is my work used by generative AI ?',pageW/2,y,{align:'center'});
|
430 |
-
y+=100; // six blank lines
|
431 |
-
const section=document.querySelector('#compareSection .d-flex');const clone=section.cloneNode(true);
|
432 |
-
clone.querySelectorAll('button').forEach(b=>b.style.display='none'); // hide calculate/print
|
433 |
-
document.body.appendChild(clone);clone.style.position='absolute';clone.style.left='-9999px';
|
434 |
-
const canvas=await html2canvas(clone,{backgroundColor:null});document.body.removeChild(clone);
|
435 |
-
const imgData=canvas.toDataURL('image/png');const props=pdf.getImageProperties(imgData);const imgH=(props.height*usableW)/props.width;
|
436 |
-
pdf.addImage(imgData,'PNG',margin,y,usableW,imgH);
|
437 |
-
y+=imgH+100; // six blank lines before footer
|
438 |
-
pdf.setFontSize(10);
|
439 |
-
const now=new Date();pdf.text(`Calculated on: ${now.toLocaleString()}`,margin,y);
|
440 |
-
const urlText=`by: ${window.location.href}`;
|
441 |
-
const wrapped=pdf.splitTextToSize(urlText,usableW);
|
442 |
-
pdf.text(wrapped,margin,y+28);
|
443 |
-
window.open(pdf.output('bloburl'),'_blank');}
|
444 |
|
445 |
</script>
|
446 |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
|
225 |
<label class="form-label">Generative AI</label>
|
226 |
<select id="aiModel" class="form-select" required>
|
227 |
<option value="" selected disabled>Select…</option>
|
228 |
+
<option>Adobe Firefly Image Model 4</option>
|
229 |
+
<option>Bing Image Creator</option>
|
|
|
230 |
<option>Canva Magic Media</option>
|
231 |
+
<option>DALL·E / GPT‑4o Image</option>
|
232 |
+
<option>Flux (F‑LUX 1)</option>
|
233 |
+
<option>Ideogram 3.0</option>
|
234 |
+
<option>Leonardo AI (Phoenix)</option>
|
235 |
+
<option>Microsoft Designer</option>
|
236 |
+
<option>Midjourney v6</option>
|
237 |
+
<option>NightCafe Creator</option>
|
238 |
+
<option>Playground AI</option>
|
239 |
+
<option>Runway Gen‑3 Alpha</option>
|
240 |
+
<option>Stable Diffusion 3</option>
|
241 |
<option>Other</option>
|
242 |
</select>
|
243 |
</div>
|
|
|
277 |
bootstrap.Modal.getInstance(document.getElementById('certModal')).hide();
|
278 |
generatePDF2();
|
279 |
});
|
280 |
+
/* PDF2 : certificat avec les infos du formulaire */
|
281 |
+
async function generatePDF2 () {
|
282 |
+
const { jsPDF } = window.jspdf;
|
283 |
+
const pdf = new jsPDF({ unit : 'pt', format : 'a4' });
|
284 |
+
/* ── page metrics ─────────────────────────────────── */
|
285 |
+
const pageW = pdf.internal.pageSize.getWidth();
|
286 |
+
const margin = 40;
|
287 |
+
const usableW = pageW - margin * 2;
|
288 |
+
let y = 80;
|
289 |
+
/* ── header ───────────────────────────────────────── */
|
290 |
+
pdf.setFont('helvetica', 'normal');
|
291 |
+
pdf.setFontSize(26);
|
292 |
+
pdf.text('Certification', pageW / 2, y, { align : 'center' });
|
293 |
+
y += 22;
|
294 |
+
pdf.setDrawColor('#d1d1d6');
|
295 |
+
pdf.line(margin, y, pageW - margin, y); /* thin divider */
|
296 |
+
y += 32;
|
297 |
+
/* ── visual block (images + gauge + score) ────────── */
|
298 |
+
const section = document.querySelector('#compareSection .d-flex');
|
299 |
+
const clone = section.cloneNode(true);
|
300 |
+
clone.querySelectorAll('button').forEach(b => (b.style.display = 'none'));
|
301 |
document.body.appendChild(clone);
|
302 |
+
clone.style.cssText = 'position:absolute;left:-9999px;top:0';
|
303 |
+
const canvas = await html2canvas(clone, { backgroundColor : null });
|
304 |
document.body.removeChild(clone);
|
305 |
+
const imgData = canvas.toDataURL('image/png');
|
306 |
+
const props = pdf.getImageProperties(imgData);
|
307 |
+
const imgH = (props.height * usableW) / props.width;
|
308 |
+
pdf.addImage(imgData, 'PNG', margin, y, usableW, imgH);
|
309 |
+
y += imgH + 40;
|
310 |
+
/* ── certificate text ──────────────���──────────────── */
|
311 |
+
pdf.setFontSize(12);
|
312 |
+
pdf.text('I hereby certify that the original picture shown on the left is my own work and that', margin, y);
|
313 |
+
y += 20;
|
314 |
+
pdf.text('the AI‑generated picture shown on the right was produced by the generative AI', margin, y);
|
315 |
+
y += 20;
|
316 |
+
pdf.text('indicated below, using the prompt that follows.', margin, y);
|
317 |
+
y += 50;
|
318 |
+
const indentX = 150; // tabulation pour les valeurs saisies
|
319 |
+
|
320 |
+
/* generative AI (label regular, value italic) */
|
321 |
+
pdf.setFont('helvetica', 'normal');
|
322 |
+
pdf.text('Generative AI:', margin + 50, y);
|
323 |
+
pdf.setFont('helvetica', 'italic');
|
324 |
+
pdf.text(certData.ai, margin + indentX, y);
|
325 |
+
y += 30;
|
326 |
+
/* prompt */
|
327 |
+
const promptMaxWidth = usableW - indentX; // largeur réellement disponible
|
328 |
+
|
329 |
+
pdf.setFont('helvetica', 'normal');
|
330 |
+
pdf.text('Prompt:', margin + 50, y);
|
331 |
+
pdf.setFont('helvetica', 'italic');
|
332 |
+
const promptLines = pdf.splitTextToSize(certData.prompt, promptMaxWidth);
|
333 |
+
pdf.text(promptLines, margin + indentX, y); // même retrait pour toutes les lignes
|
334 |
+
y += promptLines.length * 14 + 20;
|
335 |
+
/* signer’s name */
|
336 |
+
pdf.setFont('helvetica', 'normal');
|
337 |
+
pdf.text('Name:', margin + 50, y);
|
338 |
+
pdf.setFont('helvetica', 'italic');
|
339 |
+
pdf.text(` ${certData.first} ${certData.last}`,margin + indentX,y);
|
340 |
+
y += 30;
|
341 |
+
/* date */
|
342 |
+
const now = new Date().toLocaleString();
|
343 |
+
pdf.setFont('helvetica', 'normal');
|
344 |
+
pdf.text('Date:', margin + 50, y);
|
345 |
+
pdf.setFont('helvetica', 'italic');
|
346 |
+
pdf.text(` ${now.toLocaleString()}`,margin + indentX,y);
|
347 |
+
y += 50;
|
348 |
+
/* URL */
|
349 |
+
pdf.setFont('helvetica', 'normal');
|
350 |
+
const footerLines = pdf.splitTextToSize(`Fraud Score calculated by: ${window.location.href}`, usableW);
|
351 |
+
pdf.text(footerLines, margin, y);
|
352 |
+
/* ── open PDF ─────────────────────────────────────── */
|
353 |
+
window.open(pdf.output('bloburl'), '_blank');
|
354 |
}
|
355 |
|
356 |
function resetSelection(target) {
|
|
|
460 |
const wrapped=pdf.splitTextToSize(urlText,usableW);
|
461 |
pdf.text(wrapped,margin,y+28);
|
462 |
window.open(pdf.output('bloburl'),'_blank');}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
|
464 |
</script>
|
465 |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|