ocoge/blocks/index.js

36 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2023-01-20 12:21:43 +00:00
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;
}
}
2023-01-20 12:21:43 +00:00
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;
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = fname;
script.async = false;
2023-01-20 12:21:43 +00:00
script.defer = true;
document.body.appendChild(script);
}
}
// センサーカテゴリ
registerCategory('sensors', [ // サブカテゴリファイル名
"amg8833.js",
"sfmv17.js",
"paj7620.js",
"bme280.js",
"ssd1306.js",
"z-line.js" // フライアウト下端の不可視ライン。フライアウトのアップデートをここで行っているので変更・削除に注意!
]);