ocoge/blocks/index.js

34 lines
1.0 KiB
JavaScript
Raw Normal View History

const current = (function () {
let r = "";
if (document.currentScript) {
r = document.currentScript.src;
} else {
var scripts = document.getElementsByTagName('script'),
script = scripts[scripts.length - 1];
if (script.src) {
r = script.src;
}
}
return r.replace(/[^/]*$/, '')
})();
var flyout_contents = [];
const registerCategory = (category_dir, subcategories) => {
for (let sbctgr of subcategories) {
let fname = current + category_dir + '/' + sbctgr + "/index.js";
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = fname;
script.async = false;
document.body.appendChild(script);
}
}
// センサーカテゴリ
registerCategory('sensors', [ // カテゴリディレクトリ名
"amg8833",
"paj7620",
"bme280",
"dht11",
"z-line" // フライアウト下端の不可視ライン。スクリプトにカテゴリ名を含むので注意
]);