blob: 73cb8053c7409c88543af3d6e6b69392c2effb46 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001requirejs.config({
2 baseUrl: '../js/src',
3 paths : {
4 'lib': '../lib'
5 }
6});
7
8var 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 Diewald4c221252015-04-21 20:19:25 +000018 "key":"title",
Nils Diewald0e6992a2015-04-14 20:13:52 +000019 "value":"Der Birnbaum",
20 "match":"match:eq"
21 },
22 {
23 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000024 "key":"pubPlace",
Nils Diewald0e6992a2015-04-14 20:13:52 +000025 "value":"Mannheim",
26 "match":"match:eq"
27 },
28 {
29 "@type":"koral:docGroup",
30 "operation":"operation:or",
31 "operands":[
32 {
33 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000034 "key":"subTitle",
Nils Diewald0e6992a2015-04-14 20:13:52 +000035 "value":"Aufzucht und Pflege",
36 "match":"match:eq"
37 },
38 {
39 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000040 "key":"subTitle",
Nils Diewald0e6992a2015-04-14 20:13:52 +000041 "value":"Gedichte",
42 "match":"match:eq",
Nils Diewald652e5f42015-05-10 18:11:45 +000043/*
Nils Diewald0e6992a2015-04-14 20:13:52 +000044 "rewrites" : [
45 {
46 "@type": "koral:rewrite",
47 "src" : "policy",
48 "operation" : "operation:injection",
49 }
50 ]
Nils Diewald652e5f42015-05-10 18:11:45 +000051*/
Nils Diewald0e6992a2015-04-14 20:13:52 +000052 }
53 ]
54 }
55 ]
56 },
57 {
58 "@type":"koral:doc",
Nils Diewald4c221252015-04-21 20:19:25 +000059 "key":"pubDate",
Nils Diewald0e6992a2015-04-14 20:13:52 +000060 "type":"type:date",
61 "value":"2015-03-05",
62 "match":"match:geq"
63 }
64 ]
65};
66
Akron48b1e4d2015-06-17 18:47:01 +020067var collections = [
68 {
69 "statistics":{
70 "paragraphs":2034752,
71 "documents":196510,
72 "tokens":51545081,
73 "sentences":4116282
74 },
75 "query":[
76 {
77 "@value":{
78 "@field":"korap:field#corpusID",
79 "@value":"WPD",
80 "@type":"korap:term"
81 },
82 "@type":"korap:meta-filter"
83 }
84 ],
85 "name":"Wikipedia",
86 "path":"Wikipedia",
87 "description":"Die freie Enzyklopädie",
88 "shared":false,
89 "managed":true,
90 "created":"2015-04-01T23:04:32.000+02:00",
91 "foundries":"",
92 "id":"ZGU0ZTllNTFkYzc3M2VhZmViYzdkYWE2ODI5NDc3NTk4NGQ1YThhOTMwOTNhOWYxNWMwN2M3Y2YyZmE3N2RlNQ=="
93 }
94];
95
Nils Diewald652e5f42015-05-10 18:11:45 +000096require(['vc','lib/domReady', 'lib/highlight/highlight.pack'], function (vcClass, domReady) {
Nils Diewald4c221252015-04-21 20:19:25 +000097
98 var loc = KorAP.Locale;
99
Nils Diewald652e5f42015-05-10 18:11:45 +0000100/*
Nils Diewald4c221252015-04-21 20:19:25 +0000101 loc.AND = 'und';
102 loc.OR = 'oder';
103 loc.VC_subTitle = 'Untertitel';
104 loc.VC_title = 'Titel';
105 loc.VC_pubDate = 'Veröffentlichungsdatum';
106 loc.VC_pubPlace = 'Veröffentlichungsort';
Nils Diewald652e5f42015-05-10 18:11:45 +0000107*/
Nils Diewald0e6992a2015-04-14 20:13:52 +0000108
109 domReady(function() {
Nils Diewald4c221252015-04-21 20:19:25 +0000110
111 // Create a new virtual collection by passing a based json object and
112 // field menu information
Nils Diewald6283d692015-04-23 20:32:53 +0000113 var vc = vcClass.create([
Nils Diewald4c221252015-04-21 20:19:25 +0000114 ['title', 'string'],
115 ['subTitle', 'string'],
116 ['pubDate', 'date'],
117 ['author', 'string']
Nils Diewald6283d692015-04-23 20:32:53 +0000118 ]).fromJson(json);
Nils Diewald87507832015-05-01 23:36:41 +0000119
Nils Diewald0e6992a2015-04-14 20:13:52 +0000120 document.getElementById('vc').appendChild(vc.element());
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000121
Nils Diewald4c221252015-04-21 20:19:25 +0000122 // show the current JSON serialization
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000123 KorAP.showJSON = function () {
Nils Diewald652e5f42015-05-10 18:11:45 +0000124 var json = document.getElementById("json");
125 json.innerHTML = JSON.stringify(vc.root().toJson(), null, ' ');
126 hljs.highlightBlock(json);
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000127 };
128
Nils Diewald4c221252015-04-21 20:19:25 +0000129 // show the current query serialization
Nils Diewald1fcb2ad2015-04-20 19:19:18 +0000130 KorAP.showQuery = function () {
131 document.getElementById("query").innerHTML = vc.root().toQuery();
132 };
Nils Diewald845282c2015-05-14 07:53:03 +0000133
134 // make the current vc persistant
135 KorAP.makeVCPersistant = function () {
136 vc.makePersistant();
137 };
Nils Diewald0e6992a2015-04-14 20:13:52 +0000138 });
139});