Skip to content
MaryS94 edited this page Feb 5, 2016 · 1 revision

Overview

This file contains everything necessary to read things with the screen reader. One of the most important features of this file is the Say('string to be read') function that will read out the given string immediately to the user. This function is primarily used for alerting and updating the user when needed.

How blocks are read

The majority of block reading is handled in speech.js. Default strings for each block are stored in the method blockToString. Each string denotes potential inner blocks with ( ) and fields with ' '. Regex is used to replace these symbols with the appropriate content as the workspace changes.

blockToString(type, disabled){

type - The type of block selected.
disabled - Used during the process to connect blocks, it is a boolean representing if the block is disabled in the menu. If it is disabled the block reads "connection doesn't match" followed by the default block string.

Returns default string of the block

}

changeString(block, xmlDoc){

Creates the string to be read by the screenreader using the xml of blocks in the workspace.

block - The xml of the currently selected block
xmlDoc - The xml of all of the blocks on the workspace

Variables
strArr - Stores the default str of every block.
blockArr - Stores every block to be read.
fieldBlcArr - Stores the tags of the blocks in blockArr.
fieldValArr - Stores the values of all fields in blockArr.

How it works

  1. strArr is populated with default strings.
  2. fieldValArr is populated with all field values.
  3. Replace instances of ' ' in the strings with the field values.
  4. Combine each element of strArr into strArr[0] by replacing ( ) with the next string in the array.

Returns newStr (strArr[0] with updated values).

}

fieldNameChange(defaultName, blockType){

Changes the letter representations of field values into words. (example: EQ = equals)

defaultName - Usually denoted as 2 - 4 capital letters in a field tag.
blockType - The type of block being updated. This is currently only used for the text_charAt block so that it can be worded logically. This parameter most likely be replaced with a better solution.

Returns the word equivalent of the default name in lowercase due to screenreaders sometimes reading capital letters individually. ##}