[html5] r4605 - [e] (0) Fix some coding errors in a scripted iCalendar example.

whatwg at whatwg.org whatwg at whatwg.org
Sun Jan 17 22:46:24 PST 2010


Author: ianh
Date: 2010-01-17 22:46:22 -0800 (Sun, 17 Jan 2010)
New Revision: 4605

Modified:
   complete.html
   index
   source
Log:
[e] (0) Fix some coding errors in a scripted iCalendar example.

Modified: complete.html
===================================================================
--- complete.html	2010-01-18 06:36:25 UTC (rev 4604)
+++ complete.html	2010-01-18 06:46:22 UTC (rev 4605)
@@ -48432,7 +48432,9 @@
    this:</p>
 
    <pre>function getCalendar(node) {
-  while (node && (!node.nodeScope || !node.itemType == 'http://microformats.org/profile/hcalendar#vevent'))
+  // This function assumes the content is valid.
+  // It is not a compliant implementation of the algorithm for <a href=#extracting-vevent-data>extracting vEvent data</a>.
+  while (node && (!node.itemScope || !node.itemType == 'http://microformats.org/profile/hcalendar#vevent'))
     node = node.parentNode;
   if (!node) {
     alert('No event data found.');
@@ -48450,19 +48452,19 @@
     var parameters = '';
     if (prop.localName == 'time') {
       value = value.replace(/[:-]/g, '');
-      if (prop.date && prop.time)
+      if (value.match(/T/))
         parameters = ';VALUE=DATE';
       else
         parameters = ';VALUE=DATE-TIME';
     } else {
       value = value.replace(/\\/g, '\\n');
       value = value.replace(/;/g, '\\;');
-      value = value.replace(/,/g, \\,');
+      value = value.replace(/,/g, '\\,');
       value = value.replace(/\n/g, '\\n');
     }
     for (var nameIndex = 0; nameIndex < prop.itemProp.length; nameIndex += 1) {
       var name = prop.itemProp[nameIndex];
-      if (!name.match(':') && !name.match('.'))
+      if (!name.match(/:/) && !name.match(/\./))
         calendar += name.toUpperCase() + parameters + ':' + value + '\r\n';
     }
   }

Modified: index
===================================================================
--- index	2010-01-18 06:36:25 UTC (rev 4604)
+++ index	2010-01-18 06:46:22 UTC (rev 4605)
@@ -48332,7 +48332,9 @@
    this:</p>
 
    <pre>function getCalendar(node) {
-  while (node && (!node.nodeScope || !node.itemType == 'http://microformats.org/profile/hcalendar#vevent'))
+  // This function assumes the content is valid.
+  // It is not a compliant implementation of the algorithm for <a href=#extracting-vevent-data>extracting vEvent data</a>.
+  while (node && (!node.itemScope || !node.itemType == 'http://microformats.org/profile/hcalendar#vevent'))
     node = node.parentNode;
   if (!node) {
     alert('No event data found.');
@@ -48350,19 +48352,19 @@
     var parameters = '';
     if (prop.localName == 'time') {
       value = value.replace(/[:-]/g, '');
-      if (prop.date && prop.time)
+      if (value.match(/T/))
         parameters = ';VALUE=DATE';
       else
         parameters = ';VALUE=DATE-TIME';
     } else {
       value = value.replace(/\\/g, '\\n');
       value = value.replace(/;/g, '\\;');
-      value = value.replace(/,/g, \\,');
+      value = value.replace(/,/g, '\\,');
       value = value.replace(/\n/g, '\\n');
     }
     for (var nameIndex = 0; nameIndex < prop.itemProp.length; nameIndex += 1) {
       var name = prop.itemProp[nameIndex];
-      if (!name.match(':') && !name.match('.'))
+      if (!name.match(/:/) && !name.match(/\./))
         calendar += name.toUpperCase() + parameters + ':' + value + '\r\n';
     }
   }

Modified: source
===================================================================
--- source	2010-01-18 06:36:25 UTC (rev 4604)
+++ source	2010-01-18 06:46:22 UTC (rev 4605)
@@ -54423,7 +54423,9 @@
    this:</p>
 
    <pre>function getCalendar(node) {
-  while (node && (!node.nodeScope || !node.itemType == 'http://microformats.org/profile/hcalendar#vevent'))
+  // This function assumes the content is valid.
+  // It is not a compliant implementation of the algorithm for <span>extracting vEvent data</span>.
+  while (node && (!node.itemScope || !node.itemType == 'http://microformats.org/profile/hcalendar#vevent'))
     node = node.parentNode;
   if (!node) {
     alert('No event data found.');
@@ -54441,19 +54443,19 @@
     var parameters = '';
     if (prop.localName == 'time') {
       value = value.replace(/[:-]/g, '');
-      if (prop.date && prop.time)
+      if (value.match(/T/))
         parameters = ';VALUE=DATE';
       else
         parameters = ';VALUE=DATE-TIME';
     } else {
       value = value.replace(/\\/g, '\\n');
       value = value.replace(/;/g, '\\;');
-      value = value.replace(/,/g, \\,');
+      value = value.replace(/,/g, '\\,');
       value = value.replace(/\n/g, '\\n');
     }
     for (var nameIndex = 0; nameIndex < prop.itemProp.length; nameIndex += 1) {
       var name = prop.itemProp[nameIndex];
-      if (!name.match(':') && !name.match('.'))
+      if (!name.match(/:/) && !name.match(/\./))
         calendar += name.toUpperCase() + parameters + ':' + value + '\r\n';
     }
   }




More information about the Commit-Watchers mailing list