-
Notifications
You must be signed in to change notification settings - Fork 156
New Windows extension #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Monochromasity
wants to merge
6
commits into
PenguinMod:main
Choose a base branch
from
Monochromasity:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
172ddfc
Add files via upload
Monochromasity 6a485ae
Delete static/extensions/Monochromasity/newwindows.js
Monochromasity 79dedca
Add newwindows.js
Monochromasity ad56bd2
Add new windows image
Monochromasity f07b4e3
Update extensions.js with New Windows ext
Monochromasity 06e27d4
Update newwindows.js to current version
Monochromasity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,243 @@ | ||
| // Name: New Windows | ||
| // ID: monowindows | ||
| // Description: Lets you open websites in new windows. | ||
| // By: Monochromasity | ||
|
|
||
| (function (Scratch) { | ||
| "use strict"; | ||
|
|
||
| let menubar = "no"; | ||
| let status = "no"; | ||
| let titlebar = "no"; | ||
| let full = "no"; | ||
| let location = "no"; | ||
| let resizable = "no"; | ||
| let scroll = "no"; | ||
| let toolbar = "no"; | ||
| let replace = "false"; | ||
|
|
||
| class NewWindows { | ||
| getInfo() { | ||
| return { | ||
| id: 'monowindows', | ||
| color1: '#297bff', | ||
| name: 'New Windows', | ||
| blocks: [ | ||
| { | ||
| opcode: 'openwindow', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'open website [WEB] in new window with ID: [ID] width: [WIDTH] height: [HEIGHT] distance from left: [LEFT] distance from top: [TOP]', | ||
| arguments: { | ||
| WEB: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'https://penguinmod.com' | ||
| }, | ||
| ID: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'myWindow' | ||
| }, | ||
| WIDTH: { | ||
| type: Scratch.ArgumentType.NUMBER, | ||
| defaultValue: '400' | ||
| }, | ||
| HEIGHT: { | ||
| type: Scratch.ArgumentType.NUMBER, | ||
| defaultValue: '400' | ||
| }, | ||
| LEFT: { | ||
| type: Scratch.ArgumentType.NUMBER, | ||
| defaultValue: '0' | ||
| }, | ||
| TOP: { | ||
| type: Scratch.ArgumentType.NUMBER, | ||
| defaultValue: '0' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'setproperty', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'set window property [PROPERTY] to [TOGGLE]', | ||
| arguments: { | ||
| PROPERTY: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| menu: 'PROPERTY' | ||
| }, | ||
| TOGGLE: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| menu: 'TOGGLE' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'reset', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'reset properties to default', | ||
| hideFromPalette: true | ||
| }, | ||
| { | ||
| opcode: 'getproperty', | ||
| blockType: Scratch.BlockType.REPORTER, | ||
| text: 'get value of property [PROPERTY]', | ||
| arguments: { | ||
| PROPERTY: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| menu: 'PROPERTY' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'closewithid', | ||
| blockType: Scratch.BlockType.COMMAND, | ||
| text: 'close window with id [ID]', | ||
| arguments: { | ||
| ID: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'myWindow' | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| opcode: 'isopen', | ||
| blockType: Scratch.BlockType.BOOLEAN, | ||
| text: 'is window with ID [ID] open?', | ||
| arguments: { | ||
| ID: { | ||
| type: Scratch.ArgumentType.STRING, | ||
| defaultValue: 'myWindow' | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| menus: { | ||
| PROPERTY: { | ||
| acceptReporters: true, | ||
| items: [ | ||
| { | ||
| text: 'menu bar', | ||
| value: 'menubar' | ||
| }, | ||
| { | ||
| text: 'status bar', | ||
| value: 'status' | ||
| }, | ||
| { | ||
| text: 'title bar', | ||
| value: 'titlebar' | ||
| }, | ||
| { | ||
| text: 'fullscreen (IE only)', | ||
| value: 'full' | ||
| }, | ||
| { | ||
| text: 'address field (Opera only)', | ||
| value: 'location' | ||
| }, | ||
| { | ||
| text: 'resizable (IE only)', | ||
| value: 'resizable' | ||
| }, | ||
| { | ||
| text: 'scrollbars (IE, Firefox, Opera only)', | ||
| value: 'scroll', | ||
| }, | ||
| { | ||
| text: 'toolbar (IE, Firefox)', | ||
| value: 'toolbar', | ||
| }, | ||
| { | ||
| text: 'replace (Deprecated)', | ||
| value: 'replace' | ||
| } | ||
| ] | ||
| }, | ||
| TOGGLE: { | ||
| acceptReporters: true, | ||
| items: [ | ||
| { | ||
| text: 'true', | ||
| value: 'yes' | ||
| }, | ||
| { | ||
| text: 'false', | ||
| value: 'no' | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| openwindow(args) { | ||
| let web = args.WEB; | ||
| let iduf = args.ID; | ||
| let id = iduf.toLowerCase(); | ||
| let width = args.WIDTH; | ||
| let height = args.HEIGHT; | ||
| let strstart = "width="; | ||
| let left = Math.abs(Number(args.LEFT)); | ||
| let top = Math.abs(Number(args.TOP)); | ||
| let str = strstart.concat(width, ",height=", height, ",fullscreen=", full, ",left=", left, ",top=", top, ",menubar=", menubar, ",status=", status, ",titlebar=", titlebar, ",location=", location, ",resizable=", resizable, ",scrollbars=", scroll, ",toolbar=", toolbar); | ||
| console.log(str); | ||
| let name = "windows" + id; | ||
| this[name] = window.open(web, '', str, replace); | ||
| } | ||
| closewithid(args) { | ||
| let iduf = args.ID; | ||
| let id = iduf.toLowerCase(); | ||
| let name = "windows" + id; | ||
| this[name].close(); | ||
| } | ||
| isopen(args) { | ||
| let iduf = args.ID; | ||
| let id = iduf.toLowerCase(); | ||
| let name = "windows" + id; | ||
| try { | ||
| if (!this[name].closed) { | ||
| return true; | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| catch(err) { | ||
| return false; | ||
| } | ||
| } | ||
| setproperty(args) { | ||
| let title = args.PROPERTY; | ||
| if (title == "replace") { | ||
| let toggle = args.TOGGLE; | ||
| if (toggle == "yes") { | ||
| this[title] = "true"; | ||
| } else if (toggle == "no") { | ||
| this[title] = "false"; | ||
| } | ||
| } else { | ||
| this[title] = args.TOGGLE; | ||
| } | ||
| } | ||
| reset() { | ||
| menubar = "no"; | ||
| status = "no"; | ||
| titlebar = "no"; | ||
| full = "no"; | ||
| location = "no"; | ||
| resizable = "no"; | ||
| scroll = "no"; | ||
| toolbar = "no"; | ||
| replace = "false"; | ||
| } | ||
| getproperty(args) { | ||
| let title = args.PROPERTY; | ||
| let propval = this[title]; | ||
| if (propval == "yes") { | ||
| return true; | ||
| } else if (propval == "no") { | ||
| return false; | ||
| } else { | ||
| return propval; | ||
| } | ||
| } | ||
| } | ||
| Scratch.extensions.register(new NewWindows()); | ||
| })(Scratch); | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion, but maybe
open [WEB] in new window with dimensions [WIDTH]x[HEIGHT] with a distance of [LEFT]x[TOP] from the top left with id [ID]? It's not that much shorter, but given how ridiculously long this block name is it should help a little.