fix: update the playground to load compressed when hosted (#5835)

This commit is contained in:
alschmiedt
2022-01-06 11:28:27 -08:00
committed by GitHub
parent 18b56d5da8
commit 2adf326c23
5 changed files with 80 additions and 1710 deletions

View File

@@ -3,24 +3,14 @@
<head>
<meta charset="utf-8">
<title>Blockly Playground</title>
<script src="../blockly_uncompressed.js"></script>
<script src="../msg/messages.js"></script>
<script src="themes/test_themes.js"></script>
<script src="./playgrounds/screenshot.js"></script>
<script src="../node_modules/@blockly/block-test/dist/index.js"></script>
<script>
// Custom requires for the playground.
goog.require('Blockly.Dart.all');
goog.require('Blockly.JavaScript.all');
goog.require('Blockly.Lua.all');
goog.require('Blockly.PHP.all');
goog.require('Blockly.Python.all');
goog.require('Blockly.WorkspaceCommentSvg');
goog.require('Blockly.blocks.all');
</script>
<!-- This script loads uncompressed when on localhost and loads compressed when it is being hosted.
Please add any other dependencies to playgrounds/load_all.js.-->
<script src="playgrounds/load_all.js"></script>
<script>
'use strict';
const IS_UNCOMPRESSED = !!document.getElementById('blockly-uncompressed-script');
var workspace = null;
function start() {
@@ -97,14 +87,11 @@ function start() {
}
function setBackgroundColour() {
// Set background colour to differentiate file: vs. localhost
// vs. server copy.
if (location.protocol === 'file:') {
document.body.style.backgroundColor = '#89A203'; // Unpleasant green.
} else if (location.hostname === 'localhost' ||
location.hostname === '127.0.0.1' ||
location.hostname === '[::1]') {
document.body.style.backgroundColor = '#d6d6ff'; // Familliar lilac.
// Set background colour to differentiate between compressed and uncompressed mode.
if (IS_UNCOMPRESSED) {
document.body.style.backgroundColor = '#d6d6ff'; // Familiar lilac.
} else {
document.body.style.backgroundColor = '#60fcfc'; // Unfamiliar blue.
}
}