blob: 04574364f4eb92be4db992998da9c6f4c3829977 [file] [log] [blame]
hebasta393829f2020-03-09 12:37:29 +01001/**
2 * Export Demo
3 *
4 * @author Helge
5 *
6 */
7
8requirejs.config({
9 baseUrl: '../js/src',
10 paths : {
11 'lib': '../lib'
12 }
13});
14
15
16require(['plugin/server', 'panel/result'], function (pluginClass, resultPanelClass){
17
18 KorAP.Plugin = pluginClass.create();
19
20 // Add services container to head
21 document.head.appendChild(KorAP.Plugin.element());
22
23 //Register result plugin
24 KorAP.Plugin.register({
25 'name' : 'Export',
26 'desc' : 'Exports Kalamar results',
27 // 'about' : 'https://localhost:5678/',
28 'embed' : [{
29 'panel' : 'result',
30 'title' : 'Export',
31 'classes' : ['export'],
32 'onClick' : {
33 'action' : 'addWidget',
34 'template' : 'http://localhost:7777/res/export.html'
35 }
36 }]
37 });
38
39 //Add result panel
40 var show = {};
41 var resultPanel = resultPanelClass.create(show);
42
43 var resultInfo = document.getElementById('resultinfo');
44 if (resultInfo != null) {
45 // Move buttons to resultinfo
46 resultInfo.appendChild(resultPanel.actions.element());
47 // The views are at the top of the search results
48 var sb = document.getElementById('search');
49 sb.insertBefore(resultPanel.element(), sb.firstChild);
50 };
51
52 resultPanel.addAlignAction();
53
54 // There is a koralQuery
55 if (KorAP.koralQuery !== undefined) {
56
57 // Add KoralQuery view to result panel
58 if (resultInfo !== null) {
59 resultPanel.addKqAction()
60 };
61
62 if (KorAP.koralQuery["errors"]) {
63 var errors = KorAP.koralQuery["errors"];
64 for (var i in errors) {
65
66 // Malformed query
67 if (errors[i][0] === 302 && errors[i][2]) {
68 obj.hint = hintClass.create();
69 obj.hint.alert(errors[i][2], errors[i][1]);
70 break;
71 }
72
73 // no query
74 else if (errors[i][0] === 301) {
75 obj.hint = hintClass.create();
76 obj.hint.alert(0, errors[i][1]);
77 }
78 }
79 };
80 };
81});