mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-24 00:19:48 +00:00
35 lines
1.1 KiB
JavaScript
35 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",
|
|
"z-line" // フライアウト下端の不可視ライン。スクリプトにカテゴリ名を含むので注意
|
|
]);
|