Skip to content

Commit

Permalink
修正scratch3_dataProcessing積木
Browse files Browse the repository at this point in the history
  • Loading branch information
estea8968 committed Oct 17, 2024
1 parent 6fcd5d9 commit e282d46
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 45 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" value="notranslate">
<link rel="shortcut icon" href="static/favicon.ico">
<title>OSEP_scratch 1130925</title>
<title>OSEP_scratch 1131017</title>

</head>
<body>
Expand Down
39 changes: 26 additions & 13 deletions app/lib.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -410761,7 +410761,7 @@ var dataProcessing = /*#__PURE__*/function () {
},
text: msg.endsWith[theLocale]
}, "---", {
opcode: 'replace',
opcode: 'replaceAll',
blockType: BlockType.REPORTER,
arguments: {
data: {
Expand All @@ -410777,7 +410777,7 @@ var dataProcessing = /*#__PURE__*/function () {
defaultValue: 'a'
}
},
text: msg.replace[theLocale]
text: msg.replaceAll[theLocale]
}, {
opcode: 'repeat',
blockType: BlockType.REPORTER,
Expand Down Expand Up @@ -410940,12 +410940,12 @@ var dataProcessing = /*#__PURE__*/function () {
return data.endsWith(text);
}
}, {
key: "replace",
value: function replace(args) {
key: "replaceAll",
value: function replaceAll(args) {
var data = args.data;
var originalText = args.originalText;
var replaceText = args.replaceText;
var text = data.replace(originalText, replaceText);
var text = data.replaceAll(originalText, replaceText);
return text;
}
}, {
Expand Down Expand Up @@ -411014,7 +411014,7 @@ module.exports = dataProcessing;
/*!***************************************************************************************!*\
!*** ./node_modules/scratch-vm/src/extensions/scratch3_dataProcessing/translation.js ***!
\***************************************************************************************/
/*! exports provided: title, conversion, Binary, Octal, Decimal, Hexadecimal, substring, startsWith, endsWith, replace, repeat, trim, uppercase, lowerCase, FormConverNum */
/*! exports provided: title, conversion, Binary, Octal, Decimal, Hexadecimal, substring, startsWith, endsWith, replaceAll, repeat, trim, uppercase, lowerCase, FormConverNum */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Expand All @@ -411028,7 +411028,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substring", function() { return substring; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "startsWith", function() { return startsWith; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "endsWith", function() { return endsWith; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replace", function() { return replace; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replaceAll", function() { return replaceAll; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "repeat", function() { return repeat; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "trim", function() { return trim; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "uppercase", function() { return uppercase; });
Expand Down Expand Up @@ -411070,9 +411070,9 @@ var endsWith = {
'en': '[data] ends with [text]?',
'zh-tw': '[data]用[text]結尾?'
};
var replace = {
'en': 'replace [data] [originalText] with [replaceText]',
'zh-tw': '把[data]內的[originalText]換成[replaceText]'
var replaceAll = {
'en': 'replace all the [originalText] in [data] with [replaceText]',
'zh-tw': '把[data]內所有的[originalText]取代成[replaceText]'
};
var repeat = {
'en': 'repeat [data] [number] times',
Expand Down Expand Up @@ -418782,15 +418782,15 @@ var scratch3_gemini = /*#__PURE__*/function () {
text: msg.set_temperature[theLocale]
},
/*{
opcode: 'set_assistant',
opcode: 'upload_file',
blockType: BlockType.COMMAND,
arguments: {
ASSISTANT: {
type: ArgumentType.STRING,
defaultValue: ' '
},
},
text: msg.set_assistant[theLocale]
text: msg.upload_file[theLocale]
},*/
{
opcode: 'do_question',
Expand Down Expand Up @@ -418845,6 +418845,13 @@ var scratch3_gemini = /*#__PURE__*/function () {
value: function openai_apikey(args) {
this.api_key = args.KEY;
}
/*upload_file(){
const fileUploader = document.querySelector('#file-uploader');
fileUploader.addEventListener('change', (e) => {
console.log(e.target.files); // get file object
});
}*/

}, {
key: "set_ai_modle",
value: function set_ai_modle(args) {
Expand Down Expand Up @@ -419094,7 +419101,7 @@ module.exports = scratch3_gemini;
/*!*******************************************************************************!*\
!*** ./node_modules/scratch-vm/src/extensions/scratch3_gemini/translation.js ***!
\*******************************************************************************/
/*! exports provided: openai_apikey, ananswer, copyTEXT_memory, size, drawimage, set_ai_user, set_ai_modle, set_max_token, set_temperature, set_assistant, set_question, error_ai, error_api_key_null, name */
/*! exports provided: openai_apikey, ananswer, copyTEXT_memory, size, drawimage, set_ai_user, set_ai_modle, set_max_token, set_temperature, set_assistant, set_question, error_ai, error_api_key_null, name, upload_file */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Expand All @@ -419113,6 +419120,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "error_ai", function() { return error_ai; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "error_api_key_null", function() { return error_api_key_null; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "upload_file", function() { return upload_file; });
var openai_apikey = {
'en': 'Gemini API key[KEY]',
'zh-tw': 'Gemini金鑰[KEY]'
Expand Down Expand Up @@ -419174,6 +419182,10 @@ var name = {
'en': 'GeminiAI',
'zh-tw': 'GeminiAI'
};
var upload_file = {
'en': 'Up load file',
'zh-tw': '上傳檔案'
};

/***/ }),

Expand Down Expand Up @@ -510094,6 +510106,7 @@ var mapStateToProps = function mapStateToProps(state, ownProps) {
accountMenuOpen: Object(_reducers_menus__WEBPACK_IMPORTED_MODULE_31__["accountMenuOpen"])(state),
fileMenuOpen: Object(_reducers_menus__WEBPACK_IMPORTED_MODULE_31__["fileMenuOpen"])(state),
editMenuOpen: Object(_reducers_menus__WEBPACK_IMPORTED_MODULE_31__["editMenuOpen"])(state),
farmwareOpen: Object(_reducers_menus__WEBPACK_IMPORTED_MODULE_31__["farmwareMenuOpen"])(state),
isRtl: state.locales.isRtl,
isUpdating: Object(_reducers_project_state__WEBPACK_IMPORTED_MODULE_30__["getIsUpdating"])(loadingState),
isShowingProject: Object(_reducers_project_state__WEBPACK_IMPORTED_MODULE_30__["getIsShowingProject"])(loadingState),
Expand Down
2 changes: 1 addition & 1 deletion app/lib.min.js.map

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions source/scratch-vm/src/extensions/scratch3_dataProcessing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class dataProcessing {
},
"---",
{
opcode: 'replace',
opcode: 'replaceAll',
blockType: BlockType.REPORTER,
arguments: {
data: {
Expand All @@ -178,7 +178,7 @@ class dataProcessing {
defaultValue: 'a'
},
},
text: msg.replace[theLocale]
text: msg.replaceAll[theLocale]
},
{
opcode: 'repeat',
Expand Down Expand Up @@ -316,75 +316,75 @@ class dataProcessing {
return text;
}

startsWith(args){
startsWith(args) {
var data = args.data;
var text = args.text;

return data.startsWith(text);
}

endsWith(args){
endsWith(args) {
var data = args.data;
var text = args.text;

return data.endsWith(text);
}

replace(args) {
replaceAll(args) {
var data = args.data;
var originalText = args.originalText;
var replaceText = args.replaceText;
var text = data.replace(originalText, replaceText);
var text = data.replaceAll(originalText, replaceText);

return text;
}

repeat(args){
repeat(args) {
var data = args.data;
var number = args.number;

return data.repeat(number);
}

trim(args){
trim(args) {
return args.data.trim();
}

uppercase(args){
uppercase(args) {
return args.data.toUpperCase();
}

lowerCase(args){
lowerCase(args) {
return args.data.toLowerCase();
}

conver_num(args){
const value = parseInt(args.VALUE,10) ;
let f_begin = parseInt(args.F_BEGIN,10);
let f_end = parseInt(args.F_END,10);
conver_num(args) {
const value = parseInt(args.VALUE, 10);
let f_begin = parseInt(args.F_BEGIN, 10);
let f_end = parseInt(args.F_END, 10);
let f_range;
if(f_end>f_begin){
f_range = f_end-f_begin;
}else{
f_range = f_begin-f_end;
if (f_end > f_begin) {
f_range = f_end - f_begin;
} else {
f_range = f_begin - f_end;
}
const t_begin = parseInt(args.T_BEGIN,10);
const t_end = parseInt(args.T_END,10);
const t_begin = parseInt(args.T_BEGIN, 10);
const t_end = parseInt(args.T_END, 10);
let t_range;
let t_add;
if(t_end>t_begin){
t_range = t_end -t_begin;
if (t_end > t_begin) {
t_range = t_end - t_begin;
t_add = t_begin;
}else{
t_range = t_begin-t_end;
} else {
t_range = t_begin - t_end;
t_add = t_end;
}
const conver_value = Math.round(((value/f_range)*t_range)+t_add);
console.log('conver_value',conver_value);
const conver_value = Math.round(((value / f_range) * t_range) + t_add);
console.log('conver_value', conver_value);
return conver_value;
}


}

module.exports = dataProcessing;
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const endsWith = {
'zh-tw': '[data]用[text]結尾?'
};

export const replace = {
'en': 'replace [data] [originalText] with [replaceText]',
'zh-tw': '把[data]內的[originalText]換成[replaceText]'
export const replaceAll = {
'en': 'replace all the [originalText] in [data] with [replaceText]',
'zh-tw': '把[data]內所有的[originalText]取代成[replaceText]'
};

export const repeat = {
Expand Down

0 comments on commit e282d46

Please sign in to comment.