10
10
box-sizing : border-box;
11
11
}
12
12
13
+ html {
14
+ display : flex;
15
+ align-content : center;
16
+ justify-content : center;
17
+ height : 100% ;
18
+ }
19
+
13
20
body {
14
21
margin : 0 ;
15
22
font-family : Arial, sans-serif;
16
23
display : flex;
17
- justify-content : center;
18
- align-items : center;
19
- height : 100vh ;
24
+ width : 100% ;
20
25
background-color : # f0f0f0 ;
21
26
}
22
27
23
28
.start-screen {
24
29
text-align : center;
30
+ margin : auto;
31
+ padding : 10px ;
25
32
}
26
33
27
34
h1 {
506
513
button .icon : last-child {
507
514
margin : 0 ;
508
515
}
516
+
517
+ @media (max-width : 630px ) {
518
+ .section-edit-panel , .section-add-panel-row , .item-edit-panel , .item-add-panel {
519
+ flex-direction : column;
520
+ align-items : flex-start;
521
+ }
522
+ }
509
523
</ style >
510
524
< style id ="dynamicStyles "> </ style >
511
525
< title > Limits Editor</ title >
@@ -921,7 +935,7 @@ <h1>Telegram Limits Editor</h1>
921
935
static noFsMode = false ;
922
936
923
937
static async openHelp ( source ) {
924
- alert ( "We're already working on documentation. Until then, for guidance, please contact contributors directly. " ) ;
938
+ alert ( "We're already working on documentation. Until then, for guidance, please contact @infowritebot " ) ;
925
939
}
926
940
927
941
static async suggestEdit ( ) {
@@ -1000,11 +1014,14 @@ <h1>Telegram Limits Editor</h1>
1000
1014
}
1001
1015
}
1002
1016
1017
+ const commitSha = this . latestCommitJson ? this . latestCommitJson . sha : undefined ;
1018
+
1003
1019
const data = {
1004
1020
structure : this . structure ,
1005
1021
localization : this . localization ,
1006
1022
description : desc ,
1007
1023
contact : dialog . querySelector ( '#contact' ) . value ,
1024
+ baseCommitSha : commitSha ,
1008
1025
} ;
1009
1026
1010
1027
const response = await fetch ( url , {
@@ -1111,7 +1128,7 @@ <h1>Telegram Limits Editor</h1>
1111
1128
button . textContent = 'Downloading...' ;
1112
1129
1113
1130
try {
1114
- const { structureBlob, localizationBlob, iconBlob, iconCodePointsBlob } = await this . downloadBlobs ( 'master' ) ;
1131
+ const { structureBlob, localizationBlob, iconBlob, iconCodePointsBlob, latestCommitsJson } = await this . downloadBlobs ( 'master' ) ;
1115
1132
1116
1133
const structureText = await structureBlob . text ( ) ;
1117
1134
const localizationText = await localizationBlob . text ( ) ;
@@ -1122,8 +1139,10 @@ <h1>Telegram Limits Editor</h1>
1122
1139
const iconObjectUrl = URL . createObjectURL ( iconBlob ) ;
1123
1140
const iconCodePointsMap = WorkDirHandle . parseIconCodePoints ( iconCodePointsText ) ;
1124
1141
1142
+ let latestCommitJson = latestCommitsJson ? latestCommitsJson [ 0 ] : null ;
1143
+
1125
1144
this . noFsMode = true ;
1126
- this . applyData ( { structure, localization, iconCodePointsMap, iconObjectUrl } ) ;
1145
+ this . applyData ( { structure, localization, iconCodePointsMap, iconObjectUrl, latestCommitJson } ) ;
1127
1146
} catch ( e ) {
1128
1147
console . error ( e ) ;
1129
1148
alert ( 'An error occurred while starting: ' + e . message ) ;
@@ -1134,23 +1153,27 @@ <h1>Telegram Limits Editor</h1>
1134
1153
}
1135
1154
1136
1155
static async downloadBlobs ( branchName ) {
1137
- const urlPrefix = 'https://raw.githubusercontent.com/tginfo/Telegram-Limits/' + branchName ;
1156
+ const repo = 'tginfo/Telegram-Limits' ;
1157
+ const urlPrefix = `https://raw.githubusercontent.com/${ repo } /` + branchName ;
1138
1158
const structureUrl = `${ urlPrefix } /data/structure.json` ;
1139
1159
const localizationUrl = `${ urlPrefix } /localization/en/data.json` ;
1140
1160
const iconUrl = `${ urlPrefix } /assets/images/icons.woff2` ;
1141
1161
const iconCodePointsUrl = `${ urlPrefix } /assets/images/icons.codepoints` ;
1162
+ const latestCommitsUrl = `https://api.github.com/repos/${ repo } /commits?sha=${ branchName } &per_page=1` ;
1142
1163
1143
1164
const structureResponse = await fetch ( structureUrl ) ;
1144
1165
const localizationResponse = await fetch ( localizationUrl ) ;
1145
1166
const iconResponse = await fetch ( iconUrl ) ;
1146
1167
const iconCodePointsResponse = await fetch ( iconCodePointsUrl ) ;
1168
+ const latestCommitsResponse = await fetch ( latestCommitsUrl ) ;
1147
1169
1148
1170
const structureBlob = await structureResponse . blob ( ) ;
1149
1171
const localizationBlob = await localizationResponse . blob ( ) ;
1150
1172
const iconBlob = await iconResponse . blob ( ) ;
1151
1173
const iconCodePointsBlob = await iconCodePointsResponse . blob ( ) ;
1174
+ const latestCommitsJson = await latestCommitsResponse . json ( ) ;
1152
1175
1153
- return { structureBlob, localizationBlob, iconBlob, iconCodePointsBlob } ;
1176
+ return { structureBlob, localizationBlob, iconBlob, iconCodePointsBlob, latestCommitsJson } ;
1154
1177
}
1155
1178
1156
1179
static async downloadFiles ( ) {
@@ -1224,6 +1247,7 @@ <h1>Telegram Limits Editor</h1>
1224
1247
this . localization = data . localization ;
1225
1248
this . iconCodePointsMap = data . iconCodePointsMap ;
1226
1249
this . iconObjectUrl = data . iconObjectUrl ;
1250
+ this . latestCommitJson = data . latestCommitJson ;
1227
1251
1228
1252
this . editor = new LimitsEditor ( this . structure , this . localization , this . iconCodePointsMap ) ;
1229
1253
@@ -1391,6 +1415,18 @@ <h1>Telegram Limits Editor</h1>
1391
1415
sectionDragHandle . textContent = 'drag_indicator' ;
1392
1416
sectionDragHandle . title = 'Drag to reorder' ;
1393
1417
sectionElement . appendChild ( sectionDragHandle ) ;
1418
+
1419
+ sectionDragHandle . addEventListener ( 'touchstart' , ( e ) => {
1420
+ const touchTime = performance . now ( ) ;
1421
+
1422
+ sectionDragHandle . addEventListener ( 'touchend' , ( e ) => {
1423
+ const touchDuration = performance . now ( ) - touchTime ;
1424
+ if ( touchDuration < 300 ) {
1425
+ alert ( 'Sorry, only mouse pointer can be used to rearrange sections' ) ;
1426
+ }
1427
+ } , { once : true } ) ;
1428
+ } ) ;
1429
+
1394
1430
sectionDragHandle . addEventListener ( 'mousedown' , ( e ) => {
1395
1431
sectionElement . draggable = true ;
1396
1432
@@ -1759,6 +1795,18 @@ <h1>Telegram Limits Editor</h1>
1759
1795
itemDragHandle . textContent = 'drag_indicator' ;
1760
1796
itemDragHandle . title = 'Drag to reorder' ;
1761
1797
itemElement . appendChild ( itemDragHandle ) ;
1798
+
1799
+ itemDragHandle . addEventListener ( 'touchstart' , ( e ) => {
1800
+ const touchTime = performance . now ( ) ;
1801
+
1802
+ itemDragHandle . addEventListener ( 'touchend' , ( e ) => {
1803
+ const touchDuration = performance . now ( ) - touchTime ;
1804
+ if ( touchDuration < 300 ) {
1805
+ alert ( "Sorry, only mouse pointer can be used to move items" )
1806
+ }
1807
+ } , { once : true } ) ;
1808
+ } ) ;
1809
+
1762
1810
itemDragHandle . addEventListener ( 'mousedown' , ( e ) => {
1763
1811
itemElement . draggable = true ;
1764
1812
0 commit comments