diff --git a/lib/custom-dialog.js b/google-blockly/custom-dialog.js
similarity index 76%
rename from lib/custom-dialog.js
rename to google-blockly/custom-dialog.js
index a2f8c32..04793e3 100644
--- a/lib/custom-dialog.js
+++ b/google-blockly/custom-dialog.js
@@ -1,174 +1,161 @@
-/**
- * Blockly Demos: Custom Dialogs
- *
- * Copyright 2016 Google Inc.
- * https://developers.google.com/blockly/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * An example implementation of how one might replace Blockly's browser
- * dialogs. This is just an example, and applications are not encouraged to use
- * it verbatim.
- *
- * @namespace
- */
-CustomDialog = {};
-
-/** Override Blockly.alert() with custom implementation. */
-Blockly.alert = function(message, callback) {
- console.log('Alert: ' + message);
- CustomDialog.show('Alert', message, {
- onCancel: callback
- });
-};
-
-/** Override Blockly.confirm() with custom implementation. */
-Blockly.confirm = function(message, callback) {
- console.log('Confirm: ' + message);
- CustomDialog.show('Confirm', message, {
- showOkay: true,
- onOkay: function() {
- callback(true);
- },
- showCancel: true,
- onCancel: function() {
- callback(false);
- }
- });
-};
-
-/** Override Blockly.prompt() with custom implementation. */
-Blockly.prompt = function(message, defaultValue, callback) {
- console.log('Prompt: ' + message);
- CustomDialog.show('Prompt', message, {
- showInput: true,
- showOkay: true,
- onOkay: function() {
- callback(CustomDialog.inputField.value);
- },
- showCancel: true,
- onCancel: function() {
- callback(null);
- }
- });
- CustomDialog.inputField.value = defaultValue;
-};
-
-/** Hides any currently visible dialog. */
-CustomDialog.hide = function() {
- if (CustomDialog.backdropDiv_) {
- CustomDialog.backdropDiv_.style.display = 'none';
- CustomDialog.dialogDiv_.style.display = 'none';
- }
-};
-
-/**
- * Shows the dialog.
- * Allowed options:
- * - showOkay: Whether to show the OK button.
- * - showCancel: Whether to show the Cancel button.
- * - showInput: Whether to show the text input field.
- * - onOkay: Callback to handle the okay button.
- * - onCancel: Callback to handle the cancel button and backdrop clicks.
- */
-CustomDialog.show = function(title, message, options) {
- var backdropDiv = CustomDialog.backdropDiv_;
- var dialogDiv = CustomDialog.dialogDiv_;
- if (!dialogDiv) {
- // Generate HTML
- backdropDiv = document.createElement('div');
- backdropDiv.id = 'customDialogBackdrop';
- backdropDiv.style.cssText =
- 'position: absolute;' +
- 'top: 0; left: 0; right: 0; bottom: 0;' +
- 'background-color: rgba(0, 0, 0, .7);' +
- 'z-index: 100;';
- document.body.appendChild(backdropDiv);
-
- dialogDiv = document.createElement('div');
- dialogDiv.id = 'customDialog';
- dialogDiv.style.cssText =
- 'background-color: #fff;' +
- 'width: 400px;' +
- 'margin: 20px auto 0;' +
- 'padding: 10px;';
- backdropDiv.appendChild(dialogDiv);
-
- dialogDiv.onclick = function(event) {
- event.stopPropagation();
- };
-
- CustomDialog.backdropDiv_ = backdropDiv;
- CustomDialog.dialogDiv_ = dialogDiv;
- }
- backdropDiv.style.display = 'block';
- dialogDiv.style.display = 'block';
-
- dialogDiv.innerHTML =
- '' +
- '
' +
- (options.showInput ? '' : '') +
- '' +
- (options.showCancel ? '': '') +
- (options.showOkay ? '': '') +
- '
';
- dialogDiv.getElementsByClassName('customDialogTitle')[0]
- .appendChild(document.createTextNode(title));
- dialogDiv.getElementsByClassName('customDialogMessage')[0]
- .appendChild(document.createTextNode(message));
-
- var onOkay = function(event) {
- CustomDialog.hide();
- options.onOkay && options.onOkay();
- event && event.stopPropagation();
- };
- var onCancel = function(event) {
- CustomDialog.hide();
- options.onCancel && options.onCancel();
- event && event.stopPropagation();
- };
-
- var dialogInput = document.getElementById('customDialogInput');
- CustomDialog.inputField = dialogInput;
- if (dialogInput) {
- dialogInput.focus();
-
- dialogInput.onkeyup = function(event) {
- if (event.keyCode == 13) {
- // Process as OK when user hits enter.
- onOkay();
- return false;
- } else if (event.keyCode == 27) {
- // Process as cancel when user hits esc.
- onCancel();
- return false;
- }
- };
- } else {
- var okay = document.getElementById('customDialogOkay');
- okay && okay.focus();
- }
-
- if (options.showOkay) {
- document.getElementById('customDialogOkay')
- .addEventListener('click', onOkay);
- }
- if (options.showCancel) {
- document.getElementById('customDialogCancel')
- .addEventListener('click', onCancel);
- }
-
- backdropDiv.onclick = onCancel;
-};
+/**
+ * @license
+ * Copyright 2016 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**
+ * An example implementation of how one might replace Blockly's browser
+ * dialogs. This is just an example, and applications are not encouraged to use
+ * it verbatim.
+ *
+ * @namespace
+ */
+CustomDialog = {};
+
+/** Override Blockly.dialog.alert() with custom implementation. */
+Blockly.dialog.setAlert(function(message, callback) {
+ console.log('Alert: ' + message);
+ CustomDialog.show('Alert', message, {
+ onCancel: callback
+ });
+});
+
+/** Override Blockly.dialog.confirm() with custom implementation. */
+Blockly.dialog.setConfirm(function(message, callback) {
+ console.log('Confirm: ' + message);
+ CustomDialog.show('Confirm', message, {
+ showOkay: true,
+ onOkay: function() {
+ callback(true);
+ },
+ showCancel: true,
+ onCancel: function() {
+ callback(false);
+ }
+ });
+});
+
+/** Override Blockly.dialog.prompt() with custom implementation. */
+Blockly.dialog.setPrompt(function(message, defaultValue, callback) {
+ console.log('Prompt: ' + message);
+ CustomDialog.show('Prompt', message, {
+ showInput: true,
+ showOkay: true,
+ onOkay: function() {
+ callback(CustomDialog.inputField.value);
+ },
+ showCancel: true,
+ onCancel: function() {
+ callback(null);
+ }
+ });
+ CustomDialog.inputField.value = defaultValue;
+});
+
+/** Hides any currently visible dialog. */
+CustomDialog.hide = function() {
+ if (CustomDialog.backdropDiv_) {
+ CustomDialog.backdropDiv_.style.display = 'none';
+ CustomDialog.dialogDiv_.style.display = 'none';
+ }
+};
+
+/**
+ * Shows the dialog.
+ * Allowed options:
+ * - showOkay: Whether to show the OK button.
+ * - showCancel: Whether to show the Cancel button.
+ * - showInput: Whether to show the text input field.
+ * - onOkay: Callback to handle the okay button.
+ * - onCancel: Callback to handle the cancel button and backdrop clicks.
+ */
+CustomDialog.show = function(title, message, options) {
+ var backdropDiv = CustomDialog.backdropDiv_;
+ var dialogDiv = CustomDialog.dialogDiv_;
+ if (!dialogDiv) {
+ // Generate HTML
+ backdropDiv = document.createElement('div');
+ backdropDiv.id = 'customDialogBackdrop';
+ backdropDiv.style.cssText =
+ 'position: absolute;' +
+ 'top: 0; left: 0; right: 0; bottom: 0;' +
+ 'background-color: rgba(0, 0, 0, .7);' +
+ 'z-index: 100;';
+ document.body.appendChild(backdropDiv);
+
+ dialogDiv = document.createElement('div');
+ dialogDiv.id = 'customDialog';
+ dialogDiv.style.cssText =
+ 'background-color: #fff;' +
+ 'width: 400px;' +
+ 'margin: 20px auto 0;' +
+ 'padding: 10px;';
+ backdropDiv.appendChild(dialogDiv);
+
+ dialogDiv.onclick = function(event) {
+ event.stopPropagation();
+ };
+
+ CustomDialog.backdropDiv_ = backdropDiv;
+ CustomDialog.dialogDiv_ = dialogDiv;
+ }
+ backdropDiv.style.display = 'block';
+ dialogDiv.style.display = 'block';
+
+ dialogDiv.innerHTML =
+ '' +
+ '' +
+ (options.showInput ? '' : '') +
+ '' +
+ (options.showCancel ? '': '') +
+ (options.showOkay ? '': '') +
+ '
';
+ dialogDiv.getElementsByClassName('customDialogTitle')[0]
+ .appendChild(document.createTextNode(title));
+ dialogDiv.getElementsByClassName('customDialogMessage')[0]
+ .appendChild(document.createTextNode(message));
+
+ var onOkay = function(event) {
+ CustomDialog.hide();
+ options.onOkay && options.onOkay();
+ event && event.stopPropagation();
+ };
+ var onCancel = function(event) {
+ CustomDialog.hide();
+ options.onCancel && options.onCancel();
+ event && event.stopPropagation();
+ };
+
+ var dialogInput = document.getElementById('customDialogInput');
+ CustomDialog.inputField = dialogInput;
+ if (dialogInput) {
+ dialogInput.focus();
+
+ dialogInput.onkeyup = function(event) {
+ if (event.keyCode === 13) {
+ // Process as OK when user hits enter.
+ onOkay();
+ return false;
+ } else if (event.keyCode === 27) {
+ // Process as cancel when user hits esc.
+ onCancel();
+ return false;
+ }
+ };
+ } else {
+ var okay = document.getElementById('customDialogOkay');
+ okay && okay.focus();
+ }
+
+ if (options.showOkay) {
+ document.getElementById('customDialogOkay')
+ .addEventListener('click', onOkay);
+ }
+ if (options.showCancel) {
+ document.getElementById('customDialogCancel')
+ .addEventListener('click', onCancel);
+ }
+
+ backdropDiv.onclick = onCancel;
+};
diff --git a/index.html b/index.html
index eca882a..da95253 100644
--- a/index.html
+++ b/index.html
@@ -103,6 +103,29 @@
WHILE
+ +
+
+
+ 番号
+
+
+
+
+ 1
+
+
+
+
+ 10
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+ 項目
+
+
BREAK
@@ -488,7 +518,14 @@
- 気温
+ 0x76
+
+
+ 0
+
+
+
@@ -635,9 +672,17 @@
-
+
+
+ keydown
+
+
+ キー
+
+
@@ -671,11 +716,15 @@
-
+
+
+
+ 0
@@ -713,13 +762,25 @@
-
+
+
+
+
+ URL
+
+
+
+
+ オコゲ
+
+
@@ -730,18 +791,43 @@
- 自分のID
+
+
+ 自分のID
+
+
-
+
+
+
+
+ 相手のID
+
+
-
+
+
+
+
+ 発言
+
+
+
+
+
+
+ 内容
+
+
@@ -759,13 +845,25 @@
-
+
+
+
+
+ お名前は?
+
+
+
+
+ 答え
+
+
@@ -786,7 +884,6 @@
- ツールチップ
ボタン1
@@ -799,12 +896,12 @@
- #00cccc
+ #999999
- データの保存に使えます。
+ ここをクリック
@@ -859,10 +956,18 @@
- 実行結果
+
+
+ 実行結果
+
+
- データ
+
+
+ データストリーム
+
+
@@ -946,7 +1051,12 @@
- 答え
+
+
+
+ 答え
+
+
お名前は?
@@ -978,7 +1088,7 @@
- 答え
+ 答え
@@ -1002,7 +1112,13 @@
-
+
+
+
+ 変数
+
+
+
@@ -1011,13 +1127,13 @@
-
+
-
+