corgis.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * @license
  3. * Visual Blocks Language
  4. *
  5. * Copyright 2012 Google Inc.
  6. * https://developers.google.com/blockly/
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /**
  21. * @fileoverview Generating Pseudo for CORGIS big data blocks.
  22. * @author acbart@vt.edu (Austin Cory Bart)
  23. */
  24. 'use strict';
  25. goog.provide('Blockly.Pseudo.corgis');
  26. goog.require('Blockly.Pseudo');
  27. /*
  28. * Weather Data
  29. */
  30. Blockly.Pseudo['weather_temperature'] = function(block) {
  31. Blockly.Pseudo.definitions_['import_weather'] = 'Import the weather module (which provides access to US weather reports).';
  32. var code = 'the current temperature for ';
  33. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('CITY'));
  34. code += argument0;
  35. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  36. };
  37. Blockly.Pseudo['weather_forecasts'] = function(block) {
  38. Blockly.Pseudo.definitions_['import_weather'] = 'Import the weather module (which provides access to US weather reports).';
  39. var code = 'the expected temperatures for ';
  40. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('CITY'));
  41. code += argument0 + '';
  42. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  43. };
  44. Blockly.Pseudo['weather_highs_lows'] = function(block) {
  45. Blockly.Pseudo.definitions_['import_weather'] = 'Import the weather module (which provides access to US weather reports).';
  46. var code = 'the highs and lows for ';
  47. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('CITY'));
  48. code += argument0 + '';
  49. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  50. };
  51. Blockly.Pseudo['weather_report'] = function(block) {
  52. Blockly.Pseudo.definitions_['import_weather'] = 'Import the weather module (which provides access to US weather reports).';
  53. var code = 'the complete weather report for ';
  54. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('CITY'));
  55. code += argument0 + '';
  56. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  57. };
  58. Blockly.Pseudo['weather_report_forecasts'] = function(block) {
  59. Blockly.Pseudo.definitions_['import_weather'] = 'Import the weather module (which provides access to US weather reports).';
  60. var code = 'the complete weather forecast for ';
  61. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('CITY'));
  62. code += argument0 + '';
  63. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  64. };
  65. Blockly.Pseudo['weather_all_forecasts'] = function(block) {
  66. Blockly.Pseudo.definitions_['import_weather'] = 'Import the weather module (which provides access to US weather reports).';
  67. var code = 'all of the forecasted weather reports'
  68. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  69. };
  70. /*
  71. * Stocks Data
  72. */
  73. Blockly.Pseudo['stocks_current'] = function(block) {
  74. Blockly.Pseudo.definitions_['import_stocks'] = 'Import the stock module (which provides access to stock changes)';
  75. var code = 'the current change in stock for ';
  76. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('TICKER'));
  77. code += argument0;
  78. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  79. };
  80. Blockly.Pseudo['stocks_past'] = function(block) {
  81. Blockly.Pseudo.definitions_['import_stocks'] = 'Import the stock module (which provides access to stock changes)';
  82. var code = 'the past change in stocks for ';
  83. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('TICKER'));
  84. code += argument0;
  85. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  86. };
  87. /*
  88. * Earthquake Data
  89. */
  90. Blockly.Pseudo['earthquake_get'] = function(block) {
  91. Blockly.Pseudo.definitions_['import_earthquakes'] = 'Import the earthquake module (which provides access to recent earthquakes)';
  92. var code = 'the ';
  93. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('PROPERTY'));
  94. code += argument0 + ' of recent earthquakes';
  95. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  96. };
  97. Blockly.Pseudo['earthquake_both'] = function(block) {
  98. Blockly.Pseudo.definitions_['import_earthquakes'] = 'Import the earthquake module (which provides access to recent earthquakes)';
  99. var code = 'both the magnitude and depth of recent earthquakes';
  100. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  101. };
  102. Blockly.Pseudo['earthquake_all'] = function(block) {
  103. Blockly.Pseudo.definitions_['import_earthquakes'] = 'Import the earthquake module (which provides access to recent earthquakes)';
  104. var code = 'all of the recent earthquakes';
  105. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  106. };
  107. /*
  108. * Crime Data
  109. */
  110. Blockly.Pseudo['crime_state'] = function(block) {
  111. Blockly.Pseudo.definitions_['import_crime'] = 'Import the crime module (which provides access to historical crime records in the US)';
  112. var code = 'the ' + block.getFieldValue('TYPE') + ' property crimes of ';
  113. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('STATE'));
  114. code += argument0;
  115. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  116. };
  117. Blockly.Pseudo['crime_year'] = function(block) {
  118. Blockly.Pseudo.definitions_['import_crime'] = 'Import the crime module (which provides access to historical crime records in the US)';
  119. var code = 'the crime reports in ';
  120. var argument0 = Blockly.Pseudo.quote_(block.getFieldValue('YEAR'));
  121. code += argument0;
  122. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  123. };
  124. Blockly.Pseudo['crime_all'] = function(block) {
  125. Blockly.Pseudo.definitions_['import_crime'] = 'Import the crime module (which provides access to historical crime records in the US)';
  126. var code = 'all of the crime reports';
  127. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  128. };
  129. /*
  130. * Book Data
  131. */
  132. Blockly.Pseudo['books_get'] = function(block) {
  133. Blockly.Pseudo.definitions_['import_books'] = 'Import the books module (which provides access to a few example books)';
  134. var code = 'all of the books';
  135. return [code, Blockly.Pseudo.ORDER_ATOMIC];
  136. };