exl100

Émulateur Exelvision EXL 100 (1984) dans le navigateur : dsp-cpp en WebAssembly, cartouches et cassettes BASIC
git clone https://git.schurger.org/exl100.git
Log | Files | Refs | README

disk-modal.mjs (2176B)


      1 // Modale de la disquette : clic sur une disquette de la bibliothèque → amorçage + modale listant les fichiers ;
      2 // clic sur un programme → redémarrage et commande tapée à l'invite EXELDOS. Captures.
      3 //   node test/disk-modal.mjs [bout de titre de la disquette] [bout de nom de fichier] [base-url] [préfixe]
      4 import { open, sleep } from './cdp.mjs';
      5 
      6 const want = (process.argv[2] ?? 'loadrun').toLowerCase();
      7 const file = (process.argv[3] ?? 'PING').toUpperCase();
      8 const base = process.argv[4] ?? 'http://127.0.0.1:8196';
      9 const prefix = process.argv[5] ?? '/tmp/disk-modal';
     10 const page = await open(base + '/', { width: 900, height: 1100 });
     11 await page.evaluate('location.reload()');
     12 await sleep(7000);
     13 const hit = await page.evaluate(`(() => {
     14   const b = [...document.querySelectorAll('.pg')].find((b) => b.dataset.type === 'disk' && b.dataset.search.includes(${JSON.stringify(want)}));
     15   if (b) b.click();
     16   return b ? b.querySelector('.pg-t').textContent : null;
     17 })()`);
     18 console.log('disquette :', hit);
     19 await sleep(2500);
     20 const info = await page.evaluate(`({ open: document.getElementById('disk-modal').open, title: document.getElementById('disk-title').textContent,
     21   summary: document.getElementById('disk-summary').textContent,
     22   rows: [...document.querySelectorAll('#disk-files tbody tr')].map((tr) => [...tr.children].map((td) => td.textContent).join(' | ')) })`);
     23 console.log('modale :', info.open, info.title, '—', info.summary);
     24 console.log(info.rows.slice(0, 6).join('\n'), info.rows.length > 6 ? '\n… ' + info.rows.length + ' lignes' : '');
     25 await page.screenshot(prefix + '-modal.png');
     26 const clicked = await page.evaluate(`(() => {
     27   const tr = [...document.querySelectorAll('#disk-files tbody tr.run')].find((tr) => tr.children[0].textContent.includes(${JSON.stringify(file)}));
     28   if (tr) tr.click();
     29   return tr ? tr.children[4].textContent : null;
     30 })()`);
     31 console.log('fichier cliqué :', clicked);
     32 await sleep(14000);
     33 console.log('statut :', await page.evaluate("document.getElementById('status').textContent"));
     34 await page.screenshot(prefix + '-run.png');
     35 console.log('Captures :', prefix + '-modal.png', prefix + '-run.png');
     36 page.close();