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

fenêtre de saisie

Browse files
Files changed (1) hide show
  1. templates/index.html +115 -6
templates/index.html CHANGED
@@ -128,6 +128,9 @@
128
  text-align: center;
129
  display: none;
130
  }
 
 
 
131
  </style>
132
  </head>
133
  <body>
@@ -187,12 +190,7 @@
187
  <!-- boutons de PDF -->
188
  <div class="icon-buttons" id="iconButtons">
189
  <button title="Print" onclick="generatePDF1()"><i class="fas fa-print"></i></button>
190
- <button
191
- title="Certificate"
192
- aria-label="Certificate PDF"
193
- onclick="generatePDF2()">
194
- <i class="fas fa-certificate" aria-hidden="true"></i>
195
- </button>
196
 
197
  </div>
198
  </div>
@@ -204,9 +202,120 @@
204
  <div id="results" class="mt-4"></div>
205
  </div>
206
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  <script>
208
  let file1 = null,
209
  file2 = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  function resetSelection(target) {
211
  for (let i = 1; i <= 3; i++) {
212
  const thumb = document.getElementById(`preset-${i}-${target}`);
 
128
  text-align: center;
129
  display: none;
130
  }
131
+ /* modal */
132
+ .modal-header{border-bottom:1px solid var(--apple-border)}
133
+ .modal-footer{border-top:1px solid var(--apple-border)}
134
  </style>
135
  </head>
136
  <body>
 
190
  <!-- boutons de PDF -->
191
  <div class="icon-buttons" id="iconButtons">
192
  <button title="Print" onclick="generatePDF1()"><i class="fas fa-print"></i></button>
193
+ <button title="Certificate" data-bs-toggle="modal" data-bs-target="#certModal"><i class="fas fa-certificate"></i></button>
 
 
 
 
 
194
 
195
  </div>
196
  </div>
 
202
  <div id="results" class="mt-4"></div>
203
  </div>
204
  </div>
205
+ <!-- Certificate modal -->
206
+ <div class="modal fade" id="certModal" tabindex="-1" aria-hidden="true">
207
+ <div class="modal-dialog modal-dialog-centered">
208
+ <div class="modal-content">
209
+ <form id="certForm" class="needs-validation" novalidate>
210
+ <div class="modal-header">
211
+ <h5 class="modal-title">Certificate details</h5>
212
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
213
+ </div>
214
+ <div class="modal-body">
215
+ <div class="row g-3">
216
+ <div class="col-md-6">
217
+ <label class="form-label">First Name</label>
218
+ <input id="firstName" class="form-control" required>
219
+ </div>
220
+ <div class="col-md-6">
221
+ <label class="form-label">Last Name</label>
222
+ <input id="lastName" class="form-control" required>
223
+ </div>
224
+ <div class="col-12">
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>
239
+ <div class="col-12">
240
+ <div class="form-check">
241
+ <input id="certCheck" class="form-check-input" type="checkbox" required>
242
+ <label class="form-check-label" for="certCheck">
243
+ I certify that the original image is my work and that the generated image was produced by the indicated generative AI, with the following prompt:
244
+ </label>
245
+ </div>
246
+ </div>
247
+ <div class="col-12">
248
+ <textarea id="promptText" class="form-control" rows="3" placeholder="Prompt" required></textarea>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ <div class="modal-footer">
253
+ <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
254
+ <button type="submit" class="btn btn-primary">Validate &amp; Generate PDF</button>
255
+ </div>
256
+ </form>
257
+ </div>
258
+ </div>
259
+ </div>
260
  <script>
261
  let file1 = null,
262
  file2 = null;
263
+ /* formulaire certificat */
264
+ document.getElementById('certForm').addEventListener('submit',e=>{
265
+ e.preventDefault();
266
+ certData={
267
+ first:document.getElementById('firstName').value.trim(),
268
+ last:document.getElementById('lastName').value.trim(),
269
+ ai:document.getElementById('aiModel').value,
270
+ prompt:document.getElementById('promptText').value.trim()
271
+ };
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) {
320
  for (let i = 1; i <= 3; i++) {
321
  const thumb = document.getElementById(`preset-${i}-${target}`);