11//
2- // BarcodeAPI.org
3- // index.js
2+ // BarcodeAPI.org, 2017-2025
3+ // index.js // index.html
44//
55
66/**
@@ -86,7 +86,8 @@ async function init() {
8686 window . onbeforeunload = actionCloseKeyboard ;
8787
8888 // Log tracking event
89- trackingEvent ( "app_main_load" ) ;
89+ var setupMillis = ( ( new Date ( ) ) - timeStart ) ;
90+ trackingEvent ( "AppEvents" , "AppLoad" , "Main" , setupMillis ) ;
9091}
9192
9293/**
@@ -209,8 +210,8 @@ function loadSelectedType() {
209210 text . focus ( ) ;
210211
211212 // Log tracking event
212- trackingEvent ( "app_main_type " , //
213- ( ( codeType ) ? { "type" : codeType . name } : null ) ) ;
213+ trackingEvent ( "AppMain" , "TypeChange ", //
214+ ( codeType ) ? codeType . name : "Auto" ) ;
214215}
215216
216217function renderOptions ( type ) {
@@ -371,31 +372,32 @@ function updateBarcodeImage(url) {
371372 }
372373
373374 // Request the image
374- fetch ( url , options ) . then ( response => {
375-
376- // Upate token count if not cached
377- var tokens = response . headers . get ( 'x-ratelimit-tokens' ) ;
378- tokens = ( tokens == - 1 ) ? "Unlimited" : tokens ;
379- document . getElementById ( "barcode_tokens" ) . innerHTML = tokens ;
380-
381- // Update learn more link
382- var codeType = response . headers . get ( 'x-barcode-type' ) ;
383- var displayType = codeType . replace ( "_" , " " ) ;
384- var linkType = codeType . replace ( "_" , "" ) ;
385-
386- // Update learn more link
387- var link = document . getElementsByClassName ( "link-more" ) [ 0 ] ;
388- link . innerHTML = "Learn more about " + displayType + " barcodes!" ;
389- link . href = "/type.html#" + linkType ;
390-
391- // Update the image blob
392- response . blob ( ) . then ( blob => {
393- document . getElementById ( 'barcode_output' ) . src = URL . createObjectURL ( blob ) ;
375+ fetch ( url , options )
376+ . then ( response => {
377+
378+ // Upate token count if not cached
379+ var tokens = response . headers . get ( 'x-ratelimit-tokens' ) ;
380+ tokens = ( tokens == - 1 ) ? "Unlimited" : tokens ;
381+ document . getElementById ( "barcode_tokens" ) . innerHTML = tokens ;
382+
383+ // Update learn more link
384+ var codeType = response . headers . get ( 'x-barcode-type' ) ;
385+ var displayType = codeType . replace ( "_" , " " ) ;
386+ var linkType = codeType . replace ( "_" , "" ) ;
387+
388+ // Update learn more link
389+ var link = document . getElementsByClassName ( "link-more" ) [ 0 ] ;
390+ link . innerHTML = "Learn more about " + displayType + " barcodes!" ;
391+ link . href = "/type.html#" + linkType ;
392+
393+ // Update the image blob
394+ response . blob ( ) . then ( blob => {
395+ document . getElementById ( 'barcode_output' ) . src = URL . createObjectURL ( blob ) ;
396+ } ) ;
394397 } ) ;
395- } ) ;
396398
397399 // Log tracking event
398- trackingEvent ( "app_main_generate " ) ;
400+ trackingEvent ( "AppMain" , "Generate ") ;
399401}
400402
401403/**
@@ -524,11 +526,17 @@ function showRenderMenu(show) {
524526 */
525527function toggleShowRenderOptions ( ) {
526528
527- // Toggle render options dropdown state
528- showRenderMenu ( ! appState . optionsOpen ) ;
529+ // Determine opposite state
530+ var stateNew = ! appState . optionsOpen ;
529531
530- // Log tracking event
531- trackingEvent ( "app_main_options" ) ;
532+ // Set new state
533+ showRenderMenu ( stateNew ) ;
534+
535+ if ( stateNew ) {
536+
537+ // Log tracking event
538+ trackingEvent ( "AppMain" , "Options" ) ;
539+ }
532540}
533541
534542/**
@@ -555,7 +563,7 @@ function actionShowKeyboard() {
555563 }
556564
557565 // Log tracking event
558- trackingEvent ( "app_main_keyboard " ) ;
566+ trackingEvent ( "AppMain" , "Keyboard ") ;
559567}
560568
561569/**
@@ -580,7 +588,7 @@ function actionPrintImage() {
580588 w . close ( ) ;
581589
582590 // Log tracking event
583- trackingEvent ( "app_main_print " ) ;
591+ trackingEvent ( "AppMain" , "Print ") ;
584592}
585593
586594/**
@@ -629,7 +637,7 @@ async function actionCopyImage() {
629637 }
630638
631639 // Log tracking event
632- trackingEvent ( "app_main_copy " ) ;
640+ trackingEvent ( "AppMain" , "Copy ") ;
633641}
634642
635643/**
@@ -640,7 +648,7 @@ function actionDownloadImage() {
640648 window . open ( appState . current , '_blank' ) ;
641649
642650 // Log tracking event
643- trackingEvent ( "app_main_download" )
651+ trackingEvent ( "AppMain" , "Download" ) ;
644652}
645653
646654/**
0 commit comments