1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.client_req = exports.EduRequest_Client = exports.EduRequest = void 0; 4var tslib_1 = require("tslib"); 5var lib_date_1 = require("./lib_date"); 6var EduRequest = (function () { 7 function EduRequest() { 8 this.props = null; 9 this.edupage = ''; 10 this.lang = ''; 11 this.firstDayOfWeek = 1; 12 this.weekendDays = []; 13 this.school_country = ''; 14 this.school_state = ''; 15 this.schoolyear_turnover = ''; 16 this.custom_turnover = {}; 17 this.loggedUser = ''; 18 this.loggedUserRights = []; 19 this.sort_name_col = 'FSL'; 20 this.edupageLangs = null; 21 this.ttlangasc = null; 22 this.aiLangs = {}; 23 this._memoize_cache = new Map(); 24 this.yield_time = 0; 25 } 26 EduRequest.prototype.initRequest = function (props) { 27 this.props = props; 28 for (var _i = 0, _a = [ 29 'edupage', 30 'lang', 31 'firstDayOfWeek', 32 'weekendDays', 33 'school_country', 34 'school_state', 35 'schoolyear_turnover', 36 'custom_turnover', 37 'loggedUser', 38 'loggedUserRights', 39 'parent_studentid', 40 'sort_name_col', 41 'jsmodulemode', 42 ]; _i < _a.length; _i++) { 43 var c = _a[_i]; 44 var v = props[c]; 45 if (v !== undefined) 46 this[c] = v; 47 } 48 }; 49 EduRequest.prototype.getSchoolYear = function (date) { 50 if (date === void 0) { date = this.timezone_date(); } 51 if (!date || !this.schoolyear_turnover) 52 ASC.dieError('8130146806'); 53 var year = parseInt(date.substr(0, 4)); 54 if (date < this.schoolYear_turnOver(year)) 55 year--; 56 return year; 57 }; 58 EduRequest.prototype.getSchoolYear_auto = function () {
59 return this.props.year_auto || this.getSchoolYear(); 60 }; 61 EduRequest.prototype.getSchoolYear_auto_date = function () { 62 return this.props.year_auto_date || this.timezone_date(); 63 }; 64 EduRequest.prototype.getSchoolYearName = function (year) { 65 if (!year) 66 return ''; 67 if (this.schoolYear_turnOver(year + 1) <= (year + 1) + '-02-01') 68 return '' + year; 69 else 70 return year + '/' + (year + 1); 71 }; 72 EduRequest.prototype.schoolYear_turnOver = function (year) { 73 return this.custom_turnover[year] || (year + '-' + this.schoolyear_turnover); 74 }; 75 EduRequest.prototype.schoolYear_turnOver_end = function (year) { 76 return (0, lib_date_1.date_delta)(this.schoolYear_turnOver(year + 1), -1); 77 }; 78 EduRequest.prototype.isAdmin = function () { 79 return this.loggedUser == 'Admin'; 80 }; 81 EduRequest.prototype.isUcitel = function () { 82 if (this.loggedUser.substr(0, 6) == 'Ucitel') 83 return this.loggedUser.substr(6); 84 return ''; 85 }; 86 EduRequest.prototype.isStudent = function () { 87 if (this.loggedUser.substr(0, 7) == 'Student') 88 return this.loggedUser.substr(7); 89 return ''; 90 }; 91 EduRequest.prototype.isStudentOrParent = function () { 92 return this.isStudent() || this.props.parent_studentid || ''; 93 }; 94 EduRequest.prototype.isParent = function () { 95 if (this.loggedUser.substr(0, 5) == 'Rodic') 96 return this.loggedUser.substr(5); 97 return ''; 98 }; 99 EduRequest.prototype.isGuest = function () { 100 if (this.loggedUser.substr(0, 5) == 'Guest') 101 return this.loggedUser.substr(5); 102 return ''; 103 }; 104 EduRequest.prototype.isAscAdmin = function () { 105 return !!this.props.ascadmin; 106 }; 107 EduRequest.prototype.isAscDebug = function () { 108 return !!this.props.ascdebug; 109 }; 110 EduRequest.prototype.isDevelopEdupage = function (mode) { 111 if (mode === void 0) { mode = ''; } 112 var d = this.props.ascdevelop; 113 if (!d) 114 return false; 115 switch (mode) { 116 case '': return true; 117 case 'junior': return !!d.junior; 118 case 'senior': return !d.junior; 119 } 120 ASC.dieError('8779618679', mode); 121 }; 122 EduRequest.prototype.isAscDevelop = function () { 123 return this.isDevelopEdupage(); 124 }; 125 EduRequest.prototype.isApp = function () { 126 return !!this.props.app; 127 }; 128 EduRequest.prototype.hasRight = function (right) { 129 if (this.isAdmin()) { 130 return !['limited'].includes(right); 131 } 132 return this.loggedUserRights.includes(right); 133 }; 134 EduRequest.prototype.jeZUS = function () { 135 return !!this.props.jeZUS; 136 }; 137 EduRequest.prototype.jeSUS = function () { 138 return !!this.props.jeSUS; 139 }; 140 EduRequest.prototype.jeSportovyKlub = function () { 141 return !!this.props.jeSportovyKlub; 142 }; 143 EduRequest.prototype.jeCVC = function () { 144 return !!this.props.jeCVC; 145 }; 146 EduRequest.prototype.jeMS = function () { 147 return !!this.props.jeMS; 148 }; 149 EduRequest.prototype.isAgenda = function () { 150 return !!this.props.isAgenda; 151 }; 152 EduRequest.prototype.jeFirma = function () { 153 return !!this.props.jeFirma; 154 }; 155 EduRequest.prototype.jeNemeckaSkolaSkdFirma = function () { 156 return !!this.props.jeNemeckaSkolaSkdFirma; 157 }; 158 EduRequest.prototype.isCustomer = function () { 159 return !!this.props.isCustomer; 160 }; 161 EduRequest.prototype.uiError = function (errNumber, msg, info) { 162 if (typeof msg !== 'string') 163 ASC.dieError('8358216710'); 164 console.error('Error', errNumber); 165 if (msg) 166 console.log(msg); 167 if (info !== undefined) 168 console.log(info); 169 var e = new Error('' + errNumber); 170 e['errNumber'] = errNumber; 171 e['msg'] = msg; 172 throw e; 173 }; 174 EduRequest.prototype.ls = function (i) { 175 if (this.edupageLangs && this.edupageLangs[i]) { 176 return this.edupageLangs[i]; 177 } 178 return ASC.ls(i); 179 }; 180 EduRequest.prototype.lsf = function (i, replace) { 181 if (this.edupageLangs && this.edupageLangs[i]) { 182 i = this.edupageLangs[i]; 183 } 184 if (!ASC.lang && this.lang) { 185 ASC.lang = this.lang; 186 } 187 return ASC.lsf(i, replace); 188 }; 189 EduRequest.prototype.ttls = function (i) { 190 if (this.ttlangasc && this.ttlangasc[i]) { 191 return this.ttlangasc[i]; 192 } 193 return ASC.ttls(i); 194 }; 195 EduRequest.prototype.ttlsf = function (i, replace) { 196 var s = this.ttls(i); 197 for (var k in replace) { 198 s = s.replace('%' + k, replace[k]); 199 } 200 return s; 201 }; 202 EduRequest.prototype.uls = function (i, lf) { 203 switch (lf) { 204 case 'tt': return this.ttls(i); 205 } 206 return this.ls(i); 207 }; 208 EduRequest.prototype.localize = function (s) { 209 for (var i = 0; i < 10; i++) { 210 var m = /\{(?:|([a-z]{2}):)([0-9]{4,5})\}/g.exec(s); 211 if (!m) 212 break; 213 s = s.replace(m[0], this.uls(parseInt(m[2]), m[1])); 214 } 215 return s; 216 }; 217 EduRequest.prototype.ails = function (s, params) { 218 if (!s) 219 ASC.dieError('1993235492', s); 220 var t = this.aiLangs[s]; 221 if (!t) { 222 t = s.split('|')[0]; 223 if (t[2] == ':') 224 t = t.slice(3); 225 } 226 if (!t) 227 ASC.dieError('3849862994', [s, t]); 228 if (t.includes('{')) { 229 if (params) { 230 t = t.replace(/\{([a-zA-Z0-9_]+)\}/g, function (match, field) { 231 var val = params[field]; 232 return (val === undefined || val === null) ? match : String(val); 233 }); 234 } 235 } 236 return t; 237 }; 238 EduRequest.prototype.timezone_date = function (time) { 239 if (time === void 0) { time = undefined; } 240 return this.timezone_datetime(time).substr(0, 10); 241 }; 242 EduRequest.prototype.timezone_datetime = function (time) { 243 if (time === void 0) { time = undefined; } 244 var d = typeof time == 'number' ? new Date(time * 1000) : new Date(); 245 var parts; 246 try { 247 var df = new Intl.DateTimeFormat('en-US', { 248 year: 'numeric', 249 month: 'numeric', 250 day: 'numeric', 251 hour: 'numeric', 252 minute: 'numeric', 253 second: 'numeric', 254 hour12: false, 255 timeZone: this.props.ttdemo_user ? undefined : this.props.timezone, 256 }); 257 var s = df.format(d); 258 parts = /(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)/.exec(s); 259 parts[4] %= 24; 260 } 261 catch (e) { 262 parts = [ 263 0, 264 d.getMonth() + 1, 265 d.getDate(), 266 d.getFullYear(), 267 d.getHours(), 268 d.getMinutes(), 269 d.getSeconds() 270 ]; 271 } 272 function zpl(i, len) { 273 var s = '' + parts[i]; 274 while (s.length < len) 275 s = '0' + s; 276 return s; 277 } 278 return zpl(3, 4) + '-' 279 + zpl(1, 2) + '-' 280 + zpl(2, 2) 281 + ' ' 282 + zpl(4, 2) + ':' 283 + zpl(5, 2) + ':' 284 + zpl(6, 2); 285 }; 286 EduRequest.prototype.timezone_datetime2int = function (datetime) { 287 return Math.floor((0, lib_date_1.datetime_sql2js)(datetime).getTime() / 1000); 288 }; 289 EduRequest.prototype.substdbi = function (dbid, options) { 290 if (options === void 0) { options = {}; } 291 return tslib_1.__awaiter(this, void 0, Promise, function () { 292 var _this = this; 293 return tslib_1.__generator(this, function (_a) { 294 switch (_a.label) { 295 case 0: return [4, Promise.resolve().then(function () { return require("../rpr/dbi"); })]; 296 case 1: return [2, (_a.sent()).ClientDBI.newInstance(this, function (args) { return tslib_1.__awaiter(_this, void 0, void 0, function () { 297 return tslib_1.__generator(this, function (_a) { 298 switch (_a.label) { 299 case 0: return [4, Promise.resolve().then(function () { return require("../substitution/server/substdbi"); })]; 300 case 1: return [2, (_a.sent()).substDBIAccessor(null, dbid, args)]; 301 } 302 }); 303 }); }, options)]; 304 } 305 }); 306 }); 307 }; 308 EduRequest.prototype.ttuidocdbi = function (ttgpid, options) { 309 if (options === void 0) { options = {}; } 310 return tslib_1.__awaiter(this, void 0, Promise, function () { 311 var _this = this; 312 return tslib_1.__generator(this, function (_a) { 313 switch (_a.label) { 314 case 0: return [4, Promise.resolve().then(function () { return require("../rpr/dbi"); })]; 315 case 1: return [2, (_a.sent()).ClientDBI.newInstance(this, function (args) { return tslib_1.__awaiter(_this, void 0, void 0, function () { 316 return tslib_1.__generator(this, function (_a) { 317 switch (_a.label) { 318 case 0: return [4, Promise.resolve().then(function () { return require("../timetable/app/server/ttdoc"); })]; 319 case 1: return [2, (_a.sent()).ttuidocDBIAccessor(null, ttgpid, args)]; 320 } 321 }); 322 }); }, options)]; 323 } 324 }); 325 }); 326 }; 327 EduRequest.prototype.memoize = function (key, supplier) { 328 var vp = this._memoize_cache.get(key); 329 if (!vp) { 330 vp = supplier(); 331 this._memoize_cache.set(key, vp); 332 } 333 return vp; 334 }; 335 EduRequest.prototype.waitSuspense = function (func) { 336 return tslib_1.__awaiter(this, void 0, Promise, function () { 337 var e_1; 338 return tslib_1.__generator(this, function (_a) { 339 switch (_a.label) { 340 case 0: 341 _a.trys.push([0, 1, , 3]); 342 return [2, func()]; 343 case 1: 344 e_1 = _a.sent(); 345 if (typeof (e_1 === null || e_1 === void 0 ? void 0 : e_1.then) != 'function') 346 throw e_1; 347 return [4, e_1]; 348 case 2: 349 _a.sent(); 350 return [3, 3]; 351 case 3: return [3, 0]; 352 case 4: return [2]; 353 } 354 }); 355 }); 356 }; 357 EduRequest.prototype.suspendCall = function (func) { 358 return Promise.resolve().then(func); 359 }; 360 EduRequest.prototype.yield = function () { 361 return tslib_1.__awaiter(this, void 0, void 0, function () { 362 var t; 363 return tslib_1.__generator(this, function (_a) { 364 switch (_a.label) { 365 case 0: 366 t = Date.now(); 367 if (!this.yield_time) { 368 this.yield_time = t + Math.round(40 + Math.random() * 10); 369 } 370 if (t < this.yield_time) 371 return [2]; 372 this.yield_time = 0; 373 return [4, new Promise(function (resolve) { return setTimeout(resolve, 4 + Math.random() * 2); })]; 374 case 1: 375 _a.sent(); 376 return [2]; 377 } 378 }); 379 }); 380 }; 381 return EduRequest; 382}()); 383exports.EduRequest = EduRequest; 384var EduRequest_Client = (function (_super) { 385 tslib_1.__extends(EduRequest_Client, _super); 386 function EduRequest_Client() { 387 var _this = this; 388 var _a; 389 _this = _super.call(this) || this; 390 _this.lib_date = new lib_date_1.Lib_date(_this); 391 var req_props = ASC.req_props; 392 _super.prototype.initRequest.call(_this, req_props || {}); 393 if (!req_props) { 394 if (window && !((_a = window.MobileAppBridge) === null || _a === void 0 ? void 0 : _a.isActive())) { 395 ASC.sendErrorJS('9883465806', new Error().stack); 396 } 397 } 398 return _this; 399 } 400 EduRequest_Client.prototype.maindbi = function (year, options) { 401 var _a; 402 return tslib_1.__awaiter(this, void 0, Promise, function () { 403 return tslib_1.__generator(this, function (_b) { 404 switch (_b.label) { 405 case 0: return [4, Promise.resolve().then(function () { return require('../rpr/clientcache'); })]; 406 case 1: return [2, (_b.sent()).cachedDBI_async(this, 'maindbi', ASC.strVal(year), tslib_1.__assign(tslib_1.__assign({}, options), { cache: (_a = options.cache) !== null && _a !== void 0 ? _a : false }))]; 407 } 408 }); 409 }); 410 }; 411 EduRequest_Client.prototype.timetabledbi = function (num, options) { 412 if (options === void 0) { options = {}; } 413 return tslib_1.__awaiter(this, void 0, Promise, function () { 414 return tslib_1.__generator(this, function (_a) { 415 switch (_a.label) { 416 case 0: return [4, Promise.resolve().then(function () { return require('../rpr/clientcache'); })]; 417 case 1: return [2, (_a.sent()).cachedDBI_async(this, 'ttdbi', num, options)]; 418 } 419 }); 420 }); 421 }; 422 return EduRequest_Client; 423}(EduRequest)); 424exports.EduRequest_Client = EduRequest_Client; 425exports.client_req = new EduRequest_Client(); 426ASC.req = exports.client_req;
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.