ocoge/blocks/index.js
2023-06-25 21:18:33 +09:00

36 lines
1.1 KiB
JavaScript

apptool.blocks_dir = (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(/[^/]*$/, '').replace('file://', '')
})();
var flyout_contents = [];
const registerCategory = (category_dir, subcategories) => {
for (let sbctgr of subcategories) {
let fname = apptool.blocks_dir + category_dir + '/' + sbctgr + "/index.js";
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = fname;
script.async = false;
script.defer = true;
document.body.appendChild(script);
}
}
// センサーカテゴリ
registerCategory('sensors', [ // カテゴリディレクトリ名
"amg8833",
"paj7620",
"bme280",
// "dht11",
// "pico_slave",
"z-line" // フライアウト下端の不可視ライン。スクリプトにカテゴリ名を含むので注意
]);