Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Virtual Collection demo</title> |
| 5 | <meta charset="utf-8" /> |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 6 | <script src="../js/src/menu.js"></script> |
| 7 | <script src="../js/src/vc.js"></script> |
| 8 | <link type="text/css" rel="stylesheet" href="../css/kalamar.css" /> |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 9 | <style type="text/css" rel="stylesheet"> |
| 10 | |
| 11 | body { |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 12 | background-color: #9bad0b; |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 13 | color: white; |
| 14 | font-family: tahoma, verdana, arial; |
| 15 | font-size: 10pt; |
| 16 | margin: 20px; |
| 17 | } |
| 18 | |
| 19 | .info { |
| 20 | background-color:white; |
| 21 | color: black; |
| 22 | padding: 1em; |
| 23 | font-family: mono; |
| 24 | } |
| 25 | </style> |
| 26 | </head> |
| 27 | <body> |
| 28 | <div id="vc"></div> |
| 29 | <div id="menu" class="vc"></div> |
| 30 | |
| 31 | <script> |
| 32 | var json = { |
| 33 | "@type":"koral:docGroup", |
| 34 | "operation":"operation:or", |
| 35 | "operands":[ |
| 36 | { |
| 37 | "@type":"koral:docGroup", |
| 38 | "operation":"operation:and", |
| 39 | "operands":[ |
| 40 | { |
| 41 | "@type":"koral:doc", |
| 42 | "key":"Titel", |
| 43 | "value":"Der Birnbaum", |
| 44 | "match":"match:eq" |
| 45 | }, |
| 46 | { |
| 47 | "@type":"koral:doc", |
| 48 | "key":"Veröffentlichungsort", |
| 49 | "value":"Mannheim", |
| 50 | "match":"match:eq" |
| 51 | }, |
| 52 | { |
| 53 | "@type":"koral:docGroup", |
| 54 | "operation":"operation:or", |
| 55 | "operands":[ |
| 56 | { |
| 57 | "@type":"koral:doc", |
| 58 | "key":"Untertitel", |
| 59 | "value":"Aufzucht und Pflege", |
| 60 | "match":"match:eq" |
| 61 | }, |
| 62 | { |
| 63 | "@type":"koral:doc", |
| 64 | "key":"Untertitel", |
| 65 | "value":"Gedichte", |
| 66 | "match":"match:eq", |
| 67 | "rewrites" : [ |
| 68 | { |
| 69 | "@type": "koral:rewrite", |
| 70 | "src" : "policy", |
| 71 | "operation" : "operation:injection", |
| 72 | } |
| 73 | ] |
| 74 | } |
| 75 | ] |
| 76 | } |
| 77 | ] |
| 78 | }, |
| 79 | { |
| 80 | "@type":"koral:doc", |
| 81 | "key":"Veröffentlichungsdatum", |
| 82 | "type":"type:date", |
| 83 | "value":"2015-03-05", |
| 84 | "match":"match:geq" |
| 85 | } |
| 86 | ] |
| 87 | }; |
| 88 | KorAP.Locale.AND = 'und'; |
| 89 | KorAP.Locale.OR = 'oder'; |
| 90 | |
| 91 | var vc = KorAP.VirtualCollection.render(json); |
| 92 | document.getElementById('vc').appendChild(vc.element()); |
| 93 | |
| 94 | function showJSON() { |
| 95 | document.getElementById("json").innerHTML = JSON.stringify(vc.root().toJson()); |
| 96 | }; |
| 97 | |
| 98 | function showQuery() { |
| 99 | document.getElementById("query").innerHTML = vc.root().toQuery(); |
| 100 | }; |
| 101 | |
| 102 | </script> |
| 103 | |
| 104 | <hr /> |
| 105 | |
| 106 | <p><a onclick="showJSON()" style="cursor:pointer">show JSON!</a></p> |
| 107 | <div id="json" class="info"></div> |
| 108 | |
| 109 | <hr /> |
| 110 | |
| 111 | <p><a onclick="showQuery()" style="cursor:pointer">show Query!</a></p> |
| 112 | <div id="query" class="info"></div> |
| 113 | |
| 114 | </body> |
| 115 | </html> |