Discuss Scratch

Botcho_Otkho
Scratcher
1000+ posts

Chromedials - extension

Warning: there aren't any links on github, just a code that you can copy in the JS console in one of your Scratch projects to add this. I have to get used on Github.
Tested on: Chrome
Hello! I worked on this extension called “Chromedials”. It opens dialogs to have a faster and fancier way to alert people, asking things or confirm things.
Here are the principal blocks:
alert []::extension//opens a basic dialog.
ask for [] with original answer []::extension reporter//opens a dialog with a textbox to receive an input.
confirm []::extension boolean//if "ok" is clicked reports true, otherwise it reports false.
And comes too with other help to manage code:
newline::reporter extension//creates a new line. (it works everywhere, not just in dialogs)
evaluate []::extension//useful for ignoring the "ask for" and the "confirm" dialog when you don't need to receive inputs.
JS code:
(function(ext) {
// Cleanup function when the extension is unloaded
ext._shutdown = function() {};

// Status reporting code
// Use this to report missing hardware, plugin or unsupported browser
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};

ext.my_first_block = function() {
// Code that gets executed when the block is run
};

// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name
[' ', 'alert %s', 'alertDial', 'Done.'],
['r', 'ask for %s with original answer %s', 'promptDial', 'What is your name?', 'John Doe'],
['b', 'confirm %s', 'askDial', 'Are you sure?'],
['r', 'newline', 'newlineX', ''],
[' ', 'evaluate %s', 'evaluateX']
]
};
ext.alertDial = function(dialText) {
alert(dialText)
};
ext.promptDial = function(dialText, origAnswer) {
return prompt(dialText, origAnswer)
};
ext.askDial = function(dialText) {
return confirm(dialText)
};
ext.newlineX = function() {
return "\n"
};
ext.evaluateX = function(evaluate) {
eval(evaluate)
};

// Register the extension
ScratchExtensions.register('Chromedials', descriptor, ext);
})({});
(I used ScratchX wiki's template)
Hope you like it!

PS.: let me know if you tested it on other browsers and it worked.

Last edited by Botcho_Otkho (April 4, 2018 17:20:58)


I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
mrbumppo
Scratcher
500+ posts

Chromedials - extension

Nice! Could I host code on YourJavascript or repl.it?
I also think we might be able to collaborate on making Chromedials 2.0 or something.

mrbumppo
The Internet is a weird place, so don't question it.




Botcho_Otkho
Scratcher
1000+ posts

Chromedials - extension

mrbumppo wrote:

Nice! Could I host code on YourJavascript or repl.it?
I also think we might be able to collaborate on making Chromedials 2.0 or something.
I'd like that idea

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
mrbumppo
Scratcher
500+ posts

Chromedials - extension

Botcho_Otkho wrote:

mrbumppo wrote:

Nice! Could I host code on YourJavascript or repl.it?
I also think we might be able to collaborate on making Chromedials 2.0 or something.
I'd like that idea
So should I?

mrbumppo
The Internet is a weird place, so don't question it.




Botcho_Otkho
Scratcher
1000+ posts

Chromedials - extension

mrbumppo wrote:

Botcho_Otkho wrote:

mrbumppo wrote:

Nice! Could I host code on YourJavascript or repl.it?
I also think we might be able to collaborate on making Chromedials 2.0 or something.
I'd like that idea
So should I?
Yes!

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
mrbumppo
Scratcher
500+ posts

Chromedials - extension

YourJavascript is done! http://yourjavascript.com/15712442823/chromedials.js

mrbumppo
The Internet is a weird place, so don't question it.




Botcho_Otkho
Scratcher
1000+ posts

Chromedials - extension

mrbumppo wrote:

YourJavascript is done! http://yourjavascript.com/15712442823/chromedials.js
Thanks!

I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo

Powered by DjangoBB