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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 Number.constrain = function(num, min, max) | 529 Number.constrain = function(num, min, max) |
530 { | 530 { |
531 if (num < min) | 531 if (num < min) |
532 num = min; | 532 num = min; |
533 else if (num > max) | 533 else if (num > max) |
534 num = max; | 534 num = max; |
535 return num; | 535 return num; |
536 } | 536 } |
537 | 537 |
538 Date.prototype.toRFC3339 = function() | 538 Date.prototype.toISO8601Compact = function() |
539 { | 539 { |
540 function leadZero(x) | 540 function leadZero(x) |
541 { | 541 { |
542 return x > 9 ? x : '0' + x | 542 return x > 9 ? x : '0' + x |
543 } | 543 } |
544 var offset = Math.abs(this.getTimezoneOffset()); | 544 return this.getFullYear() + |
545 var offsetString = Math.floor(offset / 60) + ':' + leadZero(offset % 60); | 545 leadZero(this.getMonth() + 1) + |
546 return this.getFullYear() + '-' + | |
547 leadZero(this.getMonth() + 1) + '-' + | |
548 leadZero(this.getDate()) + 'T' + | 546 leadZero(this.getDate()) + 'T' + |
549 leadZero(this.getHours()) + ':' + | 547 leadZero(this.getHours()) + |
550 leadZero(this.getMinutes()) + ':' + | 548 leadZero(this.getMinutes()) + |
551 leadZero(this.getSeconds()) + | 549 leadZero(this.getSeconds()); |
552 (!offset ? "Z" : (this.getTimezoneOffset() > 0 ? '-' : '+') + offsetS
tring); | |
553 } | 550 } |
554 | 551 |
555 HTMLTextAreaElement.prototype.moveCursorToEnd = function() | 552 HTMLTextAreaElement.prototype.moveCursorToEnd = function() |
556 { | 553 { |
557 var length = this.value.length; | 554 var length = this.value.length; |
558 this.setSelectionRange(length, length); | 555 this.setSelectionRange(length, length); |
559 } | 556 } |
560 | 557 |
561 Object.defineProperty(Array.prototype, "remove", | 558 Object.defineProperty(Array.prototype, "remove", |
562 { | 559 { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 var text = content; | 978 var text = content; |
982 var result = 0; | 979 var result = 0; |
983 var match; | 980 var match; |
984 while (text && (match = regex.exec(text))) { | 981 while (text && (match = regex.exec(text))) { |
985 if (match[0].length > 0) | 982 if (match[0].length > 0) |
986 ++result; | 983 ++result; |
987 text = text.substring(match.index + 1); | 984 text = text.substring(match.index + 1); |
988 } | 985 } |
989 return result; | 986 return result; |
990 } | 987 } |
OLD | NEW |