@@ -1891,12 +1891,10 @@ Blockly.Blocks['servo_angle_set'] = {
18911891Blockly . Blocks [ 'data_firebase' ]  =  { 
18921892 init : function  ( )  { 
18931893 this . appendValueInput ( "name_" ) 
1894-  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_NAME ,  "< Firebase > 名稱: " ) ; 
1894+  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_NAME ,  "使用 firebase 資料庫 " ) ; 
18951895 this . appendDummyInput ( ) 
18961896 . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_URL ,  "網址:" ) 
18971897 . appendField ( new  Blockly . FieldTextInput ( "https://<YOUR-FIREBASE-APP>.firebaseio.com" ) ,  "url_" ) ; 
1898-  this . appendStatementInput ( "do_" ) 
1899-  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_DO ,  "執行:" ) ; 
19001898 this . setPreviousStatement ( true ) ; 
19011899 this . setNextStatement ( true ) ; 
19021900 this . setTooltip ( '' ) ; 
@@ -1905,17 +1903,115 @@ Blockly.Blocks['data_firebase'] = {
19051903 } 
19061904} ; 
19071905
1908- Blockly . Blocks [ 'data_firebase_write ' ]  =  { 
1906+ Blockly . Blocks [ 'data_firebase_write_container ' ]  =  { 
19091907 init : function  ( )  { 
1910-  this . appendStatementInput ( "write_" ) 
1911-  . appendField ( new  Blockly . FieldVariable ( "myFirebase" ) ,  "var_" ) 
1912-  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_WRITE ,  "寫入" ) ; 
1908+  this . setColour ( 100 ) ; 
1909+  this . appendDummyInput ( ) 
1910+  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_ADDCOLUMN ,  '增加資料欄位' ) ; 
1911+  this . appendStatementInput ( 'STACK' ) ; 
1912+  this . setTooltip ( '' ) ; 
1913+  this . contextMenu  =  false ; 
1914+  } 
1915+ } ; 
1916+ 
1917+ Blockly . Blocks [ 'data_firebase_write_item' ]  =  { 
1918+  init : function  ( )  { 
1919+  this . setColour ( 100 ) ; 
1920+  this . appendDummyInput ( ) 
1921+  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_COLUMN , '欄位' ) ; 
19131922 this . setPreviousStatement ( true ) ; 
19141923 this . setNextStatement ( true ) ; 
19151924 this . setTooltip ( '' ) ; 
1925+  this . contextMenu  =  false ; 
1926+  } 
1927+ } ; 
1928+ 
1929+ Blockly . Blocks [ 'data_firebase_write' ]  =  { 
1930+  init : function  ( )  { 
1931+  this . appendDummyInput ( ) 
1932+  . appendField ( new  Blockly . FieldVariable ( "myFirebase" ) ,  "var_" ) 
1933+  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_WRITEDATA , "寫入資料" ) ; 
19161934 this . setColour ( 160 ) ; 
1935+  this . itemCount_  =  2 ; 
1936+  this . updateShape_ ( ) ; 
1937+  this . setMutator ( new  Blockly . Mutator ( [ 'data_firebase_write_item' ] ) ) ; 
1938+  this . setTooltip ( '' ) ; 
1939+  this . setPreviousStatement ( true ) ; 
1940+  this . setNextStatement ( true ) ; 
19171941 this . setHelpUrl ( 'http://www.example.com/' ) ; 
1918-  } 
1942+  } , 
1943+  mutationToDom : function  ( )  { 
1944+  var  container  =  document . createElement ( 'mutation' ) ; 
1945+  container . setAttribute ( 'items' ,  this . itemCount_ ) ; 
1946+  return  container ; 
1947+  } , 
1948+  domToMutation : function  ( xmlElement )  { 
1949+  this . itemCount_  =  parseInt ( xmlElement . getAttribute ( 'items' ) ,  10 ) ; 
1950+  this . updateShape_ ( ) ; 
1951+  } , 
1952+  decompose : function  ( workspace )  { 
1953+  var  containerBlock  =  Blockly . Block . obtain ( workspace , 
1954+  'data_firebase_write_container' ) ; 
1955+  containerBlock . initSvg ( ) ; 
1956+  var  connection  =  containerBlock . getInput ( 'STACK' ) . connection ; 
1957+  for  ( var  i  =  0 ;  i  <  this . itemCount_ ;  i ++ )  { 
1958+  var  itemBlock  =  Blockly . Block . obtain ( workspace ,  'data_firebase_write_item' ) ; 
1959+  itemBlock . initSvg ( ) ; 
1960+  connection . connect ( itemBlock . previousConnection ) ; 
1961+  connection  =  itemBlock . nextConnection ; 
1962+  } 
1963+  return  containerBlock ; 
1964+  } , 
1965+  compose : function  ( containerBlock )  { 
1966+  var  itemBlock  =  containerBlock . getInputTargetBlock ( 'STACK' ) ; 
1967+  var  connections  =  [ ] ; 
1968+  while  ( itemBlock )  { 
1969+  connections . push ( itemBlock . valueConnection_ ) ; 
1970+  itemBlock  =  itemBlock . nextConnection  && 
1971+  itemBlock . nextConnection . targetBlock ( ) ; 
1972+  } 
1973+  this . itemCount_  =  connections . length ; 
1974+  this . updateShape_ ( ) ; 
1975+  for  ( var  i  =  0 ;  i  <  this . itemCount_ ;  i ++ )  { 
1976+  if  ( connections [ i ] )  { 
1977+  this . getInput ( 'data_'  +  i ) . connection . connect ( connections [ i ] ) ; 
1978+  } 
1979+  } 
1980+  } , 
1981+  saveConnections : function  ( containerBlock )  { 
1982+  var  itemBlock  =  containerBlock . getInputTargetBlock ( 'STACK' ) ; 
1983+  var  i  =  0 ; 
1984+  while  ( itemBlock )  { 
1985+  var  input  =  this . getInput ( 'data_'  +  i ) ; 
1986+  itemBlock . valueConnection_  =  input  &&  input . connection . targetConnection ; 
1987+  i ++ ; 
1988+  itemBlock  =  itemBlock . nextConnection  && 
1989+  itemBlock . nextConnection . targetBlock ( ) ; 
1990+  } 
1991+  } , 
1992+  updateShape_ : function  ( )  { 
1993+  var  v  =  [ ] ; 
1994+  if  ( this . getInput ( 'EMPTY' ) )  { 
1995+  this . removeInput ( 'EMPTY' ) ; 
1996+  }  else  { 
1997+  var  i  =  0 ; 
1998+  while  ( this . getInput ( 'data_'  +  i ) )  { 
1999+  v [ i ]  =  this . getInput ( 'data_'  +  i ) . fieldRow [ 1 ] . text_ ; 
2000+  this . removeInput ( 'data_'  +  i ) ; 
2001+  i ++ ; 
2002+  } 
2003+  } 
2004+  if  ( this . itemCount_  ==  0 )  { }  else  { 
2005+  for  ( var  i  =  0 ;  i  <  this . itemCount_ ;  i ++ )  { 
2006+  this . appendValueInput ( 'data_'  +  i ) 
2007+  . setAlign ( Blockly . ALIGN_RIGHT ) 
2008+  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_WRITEDATACOLUMN  +  ( i  +  1 )  +  Blockly . Msg . WEBDUINO_FIREBASE_WRITEDATANAME ) 
2009+  . appendField ( new  Blockly . FieldTextInput ( '...' ) ,  "name_"  +  i ) 
2010+  . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_WRITEDATAVAL ) ; 
2011+  } 
2012+  } 
2013+  } , 
2014+  newQuote_ : Blockly . Blocks [ 'text' ] . newQuote_ 
19192015} ; 
19202016
19212017Blockly . Blocks [ 'data_firebase_data' ]  =  { 
@@ -1940,8 +2036,8 @@ Blockly.Blocks['data_firebase_read'] = {
19402036 . appendField ( new  Blockly . FieldTextInput ( "..." ) ,  "attr_" ) 
19412037 . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_S ,  "的" ) 
19422038 . appendField ( new  Blockly . FieldDropdown ( [ 
1943-  [ "完整內容" ,  '1' ] , 
1944-  [ "最後一筆更新" ,  '2' ] 
2039+  [ Blockly . Msg . WEBDUINO_FIREBASE_DATAALL ,  '1' ] , 
2040+  [ Blockly . Msg . WEBDUINO_FIREBASE_DATALAST ,  '2' ] 
19452041 ] ) ,  "type_" ) 
19462042 . appendField ( Blockly . Msg . WEBDUINO_FIREBASE_TO ,  "到" ) ; 
19472043 this . appendStatementInput ( "do_" ) 
0 commit comments