blob: 53ab75e59bd794371ff8ada1b73a5144e3805cd7 [file] [log] [blame]
requirejs.config({
baseUrl: '../js/src',
paths : {
'lib': '../lib'
}
});
var json = {
"@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
"@type":"koral:docGroup",
"operation":"operation:and",
"operands":[
{
"@type":"koral:doc",
"key":"title",
"value":"Der Birnbaum",
"match":"match:eq"
},
{
"@type":"koral:doc",
"key":"pubPlace",
"value":"Mannheim",
"match":"match:eq"
},
{
"@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
"@type":"koral:doc",
"key":"subTitle",
"value":"Aufzucht und Pflege",
"match":"match:eq"
},
{
"@type":"koral:doc",
"key":"subTitle",
"value":"Gedichte",
"match":"match:eq",
/*
"rewrites" : [
{
"@type": "koral:rewrite",
"src" : "policy",
"operation" : "operation:injection",
}
]
*/
}
]
}
]
},
{
"@type":"koral:doc",
"key":"pubDate",
"type":"type:date",
"value":"2015-03-05",
"match":"match:geq"
}
]
};
require(['vc','lib/domReady', 'lib/highlight/highlight.pack'], function (vcClass, domReady) {
var loc = KorAP.Locale;
/*
loc.AND = 'und';
loc.OR = 'oder';
loc.VC_subTitle = 'Untertitel';
loc.VC_title = 'Titel';
loc.VC_pubDate = 'Veröffentlichungsdatum';
loc.VC_pubPlace = 'Veröffentlichungsort';
*/
domReady(function() {
// Create a new virtual collection by passing a based json object and
// field menu information
var vc = vcClass.create([
['title', 'string'],
['subTitle', 'string'],
['pubDate', 'date'],
['author', 'string']
]).fromJson(json);
document.getElementById('vc').appendChild(vc.element());
// show the current JSON serialization
KorAP.showJSON = function () {
var json = document.getElementById("json");
json.innerHTML = JSON.stringify(vc.root().toJson(), null, ' ');
hljs.highlightBlock(json);
};
// show the current query serialization
KorAP.showQuery = function () {
document.getElementById("query").innerHTML = vc.root().toQuery();
};
// make the current vc persistant
KorAP.makeVCPersistant = function () {
vc.makePersistant();
};
});
});