Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added schema.org Organization

  • Loading branch information...
commit 33b7755a989bd1698780d7608e8ffd7f66b4020f 1 parent 342a395
Klemen Slavič authored

Showing 2 changed files with 42 additions and 20 deletions. Show diff stats Hide diff stats

  1. +2 0  jquery.microdata.js
  2. +40 20 schemas.js
2  jquery.microdata.js
@@ -26,6 +26,8 @@
26 26
27 27 url: function(value, el) { return (/^https?:\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/).test(value); },
28 28
  29 + email: function(value, el) { return (/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/).text(value); },
  30 +
29 31 int: function(value, el) { return (/^\d+$/).test(value); },
30 32
31 33 float: function(value, el) { return (/^\d+([.,]\d*)?$/).test(value); },
60 schemas.js
@@ -107,6 +107,8 @@
107 107 }
108 108 ];
109 109
  110 +
  111 + // add the data-vocabulary.org validators to the plugin
110 112 for (var i = 0; i < dataVocabulary.length; i++) {
111 113 $.microdata.addDefinition(dataVocabulary[i].url, dataVocabulary[i].fields);
112 114 }
@@ -117,30 +119,48 @@
117 119 {
118 120 url: "http://schema.org/Thing",
119 121 fields: [
120   - { name: "description", required: false, type: "text", validator: validators.text },
121   - { name: "image", required: false, type: "url", validator: validators.url },
122   - { name: "name", required: false, type: "text", validator: validators.text },
123   - { name: "url", required: false, type: "url", validator: validators.url }
  122 + { name: "description", required: false, type: "text", validator: validators.text },
  123 + { name: "image", required: false, type: "url", validator: validators.url },
  124 + { name: "name", required: false, type: "text", validator: validators.text },
  125 + { name: "url", required: false, type: "url", validator: validators.url }
124 126 ]
125 127 }
126 128 ];
127   - schemaOrg.push(
128   - {
129   - url: "http://schema.org/Event",
130   - fields: extend(findByUrl(schemaOrg, "http://schema.org/Thing"), [
131   - { name: "attendees", required: false, type: "complex", validator: validators.complex }, // child elements of type Person or Organization
132   - { name: "duration", required: false, type: "duration", validator: validators.duration },
133   - { name: "endDate", required: false, type: "datetime", validator: validators.datetime },
134   - { name: "location", required: false, type: "complex", validator: validators.complex }, // child elements of type Place or PostalAddress
135   - { name: "offers", required: false, type: "complex", validator: validators.complex }, // child elements of type Offer
136   - { name: "performers", required: false, type: "complex", validator: validators.complex }, // child elements of type Person or Organization
137   - { name: "startDate", required: false, type: "datetime", validator: validators.datetime },
138   - { name: "subEvents", required: false, type: "complex", validator: validators.complex }, // child elements of type Event
139   - { name: "superEvent", required: false, type: "complex", validator: validators.complex } // a child element of type Event
140   - ])
141   - }
142   - );
  129 + schemaOrg.push({
  130 + url: "http://schema.org/Event",
  131 + fields: extend(findByUrl(schemaOrg, "http://schema.org/Thing"), [
  132 + { name: "attendees", required: false, type: "complex", validator: validators.complex }, // child elements of type Person or Organization
  133 + { name: "duration", required: false, type: "duration", validator: validators.duration },
  134 + { name: "endDate", required: false, type: "datetime", validator: validators.datetime },
  135 + { name: "location", required: false, type: "complex", validator: validators.complex }, // child elements of type Place or PostalAddress
  136 + { name: "offers", required: false, type: "complex", validator: validators.complex }, // child elements of type Offer
  137 + { name: "performers", required: false, type: "complex", validator: validators.complex }, // child elements of type Person or Organization
  138 + { name: "startDate", required: false, type: "datetime", validator: validators.datetime },
  139 + { name: "subEvents", required: false, type: "complex", validator: validators.complex }, // child elements of type Event
  140 + { name: "superEvent", required: false, type: "complex", validator: validators.complex } // a child element of type Event
  141 + ])
  142 + });
  143 + schemaOrg.push({
  144 + url: "http://schema.org/Organization",
  145 + fiels: extend(findByUrl(schemaOrg, "http://schema.org/Thing"), [
  146 + { name: "address", required: false, type: "complex", validator: validators.complex }, // a child element of PostalAddress
  147 + { name: "aggregatRating", required: false, type: "complex", validator: validators.complex }, // a child element of AggregateRating
  148 + { name: "contactPoints", required: false, type: "complex", validator: validators.complex }, // child elements of ContactPoint
  149 + { name: "email", required: false, type: "text", validator: validators.email },
  150 + { name: "employees", required: false, type: "complex", validator: validators.complex }, // child elements of Person
  151 + { name: "events", required: false, type: "complex", validator: validators.complex }, // a child element of Event
  152 + { name: "faxNumber", required: false, type: "text", validator: validators.text },
  153 + { name: "founders", required: false, type: "complex", validator: validators.complex }, // child elements of type Person
  154 + { name: "foundingDate", required: false, type: "datetime", validator: validators.datetime },
  155 + { name: "interactionCount", required: false, type: "text", validator: validators.text }, // should be one of the types of UserInteraction
  156 + { name: "location", required: false, type: "complex", validator: validators.complex }, // a child element of Place or PostalAddress
  157 + { name: "members", required: false, type: "complex", validator: validators.complex }, // child elements of Person or Organization
  158 + { name: "reviews", required: false, type: "complex", validator: validators.complex }, // child elements of Review
  159 + { name: "telephone", required: false, type: "text", validator: validators.text }
  160 + ])
  161 + });
143 162
  163 + // add schema.org to the roster
144 164 for (var i = 0; i < schemaOrg.length; i++) {
145 165 $.microdata.addDefinition(schemaOrg[i].url, schemaOrg[i].fields);
146 166 }

0 comments on commit 33b7755

Please sign in to comment.
Something went wrong with that request. Please try again.