123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428 |
- var MATERIAL_CATEGORY;
- (function (MATERIAL_CATEGORY) {
- MATERIAL_CATEGORY["MATERIAL"] = "\u043C\u0430\u0442\u0435\u0440\u0438\u0430\u043B";
- MATERIAL_CATEGORY["NEWS"] = "\u043D\u043E\u0432\u043E\u0441\u0442\u044C";
- MATERIAL_CATEGORY["NOTICE"] = "\u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D\u0438\u0435";
- })(MATERIAL_CATEGORY || (MATERIAL_CATEGORY = {}));
- var MENU_CATEGORY;
- (function (MENU_CATEGORY) {
- MENU_CATEGORY["MAIN"] = "__main";
- MENU_CATEGORY["TOP"] = "__top";
- })(MENU_CATEGORY || (MENU_CATEGORY = {}));
- var CLIENT_PLATFORM;
- (function (CLIENT_PLATFORM) {
- CLIENT_PLATFORM[CLIENT_PLATFORM["DESKTOP"] = 9999] = "DESKTOP";
- CLIENT_PLATFORM[CLIENT_PLATFORM["OLD_DESKTOP"] = 1280] = "OLD_DESKTOP";
- CLIENT_PLATFORM[CLIENT_PLATFORM["TABLET"] = 1024] = "TABLET";
- CLIENT_PLATFORM[CLIENT_PLATFORM["MOBILE"] = 560] = "MOBILE";
- })(CLIENT_PLATFORM || (CLIENT_PLATFORM = {}));
- var VKKO;
- (function (VKKO) {
- var Setting;
- (function (Setting) {
- var __BlockingScrollCount = 0;
- Setting.Platform = CLIENT_PLATFORM.DESKTOP;
- function BlockScroll() {
- document.documentElement.style.marginRight = window.innerWidth - document.documentElement.clientWidth + "px";
- document.documentElement.style.overflow = "hidden";
- __BlockingScrollCount++;
- }
- Setting.BlockScroll = BlockScroll;
- ;
- function UnblockScroll() {
- __BlockingScrollCount--;
- if (__BlockingScrollCount <= 0) {
- document.documentElement.style.overflow = "";
- document.documentElement.style.marginRight = null;
- __BlockingScrollCount = 0;
- }
- }
- Setting.UnblockScroll = UnblockScroll;
- ;
- })(Setting = VKKO.Setting || (VKKO.Setting = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var Utils;
- (function (Utils) {
- function logError(message) {
- console.log("%c ERROR ", "background-color: red; color: white; font-weight: 700;", message);
- }
- Utils.logError = logError;
- function logWarning(message) {
- console.log("%c WARNING ", "background-color: orange; color: white; font-weight: 700;", message);
- }
- Utils.logWarning = logWarning;
- function logInfo(message) {
- console.log("%c INFO ", "background-color: green; color: white; font-weight: 700;", message);
- }
- Utils.logInfo = logInfo;
- function GenerateHash256(uppercase) {
- if (uppercase === void 0) { uppercase = false; }
- var randomValue = crypto.getRandomValues(new Uint32Array(4));
- var randomHash = "";
- for (var i = 0; i < randomValue.length; i++) {
- randomHash += randomValue[i].toString(16);
- }
- if (uppercase === true) {
- return randomHash.toUpperCase();
- }
- return randomHash;
- }
- Utils.GenerateHash256 = GenerateHash256;
- ;
- function GenerateHashDashed(group) {
- if (group === void 0) { group = 4; }
- var randomValue = crypto.getRandomValues(new Uint32Array(group));
- var randomHash = "";
- for (var i = 0; i < randomValue.length; i++) {
- randomHash += randomValue[i].toString(16) + "-";
- }
- return randomHash.slice(0, randomHash.length - 1).toUpperCase();
- }
- Utils.GenerateHashDashed = GenerateHashDashed;
- ;
- })(Utils = VKKO.Utils || (VKKO.Utils = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var Messenger = (function () {
- function Messenger() {
- this.HARDREMOVE_TIME = 100;
- this.AUTOREMOVE_TIME = 2000;
- this.REMOVING_SHORT = "short";
- this.REMOVING_LONG = "long";
- this.MESSAGE_COUNTER = -1;
- this.__MessageContainer = document.querySelector("#MessengerBox");
- if (!this.__MessageContainer) {
- this.__MessageContainer = document.createElement("div");
- this.__MessageContainer.classList.add("messenger");
- this.__MessageContainer.id = "MessengerBox";
- document.body.append(this.__MessageContainer);
- }
- }
- Messenger.prototype.removeMessage = function (time, transition) {
- if (time === void 0) { time = this.HARDREMOVE_TIME; }
- if (transition === void 0) { transition = this.REMOVING_SHORT; }
- if (this instanceof HTMLElement) {
- this.classList.add("removing", transition);
- setTimeout(function (element) {
- element.remove();
- }, time, this);
- }
- else {
- VKKO.Utils.logError("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435, \u0442.\u043A. \u0435\u0433\u043E \u0442\u0438\u043F \u043D\u0435 HTMLElement");
- }
- };
- Messenger.prototype.autoRemoveMessage = function (element) {
- this.removeMessage.call(element, this.AUTOREMOVE_TIME, this.REMOVING_SHORT);
- };
- Messenger.prototype.Show = function (msg, time) {
- if (time === void 0) { time = 10000; }
- var message = document.createElement("div");
- message.id = "MessageTick" + ++this.MESSAGE_COUNTER;
- message.classList.add("in");
- var content = document.createElement("div");
- content.textContent = msg;
- var close = document.createElement("span");
- close.classList.add("close");
- close.onclick = this.removeMessage.bind(message);
- message.append(close, content);
- this.__MessageContainer.append(message);
- setTimeout(function () {
- message.classList.remove("in");
- }, 100);
- setTimeout(this.autoRemoveMessage.bind(this, message), time);
- };
- return Messenger;
- }());
- VKKO.Messenger = Messenger;
- })(VKKO || (VKKO = {}));
- var VKKOWork;
- (function (VKKOWork) {
- VKKOWork.Messenger = new VKKO.Messenger();
- })(VKKOWork || (VKKOWork = {}));
- var VKKO;
- (function (VKKO) {
- var XHR = (function () {
- function XHR() {
- this.__QueryCounter = 0;
- this.__LoadAnimationElement = document.querySelector("#LoadingAnimation");
- if (!this.__LoadAnimationElement) {
- this.__LoadAnimationElement = document.createElement("div");
- this.__LoadAnimationElement.id = "LoadingAnimation";
- this.__LoadAnimationElement.className = "loading hidden";
- for (var i = 0; i < 7; i++) {
- var element = document.createElement("div");
- element.className = "glob";
- element.setAttribute("style", "--i:" + (i + 1));
- this.__LoadAnimationElement.append(element);
- }
- document.body.append(this.__LoadAnimationElement);
- }
- }
- XHR.prototype.onStartRequest = function (event) {
- if (this.__QueryCounter === 0) {
- this.__LoadAnimationElement.classList.remove("hidden");
- }
- this.__QueryCounter++;
- };
- XHR.prototype.onStopRequest = function (event) {
- this.__QueryCounter--;
- if (this.__QueryCounter <= 0) {
- this.__LoadAnimationElement.classList.add("hidden");
- this.__QueryCounter = 0;
- }
- };
- XHR.prototype.POST = function (callback, uri, params, callbackParams, isAsinc, multipart) {
- if (isAsinc === void 0) { isAsinc = true; }
- if (multipart === void 0) { multipart = false; }
- if (!uri) {
- VKKO.Utils.logError("URI не был передан");
- return;
- }
- if (!params) {
- params = {};
- }
- var xhr = new XMLHttpRequest();
- xhr.onloadstart = this.onStartRequest;
- xhr.onloadend = this.onStopRequest;
- xhr.onabort = function (event) {
- VKKO.Utils.logWarning(uri + " => Выполнение запроса было прервано...");
- VKKOWork.Messenger.Show("Выполнение запроса было прервано...");
- };
- xhr.onerror = function (event) {
- VKKO.Utils.logError(uri + " => " + this.statusText + " " + this.status);
- VKKOWork.Messenger.Show("Выполнение запроса завершилось неудачей. Перезагрузите страницу и повторите попытку. Если проблема сохраняется, пожалуйста, сообщите об этом администратору admin@ktk-45.ru");
- };
- xhr.ontimeout = function (event) {
- VKKO.Utils.logError(uri + " => Время ожидания запроса истекло... Проверьте соединение с интернетом");
- VKKOWork.Messenger.Show("Время ожидания запроса истекло... Проверьте соединение с интернетом");
- };
- xhr.onload = function (event) {
- VKKO.Utils.logInfo(uri + " => " + this.statusText + " " + this.status.toString());
- var data;
- try {
- data = JSON.parse(this.response);
- }
- catch (error) {
- VKKO.Utils.logError(error);
- data = null;
- }
- if (data === null) {
- return;
- }
- if ("Error" in data) {
- if (typeof data.Error === "boolean") {
- VKKOWork.Messenger.Show(data.Error);
- return;
- }
- }
- callback(data, callbackParams);
- };
- xhr.open("POST", uri, isAsinc);
- if (!multipart) {
- xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
- xhr.send(JSON.stringify(params));
- }
- else {
- xhr.send(params);
- }
- };
- return XHR;
- }());
- VKKO.XHR = XHR;
- })(VKKO || (VKKO = {}));
- var VKKOWork;
- (function (VKKOWork) {
- VKKOWork.XHR = new VKKO.XHR();
- })(VKKOWork || (VKKOWork = {}));
- var VKKO;
- (function (VKKO) {
- var Control;
- (function (Control) {
- function CreateCheckbox(text, id, dataset, onchange) {
- if (dataset === void 0) { dataset = null; }
- if (onchange === void 0) { onchange = null; }
- var label = document.createElement("label"), input = document.createElement("input"), spanCheck = document.createElement("span"), spanText = document.createElement("span");
- label.className = "checkbox";
- label.append(input, spanCheck, spanText);
- spanText.className = "text";
- spanText.textContent = text;
- spanCheck.className = "checked";
- input.type = "checkbox";
- if (id) {
- var ifExists = document.querySelector("#" + id);
- if (ifExists) {
- VKKOWork.Messenger.Show("Нельзя создать элемент с повторяющимся идентификатором");
- return;
- }
- input.id = id;
- }
- if (dataset) {
- for (var key in dataset) {
- if (dataset.hasOwnProperty(key)) {
- input.dataset[key] = dataset[key];
- }
- }
- }
- if (onchange) {
- input.onchange = onchange;
- }
- return label;
- }
- Control.CreateCheckbox = CreateCheckbox;
- })(Control = VKKO.Control || (VKKO.Control = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var Modal;
- (function (Modal) {
- var __ModalCounter = 0;
- function Create(head, body, callback) {
- var backdropContainer;
- if (__ModalCounter === 0) {
- backdropContainer = document.createElement("div");
- backdropContainer.className = "backdrop-container";
- document.body.append(backdropContainer);
- VKKO.Setting.BlockScroll();
- }
- else {
- backdropContainer = document.querySelector(".backdrop-container");
- }
- if (backdropContainer == undefined) {
- VKKOWork.Messenger.Show("Ой, что-то пошло не так...");
- return;
- }
- var emodal = document.createElement("div"), ehead = document.createElement("div"), ebody = document.createElement("div"), eclose = document.createElement("div"), backdrop = document.createElement("div");
- backdrop.className = "backdrop";
- emodal.className = "modal";
- ehead.className = "head";
- ebody.className = "body";
- eclose.className = "close fas fa-times";
- eclose.onclick = destroy.bind(eclose, callback);
- emodal.append(eclose, ehead, ebody);
- backdrop.append(emodal);
- backdropContainer.append(backdrop);
- backdrop.style.zIndex = (__ModalCounter++).toString();
- if (typeof head === "string" || head instanceof HTMLElement) {
- ehead.append(head);
- }
- if (body instanceof HTMLElement) {
- while (body.children.length > 0) {
- ebody.append(body.children[0]);
- }
- }
- }
- Modal.Create = Create;
- function destroy(callback, event) {
- var backdrop = this.closest(".backdrop");
- if (backdrop) {
- backdrop.remove();
- __ModalCounter--;
- }
- if (__ModalCounter < 1) {
- var backdropContainer = document.querySelector(".backdrop-container");
- if (backdropContainer) {
- backdropContainer.remove();
- __ModalCounter = 0;
- VKKO.Setting.UnblockScroll();
- }
- }
- if (callback) {
- callback();
- }
- }
- })(Modal = VKKO.Modal || (VKKO.Modal = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var Slider = (function () {
- function Slider(containerSelector, swipeSpeed, swipeInterval) {
- if (swipeSpeed === void 0) { swipeSpeed = 250; }
- if (swipeInterval === void 0) { swipeInterval = 5000; }
- this.__SlideCount = 0;
- this.__WidthOneSlide = 0;
- this.__CarouselRoot = document.querySelector(containerSelector);
- if (!this.__CarouselRoot) {
- VKKO.Utils.logWarning("Отмена создания слайдера. Нет корневого контейнера.");
- return;
- }
- this.__Carousel = this.__CarouselRoot.querySelector(".carousel");
- if (!this.__Carousel) {
- VKKO.Utils.logWarning("Отмена создания слайдера. Отсутствует бокс.");
- this.__CarouselRoot.remove();
- return;
- }
- this.__Slider = this.__Carousel.querySelector(".slider");
- if (!this.__Slider) {
- this.__CarouselRoot.remove();
- return;
- }
- this.__NavigationDots = this.__Carousel.querySelector(".navigation-dots");
- this.__SlideCount = this.__Slider.children.length;
- if (this.__SlideCount == 0) {
- this.__CarouselRoot.remove();
- return;
- }
- switch (VKKO.Setting.Platform) {
- case CLIENT_PLATFORM.DESKTOP:
- this.__WidthOneSlide = this.__CarouselRoot.getBoundingClientRect().width;
- break;
- case CLIENT_PLATFORM.TABLET:
- break;
- case CLIENT_PLATFORM.MOBILE:
- this.__WidthOneSlide = document.documentElement.clientWidth;
- break;
- default:
- this.__WidthOneSlide = this.__CarouselRoot.getBoundingClientRect().width;
- }
- this.buildNavigationDots();
- this.buildButtonEvent();
- if (this.__SlideCount == 1) {
- this.__Slider.style.width = this.__WidthOneSlide + "px";
- this.outForeground();
- return;
- }
- if (this.__SlideCount > 1) {
- this.__Slider.prepend(this.__Slider.lastElementChild);
- }
- this.__SwipeInterval = swipeInterval;
- this.__SwipeSpeed = swipeSpeed;
- this.__Slider.style.width = (this.__SlideCount * this.__WidthOneSlide) + "px";
- this.__Slider.style.left = "-" + this.__WidthOneSlide + "px";
- this.__Slider.onmouseover = this.stopSlider.bind(this);
- this.__Slider.onmouseout = this.startSlider.bind(this);
- this.outForeground();
- this.startSlider();
- }
- Slider.prototype.buildNavigationDots = function () {
- if (this.__NavigationDots) {
- while (this.__NavigationDots.children.length > 0) {
- this.__NavigationDots.children[0].remove();
- }
- for (var i = 0; i < this.__SlideCount; i++) {
- var element = document.createElement("div");
- element.dataset.slide = i.toString();
- element.onclick = this.goToSlide.bind(this, element);
- this.__NavigationDots.append(element);
- }
- if (this.__NavigationDots.children.length > 0) {
- this.__NavigationDots.children[0].classList.add("active");
- }
- }
- };
- Slider.prototype.buildButtonEvent = function () {
- for (var i = 0; i < this.__Slider.children.length; i++) {
- var button = this.__Slider.children[i].querySelector(".gradient-button");
- if (button) {
- button.onclick = this.toggleSlide.bind(this, button);
- }
- }
- };
- Slider.prototype.outForeground = function () {
- this.__Carousel.classList.add("out");
- this.__Carousel.ontransitionend = function (event) {
- event.target.classList.remove("hide", "out");
- };
- };
- Slider.prototype.goToSlide = function (element) {
- this.stopSlider();
- this.__Slider.style.transition = "left " + this.__SwipeSpeed + "ms cubic-bezier(.18,.89,.32,1.28)";
- var currentSlide = this.__Slider.children[1];
- var currentSlideID = currentSlide.dataset.slide;
- var toSlideID = element.dataset.slide;
- while (toSlideID != currentSlideID) {
- this.__Slider.append(this.__Slider.firstElementChild);
- currentSlide = this.__Slider.children[1];
- currentSlideID = currentSlide.dataset.slide;
- }
- this.__Slider.style.left = "-" + this.__WidthOneSlide * 2 + "px";
- this.__Slider.ontransitionend = this.nextEndAlt.bind(this);
- this.switchNavigationDot();
- };
- Slider.prototype.switchNavigationDot = function () {
- var currentSlide = this.__Slider.children[1];
- var slide = Number(currentSlide.dataset.slide);
- var activeDots = this.__NavigationDots.querySelectorAll(".active");
- activeDots.forEach(function (element) {
- element.classList.remove("active");
- });
- this.__NavigationDots.children[slide].classList.add("active");
- };
- Slider.prototype.stopSlider = function () {
- clearInterval(this.__SwipeIntervalHandle);
- this.__SwipeIntervalHandle = undefined;
- this.__Slider.ontransitionend = undefined;
- };
- Slider.prototype.startSlider = function () {
- if (this.__SwipeIntervalHandle) {
- clearInterval(this.__SwipeIntervalHandle);
- }
- this.__SwipeIntervalHandle = setInterval(this.nextSlide.bind(this), this.__SwipeInterval);
- this.__Slider.ontransitionend = this.nextEnd.bind(this);
- };
- Slider.prototype.nextSlide = function () {
- this.__Slider.style.transition = "left " + this.__SwipeSpeed + "ms cubic-bezier(.6,-0.28,.74,.05)";
- this.__Slider.style.left = "-" + this.__WidthOneSlide * 2 + "px";
- };
- Slider.prototype.nextEnd = function () {
- this.__Slider.style.transition = null;
- this.__Slider.append(this.__Slider.firstElementChild);
- this.__Slider.style.left = "-" + this.__WidthOneSlide + "px";
- this.switchNavigationDot();
- };
- Slider.prototype.nextEndAlt = function () {
- this.__Slider.style.transition = null;
- this.__Slider.style.left = "-" + this.__WidthOneSlide + "px";
- this.startSlider();
- };
- Slider.prototype.toggleSlide = function (element) {
- if (element) {
- var slide = element.closest(".slide");
- if (slide) {
- if (slide.classList.contains("expand")) {
- slide.classList.remove("expand");
- element.textContent = "Развернуть";
- this.__NavigationDots.style.display = null;
- VKKO.Setting.UnblockScroll();
- }
- else {
- slide.classList.add("expand");
- element.textContent = "Свернуть";
- this.__NavigationDots.style.display = "none";
- VKKO.Setting.BlockScroll();
- }
- }
- }
- };
- Slider.prototype.Rebuild = function () {
- switch (VKKO.Setting.Platform) {
- case CLIENT_PLATFORM.DESKTOP:
- this.__WidthOneSlide = this.__CarouselRoot.getBoundingClientRect().width;
- break;
- case CLIENT_PLATFORM.TABLET:
- break;
- case CLIENT_PLATFORM.MOBILE:
- this.__WidthOneSlide = document.documentElement.clientWidth;
- break;
- default:
- this.__WidthOneSlide = this.__CarouselRoot.getBoundingClientRect().width;
- }
- this.__Slider.style.width = (this.__SlideCount * this.__WidthOneSlide) + "px";
- this.__Slider.style.left = "-" + this.__WidthOneSlide + "px";
- };
- return Slider;
- }());
- VKKO.Slider = Slider;
- })(VKKO || (VKKO = {}));
- var VKKOWork;
- (function (VKKOWork) {
- VKKOWork.NoticeSlider = null;
- })(VKKOWork || (VKKOWork = {}));
- var VKKO;
- (function (VKKO) {
- var Search;
- (function (Search) {
- function search() {
- }
- function Init(selector) {
- if (selector != null) {
- var inputSearch = document.querySelector(selector);
- if (inputSearch) {
- if (inputSearch.parentElement.nextElementSibling && inputSearch.parentElement.nextElementSibling.classList.contains("search-list")) {
- }
- inputSearch.oninput = search;
- }
- }
- }
- Search.Init = Init;
- })(Search = VKKO.Search || (VKKO.Search = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var Main;
- (function (Main) {
- var __RootMenuItemOpen = false;
- function switchMenu(event) {
- if (this.classList.contains("open")) {
- this.classList.remove("open");
- VKKO.Setting.UnblockScroll();
- }
- else {
- this.classList.add("open");
- VKKO.Setting.BlockScroll();
- }
- }
- var __ResizeTimeout;
- var __LastClientPlatform;
- function resize(event) {
- clearTimeout(__ResizeTimeout);
- __ResizeTimeout = setTimeout(function () {
- if (document.documentElement.clientWidth > CLIENT_PLATFORM.MOBILE) {
- if (document.documentElement.clientWidth > CLIENT_PLATFORM.TABLET) {
- if (document.documentElement.clientWidth > CLIENT_PLATFORM.OLD_DESKTOP) {
- VKKO.Setting.Platform = CLIENT_PLATFORM.OLD_DESKTOP;
- }
- else {
- VKKO.Setting.Platform = CLIENT_PLATFORM.DESKTOP;
- }
- }
- else {
- VKKO.Setting.Platform = CLIENT_PLATFORM.TABLET;
- }
- }
- else {
- VKKO.Setting.Platform = CLIENT_PLATFORM.MOBILE;
- }
- }, 250);
- }
- function login(login, password) {
- var data = {
- Login: login.value,
- Password: password.value
- };
- VKKOWork.XHR.POST(function (result) {
- if (result) {
- if (result.Error) {
- VKKOWork.Messenger.Show(result.Error);
- }
- else {
- VKKOWork.Messenger.Show("Привет, " + result.Name);
- window.location.reload();
- }
- }
- else {
- VKKOWork.Messenger.Show("Сервер ничего не вернул :(");
- }
- }, "/login", data);
- this.closest(".modal").querySelector(".close").click();
- }
- function Init() {
- resize();
- setTimeout(window.FsLightbox, 250);
- setTimeout(function () {
- document.body.onresize = resize;
- }, 500);
- }
- Main.Init = Init;
- function SignIn() {
- var body = document.createElement("div"), inputLogin = document.createElement("input"), inputPass = document.createElement("input"), button = document.createElement("button");
- var tabIndex = 1;
- inputLogin.type = "text";
- inputLogin.placeholder = "Логин";
- inputLogin.tabIndex = tabIndex++;
- inputPass.type = "password";
- inputPass.placeholder = "Пароль";
- inputPass.tabIndex = tabIndex++;
- inputPass.onkeypress = function (event) {
- if (event.keyCode == 13) {
- login.call(button, inputLogin, inputPass);
- }
- };
- button.textContent = "Войти";
- button.onclick = login.bind(button, inputLogin, inputPass);
- button.tabIndex = tabIndex++;
- body.append(inputLogin, inputPass, button);
- VKKO.Modal.Create("Авторизация", body);
- }
- Main.SignIn = SignIn;
- function SignOut() {
- VKKOWork.XHR.POST(function (data) { if (data.Error == null) {
- window.location.reload();
- } }, "/logout");
- }
- Main.SignOut = SignOut;
- })(Main = VKKO.Main || (VKKO.Main = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var Tree = (function () {
- function Tree() {
- this.__Root = document.createElement("div");
- this.__Root.classList.add("tree");
- }
- Tree.prototype.onClickBranch = function (event) {
- if (this instanceof HTMLElement) {
- var root = this.closest(".tree");
- var selected = root.querySelectorAll(".selected");
- var thisParent_1 = this.parentElement;
- selected.forEach(function (value) {
- if (value !== thisParent_1) {
- value.classList.remove("selected");
- }
- });
- thisParent_1.classList.toggle("selected");
- }
- };
- Tree.prototype.AddBranch = function (caption, dataset, root) {
- var branch = document.createElement("div"), body = document.createElement("div"), head = document.createElement("div");
- if (dataset) {
- for (var key in dataset) {
- if (dataset.hasOwnProperty(key)) {
- branch.dataset[key] = dataset[key];
- }
- }
- }
- branch.classList.add("branch");
- body.classList.add("body");
- head.classList.add("head");
- head.textContent = caption;
- head.onclick = this.onClickBranch;
- branch.append(head, body);
- if (root) {
- root.append(branch);
- }
- else {
- this.__Root.append(branch);
- }
- return body;
- };
- Tree.prototype.CreateBranch = function (caption, dataset) {
- return this.AddBranch(caption, dataset).parentElement;
- };
- Tree.prototype.InsertInto = function (index, caption, dataset, root) {
- if (!root) {
- root = this.__Root;
- }
- var l = root.children.length;
- for (var i = 0; i < l; i++) {
- var element = root.children[i];
- if (element.classList.contains("branch")) {
- if (element.dataset.id && element.dataset.id === index.toString()) {
- if (element.children[1] && element.children[1].classList.contains("body")) {
- element.children[1].append(this.CreateBranch(caption, dataset));
- return;
- }
- }
- else {
- if (element.children[1] && element.children[1].classList.contains("body")) {
- this.InsertInto(index, caption, dataset, element.children[1]);
- }
- }
- }
- }
- };
- Tree.prototype.SetTo = function (element) {
- if (element) {
- while (element.children.length > 0) {
- element.children[0].remove();
- }
- while (this.__Root.children.length > 0) {
- element.append(this.__Root.children[0]);
- }
- element.classList.add("tree");
- }
- };
- return Tree;
- }());
- VKKO.Tree = Tree;
- })(VKKO || (VKKO = {}));
- var VKKO;
- (function (VKKO) {
- var MaterialEditor;
- (function (MaterialEditor) {
- var __CreateNewsButton = document.querySelector("#CreateNewsButton");
- if (__CreateNewsButton) {
- __CreateNewsButton.onclick = openModal;
- }
- var __CreateNoticeButton = document.querySelector("#CreateNoticeButton");
- if (__CreateNoticeButton) {
- __CreateNoticeButton.onclick = openModal;
- }
- var __CreateMaterialButton = document.querySelector("#CreateMaterialButton");
- if (__CreateMaterialButton) {
- __CreateMaterialButton.onclick = openModal;
- }
- var __EditMaterialButton = document.querySelector("#EditMaterialButton");
- if (__EditMaterialButton) {
- __EditMaterialButton.onclick = getMaterialSource;
- }
- var __DeleteMaterialButton = document.querySelector("#DeleteMaterialButton");
- if (__DeleteMaterialButton) {
- __DeleteMaterialButton.onclick = deleteMaterial;
- }
- var __CurrentCategory = undefined;
- function deleteMaterial() {
- if (this.dataset.active == "true") {
- VKKOWork.XHR.POST(function () { }, "/material-delete/" + this.dataset.link);
- }
- else {
- VKKOWork.XHR.POST(function () { }, "/material-restore/" + this.dataset.link);
- }
- }
- function openModal() {
- switch (this.dataset.category) {
- case MATERIAL_CATEGORY.MATERIAL:
- __CurrentCategory = MATERIAL_CATEGORY.MATERIAL;
- break;
- case MATERIAL_CATEGORY.NEWS:
- __CurrentCategory = MATERIAL_CATEGORY.NEWS;
- break;
- case MATERIAL_CATEGORY.NOTICE:
- __CurrentCategory = MATERIAL_CATEGORY.NOTICE;
- break;
- default:
- return;
- }
- var body = document.createElement("div"), inputCaption = document.createElement("input"), inputLink = document.createElement("input"), contentBlock = document.createElement("div"), previewBlock = document.createElement("div"), preview = document.createElement("div"), label = document.createElement("label"), file = document.createElement("input"), fileButton = document.createElement("div"), buttonSend = document.createElement("button");
- label.append(file, fileButton);
- label.className = "select-file";
- fileButton.className = "button";
- fileButton.textContent = "Выбрать изображениия";
- file.type = "file";
- if (__CurrentCategory === MATERIAL_CATEGORY.NOTICE) {
- file.multiple = false;
- }
- else {
- file.multiple = true;
- }
- file.accept = "image/*";
- file.onchange = changeImages;
- inputCaption.type = "text";
- inputCaption.placeholder = "Заголовок/название (обязательно)";
- inputLink.type = "text";
- inputLink.placeholder = "Ссылка на " + __CurrentCategory + " (не обязательно)";
- buttonSend.textContent = "Создать";
- preview.className = "preview-images";
- contentBlock.id = "editorjs";
- contentBlock.className = "content-editor";
- if (__CurrentCategory !== MATERIAL_CATEGORY.MATERIAL) {
- body.append(inputCaption, inputLink, contentBlock, previewBlock, label, preview, buttonSend);
- }
- else {
- body.append(inputCaption, inputLink, contentBlock, previewBlock, buttonSend);
- }
- var tools = {
- header: {
- "class": Header,
- inlineToolbar: true,
- shortcut: "CMD+SHIFT+H"
- },
- list: {
- "class": List,
- inlineToolbar: true,
- shortcut: "CMD+SHIFT+L"
- },
- marker: {
- "class": Marker,
- shortcut: "CMD+SHIFT+M"
- },
- delimiter: Delimiter,
- inlineCode: {
- "class": InlineCode,
- shortcut: "CMD+SHIFT+C"
- },
- linkTool: LinkTool,
- code: CodeTool,
- table: {
- "class": Table,
- inlineToolbar: true,
- shortcut: "CMD+ALT+T"
- },
- onReady: function () {
- console.log("ready");
- },
- onChange: function () {
- console.log("changed");
- }
- };
- if (__CurrentCategory === MATERIAL_CATEGORY.MATERIAL) {
- tools.image = {
- "class": SimpleImage,
- inlineCode: true
- };
- tools.embed = {
- "class": Embed,
- inlineToolbar: false,
- config: {
- services: {
- youtube: true
- }
- }
- };
- }
- var editor = new EditorJS({
- holder: contentBlock,
- tools: tools,
- data: null
- });
- buttonSend.addEventListener("click", function () {
- editor.save().then(function (savedData) {
- create.call(buttonSend, inputCaption, inputLink, savedData, preview, file);
- });
- });
- VKKO.Modal.Create("Создать " + __CurrentCategory, body);
- }
- function getMaterialSource() {
- VKKOWork.XHR.POST(openModalToEdit, "/material-get-source/" + this.dataset.link,);
- }
- function openModalToEdit(data) {
- var source = {};
- try {
- source.Caption = data.Data.Caption;
- source.Category = data.Data.Category;
- source.Link = data.Data.Link;
- source.Source = JSON.parse(data.Data.Source);
- source.SourceImages = JSON.parse(data.Data.SourceImages);
- }
- catch (error) {
- VKKO.Utils.logError(error);
- VKKOWork.Messenger.Show("Ошибка загрузки исходных данных материала: " + error);
- return;
- }
- switch (source.Category) {
- case MATERIAL_CATEGORY.MATERIAL:
- __CurrentCategory = MATERIAL_CATEGORY.MATERIAL;
- break;
- case MATERIAL_CATEGORY.NEWS:
- __CurrentCategory = MATERIAL_CATEGORY.NEWS;
- break;
- case MATERIAL_CATEGORY.NOTICE:
- __CurrentCategory = MATERIAL_CATEGORY.NOTICE;
- break;
- default:
- VKKOWork.Messenger.Show("Неизвестная категория материала: " + source.Category);
- return;
- }
- var body = document.createElement("div"), inputCaption = document.createElement("input"), inputLink = document.createElement("input"), contentBlock = document.createElement("div"), previewBlock = document.createElement("div"), preview = document.createElement("div"), buttonSend = document.createElement("button");
- inputCaption.type = "text";
- inputCaption.placeholder = "Заголовок/название (обязательно)";
- inputCaption.value = source.Caption;
- inputLink.disabled = true;
- inputLink.type = "text";
- inputLink.value = source.Link;
- buttonSend.textContent = "Сохранить изменения";
- preview.className = "preview-images";
- contentBlock.id = "editorjs";
- contentBlock.className = "content-editor";
- createPreviewImagesFromSource(preview, source.SourceImages);
- if (__CurrentCategory !== MATERIAL_CATEGORY.MATERIAL) {
- body.append(inputCaption, inputLink, contentBlock, previewBlock, preview, buttonSend);
- }
- else {
- body.append(inputCaption, inputLink, contentBlock, previewBlock, buttonSend);
- }
- var tools = {
- header: {
- "class": Header,
- inlineToolbar: true,
- shortcut: "CMD+SHIFT+H"
- },
- list: {
- "class": List,
- inlineToolbar: true,
- shortcut: "CMD+SHIFT+L"
- },
- marker: {
- "class": Marker,
- shortcut: "CMD+SHIFT+M"
- },
- delimiter: Delimiter,
- inlineCode: {
- "class": InlineCode,
- shortcut: "CMD+SHIFT+C"
- },
- linkTool: LinkTool,
- table: {
- "class": Table,
- inlineToolbar: true,
- shortcut: "CMD+ALT+T"
- },
- onReady: function () {
- console.log("ready");
- },
- onChange: function () {
- console.log("changed");
- }
- };
- if (__CurrentCategory === MATERIAL_CATEGORY.MATERIAL) {
- tools.image = {
- "class": SimpleImage,
- inlineCode: true
- };
- tools.embed = {
- "class": Embed,
- inlineToolbar: false,
- config: {
- services: {
- youtube: true
- }
- }
- };
- }
- var editor = new EditorJS({
- holder: contentBlock,
- tools: tools,
- data: JSON.parse(data.Data.Source)
- });
- buttonSend.addEventListener("click", function () {
- editor.save().then(function (savedData) {
- update.call(buttonSend, inputCaption, inputLink, savedData, preview, source.SourceImages);
- });
- });
- VKKO.Modal.Create("Редактировать " + __CurrentCategory, body);
- }
- function changeImages() {
- var preview = document.querySelector(".preview-images");
- if (!preview) {
- VKKO.Utils.logWarning("Элемент [.preview-images] не найден");
- return;
- }
- for (var _i = 0, _a = this.files; _i < _a.length; _i++) {
- var file = _a[_i];
- var div = document.createElement("div");
- div.className = "image";
- var img = document.createElement("img");
- img.src = window.URL.createObjectURL(file);
- img.alt = file.name;
- img.height = 100;
- var label = document.createElement("label");
- var input = document.createElement("input");
- input.type = "radio";
- input.dataset.image = file.name;
- input.name = "preview-images";
- var span = document.createElement("span");
- div.append(img, label);
- label.append(input, span);
- preview.append(div);
- }
- var firstImage = preview.querySelector("input");
- firstImage.click();
- }
- function dataURIToBlob(dataURI) {
- var splitDataURI = dataURI.split(",");
- var byteString = splitDataURI[0].indexOf("base64") >= 0 ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1]);
- var mimeString = splitDataURI[0].split(":")[1].split(";")[0];
- var ia = new Uint8Array(byteString.length);
- for (var i = 0; i < byteString.length; i++)
- ia[i] = byteString.charCodeAt(i);
- return new Blob([ia], { type: mimeString });
- }
- function createPreviewImagesFromSource(element, source) {
- for (var _i = 0, source_1 = source; _i < source_1.length; _i++) {
- var file = source_1[_i];
- var div = document.createElement("div");
- div.className = "image";
- var img = document.createElement("img");
- img.src = file.Thumb;
- img.height = 100;
- element.append(div);
- }
- }
- function create(caption, link, content, images, file) {
- if (!caption || !link || !content || !images) {
- VKKOWork.Messenger.Show("Некоторые элементы не были найдены, невозможно создать новость!");
- return;
- }
- if (caption.value.length == 0) {
- VKKOWork.Messenger.Show("Необходимо заполнить заголовок!");
- return;
- }
- if (link.value.length == 0) {
- link.value = VKKO.Utils.GenerateHash256();
- }
- var preview = {
- Valid: "true",
- String: ""
- };
- var date = new Date();
- var m = ("00" + (date.getMonth() + 1)).slice(-2);
- var d = ("00" + date.getDate()).slice(-2);
- var imageFullpath = "image/" + __CurrentCategory + "/" + date.getUTCFullYear().toString() + "-" + m + "-" + d + "/";
- var thumbFullpath = "thumb/" + __CurrentCategory + "/" + date.getUTCFullYear().toString() + "-" + m + "-" + m + "/";
- var data = new FormData();
- var contentHtml = "";
- for (var _i = 0, _a = content.blocks; _i < _a.length; _i++) {
- var c = _a[_i];
- switch (c.type) {
- case "paragraph":
- contentHtml += "<p>" + c.data.text + "</p>";
- preview.String += c.data.text;
- break;
- case "header":
- contentHtml += "<h" + c.data.level + ">" + c.data.text + "</h" + c.data.level + ">";
- preview.String += c.data.text;
- break;
- case "list":
- if (c.data.style === "ordered") {
- contentHtml += "<ol>";
- for (var _b = 0, _c = c.data.items; _b < _c.length; _b++) {
- var li = _c[_b];
- contentHtml += "<li>" + li + "</li>";
- preview.String += li;
- }
- contentHtml += "</ol>";
- }
- else {
- contentHtml += "<ul>";
- for (var _d = 0, _e = c.data.items; _d < _e.length; _d++) {
- var li = _e[_d];
- contentHtml += "<li>" + li + "</li>";
- preview.String += li;
- }
- contentHtml += "</ul>";
- }
- break;
- case "delimiter":
- contentHtml += "<hr>";
- break;
- case "table":
- contentHtml += "<table>";
- for (var _f = 0, _g = c.data.content; _f < _g.length; _f++) {
- var row = _g[_f];
- contentHtml += "<tr>";
- for (var _h = 0, row_1 = row; _h < row_1.length; _h++) {
- var col = row_1[_h];
- contentHtml += "<td>" + col + "</td>";
- preview.String += col;
- }
- contentHtml += "</tr>";
- }
- contentHtml += "</table>";
- break;
- case "image":
- var filename = VKKO.Utils.GenerateHashDashed(2) + "." + c.data.url.slice(11, c.data.url.indexOf(";"));
- contentHtml +=
- '<a href="/' +
- imageFullpath +
- filename +
- '" data-fslightbox="' +
- link.value +
- '"><img class="material-image" src="/' +
- thumbFullpath +
- filename +
- '" /></a>';
- var div = document.createElement("div");
- div.innerHTML = c.data.caption;
- if (div.textContent.length > 0) {
- contentHtml += '<div class="material-image-caption">' + c.data.caption + "</div>";
- }
- data.append("Files", dataURIToBlob(c.data.url), filename);
- break;
- case "embed":
- contentHtml += '<iframe src="' + c.data.embed + '" style="width:' + c.data.width + 'px; height:' + c.data.height + 'px;display:block;margin:40px auto;" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0"></iframe>';
- var youtubeCaption = document.createElement("div");
- youtubeCaption.innerHTML = c.data.caption;
- if (youtubeCaption.textContent.length > 0) {
- contentHtml += '<div class="material-image-caption">' + c.data.caption + "</div>";
- }
- break;
- }
- }
- var clearTags = document.createElement("div");
- clearTags.innerHTML = preview.String;
- preview.String = clearTags.textContent;
- if (preview.String.length > 260) {
- preview.String = preview.String.slice(0, 260);
- }
- var selectedImage = {
- Valid: "false",
- String: ""
- };
- var sourceImages = [];
- if (__CurrentCategory != MATERIAL_CATEGORY.MATERIAL) {
- var selectedImageName = ";";
- var selectedInput = images.querySelector("input:checked");
- if (selectedInput) {
- var img = selectedInput.closest(".image").querySelector("img");
- if (img) {
- selectedImageName = img.alt;
- selectedImage.String = thumbFullpath + selectedImageName.toLowerCase();
- selectedImage.Valid = "true";
- }
- }
- if (file.files.length > 0) {
- if (__CurrentCategory != MATERIAL_CATEGORY.NOTICE) {
- contentHtml += '<div class="news-images">';
- }
- for (var i = 0; i < file.files.length; i++) {
- var f = file.files.item(i);
- var filename = f.name.toLowerCase();
- filename = VKKO.Utils.GenerateHashDashed(2) + filename.slice(filename.lastIndexOf("."));
- if (selectedImageName === f.name) {
- selectedImage.String = thumbFullpath + filename;
- }
- if (__CurrentCategory != MATERIAL_CATEGORY.NOTICE) {
- contentHtml +=
- '<a href="/' +
- imageFullpath +
- filename +
- '" data-fslightbox="' +
- link.value +
- '"><img src="/' +
- thumbFullpath +
- filename +
- '" alt="' +
- filename +
- '"></a>';
- }
- data.append("Files", f, filename);
- sourceImages.push({
- Image: "/" + imageFullpath + filename,
- Thumb: "/" + thumbFullpath + filename
- });
- }
- if (__CurrentCategory != MATERIAL_CATEGORY.NOTICE) {
- contentHtml += "</div>";
- }
- }
- }
- data.set("Caption", caption.value);
- data.set("Link", link.value);
- data.set("Content", contentHtml);
- data.set("Source", JSON.stringify(content));
- data.set("SourceImages", JSON.stringify(sourceImages));
- data.set("PreviewValid", preview.Valid);
- data.set("PreviewString", preview.String);
- data.set("ImageValid", selectedImage.Valid);
- data.set("ImageString", selectedImage.String);
- data.set("ImagePath", imageFullpath);
- data.set("ThumbPath", thumbFullpath);
- var closeModal = this.closest(".modal").querySelector(".close");
- VKKOWork.XHR.POST(function (result) {
- if (result && "Error" in result) {
- if (result.Error === null) {
- VKKOWork.Messenger.Show(__CurrentCategory + " успешно добавлена");
- closeModal.click();
- }
- else {
- VKKOWork.Messenger.Show("Возникла ошибка добавления новости." + result.Error);
- }
- }
- }, "/material-insert/" + __CurrentCategory, data, null, true, true);
- }
- function update(caption, link, content, images, source) {
- if (!caption || !link || !content || !images) {
- VKKOWork.Messenger.Show("Некоторые элементы не были найдены, невозможно создать новость!");
- return;
- }
- if (caption.value.length == 0) {
- VKKOWork.Messenger.Show("Необходимо заполнить заголовок!");
- return;
- }
- if (link.value.length == 0) {
- link.value = VKKO.Utils.GenerateHash256();
- }
- var preview = {
- Valid: "true",
- String: ""
- };
- var date = new Date();
- var m = ("00" + (date.getMonth() + 1)).slice(-2);
- var d = ("00" + date.getDate()).slice(-2);
- var imageFullpath = "";
- var thumbFullpath = "";
- if (__CurrentCategory != MATERIAL_CATEGORY.MATERIAL) {
- if (source.length > 0) {
- imageFullpath = source[0].Image.slice(1, source[0].Image.lastIndexOf("/") + 1);
- thumbFullpath = source[0].Thumb.slice(1, source[0].Thumb.lastIndexOf("/") + 1);
- }
- }
- else {
- imageFullpath = "image/" + __CurrentCategory + "/" + date.getUTCFullYear().toString() + "-" + m + "-" + d + "/";
- thumbFullpath = "thumb/" + __CurrentCategory + "/" + date.getUTCFullYear().toString() + "-" + m + "-" + m + "/";
- }
- var data = new FormData();
- var contentHtml = "";
- for (var _i = 0, _a = content.blocks; _i < _a.length; _i++) {
- var c = _a[_i];
- switch (c.type) {
- case "paragraph":
- contentHtml += "<p>" + c.data.text + "</p>";
- preview.String += c.data.text;
- break;
- case "header":
- contentHtml += "<h" + c.data.level + ">" + c.data.text + "</h" + c.data.level + ">";
- preview.String += c.data.text;
- break;
- case "list":
- if (c.data.style === "ordered") {
- contentHtml += "<ol>";
- for (var _b = 0, _c = c.data.items; _b < _c.length; _b++) {
- var li = _c[_b];
- contentHtml += "<li>" + li + "</li>";
- preview.String += li;
- }
- contentHtml += "</ol>";
- }
- else {
- contentHtml += "<ul>";
- for (var _d = 0, _e = c.data.items; _d < _e.length; _d++) {
- var li = _e[_d];
- contentHtml += "<li>" + li + "</li>";
- preview.String += li;
- }
- contentHtml += "</ul>";
- }
- break;
- case "delimiter":
- contentHtml += "<hr>";
- break;
- case "table":
- contentHtml += "<table>";
- for (var _f = 0, _g = c.data.content; _f < _g.length; _f++) {
- var row = _g[_f];
- contentHtml += "<tr>";
- for (var _h = 0, row_2 = row; _h < row_2.length; _h++) {
- var col = row_2[_h];
- contentHtml += "<td>" + col + "</td>";
- preview.String += col;
- }
- contentHtml += "</tr>";
- }
- contentHtml += "</table>";
- break;
- case "image":
- var filename = VKKO.Utils.GenerateHashDashed(2) + "." + c.data.url.slice(11, c.data.url.indexOf(";"));
- contentHtml +=
- '<a href="/' +
- imageFullpath +
- filename +
- '" data-fslightbox="' +
- link.value +
- '"><img class="material-image" src="/' +
- thumbFullpath +
- filename +
- '" /></a>';
- var div = document.createElement("div");
- div.innerHTML = c.data.caption;
- if (div.textContent.length > 0) {
- contentHtml += '<div class="material-image-caption">' + c.data.caption + "</div>";
- }
- data.append("Files", dataURIToBlob(c.data.url), filename);
- break;
- case "embed":
- contentHtml += '<iframe src="' + c.data.embed + '" style="width: ' + c.data.width + 'px; height: ' + c.data.height + 'px;" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0"></iframe>';
- var youtubeCaption = document.createElement("div");
- youtubeCaption.innerHTML = c.data.caption;
- if (youtubeCaption.textContent.length > 0) {
- contentHtml += '<div class="material-image-caption">' + c.data.caption + "</div>";
- }
- break;
- }
- }
- var clearTags = document.createElement("div");
- clearTags.innerHTML = preview.String;
- preview.String = clearTags.textContent;
- if (preview.String.length > 260) {
- preview.String = preview.String.slice(0, 260);
- }
- if (__CurrentCategory != MATERIAL_CATEGORY.MATERIAL) {
- if (source.length > 0) {
- if (__CurrentCategory != MATERIAL_CATEGORY.NOTICE) {
- contentHtml += '<div class="news-images">';
- }
- for (var i = 0; i < source.length; i++) {
- if (__CurrentCategory != MATERIAL_CATEGORY.NOTICE) {
- contentHtml +=
- '<a href="' + source[i].Image +
- '" data-fslightbox="' +
- link.value +
- '"><img src="' +
- source[i].Thumb +
- '" alt="' +
- source[i].Image.slice(source[i].Image.lastIndexOf("/") + 1) +
- '"></a>';
- }
- }
- if (__CurrentCategory != MATERIAL_CATEGORY.NOTICE) {
- contentHtml += "</div>";
- }
- }
- }
-
- data.set("Link", link.value);
- data.set("Caption", caption.value);
- data.set("Content", contentHtml);
- data.set("Source", JSON.stringify(content));
- data.set("PreviewValid", preview.Valid);
- data.set("PreviewString", preview.String);
- data.set("ImagePath", imageFullpath);
- data.set("ThumbPath", thumbFullpath);
- var closeModal = this.closest(".modal").querySelector(".close");
- VKKOWork.XHR.POST(function (result) {
- if (result && "Error" in result) {
- if (result.Error === null) {
- VKKOWork.Messenger.Show(__CurrentCategory + " успешно добавлена");
- closeModal.click();
- }
- else {
- VKKOWork.Messenger.Show("Возникла ошибка добавления новости." + result.Error);
- }
- }
- }, "/material-update/" + __CurrentCategory, data, null, true, true);
- }
- MaterialEditor.initButton = function() {
- var __editMaterialButton = document.querySelectorAll(".edit-material-button");
- for (let emb of __editMaterialButton) {
- emb.onclick = getMaterialSource;
- }
- var __deleteMaterialButton = document.querySelectorAll(".delete-material-button");
- for (let emb of __deleteMaterialButton) {
- emb.onclick = deleteMaterial;
- }
- }
- })(MaterialEditor = VKKO.MaterialEditor || (VKKO.MaterialEditor = {}));
- })(VKKO || (VKKO = {}));
- var VKKO;
- let singIn = document.querySelector('.sign-in');
- let isOver = false;
- let clickCount = 0;
- if (singIn) {
- singIn.onmouseover = function(event) {
- isOver = true;
- clickCount = 0;
- };
- singIn.onmouseleave = function(event) {
- isOver = false;
- clickCount = 0;
- };
- singIn.onclick = function(event) {
- if (isOver) {
- clickCount++;
- if (clickCount == 5) {
- this.classList.remove("hide");
- this.onmouseover = undefined;
- this.onmouseleave = undefined;
- this.onclick = VKKO.Main.SignIn;
- }
- }
- };
- }
- let AddMaterialButton = document.querySelector("#AddMaterialButton");
- if (AddMaterialButton) {
- AddMaterialButton.onclick = function() {
- let label = document.createElement("label");
- let input = document.createElement("input");
- let button = document.createElement("button");
- let body = document.createElement("div");
- label.textContent = "Ссылка на материал";
- input.type = "text";
- button.textContent = "Добавить";
- button.onclick = function() {
- VKKOWork.XHR.POST(function (result) {
- if ("Error" in result && result.Error == null) {
- VKKOWork.Messenger.Show("Ссылка успешно добавлена");
- } else {
- VKKOWork.Messenger.Show(result.Error);
- }
- }, "/set-material-list", {Link: input.value});
- this.closest(".modal").querySelector(".close").click();
- };
- body.append(label, input, button);
- VKKO.Modal.Create("Добавить ссылку на материал в полезную информацию", body);
- };
- }
|