diff --git a/extensions/Scratch_craft_2/modals.js b/extensions/Scratch_craft_2/modals.js new file mode 100644 index 0000000000..7a3e91bbde --- /dev/null +++ b/extensions/Scratch_craft_2/modals.js @@ -0,0 +1,72 @@ +// Name: Modals +// ID: htmlalert +// Description: This extension adds modal dialog boxes. +// By: scratch_craft_2 +// License: MPL-2.0 + +(function (Scratch) { + "use strict"; + + if (!Scratch.extensions.unsandboxed) { + throw new Error("This Extension must run unsandboxed"); + } + + class modals { + getInfo() { + return { + id: "htmlalert", + name: "modals", + color1: "#a3c0e1", + blocks: [ + { + opcode: "alertb", + blockType: Scratch.BlockType.COMMAND, + text: "alert [textia]", + arguments: { + textia: { + defaultValue: "hello!", + type: Scratch.ArgumentType.STRING, + }, + }, + }, + { + opcode: "Promptb", + blockType: Scratch.BlockType.REPORTER, + text: "prompt [textip], default value: [classic]", + arguments: { + textip: { + defaultValue: "what's your name?", + type: Scratch.ArgumentType.STRING, + }, + classic: { + defaultValue: " ", + type: Scratch.ArgumentType.STRING, + }, + }, + }, + { + opcode: "Confirmb", + blockType: Scratch.BlockType.BOOLEAN, + text: "confirm [textic]", + arguments: { + textic: { + defaultValue: "Did you see that movie?", + type: Scratch.ArgumentType.STRING, + }, + }, + }, + ], + }; + } +alertb(args) { + alert([args.textia]); +} +Promptb(args) { + return prompt([args.textip], [args.classic]); +} +Confirmb(args) { + return confirm([args.textic]); +} + } + Scratch.extensions.register(new modals()); + })(Scratch); diff --git a/extensions/extensions.json b/extensions/extensions.json index d8ed71e33d..923c528024 100644 --- a/extensions/extensions.json +++ b/extensions/extensions.json @@ -18,6 +18,7 @@ "sound", "Lily/Video", "iframe", + "Scratch_craft_2/modals", "Clay/htmlEncode", "Xeltalliv/clippingblending", "clipboard", diff --git a/images/README.md b/images/README.md index 877bfbf84c..cdc491bb6a 100644 --- a/images/README.md +++ b/images/README.md @@ -50,6 +50,11 @@ All images in this folder are licensed under the [GNU General Public License ver - Created by [@David-Orangemoon](https://scratch.mit.edu/users/pinksheep2917/) in https://github.com/TurboWarp/extensions/pull/103. - Font is Noto Sans. +## Scratch_craft_2/modals.png + - Created by [scratch_craft_2](https://scratch.mit.edu/users/scratch_craft_2/) in https://github.com/TurboWarp/extensions/pull/2095. + - Font is Noto Sans. + - Background based on https://turbowarp.org/static/assets/cf07199bb768b01e6ac2a5c68fd8c3bb.svg + - Communication icon from https://www.svgrepo.com/svg/533234/message-circle-chat ## pointerlock.svg - Created by [@True-Fantom](https://scratch.mit.edu/users/TrueFantom/) in https://github.com/TurboWarp/extensions/pull/498. - Chain from https://svgsilh.com/ru/image/1300304.html. diff --git a/images/Scratch_craft_2/modals.png b/images/Scratch_craft_2/modals.png new file mode 100644 index 0000000000..e494d811cb Binary files /dev/null and b/images/Scratch_craft_2/modals.png differ