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'); |
| 274 | const hint = document.querySelector('#hint'); |
| 275 | const results = document.querySelector('.found'); |
| 276 | const aside = document.querySelector('aside'); |
| 277 | |
| 278 | if (aside && aside.classList.contains('active')) { |
| 279 | header.classList.add('shifted'); |
| 280 | if (!results) { |
| 281 | main.classList.add('shifted'); |
| 282 | } |
| 283 | footer.classList.add('shifted'); |
| 284 | if (hint) { |
| 285 | hint.classList.add('shifted'); |
| 286 | adjustHintPosition(); |
| 287 | } |
| 288 | } else { |
| 289 | header.classList.remove('shifted'); |
| 290 | main.classList.remove('shifted'); |
| 291 | footer.classList.remove('shifted'); |
| 292 | if (hint) { |
| 293 | hint.classList.remove('shifted'); |
| 294 | adjustHintPosition(); |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | // Function to adjust the position of the annotation assistant bar (hint), when user types into the searchbar and clicks the sidebar (or anywhere outside the searchbar) afterwards |
| 300 | function adjustHintPosition() { |
| 301 | const hint = document.querySelector('#hint'); |
| 302 | const searchInput = document.querySelector('#q-field'); |
| 303 | const aside = document.querySelector('aside'); |
| 304 | |
| 305 | if (hint && searchInput) { |
| 306 | // Create a temporary span to measure the exact text width |
| 307 | const span = document.createElement('span'); |
| 308 | span.style.visibility = 'hidden'; |
| 309 | span.style.position = 'absolute'; |
| 310 | span.style.whiteSpace = 'pre'; |
| 311 | // Copy the input's font properties |
| 312 | const inputStyle = window.getComputedStyle(searchInput); |
| 313 | span.style.font = inputStyle.font; |
| 314 | span.style.fontSize = inputStyle.fontSize; |
| 315 | span.style.fontFamily = inputStyle.fontFamily; |
| 316 | span.textContent = searchInput.value; |
| 317 | document.body.appendChild(span); |
| 318 | |
| 319 | // Get the actual width of the text |
| 320 | const inputWidth = searchInput.value.length > 0 ? span.offsetWidth : 0; |
| 321 | document.body.removeChild(span); |
| 322 | let hintLeftPosition = inputWidth; |
| 323 | |
| 324 | // TODO: This shouldn't be a fixed position! |
| 325 | if (aside && aside.classList.contains('active')) { |
| 326 | hintLeftPosition += 230; |
| 327 | } |
| 328 | |
| 329 | hint.style.left = `${hintLeftPosition}px`; |
| 330 | } |
| 331 | } |
| 332 | //Can be solved more elegant witch ES6 (see optional chaining operator) |
| 333 | let qlf = document.querySelector('#q-field'); |
| 334 | if(qlf != null){ |
| 335 | qlf.addEventListener('blur', adjustHintPosition); |
| 336 | } |
| 337 | |
| 338 | // MutationObserver to detect when #hint is injected into the DOM |
| 339 | const observer = new MutationObserver((mutationsList, observer) => { |
| 340 | for (const mutation of mutationsList) { |
| 341 | if (mutation.type === 'childList') { |
| 342 | const hint = document.querySelector('#hint'); |
| 343 | if (hint) { |
| 344 | shiftContent(); |
| 345 | observer.disconnect(); |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | }); |
| 350 | |
| 351 | observer.observe(document.body, { childList: true, subtree: true }); |
| 352 | |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 353 | // Add focus listener to aside |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 354 | var aside = d.getElementsByTagName('aside')[0]; |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 355 | |
| 356 | if (aside && aside.classList.contains('active') == false) { |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 357 | |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 358 | // Horrible lock to deal with sidebar clicks |
| 359 | var asideClicked = false; |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 360 | |
| 361 | shiftContent(); |
| 362 | |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 363 | // Make aside active on focus |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 364 | aside.addEventListener('focus', function (e) { |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 365 | this.classList.add('active'); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 366 | shiftContent(); |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 367 | }); |
| 368 | |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 369 | // Deactivate focus when clicking anywhere else |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 370 | var body = d.getElementsByTagName('body')[0]; |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 371 | if (body !== null) { |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 372 | body.addEventListener('click', function () { |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 373 | if (!asideClicked) { |
| 374 | aside.classList.remove('active'); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 375 | shiftContent(); |
| 376 | } else { |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 377 | asideClicked = false; |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 378 | } |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 379 | }); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 380 | } |
Akron | 1885ce9 | 2017-04-26 23:10:01 +0200 | [diff] [blame] | 381 | |
| 382 | /* Stop click event on aside |
| 383 | * (to not trickle down to body) |
| 384 | */ |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 385 | aside.addEventListener('click', function (e) { |
Akron | 5258d46 | 2017-04-26 23:32:57 +0200 | [diff] [blame] | 386 | asideClicked = true; |
Akron | e0c32c7 | 2017-04-25 22:38:23 +0200 | [diff] [blame] | 387 | }); |
Uyen-Nhu Tran | 243fe73 | 2024-04-10 01:17:24 +0200 | [diff] [blame] | 388 | } |
Akron | b9cdb10 | 2017-04-25 00:52:31 +0200 | [diff] [blame] | 389 | |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 390 | // Replace QL select menus with KorAP menus |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 391 | var qlField = d.getElementById('ql-field'); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 392 | if (qlField !== null) { |
Akron | 086fe5d | 2017-11-13 14:01:45 +0100 | [diff] [blame] | 393 | KorAP.QLmenu = selectMenuClass.create( |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 394 | d.getElementById('ql-field').parentNode |
Marc Kupietz | 9545582 | 2023-09-19 20:14:31 +0200 | [diff] [blame] | 395 | ).limit(10); |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 396 | }; |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 397 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 398 | var resultInfo = d.getElementById('resultinfo'); |
| 399 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 400 | /** |
| 401 | * Add result panel |
| 402 | */ |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 403 | var resultPanel = resultPanelClass.create(show); |
Akron | 644ad9f | 2021-07-26 16:12:59 +0200 | [diff] [blame] | 404 | |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 405 | if (resultInfo != null) { |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 406 | |
| 407 | // Move buttons to resultinfo |
Akron | 37ea119 | 2021-07-28 10:40:14 +0200 | [diff] [blame] | 408 | resultInfo.appendChild(resultPanel.actions().element()); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 409 | |
Akron | e6538cd | 2018-07-16 17:52:33 +0200 | [diff] [blame] | 410 | // The views are at the top of the search results |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 411 | var sb = d.getElementById('search'); |
| 412 | sb.insertBefore(resultPanel.element(), sb.firstChild); |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 413 | }; |
| 414 | |
| 415 | |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 416 | // There is a koralQuery |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 417 | if (KorAP.koralQuery !== undefined) { |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 418 | |
| 419 | // Add KoralQuery view to result panel |
Akron | 4d926f1 | 2018-07-16 15:30:25 +0200 | [diff] [blame] | 420 | if (resultInfo !== null) { |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 421 | resultPanel.addKqAction() |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 422 | }; |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 423 | |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 424 | if (KorAP.koralQuery["errors"]) { |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 425 | KorAP.koralQuery["errors"].forEach(function(e) { |
Akron | f0c31ed | 2016-06-11 11:27:01 +0200 | [diff] [blame] | 426 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 427 | // Malformed query |
Akron | 4a24b72 | 2020-10-13 12:44:25 +0200 | [diff] [blame] | 428 | if (e[0] === 302 && e[2] !== undefined) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 429 | obj.hint = hintClass.create(); |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 430 | obj.hint.alert(e[2], e[1]); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 431 | } |
Akron | f0c31ed | 2016-06-11 11:27:01 +0200 | [diff] [blame] | 432 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 433 | // no query |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 434 | else if (e[0] === 301) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 435 | obj.hint = hintClass.create(); |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 436 | obj.hint.alert(0, e[1]); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 437 | } |
Akron | 678c26f | 2020-10-09 08:52:50 +0200 | [diff] [blame] | 438 | }); |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 439 | }; |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 440 | }; |
| 441 | |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 442 | |
| 443 | /* |
| 444 | * There is more than 0 matches, so allow for |
| 445 | * alignment toggling (left <=> right) |
| 446 | */ |
Akron | b50964a | 2020-10-12 11:44:37 +0200 | [diff] [blame] | 447 | if (matchElements.length > 0) |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 448 | resultPanel.addAlignAction(); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 449 | |
hebasta | 043e96f | 2019-11-28 12:33:00 +0100 | [diff] [blame] | 450 | KorAP.Panel['result'] = resultPanel; |
Akron | 5cb9b2b | 2018-07-24 17:01:09 +0200 | [diff] [blame] | 451 | /* |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 452 | * Toggle the Virtual Corpus builder |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 453 | */ |
| 454 | if (vcname) { |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 455 | vc.onMinimize = function () { |
| 456 | vcname.classList.remove('active'); |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 457 | delete show['vc']; |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 458 | }; |
Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 459 | |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 460 | vc.onOpen = function () { |
| 461 | vcname.classList.add('active'); |
Akron | cfe8ecc | 2018-11-20 18:46:16 +0100 | [diff] [blame] | 462 | |
| 463 | var view = d.getElementById('vc-view'); |
| 464 | if (!view.firstChild) |
| 465 | view.appendChild(this.element()); |
| 466 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 467 | show['vc'] = true; |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 468 | }; |
| 469 | |
| 470 | var vcclick = function () { |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 471 | if (vc.isOpen()) { |
| 472 | vc.minimize() |
| 473 | } |
| 474 | else { |
Akron | ec6bb8e | 2018-08-29 13:07:56 +0200 | [diff] [blame] | 475 | vc.open(); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 476 | }; |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 477 | }; |
Akron | 04671e7 | 2017-05-11 20:47:32 +0200 | [diff] [blame] | 478 | |
Akron | 179c8ac | 2015-06-30 19:30:50 +0200 | [diff] [blame] | 479 | vcname.onclick = vcclick; |
Akron | 5c829e9 | 2017-05-12 18:10:00 +0200 | [diff] [blame] | 480 | |
| 481 | // Click, if the VC should be shown |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 482 | if (show['vc']) { |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 483 | vcclick.apply(); |
Akron | 04671e7 | 2017-05-11 20:47:32 +0200 | [diff] [blame] | 484 | }; |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 485 | }; |
| 486 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 487 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 488 | /** |
| 489 | * Init Tutorial view |
| 490 | */ |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 491 | if (d.getElementById('view-tutorial')) { |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 492 | window.tutorial = tutClass.create( |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 493 | d.getElementById('view-tutorial'), |
Akron | f803559 | 2018-05-24 20:40:51 +0200 | [diff] [blame] | 494 | KorAP.session |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 495 | ); |
| 496 | obj.tutorial = window.tutorial; |
| 497 | } |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 498 | |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 499 | // Tutorial is in parent |
| 500 | else if (window.parent) { |
| 501 | obj.tutorial = window.parent.tutorial; |
| 502 | }; |
| 503 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 504 | // Initialize queries for d |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 505 | if (obj.tutorial) { |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 506 | obj.tutorial.initQueries(d); |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 507 | |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 508 | // Initialize documentation links |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 509 | obj.tutorial.initDocLinks(d); |
Akron | 6ed1399 | 2016-05-23 18:06:05 +0200 | [diff] [blame] | 510 | }; |
Nils Diewald | 61e6ff5 | 2015-05-07 17:26:50 +0000 | [diff] [blame] | 511 | |
Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 512 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 513 | /** |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 514 | * Add VC creation on submission. |
| 515 | */ |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 516 | var form = d.getElementById('searchform'); |
Akron | 792f58b | 2015-07-08 18:59:36 +0200 | [diff] [blame] | 517 | if (form !== null) { |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 518 | form.addEventListener('submit', function (e) { |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 519 | var qf = d.getElementById('q-field'); |
Akron | 1be6c1c | 2020-01-07 15:29:58 +0100 | [diff] [blame] | 520 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 521 | // No query was defined |
| 522 | if (qf.value === undefined || qf.value === '') { |
| 523 | qf.focus(); |
| 524 | e.halt(); |
| 525 | KorAP.log(700, "No query given"); |
| 526 | return; |
| 527 | }; |
Akron | 1be6c1c | 2020-01-07 15:29:58 +0100 | [diff] [blame] | 528 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 529 | // Store session information |
Akron | f803559 | 2018-05-24 20:40:51 +0200 | [diff] [blame] | 530 | KorAP.session.set("show", show); |
Akron | 7716f01 | 2015-07-01 20:38:32 +0200 | [diff] [blame] | 531 | |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 532 | if (vc !== undefined) { |
| 533 | input.value = vc.toQuery(); |
Akron | d7ad907 | 2019-12-09 07:08:20 +0100 | [diff] [blame] | 534 | if (input.value == '') |
| 535 | input.removeAttribute('name'); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 536 | } |
| 537 | else { |
Akron | d7ad907 | 2019-12-09 07:08:20 +0100 | [diff] [blame] | 538 | input.removeAttribute('value'); |
| 539 | input.removeAttribute('name'); |
Akron | 19d97fe | 2016-09-06 20:47:05 +0200 | [diff] [blame] | 540 | }; |
Akron | 1be6c1c | 2020-01-07 15:29:58 +0100 | [diff] [blame] | 541 | |
| 542 | // This would preferably set the query to be "disabled", |
| 543 | // but in that case the query wouldn't be submitted |
| 544 | // at all. |
| 545 | // Setting the cursor to "progress" fails in current versions |
| 546 | // of webkit. |
| 547 | qf.classList.add("loading"); |
| 548 | d.getElementById('qsubmit').classList.add("loading"); |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 549 | }); |
| 550 | }; |
hebasta | 5df796f | 2019-05-21 15:27:12 +0200 | [diff] [blame] | 551 | |
| 552 | |
| 553 | //Starts the guided tour at the next page |
| 554 | if(KorAP.session.get("tour")){ |
| 555 | tourClass.gTshowResults().start(); |
| 556 | } |
| 557 | |
Akron | c1457bf | 2015-06-11 19:24:00 +0200 | [diff] [blame] | 558 | /** |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 559 | * Init hint helper |
| 560 | * has to be final because of |
| 561 | * reposition |
| 562 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 563 | // Todo: Pass an element, so this works with |
| 564 | // tutorial pages as well! |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 565 | if (obj.hint === undefined) |
| 566 | obj.hint = hintClass.create(); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 567 | |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 568 | // Add the hinthelper to the KorAP object to make it manipulatable globally |
Akron | 72f7357 | 2017-12-05 12:31:09 +0100 | [diff] [blame] | 569 | KorAP.Hint = obj.hint; |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 570 | |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 571 | |
| 572 | /** |
| 573 | * Add query panel |
| 574 | */ |
| 575 | var queryPanel = queryPanelClass.create(); |
| 576 | |
| 577 | // Get input field |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 578 | var vcView = d.getElementById('vc-view') |
Akron | 96b97d6 | 2023-11-07 15:56:54 +0100 | [diff] [blame] | 579 | if (form && vcView) { |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 580 | // The views are below the query bar |
Akron | 96b97d6 | 2023-11-07 15:56:54 +0100 | [diff] [blame] | 581 | form.insertBefore(queryPanel.element(), vcView); |
Akron | 2d0d96d | 2019-11-18 19:49:50 +0100 | [diff] [blame] | 582 | KorAP.Panel['query'] = queryPanel; |
Akron | 644ad9f | 2021-07-26 16:12:59 +0200 | [diff] [blame] | 583 | }; |
| 584 | |
| 585 | |
| 586 | /** |
| 587 | * Add pagination panel |
| 588 | */ |
| 589 | const paginationPanel = paginationPanelClass.create(); |
| 590 | |
| 591 | if (paginationPanel) { |
| 592 | paginationPanel.addRandomPage(); |
| 593 | KorAP.Panel['pagination'] = paginationPanel; |
| 594 | }; |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 595 | |
Akron | a9c5580 | 2021-06-15 11:41:29 +0200 | [diff] [blame] | 596 | |
| 597 | /** |
| 598 | * Initialize password toggle. |
| 599 | */ |
| 600 | initCopyToClipboard(d); |
| 601 | |
| 602 | |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 603 | /** |
Akron | 116eace | 2021-06-14 18:02:37 +0200 | [diff] [blame] | 604 | * Initialize password toggle. |
| 605 | */ |
Akron | 1cfde27 | 2021-06-14 18:32:39 +0200 | [diff] [blame] | 606 | initTogglePwdVisibility(d); |
Akron | 116eace | 2021-06-14 18:02:37 +0200 | [diff] [blame] | 607 | |
| 608 | /** |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 609 | * Initialize Plugin registry. |
| 610 | */ |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 611 | let pe; |
| 612 | if (pe = d.getElementById("kalamar-plugins")) { |
| 613 | let url = pe.getAttribute('data-plugins'); |
| 614 | if (url !== undefined) { |
| 615 | KorAP.API.getPluginList(url, function (json) { |
| 616 | if (json && json.length > 0) { |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 617 | |
| 618 | // Add state manager |
Akron | 96b97d6 | 2023-11-07 15:56:54 +0100 | [diff] [blame] | 619 | form = d.getElementById("searchform"); |
| 620 | if (!form) { |
| 621 | return; |
| 622 | }; |
| 623 | |
| 624 | const input = form.addE("input"); |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 625 | input.setAttribute("name","state"); |
| 626 | KorAP.States = stateManagerClass.create(input); |
| 627 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 628 | // Load Plugin Server first |
| 629 | KorAP.Plugin = pluginClass.create(); |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 630 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 631 | // Add services container to head |
| 632 | d.head.appendChild(KorAP.Plugin.element()); |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 633 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 634 | // Add pipe form |
| 635 | KorAP.Pipe = pipeClass.create(); |
| 636 | d.getElementById("searchform").appendChild(KorAP.Pipe.element()); |
Akron | da32e7a | 2021-11-16 17:28:57 +0100 | [diff] [blame] | 637 | |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 638 | try { |
| 639 | |
| 640 | // Register all plugins |
| 641 | json.forEach(i => KorAP.Plugin.register(i)); |
| 642 | } |
| 643 | catch (e) { |
| 644 | KorAP.log(0, e); |
| 645 | } |
| 646 | } |
| 647 | }); |
| 648 | }; |
Akron | 24f48ea | 2020-07-01 09:37:19 +0200 | [diff] [blame] | 649 | }; |
Akron | f7f75a9 | 2024-09-24 11:15:43 +0200 | [diff] [blame] | 650 | |
| 651 | window.dispatchEvent(new Event("ui-ready")); |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 652 | |
Nils Diewald | 5814133 | 2015-04-07 16:18:45 +0000 | [diff] [blame] | 653 | return obj; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 654 | }); |
hebasta | 75cfca5 | 2019-02-19 13:15:27 +0100 | [diff] [blame] | 655 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 656 | }); |