Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/host/chrome/braille_table.js

Issue 589133002: Make undefined Unicode characters show up in a nicer way in braille. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moretables
Patch Set: Fix typo. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Holds information about a braille table. 6 * @fileoverview Holds information about a braille table.
7 */ 7 */
8 8
9 goog.provide('cvox.BrailleTable'); 9 goog.provide('cvox.BrailleTable');
10 10
11 11
12 /** 12 /**
13 * @typedef {{ 13 * @typedef {{
14 * locale:string, 14 * locale:string,
15 * dots:string, 15 * dots:string,
16 * id:string, 16 * id:string,
17 * grade:(string|undefined), 17 * grade:(string|undefined),
18 * variant:(string|undefined), 18 * variant:(string|undefined),
19 * fileName:string 19 * fileNames:string
20 * }} 20 * }}
21 */ 21 */
22 cvox.BrailleTable.Table; 22 cvox.BrailleTable.Table;
23 23
24 24
25 /** 25 /**
26 * @const {string} 26 * @const {string}
27 */ 27 */
28 cvox.BrailleTable.TABLE_PATH = 'chromevox/background/braille/tables.json'; 28 cvox.BrailleTable.TABLE_PATH = 'chromevox/background/braille/tables.json';
29 29
30 30
31 /** 31 /**
32 * @const {string}
33 * @private
34 */
35 cvox.BrailleTable.COMMON_DEFS_FILENAME_ = 'cvox-common.cti';
36
37
38 /**
32 * Retrieves a list of all available braille tables. 39 * Retrieves a list of all available braille tables.
33 * @param {function(!Array.<cvox.BrailleTable.Table>)} callback 40 * @param {function(!Array.<cvox.BrailleTable.Table>)} callback
34 */ 41 */
35 cvox.BrailleTable.getAll = function(callback) { 42 cvox.BrailleTable.getAll = function(callback) {
43 function appendCommonFilename(tables) {
44 // Append the common definitions to all table filenames.
45 tables.forEach(function(table) {
46 table.fileNames += (',' + cvox.BrailleTable.COMMON_DEFS_FILENAME_);
47 });
48 return tables;
49 }
36 var url = chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH); 50 var url = chrome.extension.getURL(cvox.BrailleTable.TABLE_PATH);
37 if (!url) { 51 if (!url) {
38 throw 'Invalid path: ' + cvox.BrailleTable.TABLE_PATH; 52 throw 'Invalid path: ' + cvox.BrailleTable.TABLE_PATH;
39 } 53 }
40 54
41 var xhr = new XMLHttpRequest(); 55 var xhr = new XMLHttpRequest();
42 xhr.open('GET', url, true); 56 xhr.open('GET', url, true);
43 xhr.onreadystatechange = function() { 57 xhr.onreadystatechange = function() {
44 if (xhr.readyState == 4) { 58 if (xhr.readyState == 4) {
45 if (xhr.status == 200) { 59 if (xhr.status == 200) {
46 callback(/** @type {!Array.<cvox.BrailleTable.Table>} */ ( 60 callback(
47 JSON.parse(xhr.responseText))); 61 appendCommonFilename(
62 /** @type {!Array.<cvox.BrailleTable.Table>} */ (
63 JSON.parse(xhr.responseText))));
48 } 64 }
49 } 65 }
50 }; 66 };
51 xhr.send(); 67 xhr.send();
52 }; 68 };
53 69
54 70
55 /** 71 /**
56 * Finds a table in a list of tables by id. 72 * Finds a table in a list of tables by id.
57 * @param {!Array.<cvox.BrailleTable.Table>} tables tables to search in. 73 * @param {!Array.<cvox.BrailleTable.Table>} tables tables to search in.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return msgs.getMsg('braille_table_name_with_grade', 123 return msgs.getMsg('braille_table_name_with_grade',
108 [localeName, table.grade]); 124 [localeName, table.grade]);
109 } else if (!table.grade && table.variant) { 125 } else if (!table.grade && table.variant) {
110 return msgs.getMsg('braille_table_name_with_variant', 126 return msgs.getMsg('braille_table_name_with_variant',
111 [localeName, table.variant]); 127 [localeName, table.variant]);
112 } else { 128 } else {
113 return msgs.getMsg('braille_table_name_with_variant_and_grade', 129 return msgs.getMsg('braille_table_name_with_variant_and_grade',
114 [localeName, table.variant, table.grade]); 130 [localeName, table.variant, table.grade]);
115 } 131 }
116 }; 132 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698