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

Side by Side Diff: ui/file_manager/file_manager/common/js/util.js

Issue 824003004: Add type annotations to metadata_dispatcher.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * Namespace for utility functions. 6 * Namespace for utility functions.
7 */ 7 */
8 var util = {}; 8 var util = {};
9 9
10 /** 10 /**
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 for (i = 2 /* MB */; i < UNITS.length - 1; i++) { 194 for (i = 2 /* MB */; i < UNITS.length - 1; i++) {
195 if (bytes < STEPS[i + 1]) 195 if (bytes < STEPS[i + 1])
196 return fmt(STEPS[i], UNITS[i]); 196 return fmt(STEPS[i], UNITS[i]);
197 } 197 }
198 198
199 return fmt(STEPS[i], UNITS[i]); 199 return fmt(STEPS[i], UNITS[i]);
200 }; 200 };
201 201
202 /** 202 /**
203 * Utility function to read specified range of bytes from file
204 * @param {File} file The file to read.
205 * @param {number} begin Starting byte(included).
206 * @param {number} end Last byte(excluded).
207 * @param {function(File, ByteReader)} callback Callback to invoke.
208 * @param {function(string)} onError Error handler.
209 */
210 util.readFileBytes = function(file, begin, end, callback, onError) {
211 var fileReader = new FileReader();
212 fileReader.onerror = function(event) {
213 onError(event.type);
214 };
215 fileReader.onloadend = function() {
216 callback(file, new ByteReader(
217 /** @type {ArrayBuffer} */ (fileReader.result)));
218 };
219 fileReader.readAsArrayBuffer(file.slice(begin, end));
220 };
221
222 /**
223 * Returns a string '[Ctrl-][Alt-][Shift-][Meta-]' depending on the event 203 * Returns a string '[Ctrl-][Alt-][Shift-][Meta-]' depending on the event
224 * modifiers. Convenient for writing out conditions in keyboard handlers. 204 * modifiers. Convenient for writing out conditions in keyboard handlers.
225 * 205 *
226 * @param {Event} event The keyboard event. 206 * @param {Event} event The keyboard event.
227 * @return {string} Modifiers. 207 * @return {string} Modifiers.
228 */ 208 */
229 util.getKeyModifiers = function(event) { 209 util.getKeyModifiers = function(event) {
230 return (event.ctrlKey ? 'Ctrl-' : '') + 210 return (event.ctrlKey ? 'Ctrl-' : '') +
231 (event.altKey ? 'Alt-' : '') + 211 (event.altKey ? 'Alt-' : '') +
232 (event.shiftKey ? 'Shift-' : '') + 212 (event.shiftKey ? 'Shift-' : '') +
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 * @param {!cr.EventTarget} target 994 * @param {!cr.EventTarget} target
1015 * @param {string} type 995 * @param {string} type
1016 * @param {Function} handler 996 * @param {Function} handler
1017 */ 997 */
1018 util.addEventListenerToBackgroundComponent = function(target, type, handler) { 998 util.addEventListenerToBackgroundComponent = function(target, type, handler) {
1019 target.addEventListener(type, handler); 999 target.addEventListener(type, handler);
1020 window.addEventListener('pagehide', function() { 1000 window.addEventListener('pagehide', function() {
1021 target.removeEventListener(type, handler); 1001 target.removeEventListener(type, handler);
1022 }); 1002 });
1023 }; 1003 };
OLDNEW
« no previous file with comments | « ui/file_manager/externs/platform_worker.js ('k') | ui/file_manager/file_manager/foreground/js/metadata/compiled_resources.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698