From 42911989bbd4a1aaace1e42cd7cd487a4358ee18 Mon Sep 17 00:00:00 2001 From: 0832k12 <70421730+0832k12@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:03:49 +0800 Subject: [PATCH 1/6] Add SuperAlert --- extensions/0832/SuperAlert.js | 128 ++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 extensions/0832/SuperAlert.js diff --git a/extensions/0832/SuperAlert.js b/extensions/0832/SuperAlert.js new file mode 100644 index 0000000000..a2d82a28e3 --- /dev/null +++ b/extensions/0832/SuperAlert.js @@ -0,0 +1,128 @@ +(function (Scratch) { + 'use strict'; + var b = false; + var c; + + function d() { + c = document.createElement("div"); + c.style.position = "fixed"; + c.style.backgroundColor = "white"; + c.style.border = "1px solid black"; + c.style.top = "50%"; + c.style.left = "50%"; + c.style.transform = "translate(-50%, -50%)"; + c.style.display = "none"; + c.style.borderRadius = "10px"; + c.style.color = "white"; + c.style.backgroundColor = "black"; + c.style.border = "1px solid white"; + c.style.padding = "20px"; + c.style.textAlign = "center"; + c.style.transition = "opacity 0.3s, transform 0.3s"; + c.style.opacity = "0"; + document.body.appendChild(c); + setTimeout(function () { + b = true; + c.style.opacity = "1"; + c.style.transform = "translate(-50%, -50%) scale(1)"; + c.style.display = "block"; + }, 100); + } + + function e() { + c.style.opacity = "0"; + c.style.transform = "translate(-50%, -50%) scale(0)"; + setTimeout(function () { + document.body.removeChild(c); + b = false; + }, 300); + } + + class f { + constructor() { + this.g = ""; + this.h = ""; + } + d() { + if (!b) { + d(); + c.style.display = "block"; + this.i(); + } + } + + e() { + if (b) { + e(); + } + } + + j(k) { + this.g = k.L; + this.i(); + } + + l(k) { + this.h = k.M; + this.i(); + } + + i() { + if (b) { + c.style.opacity = "0"; + c.style.transform = "translate(-50%, -50%) scale(0)"; + setTimeout(() => { + c.innerHTML = ` +

${this.g}

+

${this.h}

+ `; + c.style.opacity = "1"; + c.style.transform = "translate(-50%, -50%) scale(1)"; + }, 300); + } + } + + getInfo() { + return { + id: 'tc', + name: '弹窗', + blocks: [ + { + opcode: 'd', + blockType: Scratch.BlockType.COMMAND, + text: '显示弹窗', + }, + { + opcode: 'e', + blockType: Scratch.BlockType.COMMAND, + text: '隐藏弹窗', + }, + { + opcode: 'j', + blockType: Scratch.BlockType.COMMAND, + text: '设置弹窗标题为 [L]', + arguments: { + L: { + type: Scratch.ArgumentType.STRING, + defaultValue: '标题', + }, + }, + }, + { + opcode: 'l', + blockType: Scratch.BlockType.COMMAND, + text: '设置弹窗内容为 [M]', + arguments: { + M: { + type: Scratch.ArgumentType.STRING, + defaultValue: '内容', + }, + }, + }, + ], + }; + } + } + + Scratch.extensions.register(new f()); +})(Scratch); From ccca96c5117df2814d0bcdacfd2b35a3f048cd21 Mon Sep 17 00:00:00 2001 From: 0832k12 <70421730+0832k12@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:08:12 +0800 Subject: [PATCH 2/6] repair bug --- extensions/0832/SuperAlert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/0832/SuperAlert.js b/extensions/0832/SuperAlert.js index a2d82a28e3..9eb106a11c 100644 --- a/extensions/0832/SuperAlert.js +++ b/extensions/0832/SuperAlert.js @@ -125,4 +125,4 @@ } Scratch.extensions.register(new f()); -})(Scratch); +})(Scratch); From 0a04ba9874158f5a6eae18d9b2a244c3ab95cb8d Mon Sep 17 00:00:00 2001 From: 0832k12 <70421730+0832k12@users.noreply.github.com> Date: Fri, 14 Jul 2023 21:37:35 +0800 Subject: [PATCH 3/6] Do translation --- extensions/0832/SuperAlert.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/extensions/0832/SuperAlert.js b/extensions/0832/SuperAlert.js index 9eb106a11c..133e2a2faf 100644 --- a/extensions/0832/SuperAlert.js +++ b/extensions/0832/SuperAlert.js @@ -2,7 +2,15 @@ 'use strict'; var b = false; var c; - + Scratch.translate.setup({ + zh: { + name: '弹窗', + d: '显示弹窗', + e: '隐藏弹窗', + j: '设置弹窗标题为 [L]', + l: '设置弹窗内容为 [M]', + }, + }); function d() { c = document.createElement("div"); c.style.position = "fixed"; @@ -85,22 +93,22 @@ getInfo() { return { id: 'tc', - name: '弹窗', + name: Scratch.translate({ id: 'name', default: 'SuperAlert' }), blocks: [ { opcode: 'd', blockType: Scratch.BlockType.COMMAND, - text: '显示弹窗', + text: Scratch.translate({ id: 'd', default: 'Show alert' }) }, { opcode: 'e', blockType: Scratch.BlockType.COMMAND, - text: '隐藏弹窗', + text: Scratch.translate({ id: 'e', default: 'Hide alert' }) }, { opcode: 'j', blockType: Scratch.BlockType.COMMAND, - text: '设置弹窗标题为 [L]', + text: Scratch.translate({ id: 'j', default: 'Set the alert title to [L]' }), arguments: { L: { type: Scratch.ArgumentType.STRING, @@ -111,7 +119,7 @@ { opcode: 'l', blockType: Scratch.BlockType.COMMAND, - text: '设置弹窗内容为 [M]', + text: Scratch.translate({ id: 'l', default: 'Set the alert content to [M]' }), arguments: { M: { type: Scratch.ArgumentType.STRING, From 3d82cfc83a7da4ad8c07d27eb44d50c4dab0eed0 Mon Sep 17 00:00:00 2001 From: 0832k12 <70421730+0832k12@users.noreply.github.com> Date: Fri, 21 Jul 2023 10:08:35 +0800 Subject: [PATCH 4/6] Use advice --- extensions/0832/SuperAlert.js | 415 ++++++++++++++++++++++++---------- 1 file changed, 298 insertions(+), 117 deletions(-) diff --git a/extensions/0832/SuperAlert.js b/extensions/0832/SuperAlert.js index 133e2a2faf..d088c5308f 100644 --- a/extensions/0832/SuperAlert.js +++ b/extensions/0832/SuperAlert.js @@ -1,136 +1,317 @@ -(function (Scratch) { - 'use strict'; - var b = false; - var c; - Scratch.translate.setup({ - zh: { - name: '弹窗', - d: '显示弹窗', - e: '隐藏弹窗', - j: '设置弹窗标题为 [L]', - l: '设置弹窗内容为 [M]', - }, - }); - function d() { - c = document.createElement("div"); - c.style.position = "fixed"; - c.style.backgroundColor = "white"; - c.style.border = "1px solid black"; - c.style.top = "50%"; - c.style.left = "50%"; - c.style.transform = "translate(-50%, -50%)"; - c.style.display = "none"; - c.style.borderRadius = "10px"; - c.style.color = "white"; - c.style.backgroundColor = "black"; - c.style.border = "1px solid white"; - c.style.padding = "20px"; - c.style.textAlign = "center"; - c.style.transition = "opacity 0.3s, transform 0.3s"; - c.style.opacity = "0"; - document.body.appendChild(c); - setTimeout(function () { - b = true; - c.style.opacity = "1"; - c.style.transform = "translate(-50%, -50%) scale(1)"; - c.style.display = "block"; - }, 100); - } + (function (Scratch) { + 'use strict'; + var b = false; + var c; + Scratch.translate.setup({ + zh: { + name: '弹窗', + show_alert: '显示弹窗', + hide_alert: '隐藏弹窗', + set_title: '设置弹窗标题为 [L]', + set_content: '设置弹窗内容为 [M]', + set_position: '设置弹窗位置为 X: [X] Y: [Y]', + set_text: '设置 [T] 文本为 [C]', + align_title: '将标题文本对齐到 [A]', + align_content: '将内容文本对齐到 [A]', + set_font: '设置 [T] 字体为 [F]', + set_text_color: '设置 [T] 文本颜色为 [C]', + set_text_size: '将 [T] 文本大小设置为 [S]px' + }, + }); - function e() { - c.style.opacity = "0"; - c.style.transform = "translate(-50%, -50%) scale(0)"; - setTimeout(function () { - document.body.removeChild(c); - b = false; - }, 300); - } + function d() { + c = document.createElement("div"); + c.style.position = "fixed"; + c.style.backgroundColor = "white"; + c.style.border = "1px solid black"; + c.style.top = "50%"; + c.style.left = "50%"; + c.style.transform = "translate(-50%, -50%)"; + c.style.display = "none"; + c.style.borderRadius = "10px"; + c.style.color = "white"; + c.style.backgroundColor = "black"; + c.style.border = "1px solid white"; + c.style.padding = "20px"; + c.style.textAlign = "center"; + c.style.transition = "opacity 0.3s, transform 0.3s"; + c.style.opacity = "0"; + document.body.appendChild(c); + setTimeout(function () { + b = true; + c.style.opacity = "1"; + c.style.transform = "translate(-50%, -50%) scale(1)"; + c.style.display = "block"; + }, 100); + } - class f { - constructor() { - this.g = ""; - this.h = ""; + function e() { + c.style.opacity = "0"; + c.style.transform = "translate(-50%, -50%) scale(0)"; + setTimeout(function () { + document.body.removeChild(c); + b = false; + }, 300); } - d() { - if (!b) { - d(); - c.style.display = "block"; + + class f { + constructor() { + this.g = ""; + this.h = ""; + this.xPos = -50; // Default X position + this.yPos = -50; // Default Y position + this.titleFont = "Arial"; + this.contentFont = "Arial"; + this.titleColor = "white"; + this.contentColor = "white"; + this.titleSize = 24; + this.contentSize = 16; + this.outlineSize = 1; + } + d() { + if (!b) { + d(); + c.style.display = "block"; + this.i(); + } + } + + e() { + if (b) { + e(); + } + } + + j(k) { + this.g = k.L; this.i(); } - } - e() { - if (b) { - e(); + l(k) { + this.h = k.M; + this.i(); } - } - j(k) { - this.g = k.L; - this.i(); - } + p(k) { + this.xPos = k.X; + this.yPos = k.Y; + this.i(); + } - l(k) { - this.h = k.M; - this.i(); - } + setFont(k) { + if (k.T === 'Title') { + this.titleFont = k.F; + } else if (k.T === 'Content') { + this.contentFont = k.F; + } + this.i(); + } + + setTextColor(k) { + if (k.T === 'Title') { + this.titleColor = k.C; + } else if (k.T === 'Content') { + this.contentColor = k.C; + } + this.i(); + } - i() { - if (b) { - c.style.opacity = "0"; - c.style.transform = "translate(-50%, -50%) scale(0)"; - setTimeout(() => { - c.innerHTML = ` -

${this.g}

-

${this.h}

- `; - c.style.opacity = "1"; - c.style.transform = "translate(-50%, -50%) scale(1)"; - }, 300); + setTextSize(k) { + if (k.T === 'Title') { + this.titleSize = k.S; + } else if (k.T === 'Content') { + this.contentSize = k.S; + } + this.i(); } - } - getInfo() { - return { - id: 'tc', - name: Scratch.translate({ id: 'name', default: 'SuperAlert' }), - blocks: [ - { - opcode: 'd', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'd', default: 'Show alert' }) - }, - { - opcode: 'e', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'e', default: 'Hide alert' }) - }, - { - opcode: 'j', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'j', default: 'Set the alert title to [L]' }), - arguments: { - L: { - type: Scratch.ArgumentType.STRING, - defaultValue: '标题', + alignTitleText(k) { + this.titleAlignment = k.A; + this.i(); + } + + alignContentText(k) { + this.contentAlignment = k.A; + this.i(); + } + + i() { + if (b) { + c.style.opacity = "0"; + c.style.transform = `translate(${this.xPos}%, ${this.yPos}%) scale(0)`; + setTimeout(() => { + c.innerHTML = ` +

${this.g}

+

${this.h}

+ `; + c.style.opacity = "1"; + c.style.transform = `translate(${this.xPos}%, ${this.yPos}%) scale(1)`; + }, 300); + } + } + + getInfo() { + return { + id: 'tc', + name: Scratch.translate({ id: 'name', default: 'Alert' }), + color1:"#000000", + color2:"#ffffff", + color3:"#ffffff", + blocks: [ + { + opcode: 'd', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'show_alert', default: 'Show alert' }) + }, + { + opcode: 'e', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'hide_alert', default: 'Hide alert' }) + }, + { + opcode: 'j', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_title', default: 'Set the alert title to [L]' }), + arguments: { + L: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Title', + }, }, }, - }, - { - opcode: 'l', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'l', default: 'Set the alert content to [M]' }), - arguments: { - M: { - type: Scratch.ArgumentType.STRING, - defaultValue: '内容', + { + opcode: 'l', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_content', default: 'Set the alert content to [M]' }), + arguments: { + M: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Content', + }, + }, + }, + '---', + { + opcode: 'p', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_position', default: 'Set alert position to X: [X] Y: [Y]' }), + arguments: { + X: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: -50, + }, + Y: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: -50, + }, + }, + }, + { + opcode: 'setFont', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_font', default: 'Set [T] font to [F]' }), + arguments: { + T: { + type: Scratch.ArgumentType.STRING, + menu: 'textOptions', + defaultValue: 'Title', + }, + F: { + type: Scratch.ArgumentType.STRING, + menu: 'fontOptions', + defaultValue: 'Arial', + }, + }, + }, + { + opcode: 'setTextColor', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_text_color', default: 'Set [T] text color to [C]' }), + arguments: { + T: { + type: Scratch.ArgumentType.STRING, + menu: 'textOptions', + defaultValue: 'Title', + }, + C: { + type: Scratch.ArgumentType.STRING, + defaultValue: '#FFFFFF', + }, + }, + }, + { + opcode: 'setTextSize', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_text_size', default: 'Set [T] text size to [S]px' }), + arguments: { + T: { + type: Scratch.ArgumentType.STRING, + menu: 'textOptions', + defaultValue: 'Title', + }, + S: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 24, + }, + }, + }, + { + opcode: 'alignTitleText', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'align_title', default: 'Align title text to [A]' }), + arguments: { + A: { + type: Scratch.ArgumentType.STRING, + menu: 'alignmentOptions', + defaultValue: 'center', + }, }, }, + { + opcode: 'alignContentText', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'align_content', default: 'Align content text to [A]' }), + arguments: { + A: { + type: Scratch.ArgumentType.STRING, + menu: 'alignmentOptions', + defaultValue: 'center', + }, + }, + }, + ], + menus: { + textOptions: [ + { text: 'Title', value: 'Title' }, + { text: 'Content', value: 'Content' }, + ], + alignmentOptions: [ + { text: 'Left', value: 'left' }, + { text: 'Center', value: 'center' }, + { text: 'Right', value: 'right' }, + ], + fontOptions: [ + { text: 'Arial', value: 'Arial' }, + { text: 'Impact', value: 'Impact' }, + { text: 'Verdana', value: 'Verdana' }, + // Add more built-in fonts here + { text: 'Times New Roman', value: 'Times New Roman' }, + { text: 'Georgia', value: 'Georgia' }, + { text: 'Courier New', value: 'Courier New' }, + { text: 'Tahoma', value: 'Tahoma' }, + { text: 'Trebuchet MS', value: 'Trebuchet MS' }, + { text: 'Comic Sans MS', value: 'Comic Sans MS' }, + { text: 'Arial Black', value: 'Arial Black' }, + { text: 'Courier', value: 'Courier' }, + { text: 'Garamond', value: 'Garamond' }, + { text: 'Brush Script MT', value: 'Brush Script MT' }, + { text: 'Palatino Linotype', value: 'Palatino Linotype' }, + { text: 'Lucida Console', value: 'Lucida Console' }, + ], }, - ], - }; + }; + } } - } - Scratch.extensions.register(new f()); -})(Scratch); + Scratch.extensions.register(new f()); + })(Scratch); From db459e4c0d5470648231aee84b1e0923ecec99b7 Mon Sep 17 00:00:00 2001 From: 0832k12 <70421730+0832k12@users.noreply.github.com> Date: Fri, 21 Jul 2023 10:12:16 +0800 Subject: [PATCH 5/6] Try to fix --- extensions/0832/SuperAlert.js | 550 +++++++++++++++++----------------- 1 file changed, 275 insertions(+), 275 deletions(-) diff --git a/extensions/0832/SuperAlert.js b/extensions/0832/SuperAlert.js index d088c5308f..10418c57bf 100644 --- a/extensions/0832/SuperAlert.js +++ b/extensions/0832/SuperAlert.js @@ -1,317 +1,317 @@ - (function (Scratch) { - 'use strict'; - var b = false; - var c; - Scratch.translate.setup({ - zh: { - name: '弹窗', - show_alert: '显示弹窗', - hide_alert: '隐藏弹窗', - set_title: '设置弹窗标题为 [L]', - set_content: '设置弹窗内容为 [M]', - set_position: '设置弹窗位置为 X: [X] Y: [Y]', - set_text: '设置 [T] 文本为 [C]', - align_title: '将标题文本对齐到 [A]', - align_content: '将内容文本对齐到 [A]', - set_font: '设置 [T] 字体为 [F]', - set_text_color: '设置 [T] 文本颜色为 [C]', - set_text_size: '将 [T] 文本大小设置为 [S]px' - }, - }); +(function (Scratch) { + 'use strict'; + var b = false; + var c; + Scratch.translate.setup({ + zh: { + name: '弹窗', + show_alert: '显示弹窗', + hide_alert: '隐藏弹窗', + set_title: '设置弹窗标题为 [L]', + set_content: '设置弹窗内容为 [M]', + set_position: '设置弹窗位置为 X: [X] Y: [Y]', + set_text: '设置 [T] 文本为 [C]', + align_title: '将标题文本对齐到 [A]', + align_content: '将内容文本对齐到 [A]', + set_font: '设置 [T] 字体为 [F]', + set_text_color: '设置 [T] 文本颜色为 [C]', + set_text_size: '将 [T] 文本大小设置为 [S]px' + }, + }); - function d() { - c = document.createElement("div"); - c.style.position = "fixed"; - c.style.backgroundColor = "white"; - c.style.border = "1px solid black"; - c.style.top = "50%"; - c.style.left = "50%"; - c.style.transform = "translate(-50%, -50%)"; - c.style.display = "none"; - c.style.borderRadius = "10px"; - c.style.color = "white"; - c.style.backgroundColor = "black"; - c.style.border = "1px solid white"; - c.style.padding = "20px"; - c.style.textAlign = "center"; - c.style.transition = "opacity 0.3s, transform 0.3s"; - c.style.opacity = "0"; - document.body.appendChild(c); - setTimeout(function () { - b = true; - c.style.opacity = "1"; - c.style.transform = "translate(-50%, -50%) scale(1)"; - c.style.display = "block"; - }, 100); - } + function d() { + c = document.createElement("div"); + c.style.position = "fixed"; + c.style.backgroundColor = "white"; + c.style.border = "1px solid black"; + c.style.top = "50%"; + c.style.left = "50%"; + c.style.transform = "translate(-50%, -50%)"; + c.style.display = "none"; + c.style.borderRadius = "10px"; + c.style.color = "white"; + c.style.backgroundColor = "black"; + c.style.border = "1px solid white"; + c.style.padding = "20px"; + c.style.textAlign = "center"; + c.style.transition = "opacity 0.3s, transform 0.3s"; + c.style.opacity = "0"; + document.body.appendChild(c); + setTimeout(function () { + b = true; + c.style.opacity = "1"; + c.style.transform = "translate(-50%, -50%) scale(1)"; + c.style.display = "block"; + }, 100); + } - function e() { - c.style.opacity = "0"; - c.style.transform = "translate(-50%, -50%) scale(0)"; - setTimeout(function () { - document.body.removeChild(c); - b = false; - }, 300); - } + function e() { + c.style.opacity = "0"; + c.style.transform = "translate(-50%, -50%) scale(0)"; + setTimeout(function () { + document.body.removeChild(c); + b = false; + }, 300); + } - class f { - constructor() { - this.g = ""; - this.h = ""; - this.xPos = -50; // Default X position - this.yPos = -50; // Default Y position - this.titleFont = "Arial"; - this.contentFont = "Arial"; - this.titleColor = "white"; - this.contentColor = "white"; - this.titleSize = 24; - this.contentSize = 16; - this.outlineSize = 1; - } - d() { - if (!b) { - d(); - c.style.display = "block"; - this.i(); - } + class f { + constructor() { + this.g = ""; + this.h = ""; + this.xPos = -50; // Default X position + this.yPos = -50; // Default Y position + this.titleFont = "Arial"; + this.contentFont = "Arial"; + this.titleColor = "white"; + this.contentColor = "white"; + this.titleSize = 24; + this.contentSize = 16; + this.outlineSize = 1; + } + d() { + if (!b) { + d(); + c.style.display = "block"; + this.i(); } + } - e() { - if (b) { - e(); - } + e() { + if (b) { + e(); } + } - j(k) { - this.g = k.L; - this.i(); - } + j(k) { + this.g = k.L; + this.i(); + } - l(k) { - this.h = k.M; - this.i(); - } + l(k) { + this.h = k.M; + this.i(); + } - p(k) { - this.xPos = k.X; - this.yPos = k.Y; - this.i(); - } + p(k) { + this.xPos = k.X; + this.yPos = k.Y; + this.i(); + } - setFont(k) { - if (k.T === 'Title') { - this.titleFont = k.F; - } else if (k.T === 'Content') { - this.contentFont = k.F; - } - this.i(); + setFont(k) { + if (k.T === 'Title') { + this.titleFont = k.F; + } else if (k.T === 'Content') { + this.contentFont = k.F; } + this.i(); + } - setTextColor(k) { - if (k.T === 'Title') { - this.titleColor = k.C; - } else if (k.T === 'Content') { - this.contentColor = k.C; - } - this.i(); + setTextColor(k) { + if (k.T === 'Title') { + this.titleColor = k.C; + } else if (k.T === 'Content') { + this.contentColor = k.C; } + this.i(); + } - setTextSize(k) { - if (k.T === 'Title') { - this.titleSize = k.S; - } else if (k.T === 'Content') { - this.contentSize = k.S; - } - this.i(); + setTextSize(k) { + if (k.T === 'Title') { + this.titleSize = k.S; + } else if (k.T === 'Content') { + this.contentSize = k.S; } + this.i(); + } - alignTitleText(k) { - this.titleAlignment = k.A; - this.i(); - } + alignTitleText(k) { + this.titleAlignment = k.A; + this.i(); + } - alignContentText(k) { - this.contentAlignment = k.A; - this.i(); - } + alignContentText(k) { + this.contentAlignment = k.A; + this.i(); + } - i() { - if (b) { - c.style.opacity = "0"; - c.style.transform = `translate(${this.xPos}%, ${this.yPos}%) scale(0)`; - setTimeout(() => { - c.innerHTML = ` + i() { + if (b) { + c.style.opacity = "0"; + c.style.transform = `translate(${this.xPos}%, ${this.yPos}%) scale(0)`; + setTimeout(() => { + c.innerHTML = `

${this.g}

${this.h}

`; - c.style.opacity = "1"; - c.style.transform = `translate(${this.xPos}%, ${this.yPos}%) scale(1)`; - }, 300); - } + c.style.opacity = "1"; + c.style.transform = `translate(${this.xPos}%, ${this.yPos}%) scale(1)`; + }, 300); } + } - getInfo() { - return { - id: 'tc', - name: Scratch.translate({ id: 'name', default: 'Alert' }), - color1:"#000000", - color2:"#ffffff", - color3:"#ffffff", - blocks: [ - { - opcode: 'd', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'show_alert', default: 'Show alert' }) - }, - { - opcode: 'e', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'hide_alert', default: 'Hide alert' }) - }, - { - opcode: 'j', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'set_title', default: 'Set the alert title to [L]' }), - arguments: { - L: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'Title', - }, + getInfo() { + return { + id: 'tc', + name: Scratch.translate({ id: 'name', default: 'Alert' }), + color1: "#000000", + color2: "#ffffff", + color3: "#ffffff", + blocks: [ + { + opcode: 'd', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'show_alert', default: 'Show alert' }) + }, + { + opcode: 'e', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'hide_alert', default: 'Hide alert' }) + }, + { + opcode: 'j', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_title', default: 'Set the alert title to [L]' }), + arguments: { + L: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Title', }, }, - { - opcode: 'l', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'set_content', default: 'Set the alert content to [M]' }), - arguments: { - M: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'Content', - }, + }, + { + opcode: 'l', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_content', default: 'Set the alert content to [M]' }), + arguments: { + M: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Content', }, }, - '---', - { - opcode: 'p', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'set_position', default: 'Set alert position to X: [X] Y: [Y]' }), - arguments: { - X: { - type: Scratch.ArgumentType.NUMBER, - defaultValue: -50, - }, - Y: { - type: Scratch.ArgumentType.NUMBER, - defaultValue: -50, - }, + }, + '---', + { + opcode: 'p', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_position', default: 'Set alert position to X: [X] Y: [Y]' }), + arguments: { + X: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: -50, + }, + Y: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: -50, }, }, - { - opcode: 'setFont', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'set_font', default: 'Set [T] font to [F]' }), - arguments: { - T: { - type: Scratch.ArgumentType.STRING, - menu: 'textOptions', - defaultValue: 'Title', - }, - F: { - type: Scratch.ArgumentType.STRING, - menu: 'fontOptions', - defaultValue: 'Arial', - }, + }, + { + opcode: 'setFont', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_font', default: 'Set [T] font to [F]' }), + arguments: { + T: { + type: Scratch.ArgumentType.STRING, + menu: 'textOptions', + defaultValue: 'Title', + }, + F: { + type: Scratch.ArgumentType.STRING, + menu: 'fontOptions', + defaultValue: 'Arial', }, }, - { - opcode: 'setTextColor', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'set_text_color', default: 'Set [T] text color to [C]' }), - arguments: { - T: { - type: Scratch.ArgumentType.STRING, - menu: 'textOptions', - defaultValue: 'Title', - }, - C: { - type: Scratch.ArgumentType.STRING, - defaultValue: '#FFFFFF', - }, + }, + { + opcode: 'setTextColor', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_text_color', default: 'Set [T] text color to [C]' }), + arguments: { + T: { + type: Scratch.ArgumentType.STRING, + menu: 'textOptions', + defaultValue: 'Title', + }, + C: { + type: Scratch.ArgumentType.STRING, + defaultValue: '#FFFFFF', }, }, - { - opcode: 'setTextSize', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'set_text_size', default: 'Set [T] text size to [S]px' }), - arguments: { - T: { - type: Scratch.ArgumentType.STRING, - menu: 'textOptions', - defaultValue: 'Title', - }, - S: { - type: Scratch.ArgumentType.NUMBER, - defaultValue: 24, - }, + }, + { + opcode: 'setTextSize', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'set_text_size', default: 'Set [T] text size to [S]px' }), + arguments: { + T: { + type: Scratch.ArgumentType.STRING, + menu: 'textOptions', + defaultValue: 'Title', + }, + S: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 24, }, }, - { - opcode: 'alignTitleText', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'align_title', default: 'Align title text to [A]' }), - arguments: { - A: { - type: Scratch.ArgumentType.STRING, - menu: 'alignmentOptions', - defaultValue: 'center', - }, + }, + { + opcode: 'alignTitleText', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'align_title', default: 'Align title text to [A]' }), + arguments: { + A: { + type: Scratch.ArgumentType.STRING, + menu: 'alignmentOptions', + defaultValue: 'center', }, }, - { - opcode: 'alignContentText', - blockType: Scratch.BlockType.COMMAND, - text: Scratch.translate({ id: 'align_content', default: 'Align content text to [A]' }), - arguments: { - A: { - type: Scratch.ArgumentType.STRING, - menu: 'alignmentOptions', - defaultValue: 'center', - }, + }, + { + opcode: 'alignContentText', + blockType: Scratch.BlockType.COMMAND, + text: Scratch.translate({ id: 'align_content', default: 'Align content text to [A]' }), + arguments: { + A: { + type: Scratch.ArgumentType.STRING, + menu: 'alignmentOptions', + defaultValue: 'center', }, }, - ], - menus: { - textOptions: [ - { text: 'Title', value: 'Title' }, - { text: 'Content', value: 'Content' }, - ], - alignmentOptions: [ - { text: 'Left', value: 'left' }, - { text: 'Center', value: 'center' }, - { text: 'Right', value: 'right' }, - ], - fontOptions: [ - { text: 'Arial', value: 'Arial' }, - { text: 'Impact', value: 'Impact' }, - { text: 'Verdana', value: 'Verdana' }, - // Add more built-in fonts here - { text: 'Times New Roman', value: 'Times New Roman' }, - { text: 'Georgia', value: 'Georgia' }, - { text: 'Courier New', value: 'Courier New' }, - { text: 'Tahoma', value: 'Tahoma' }, - { text: 'Trebuchet MS', value: 'Trebuchet MS' }, - { text: 'Comic Sans MS', value: 'Comic Sans MS' }, - { text: 'Arial Black', value: 'Arial Black' }, - { text: 'Courier', value: 'Courier' }, - { text: 'Garamond', value: 'Garamond' }, - { text: 'Brush Script MT', value: 'Brush Script MT' }, - { text: 'Palatino Linotype', value: 'Palatino Linotype' }, - { text: 'Lucida Console', value: 'Lucida Console' }, - ], }, - }; - } + ], + menus: { + textOptions: [ + { text: 'Title', value: 'Title' }, + { text: 'Content', value: 'Content' }, + ], + alignmentOptions: [ + { text: 'Left', value: 'left' }, + { text: 'Center', value: 'center' }, + { text: 'Right', value: 'right' }, + ], + fontOptions: [ + { text: 'Arial', value: 'Arial' }, + { text: 'Impact', value: 'Impact' }, + { text: 'Verdana', value: 'Verdana' }, + // Add more built-in fonts here + { text: 'Times New Roman', value: 'Times New Roman' }, + { text: 'Georgia', value: 'Georgia' }, + { text: 'Courier New', value: 'Courier New' }, + { text: 'Tahoma', value: 'Tahoma' }, + { text: 'Trebuchet MS', value: 'Trebuchet MS' }, + { text: 'Comic Sans MS', value: 'Comic Sans MS' }, + { text: 'Arial Black', value: 'Arial Black' }, + { text: 'Courier', value: 'Courier' }, + { text: 'Garamond', value: 'Garamond' }, + { text: 'Brush Script MT', value: 'Brush Script MT' }, + { text: 'Palatino Linotype', value: 'Palatino Linotype' }, + { text: 'Lucida Console', value: 'Lucida Console' }, + ], + }, + }; } + } - Scratch.extensions.register(new f()); - })(Scratch); + Scratch.extensions.register(new f()); +})(Scratch); From 8f4337bc1ea62a6f2df4a998fc4ab55a71831b11 Mon Sep 17 00:00:00 2001 From: 0832k12 <70421730+0832k12@users.noreply.github.com> Date: Fri, 21 Jul 2023 10:19:43 +0800 Subject: [PATCH 6/6] Change SetColor --- extensions/0832/SuperAlert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/0832/SuperAlert.js b/extensions/0832/SuperAlert.js index 10418c57bf..d368979333 100644 --- a/extensions/0832/SuperAlert.js +++ b/extensions/0832/SuperAlert.js @@ -234,7 +234,7 @@ defaultValue: 'Title', }, C: { - type: Scratch.ArgumentType.STRING, + type: Scratch.ArgumentType.COLOR, defaultValue: '#FFFFFF', }, },