Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 1 | /* |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 2 | * Initialize The JS frontend part and decorate |
| 3 | * the static HTML data. |
| 4 | * |
Akron | 2224dcf | 2024-11-19 13:28:44 +0100 | [diff] [blame] | 5 | * @author Nils Diewald, Helge Stallkamp, Uyen-Nhu Tran |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 6 | * |
Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 7 | * TODO: Create lazy loading of objects including |
| 8 | * - obj.hint() |
| 9 | * - obj.alertify() |
| 10 | * - obj.session() |
| 11 | * - obj.tutorial() |
| 12 | * - obj.vc() // toggle |
| 13 | * - obj.matchCreate() (using webpack) |
| 14 | * - obj.koral() (show result, parse for errors ...) |
| 15 | * - obj.alignment() // toggle |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 16 | * |
| 17 | * TODO: After upgrading to ES 6 |
| 18 | * - use optional chaining operator (for example see below) |
Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 19 | */ |
| 20 | |
Akron | e51eaa3 | 2020-11-10 09:35:53 +0100 | [diff] [blame] | 21 | "use strict"; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 22 | define([ |
| 23 | 'match', |
| 24 | 'hint', |
| 25 | 'vc', |
| 26 | 'tutorial', |
| 27 | 'lib/domReady', |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 28 | 'vc/array', |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 29 | 'lib/alertify', |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 30 | 'session', |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 31 | 'state/manager', |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 32 | 'selectMenu', |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 33 | 'panel/result', |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 34 | 'panel/query', |
Akron | 644ad9f | 2021-07-26 16:12:59 +0200 | [diff] [blame] | 35 | 'panel/pagination', |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 36 | 'tour/tours', |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 37 | 'plugin/server', |
| 38 | 'pipe', |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 39 | 'api', |
Nils Diewald | c46003b | 2015-05-07 15:55:35 +0000 | [diff] [blame] | 40 | 'mailToChiffre', |
Akron | 858cbc8 | 2019-12-05 16:53:13 +0100 | [diff] [blame] | 41 | 'util', |
| 42 | 'state' |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 43 | ], function (matchClass, |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 44 | hintClass, |
| 45 | vcClass, |
| 46 | tutClass, |
| 47 | domReady, |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 48 | vcArray, |
| 49 | alertifyClass, |
| 50 | sessionClass, |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 51 | stateManagerClass, |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 52 | selectMenuClass, |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 53 | resultPanelClass, |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 54 | queryPanelClass, |
Akron | 644ad9f | 2021-07-26 16:12:59 +0200 | [diff] [blame] | 55 | paginationPanelClass, |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 56 | tourClass, |
| 57 | pluginClass, |
| 58 | pipeClass) { |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 59 | |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 60 | // Override KorAP.log |
| 61 | window.alertify = alertifyClass; |
Akron | e71bd6d | 2024-06-11 15:47:39 +0200 | [diff] [blame] | 62 | KorAP.log = function (code, msg, src, type) { |
Akron | c0a2da8 | 2018-07-04 15:27:37 +0200 | [diff] [blame] | 63 | |
| 64 | if (src) { |
| 65 | msg += '<code class="src">'+src+'</code>'; |
| 66 | }; |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 67 | |
| 68 | // Use alertify to log errors |
| 69 | alertifyClass.log( |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 70 | (code === 0 ? '' : code + ': ') + |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 71 | msg, |
Akron | e71bd6d | 2024-06-11 15:47:39 +0200 | [diff] [blame] | 72 | (type ? type : 'error'), |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 73 | 10000 |
Nils Diewald | a0defc4 | 2015-05-07 23:54:17 +0000 | [diff] [blame] | 74 | ); |
| 75 | }; |
| 76 | |
hebasta | 2758b58 | 2018-11-19 15:59:42 +0100 | [diff] [blame] | 77 | KorAP.vc = vcClass.create(vcArray); |
Akron | 690066c | 2021-01-22 17:39:18 +0100 | [diff] [blame] | 78 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 79 | domReady(function (event) { |
Akron | 006ddc6 | 2024-02-19 08:49:43 +0100 | [diff] [blame] | 80 | |
| 81 | const d = document; |
| 82 | |
| 83 | // Set base URL |
| 84 | KorAP.URL = d.body.getAttribute('data-korap-url') || ""; |
| 85 | |
| 86 | // Create suffix if KorAP is run in a subfolder |
| 87 | KorAP.session = sessionClass.create( |
| 88 | KorAP.URL.length > 0 ? 'kalamarJS-' + KorAP.URL.slugify() : 'kalamarJS' |
| 89 | ); |
| 90 | |
| 91 | // Get koralQuery response |
| 92 | const kqe = d.getElementById('koralQuery'); |
| 93 | if (kqe !== null) { |
| 94 | KorAP.koralQuery = JSON.parse(kqe.getAttribute('data-koralquery') || ""); |
| 95 | }; |
| 96 | |
Helge | 0d3630c | 2024-10-16 17:19:40 +0200 | [diff] [blame] | 97 | let gt = document.getElementsByClassName('link-guided-tour'); |
| 98 | if (gt.length != null){ |
| 99 | for(let j = 0; j < gt.length; j++){ |
| 100 | gt[j].setAttribute('href', '#'); |
| 101 | gt[j].addEventListener('click', function(){ |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 102 | tourClass.gTstartSearch().start(); |
Helge | 0d3630c | 2024-10-16 17:19:40 +0200 | [diff] [blame] | 103 | |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 104 | // Close the burger menu by simulating a click on the burger icon |
| 105 | const burgerIcon = document.querySelector('.burger-icon'); |
| 106 | if (isBurgerMenuOpen) { |
| 107 | burgerIcon.click(); |
| 108 | } |
| 109 | }); |
| 110 | } |
| 111 | |
| 112 | KorAP.tourshowR = function(){ |
| 113 | tourClass.gTshowResults().start(); |
Akron | 006ddc6 | 2024-02-19 08:49:43 +0100 | [diff] [blame] | 114 | }; |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 115 | } |
Akron | 006ddc6 | 2024-02-19 08:49:43 +0100 | [diff] [blame] | 116 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 117 | var obj = {}; |
Akron | 71b91e4 | 2016-06-01 22:12:43 +0200 | [diff] [blame] | 118 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 119 | // What should be visible in the beginning? |
Akron | f803559 | 2018-05-24 20:40:51 +0200 | [diff] [blame] | 120 | var show = KorAP.session.get('show') || {}; |
hebasta | 043e96f | 2019-11-28 12:33:00 +0100 | [diff] [blame] | 121 | |
| 122 | KorAP.Panel = KorAP.Panel || {} |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 123 | |
| 124 | /** |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 125 | * Release notifications |
| 126 | */ |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 127 | d.querySelectorAll('#notifications div.notify').forEach( |
| 128 | function(e) { |
| 129 | let msg = e.textContent; |
| 130 | |
| 131 | let src = e.getAttribute('data-src'); |
| 132 | if (src) { |
| 133 | msg += '<code class="src">'+src+'</code>'; |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 134 | }; |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 135 | |
| 136 | let type = e.getAttribute('data-type') || "error"; |
| 137 | alertifyClass.log(msg, type, 10000); |
| 138 | } |
| 139 | ); |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 140 | |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 141 | // Responsive navbar: hide and show burger menu |
| 142 | const burgerIcon = document.querySelector('.burger-icon'); |
| 143 | let isBurgerMenuOpen = false; |
| 144 | |
| 145 | if (burgerIcon) { |
| 146 | burgerIcon.addEventListener('click', function() { |
| 147 | const navbar = document.querySelector('.navbar'); |
| 148 | navbar.classList.toggle('show'); |
| 149 | |
| 150 | isBurgerMenuOpen = !isBurgerMenuOpen; |
| 151 | if (isBurgerMenuOpen) { |
| 152 | navbar.style.top = '0'; |
| 153 | } |
| 154 | }); |
| 155 | } |
| 156 | |
| 157 | // Fallback solution for login dropdown visibility (if :focus-within is not supported) |
| 158 | document.addEventListener('DOMContentLoaded', function() { |
| 159 | const dropdown = document.querySelector('.dropdown'); |
| 160 | const dropdownContent = document.querySelector('.dropdown-content'); |
| 161 | |
| 162 | dropdown.addEventListener('mouseenter', function() { |
| 163 | dropdownContent.style.display = 'block'; |
| 164 | }); |
| 165 | |
| 166 | dropdown.addEventListener('mouseleave', function() { |
| 167 | // If no input inside the form is focused, then close dropdown content |
| 168 | if (!dropdown.contains(document.activeElement)) { |
| 169 | dropdownContent.style.display = 'none'; |
| 170 | } |
| 171 | }); |
| 172 | |
| 173 | dropdownContent.addEventListener('focusin', function() { |
| 174 | dropdownContent.style.display = 'block'; |
| 175 | }); |
| 176 | |
| 177 | dropdownContent.addEventListener('focusout', function(e) { |
| 178 | // If focus moved outside the dropdown content, then close it |
| 179 | if (!dropdownContent.contains(e.relatedTarget)) { |
| 180 | dropdownContent.style.display = 'none'; |
| 181 | } |
| 182 | }); |
| 183 | }); |
| 184 | |
Akron | f55504a | 2015-06-18 16:42:55 +0200 | [diff] [blame] | 185 | /** |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 186 | * Replace Virtual Corpus field |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 187 | */ |
Akron | 5c829e9 | 2017-05-12 18:10:00 +0200 | [diff] [blame] | 188 | var vcname, vcchoose; |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 189 | var input = d.getElementById('cq'); |
Akron | 1f0521b | 2018-08-28 13:01:24 +0200 | [diff] [blame] | 190 | |
hebasta | 2758b58 | 2018-11-19 15:59:42 +0100 | [diff] [blame] | 191 | var vc = KorAP.vc; |
hebasta | 48842cf | 2018-12-11 12:57:38 +0100 | [diff] [blame] | 192 | |
Akron | 1f0521b | 2018-08-28 13:01:24 +0200 | [diff] [blame] | 193 | // Add vc name object |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 194 | if (input) { |
| 195 | input.style.display = 'none'; |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 196 | vcname = d.createElement('span'); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 197 | vcname.setAttribute('id', 'vc-choose'); |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 198 | vcname.classList.add('select'); |
Akron | 941551e | 2015-06-11 16:06:22 +0200 | [diff] [blame] | 199 | |
Akron | 1f0521b | 2018-08-28 13:01:24 +0200 | [diff] [blame] | 200 | // Load virtual corpus object |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 201 | // Supports "collection" for legacy reasons |
| 202 | if (KorAP.koralQuery !== undefined && (KorAP.koralQuery["collection"] || KorAP.koralQuery["corpus"])) { |
Akron | 1f0521b | 2018-08-28 13:01:24 +0200 | [diff] [blame] | 203 | try { |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 204 | vc.fromJson(KorAP.koralQuery["collection"] || KorAP.koralQuery["corpus"]); |
Akron | 1f0521b | 2018-08-28 13:01:24 +0200 | [diff] [blame] | 205 | } |
| 206 | catch (e) { |
| 207 | KorAP.log(0,e); |
| 208 | } |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 209 | }; |
| 210 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 211 | vcchoose = vcname.addE('span'); |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 212 | vcchoose.addT(vc.getName()); |
Akron | 27ae9ec | 2015-06-23 00:43:21 +0200 | [diff] [blame] | 213 | |
Akron | 1f0521b | 2018-08-28 13:01:24 +0200 | [diff] [blame] | 214 | if (vc.wasRewritten()) { |
| 215 | vcchoose.classList.add('rewritten'); |
| 216 | }; |
| 217 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 218 | input.parentNode.insertBefore(vcname, input); |
| 219 | }; |
| 220 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 221 | /** |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 222 | * Add actions to match entries |
| 223 | */ |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 224 | var matchElements = d.querySelectorAll( |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 225 | '#search > ol > li' |
Nils Diewald | 5c5a747 | 2015-04-02 22:13:38 +0000 | [diff] [blame] | 226 | ); |
Akron | 6a535d4 | 2015-08-26 20:16:58 +0200 | [diff] [blame] | 227 | |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 228 | matchElements.forEach(function(e) { |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 229 | |
| 230 | // Define class for active elements |
| 231 | if (e.classList.contains('active')) { |
Akron | d769d70 | 2021-08-16 11:09:08 +0200 | [diff] [blame] | 232 | if (e._match === undefined) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 233 | // lazyLoad |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 234 | matchClass.create(e).init(); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 235 | }; |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | // Define class for inactive elements |
| 239 | else { |
| 240 | e.addEventListener('click', function (e) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 241 | if (this._match !== undefined) |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 242 | this._match.open(); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 243 | else { |
| 244 | // lazyLoad |
| 245 | matchClass.create(this).open(); |
| 246 | }; |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 247 | // This would prevent the sidebar to go back |
| 248 | // e.halt(); |
| 249 | }); |
| 250 | e.addEventListener('keydown', function (e) { |
| 251 | var code = _codeFromEvent(e); |
| 252 | |
| 253 | switch (code) { |
| 254 | case 32: |
| 255 | if (this._match !== undefined) |
| 256 | this._match.toggle(); |
| 257 | else { |
| 258 | // lazyLoad |
| 259 | matchClass.create(this).open(); |
| 260 | }; |
| 261 | e.halt(); |
| 262 | break; |
| 263 | }; |
| 264 | }); |
| 265 | }; |
Akron | d769d70 | 2021-08-16 11:09:08 +0200 | [diff] [blame] | 266 | }); |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 267 | |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 268 | // Function to toggle the shifted class on elements |
| 269 | function shiftContent() { |
| 270 | // Get elements to perform content shift when sidebar is active |
| 271 | const header = document.querySelector('header'); |
| 272 | const main = document.querySelector('main'); |
| 273 | const footer = document.querySelector('footer'); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 274 | const results = document.querySelector('.found'); |
| 275 | const aside = document.querySelector('aside'); |
| 276 | |
| 277 | if (aside && aside.classList.contains('active')) { |
| 278 | header.classList.add('shifted'); |
| 279 | if (!results) { |
| 280 | main.classList.add('shifted'); |
| 281 | } |
| 282 | footer.classList.add('shifted'); |
Akron | 1c18f10 | 2024-11-19 16:31:06 +0100 | [diff] [blame] | 283 | adjustHintPosition(); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 284 | } else { |
| 285 | header.classList.remove('shifted'); |
| 286 | main.classList.remove('shifted'); |
| 287 | footer.classList.remove('shifted'); |
Akron | 1c18f10 | 2024-11-19 16:31:06 +0100 | [diff] [blame] | 288 | adjustHintPosition(); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 289 | } |
| 290 | } |
| 291 | |
Akron | 1c18f10 | 2024-11-19 16:31:06 +0100 | [diff] [blame] | 292 | // Function to adjust the position of the annotation assistant bar (hint), |
| 293 | // when user types into the searchbar and clicks the sidebar (or anywhere |
| 294 | // outside the searchbar) afterwards |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 295 | function adjustHintPosition() { |
Akron | 1c18f10 | 2024-11-19 16:31:06 +0100 | [diff] [blame] | 296 | if (KorAP.Hint != undefined) { |
| 297 | KorAP.Hint.inputField().reposition(); |
| 298 | KorAP.Hint.update(); |
| 299 | }; |
| 300 | }; |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 301 | |
| 302 | // MutationObserver to detect when #hint is injected into the DOM |
| 303 | const observer = new MutationObserver((mutationsList, observer) => { |
| 304 | for (const mutation of mutationsList) { |
| 305 | if (mutation.type === 'childList') { |
| 306 | const hint = document.querySelector('#hint'); |
| 307 | if (hint) { |
| 308 | shiftContent(); |
| 309 | observer.disconnect(); |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | }); |
| 314 | |
| 315 | observer.observe(document.body, { childList: true, subtree: true }); |
| 316 | |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 317 | // Add focus listener to aside |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 318 | var aside = d.getElementsByTagName('aside')[0]; |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 319 | |
| 320 | if (aside && aside.classList.contains('active') == false) { |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 321 | |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 322 | // Horrible lock to deal with sidebar clicks |
| 323 | var asideClicked = false; |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 324 | |
| 325 | shiftContent(); |
| 326 | |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 327 | // Make aside active on focus |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 328 | aside.addEventListener('focus', function (e) { |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 329 | this.classList.add('active'); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 330 | shiftContent(); |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 331 | }); |
| 332 | |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 333 | // Deactivate focus when clicking anywhere else |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 334 | var body = d.getElementsByTagName('body')[0]; |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 335 | if (body !== null) { |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 336 | body.addEventListener('click', function () { |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 337 | if (!asideClicked) { |
| 338 | aside.classList.remove('active'); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 339 | shiftContent(); |
| 340 | } else { |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 341 | asideClicked = false; |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 342 | } |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 343 | }); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 344 | } |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 345 | |
| 346 | /* Stop click event on aside |
| 347 | * (to not trickle down to body) |
| 348 | */ |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 349 | aside.addEventListener('click', function (e) { |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 350 | asideClicked = true; |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 351 | }); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 352 | } |
Akron | b9cdb10 | 2017-04-25 00:52:31 +0200 | [diff] [blame] | 353 | |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 354 | // Replace QL select menus with KorAP menus |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 355 | var qlField = d.getElementById('ql-field'); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 356 | if (qlField !== null) { |
Akron | 086fe5d | 2017-11-13 14:01:45 +0100 | [diff] [blame] | 357 | KorAP.QLmenu = selectMenuClass.create( |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 358 | d.getElementById('ql-field').parentNode |
Marc Kupietz | 9545582 | 2023-09-19 20:14:31 +0200 | [diff] [blame] | 359 | ).limit(10); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 360 | }; |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 361 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 362 | var resultInfo = d.getElementById('resultinfo'); |
| 363 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 364 | /** |
| 365 | * Add result panel |
| 366 | */ |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 367 | var resultPanel = resultPanelClass.create(show); |
Akron | 644ad9f | 2021-07-26 16:12:59 +0200 | [diff] [blame] | 368 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 369 | if (resultInfo != null) { |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 370 | |
| 371 | // Move buttons to resultinfo |
Akron | 37ea119 | 2021-07-28 10:40:14 +0200 | [diff] [blame] | 372 | resultInfo.appendChild(resultPanel.actions().element()); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 373 | |
Akron | e6538cd | 2018-07-16 17:52:33 +0200 | [diff] [blame] | 374 | // The views are at the top of the search results |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 375 | var sb = d.getElementById('search'); |
| 376 | sb.insertBefore(resultPanel.element(), sb.firstChild); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 377 | }; |
| 378 | |
| 379 | |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 380 | // There is a koralQuery |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 381 | if (KorAP.koralQuery !== undefined) { |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 382 | |
| 383 | // Add KoralQuery view to result panel |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 384 | if (resultInfo !== null) { |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 385 | resultPanel.addKqAction() |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 386 | }; |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 387 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 388 | if (KorAP.koralQuery["errors"]) { |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 389 | KorAP.koralQuery["errors"].forEach(function(e) { |
Akron | f0c31ed | 2016-06-11 11:27:01 +0200 | [diff] [blame] | 390 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 391 | // Malformed query |
Akron | 4a24b72 | 2020-10-13 12:44:25 +0200 | [diff] [blame] | 392 | if (e[0] === 302 && e[2] !== undefined) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 393 | obj.hint = hintClass.create(); |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 394 | obj.hint.alert(e[2], e[1]); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 395 | } |
Akron | f0c31ed | 2016-06-11 11:27:01 +0200 | [diff] [blame] | 396 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 397 | // no query |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 398 | else if (e[0] === 301) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 399 | obj.hint = hintClass.create(); |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 400 | obj.hint.alert(0, e[1]); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 401 | } |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 402 | }); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 403 | }; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 404 | }; |
| 405 | |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 406 | |
| 407 | /* |
| 408 | * There is more than 0 matches, so allow for |
| 409 | * alignment toggling (left <=> right) |
| 410 | */ |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 411 | if (matchElements.length > 0) |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 412 | resultPanel.addAlignAction(); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 413 | |
hebasta | 043e96f | 2019-11-28 12:33:00 +0100 | [diff] [blame] | 414 | KorAP.Panel['result'] = resultPanel; |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 415 | /* |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 416 | * Toggle the Virtual Corpus builder |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 417 | */ |
| 418 | if (vcname) { |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 419 | vc.onMinimize = function () { |
| 420 | vcname.classList.remove('active'); |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 421 | delete show['vc']; |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 422 | }; |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 423 | |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 424 | vc.onOpen = function () { |
| 425 | vcname.classList.add('active'); |
Akron | cfe8ecc | 2018-11-20 18:46:16 +0100 | [diff] [blame] | 426 | |
| 427 | var view = d.getElementById('vc-view'); |
| 428 | if (!view.firstChild) |
| 429 | view.appendChild(this.element()); |
| 430 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 431 | show['vc'] = true; |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 432 | }; |
| 433 | |
| 434 | var vcclick = function () { |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 435 | if (vc.isOpen()) { |
| 436 | vc.minimize() |
| 437 | } |
| 438 | else { |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 439 | vc.open(); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 440 | }; |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 441 | }; |
Akron | 04671e7 | 2017-05-11 20:47:32 +0200 | [diff] [blame] | 442 | |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 443 | vcname.onclick = vcclick; |
Akron | 5c829e9 | 2017-05-12 18:10:00 +0200 | [diff] [blame] | 444 | |
| 445 | // Click, if the VC should be shown |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 446 | if (show['vc']) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 447 | vcclick.apply(); |
Akron | 04671e7 | 2017-05-11 20:47:32 +0200 | [diff] [blame] | 448 | }; |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 449 | }; |
| 450 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 451 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 452 | /** |
| 453 | * Init Tutorial view |
| 454 | */ |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 455 | if (d.getElementById('view-tutorial')) { |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 456 | window.tutorial = tutClass.create( |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 457 | d.getElementById('view-tutorial'), |
Akron | f803559 | 2018-05-24 20:40:51 +0200 | [diff] [blame] | 458 | KorAP.session |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 459 | ); |
| 460 | obj.tutorial = window.tutorial; |
| 461 | } |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 462 | |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 463 | // Tutorial is in parent |
| 464 | else if (window.parent) { |
| 465 | obj.tutorial = window.parent.tutorial; |
| 466 | }; |
| 467 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 468 | // Initialize queries for d |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 469 | if (obj.tutorial) { |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 470 | obj.tutorial.initQueries(d); |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 471 | |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 472 | // Initialize documentation links |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 473 | obj.tutorial.initDocLinks(d); |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 474 | }; |
Nils Diewald | 61e6ff5 | 2015-05-07 17:26:50 +0000 | [diff] [blame] | 475 | |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 476 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 477 | /** |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 478 | * Add VC creation on submission. |
| 479 | */ |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 480 | var form = d.getElementById('searchform'); |
Akron | 792f58b | 2015-07-08 18:59:36 +0200 | [diff] [blame] | 481 | if (form !== null) { |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 482 | form.addEventListener('submit', function (e) { |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 483 | var qf = d.getElementById('q-field'); |
Akron | 1be6c1c | 2020-01-07 15:29:58 +0100 | [diff] [blame] | 484 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 485 | // No query was defined |
| 486 | if (qf.value === undefined || qf.value === '') { |
| 487 | qf.focus(); |
| 488 | e.halt(); |
| 489 | KorAP.log(700, "No query given"); |
| 490 | return; |
| 491 | }; |
Akron | 1be6c1c | 2020-01-07 15:29:58 +0100 | [diff] [blame] | 492 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 493 | // Store session information |
Akron | f803559 | 2018-05-24 20:40:51 +0200 | [diff] [blame] | 494 | KorAP.session.set("show", show); |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 495 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 496 | if (vc !== undefined) { |
| 497 | input.value = vc.toQuery(); |
Akron | d7ad907 | 2019-12-09 07:08:20 +0100 | [diff] [blame] | 498 | if (input.value == '') |
| 499 | input.removeAttribute('name'); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 500 | } |
| 501 | else { |
Akron | d7ad907 | 2019-12-09 07:08:20 +0100 | [diff] [blame] | 502 | input.removeAttribute('value'); |
| 503 | input.removeAttribute('name'); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 504 | }; |
Akron | 1be6c1c | 2020-01-07 15:29:58 +0100 | [diff] [blame] | 505 | |
| 506 | // This would preferably set the query to be "disabled", |
| 507 | // but in that case the query wouldn't be submitted |
| 508 | // at all. |
| 509 | // Setting the cursor to "progress" fails in current versions |
| 510 | // of webkit. |
| 511 | qf.classList.add("loading"); |
| 512 | d.getElementById('qsubmit').classList.add("loading"); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 513 | }); |
| 514 | }; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 515 | |
| 516 | |
| 517 | //Starts the guided tour at the next page |
| 518 | if(KorAP.session.get("tour")){ |
| 519 | tourClass.gTshowResults().start(); |
| 520 | } |
| 521 | |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 522 | /** |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 523 | * Init hint helper |
| 524 | * has to be final because of |
| 525 | * reposition |
| 526 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 527 | // Todo: Pass an element, so this works with |
| 528 | // tutorial pages as well! |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 529 | if (obj.hint === undefined) |
| 530 | obj.hint = hintClass.create(); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 531 | |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 532 | // Add the hinthelper to the KorAP object to make it manipulatable globally |
Akron | 72f7357 | 2017-12-05 12:31:09 +0100 | [diff] [blame] | 533 | KorAP.Hint = obj.hint; |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 534 | |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 535 | |
| 536 | /** |
| 537 | * Add query panel |
| 538 | */ |
| 539 | var queryPanel = queryPanelClass.create(); |
| 540 | |
| 541 | // Get input field |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 542 | var vcView = d.getElementById('vc-view') |
Akron | 96b97d6 | 2023-11-07 15:56:54 +0100 | [diff] [blame] | 543 | if (form && vcView) { |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 544 | // The views are below the query bar |
Akron | 96b97d6 | 2023-11-07 15:56:54 +0100 | [diff] [blame] | 545 | form.insertBefore(queryPanel.element(), vcView); |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 546 | KorAP.Panel['query'] = queryPanel; |
Akron | 644ad9f | 2021-07-26 16:12:59 +0200 | [diff] [blame] | 547 | }; |
| 548 | |
| 549 | |
| 550 | /** |
| 551 | * Add pagination panel |
| 552 | */ |
| 553 | const paginationPanel = paginationPanelClass.create(); |
| 554 | |
| 555 | if (paginationPanel) { |
| 556 | paginationPanel.addRandomPage(); |
| 557 | KorAP.Panel['pagination'] = paginationPanel; |
| 558 | }; |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 559 | |
Akron | a9c5580 | 2021-06-15 11:41:29 +0200 | [diff] [blame] | 560 | |
| 561 | /** |
| 562 | * Initialize password toggle. |
| 563 | */ |
| 564 | initCopyToClipboard(d); |
| 565 | |
| 566 | |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 567 | /** |
Akron | 116eace | 2021-06-14 18:02:37 +0200 | [diff] [blame] | 568 | * Initialize password toggle. |
| 569 | */ |
Akron | 1cfde27 | 2021-06-14 18:32:39 +0200 | [diff] [blame] | 570 | initTogglePwdVisibility(d); |
Akron | 116eace | 2021-06-14 18:02:37 +0200 | [diff] [blame] | 571 | |
| 572 | /** |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 573 | * Initialize Plugin registry. |
| 574 | */ |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 575 | let pe; |
| 576 | if (pe = d.getElementById("kalamar-plugins")) { |
| 577 | let url = pe.getAttribute('data-plugins'); |
| 578 | if (url !== undefined) { |
| 579 | KorAP.API.getPluginList(url, function (json) { |
| 580 | if (json && json.length > 0) { |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 581 | |
| 582 | // Add state manager |
Akron | 96b97d6 | 2023-11-07 15:56:54 +0100 | [diff] [blame] | 583 | form = d.getElementById("searchform"); |
| 584 | if (!form) { |
| 585 | return; |
| 586 | }; |
| 587 | |
| 588 | const input = form.addE("input"); |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 589 | input.setAttribute("name","state"); |
| 590 | KorAP.States = stateManagerClass.create(input); |
| 591 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 592 | // Load Plugin Server first |
| 593 | KorAP.Plugin = pluginClass.create(); |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 594 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 595 | // Add services container to head |
| 596 | d.head.appendChild(KorAP.Plugin.element()); |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 597 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 598 | // Add pipe form |
| 599 | KorAP.Pipe = pipeClass.create(); |
| 600 | d.getElementById("searchform").appendChild(KorAP.Pipe.element()); |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 601 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 602 | try { |
| 603 | |
| 604 | // Register all plugins |
| 605 | json.forEach(i => KorAP.Plugin.register(i)); |
| 606 | } |
| 607 | catch (e) { |
| 608 | KorAP.log(0, e); |
| 609 | } |
| 610 | } |
| 611 | }); |
| 612 | }; |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 613 | }; |
Akron | f7f75a9 | 2024-09-24 11:15:43 +0200 | [diff] [blame] | 614 | |
| 615 | window.dispatchEvent(new Event("ui-ready")); |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 616 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 617 | return obj; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 618 | }); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 619 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 620 | }); |