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,15 +3,16 @@
<head>
<meta charset="utf-8">
<title>Multi-toolbox Playground</title>
<script src="../blockly_uncompressed.js"></script>
<script src="../msg/messages.js"></script>
<script>
// Custom requires for the playground.
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 options = {
comments: true,
collapse: true,
@@ -37,6 +38,7 @@ var options = {
};
function start() {
setBackgroundColour();
var match = location.search.match(/toolbox=([^&]+)/);
var toolbox =
document.getElementById('toolbox-' + (match ? match[1] : 'categories'));
@@ -63,6 +65,15 @@ function startBlocklyInstance(suffix, rtl, horizontalLayout, position,
options.toolboxPosition = position;
Blockly.inject('blocklyDiv' + suffix, options);
}
function setBackgroundColour() {
// 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.
}
}
</script>
<style>