blob: d7548b2ddb03dc4c6eaeb258de1e364776f5ec30 [file] [log] [blame]
hebasta393829f2020-03-09 12:37:29 +01001/**
2 * Export Demo
3 *
hebasta40a85cf2020-07-15 18:10:08 +02004 * @author Helge
hebasta393829f2020-03-09 12:37:29 +01005 *
6 */
7
8requirejs.config({
9 baseUrl: '../js/src',
10 paths : {
11 'lib': '../lib'
12 }
13});
14
hebasta40a85cf2020-07-15 18:10:08 +020015require([ 'plugin/server', 'panel/result', 'init' ], function(pluginClass, resultPanelClass) {
hebasta393829f2020-03-09 12:37:29 +010016
17 KorAP.Plugin = pluginClass.create();
18
19 // Add services container to head
20 document.head.appendChild(KorAP.Plugin.element());
hebasta393829f2020-03-09 12:37:29 +010021
hebasta40a85cf2020-07-15 18:10:08 +020022 // Register result plugin
23 KorAP.Plugin.register({
24 'name' : 'Export',
25 'desc' : 'Exports Kalamar results',
26 // 'about' : 'https://localhost:5678/',
27 'embed' : [ {
28 'panel' : 'result',
29 'title' : 'exports KWICs and snippets',
30 //Unicode-Code of the plugins button-icon, Font: Font Awesome
31 'icon' : "\uf019",
32 'classes' : [ 'button-icon', 'plugin' ],
33 'onClick' : {
34 'action' : 'addWidget',
35 'template' : 'http://localhost:7777/res/export.html'
36 }
37 } ]
38 });
39
40 //Add result panel
41 var show = {};
42 var resultPanel = resultPanelClass.create(show);
43
44 var resultInfo = document.getElementById('resultinfo');
45 if (resultInfo != null) {
46 // Move buttons to resultinfo
hebasta393829f2020-03-09 12:37:29 +010047 resultInfo.appendChild(resultPanel.actions.element());
48 // The views are at the top of the search results
49 var sb = document.getElementById('search');
50 sb.insertBefore(resultPanel.element(), sb.firstChild);
hebasta40a85cf2020-07-15 18:10:08 +020051 };
52
53 // There is a koralQuery
54 if (KorAP.koralQuery !== undefined) {
hebasta393829f2020-03-09 12:37:29 +010055
56 if (KorAP.koralQuery["errors"]) {
57 var errors = KorAP.koralQuery["errors"];
hebasta40a85cf2020-07-15 18:10:08 +020058 for ( var i in errors) {
hebasta393829f2020-03-09 12:37:29 +010059
60 // Malformed query
61 if (errors[i][0] === 302 && errors[i][2]) {
62 obj.hint = hintClass.create();
63 obj.hint.alert(errors[i][2], errors[i][1]);
64 break;
65 }
66
67 // no query
68 else if (errors[i][0] === 301) {
69 obj.hint = hintClass.create();
hebasta40a85cf2020-07-15 18:10:08 +020070 obj.hint.alert(0, errors[i][1]);
hebasta393829f2020-03-09 12:37:29 +010071 }
hebasta40a85cf2020-07-15 18:10:08 +020072 }
73 };
74 };
hebasta393829f2020-03-09 12:37:29 +010075});