Browse Source

Fix firefox message input height

New favicons
New manifest
master
Eduard Kuzmenko 4 years ago
parent
commit
2660e791d1
  1. 9
      server.js
  2. 9
      src/components/appSearchSuper..ts
  3. 4
      src/components/inputField.ts
  4. 5
      src/components/passwordInputField.ts
  5. 3
      src/components/popups/datePicker.ts
  6. 3
      src/components/sidebarLeft/tabs/background.ts
  7. 61
      src/helpers/color.ts
  8. 1
      src/helpers/date.ts
  9. 24
      src/index.hbs
  10. 33
      src/lib/appManagers/appImManager.ts
  11. 3
      src/lib/appManagers/appStateManager.ts
  12. 2
      src/scss/partials/_chat.scss
  13. 2
      src/scss/partials/_rightSidebar.scss
  14. 1
      src/scss/partials/pages/_pages.scss

9
server.js

@ -1,14 +1,17 @@
const compression = require('compression'); const compression = require('compression');
const express = require('express'); const express = require('express');
const https = require('https'); const https = require('https');
const http = require('http');
const fs = require('fs'); const fs = require('fs');
const app = express(); const app = express();
const thirdTour = process.argv[2] == 3; const thirdTour = process.argv[2] == 3;
const forcePort = process.argv[3];
const useHttp = process.argv[4] === 'http';
const publicFolderName = thirdTour ? 'public3' : 'public'; const publicFolderName = thirdTour ? 'public3' : 'public';
const port = thirdTour ? 8443 : 8443; const port = forcePort ? +forcePort : (thirdTour ? 8443 : 8443);
app.use(compression()); app.use(compression());
app.use(express.static(publicFolderName)); app.use(express.static(publicFolderName));
@ -17,7 +20,9 @@ app.get('/', (req, res) => {
res.sendFile(__dirname + `/${publicFolderName}/index.html`); res.sendFile(__dirname + `/${publicFolderName}/index.html`);
}); });
https.createServer({ const server = useHttp ? http : https;
server.createServer({
key: fs.readFileSync(__dirname + '/certs/server-key.pem'), key: fs.readFileSync(__dirname + '/certs/server-key.pem'),
cert: fs.readFileSync(__dirname + '/certs/server-cert.pem') cert: fs.readFileSync(__dirname + '/certs/server-cert.pem')
}, app).listen(port, () => { }, app).listen(port, () => {

9
src/components/appSearchSuper..ts

@ -914,9 +914,14 @@ export default class AppSearchSuper {
return; return;
} }
console.log('anymore', chatFull); //console.log('anymore', chatFull);
this.loaded[mediaTab.inputFilter] = true; this.loaded[mediaTab.inputFilter] = true;
return renderParticipants((chatFull.participants as ChatParticipants.chatParticipants).participants); const participants = chatFull.participants;
if(participants._ === 'chatParticipantsForbidden') {
return;
}
return renderParticipants(participants.participants);
}); });
} }

4
src/components/inputField.ts

