| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 String.prototype.escapeHTML = function() | 444 String.prototype.escapeHTML = function() |
| 445 { | 445 { |
| 446 return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">
").replace(/"/g, """); | 446 return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">
").replace(/"/g, """); |
| 447 } | 447 } |
| 448 | 448 |
| 449 String.prototype.collapseWhitespace = function() | 449 String.prototype.collapseWhitespace = function() |
| 450 { | 450 { |
| 451 return this.replace(/[\s\xA0]+/g, " "); | 451 return this.replace(/[\s\xA0]+/g, " "); |
| 452 } | 452 } |
| 453 | 453 |
| 454 String.prototype.trimMiddle = function(maxLength) |
| 455 { |
| 456 if (this.length <= maxLength) |
| 457 return this; |
| 458 var leftHalf = maxLength >> 1; |
| 459 var rightHalf = maxLength - leftHalf - 1; |
| 460 return this.substr(0, leftHalf) + "\u2026" + this.substr(this.length - right
Half, rightHalf); |
| 461 } |
| 462 |
| 454 String.prototype.trimURL = function(baseURLDomain) | 463 String.prototype.trimURL = function(baseURLDomain) |
| 455 { | 464 { |
| 456 var result = this.replace(/^(https|http|file):\/\//i, ""); | 465 var result = this.replace(/^(https|http|file):\/\//i, ""); |
| 457 if (baseURLDomain) | 466 if (baseURLDomain) |
| 458 result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp()
, "i"), ""); | 467 result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp()
, "i"), ""); |
| 459 return result; | 468 return result; |
| 460 } | 469 } |
| 461 | 470 |
| 462 String.prototype.removeURLFragment = function() | 471 String.prototype.removeURLFragment = function() |
| 463 { | 472 { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 var text = content; | 1068 var text = content; |
| 1060 var result = 0; | 1069 var result = 0; |
| 1061 var match; | 1070 var match; |
| 1062 while (text && (match = regex.exec(text))) { | 1071 while (text && (match = regex.exec(text))) { |
| 1063 if (match[0].length > 0) | 1072 if (match[0].length > 0) |
| 1064 ++result; | 1073 ++result; |
| 1065 text = text.substring(match.index + 1); | 1074 text = text.substring(match.index + 1); |
| 1066 } | 1075 } |
| 1067 return result; | 1076 return result; |
| 1068 } | 1077 } |
| OLD | NEW |