-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample-browser.html
42 lines (40 loc) · 1.83 KB
/
example-browser.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SDO Adapter Test</title>
</head>
<body>
<div style="padding: 100px; background-color: #8e908c; font-size: 18px; ">
<pre id="output">
This Div should render the test data generated by the Library soon
</pre>
</div>
</body>
<!--<script src="../../dist/schema-org-adapter.min.js"></script>-->
<script src="../../dist/schema-org-adapter.js"></script>
<!--You can also use a CDN!-->
<!--<script src="https://cdn.jsdelivr.net/gh/semantifyit/schema-org-adapter/dist/schema-org-adapter.min.js"></script>-->
<script>
(async function() {
SOA.fetchSchemaVersions().then((res) => console.log(res));
let mySdoAdapter = await SOA.create({ schemaHttps: true, equateVocabularyProtocols: true });
console.log(await mySdoAdapter.constructURLSchemaVocabulary("latest"));
let externalVocabURL = "https://raw.githubusercontent.com/semantifyit/schema-org-adapter/master/tests/resources/data/vocabularies/vocabulary-animal.json";
mySdoAdapter.constructURLSchemaVocabulary("10.0").then(function(sdoURL) {
mySdoAdapter.addVocabularies([sdoURL, externalVocabURL]).then(function() {
let testClass = mySdoAdapter.getClass("Hotel");
console.log(mySdoAdapter.getVocabularies());
console.log(testClass.getName());
console.log(testClass.getDescription("en"));
console.log(testClass.toJSON({ implicit: true }));
let testClassExternal = mySdoAdapter.getClass("Tiger");
console.log(testClassExternal.toJSON({ implicit: false }));
let testProperty = mySdoAdapter.getProperty("accountablePerson");
console.log(testProperty.getRanges({outputFormat:"Absolute"}));
document.getElementById("output").innerHTML = JSON.stringify(testClass.toJSON({ implicit: true }), null, 2);
});
});
})();
</script>
</html>