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

Side by Side Diff: ui/webui/resources/js/util.js

Issue 125993002: Add error handling for supervised user import flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move ManagedUserListData to its own file. Created 6 years, 11 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 | Annotate | Revision Log
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 <include src="assert.js"> 5 <include src="assert.js">
6 6
7 /** 7 /**
8 * The global object. 8 * The global object.
9 * @type {!Object} 9 * @type {!Object}
10 * @const 10 * @const
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 /** 375 /**
376 * Alias for document.scrollLeft setter. 376 * Alias for document.scrollLeft setter.
377 * @param {!HTMLDocument} doc The document node where information will be 377 * @param {!HTMLDocument} doc The document node where information will be
378 * queried from. 378 * queried from.
379 * @param {number} value The target X scroll offset. 379 * @param {number} value The target X scroll offset.
380 */ 380 */
381 function setScrollLeftForDocument(doc, value) { 381 function setScrollLeftForDocument(doc, value) {
382 doc.documentElement.scrollLeft = doc.body.scrollLeft = value; 382 doc.documentElement.scrollLeft = doc.body.scrollLeft = value;
383 } 383 }
384
385 /**
386 * Replaces '&', '<', '>', '"', and ''' characters with their HTML encoding.
387 * @param {string} original The original string.
388 * @return {string} The string with all the characters mentioned above replaced.
389 */
390 function HTMLEscape(original) {
391 return original.replace(/&/g, '&amp;')
392 .replace(/</g, '&lt;')
393 .replace(/>/g, '&gt;')
394 .replace(/"/g, '&quot;')
395 .replace(/'/g, '&#39;');
396 }
397
398 /**
399 * Shortens the provided string (if necessary) to a string of length at most
400 * |maxLength|.
401 * @param {string} original The original string.
402 * @param {number} maxLength The maximum length allowed for the string.
403 * @return {string} The original string if its length does not exceed
404 * |maxLength|. Otherwise the first |maxLength| - 3 characters with '...'
405 * appended.
406 */
407 function elide(original, maxLength) {
408 if (original.length <= maxLength)
409 return original;
410 return original.substring(0, maxLength - 3) + '...';
411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698