Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Indentation fixed

  • Loading branch information...
commit 35e9907439feed41d421eda7eb61949be10faa88 1 parent 178c321
@umurgdk umurgdk authored
Showing with 161 additions and 161 deletions.
  1. +1 −1  jquery.microdata.js
  2. +160 −160 schemas.js
View
2  jquery.microdata.js
@@ -46,7 +46,7 @@
any: function(value, el) { return true; },
- boolean: function(value, el) { return (/(True|False)/).test(value); }
+ boolean: function(value, el) { return (/(True|False)/i).test(value); }
},
View
320 schemas.js
@@ -3,18 +3,18 @@
console.error('jQuery Microdata plugin has not been loaded prior to loading this script!');
return;
}
-
+
var validators = $.microdata.validators;
-
+
function extend(base, additions) {
var ret = base.fields.slice();
for (var i = 0; i < additions.length; i++) {
if (!findField(additions[i].name))
- ret.push(additions[i]);
+ ret.push(additions[i]);
}
-
+
return ret;
-
+
function findField(name) {
for (var i = 0; i < ret.length; i++) {
if (ret[i].name.toLowerCase() == name.toLowerCase()) return ret[i];
@@ -22,109 +22,109 @@
return false;
}
}
-
+
function findByUrl(source, url) {
for (var i = 0; i < source.length; i++) {
if (source[i].url == url) return source[i];
}
return null;
}
-
-
+
+
// A partial implementation of data-vocabulary.org schemas
var dataVocabulary = [
+ {
+ url: "http://data-vocabulary.org/Event",
+ fields: [
+ { name: "summary", required: true, type: "text", validator: validators.text },
+ { name: "url", required: false, type: "url", validator: validators.url },
+ { name: "location", required: false, type: "complex", validator: validators.complex }, // optionally represented by data-vocabulary.org/Organization or data-vocabulary.org/Address
+ { name: "description", required: false, type: "text", validator: validators.text },
+ { name: "startdate", required: true, type: "datetime", validator: validators.datetime },
+ { name: "enddate", required: false, type: "datetime", validator: validators.datetime },
+ { name: "duration", required: false, type: "duration", validator: validators.duration },
+ { name: "eventtype", required: false, type: "text", validator: validators.text },
+ { name: "geo", required: false, type: "complex", validator: validators.complex }, // represented by itemscope with two properties: latitude and longitude
+ { name: "photo", required: false, type: "url", validator: validators.url }
+ ]
+ },
+ {
+ url: "http://data-vocabulary.org/Person",
+ fields: [
+ { name: "name", required: false, type: "text", validator: validators.text },
+ { name: "fn", required: false, type: "text", validator: validators.text }, // alias for "name"
+ { name: "nickname", required: false, type: "text", validator: validators.text },
+ { name: "photo", required: false, type: "url", validator: validators.url },
+ { name: "title", required: false, type: "text", validator: validators.text },
+ { name: "role", required: false, type: "text", validator: validators.text },
+ { name: "url", required: false, type: "url", validator: validators.url },
+ { name: "affiliation", required: false, type: "text", validator: validators.text },
+ { name: "org", required: false, type: "text", validator: validators.text }, // alias for "affiliation"
+ { name: "address", required: false, type: "complex", validator: validators.complex }, // can have subproperties street-address, city, region, postal-code, country-name
+ { name: "adr", required: false, type: "complex", validator: validators.complex }, // alias for "address"
+ { name: "friend", required: false, type: "url", validator: validators.url },
+ { name: "contact", required: false, type: "url", validator: validators.url },
+ { name: "acquaintance", required: false, type: "url", validator: validators.url }
+ // NOTE: to define "friend", "contact" or "acquaintance", you can also use XFN rel="..."
+ ]
+ },
+ {
+ url: "http://data-vocabulary.org/Organization",
+ fields: [
+ { name: "name", required: false, type: "text", validator: validators.text },
+ { name: "fn", required: false, type: "text", validator: validators.text }, // alias for "name"
+ { name: "org", required: false, type: "text", validator: validators.text }, // alias for "name"
+ { name: "url", required: false, type: "url", validator: validators.url },
+ { name: "address", required: false, type: "complex", validator: validators.complex },
+ { name: "adr", required: false, type: "complex", validator: validators.complex }, // alias for "address"
+ { name: "tel", required: false, type: "text", validator: validators.text },
+ { name: "geo", required: false, type: "complex", validator: validators.complex }
+ ]
+ },
+ {
+ url: "http://data-vocabulary.org/Offer",
+ fields: [
+ { name: "price", required: false, type: "float", validator: validators.float },
+ { name: "currency", required: false, type: "text", validator: validators.currency },
+ { name: "pricevaliduntil", required: false, type: "datetime", validator: validators.datetime },
+ { name: "seller", required: false, type: "complex", validator: validators.complex }, // can contain a Person or Organization
{
- url: "http://data-vocabulary.org/Event",
- fields: [
- { name: "summary", required: true, type: "text", validator: validators.text },
- { name: "url", required: false, type: "url", validator: validators.url },
- { name: "location", required: false, type: "complex", validator: validators.complex }, // optionally represented by data-vocabulary.org/Organization or data-vocabulary.org/Address
- { name: "description", required: false, type: "text", validator: validators.text },
- { name: "startdate", required: true, type: "datetime", validator: validators.datetime },
- { name: "enddate", required: false, type: "datetime", validator: validators.datetime },
- { name: "duration", required: false, type: "duration", validator: validators.duration },
- { name: "eventtype", required: false, type: "text", validator: validators.text },
- { name: "geo", required: false, type: "complex", validator: validators.complex }, // represented by itemscope with two properties: latitude and longitude
- { name: "photo", required: false, type: "url", validator: validators.url }
- ]
- },
- {
- url: "http://data-vocabulary.org/Person",
- fields: [
- { name: "name", required: false, type: "text", validator: validators.text },
- { name: "fn", required: false, type: "text", validator: validators.text }, // alias for "name"
- { name: "nickname", required: false, type: "text", validator: validators.text },
- { name: "photo", required: false, type: "url", validator: validators.url },
- { name: "title", required: false, type: "text", validator: validators.text },
- { name: "role", required: false, type: "text", validator: validators.text },
- { name: "url", required: false, type: "url", validator: validators.url },
- { name: "affiliation", required: false, type: "text", validator: validators.text },
- { name: "org", required: false, type: "text", validator: validators.text }, // alias for "affiliation"
- { name: "address", required: false, type: "complex", validator: validators.complex }, // can have subproperties street-address, city, region, postal-code, country-name
- { name: "adr", required: false, type: "complex", validator: validators.complex }, // alias for "address"
- { name: "friend", required: false, type: "url", validator: validators.url },
- { name: "contact", required: false, type: "url", validator: validators.url },
- { name: "acquaintance", required: false, type: "url", validator: validators.url }
- // NOTE: to define "friend", "contact" or "acquaintance", you can also use XFN rel="..."
- ]
- },
+ name: "condition", required: false, type: "complex",
+ validator: function(value, el) {
+ return $(el).hasAttr('content') && $.inArray($(el).attr('content').toLowerCase(), ["new", "used", "refurbished"]);
+ }
+ },
{
- url: "http://data-vocabulary.org/Organization",
- fields: [
- { name: "name", required: false, type: "text", validator: validators.text },
- { name: "fn", required: false, type: "text", validator: validators.text }, // alias for "name"
- { name: "org", required: false, type: "text", validator: validators.text }, // alias for "name"
- { name: "url", required: false, type: "url", validator: validators.url },
- { name: "address", required: false, type: "complex", validator: validators.complex },
- { name: "adr", required: false, type: "complex", validator: validators.complex }, // alias for "address"
- { name: "tel", required: false, type: "text", validator: validators.text },
- { name: "geo", required: false, type: "complex", validator: validators.complex }
- ]
+ name: "availability", required: false, type: "complex",
+ validator: function(value, el) {
+ return $(el).hasAttr('content') && $.inArray($(el).attr('content').toLowerCase(), ["out_of_stock", "in_stock", "instore_only", "preorder"]);
+ }
},
- {
- url: "http://data-vocabulary.org/Offer",
- fields: [
- { name: "price", required: false, type: "float", validator: validators.float },
- { name: "currency", required: false, type: "text", validator: validators.currency },
- { name: "pricevaliduntil", required: false, type: "datetime", validator: validators.datetime },
- { name: "seller", required: false, type: "complex", validator: validators.complex }, // can contain a Person or Organization
- {
- name: "condition", required: false, type: "complex",
- validator: function(value, el) {
- return $(el).hasAttr('content') && $.inArray($(el).attr('content').toLowerCase(), ["new", "used", "refurbished"]);
- }
- },
- {
- name: "availability", required: false, type: "complex",
- validator: function(value, el) {
- return $(el).hasAttr('content') && $.inArray($(el).attr('content').toLowerCase(), ["out_of_stock", "in_stock", "instore_only", "preorder"]);
- }
- },
- { name: "offerurl", required: false, type: "url", validator: validators.url }, // points to a product web page that includes the offer
- { name: "identifier", required: false, type: "text", validator: validators.text }, // recognizes ASIN, ISBN, MPN, UPC, SKU; suggests including product prand and at least one of the identifiers
- { name: "itemoffered", required: false, type: "complex", validator: validators.complex } // can contain free text, a Product or other item types
- ]
- }
+ { name: "offerurl", required: false, type: "url", validator: validators.url }, // points to a product web page that includes the offer
+ { name: "identifier", required: false, type: "text", validator: validators.text }, // recognizes ASIN, ISBN, MPN, UPC, SKU; suggests including product prand and at least one of the identifiers
+ { name: "itemoffered", required: false, type: "complex", validator: validators.complex } // can contain free text, a Product or other item types
+ ]
+ }
];
-
-
+
+
// add the data-vocabulary.org validators to the plugin
for (var i = 0; i < dataVocabulary.length; i++) {
$.microdata.addDefinition(dataVocabulary[i].url, dataVocabulary[i].fields);
}
-
+
// This section pertains to the schema.org definitions
-
+
var schemaOrg = [
- {
- url: "http://schema.org/Thing",
+ {
+ url: "http://schema.org/Thing",
fields: [
- { name: "description", required: false, type: "text", validator: validators.text },
- { name: "image", required: false, type: "url", validator: validators.url },
- { name: "name", required: false, type: "text", validator: validators.text },
- { name: "url", required: false, type: "url", validator: validators.url }
- ]
- }
+ { name: "description", required: false, type: "text", validator: validators.text },
+ { name: "image", required: false, type: "url", validator: validators.url },
+ { name: "name", required: false, type: "text", validator: validators.text },
+ { name: "url", required: false, type: "url", validator: validators.url }
+ ]
+ }
];
schemaOrg.push({
url: "http://schema.org/Event",
@@ -138,7 +138,7 @@
{ name: "startDate", required: false, type: "datetime", validator: validators.datetime },
{ name: "subEvents", required: false, type: "complex", validator: validators.complex }, // child elements of type Event
{ name: "superEvent", required: false, type: "complex", validator: validators.complex } // a child element of type Event
- ])
+ ])
});
schemaOrg.push({
url: "http://schema.org/Organization",
@@ -157,7 +157,7 @@
{ name: "members", required: false, type: "complex", validator: validators.complex }, // child elements of Person or Organization
{ name: "reviews", required: false, type: "complex", validator: validators.complex }, // child elements of Review
{ name: "telephone", required: false, type: "text", validator: validators.text }
- ])
+ ])
});
schemaOrg.push({
url: "http://schema.org/Intangible",
@@ -173,72 +173,72 @@
{ name: "offers", required: false, type: "complex", validator: validators.complex }, // child elements of Offer
{ name: "productId", required: false, type: "text", validator: validators.text },
{ name: "reviews", required: false, type: "complex", validator: validators.complex } // child elements of Review
- ])
+ ])
+ });
+ schemaOrg.push({
+ url: "http://schema.org/CreativeWork",
+ fields: extend(findByUrl(schemaOrg, "http://schema.org/Thing"), [
+ {name: "about", required: false, type: "complex", validator: validators.text },
+ {name: "accountablePerson", required: false, type: "complex", validator: validators.text },
+ {name: "aggregateRating", required: false, type: "complex", validator: validators.text },
+ {name: "alternativeHeadline", required: false, type: "text", validator: validators.text },
+ {name: "associatedMedia", required: false, type: "complex", validator: validators.text },
+ {name: "audience", required: false, type: "complex", validator: validators.text },
+ {name: "audio", required: false, type: "complex", validator: validators.complex },
+ {name: "author", required: false, type: "complex", validator: validators.complex },
+ {name: "award", required: false, type: "text", validator: validators.text },
+ {name: "awards", required: false, type: "text", validator: validators.text },
+ {name: "comment", required: false, type: "complex", validator: validators.complex },
+ {name: "contentLocation", required: false, type: "complex", validator: validators.complex },
+ {name: "contentRating", required: false, type: "text", validator: validators.text },
+ {name: "contributor", required: false, type: "complex", validator: validators.complex },
+ {name: "copyrightHolder", required: false, type: "complex", validator: validators.complex },
+ {name: "copyrightYear", required: false, type: "number", validator: validators.number },
+ {name: "creator", required: false, type: "complex", validator: validators.complex },
+ {name: "dateCreated", required: false, type: "datetime", validator: validators.datetime },
+ {name: "dateModified", required: false, type: "datetime", validator: validators.datetime },
+ {name: "datePublished", required: false, type: "datetime", validator: validators.datetime },
+ {name: "discussionUrl", required: false, type: "url", validator: validators.url },
+ {name: "editor", required: false, type: "complex", validator: validators.complex },
+ {name: "educationalAlignment", required: false, type: "complex", validator: validators.complex },
+ {name: "educationalUse", required: false, type: "text", validator: validators.text },
+ {name: "encoding", required: false, type: "complex", validator: validators.complex },
+ {name: "encodings", required: false, type: "complex", validator: validators.complex },
+ {name: "genre", required: false, type: "text", validator: validators.text },
+ {name: "headline", required: false, type: "text", validator: validators.text },
+ {name: "inLanguage", required: false, type: "text", validator: validators.text },
+ {name: "interactionCount", required: false, type: "text", validator: validators.text },
+ {name: "interactivityType", required: false, type: "text", validator: validators.text },
+ {name: "isBasedOnUrl", required: false, type: "url", validator: validators.url },
+ {name: "isFamilyFriendly", required: false, type: "boolean", validator: validators.boolean },
+ {name: "keywords", required: false, type: "text", validator: validators.text },
+ {name: "learningResourceType", required: false, type: "text", validator: validators.text },
+ {name: "mentions", required: false, type: "complex", validator: validators.complex },
+ {name: "offers", required: false, type: "complex", validator: validators.complex },
+ {name: "provider", required: false, type: "complex", validator: validators.complex },
+ {name: "publisher", required: false, type: "complex", validator: validators.complex },
+ {name: "publishingPrinciples", required: false, type: "url", validator: validators.url },
+ {name: "review", required: false, type: "complex", validator: validators.complex },
+ {name: "reviews", required: false, type: "complex", validator: validators.complex },
+ {name: "sourceOrganization", required: false, type: "complex", validator: validators.complex },
+ {name: "text", required: false, type: "text", validator: validators.text },
+ {name: "thumbnailUrl", required: false, type: "url", validator: validators.url },
+ {name: "timeRequired", required: false, type: "duration", validator: validators.duration },
+ {name: "typicalAgeRange", required: false, type: "text", validator: validators.text },
+ {name: "version", required: false, type: "number", validator: validators.number },
+ {name: "video" , required: false, type: "complex", validator: validators.complex }
+ ])
+ });
+ schemaOrg.push({
+ url: "http://schema.org/Book",
+ fields: extend(findByUrl(schemaOrg, "http://schema.org/CreativeWork"), [
+ { name: "bookEdition", required: false, type: "text", validator: validators.text },
+ { name: "bookFormat", required: false, type: "complex", validator: validators.complex },
+ { name: "illustrator", required: false, type: "complex", validator: validators.complex },
+ { name: "isbn", required: false, type: "text", validator: validators.text },
+ { name: "numberOfPages", required: false, type: "int", validator: validators.int }
+ ])
});
- schemaOrg.push({
- url: "http://schema.org/CreativeWork",
- fields: extend(findByUrl(schemaOrg, "http://schema.org/Thing"), [
- {name: "about", required: false, type: "complex", validator: validators.text },
- {name: "accountablePerson", required: false, type: "complex", validator: validators.text },
- {name: "aggregateRating", required: false, type: "complex", validator: validators.text },
- {name: "alternativeHeadline", required: false, type: "text", validator: validators.text },
- {name: "associatedMedia", required: false, type: "complex", validator: validators.text },
- {name: "audience", required: false, type: "complex", validator: validators.text },
- {name: "audio", required: false, type: "complex", validator: validators.complex },
- {name: "author", required: false, type: "complex", validator: validators.complex },
- {name: "award", required: false, type: "text", validator: validators.text },
- {name: "awards", required: false, type: "text", validator: validators.text },
- {name: "comment", required: false, type: "complex", validator: validators.complex },
- {name: "contentLocation", required: false, type: "complex", validator: validators.complex },
- {name: "contentRating", required: false, type: "text", validator: validators.text },
- {name: "contributor", required: false, type: "complex", validator: validators.complex },
- {name: "copyrightHolder", required: false, type: "complex", validator: validators.complex },
- {name: "copyrightYear", required: false, type: "number", validator: validators.number },
- {name: "creator", required: false, type: "complex", validator: validators.complex },
- {name: "dateCreated", required: false, type: "datetime", validator: validators.datetime },
- {name: "dateModified", required: false, type: "datetime", validator: validators.datetime },
- {name: "datePublished", required: false, type: "datetime", validator: validators.datetime },
- {name: "discussionUrl", required: false, type: "url", validator: validators.url },
- {name: "editor", required: false, type: "complex", validator: validators.complex },
- {name: "educationalAlignment", required: false, type: "complex", validator: validators.complex },
- {name: "educationalUse", required: false, type: "text", validator: validators.text },
- {name: "encoding", required: false, type: "complex", validator: validators.complex },
- {name: "encodings", required: false, type: "complex", validator: validators.complex },
- {name: "genre", required: false, type: "text", validator: validators.text },
- {name: "headline", required: false, type: "text", validator: validators.text },
- {name: "inLanguage", required: false, type: "text", validator: validators.text },
- {name: "interactionCount", required: false, type: "text", validator: validators.text },
- {name: "interactivityType", required: false, type: "text", validator: validators.text },
- {name: "isBasedOnUrl", required: false, type: "url", validator: validators.url },
- {name: "isFamilyFriendly", required: false, type: "boolean", validator: validators.boolean },
- {name: "keywords", required: false, type: "text", validator: validators.text },
- {name: "learningResourceType", required: false, type: "text", validator: validators.text },
- {name: "mentions", required: false, type: "complex", validator: validators.complex },
- {name: "offers", required: false, type: "complex", validator: validators.complex },
- {name: "provider", required: false, type: "complex", validator: validators.complex },
- {name: "publisher", required: false, type: "complex", validator: validators.complex },
- {name: "publishingPrinciples", required: false, type: "url", validator: validators.url },
- {name: "review", required: false, type: "complex", validator: validators.complex },
- {name: "reviews", required: false, type: "complex", validator: validators.complex },
- {name: "sourceOrganization", required: false, type: "complex", validator: validators.complex },
- {name: "text", required: false, type: "text", validator: validators.text },
- {name: "thumbnailUrl", required: false, type: "url", validator: validators.url },
- {name: "timeRequired", required: false, type: "duration", validator: validators.duration },
- {name: "typicalAgeRange", required: false, type: "text", validator: validators.text },
- {name: "version", required: false, type: "number", validator: validators.number },
- {name: "video" , required: false, type: "complex", validator: validators.complex }
- ])
- });
- schemaOrg.push({
- url: "http://schema.org/Book",
- fields: extend(findByUrl(schemaOrg, "http://schema.org/CreativeWork"), [
- { name: "bookEdition", required: false, type: "text", validator: validators.text },
- { name: "bookFormat", required: false, type: "complex", validator: validators.complex },
- { name: "illustrator", required: false, type: "complex", validator: validators.complex },
- { name: "isbn", required: false, type: "text", validator: validators.text },
- { name: "numberOfPages", required: false, type: "int", validator: validators.int }
- ])
- });
schemaOrg.push({
url: "http://schema.org/Person",
fields: extend(findByUrl(schemaOrg, "http://schema.org/Thing"), [
@@ -274,7 +274,7 @@
{ name: "telephone", required: false, type: "text", validator: validators.text },
{ name: "workLocation", required: false, type: "complex", validator: validators.complex }, // a child element of Location or ContactPoint
{ name: "worksFor", required: false, type: "complex", validator: validators.complex } // a child element of Organization
- ])
+ ])
});
schemaOrg.push({
@@ -289,7 +289,7 @@
{ name: "priceValidUntil", required: false, type: "text", validator: validators.text },
{ name: "reviews", required: false, type: "complex", validator: validators.complex }, // Review schema child element
{ name: "seller", required: false, type: "complex", validator: validators.complex } // Organization schema child element
- ])
+ ])
});
schemaOrg.push({
url: "http://schema.org/AggregateOffer",
@@ -297,9 +297,9 @@
{ name: "highPrice", required: false, type: "text", validator: validators.text },
{ name: "lowPrice", required: false, type: "text", validator: validators.text },
{ name: "offerCount", required: false, type: "text", validator: validators.text }
- ])
+ ])
});
-
+
// add schema.org to the roster
for (var i = 0; i < schemaOrg.length; i++) {
$.microdata.addDefinition(schemaOrg[i].url, schemaOrg[i].fields);
Please sign in to comment.
Something went wrong with that request. Please try again.