mirror of
https://github.com/ocogeclub/ocoge.git
synced 2024-11-24 08:29:48 +00:00
自作スクリプトをルートフォルダに移動
This commit is contained in:
parent
f511aba1f7
commit
99fd55d53a
@ -931,8 +931,8 @@
|
|||||||
<script src="./google-blockly/blocks_compressed.js"></script>
|
<script src="./google-blockly/blocks_compressed.js"></script>
|
||||||
<script src="./google-blockly/msg/js/ja.js"></script>
|
<script src="./google-blockly/msg/js/ja.js"></script>
|
||||||
<script src="./scripts/custom-dialog.js"></script>
|
<script src="./scripts/custom-dialog.js"></script>
|
||||||
<script src="./scripts/ugj_blocks.js"></script>
|
<script src="./ugj_blocks.js"></script>
|
||||||
<script src="./scripts/ugj_script.js"></script>
|
<script src="./ugj_script.js"></script>
|
||||||
<script src="./scripts/beautify.min.js"></script>
|
<script src="./scripts/beautify.min.js"></script>
|
||||||
<script src="./scripts/prettify.js"></script>
|
<script src="./scripts/prettify.js"></script>
|
||||||
<script src="./.shared/skyway_key.js"></script>
|
<script src="./.shared/skyway_key.js"></script>
|
||||||
|
@ -17,9 +17,5 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# build ocoge
|
# build ocoge
|
||||||
# uncomment if electron will be installed on RPi OS
|
|
||||||
# echo 'arch=armv7l' > ~/.npmrc
|
|
||||||
cd ..
|
cd ..
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
read -p "Press enter to exit: "
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/** Hard Coding!!! */
|
const ugj_const = require('./ugj_const');
|
||||||
const appDocRoot = '/home/pi/Documents/ocoge_docs/'
|
|
||||||
|
|
||||||
/** Fix Basic Blocks ****************************************************************************************/
|
/** Fix Basic Blocks ****************************************************************************************/
|
||||||
var ugjConsrolForDefinition = {
|
var ugjConsrolForDefinition = {
|
||||||
@ -1280,9 +1279,9 @@ Blockly.JavaScript['ugj_canvas_loadimg'] = function (block) {
|
|||||||
var value_imgfilename = Blockly.JavaScript.valueToCode(block, 'imgfilename', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_imgfilename = Blockly.JavaScript.valueToCode(block, 'imgfilename', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = [
|
var code = [
|
||||||
`let img = new Image();`,
|
`let img = new Image();`,
|
||||||
`img.src = '${appDocRoot}' + ${value_imgfilename};`,
|
`img.src = '${ugj_const.doc_root}' + ${value_imgfilename};`,
|
||||||
`img.onload = () => ctx.drawImage(img,0,0);`,
|
`img.onload = () => ctx.drawImage(img,0,0);`,
|
||||||
// `ugj_canvasImg('${appDocRoot}' + ${value_imgfilename});`,
|
// `ugj_canvasImg('${ugj_const.doc_root}' + ${value_imgfilename});`,
|
||||||
''
|
''
|
||||||
].join('\n');
|
].join('\n');
|
||||||
return code;
|
return code;
|
||||||
@ -2086,7 +2085,7 @@ Blockly.Blocks['ugj_file_readsync'] = {
|
|||||||
Blockly.JavaScript['ugj_file_readsync'] = function (block) {
|
Blockly.JavaScript['ugj_file_readsync'] = function (block) {
|
||||||
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var dropdown_encoding = block.getFieldValue('encoding');
|
var dropdown_encoding = block.getFieldValue('encoding');
|
||||||
let filepath = appDocRoot + value_filename.replace(/\'/g, '');
|
let filepath = ugj_const.doc_root + value_filename.replace(/\'/g, '');
|
||||||
var code = `fs.readFileSync('${filepath}', '${dropdown_encoding}')`;
|
var code = `fs.readFileSync('${filepath}', '${dropdown_encoding}')`;
|
||||||
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
return [code, Blockly.JavaScript.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
@ -2406,7 +2405,7 @@ Blockly.Blocks['ugj_child_fswebcam'] = {
|
|||||||
};
|
};
|
||||||
Blockly.JavaScript['ugj_child_fswebcam'] = function (block) {
|
Blockly.JavaScript['ugj_child_fswebcam'] = function (block) {
|
||||||
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
|
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
|
||||||
var code = `'fswebcam', ['-r', '480x360', '${appDocRoot}' + ${value_filename}]`;
|
var code = `'fswebcam', ['-r', '480x360', '${ugj_const.doc_root}' + ${value_filename}]`;
|
||||||
return [code, Blockly.JavaScript.ORDER_NONE];
|
return [code, Blockly.JavaScript.ORDER_NONE];
|
||||||
};
|
};
|
||||||
|
|
3
ugj_const.js
Normal file
3
ugj_const.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports.doc_root = '/home/pi/Documents/ocoge_docs/';
|
||||||
|
module.exports.app_name = 'ocoge';
|
||||||
|
module.exports.mascot_path = '/home/pi/Applications/ocoge/img/';
|
@ -2,14 +2,10 @@
|
|||||||
|
|
||||||
/** Node.js または Electron 固有の機能を利用した関数のモジュール ************* */
|
/** Node.js または Electron 固有の機能を利用した関数のモジュール ************* */
|
||||||
|
|
||||||
// ローカルプロパティ
|
|
||||||
// Hard Coding!!!
|
|
||||||
const appName = 'ocoge';
|
|
||||||
const defpath = '/home/pi/Documents/ocoge_docs/';
|
|
||||||
const mascotDefPath = '/home/pi/Applications/ocoge/img/';
|
|
||||||
// Require
|
// Require
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
const ugj_const = require('./ugj_const');
|
||||||
|
|
||||||
const mainWin = require('@electron/remote').getCurrentWindow();
|
const mainWin = require('@electron/remote').getCurrentWindow();
|
||||||
const dialog = require('@electron/remote').dialog;
|
const dialog = require('@electron/remote').dialog;
|
||||||
@ -18,7 +14,7 @@ const clipboard = require('electron').clipboard;
|
|||||||
|
|
||||||
var saveFilepath = null;
|
var saveFilepath = null;
|
||||||
var wsChanged = false;
|
var wsChanged = false;
|
||||||
var mascotFilePath = mascotDefPath + 'cogechee.png';
|
var mascotFilePath = ugj_const.mascot_path + 'cogechee.png';
|
||||||
|
|
||||||
// 0で数値の桁合わせ
|
// 0で数値の桁合わせ
|
||||||
// NUM=値 LEN=桁数
|
// NUM=値 LEN=桁数
|
||||||
@ -28,7 +24,7 @@ const zeroPadding = (NUM, LEN) => (Array(LEN).join('0') + NUM).slice(-LEN);
|
|||||||
const getUniqueFilepath = () => {
|
const getUniqueFilepath = () => {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let filename = today.getFullYear() + '-' + zeroPadding((today.getMonth() + 1), 2) + '-' + zeroPadding(today.getDate(), 2) + '-' + zeroPadding(today.getHours(), 2) + '-' + zeroPadding(today.getMinutes(), 2) + '-' + zeroPadding(today.getSeconds(), 2);
|
let filename = today.getFullYear() + '-' + zeroPadding((today.getMonth() + 1), 2) + '-' + zeroPadding(today.getDate(), 2) + '-' + zeroPadding(today.getHours(), 2) + '-' + zeroPadding(today.getMinutes(), 2) + '-' + zeroPadding(today.getSeconds(), 2);
|
||||||
let filepath = path.join(defpath, filename);
|
let filepath = path.join(ugj_const.doc_root, filename);
|
||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,8 +38,8 @@ exports.openURL = (url) => {
|
|||||||
|
|
||||||
// タイトルバーにファイル名を表示
|
// タイトルバーにファイル名を表示
|
||||||
// const setTitle = () => {
|
// const setTitle = () => {
|
||||||
// if (saveFilepath) let title = appName;
|
// if (saveFilepath) let title = ugj_const.app_name;
|
||||||
// else let title = saveFilepath + ' - ' + appName;
|
// else let title = saveFilepath + ' - ' + ugj_const.app_name;
|
||||||
// mainWin.setTitle(title);
|
// mainWin.setTitle(title);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -52,8 +48,8 @@ exports.openURL = (url) => {
|
|||||||
const setSaveFilepath = filepath => {
|
const setSaveFilepath = filepath => {
|
||||||
let title;
|
let title;
|
||||||
saveFilepath = filepath;
|
saveFilepath = filepath;
|
||||||
// if (filepath) title = filepath + ' - ' + appName;
|
// if (filepath) title = filepath + ' - ' + ugj_const.app_name;
|
||||||
// else title = appName;
|
// else title = ugj_const.app_name;
|
||||||
// mainWin.setTitle(title);
|
// mainWin.setTitle(title);
|
||||||
this.setWsChanged(false);
|
this.setWsChanged(false);
|
||||||
}
|
}
|
||||||
@ -63,8 +59,8 @@ const setSaveFilepath = filepath => {
|
|||||||
exports.setWsChanged = changed => {
|
exports.setWsChanged = changed => {
|
||||||
let title;
|
let title;
|
||||||
wsChanged = changed;
|
wsChanged = changed;
|
||||||
if (saveFilepath) title = saveFilepath + ' - ' + appName;
|
if (saveFilepath) title = saveFilepath + ' - ' + ugj_const.app_name;
|
||||||
else title = appName;
|
else title = ugj_const.app_name;
|
||||||
if (changed) title = '*' + title;
|
if (changed) title = '*' + title;
|
||||||
mainWin.setTitle(title);
|
mainWin.setTitle(title);
|
||||||
}
|
}
|
||||||
@ -74,7 +70,7 @@ exports.newFile = () => setSaveFilepath(null);
|
|||||||
|
|
||||||
// ワークスペースファイル読み込みの一連の動作のラッパ
|
// ワークスペースファイル読み込みの一連の動作のラッパ
|
||||||
exports.loadWsFile = () => {
|
exports.loadWsFile = () => {
|
||||||
let filepath = openFile('xml', defpath);
|
let filepath = openFile('xml', ugj_const.doc_root);
|
||||||
if (filepath.length > 0) {
|
if (filepath.length > 0) {
|
||||||
if (saveFilepath === null) {
|
if (saveFilepath === null) {
|
||||||
setSaveFilepath(filepath);
|
setSaveFilepath(filepath);
|
||||||
@ -86,7 +82,7 @@ exports.loadWsFile = () => {
|
|||||||
}
|
}
|
||||||
// その他ファイル読み込みの一連の動作のラッパ
|
// その他ファイル読み込みの一連の動作のラッパ
|
||||||
exports.loadFile = ext => {
|
exports.loadFile = ext => {
|
||||||
let filepath = openFile(ext, defpath);
|
let filepath = openFile(ext, ugj_const.doc_root);
|
||||||
if (filepath.length > 0) {
|
if (filepath.length > 0) {
|
||||||
return readFromFile(filepath);
|
return readFromFile(filepath);
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +90,7 @@ exports.loadFile = ext => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.selectMascotFile = () => {
|
exports.selectMascotFile = () => {
|
||||||
return openFile('png', mascotDefPath);
|
return openFile('png', ugj_const.mascot_path);
|
||||||
}
|
}
|
||||||
// オープンファイルダイアログ
|
// オープンファイルダイアログ
|
||||||
const openFile = (ext, dpath) => {
|
const openFile = (ext, dpath) => {
|
@ -630,7 +630,7 @@ window.onbeforeunload = () => {
|
|||||||
// Electron動作とブラウザ動作を自動で仕分け
|
// Electron動作とブラウザ動作を自動で仕分け
|
||||||
if (typeof require == 'function') {
|
if (typeof require == 'function') {
|
||||||
// requireが使える = Electron
|
// requireが使える = Electron
|
||||||
var elec = require('./scripts/eleclib');
|
var elec = require('./ugj_eleclib');
|
||||||
console.log('elec loaded.');
|
console.log('elec loaded.');
|
||||||
} else {
|
} else {
|
||||||
//ブラウザ動作
|
//ブラウザ動作
|
Loading…
Reference in New Issue
Block a user