For security reasons, we cannot fire the select file dialog without a user action.
Hence the buttons to load local MOCs.
Perform all others actions (load from url/create/manipulate/save) from the console.





Try copy/paste and exec the following lines of javascript from your web-browser console:

(async () => {      
  // Load 2MASS and SDSS DR12 MOCs from CDS      
  let moc2mass = await moc.MOC.fromFitsUrl('http://alasky.u-strasbg.fr/footprints/tables/vizier/II_246_out/MOC');
  console.log("2MASS MOC depth: " + moc2mass.getDepth());
  console.log("2MASS MOC coverage: " + moc2mass.coveragePercentage() + "%");
  let mocsdss = await moc.MOC.fromFitsUrl('http://alasky.u-strasbg.fr/footprints/tables/vizier/V_147_sdss12/MOC');
  console.log("SDSS DR12 MOC depth: " + mocsdss.getDepth());      
  console.log("SDSS DR12 MOC coverage: " + mocsdss.coveragePercentage() + "%");
      
  // Init a timer
  console.time('timer');
  // Performs MOC intersection
  let tmass_inter_sdss12 = moc2mass.and(mocsdss);
  // Log time
  console.timeLog('timer', 'Intersection');
  // Performs MOC union
  let tmass_union_sdss12 = moc2mass.or(mocsdss);
  // Log time
  console.timeLog('timer', 'Union');
  // Degrade to order 2 the result of the intersection
  let tmass_union_sdss12_d2 = tmass_union_sdss12.degrade(2);
  // Remove timer
  console.timeEnd('timer');
  
  console.log("(2MASS AND SDSS DR12) MOC depth: " + tmass_inter_sdss12.getDepth());
  console.log("(2MASS AND SDSS DR12) MOC coverage: " + tmass_inter_sdss12.coveragePercentage() + "%");
  console.log("(2MASS OR SDSS DR12) MOC depth: " + tmass_union_sdss12.getDepth());
  console.log("(2MASS OR SDSS DR12) MOC coverage: " + tmass_union_sdss12.coveragePercentage() + "%");    
  console.log("(2MASS OR SDSS DR12) MOC coverage at depth 2: " + tmass_union_sdss12_d2.coveragePercentage() + "%");    
      
  // Print the ASCII and JSON serializations of '2mass_inter_sdss12_d2'
  console.log(tmass_inter_sdss12.toAscii());
  console.log(tmass_inter_sdss12.toJson());
  
  // Save the result of the intersection in a FITS file
  tmass_inter_sdss12.toFitsFile();
  return;
})();
      

Try copy/paste and exec the following lines of javascript to manipulate multi-order maps (no CORS on cdsxmatch, so the data URL works only if this page URL is on cdsxmatch)

(async () => {
  // Load a multi-order map and create a MOC on-the-fly
  let lalmap = await moc.MOC.fromMultiOrderMapFitsUrl('http://cdsxmatch.u-strasbg.fr/lab/moc/LALInference.multiorder.fits', 0.0, 0.9, false, false, false, false);
  
  console.log("LALMAP MOC depth: " + lalmap.getDepth());
  console.log("LALMAP MOC coverage: " + lalmap.coveragePercentage() + "%");

  // Init a timer
  console.time('timer');

  // Count the number of disjoint MOCs in the MOC
  let n = lalmap.splitCount();
  console.log("n sub_mocs: " + n);
  console.timeLog('timer', 'Spit count'); 

  // Do split the MOC in 10 sub-MOCs
  let mocs = lalmap.split();
  console.timeLog('timer', 'Spit'); 
  // Remove timer
  console.timeEnd('timer');

  // List MOCs loaded in the page
  console.log(mocs); 

  // Get info on sub-MOCs
  for (let i = 0; i < mocs.length; i++) {  
    console.log("Coverage percentage sub " + i  + ": " + mocs[i].coveragePercentage());
  }
  return;
})();