1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.HighlightMatch = exports.EduSearchItem = exports.EduSearchBox = exports.startAgendaOnlineSearch = void 0; 4var tslib_1 = require("tslib"); 5var React = require("react"); 6var AppReactUtils_1 = require("../../../app/pics/jsw/utils/AppReactUtils"); 7var edusearch_1 = require("./edusearch"); 8var AscHttp_1 = require("../../../app/pics/jsw/utils/AscHttp"); 9var edurequest_1 = require("../../../asc/edurequest"); 10var clientcache_1 = require("../../../rpr/clientcache"); 11var agendareports_1 = require("../../../reports/pics/jsw/agendareports"); 12var dbi_react_1 = require("../../../rpr/dbi_react"); 13var search_1 = require("../../../agenda/server/search"); 14var maindbi_ui_1 = require("../../../rpr/maindbi_ui"); 15var cache_1 = require("../../../react/cache"); 16importCss('/user/pics/css/edusearch.css'); 17importCss('/app/pics/css/mobileApp.css'); 18importCss('/user/pics/css/userIcons.css'); 19function startAgendaOnlineSearch() { 20 var startFunc = $('#edubarHeaderSearch').data('startSearchFunc'); 21 if (startFunc) { 22 startFunc(); 23 return true; 24 } 25 return false; 26} 27exports.startAgendaOnlineSearch = startAgendaOnlineSearch; 28function EduSearchBox(props) { 29 var _this = this; 30 var _a; 31 var mainElemRef = React.useRef(null); 32 var _b = AppReactUtils_1.AppReactUtils.useRefStateWithSessionStorage('', 'edusearchquery'), searchQuery = _b[0], setSearchQuery0 = _b[1]; 33 var _c = React.useState(!!searchQuery), popupShown = _c[0], setPopupShown = _c[1]; 34 var _d = React.useState(false), wasFocused = _d[0], setWasFocused = _d[1]; 35 var sentSearches = React.useRef({}); 36 var searchDataRef = React.useRef(null); 37 var _e = AppReactUtils_1.AppReactUtils.useRefState(false), searchDataLoading = _e[0], setSearchDataLoaing = _e[1], searchDataLoadingRef = _e[2]; 38 var _f = React.useState({}), expandedGroups = _f[0], setExpandedGroups = _f[1]; 39 var _g = AppReactUtils_1.AppReactUtils.useRefState(((_a = window.location.href) === null || _a === void 0 ? void 0 : _a.indexOf('/agenda/online')) >= 0 ? 'ao' : 'ed'), searchTabSrc = _g[0], setSearchTabSrc = _g[1], searchTabSrcRef = _g[2]; 40 var _h = AppReactUtils_1.AppReactUtils.useRefStateWithSessionStorage('modules', 'edusearchtab'), searchTabEd = _h[0], setSearchTabEd = _h[1]; 41 var _j = AppReactUtils_1.AppReactUtils.useRefStateWithSessionStorage('agendaonline', 'edusearchtabao'), searchTabAo = _j[0], setSearchTabAo = _j[1]; 42 var searchTab = searchTabSrc == 'ao' ? searchTabAo : searchTabEd; 43 var searchData = AppReactUtils_1.AppReactUtils.useAsyncMemo(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { 44 var _a; 45 return tslib_1.__generator(this, function (_b) { 46 switch (_b.label) { 47 case 0: 48 if (!wasFocused) 49 return [2, null]; 50 if (!(!searchDataRef.current && !searchDataLoadingRef.current)) return [3, 2]; 51 setSearchDataLoaing(true); 52 _a = searchDataRef; 53 return [4, AscHttp_1.AscHttp.asyncRpc('/user/?cmd=Edusearch', 'getData', { ignoreSessionLock: '1' }, { showLoading: false })]; 54 case 1: 55 _a.current = _b.sent(); 56 setTimeout(function () { 57 setSearchDataLoaing(false); 58 }, 20); 59 _b.label = 2; 60 case 2: return [2, searchDataRef.current]; 61 } 62 }); 63 }); }, [searchQuery, wasFocused, searchDataLoading]); 64 var dbi = (0, dbi_react_1.useMainDBI)(wasFocused ? EdubarUtils.getSelectedSchoolYear() : null, { 65 needed_part: { 66 studentkopias: ['firstname', 'lastname', '__name', 'classid', 'grade', '_uial', 'email'], 67 subjects: ["name", 'short'], 68 teachers: ['firstname', 'lastname', '__name', '_uial', 'email'], 69 classes: ['name', '__name', 'grade', 'teacher2id', 'teacherid', 'subjects', '_uial'], 70 groupsubjects: ['name', 'classids', 'subjectid', '_uial', 'teacherids'] 71 } 72 }); 73 React.useEffect(function () { 74 function handleKeyDown(e) { 75 if (e.which == 71 && e.ctrlKey) { 76 e.preventDefault(); 77 $(mainElemRef.current).find('.edusearch-box').focus().select(); 78 } 79 } 80 function handlePageLoad() { 81 var _a; 82 setSearchTabSrc(((_a = window.location.href) === null || _a === void 0 ? void 0 : _a.indexOf('/agenda/online')) >= 0 ? 'ao' : 'ed'); 83 } 84 $('#edubarHeaderSearch').data('startSearchFunc', function (tab) { 85 setSearchTab(tab || 'agendaonline'); 86 setPopupShown(true); 87 $(mainElemRef.current).find('.edusearch-box').focus().select(); 88 }); 89 $(document).on('keydown', handleKeyDown); 90 $(window).on('load', handlePageLoad); 91 $('body').on('smartLoaded', handlePageLoad); 92 return function () { 93 $(document).off('keydown', handleKeyDown); 94 $(window).off('load', handlePageLoad); 95 $('body').off('smartLoaded', handlePageLoad); 96 }; 97 }, []); 98 var searchGroups = React.useMemo(function () { 99 var _a; 100 if (!searchData || !dbi) 101 return null; 102 function newMessageClick(r, a) { 103 barNewDialog({ 104 'source': '/timeline/?cmd=TimelineMessageCreator', 105 'postData': { 106 recipients: r.userid, 107 } 108 }); 109 } 110 function agendaCardClick(r, a) {
111 if (a.tableid == 'studentkopias') { 112 ASC.requireAsync('/agenda/dlg/student.js').then(function (c) { 113 c.showStudentDlg(parseInt(dbi.dbid), a.tableid, r.id, {}); 114 }); 115 } 116 else if (a.tableid == 'teachers') { 117 ASC.requireAsync('/agenda/dlg/teacher.js').then(function (c) { 118 c.showTeacherDlg(parseInt(dbi.dbid), a.tableid, r.id, {}); 119 }); 120 } 121 else if (a.tableid == 'classes') { 122 ASC.requireAsync('/agenda/dlg/class.js').then(function (c) { 123 c.showClassDlg(parseInt(dbi.dbid), a.tableid, r.id, {}); 124 }); 125 } 126 } 127 function timetableClick(r, a) { 128 barSmartLoadPage('/timetable/view.php?' + a.p); 129 } 130 function planDetailsClick(r, a) { 131 var dlg = barNewDialog({ 132 'title': 'EduPage', 133 'source': '/plany/?jwgc=PlanyCreator&mode=kompetencie&planid=' + r.id, 134 'returnFunc': function (data) { 135 } 136 }); 137 } 138 function getHelpDescription(id) { 139 var r = helpById[id]; 140 if (!r) 141 return ''; 142 if (!r.parent_id) 143 return ''; 144 var p = helpById[r.parent_id]; 145 if (!p) 146 return ''; 147 var pd = getHelpDescription(r.parent_id); 148 var ret = []; 149 if (pd) 150 ret.push(pd); 151 if (p.text) 152 ret.push(p.text); 153 return ret.join(' · '); 154 } 155 var students = dbi.tableData('studentkopias').map(function (r) { 156 var r0 = tslib_1.__assign({}, r); 157 r0.userid = 'Student' + r.id.split(':')[0]; 158 r0.name = dbi.rowName("studentkopias", r.id) + ' (' + dbi.rowName("classes", r.classid) + ')'; 159 r0.name2 = r.lastname + ', ' + r.firstname; 160 r0.keywords = r.email ? [r.email] : null; 161 r0.group = dbi.rowName("classes", r.classid) + ' ' + dbi.rowName("classes", r.classid, 'short'); 162 r0.actions = [ 163 { id: 'newmessage', onClick: newMessageClick, name: ls(3370) }, 164 ]; 165 if (r._uial > 0) { 166 r0.actions.push({ id: 'agenda', onClick: agendaCardClick, name: ls(1920), tableid: 'studentkopias' }); 167 r0.actions.push({ id: 'timetable', onClick: timetableClick, name: ls(1001), p: 'student=' + r.id.split(':')[0] }); 168 } 169 return r0; 170 }); 171 var teachers = dbi.tableData('teachers').map(function (r) { 172 var r0 = tslib_1.__assign({}, r); 173 r0.userid = 'Ucitel' + r.id; 174 r0.name = dbi.rowName("teachers", r.id); 175 r0.name2 = r.lastname + ', ' + r.firstname; 176 r0.keywords = r.email ? [r.email] : null; 177 r0.actions = [ 178 { id: 'newmessage', onClick: newMessageClick, name: ls(3370) }, 179 ]; 180 if (r._uial > 0) { 181 r0.actions.push({ id: 'agenda', onClick: agendaCardClick, name: ls(1920), tableid: 'teachers' }); 182 r0.actions.push({ id: 'timetable', onClick: timetableClick, name: ls(1001), p: 'teacher=' + r.id }); 183 } 184 return r0; 185 }); 186 var classes = dbi.tableData('classes').map(function (r) { 187 var r0 = tslib_1.__assign({}, r); 188 r0.userid = 'Trieda' + r.id; 189 r0.actions = [ 190 { id: 'newmessage', onClick: newMessageClick, name: ls(3370) }, 191 ]; 192 if (r._uial > 0) { 193 r0.actions.push({ id: 'agenda', onClick: agendaCardClick, name: ls(1920), tableid: 'classes' }); 194 r0.actions.push({ id: 'timetable', onClick: timetableClick, name: ls(1001), p: 'class=' + r.id }); 195 } 196 return r0; 197 }); 198 var groupsubjects = dbi.tableData('groupsubjects').filter(function (r) { return EdubarUtils.isAdmin() || EdubarUtils.indexOf(r.teacherids, EdubarUtils.isUcitel()) >= 0; }).map(function (r) { 199 var r0 = tslib_1.__assign({}, r); 200 r0.userid = 'Plan' + r.id; 201 r0.actions = [ 202 { id: 'newmessage', onClick: newMessageClick, name: ls(3370) }, 203 ];
204 r0.actions.push({ id: 'plandetails', onClick: planDetailsClick, name: ls(1920), tableid: 'classes' }); 205 return r0; 206 }); 207 var helpById = {}; 208 for (var _i = 0, _b = ((searchData === null || searchData === void 0 ? void 0 : searchData.helps) || []); _i < _b.length; _i++) { 209 var r = _b[_i]; 210 helpById[r.id] = r; 211 } 212 var helps = ((searchData === null || searchData === void 0 ? void 0 : searchData.helps) || []).map(function (r) { 213 var _a; 214 var r0 = { 215 id: 'help:' + r.id, 216 name: r.text, 217 name2: r.level ? '' : r.text, 218 keywords: (_a = r.keywords) === null || _a === void 0 ? void 0 : _a.split(',').map(function (s) { return s.trim(); }), 219 action: 'help::' + r.id + '::' + (r.level || ""), 220 description: getHelpDescription(r.id) 221 }; 222 return r0; 223 }); 224 var reports0 = []; 225 if (EdubarUtils.getSchoolCountry() == 'sk') { 226 var boxes = (0, agendareports_1.getReportsBoxes)(); 227 var boxById = {}; 228 var moduleToBox = {}; 229 for (var _c = 0, boxes_1 = boxes; _c < boxes_1.length; _c++) { 230 var b = boxes_1[_c]; 231 if (b.type == 'zus_dashboardreporter' && EdubarUtils.jeZUS()) 232 b.moduleLink = null; 233 boxById[b.id] = b; 234 if (!b.modules) 235 b.modules = [b.id]; 236 if (b.modules) { 237 for (var _d = 0, _e = b.modules; _d < _e.length; _d++) { 238 var m = _e[_d]; 239 if (!moduleToBox[m]) 240 moduleToBox[m] = []; 241 moduleToBox[m].push(b); 242 } 243 } 244 } 245 for (var _f = 0, _g = (searchData === null || searchData === void 0 ? void 0 : searchData.reports) || []; _f < _g.length; _f++) { 246 var r = _g[_f]; 247 if (!r.modules) { 248 continue; 249 } 250 var modules2 = []; 251 for (var _h = 0, _j = r.modules; _h < _j.length; _h++) { 252 var m = _j[_h]; 253 if (m == 'reports') 254 continue; 255 if (m == 'agenda') 256 continue; 257 if (m.trim() == '') 258 continue; 259 if (m == 'diplomas') 260 continue; 261 if (m == 'contest') 262 continue; 263 if (m == 'triednevykazy' && EdubarUtils.jeZUS()) 264 continue; 265 modules2.push(m); 266 if (moduleToBox[m] && !r.boxid) { 267 r.boxid = (_a = moduleToBox[m][0]) === null || _a === void 0 ? void 0 : _a.id; 268 } 269 } 270 if (modules2.length == 0) 271 continue; 272 if (!r.boxid) 273 continue; 274 r.box = boxById[r.boxid]; 275 r.modules = modules2; 276 r.name2 = r.description; 277 reports0.push(r); 278 } 279 } 280 var ret = [ 281 { id: 'modules', name: ls(2058), items: (searchData === null || searchData === void 0 ? void 0 : searchData.modules) || [], searchIndex: null }, 282 { id: 'actions', name: ls(1532), items: (searchData === null || searchData === void 0 ? void 0 : searchData.actions) || [], searchIndex: null }, 283 { id: 'dbi:studentkopias', name: ls(3318), items: students, searchIndex: null, searchOptions: { distance: 0, ignoreLocation: false } }, 284 { id: 'dbi:teachers', name: ls(1005) + ' / ' + ls(7215), items: teachers, searchIndex: null, searchOptions: { distance: 0, ignoreLocation: false } }, 285 { id: 'dbi:classes', name: ls(1194), items: classes, searchIndex: null, searchOptions: { distance: 0, ignoreLocation: false } }, 286 { id: 'dbi:groupsubjects', name: ls(7877), items: groupsubjects, searchIndex: null }, 287 { id: 'helps', name: ls(9632), items: helps, searchIndex: null }, 288 ]; 289 if (reports0.length > 0) {
290 ret.push({ id: 'reports', name: ls(1641), items: reports0, searchIndex: null }); 291 } 292 for (var _k = 0, ret_1 = ret; _k < ret_1.length; _k++) { 293 var grp = ret_1[_k]; 294 grp.searchIndex = edusearch_1.EduSearch.buildSearchIndex(grp.items || [], grp.searchOptions || {}); 295 } 296 return ret; 297 }, [searchData, dbi]); 298 var wasFirstTimeSearch = React.useRef(null); 299 var searchResForSq = React.useRef(""); 300 var lastSearchResForSq = React.useRef(""); 301 var agendaSearchResForSq = React.useRef(""); 302 var lastAgendaSearchRes = React.useRef(null); 303 var searchRes0 = AppReactUtils_1.AppReactUtils.useDelayedAsyncMemo(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { 304 var ret, _i, searchGroups_1, grpRow, grp, _a, _b, r; 305 return tslib_1.__generator(this, function (_c) { 306 if (!searchGroups) 307 return [2, {}]; 308 if (searchTab == 'agendaonline') 309 return [2, {}]; 310 ret = {}; 311 for (_i = 0, searchGroups_1 = searchGroups; _i < searchGroups_1.length; _i++) { 312 grpRow = searchGroups_1[_i]; 313 grp = grpRow.id; 314 ret[grp] = edusearch_1.EduSearch.searchInJson(searchQuery, grpRow.searchIndex); 315 grpRow["maxWordScore"] = 0; 316 for (_a = 0, _b = ret[grp]; _a < _b.length; _a++) { 317 r = _b[_a]; 318 if (r.wordScore > grpRow["maxWordScore"]) { 319 grpRow["maxWordScore"] = r.wordScore; 320 } 321 } 322 } 323 wasFirstTimeSearch.current = true; 324 searchResForSq.current = searchQuery; 325 lastSearchResForSq.current = searchQuery; 326 setPopupShown(!!searchQuery); 327 return [2, ret]; 328 }); 329 }); }, [searchQuery, searchGroups, searchTab], wasFirstTimeSearch.current ? 100 : 0); 330 var agendaSearchRes = AppReactUtils_1.AppReactUtils.useDelayedAsyncMemo(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { 331 var actl, res, _a, ret, _i, ret_2, r; 332 return tslib_1.__generator(this, function (_b) { 333 switch (_b.label) { 334 case 0: 335 if (!searchQuery) 336 return [2, []]; 337 if (!wasFocused) 338 return [2, []]; 339 if (searchTab != 'agendaonline') 340 return [2, []]; 341 actl = (0, maindbi_ui_1.getAgendaControl)(); 342 if (!(agendaSearchResForSq.current == searchQuery && lastAgendaSearchRes.current)) return [3, 1]; 343 _a = lastAgendaSearchRes.current; 344 return [3, 3]; 345 case 1: return [4, (0, search_1.agendaSearch)(null, EdubarUtils.getSelectedSchoolYear(), searchQuery, { where: 'agenda', preffered_table: ((actl === null || actl === void 0 ? void 0 : actl.table) || 'students') })]; 346 case 2: 347 _a = _b.sent(); 348 _b.label = 3; 349 case 3: 350 res = _a; 351 lastAgendaSearchRes.current = res; 352 agendaSearchResForSq.current = searchQuery; 353 lastSearchResForSq.current = searchQuery; 354 ret = ((res === null || res === void 0 ? void 0 : res.items) || []); 355 for (_i = 0, ret_2 = ret; _i < ret_2.length; _i++) { 356 r = ret_2[_i]; 357 r["action"] = 'agendaDlg'; 358 } 359 setPopupShown(!!searchQuery); 360 return [2, ret]; 361 } 362 }); 363 }); }, [searchQuery, wasFocused, searchTab], lastSearchResForSq.current == searchQuery ? 10 : 400); 364 var searchRes = React.useMemo(function () { 365 var ret = {}; 366 ret = tslib_1.__assign({}, searchRes0); 367 if (agendaSearchRes) { 368 ret['agendaonline'] = agendaSearchRes; 369 } 370 return ret; 371 }, [searchRes0, agendaSearchRes]); 372 React.useEffect(function () { 373 if (!searchQuery) 374 return; 375 if (!wasFocused) 376 return; 377 setPopupShown(!!searchQuery); 378 }, [searchQuery, wasFocused]); 379 React.useEffect(function () { 380 $(mainElemRef.current).find('.edusearch-popup-outer').on('focus', function () { 381 $(mainElemRef.current).find('.edusearch-focusable-item').first().focus(); 382 }); 383 return function () { 384 $(mainElemRef.current).find('.edusearch-popup-outer').off('focus'); 385 }; 386 }, [popupShown]); 387 function setSearchTab(val) { 388 if (searchTabSrcRef.current == 'ao') { 389 setSearchTabAo(val); 390 } 391 else { 392 setSearchTabEd(val); 393 } 394 } 395 function searchQueryChange(e) { 396 setSearchQuery(e.currentTarget.value); 397 } 398 function setSearchQuery(val) { 399 setSearchQuery0(val); 400 setExpandedGroups({}); 401 } 402 function clearClick() { 403 setSearchQuery(''); 404 } 405 function handleKeyDown(e) { 406 if (e.which == 27) { 407 setPopupShown(false); 408 } 409 if (e.which == 40) { 410 e.preventDefault(); 411 setPopupShown(true); 412 focusNextPrev(1); 413 } 414 if (e.which == 38 && popupShown) { 415 e.preventDefault(); 416 focusNextPrev(-1); 417 } 418 if (e.which == 9 && popupShown) { 419 e.preventDefault(); 420 focusNextPrev(e.shiftKey ? -1 : 1); 421 } 422 else if (e.which == 13 && $(mainElemRef.current).find('.edusearch-box').is(':focus')) { 423 e.preventDefault(); 424 focusNextPrev(1); 425 }
426 else if (e.which == 8 || e.which == 37 || e.which == 39) { 427 $(mainElemRef.current).find('.edusearch-box').focus(); 428 } 429 else if (EdubarUtils.indexOf([27, 40, 38, 13, 9, 32], e.which) < 0) { 430 $(mainElemRef.current).find('.edusearch-box').focus(); 431 } 432 } 433 function focusNextPrev(dir, allowLoop) { 434 var lastElem = null; 435 var focusNext = false; 436 var wasFocused = false; 437 $(mainElemRef.current).find('.edusearch-focusable-item').each(function () { 438 if (focusNext) { 439 $(this).focus(); 440 focusNext = false; 441 wasFocused = true; 442 return false; 443 } 444 if ($(this).is(':focus')) { 445 if (dir == -1) { 446 if (lastElem) { 447 $(lastElem).focus(); 448 } 449 else { 450 $(mainElemRef.current).find('.edusearch-box').focus(); 451 } 452 wasFocused = true; 453 return false; 454 } 455 if (dir == 1) { 456 focusNext = true; 457 } 458 } 459 lastElem = this; 460 }); 461 if (dir == 1 && !wasFocused) { 462 if (focusNext) { 463 $(mainElemRef.current).find('.edusearch-box').focus(); 464 } 465 else { 466 $(mainElemRef.current).find('.edusearch-focusable-item').first().focus(); 467 } 468 } 469 if (dir == -1 && !wasFocused) { 470 $(mainElemRef.current).find('.edusearch-focusable-item').last().focus(); 471 } 472 } 473 function searchClick(e) { 474 $(mainElemRef.current).find('.edusearch-box').focus(); 475 } 476 function expandGroupClick(e) { 477 var _a; 478 var grpid = $(e.currentTarget).attr('data-groupid'); 479 setExpandedGroups(tslib_1.__assign(tslib_1.__assign({}, expandedGroups), (_a = {}, _a[grpid] = true, _a))); 480 $(e.currentTarget).prev().focus(); 481 } 482 function handleClick(e) { 483 var _a, _b, _c, _d; 484 if (e.button === 0) { 485 e.preventDefault(); 486 } 487 else if (!((_a = e.type) === null || _a === void 0 ? void 0 : _a.startsWith('key'))) { 488 return; 489 } 490 if ($(e.target).closest('.app-link-button').length > 0) 491 return; 492 var index = $(e.currentTarget).attr('data-index'); 493 var type = $(e.currentTarget).attr('data-type'); 494 var item = ((_c = (_b = searchRes === null || searchRes === void 0 ? void 0 : searchRes[type]) === null || _b === void 0 ? void 0 : _b[index]) === null || _c === void 0 ? void 0 : _c.item) || ((_d = searchRes === null || searchRes === void 0 ? void 0 : searchRes[type]) === null || _d === void 0 ? void 0 : _d[index]); 495 if (!item) 496 return; 497 setTimeout(function () { 498 handleClick0(item, type); 499 }, 70); 500 } 501 function handleAction(item, handleActionUrl) { 502 var _a; 503 var _b = (_a = item.action) === null || _a === void 0 ? void 0 : _a.split('::'), type = _b[0], url = _b[1], subaction = _b[2]; 504 if (type == 'agendaDlg') { 505 (0, maindbi_ui_1.showMainDbiItemDlg)(parseInt(item.year), item.table, item.id); 506 } 507 else if (type == 'openFireAlertReport') { 508 $j.ajax('/user/?akcia=fireAlert', { 509 type: 'POST', 510 dataType: 'script' 511 }); 512 } 513 else if (type == 'customizeOpen') { 514 ASC.CustomizeOpen(url); 515 } 516 else if (type == 'timeline') { 517 var dialog = barNewDialog({ 518 title: ls(3278), 519 postData: { 520 stype: url, 521 customData: JSON.stringify({ 522 subaction: subaction 523 }) 524 }, 525 source: '/timeline/?cmd=creator', 526 dialogClass: 'whiteDialog' 527 }); 528 } 529 else if (type == 'href0') { 530 window.location.href = url; 531 } 532 else if (type == 'hrefnew') { 533 window.open(url); 534 } 535 else if (type == 'href') { 536 barSmartLoadPage(url); 537 } 538 else if (type == 'help') { 539 var helpid = url; 540 if (EdubarUtils.indexOf(['de', 'at', 'ch'], EdubarUtils.getSchoolCountry()) >= 0) { 541 window.open(barEncLink('/customize/helpus.php?cmd=HelpusHelpDialog&' + (subaction ? 'helpid=' + helpid + '' : 'helpp='
541+ helpid) + '&redirect=1')); 542 } 543 else { 544 var dlg = barNewDialog({ 545 'source': '/customize/helpus.php?cmd=HelpusHelpDialog&' + (subaction ? 'helpid=' + helpid + '' : 'helpp=' + helpid), 546 'dialogClass': 'whiteDialog noPadding', 547 'returnFunc': function () { 548 barCloseDialog(dlg); 549 }, 550 'width': Math.min(1200, $(window).width() * 0.9), 551 'height': $(window).height() * 0.85 + 55 552 }); 553 } 554 } 555 else if (type == 'jsxaction') { 556 ASC.requireAsync(url).then(function (c) { 557 ASC.requireAsync('react-dom').then(function (ReactDOM) { 558 window.ReactDOM = ReactDOM; 559 c[subaction](tslib_1.__assign({}, item.actionProps)); 560 }); 561 }); 562 } 563 else if (type == 'jsmod') { 564 if (window[url] && window[url][subaction]) { 565 window[url][subaction](); 566 } 567 } 568 else if (type == 'jsdialog') { 569 if (item.actionUrl && handleActionUrl !== false) { 570 barSmartLoadPage(item.actionUrl, false, false, false, function () { 571 handleAction(item, false); 572 }); 573 return; 574 } 575 $j.post(url, item.postData || {}, function () { }, 'script'); 576 } 577 else if (type == 'dialog') { 578 if (item.actionUrl && handleActionUrl !== false) { 579 barSmartLoadPage(item.actionUrl, false, false, false, function () { 580 handleAction(item, false); 581 }); 582 return; 583 } 584 barNewDialog({ 585 source: url, 586 postData: item.postData || null, 587 returnFunc: function (src) { 588 if (item.id == 'file') { 589 window.open(src); 590 return 'noclose'; 591 } 592 if (item.id == 'news') { 593 window.location.href = '/news/#news-' + src; 594 return; 595 } 596 if (item.id == 'rozhodnutie') { 597 barShowMessageEx(renderS(ls(1309) + ' <a>{#1489}</a>'), 15000, { 598 clickFunc: function () { 599 barSmartLoadPage(barEncLink('/skd/?cmd=OfficialLetters>vcid=' + encodeURIComponent(src))); 600 }, 601 specialClass: 'bigger' 602 }); 603 } 604 if (item.id == 'poznamka') { 605 barShowMessageEx(renderS(ls(1309) + ' <a>{#1489}</a>'), 15000, { 606 clickFunc: function () { 607 barSmartLoadPage(barEncLink('/znamky/?what=PoznamkyTriedy>vcid=' + encodeURIComponent(src))); 608 }, 609 specialClass: 'bigger' 610 }); 611 } 612 } 613 }); 614 } 615 else if (type == 'reactdialog') { 616 if (item.actionUrl && handleActionUrl !== false) { 617 barSmartLoadPage(item.actionUrl, false, false, false, function () { 618 handleAction(item, false); 619 }); 620 return; 621 } 622 barNewReactSourceDlg(url, subaction, item.actionProps || {}); 623 } 624 } 625 function handleClick0(item, type) { 626 var _a; 627 var action = (_a = item.actions) === null || _a === void 0 ? void 0 : _a[0]; 628 if (type == 'reports') { 629 (0, agendareports_1.reportClickHandler)(item, item.box, {}); 630 unfocusMe(); 631 } 632 if (action === null || action === void 0 ? void 0 : action.link) { 633 barSmartLoadPage(action === null || action === void 0 ? void 0 : action.link); 634 unfocusMe(); 635 return; 636 } 637 if (action === null || action === void 0 ? void 0 : action.onClick) { 638 setTimeout(function () { 639 action.onClick(item, action); 640 unfocusMe(); 641 }, 50); 642 return; 643 } 644 if (item === null || item === void 0 ? void 0 : item.url) { 645 barSmartLoadPage(item === null || item === void 0 ? void 0 : item.url); 646 unfocusMe(); 647 return; 648 } 649 if (item.id == 'event' || item.id == 'calendar') { 650 $.post('/timeline/?cmd=creator&akcia=eventDlg', {}, function () { 651 }, 'script'); 652 return; 653 } 654 if (item.action) { 655 handleAction(item); 656 unfocusMe(); 657 return; 658 } 659 if (action) { 660 handleAction(action); 661 unfocusMe(); 662 } 663 } 664 function handleActionClick(e) { 665 var _a, _b; 666 var index = $(e.currentTarget).attr('data-index'); 667 var type = $(e.currentTarget).attr('data-type'); 668 var item = (_b = (_a = searchRes === null || searchRes === void 0 ? void 0 : searchRes[type]) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.item; 669 if (!item) 670 return; 671 var ind = parseInt($(e.currentTarget).attr('data-ind')); 672 var a = item.actions[ind]; 673 if (a.onClick) { 674 setTimeout(function () { 675 a.onClick(item, a); 676 unfocusMe(); 677 }, 50); 678 return; 679 } 680 if (a === null || a === void 0 ? void 0 : a.link) { 681 barSmartLoadPage(a === null || a === void 0 ? void 0 : a.link); 682 unfocusMe(); 683 return; 684 } 685 handleAction(a); 686 unfocusMe(); 687 } 688 function unfocusMe() { 689 setTimeout(function () { 690 if ($(mainElemRef.current).is(':focus-within')) { 691 $(document.activeElement).blur(); 692 } 693 }, 150); 694 } 695 function feedbackClick() { 696 barNewDialog({ 697 source: '/znamky/?jwgc=ZnamkyFeedbackDialog&forceRecipient=asc', 698 postData: { 699 feedbackText: ls(13620) + ': "' + searchQuery + '"' 700 } 701 }); 702 } 703 function sqblur() { 704 var t = searchQuery; 705 if (!t.trim()) 706 return; 707 if (sentSearches.current[t] && sentSearches.current[t] >= Date.now() - 30000) { 708 return; 709 } 710 sentSearches.current[t] = Date.now(); 711 AscHttp_1.AscHttp.rpc('/user/?cmd=Edusearch', 'searchText', { t: '' + t }, function () { 712 }, function () { 713 return true; 714 }, { showLoading: false }); 715 } 716 function tabClick(e) { 717 var tab = $(e.currentTarget).attr('data-tab'); 718 searchResForSq.current = ''; 719 agendaSearchResForSq.current = ''; 720 setSearchTab(tab); 721 $(mainElemRef.current).find('.edusearch-box').focus(); 722 } 723 var searchGroups0 = searchGroups === null || searchGroups === void 0 ? void 0 : searchGroups.slice(); 724 if (searchGroups0 && searchGroups0[1]["maxWordScore"] > searchGroups0[0]["maxWordScore"]) { 725 var pom = searchGroups0[0]; 726 searchGroups0[0] = searchGroups0[1]; 727 searchGroups0[1] = pom; 728 } 729 searchGroups0 = searchGroups0 === null || searchGroups0 === void 0 ? void 0 : searchGroups0.filter(function (grp) { var _a; return ((_a = searchRes === null || searchRes === void 0 ? void 0 : searchRes[grp.id]) === null || _a === void 0 ? void 0 : _a.length) > 0; }); 730 var searchPanels = []; 731 if (searchTab == 'agendaonline' && searchGroups0) { 732 searchPanels.push({ id: 'agendaonline', maxItems: 25 }); 733 searchGroups0.splice(0, 0, { 734 id: 'agendaonline', 735 name: ls(2548) + ' / ' + ls(8114), 736 items: agendaSearchRes 737 }); 738 } 739 else { 740 searchPanels.push({ id: 'other', maxItems: 5 }); 741 } 742 var tabs = [ 743 { id: 'modules', name: ls(2058) + ' / ' + ls(1532) }, 744 { id: 'agendaonline', name: ls(2548) + ' / ' + ls(8114) } 745 ]; 746 return (React.createElement("div", { ref: mainElemRef, className: 'edusearch-outer ' + (popupShown ? 'popupShown' : ''), onKeyDown: handleKeyDown }, 747 React.createElement("div", { className: 'edusearch-box-outer' }, 748 React.createElement("a", { className: 'app-link-button edusearch-box-searchbtn edusearch-box-inputbtn', onClick: searchClick, onKeyDown: AppReactUtils_1.AppReactUtils.
748keyPressAsClick(searchClick) }, 749 React.createElement("i", { className: 'fa fa-fw fa-search' })), 750 React.createElement("input", { className: 'edusearch-box', type: 'text', name: "searchQuery", value: searchQuery, onChange: searchQueryChange, onBlur: sqblur, placeholder: (searchTab == 'agendaonline' ? ls(14692) : ls(13612)) + ' (Ctrl + G)', onFocus: function () { return setWasFocused(true); }, autoComplete: "off" }), 751 searchQuery && (React.createElement("a", { className: 'app-link-button edusearch-box-clearbtn edusearch-box-inputbtn', onClick: clearClick, onKeyDown: AppReactUtils_1.AppReactUtils.keyPressAsClick(clearClick) }, 752 React.createElement("i", { className: 'fa fa-fw fa-close' })))), 753 popupShown && (React.createElement("div", { className: 'edusearch-popup-outer' + (searchPanels.length > 1 ? ' withPanels' : ''), tabIndex: 0 }, 754 React.createElement("div", { className: 'edusearch-popup-tabs' }, tabs.map(function (t) { 755 return (React.createElement("div", tslib_1.__assign({ className: 'edusearch-popup-tab ' + (t.id == searchTab ? 'selected' : '') }, AppReactUtils_1.AppReactUtils.addClickHandler(tabClick), { "data-tab": t.id, key: t.id }), t.name)); 756 })), 757 searchGroups 758 ? (React.createElement(React.Fragment, null, searchPanels.map(function (panel) { 759 var panelid = panel.id; 760 var numItemsTotal = 0; 761 var searchResForSq0 = panelid == 'agendaonline' ? agendaSearchResForSq.current : searchResForSq.current; 762 return (React.createElement("div", { key: panelid, className: 'edusearch-grp-panel ' + panelid }, 763 searchGroups0.filter(function (grp) { return panelid == 'other' ? grp.id != 'agendaonline' : grp.id == 'agendaonline'; }).map(function (grp) { 764 var items = (searchRes === null || searchRes === void 0 ? void 0 : searchRes[grp.id]) || []; 765 numItemsTotal += items.length; 766 if (items.length == 0) 767 return null; 768 var numMoreItems = 0; 769 if (items.length > panel.maxItems + 1 && !expandedGroups[grp.id]) { 770 numMoreItems = items.length - panel.maxItems; 771 items = items.slice(0, panel.maxItems); 772 } 773 return (React.createElement("div", { key: grp.id }, 774 React.createElement("div", { className: 'edusearch-group-title' }, 775 React.createElement("b", null, grp.name), 776 grp.id == 'agendaonline' && searchQuery && searchResForSq0 != searchQuery && (React.createElement(React.Fragment, null, 777 ' ', 778 React.createElement("i", { className: 'fa fa-spinner fa-spin' })))), 779 React.createElement("div", { className: 'edusearch-results-list' }, 780 items.map(function (r, ind) { 781 return React.createElement(EduSearchItem, { key: (r.table || "") + r.id + 'x' + ind, item: r.item || r, searchQuery: searchQuery, index: ind, type: grp.id, handleClick: handleClick, handleActionClick: handleActionClick }); 782 }), 783 numMoreItems > 0 && (React.createElement("div", { className: 'edusearch-result-item edusearch-focusable-item expandGroup', tabIndex: 0, onClick: expandGroupClick, onKeyDown: AppReactUtils_1.AppReactUtils.keyPressAsClick(expandGroupClick), "data-groupid": grp.id }, 784 React.createElement("div", { className: 'edusearch-result-item-icon' }, 785 React.createElement("i", { className: 'fa fa-fw fa-ellipsis-h' })), 786 React.createElement("div", { className: 'edusearch-result-item-main' }, 787 "+ ", 788 numMoreItems)))))); 789 }), 790 (numItemsTotal == 0) && (React.createElement(React.Fragment, null, 791 searchQuery && searchPanels.length > 1 && (React.createElement("div", { className: 'edusearch-group-title' }, 792 React.createElement("b", null, panelid == 'agendaonline' ? ls(8114) : ls(2058) + ' / ' + ls(1532)))), 793 React.createElement("div", { className: 'edusearch-empty-list' }, searchQuery && searchResForSq0 == searchQuery 794 ? ls(6562) 795 : searchQuery && searchResForSq0 != searchQuery 796 ? React.createElement(React.Fragment, null, 797 React.createElement("i", { className: 'fa fa-spinner fa-spin' }), 798 " ", 799 ls(3358)) 800 : searchTab == 'agendaonline' ? ls(14693) : ls(13613)))))); 801 }))) 802 : searchGroups && searchResForSq.current == searchQuery 803 ? (React.createElement("div", { className: 'edusearch-empty-list' }, ls(13613))) 804 : (React.createElement("div", { className: 'edusearch-empty-list' }, 805 React.createElement("i", { className: 'fa fa-fw fa-spinner fa-spin' }), 806 " ", 807 ls(3358))), 808 React.createElement("div", { className: 'edusearch-popup-footer' }, 809 React.createElement("span", null, ls(10389)), 810 React.createElement("a", { className: 'app-link-button
810normalCase normalWeight', tabIndex: 0, onClick: feedbackClick, onKeyDown: AppReactUtils_1.AppReactUtils.keyPressAsClick(feedbackClick) }, ls(14742)), 811 (searchData === null || searchData === void 0 ? void 0 : searchData.isAsc) && (React.createElement("a", { href: "/user/?cmd=Edusearch", className: 'app-link-button normalCase normalWeight edubarSmartLink', tabIndex: 0 }, "Search data (aSc)"))))))); 812} 813exports.EduSearchBox = EduSearchBox; 814function EduSearchItem(props) { 815 var _a, _b, _c, _d, _e, _f, _g; 816 var item = props.item; 817 (0, cache_1.useCacheRefresh)(); 818 function getHref() { 819 var _a; 820 var action = (_a = item.actions) === null || _a === void 0 ? void 0 : _a[0]; 821 if (action === null || action === void 0 ? void 0 : action.link) { 822 return action.link; 823 } 824 if (action === null || action === void 0 ? void 0 : action.onClick) { 825 return null; 826 } 827 if (item === null || item === void 0 ? void 0 : item.url) { 828 return item.url; 829 } 830 if (item.id == 'event' || item.id == 'calendar') { 831 return; 832 } 833 var actionStr = item.action || (action === null || action === void 0 ? void 0 : action.action); 834 var _b = (actionStr || "").split('::'), type = _b[0], url = _b[1], subaction = _b[2]; 835 if (type == 'href0' || type == 'hrefnew' || type == 'href') 836 return url; 837 if (type == 'help') { 838 var helpid = url; 839 return 'https://help.edupage.org/?' + (subaction ? 'id=' + helpid + '' : 'p=' + helpid); 840 } 841 return null; 842 } 843 var matchedColumns = (_a = item.matchColumns) === null || _a === void 0 ? void 0 : _a.filter(function (c) { return EdubarUtils.indexOf(['firstname', 'lastname', 'name'], c.id) < 0; }); 844 return (React.createElement("a", { className: 'edusearch-result-item edusearch-focusable-item ' + props.type, href: getHref(), tabIndex: 0, "data-type": props.type, "data-index": props.index, onClick: props.handleClick, onKeyDown: AppReactUtils_1.AppReactUtils.keyPressAsClick(props.handleClick) }, 845 React.createElement("div", { className: 'edusearch-result-item-icon' }, item.table 846 ? (React.createElement("img", { src: ((_b = (0, clientcache_1.cachedDBI_getTableDef)(edurequest_1.client_req, 'maindbi', item.table, {})) === null || _b === void 0 ? void 0 : _b.icon) || '/app/pics/icons/sidemenu/student.svg', alt: "" })) 847 : item.iconClass 848 ? React.createElement("div", { className: "edusearch-result-item-icon1 " + item.iconClass }) 849 : item.usericontyp 850 ? React.createElement("div", { className: "edusearch-result-item-icon1 usericon-" + item.usericontyp }) 851 : props.type == 'dbi:teachers' 852 ? React.createElement("img", { src: "/app/pics/icons/sidemenu/teacher.svg", alt: "" }) 853 : props.type == 'dbi:studentkopias' 854 ? React.createElement("img", { src: "/app/pics/icons/sidemenu/student.svg", alt: "" }) 855 : item.img 856 ? React.createElement("img", { src: item.img, alt: "" }) 857 : props.type == 'helps' 858 ? React.createElement("i", { className: 'fa fa-fw fa-question-circle-o' }) 859 : props.type == 'reports' 860 ? React.createElement("i", { className: 'fa fa-fw fa-file-pdf-o edusearch-icon-' + (item.isLocal ? 'blue' : 'red') }) 861 : props.type == 'actions' 862 ? React.createElement("img", { src: "/user/pics/runcmd.svg", alt: "" }) 863 : React.createElement("i", { className: 'fa fa-fw fa-chevron-circle-right' })), 864 React.createElement("div", { className: 'edusearch-result-item-main' }, 865 React.createElement("div", null, 866 React.createElement(HighlightMatch, { value: item.name, searchQuery: props.searchQuery })), 867 false && item.group && React.createElement("div", { className: 'edusearch-result-item-group' }, item.group), 868 matchedColumns && matchedColumns.length > 0 && (React.createElement("div", { className: 'edusearch-result-item-group edusearch-matched-cols' }, matchedColumns.map(function (c) { 869 return (React.createElement("span", { key: c.id, className: 'edusearch-matched-col' }, 870 c.name, 871 ": ", 872 React.createElement(HighlightMatch, { value: c.text, searchQuery: props.searchQuery }))); 873 }))), 874 item.info ? React.createElement("div", { className: 'edusearch-result-item-group' }, item.info) : React.createElement("div", { className: 'edusearch-result-item-group' }, item.description), 875 false && item.keywords && ((_c = item.actions) === null || _c === void 0 ? void 0 : _c.length) <= 1 && React.createElement("div", { className: 'edusearch-result-item-group' }, item.keywords.join('; ')), 876 (((_d = item.actions) === null || _d === void 0 ? void 0 : _d.length) > 1 || (((_e = item.actions) === null || _e === void 0 ? void 0 : _e.length) > 0 && ((_f = item.actions[0]) === null || _f === void 0 ? void 0 : _f.name))) && (React.createElement("div", { className: 'edusearch-result-item-actions' }, (_g = item.actions) === null || _g === void 0 ? void 0 : _g.map(function (a, ind) { 877 return (React.createElement("div", { key: ind, onClick: props.handleActionClick, "data-ind": ind, "data-type": props.type, "data-index": props.index, className: 'app-link-button smallPadding normalCase normalWeight edusearch-focusable-item', tabIndex: 0, onKeyDown: AppReactUtils_1.AppReactUtils.
877keyPressAsClick(props.handleActionClick) }, a.name)); 878 })))))); 879} 880exports.EduSearchItem = EduSearchItem; 881function HighlightMatch(props) { 882 var value = props.value, searchQuery = props.searchQuery; 883 var value0 = (value || "").latinise().toLowerCase().replace(/[\.,"']/gi, ' '); 884 var sq = (searchQuery || "").latinise().toLowerCase().replace(/[\.,"']/gi, ' ').trim(); 885 var parts = value0.split(new RegExp('(' + sq.replace(/[.*+?^${ }()|[\]\\]/g, '\\$&') + ')', 'gi')); 886 var lastInd = 0; 887 return (React.createElement(React.Fragment, null, parts === null || parts === void 0 ? void 0 : parts.map(function (r, ind) { 888 var s0 = value.substring(lastInd, lastInd + r.length); 889 lastInd = lastInd + r.length; 890 return (React.createElement("span", { className: r == sq ? "edusearch-match" : '', key: ind }, s0)); 891 }))); 892} 893exports.HighlightMatch = HighlightMatch;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.