diff --git a/data/core.telegram.org/api/discussion.html b/data/core.telegram.org/api/discussion.html
deleted file mode 100644
index d1181b0f5f..0000000000
--- a/data/core.telegram.org/api/discussion.html
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
- ').text(message).html();
- showConfirm(message_html, load_func, l('WEB_LEAVE_PAGE', 'Leave'));
- return false;
- } else {
- load_func();
- return true;
- }
- }
-
- $(document).on('click', 'a[href]', linkHandler);
- $(document.body).removeClass('no-transition');
-
- $(window).on('popstate', function(e) {
- var popstate = e.originalEvent.state;
- var state_go = popstate ? (popstate.i - curHistoryState.i) : 0;
- if (!popstate) {
- popstate = {i: 0, u: location.href};
- } else if (!popstate.u) {
- popstate.u = location.href;
- }
- console.log('history popstate', 'oldState =', curHistoryState, 'newState =', popstate, 'go(' + state_go + ')');
- curHistoryState = popstate;
- if (skipPopState) {
- skipPopState = false;
- return;
- }
- if (Aj._useScrollHack) {
- $('body').css({height: '100000px', overflow: 'hidden'}); // for correct scroll restoration
- }
- var link = loc(curHistoryState.u);
- var loaded = loadPage(link, false, state_go);
- if (!loaded && Aj._useScrollHack) {
- $('body').css({height: '', overflow: ''});
- }
- });
- window.onbeforeunload = beforeUnloadHandler;
-}
-
-function updateNavBar() {
- var $nav_menu = $('.nav-menu');
- $nav_menu.addClass('nav-menu-can-fix');
- if ($nav_menu.css('position') == 'fixed') {
- $nav_menu.width($nav_menu.parent().width());
- } else {
- $nav_menu.css('width', 'auto');
- }
-}
-
-function getBR() {
- if (window._brHTML) return window._brHTML;
- return window._brHTML = $('
').html();
-}
-
-function cleanHTML(value) {
- return value.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/\n/g, getBR());
-}
-
-function cleanRE(value) {
- return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
-}
-
-var Keys = {
- BACKSPACE: 8,
- ESC: 27,
- TAB: 9,
- RETURN: 13,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40,
- on: function(key, callback) {
- return function(e){ if(e.which == key) callback.apply(this, Array.prototype.slice.apply(arguments)); };
- }
-};
-
-var Popups = [];
-
-function openPopup(popup, options) {
- if (!popup) return false;
- options = options || {};
- var $popup = $(popup);
- var popup_id = $popup.data('puid');
- if (!popup_id) {
- if (!Popups._pid) Popups._pid = 0;
- popup_id = ++Popups._pid;
- $popup.data('puid', popup_id);
- }
- $popup.data('options', options);
- var i = Popups.indexOf(popup_id);
- if (i >= 0) {
- Popups.splice(i, 1);
- }
- Popups.push(popup_id);
- $('body').css('overflow', 'hidden');
- $popup.appendTo(window.Aj && Aj.ajContainer || 'body');
- $popup.removeClass('hide');
- if (document.activeElement) {
- document.activeElement.blur();
- }
- if (options.closeByClickOutside) {
- $popup.on('click', function(e) {
- if ($(e.target).closest('body').length &&
- !$(e.target).closest(options.closeByClickOutside).length) {
- closePopup($popup);
- }
- });
- }
- $('.popup-cancel-btn', $popup).on('click', function(e) {
- closePopup($popup);
- });
- $popup.trigger('popup:open');
-}
-
-function getPopupById(popup_id) {
- var $popups = $('.popup-container');
- var found = false;
- for (var i = 0; i < $popups.length; i++) {
- $popup = $popups.eq(i);
- if (popup_id == $popup.data('puid')) {
- return $popup;
- }
- }
- return false;
-}
-
-function closePopup(popup) {
- if (!Popups.length) return false;
- var $popup, popup_id;
- if (popup) {
- $popup = $(popup);
- popup_id = $popup.data('puid');
- } else {
- popup_id = Popups[Popups.length - 1];
- $popup = getPopupById(popup_id);
- if (!$popup) {
- return false;
- }
- }
- var options = $popup.data('options');
- if (options.onBeforeClose) {
- var result = options.onBeforeClose($popup);
- if (result === false) {
- return false;
- }
- }
- var i = Popups.indexOf(popup_id);
- if (i >= 0) {
- Popups.splice(i, 1);
- }
- if (!Popups.length) {
- $('body').css('overflow', '');
- }
- if (options.closeByClickOutside) {
- $popup.off('click');
- }
- $('.popup-cancel-btn', $popup).off('click');
- $popup.addClass('hide');
- $popup.trigger('popup:close');
-}
-
-function closeAllPopups() {
- for (var i = Popups.length - 1; i >= 0; i--) {
- var $popup = getPopupById(Popups[i]);
- if ($popup) {
- closePopup($popup);
- }
- }
-}
-
-function showAlert(html, options) {
- options = options || {};
- var $alert = $('');
- var onEnterPress = function(e) {
- if (e.keyCode == Keys.RETURN) {
- e.stopImmediatePropagation();
- closePopup($alert);
- }
- };
- $('.popup-text', $alert).html(html);
- $(document).on('keydown', onEnterPress);
- $alert.one('popup:close', function() {
- $(document).off('keydown', onEnterPress);
- $alert.remove();
- });
- openPopup($alert);
- return $alert;
-}
-
-function showConfirm(html, onConfirm, confirm_btn, onCancel, cancel_btn) {
- var $confirm = $('');
- var confirm = function() {
- onConfirm && onConfirm($confirm);
- closePopup($confirm);
- }
- var onEnterPress = function(e) {
- if (e.keyCode == Keys.RETURN) {
- e.stopImmediatePropagation();
- confirm();
- }
- };
- $('.popup-text', $confirm).html(html);
- var $primaryBtn = $('.popup-primary-btn', $confirm);
- $primaryBtn.on('click', confirm);
- if (onCancel) {
- var cancel = function(){ onCancel($confirm); };
- var $cancelBtn = $('.popup-cancel-btn', $confirm);
- $cancelBtn.on('click', cancel);
- }
- $(document).on('keydown', onEnterPress);
- $confirm.one('popup:close', function() {
- $primaryBtn.off('click', confirm);
- if (onCancel) {
- $cancelBtn.off('click', cancel);
- }
- $(document).off('keydown', onEnterPress);
- $confirm.remove();
- });
- openPopup($confirm);
- return $confirm;
-}
-
-function showMedia(src, is_video, options) {
- var media_html = (is_video ? '
' : '
') + (options.add_media_html || '');
- var title_html = options.title ? '
' : '';
- var pagination_html = options.pagination ? '
' : '';
- var $popup = $('');
- var media = {
- $wrap: $('.media-popup-wrap', $popup),
- $cover: $('.media-popup-cover', $popup),
- $pwrap: $('.circle-progress-wrap', $popup),
- $media: $('.media', $popup),
- width: null,
- height: null,
- cover: null,
- timeout: null,
- checkMediaSize: function() {
- if (is_video) {
- var video = media.mediaEl;
- if (video.videoWidth && video.videoHeight) {
- media.width = video.videoWidth;
- media.height = video.videoHeight;
- media.$media.removeClass('ohide');
- media.$wrap.removeClass('file-loading').addClass('file-loaded');
- media.onResize();
- return;
- }
- } else {
- var img = media.mediaEl;
- if (img.naturalWidth && img.naturalHeight) {
- media.width = img.naturalWidth;
- media.height = img.naturalHeight;
- media.onResize();
- return;
- }
- }
- media.timeout = setTimeout(media.checkMediaSize, 50);
- },
- onResize: function() {
- if (!media.width || !media.height) {
- return;
- }
- var w = media.width, h = media.height;
- var de = document.documentElement;
- var vw = de.clientWidth, vh = de.clientHeight;
- vw -= parseInt($popup.css('paddingLeft') || 0)
- + parseInt($popup.css('paddingRight') || 0)
- + parseInt(media.$wrap.css('paddingRight') || 0);
- vh -= parseInt($popup.css('paddingTop') || 0)
- + parseInt($popup.css('paddingBottom') || 0)
- + parseInt(media.$wrap.css('paddingBottom') || 0);
- var min_vw = Math.max(320, vw);
- var min_vh = Math.max(320, vh);
- var sw = w / min_vw;
- var sh = h / min_vh;
- var s = Math.max(sw, sh);
- var iw = w / s, ih = h / s;
- if (!is_video) {
- var can_zoom = (s > 1);
- if (!can_zoom || $popup.hasClass('fullsize')) {
- var iw = w, ih = h;
- }
- $popup.toggleClass('can-zoom', can_zoom);
- }
- var scroll_x = iw > vw;
- var scroll_y = ih > vh;
- $popup.toggleClass('scroll-x', scroll_x);
- $popup.toggleClass('scroll-y', scroll_y);
- media.$media.width(iw);
- media.$media.height(ih);
- },
- onLoad: function() {
- if (!is_video) {
- media.$media.css('background-image', "url('" + media.mediaEl.src + "')");
- media.$media.removeClass('ohide');
- media.$wrap.removeClass('ohide').removeClass('file-loading').addClass('file-loaded');
- media.onResize();
- }
- },
- onZoomInOut: function(e) {
- if (!is_video) {
- var photo = media.$media.get(0);
- var dx, dy, px, py, sx, sy, rect;
- rect = photo.getBoundingClientRect();
- dx = e.clientX - rect.left;
- dy = e.clientY - rect.top;
- px = dx / rect.width;
- py = dy / rect.height;
- $popup.toggleClass('fullsize');
- media.onResize();
- rect = photo.getBoundingClientRect();
- dx = px * rect.width;
- dy = py * rect.height;
- sx = e.clientX - dx - rect.left - $popup.scrollLeft();
- sy = e.clientY - dy - rect.top - $popup.scrollTop();
- $popup.scrollLeft(-sx);
- $popup.scrollTop(-sy);
- }
- },
- onKeysPress: function(e) {
- if (e.keyCode == Keys.LEFT) {
- media.onPrevMedia(e);
- } else if (e.keyCode == Keys.RIGHT) {
- media.onNextMedia(e);
- } else if (e.keyCode == Keys.UP) {
- media.onPrevMediaGroup(e);
- } else if (e.keyCode == Keys.DOWN) {
- media.onNextMediaGroup(e);
- }
- },
- onPrevMedia: function(e) {
- if (options.pagination && options.pagination.prev) {
- e.preventDefault();
- e.stopImmediatePropagation();
- closePopup($popup);
- options.pagination.prev();
- }
- },
- onNextMedia: function(e) {
- if (options.pagination && options.pagination.next) {
- e.preventDefault();
- e.stopImmediatePropagation();
- closePopup($popup);
- options.pagination.next();
- }
- },
- onPrevMediaGroup: function(e) {
- if (options.pagination && options.pagination.prevGroup) {
- e.preventDefault();
- e.stopImmediatePropagation();
- closePopup($popup);
- options.pagination.prevGroup();
- }
- },
- onNextMediaGroup: function(e) {
- if (options.pagination && options.pagination.nextGroup) {
- e.preventDefault();
- e.stopImmediatePropagation();
- closePopup($popup);
- options.pagination.nextGroup();
- }
- }
- };
- if (is_video) {
- media.mediaEl = media.$media.get(0);
- } else {
- media.mediaEl = new Image();
- media.mediaEl.onload = media.onLoad;
- media.$wrap.on('click', media.onZoomInOut);
- }
- if (options.pagination) {
- $('.media-prev-btn', $popup).on('click', media.onPrevMedia);
- $('.media-next-btn', $popup).on('click', media.onNextMedia);
- $(document).on('keydown', media.onKeysPress);
- }
- $(window).on('resize', media.onResize);
- media.checkMediaSize();
- $popup.one('popup:close', function() {
- if (!is_video) {
- media.$media.off('click', media.onZoomInOut);
- }
- if (options.pagination) {
- $('.media-prev-btn', $popup).off('click', media.onPrevMedia);
- $('.media-next-btn', $popup).off('click', media.onNextMedia);
- $(document).off('keydown', media.onKeysPress);
- }
- $(window).off('resize', media.onResize);
- clearTimeout(media.timeout);
- $popup.remove();
- });
- openPopup($popup, {
- closeByClickOutside: '.popup-no-close',
- });
- if (options.width && options.height && options.cover) {
- media.width = parseInt(options.width);
- media.height = parseInt(options.height);
- media.cover = options.cover;
- media.$cover.css('background-image', "url('" + media.cover + "')").removeClass('ohide');
- media.onResize();
- }
- setTimeout(function() {
- media.$pwrap.get(0).classList.remove('ohide');
- }, 250);
- media.mediaEl.src = src;
- return $popup;
-}
-
-function showPhoto(image_src, options) {
- showMedia(image_src, false, options);
-}
-
-function showVideo(video_src, options) {
- showMedia(video_src, true, options);
-}
-
-function showToast(html, delay) {
- var $toast = $('
');
- $('.toast', $toast).html(html);
- var to, close = function() {
- clearTimeout(to);
- $toast.fadeHide();
- setTimeout(function() { $toast.remove(); }, 200);
- };
- $toast.appendTo('body').redraw().fadeShow();
- $(document).one('mousedown touchstart', close);
- to = setTimeout(close, delay || 2000);
-}
-
-function l(lang_key, params, def_value) {
- if (typeof params === 'string') {
- def_value = params;
- params = {};
- }
- params = params || {};
- var value = l._keys[lang_key] || def_value || lang_key;
- value = value.replace(/\{\{([A-Za-z_\-\d]{1,32}):(.+?)\}\}/g, function(lang_value, token, options) {
- var number = +params[token] || 0;
- var numeric_options = options.split('|');
- var i;
- if (number == 1) i = 0;
- else i = 1;
- if (typeof numeric_options[i] === 'undefined') {
- i = 1;
- }
- var numeric_option = numeric_options[i] || '#';
- return numeric_option.replace(/#/g, number);
- });
- value = value.replace(/\{([A-Za-z_\-\d]{1,32}):(.{1,256}?)\}/g, function(lang_value, token, options) {
- var number = +params[token] || 0;
- var numeric_options = options.split('|');
- var i;
- if (!number) i = 0;
- else if (number == 1) i = 1;
- else i = 2;
- if (typeof numeric_options[i] === 'undefined') {
- i = 0;
- }
- var numeric_option = numeric_options[i] || '#';
- return numeric_option.replace(/#/g, number);
- });
- for (var param in params) {
- value = value.split('{' + param + '}').join(params[param]);
- }
- return value;
-}
-l._keys = {};
-l.add = function(lang_values) {
- for (var lang_key in lang_values) {
- l._keys[lang_key] = lang_values[lang_key];
- }
-}
-
-function redraw(el) {
- el.offsetTop + 1;
-}
-
-$(document).on('keydown', function(e) {
- if (e.keyCode == Keys.ESC && Popups.length > 0) {
- var last_popup_id = Popups[Popups.length - 1];
- var $popup = getPopupById(last_popup_id);
- if ($popup && !$popup.hasClass('popup-ignore-esc')) {
- e.stopImmediatePropagation();
- e.preventDefault();
- closePopup($popup);
- }
- }
-});
-
-$(document).on('keydown', 'textarea', function(e) {
- if (e.keyCode == Keys.RETURN && (e.metaKey || e.ctrlKey)) {
- $(this.form).submit();
- }
-});
-
-(function($) {
- function onTextRippleStart(evt) {
- var e = evt.originalEvent;
- if (document.activeElement === this) return;
- var rect = this.getBoundingClientRect();
- if (e.type == 'touchstart') {
- var clientX = e.targetTouches[0].clientX;
- } else {
- var clientX = e.clientX;
- }
- var ripple = this.parentNode.querySelector('.textfield-item-underline');
- var rippleX = (clientX - rect.left) / this.offsetWidth * 100;
- ripple.style.transition = 'none';
- redraw(ripple);
- ripple.style.left = rippleX + '%';
- ripple.style.right = (100 - rippleX) + '%';
- redraw(ripple);
- ripple.style.left = '';
- ripple.style.right = '';
- ripple.style.transition = '';
- }
- function onRippleStart(evt) {
- var e = evt.originalEvent;
- var rippleMask = this.querySelector('.ripple-mask');
- if (!rippleMask) return;
- var rect = rippleMask.getBoundingClientRect();
- if (e.type == 'touchstart') {
- var clientX = e.targetTouches[0].clientX;
- var clientY = e.targetTouches[0].clientY;
- } else {
- var clientX = e.clientX;
- var clientY = e.clientY;
- }
- var rippleX = (clientX - rect.left) - rippleMask.offsetWidth / 2;
- var rippleY = (clientY - rect.top) - rippleMask.offsetHeight / 2;
- var ripple = this.querySelector('.ripple');
- ripple.style.transition = 'none';
- redraw(ripple);
- ripple.style.transform = 'translate3d(' + rippleX + 'px, ' + rippleY + 'px, 0) scale3d(0.2, 0.2, 1)';
- ripple.style.opacity = 1;
- redraw(ripple);
- ripple.style.transform = 'translate3d(' + rippleX + 'px, ' + rippleY + 'px, 0) scale3d(1, 1, 1)';
- ripple.style.transition = '';
-
- function onRippleEnd(e) {
- ripple.style.transitionDuration = '.2s';
- ripple.style.opacity = 0;
- document.removeEventListener('mouseup', onRippleEnd);
- document.removeEventListener('touchend', onRippleEnd);
- document.removeEventListener('touchcancel', onRippleEnd);
- }
- document.addEventListener('mouseup', onRippleEnd);
- document.addEventListener('touchend', onRippleEnd);
- document.addEventListener('touchcancel', onRippleEnd);
- }
- $.fn.initRipple = function() {
- return this.map(function(){
- $(this).off('.ripple');
- $(this).on('mousedown.ripple touchstart.ripple', '.textfield-item input.form-control', onTextRippleStart);
- $(this).on('mousedown.ripple touchstart.ripple', '.ripple-handler', onRippleStart);
- return this;
- });
- };
- $.fn.destroyRipple = function() {
- return this.map(function(){
- $(this).off('.ripple');
- return this;
- });
- };
-})(jQuery);
-$(document).initRipple();
-
-Function.prototype.pbind = function() {
- var func = this, args = Array.prototype.slice.apply(arguments);
- return function() {
- return func.apply(this, args.concat(Array.prototype.slice.apply(arguments)));
- }
-}