123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- /**
- * @license
- * Visual Blocks Editor
- *
- * Copyright 2012 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.
- */
- /**
- * @fileoverview CORGIS big data blocks for Blockly.
- * @author acbart@vt.edu (Austin Cory Bart)
- */
- 'use strict';
- goog.provide('Blockly.Blocks.corgis');
- goog.require('Blockly.Blocks');
- var WEATHER_HUE = 70,
- QUAKES_HUE = 60,
- STOCKS_HUE = 65,
- CRIME_HUE = 55,
- BOOKS_HUE = 50;
-
- /*
- * Weather Data
- */
- var CITIES = [['Blacksburg, VA', 'Blacksburg, VA'],
- ['Seattle, WA', 'Seattle, WA'],
- ['Miami, FL', 'Miami, FL'],
- ['San Jose, CA', 'San Jose, CA'],
- ['New York, NY', 'New York, NY']];
- Blockly.Blocks['weather_temperature_get'] = {
- init: function() {
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get a set of temperatures");
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns a set of temperature (number)');
- }
- };
- Blockly.Blocks['weather_temperature'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get temperature in")
- .appendField(new Blockly.FieldDropdown(CITIES), 'CITY');
- this.setInputsInline(false);
- this.setOutput(true, "Number");
- this.setTooltip('Returns a single temperature (number)');
- }
- };
-
- Blockly.Blocks['weather_forecasts'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get forecasted temperatures in")
- .appendField(new Blockly.FieldDropdown(CITIES), 'CITY');
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns a list of forecasted temperatures (list of number)');
- }
- };
- Blockly.Blocks['weather_highs_lows'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get highs and lows in")
- .appendField(new Blockly.FieldDropdown(CITIES), 'CITY');
- this.setInputsInline(false);
- this.setOutput(true, "dict");
- this.setTooltip('Returns a list of forecasted temperature highs and lows (dict of lists of numbers)');
- }
- };
- Blockly.Blocks['weather_report_forecasts'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get forecasted weather in")
- .appendField(new Blockly.FieldDropdown(CITIES), 'CITY');
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns a list of forecasted weather reports (list of dicts)');
- }
- };
- Blockly.Blocks['weather_report'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get weather in")
- .appendField(new Blockly.FieldDropdown(CITIES), 'CITY');
- this.setInputsInline(false);
- this.setOutput(true, "dict");
- this.setTooltip('Returns a weather report (dictionary)');
- }
- };
- Blockly.Blocks['weather_all_forecasts'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(WEATHER_HUE);
- this.appendDummyInput()
- .appendField("get all forecasted temperatures");
- this.setInputsInline(false);
- this.setOutput(true, "dict");
- this.setTooltip('Returns a list of dictionaries of forecasts and cities');
- }
- };
- /*
- * Stocks Data
- */
- var COMPANIES = [['Facebook', 'FB'],
- ['Apple', 'AAPL'],
- ['Microsoft', 'MSFT'],
- ['Google', 'GOOG']]
- Blockly.Blocks['stocks_current'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(STOCKS_HUE);
- this.appendDummyInput()
- .appendField("get current stock of")
- .appendField(new Blockly.FieldDropdown(COMPANIES), 'TICKER');
- this.setInputsInline(false);
- this.setOutput(true, "Number");
- this.setTooltip('Returns a single stock change value (number)');
- }
- };
-
- Blockly.Blocks['stocks_past'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(STOCKS_HUE);
- this.appendDummyInput()
- .appendField("get past stock changes of")
- .appendField(new Blockly.FieldDropdown(COMPANIES), 'TICKER');
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns a list of the previous stock values');
- }
- };
- /*
- * Earthquake Data
- */
- var EARTHQUAKES = [['magnitude', 'magnitude'],
- ['depth', 'depth']]
- Blockly.Blocks['earthquake_get'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(QUAKES_HUE);
- this.appendDummyInput()
- .appendField("get recent earthquakes'")
- .appendField(new Blockly.FieldDropdown(EARTHQUAKES), 'PROPERTY');
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns a property of an earthquake');
- }
- };
- Blockly.Blocks['earthquake_both'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(QUAKES_HUE);
- this.appendDummyInput()
- .appendField("get earthquakes magnitude and depth'");
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns magnitude and depth of multiple earthquakes');
- }
- };
- Blockly.Blocks['earthquake_all'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(QUAKES_HUE);
- this.appendDummyInput()
- .appendField("get complete earthquakes report'");
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns all properties of multiple earthquakes');
- }
- };
- /*
- * Crime Data
- */
-
- var YEARS = [];
- for (var i = 1960; i <= 2012; i+= 5) {
- YEARS.push([''+i, ''+i]);
- }
- var STATES = [['Alaska', 'alaska'], ['California', 'california'],
- ['Delaware', 'delaware'], ['Florida', 'florida'],
- ['Maryland', 'maryland'], ['Nevada', 'nevada'],
- ['New Jersey', 'new jersey'], ['New York', 'new york'],
- ['Pennsylvania', 'pennsylvania'], ['Texas', 'texas'],
- ['Virginia', 'virginia']];
- Blockly.Blocks['crime_state'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(CRIME_HUE);
- this.appendDummyInput()
- .appendField("get")
- .appendField(new Blockly.FieldDropdown([['property', 'property'],
- ['violent', 'violent'],
- ['both kinds', 'both']]), 'TYPE')
- .appendField("crime rates in")
- .appendField(new Blockly.FieldDropdown(STATES), 'STATE');
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns all of the crime rates in the those states since 1960');
- }
- };
- Blockly.Blocks['crime_year'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(CRIME_HUE);
- this.appendDummyInput()
- .appendField("get crime rates in")
- .appendField(new Blockly.FieldDropdown(YEARS), 'YEAR');
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns all of the crime rates reports for the given year by state');
- }
- };
- Blockly.Blocks['crime_all'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(CRIME_HUE);
- this.appendDummyInput()
- .appendField("get all crime reports");
- this.setInputsInline(false);
- this.setOutput(true, "dict");
- this.setTooltip('Returns all of the crime rates reports');
- }
- };
- /*
- * Book Data
- */
- Blockly.Blocks['books_get'] = {
- init: function() {
- this.setHelpUrl('http://www.example.com/');
- this.setColour(BOOKS_HUE);
- this.appendDummyInput()
- .appendField("get books");
- this.setInputsInline(false);
- this.setOutput(true, "Array");
- this.setTooltip('Returns a list of books (list of dict)');
- }
- };
-
|