PageSourceSearch

https://bakaweb.gekom.cz/core/lib/bakalari/code/CommonFunctions.js…k7GYJjnttz5HAJ6H4H43GaYbNT0ayewkC0B40vGnwhs

js gekom.cz collected 2026-10-06 08:54:10 UTC 8,896 bytes, 213 lines download raw bytes

1/**
2* IMPORTANT: This file has been generated by babel, do not modify it by hand! All changes you made will be lost!
3**/
4function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
5function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
8function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
9function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10function notification(type, text, timeout, layout) {
11  var noty = new Noty();
12
13  // Výchozí hodnoty
14  noty.options["type"] = "warning"; // [alert, success, warning, info, error, ]
15  noty.options["layout"] = "topCenter"; // [top, topLeft, topCenter, topRight, center, centerLeft, centerRight, bottom, bottomLeft, bottomCenter, bottomRight]
16  noty.options["theme"] = "baka"; // [relax, mint, metroui, baka]
17  noty.options["text"] = "Text is not set";
18  noty.options["timeout"] = 7000; // [5000, false]
19  noty.options["closeWith"] = ["click", "button"]; // [click, button]
20
21  config = new Array();
22  config["text"] = text;
23  config["type"] = type;
24  config["layout"] = layout;
25  config["timeout"] = timeout;
26  for (index in config) {
27    noty.options[index] = config[index] !== undefined ? config[index] : noty.options[index];
28  }
29  noty.show();
30
31  // Rozmazaný text text css property TRANSFORM (horizontal center), proto je řešení v js
32  var container = $(".noty_bar[id=" + noty.id + "]").parent();
33  function viewportRealWidth() {
34    var e = window,
35      a = "inner";
36    if (!("innerWidth" in window)) {
37      a = "client";
38      e = document.documentElement || document.body;
39    }
40    return {
41      width: e[a + "Width"]
42    };
43  }
44  var res = (parseInt(viewportRealWidth().width) / 2 - parseInt(container.width()) / 2) / parseInt(viewportRealWidth().width) * 100;
45  container.css("left", res + "%");
46}
47function beforeLinkAdd() {
48  var range = document.createRange();
49  var selection = document.getSelection();
50  var caretPosition = selection.anchorOffset;
51  var focusNode = document.getSelection().focusNode;
52  if (!focusNode) return;
53  if (selection.toString().length !== 0) return;
54  var referenceNode = focusNode.parentNode;
55  if (!referenceNode.innerText) return;
56  var endNode = referenceNode.childNodes[0];
57  var carretRange = document.getSelection().getRangeAt(0);
58  var parentNode = carretRange.commonAncestorContainer.parentNode.tagName;
59  var wholeText = carretRange.endContainer.wholeText;
60  if (!wholeText) return;
61  endNode = Array.from(referenceNode.childNodes).find(function (node) {
62    return node.wholeText === wholeText || node.innerText === wholeText;
63  });
64  if (!endNode) return;
65  while (endNode.childNodes.length) {
66    endNode = endNode.childNodes[0];
67  }
68  var fullRange = wholeText.toString().length;
69  var matches = _toConsumableArray(wholeText.matchAll(/ /g));
70  var indexes = matches.map(function (match, idx) {
71    return match.index;
72  });
73  var extendedIndexes = indexes.map(function (l) {
74    return l += 1;
75  }).concat(indexes).sort();
76  var allIndexes = indexes.indexOf(0) !== -1 ? [].concat(_toConsumableArray(extendedIndexes), [fullRange]) : [0].concat(_toConsumableArray(extendedIndexes), [fullRange]);
77  allIndexes.push(caretPosition);
78  allIndexes = allIndexes.sort(function (a, b) {
79    return a - b;
80  });
81  var positionIndex = allIndexes.indexOf(caretPosition);
82  var ranges = [allIndexes[positionIndex - 1], allIndexes[positionIndex + 1]];
83  if (!indexes.length) {
84    ranges = [0, wholeText.length];
85  }
86  if (parentNode === "A") {
87    range.selectNodeContents(endNode);
88  } else {
89    if (ranges[1] - ranges[0] < 2) return;
90    range.setStart(endNode, ranges[0]);
91    range.setEnd(endNode, ranges[1]);
92  }
93  selection.removeAllRanges();
94  selection.addRange(range);
95}
96function makeJSDayModel(dayObject) {
97  //Pre ucely převzetí svátků a dnů volna ze suplování
98  //Ak chyba TimesType
99  if (!dayObject || !dayObject.TimesType && dayObject.TimesType !== 0) {
100    return {
101      TimesType: BakaEnums.DayTimeType.WholeDay,
102      Times: "Celý den",
103      RepetitionType: BakaEnums.RepetitionType.NoRepetition
104    };
105  }
106  var newDayModel = new DayModel();
107  newDayModel.TimesType = dayObject.TimesType;
108  newDayModel.FromTime = dayObject.FromTime;
109  newDayModel.ToTime = dayObject.ToTime;
110  newDayModel.HasBreak = dayObject.HasBreak;
111  newDayModel.BreakStartTime = dayObject.BreakStartTime;
112  newDayModel.BreakEndTime = dayObject.BreakEndTime;
113  newDayModel.FromLessons = dayObject.FromLessons;
114  newDayModel.ToLessons = dayObject.ToLessons;
115  newDayModel.BreakFromLessons = dayObject.BreakFromLessons;
116  newDayModel.BreakToLessons = dayObject.BreakToLessons;
117  newDayModel.IsFromMidnight = dayObject.IsFromMidnight;
118  newDayModel.IsUntilMidnight = dayObject.IsUntilMidnight;
119  convertDayDatesToJSObjects(newDayModel);
120  return newDayModel;
121}
122
123// Konfigurace xss filtru pro popis akce a poznámky. Stavíme nad ověřenou knihovnou xss
124// (https://github.com/leizongmin/js-xss) — defaultní whitelist nepovoluje style ani class,
125// takže by se ztratilo formátování z editoru. Doplňujeme proto:
126//   - atribut style jen na blokových tazích, které DevExtreme HtmlEditor reálně generuje,
127//   - class na blokových tazích a její hodnotu ořezáváme jen na známé Quill třídy
128//     (ql-align-* pro zarovnání, ql-indent-* pro nestování seznamů),
129//   - povolené CSS vlastnosti omezujeme přes css.whiteList — všechno ostatní (position,
130//     transform, animation, expression(), url(...) apod.) cssFilter v xss.js zahodí.
131var DESCRIPTION_XSS_OPTIONS = function () {
132  if (typeof filterXSS === "undefined" || !filterXSS.whiteList) return undefined;
133  var blockTagsWithStyle = ["p", "div", "span", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "pre", "li", "img"];
134  var tagsWithClass = ["p", "li", "ol", "ul"];
135  var whiteList = {};
136  for (var tag in filterXSS.whiteList) {
137    whiteList[tag] = filterXSS.whiteList[tag].slice();
138    if (blockTagsWithStyle.indexOf(tag) >= 0) {
139      whiteList[tag].push("style");
140    }
141    if (tagsWithClass.indexOf(tag) >= 0) {
142      whiteList[tag].push("class");
143    }
144  }
145  var quillFormatClassRegex = /^ql-(align-(left|center|right|justify)|indent-[1-9])$/;
146  return {
147    whiteList: whiteList,
148    css: {
149      whiteList: {
150        "text-align": true,
151        "color": true,
152        "background-color": true,
153        "font-weight": true,
154        "font-style": true,
155        "text-decoration": true,
156        "padding-left": true,
157        "margin-left": true,
158        "width": true,
159        "height": true
160      }
161    },
162    onTagAttr: function onTagAttr(tag, name, value, isWhiteAttr) {
163      if (name === "class") {
164        var safe = String(value).split(/\s+/).filter(function (c) {
165          return quillFormatClassRegex.test(c);
166        }).join(" ");
167        return safe ? 'class="' + safe + '"' : "";
168      }
169    }
170  };
171}();
172function addProtocolToHREF(str) {
173  var newString = str.replaceAll(/href="(.*?)"/g, function (m, $link) {
174    if (!($link.indexOf("http") !== -1)) {
175      return "href=\"https://".concat($link, "\"");
176    }
177    return "href=\"".concat($link, "\"");
178  });
179  return filterXSS(newString, DESCRIPTION_XSS_OPTIONS);
180}
181function getHtmlEditorContent() {
182  function replaceEditorText() {
183    var text = $(".ql-editor");
184    if (!text) return;
185    var html = text[0].innerHTML;
186    var newHtml = addProtocolToHREF(html);
187    if (html === newHtml) return;
188    text.html(newHtml);
189  }
190  $(".dx-popup-normal .dx-toolbar-after .dx-button").click(function (e) {
191    replaceEditorText();
192  });
193  $(".dx-formdialog-form.dx-form").on("keyup", function (e) {
194    if (e.keyCode === 13) {
195      replaceEditorText();
196    }
197  });
198}
199CommonFunctions = {
200  debounce: function debounce(func, wait) {
201    var timeout;
202    return function () {
203      var _this = this;
204      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
205        args[_key] = arguments[_key];
206      }
207      clearTimeout(timeout);
208      timeout = setTimeout(function () {
209        return func.apply(_this, args);
210      }, wait);
211    };
212  }
213};

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.