@ -153,6 +153,10 @@ class InputField {
if(placeholder) { if(placeholder) {
_i18n(input, placeholder, undefined, 'placeholder'); _i18n(input, placeholder, undefined, 'placeholder');
if(this.inputFake) {
_i18n(this.inputFake, placeholder, undefined, 'placeholder');
}
} }
if(label) { if(label) {

5
src/components/passwordInputField.ts

@ -22,6 +22,11 @@ export default class PasswordInputField extends InputField {
input.type = 'password'; input.type = 'password';
input.setAttribute('required', ''); input.setAttribute('required', '');
input.autocomplete = 'off'; input.autocomplete = 'off';
input.readOnly = true;
input.addEventListener('focus', () => {
input.removeAttribute('readonly');
}, {once: true});
const toggleVisible = this.toggleVisible = document.createElement('span'); const toggleVisible = this.toggleVisible = document.createElement('span');
toggleVisible.classList.add('toggle-visible', 'tgico'); toggleVisible.classList.add('toggle-visible', 'tgico');

3
src/components/popups/datePicker.ts

@ -248,8 +248,7 @@ export default class PopupDatePicker extends PopupElement {
const timeOptions: Intl.DateTimeFormatOptions = { const timeOptions: Intl.DateTimeFormatOptions = {
minute: '2-digit', minute: '2-digit',
hour: '2-digit', hour: '2-digit'
hour12: false
}; };
const sendDate = new Date(this.selectedDate.getTime()); const sendDate = new Date(this.selectedDate.getTime());

3
src/components/sidebarLeft/tabs/background.ts

@ -18,7 +18,6 @@ import appImManager from "../../../lib/appManagers/appImManager";
import appStateManager from "../../../lib/appManagers/appStateManager"; import appStateManager from "../../../lib/appManagers/appStateManager";
import apiManager from "../../../lib/mtproto/mtprotoworker"; import apiManager from "../../../lib/mtproto/mtprotoworker";
import rootScope from "../../../lib/rootScope"; import rootScope from "../../../lib/rootScope";
import Button from "../../button";
import CheckboxField from "../../checkboxField"; import CheckboxField from "../../checkboxField";
import ProgressivePreloader from "../../preloader"; import ProgressivePreloader from "../../preloader";
import { SliderSuperTab } from "../../slider"; import { SliderSuperTab } from "../../slider";
@ -92,7 +91,7 @@ export default class AppBackgroundTab extends SliderSuperTab {
rootScope.settings.background.slug = slug; rootScope.settings.background.slug = slug;
rootScope.settings.background.type = 'image'; rootScope.settings.background.type = 'image';
rootScope.settings.background.highlightningColor = hsla; rootScope.settings.background.highlightningColor = hsla;
document.documentElement.style.setProperty('--message-highlightning-color', rootScope.settings.background.highlightningColor); appImManager.applyBackgroundColor();
appStateManager.pushToState('settings', rootScope.settings); appStateManager.pushToState('settings', rootScope.settings);
saveToCache(slug, url); saveToCache(slug, url);

61
src/helpers/color.ts

@ -36,6 +36,65 @@ export function rgbToHsl(r: number, g: number, b: number) {
}); });
} }
// * https://stackoverflow.com/a/9493060/6758968
/**
* Converts an HSL color value to RGB. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes h, s, and l are contained in the set [0, 1] and
* returns r, g, and b in the set [0, 255].
*
* @param {number} h The hue
* @param {number} s The saturation
* @param {number} l The lightness
* @return {Array} The RGB representation
*/
export function hslToRgba(h: number, s: number, l: number, a: number) {
let r: number, g: number, b: number;
if(s === 0) {
r = g = b = l; // achromatic
} else {
const hue2rgb = function hue2rgb(p: number, q: number, t: number) {
if(t < 0) t += 1;
if(t > 1) t -= 1;
if(t < 1/6) return p + (q - p) * 6 * t;
if(t < 1/2) return q;
if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
return p;
}
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
r = hue2rgb(p, q, h + 1/3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1/3);
}
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), Math.round(a * 255)];
}
export function hslaStringToRgba(hsla: string) {
const splitted = hsla.slice(5, -1).split(', ');
const alpha = +splitted.pop();
const arr = splitted.map((val) => {
if(val.endsWith('%')) {
return +val.slice(0, -1) / 100;
}
return +val / 360;
});
return hslToRgba(arr[0], arr[1], arr[2], alpha);
}
export function hslaStringToRgbaString(hsla: string) {
return '#' + hslaStringToRgba(hsla).map(v => ('0' + v.toString(16)).slice(-2)).join('');
}
export function hslaStringToRgbString(hsla: string) {
return hslaStringToRgbaString(hsla).slice(0, -2);
}
// * https://github.com/TelegramMessenger/Telegram-iOS/blob/3d062fff78cc6b287c74e6171f855a3500c0156d/submodules/TelegramPresentationData/Sources/PresentationData.swift#L453 // * https://github.com/TelegramMessenger/Telegram-iOS/blob/3d062fff78cc6b287c74e6171f855a3500c0156d/submodules/TelegramPresentationData/Sources/PresentationData.swift#L453
export function highlightningColor(pixel: Uint8ClampedArray) { export function highlightningColor(pixel: Uint8ClampedArray) {
let {h, s, l} = rgbToHsl(pixel[0], pixel[1], pixel[2]); let {h, s, l} = rgbToHsl(pixel[0], pixel[1], pixel[2]);
@ -46,4 +105,4 @@ export function highlightningColor(pixel: Uint8ClampedArray) {
const hsla = `hsla(${h * 360}, ${s * 100}%, ${l * 100}%, .4)`; const hsla = `hsla(${h * 360}, ${s * 100}%, ${l * 100}%, .4)`;
return hsla; return hsla;
}; }

1
src/helpers/date.ts

@ -48,7 +48,6 @@ export function formatDateAccordingToTodayNew(time: Date) {
const options: Intl.DateTimeFormatOptions = {}; const options: Intl.DateTimeFormatOptions = {};
if((now - timestamp) < ONE_DAY && today.getDate() === time.getDate()) { // if the same day if((now - timestamp) < ONE_DAY && today.getDate() === time.getDate()) { // if the same day
options.hour = options.minute = '2-digit'; options.hour = options.minute = '2-digit';
options.hour12 = false;
} else if(today.getFullYear() !== time.getFullYear()) { // different year } else if(today.getFullYear() !== time.getFullYear()) { // different year
options.year = options.day = 'numeric'; options.year = options.day = 'numeric';
options.month = '2-digit'; options.month = '2-digit';

24
src/index.hbs

@ -4,16 +4,22 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Telegram Web</title> <title>Telegram Web</title>
<meta name="description" content=""> <meta name="description" content="Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="180x180" href="/assets/img/apple-touch-icon.png?v=jw3mK7G9Ry">
<link rel="icon" type="image/png" sizes="32x32" href="assets/img/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon-32x32.png?v=jw3mK7G9Ry">
<!--<link rel="icon" type="image/png" sizes="16x16" href="assets/img/favicon-16x16.png">--> <!--<link rel="icon" type="image/png" sizes="192x192" href="/assets/img/android-chrome-192x192.png?v=jw3mK7G9Ry">
<link rel="manifest" href="site.webmanifest"> <link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon-16x16.png?v=jw3mK7G9Ry">-->
<link rel="mask-icon" href="assets/img/safari-pinned-tab.svg" color="#64a3f0"> <link rel="manifest" href="/assets/img/site.webmanifest?v=jw3mK7G9Ry">
<meta name="msapplication-TileColor" content="#da532c"> <link rel="mask-icon" href="/assets/img/safari-pinned-tab.svg?v=jw3mK7G9Ry" color="#3390ec">
<meta name="theme-color" content="#fafafa"> <link rel="shortcut icon" href="/assets/img/favicon.ico?v=jw3mK7G9Ry">
<meta name="apple-mobile-web-app-title" content="Telegram WebK">
<meta name="application-name" content="Telegram WebK">
<meta name="msapplication-TileColor" content="#2d89ef">
<meta name="msapplication-TileImage" content="/assets/img/mstile-144x144.png?v=jw3mK7G9Ry">
<meta name="msapplication-config" content="/assets/img/browserconfig.xml?v=jw3mK7G9Ry">
<meta name="theme-color" content="#ffffff">
{{# each htmlWebpackPlugin.files.css }} {{# each htmlWebpackPlugin.files.css }}
<link rel="stylesheet" href="{{ this }}"> <link rel="stylesheet" href="{{ this }}">
{{/ each }} {{/ each }}
@ -64,7 +70,7 @@
<svg style="position: absolute; top: -10000px; left: -10000px;"> <svg style="position: absolute; top: -10000px; left: -10000px;">
<defs id="svg-defs"> <defs id="svg-defs">
<path id="message-tail" d="M1.00002881,1.03679295e-14 L7,0 L7,17 C6.8069969,14.1607017 6.12380234,11.2332513 4.95041634,8.21764872 C4.04604748,5.89342034 2.50413132,3.73337411 0.324667862,1.73751004 L0.324652538,1.73752677 C-0.0826597201,1.36452676 -0.110475289,0.731958677 0.262524727,0.324646419 C0.451952959,0.117792698 0.719544377,1.0985861e-14 1.00002881,1.04360964e-14 Z"></path> <path id="message-tail" d="M1.00002881,1.03679295e-14 L7,0 L7,17 C6.8069969,14.1607017 6.12380234,11.2332513 4.95041634,8.21764872 C4.04604748,5.89342034 2.50413132,3.73337411 0.324667862,1.73751004 L0.324652538,1.73752677 C-0.0826597201,1.36452676 -0.110475289,0.731958677 0.262524727,0.324646419 C0.451952959,0.117792698 0.719544377,1.0985861e-14 1.00002881,1.04360964e-14 Z"></path>
<path id="logo" fill="#50A2E9" fill-rule="evenodd" d="M80,0 C124.18278,0 160,35.81722 160,80 C160,124.18278 124.18278,160 80,160 C35.81722,160 0,124.18278 0,80 C0,35.81722 35.81722,0 80,0 Z M114.262551,46.4516129 L114.123923,46.4516129 C111.089589,46.5056249 106.482806,48.0771432 85.1289541,56.93769 L81.4133571,58.4849956 C72.8664779,62.0684477 57.2607933,68.7965125 34.5963033,78.66919 C30.6591745,80.2345564 28.5967328,81.765936 28.4089783,83.2633288 C28.0626453,86.0254269 31.8703852,86.959903 36.7890378,88.5302703 L38.2642674,89.0045258 C42.3926354,90.314406 47.5534685,91.7248852 50.3250916,91.7847532 C52.9151948,91.8407003 55.7944784,90.8162976 58.9629426,88.7115451 L70.5121776,80.9327422 C85.6657026,70.7535853 93.6285785,65.5352892 94.4008055,65.277854 L94.6777873,65.216416 C95.1594319,65.1213105 95.7366278,65.0717596 96.1481181,65.4374337 C96.6344248,65.8695939 96.5866185,66.6880224 96.5351057,66.9075859 C96.127514,68.6448691 75.2839361,87.6143392 73.6629144,89.2417998 L73.312196,89.6016896 C68.7645143,94.2254793 63.9030972,97.1721503 71.5637945,102.355193 L73.3593638,103.544598 C79.0660342,107.334968 82.9483395,110.083813 88.8107882,113.958377 L90.3875424,114.996094 C95.0654739,118.061953 98.7330313,121.697601 103.562866,121.253237 C105.740839,121.052855 107.989107,119.042224 109.175465,113.09692 L109.246762,112.727987 C112.002037,98.0012935 117.417883,66.09303 118.669527,52.9443975 C118.779187,51.7924073 118.641237,50.318088 118.530455,49.6708963 L118.474159,49.3781963 C118.341081,48.7651315 118.067967,48.0040758 117.346762,47.4189793 C116.412565,46.6610871 115.002114,46.4638844 114.262551,46.4516129 Z"/> <path id="logo" fill-rule="evenodd" d="M80,0 C124.18278,0 160,35.81722 160,80 C160,124.18278 124.18278,160 80,160 C35.81722,160 0,124.18278 0,80 C0,35.81722 35.81722,0 80,0 Z M114.262551,46.4516129 L114.123923,46.4516129 C111.089589,46.5056249 106.482806,48.0771432 85.1289541,56.93769 L81.4133571,58.4849956 C72.8664779,62.0684477 57.2607933,68.7965125 34.5963033,78.66919 C30.6591745,80.2345564 28.5967328,81.765936 28.4089783,83.2633288 C28.0626453,86.0254269 31.8703852,86.959903 36.7890378,88.5302703 L38.2642674,89.0045258 C42.3926354,90.314406 47.5534685,91.7248852 50.3250916,91.7847532 C52.9151948,91.8407003 55.7944784,90.8162976 58.9629426,88.7115451 L70.5121776,80.9327422 C85.6657026,70.7535853 93.6285785,65.5352892 94.4008055,65.277854 L94.6777873,65.216416 C95.1594319,65.1213105 95.7366278,65.0717596 96.1481181,65.4374337 C96.6344248,65.8695939 96.5866185,66.6880224 96.5351057,66.9075859 C96.127514,68.6448691 75.2839361,87.6143392 73.6629144,89.2417998 L73.312196,89.6016896 C68.7645143,94.2254793 63.9030972,97.1721503 71.5637945,102.355193 L73.3593638,103.544598 C79.0660342,107.334968 82.9483395,110.083813 88.8107882,113.958377 L90.3875424,114.996094 C95.0654739,118.061953 98.7330313,121.697601 103.562866,121.253237 C105.740839,121.052855 107.989107,119.042224 109.175465,113.09692 L109.246762,112.727987 C112.002037,98.0012935 117.417883,66.09303 118.669527,52.9443975 C118.779187,51.7924073 118.641237,50.318088 118.530455,49.6708963 L118.474159,49.3781963 C118.341081,48.7651315 118.067967,48.0040758 117.346762,47.4189793 C116.412565,46.6610871 115.002114,46.4638844 114.262551,46.4516129 Z"/>
<path id="poll-line" d="M4.47,5.33v13.6c0,4.97,4.03,9,9,9h458.16"/> <path id="poll-line" d="M4.47,5.33v13.6c0,4.97,4.03,9,9,9h458.16"/>
<path id="check" fill="none" d="M 4.7071 12.2929 l 5 5 c 0.3905 0.3905 1.0237 0.3905 1.4142 0 l 11 -11" /> <path id="check" fill="none" d="M 4.7071 12.2929 l 5 5 c 0.3905 0.3905 1.0237 0.3905 1.4142 0 l 11 -11" />
<symbol id="message-tail-filled" viewBox="0 0 11 20"> <symbol id="message-tail-filled" viewBox="0 0 11 20">

33
src/lib/appManagers/appImManager.ts

@ -45,7 +45,7 @@ import appNotificationsManager from './appNotificationsManager';
import AppPrivateSearchTab from '../../components/sidebarRight/tabs/search'; import AppPrivateSearchTab from '../../components/sidebarRight/tabs/search';
import { i18n } from '../langPack'; import { i18n } from '../langPack';
import { SendMessageAction } from '../../layer'; import { SendMessageAction } from '../../layer';
import { highlightningColor } from '../../helpers/color'; import { highlightningColor, hslaStringToRgbString } from '../../helpers/color';
import { getObjectKeysAndSort } from '../../helpers/object'; import { getObjectKeysAndSort } from '../../helpers/object';
import { getFilesFromEvent } from '../../helpers/files'; import { getFilesFromEvent } from '../../helpers/files';
@ -79,6 +79,7 @@ export class AppImManager {
private chatsSelectTabDebounced: () => void; private chatsSelectTabDebounced: () => void;
public markupTooltip: MarkupTooltip; public markupTooltip: MarkupTooltip;
private themeColorElem: Element;
get myId() { get myId() {
return rootScope.myId; return rootScope.myId;
@ -278,19 +279,39 @@ export class AppImManager {
return sessionStorage.getFromCache('chatPositions')[key]; return sessionStorage.getFromCache('chatPositions')[key];
} }
private setSettings = () => { public applyBackgroundColor() {
document.documentElement.style.setProperty('--messages-text-size', rootScope.settings.messagesTextSize + 'px'); let hsla: string;
if(rootScope.settings.nightTheme) { if(rootScope.settings.nightTheme) {
document.documentElement.style.setProperty('--message-highlightning-color', highlightningColor(new Uint8ClampedArray([15, 15, 15, 1]))); hsla = highlightningColor(new Uint8ClampedArray([15, 15, 15, 1]));
document.documentElement.style.setProperty('--message-highlightning-color', hsla);
} else { } else {
if(rootScope.settings.background.highlightningColor) { if(rootScope.settings.background.highlightningColor) {
document.documentElement.style.setProperty('--message-highlightning-color', rootScope.settings.background.highlightningColor); hsla = rootScope.settings.background.highlightningColor;
document.documentElement.style.setProperty('--message-highlightning-color', hsla);
} else { } else {
document.documentElement.style.removeProperty('--message-highlightning-color'); document.documentElement.style.removeProperty('--message-highlightning-color');
} }
} }
let themeColor = '#ffffff';
if(hsla) {
themeColor = hslaStringToRgbString(hsla);
}
if(this.themeColorElem === undefined) {
this.themeColorElem = document.head.querySelector('[name="theme-color"]') as Element || null;
}
if(this.themeColorElem) {
this.themeColorElem.setAttribute('content', themeColor);
}
}
private setSettings = () => {
document.documentElement.style.setProperty('--messages-text-size', rootScope.settings.messagesTextSize + 'px');
this.applyBackgroundColor();
document.documentElement.classList.toggle('night', rootScope.settings.nightTheme); document.documentElement.classList.toggle('night', rootScope.settings.nightTheme);
document.body.classList.toggle('animation-level-0', !rootScope.settings.animationsEnabled); document.body.classList.toggle('animation-level-0', !rootScope.settings.animationsEnabled);

3
src/lib/appManagers/appStateManager.ts

@ -118,7 +118,8 @@ export const STATE_INIT: State = {
background: { background: {
type: 'image', type: 'image',
blur: false, blur: false,
slug: 'ByxGo2lrMFAIAAAAmkJxZabh8eM', // * new blurred camomile slug: 'ByxGo2lrMFAIAAAAmkJxZabh8eM', // * new blurred camomile,
highlightningColor: 'hsla(85.5319, 36.9171%, 40.402%, 0.4)'
}, },
notifications: { notifications: {
sound: false sound: false

2
src/scss/partials/_chat.scss

@ -594,7 +594,7 @@ $chat-helper-size: 39px;
@include respond-to(medium-screens) { @include respond-to(medium-screens) {
@include animation-level(2) { @include animation-level(2) {
// !WARNING, МАГИЧЕСКОЕ ЧИСЛО // !WARNING, МАГИЧЕСКОЕ ЧИСЛО
margin: -16.5rem 0 -20rem 0; margin: -18.5rem 0 -22rem 0;
transform: scale(1); transform: scale(1);
transform-origin: left center; transform-origin: left center;
transition: transform var(--transition-standard-out), opacity var(--transition-standard-out) !important; transition: transform var(--transition-standard-out), opacity var(--transition-standard-out) !important;

2
src/scss/partials/_rightSidebar.scss

@ -9,7 +9,7 @@
overflow: unset; overflow: unset;
@include respond-to(only-small-screens) { @include respond-to(only-small-screens) {
box-shadow: 0 0.25rem 0.5rem 0.1rem hsla(0, 0%, 44.7%, .25); box-shadow: 0 0.25rem 0.5rem 0.1rem rgba(0, 0, 0, .2);
} }
@include respond-to(handhelds) { @include respond-to(handhelds) {

1
src/scss/partials/pages/_pages.scss

@ -153,6 +153,7 @@
.sign-logo { .sign-logo {
max-width: 100%; max-width: 100%;
max-height: 100%; max-height: 100%;
fill: var(--primary-color);
} }
.page-sign, .page-signQR { .page-sign, .page-signQR {

Loading…
Cancel
Save