File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,15 @@ <h1 class="barcode-scanner-title">
2323 < div class ="barcode-scanner-view " style ="width: 100%; height: 70vh; "> </ div >
2424 < div class ="result-view " style ="width: 100%; height: calc(30vh - 80px); padding: 10px;overflow: auto; "> </ div >
2525 < script >
26+ // Detect file:// protocol and show a helpful tip
27+ if ( location . protocol === "file:" ) {
28+ const tip = document . createElement ( "div" ) ;
29+ tip . style . cssText = "background:#fff3cd;border:1px solid #ffc107;color:#856404;padding:12px 16px;margin:8px;border-radius:6px;font:14px/1.5 sans-serif;text-align:center;" ;
30+ tip . innerHTML = '<strong>Tip:</strong> This page works via <code>file://</code>, but for the best experience, '
31+ + 'serve it from a web server (e.g. HTTPS or localhost).' ;
32+ document . body . insertBefore ( tip , document . body . firstChild ) ;
33+ }
34+
2635 const resultView = document . querySelector ( ".result-view" ) ;
2736
2837 /** LICENSE ALERT - README
Original file line number Diff line number Diff line change @@ -23,6 +23,15 @@ <h1 class="barcode-scanner-title">
2323 <!-- This div will host the barcode scanner's camera view -->
2424 < div class ="barcode-scanner-view "> </ div >
2525 < script >
26+ // Detect file:// protocol and show a helpful tip
27+ if ( location . protocol === "file:" ) {
28+ const tip = document . createElement ( "div" ) ;
29+ tip . style . cssText = "background:#fff3cd;border:1px solid #ffc107;color:#856404;padding:12px 16px;margin:8px;border-radius:6px;font:14px/1.5 sans-serif;text-align:center;" ;
30+ tip . innerHTML = '<strong>Tip:</strong> This page works via <code>file://</code>, but for the best experience, '
31+ + 'serve it from a web server (e.g. HTTPS or localhost).' ;
32+ document . body . insertBefore ( tip , document . body . firstChild ) ;
33+ }
34+
2635 /** LICENSE ALERT - README
2736 * To use the library, you need to first specify a license key.
2837 *
You can’t perform that action at this time.
0 commit comments