TheFrenchDemos commited on
Commit
1704402
·
verified ·
1 Parent(s): d4dac67

PDF2, quelques scories, V samedi 3 mai 17:42

Browse files
Files changed (1) hide show
  1. 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>DALL·E / GPT‑4o Image</option>
229
- <option>Midjourney v6</option>
230
- <option>Flux (F‑LUX 1)</option>
231
  <option>Canva Magic Media</option>
232
- <option>Adobe Firefly Image Model 4</option>
233
- <option>Stable Diffusion 3</option>
234
- <option>Leonardo AI (Phoenix)</option>
235
- <option>Runway Gen‑3 Alpha</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 : ajoute les infos du formulaire */
276
- async function generatePDF2(){
277
- const {jsPDF}=window.jspdf;
278
- const pdf=new jsPDF({unit:'pt',format:'a4'});
279
- const pageW=pdf.internal.pageSize.getWidth(),margin=40,usableW=pageW-margin*2;
280
- let y=80;
281
- pdf.setFont('helvetica','normal');
282
- pdf.setFontSize(24);
283
- pdf.text('Fraud Score',pageW/2,y,{align:'center'});
284
- y+=22;
285
- pdf.setFontSize(12);
286
- pdf.text('Is my work used by generative AI ?',pageW/2,y,{align:'center'});
287
- y+=48;
288
- /* capture de la zone résultat (sans boutons) */
289
- const section=document.querySelector('#compareSection .d-flex');
290
- const clone=section.cloneNode(true);
291
- clone.querySelectorAll('button').forEach(b=>b.style.display='none');
 
 
 
 
292
  document.body.appendChild(clone);
293
- clone.style.position='absolute';clone.style.left='-9999px';
294
- const canvas=await html2canvas(clone,{backgroundColor:null});
295
  document.body.removeChild(clone);
296
- const img=canvas.toDataURL('image/png');
297
- const prop=pdf.getImageProperties(img);
298
- const imgH=(prop.height*usableW)/prop.width;
299
- pdf.addImage(img,'PNG',margin,y,usableW,imgH);
300
- y+=imgH+40;
301
- /* bloc certificat */
302
- pdf.setFontSize(14);
303
- pdf.text('Certificate',margin,y); y+=20;
304
- pdf.setFontSize(11);
305
- pdf.text(`Name: ${certData.first} ${certData.last}`,margin,y); y+=16;
306
- pdf.text(`Generative AI: ${certData.ai}`,margin,y); y+=16;
307
- pdf.text('Prompt:',margin,y); y+=14;
308
- const wrappedPrompt=pdf.splitTextToSize(certData.prompt,usableW);
309
- pdf.text(wrappedPrompt,margin,y); y+=wrappedPrompt.length*12+24;
310
- /* footer */
311
- const now=new Date();
312
- pdf.setFontSize(10);
313
- pdf.text(`Generated on: ${now.toLocaleString()}`,margin,y);
314
- const urlLines=pdf.splitTextToSize(`Calculated by: ${window.location.href}`,usableW);
315
- pdf.text(urlLines,margin,y+14);
316
- window.open(pdf.output('bloburl'),'_blank');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>