mami/src/mami.js/eeprom/eeprom.js

39 lines
1 KiB
JavaScript

#include utility.js
const MamiEEPROM = function() {
//
};
MamiEEPROM.init = (function() {
let initialised = false;
return () => {
return new Promise((resolve, reject) => {
if(initialised)
return new Promise(resolve => resolve());
// cuts off "/uploads", this is little disgusting
const src = futami.get('eeprom').slice(0, -8) + '/eeprom.js';
const script = $e({
tag: 'script',
attrs: {
charset: 'utf-8',
type: 'text/javascript',
src: src,
onload: () => {
initialised = true;
resolve();
},
onerror: () => {
$r(script);
console.error('Failed to load EEPROM script!');
reject();
},
},
});
document.body.appendChild(script);
});
};
})();