Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bddjr committed Jul 3, 2023
1 parent 01400a5 commit dd09680
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 94 deletions.
16 changes: 10 additions & 6 deletions categorys/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const {
} = require('../myjs/menus.js');


//===========================================================
//2.0.0

function get_value_for_sort( thisjson, keymode, keyslist ){
if( typeof keyslist === 'number' ){
return thisjson[ keyslist ];
Expand Down Expand Up @@ -57,6 +60,8 @@ function get_value_for_sort( thisjson, keymode, keyslist ){
return thisjson
}

//===========================================================


/** @param {string} category_id */
module.exports = ( category_id )=>{ api.addBlocks([
Expand Down Expand Up @@ -164,7 +169,7 @@ module.exports = ( category_id )=>{ api.addBlocks([
},
},
//===========================================================
{//2.0.0
{//2.0.1
opcode: `${category_id}.lastIndexOf`,
messageId: `${category_id}.lastIndexOf`,
categoryId: category_id,
Expand All @@ -186,10 +191,11 @@ module.exports = ( category_id )=>{ api.addBlocks([
v1 = JSON.parse( v1 );

let v2 = args.v2;
if( typeof v2 !== 'object' )
if( typeof v2 !== 'object' ){
try{
v2 = JSON.parse( v2 );
}catch{}
}

return v1.lastIndexOf(v2);

Expand Down Expand Up @@ -538,7 +544,7 @@ module.exports = ( category_id )=>{ api.addBlocks([
},
},
//===========================================================
{//2.0.0
{//2.0.1
opcode: `${category_id}.concat`,
messageId: `${category_id}.concat`,
categoryId: category_id,
Expand Down Expand Up @@ -566,10 +572,8 @@ module.exports = ( category_id )=>{ api.addBlocks([

let v2 = args.v2;
if( typeof v2 !== 'object' ){
if( typeof v2 === 'string' )
v2 = `[${v2}]`;
try{
v2 = JSON.parse( v2 );
v2 = JSON.parse(`[${v2}]`);
}catch{}
}

Expand Down
77 changes: 72 additions & 5 deletions categorys/debug.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
const { type, api } = require('clipcc-extension');

/**@type {any}*/
const vm = api.getVmInstance();

const {
err_msg
err_msg,
my_log_block_error,
returnType,
get_sprite_target
} = require('../myjs/tools');

const {
make_menus
make_menus,
myTypeMenu,
sprite_type_menu,
sprites_name_menu
} = require('../myjs/menus');

/**@param {string} category_id*/
Expand All @@ -20,7 +27,7 @@ module.exports = ( category_id )=>{ api.addBlocks([
function: (args,util)=> err_msg[0]
},
//===========================================================
{//2.0.0
{//2.0.1
opcode: `${category_id}.console`,
messageId: `${category_id}.console`,
categoryId: category_id,
Expand Down Expand Up @@ -58,10 +65,11 @@ module.exports = ( category_id )=>{ api.addBlocks([
if( typeof v !== 'object' ){
try{
v = JSON.parse(`[${v}]`);
console[ args.type ]( ...v );
return;
}catch{}
}

console[ args.type ]( ...v );
console[ args.type ]( v );
}
},
//===========================================================
Expand All @@ -72,5 +80,64 @@ module.exports = ( category_id )=>{ api.addBlocks([
type: type.BlockType.REPORTER,
function: (args,util)=> vm.toJSON()
},
//===========================================================
{//2.0.1
opcode: `${category_id}.temp_var`,
messageId: `${category_id}.temp_var`,
categoryId: category_id,
type: type.BlockType.REPORTER,
param: {
return_type: {
type: type.ParameterType.STRING,
default: 'ScratchType',
menu: myTypeMenu
},
},
function: (args,util)=>{
try{
return returnType(
vm.bddjr_toolbox_v2_temp_var ,
args.return_type
);
}catch(e){
return my_log_block_error( util.currentBlock.id, util.currentBlock.opcode, e )
}
}
},
//===========================================================
{//2.0.1
opcode: `${category_id}.sprite_temp_var`,
messageId: `${category_id}.sprite_temp_var`,
categoryId: category_id,
type: type.BlockType.REPORTER,
param: {
sprite_type: {
type: type.ParameterType.STRING,
default: 'thisClone',
menu: sprite_type_menu
},
sprite_name: {
type: type.ParameterType.STRING,
default: '',
// @ts-ignore
menu: sprites_name_menu
},
return_type: {
type: type.ParameterType.STRING,
default: 'ScratchType',
menu: myTypeMenu
},
},
function: (args,util)=>{
try{
return returnType(
get_sprite_target( util, args.sprite_type, args.sprite_name ).bddjr_toolbox_v2_temp_var ,
args.return_type
);
}catch(e){
return my_log_block_error( util.currentBlock.id, util.currentBlock.opcode, e )
}
}
},

]);}
38 changes: 31 additions & 7 deletions categorys/help.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
const { type, api } = require('clipcc-extension');

//===========================================================
//2.0.1

/**
* @param {String} name
* @param {String} link
*/
function jumpto(name, link){
if(window.confirm(`你确定要跳转到${name}吗?\n${link}`)){ //弹窗确认
window.open(link);
}
}

//===========================================================

/**@param {string} category_id*/
module.exports = ( category_id )=>{ api.addBlocks([
// 创建一个不能被程序触发的积木,点击它就会直接跳转到github仓库地址
{//2.0.0
// 创建不能被程序触发的积木,鼠标点击才能触发
{//2.0.1
opcode: `${category_id}.jumptogithub`,
messageId: `${category_id}.jumptogithub`,
categoryId: category_id,
type: undefined,
function: (args,util)=>{
if(window.confirm("你确定要跳转到github吗?")){ //弹窗确认
window.open("https://github.com/bddjr/clipcc-extension-bddjr_toolbox_v2");
}
},
function: ()=> jumpto(
'Github',
"https://github.com/bddjr/clipcc-extension-bddjr_toolbox_v2/"
),
},
{//2.0.1
opcode: `${category_id}.doc`,
messageId: `${category_id}.doc`,
categoryId: category_id,
type: undefined,
function: ()=> jumpto(
'文档',
"https://btbv2.ccext.bddjr.cn"
),
},
]);}
44 changes: 42 additions & 2 deletions categorys/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = ( category_id )=>{ api.addBlocks([
},
},
//======================================================================================================================
{//2.0.0
{//2.0.1
opcode: `${category_id}.set_value`,
messageId: `${category_id}.set_value`,
categoryId: category_id,
Expand Down Expand Up @@ -170,24 +170,44 @@ module.exports = ( category_id )=>{ api.addBlocks([
setKey = keyslist;
else if( args.keymode === 'Array' ){
for( let i=0 ; i< keyslist.length-1 ; i++ ){
if( (+i)<0 && Array.isArray(thisjson) ){
// 兼容数组负数下标取值
i = thisjson.length + (+i);
}
thisjson = thisjson[ keyslist[i] ];
}
setKey = keyslist.slice(-1);
}else{ // args.keymode === '.'
if( Array.isArray( keyslist ) ){
for( let i of keyslist ){
if( Array.isArray( i ) ){
if( Array.isArray(thisjson) && (+i[0])<0 ){
// 兼容数组负数下标取值
i[0] = thisjson.length + (+i[0]);
}
thisjson = thisjson[ i[0] ];
if( i[1] ==='?.' && !thisjson )
break;
}else{
if( Array.isArray(thisjson) && (+i)<0 ){
// 兼容数组负数下标取值
i = thisjson.length + (+i);
}
setKey = i ;
}
}
}else{ // typeof keyslist === 'string'
if( Array.isArray(thisjson) && (+keyslist)<0 ){
// 兼容数组负数下标取值
keyslist = thisjson.length + (+keyslist);
}
setKey = keyslist;
}
}
if( Array.isArray(thisjson) && (+setKey)<0 ){
// 兼容数组负数下标取值
setKey = thisjson.length + (+setKey);
}
switch( args.operator ){
case '=':
thisjson[setKey] = setValue;
Expand Down Expand Up @@ -293,7 +313,7 @@ module.exports = ( category_id )=>{ api.addBlocks([
},
},
//======================================================================================================================
{//2.0.0
{//2.0.1
opcode: `${category_id}.deleteProperty`,
messageId: `${category_id}.deleteProperty`,
categoryId: category_id,
Expand Down Expand Up @@ -335,24 +355,44 @@ module.exports = ( category_id )=>{ api.addBlocks([
setKey = keyslist;
else if( args.keymode === 'Array' ){
for( let i=0 ; i< keyslist.length-1 ; i++ ){
if( (+i)<0 && Array.isArray(thisjson) ){
// 兼容数组负数下标取值
i = thisjson.length + (+i);
}
thisjson = thisjson[ keyslist[i] ];
}
setKey = keyslist.slice(-1);
}else{ // args.keymode === '.'
if( Array.isArray( keyslist ) ){
for( let i of keyslist ){
if( Array.isArray( i ) ){
if( Array.isArray(thisjson) && (+i[0])<0 ){
// 兼容数组负数下标取值
i[0] = thisjson.length + (+i[0]);
}
thisjson = thisjson[ i[0] ];
if( i[1] ==='?.' && !thisjson )
break;
}else{
if( Array.isArray(thisjson) && (+i)<0 ){
// 兼容数组负数下标取值
i = thisjson.length + (+i);
}
setKey = i ;
}
}
}else{ // typeof keyslist === 'string'
if( Array.isArray(thisjson) && (+keyslist)<0 ){
// 兼容数组负数下标取值
keyslist = thisjson.length + (+keyslist);
}
setKey = keyslist;
}
}
if( Array.isArray(thisjson) && (+setKey)<0 ){
// 兼容数组负数下标取值
setKey = thisjson.length + (+setKey);
}
Reflect.deleteProperty( thisjson, setKey );
return returnType( globaljson, args.return_type );

Expand Down
30 changes: 27 additions & 3 deletions categorys/string_and_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,22 +597,46 @@ module.exports = ( category_id )=>{ api.addBlocks([
function: (args,util)=> String.fromCharCode( args.n1 )
},
//===========================================================
{//2.0.0
{//2.0.1
opcode: `${category_id}.repeat`,
messageId: `${category_id}.repeat`,
categoryId: category_id,
type: type.BlockType.REPORTER,
param: {
v: {
type: type.ParameterType.STRING,
default: ''
default: '我爱你!'
},
n1: {
type: type.ParameterType.NUMBER,
default: '2'
default: '520'
}
},
function: (args,util)=> String( args.v ).repeat( args.n1 )
},
//===========================================================
{//2.0.1
opcode: `${category_id}.instanceof`,
messageId: `${category_id}.instanceof`,
categoryId: category_id,
type: type.BlockType.BOOLEAN,
param: {
v1: {
type: undefined
},
v2: {
type: type.ParameterType.STRING,
default: 'Set'
},
},
function: (args,util)=>{
try{
// @ts-ignore
return args.v1 instanceof window[ args.v2 ];
}catch(e){
return my_log_block_error( util.currentBlock.id, util.currentBlock.opcode, e );
}
}
},

]);}
Loading

0 comments on commit dd09680

Please sign in to comment.