Cat-Printer/www/loader.js
NaitLee 500971ae95 Major code clean up; new features:
Test unknown devices (scan everything)
Rework of Web FE Event & Dispatch
Fix major performance problem
Better image processing algorithm
New Halftone-like dither algo., namingly "Pattern"
Some fixes to CSS
Fix potential misc problems by manual testing
2022-07-15 02:51:44 +08:00

46 lines
1.3 KiB
JavaScript

`
Copyright © 2021-2022 NaitLee Soft. No rights reserved.
License CC0-1.0-only: https://directory.fsf.org/wiki/License:CC0
`;
window.exports = {};
/**
* Satisfy both development and old-old webView need
*/
(function() {
var fallbacks;
if (location.href.indexOf('?debug') !== -1)
fallbacks = ['i18n-ext.js', 'i18n.js', 'image.js', 'accessibility.js', 'main.js'];
else
fallbacks = ['~every.js', 'main.comp.js'];
var trial_count = 0;
/**
* Try to load next "fallback" script,
* until we see the "main" variable (ie. success)
* fail if nothing is left to load.
* This is recursive. Just call once.
*/
function try_load() {
var script = document.createElement('script');
script.addEventListener('load', function() {
if (typeof main === 'undefined') {
// the script can't be 'unrun', though
script.remove();
try_load();
} else {
console.log('Success');
}
});
var path = fallbacks[trial_count++];
if (!path) throw new Error('All fallback scripts were tried');
script.src = path;
console.log('Trying script: ' + path);
document.body.appendChild(script);
}
try_load();
})();