<commit_before>import './prototype.js'
import './menuelement.js'

function offline() {
  navigator.serviceWorker.getRegistrations()
    .then(function(registrations:any) {
      for(let registration of registrations) registration.unregister()
    })
}

function online() {
  if ('serviceWorker' in navigator) navigator.serviceWorker.register('service.js')
}

function show(...args:string[]) {
  const elms = document.querySelectorAll('body > *')
  for (let i = 0; i < elms.length; ++i) {
    let next = false
    args.forEach( (v) => {if (v.toUpperCase() == elms[i].tagName) next = true; })
    if (next) {elms[i].removeAttribute('hidden'); continue;}
    if ('STYLE' == elms[i].tagName) continue;
    if ('SCRIPT' == elms[i].tagName) continue;
    elms[i].setAttribute('hidden', 'true')
  }
}

;(function(){
  const menu = document.querySelector('menu-ts')
  menu!.addEventListener('transaction', () => { script('./scripts/transactionelement.js').then( () => show('menu-ts', 'transaction-ts') ) })      
  menu!.addEventListener('form', () => { script('./scripts/formelement.js', './scripts/issuerelement.js', './scripts/methodelement.js').then( () => show('menu-ts', 'form-ts') ) })
  menu!.addEventListener('test', () => { script('./scripts/formelement_test.js').then( () => show('menu-ts', 'form-test') ) })
  menu!.addEventListener('online', () => { online(); show('menu-ts') })
  menu!.addEventListener('offline', () => { offline(); show('menu-ts') })
  const page = window.location.search.substr(1)
  let event = new CustomEvent('form', { 'detail': null })
  if (page) event = new CustomEvent(page, { 'detail': null })
  menu!.dispatchEvent(event)
})()

const scripts:string[] = []
function script(...href:string[]):Promise<{}> {
  const p:Promise<{}>[] = []
  for (let i=0; i < href.length; ++i) {
    let c = false
    scripts.forEach( v => { if ( v == href[i] ) c = true } )
    if (c) continue
    scripts.push(href[i])
    p.push( new Promise( (resolve, reject) => {
      const script = document.createElement('script')
      script.type = 'module'
      script.src = href[i]
      script.onload = resolve<commit_msg>Safari 10.1+<commit_after>import './prototype.js'
import './menuelement.js'

function offline() {
  navigator.serviceWorker.getRegistrations()
    .then(function(registrations:any) {
      for(let registration of registrations) registration.unregister()
    })
}

function online() {
  if ('serviceWorker' in navigator) navigator.serviceWorker.register('service.js')
}

function show(...args:string[]) {
  const elms = document.querySelectorAll('body > *')
  for (let i = 0; i < elms.length; ++i) {
    let next = false
    args.forEach( (v) => {if (v.toUpperCase() == elms[i].tagName) next = true; })
    if (next) {elms[i].removeAttribute('hidden'); continue;}
    if ('STYLE' == elms[i].tagName) continue;
    if ('SCRIPT' == elms[i].tagName) continue;
    elms[i].setAttribute('hidden', 'true')
  }
}

;(function(){
  const scripts:string[] = []
  const menu = document.querySelector('menu-ts')
  menu!.addEventListener('transaction', () => { script(scripts, './scripts/transactionelement.js').then( () => show('menu-ts', 'transaction-ts') ) })      
  menu!.addEventListener('form', () => { script(scripts, './scripts/formelement.js', './scripts/issuerelement.js', './scripts/methodelement.js').then( () => show('menu-ts', 'form-ts') ) })
  menu!.addEventListener('test', () => { script(scripts, './scripts/formelement_test.js').then( () => show('menu-ts', 'form-test') ) })
  menu!.addEventListener('online', () => { online(); show('menu-ts') })
  menu!.addEventListener('offline', () => { offline(); show('menu-ts') })
  const page = window.location.search.substr(1)
  let event = new CustomEvent('form', { 'detail': null })
  if (page) event = new CustomEvent(page, { 'detail': null })
  menu!.dispatchEvent(event)
})()

function script(scripts:string[], ...href:string[]):Promise<{}> {
  const p:Promise<{}>[] = []
  for (let i=0; i < href.length; ++i) {
    let c = false
    scripts.forEach( v => { if (v == href[i]) c = true } )
    if (c) continue
    scripts.push(href[i])
    p.push( new Promise( (resolve, reject) => {
      const script = document.createElement('script')
      script.type = 'module'
      script.src = href[i]
      script.onload = resolve
{'fraction_non_alphanumeric': 0.20887546468401488, 'fraction_numerical': 0.002091078066914498, 'mean_word_length': 4.046893317702227, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4006235', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1380, 'n_words': 278}