Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | requirejs.config({ |
| 2 | baseUrl: '../js/src', |
| 3 | paths : { |
| 4 | 'lib': '../lib' |
| 5 | } |
| 6 | }); |
| 7 | |
| 8 | var json = { |
| 9 | "@type":"koral:docGroup", |
| 10 | "operation":"operation:or", |
| 11 | "operands":[ |
| 12 | { |
| 13 | "@type":"koral:docGroup", |
| 14 | "operation":"operation:and", |
| 15 | "operands":[ |
| 16 | { |
| 17 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 18 | "key":"title", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 19 | "value":"Der Birnbaum", |
| 20 | "match":"match:eq" |
| 21 | }, |
| 22 | { |
| 23 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 24 | "key":"pubPlace", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 25 | "value":"Mannheim", |
| 26 | "match":"match:eq" |
| 27 | }, |
| 28 | { |
| 29 | "@type":"koral:docGroup", |
| 30 | "operation":"operation:or", |
| 31 | "operands":[ |
| 32 | { |
| 33 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 34 | "key":"subTitle", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 35 | "value":"Aufzucht und Pflege", |
| 36 | "match":"match:eq" |
| 37 | }, |
| 38 | { |
| 39 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 40 | "key":"subTitle", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 41 | "value":"Gedichte", |
| 42 | "match":"match:eq", |
| 43 | "rewrites" : [ |
| 44 | { |
| 45 | "@type": "koral:rewrite", |
| 46 | "src" : "policy", |
| 47 | "operation" : "operation:injection", |
| 48 | } |
| 49 | ] |
| 50 | } |
| 51 | ] |
| 52 | } |
| 53 | ] |
| 54 | }, |
| 55 | { |
| 56 | "@type":"koral:doc", |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 57 | "key":"pubDate", |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 58 | "type":"type:date", |
| 59 | "value":"2015-03-05", |
| 60 | "match":"match:geq" |
| 61 | } |
| 62 | ] |
| 63 | }; |
| 64 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 65 | require(['vc','lib/domReady'], function (vcClass, domReady) { |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 66 | |
| 67 | var loc = KorAP.Locale; |
| 68 | |
| 69 | loc.AND = 'und'; |
| 70 | loc.OR = 'oder'; |
| 71 | loc.VC_subTitle = 'Untertitel'; |
| 72 | loc.VC_title = 'Titel'; |
| 73 | loc.VC_pubDate = 'Veröffentlichungsdatum'; |
| 74 | loc.VC_pubPlace = 'Veröffentlichungsort'; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 75 | |
| 76 | domReady(function() { |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 77 | |
| 78 | // Create a new virtual collection by passing a based json object and |
| 79 | // field menu information |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 80 | var vc = vcClass.create([ |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 81 | ['title', 'string'], |
| 82 | ['subTitle', 'string'], |
| 83 | ['pubDate', 'date'], |
| 84 | ['author', 'string'] |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 85 | ]).fromJson(json); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 86 | document.getElementById('vc').appendChild(vc.element()); |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 87 | |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 88 | // show the current JSON serialization |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 89 | KorAP.showJSON = function () { |
| 90 | document.getElementById("json").innerHTML = JSON.stringify(vc.root().toJson()); |
| 91 | }; |
| 92 | |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 93 | // show the current query serialization |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 94 | KorAP.showQuery = function () { |
| 95 | document.getElementById("query").innerHTML = vc.root().toQuery(); |
| 96 | }; |
| 97 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 98 | }); |
| 99 | }); |