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