@@ -831,6 +831,79 @@ <h1>Telegram Limits Editor</h1>
831
831
static contentElement = null ;
832
832
static draggingType = null ;
833
833
834
+ static async openHelp ( source ) {
835
+ alert ( "We're already working on documentation. Until then, for guidance, please contact contributors directly." ) ;
836
+ }
837
+
838
+ static async suggestEdit ( ) {
839
+ try {
840
+ const dialog = document . createElement ( 'dialog' ) ;
841
+ dialog . innerHTML = `
842
+ <form method="dialog">
843
+ <article>
844
+ <p>
845
+ <b>Note:</b> We do not accept translations through this form.
846
+ Please go to <a href="https://crowdin.com/project/telegram-limits" target="_blank">Crowdin</a> for translation.
847
+ </p>
848
+ </article>
849
+ <label>
850
+ <span>Description:</span>
851
+ <textarea id="description" rows="5" style="width: 100%;" placeholder="Describe changes you've made" maxlength="800"></textarea>
852
+ </label>
853
+ <label>
854
+ <span>Contact:</span>
855
+ <input id="contact" type="text" style="width: 100%;" placeholder="Telegram username, email, etc." maxlength="100">
856
+ </label>
857
+ <menu style="display: flex; padding: 0;">
858
+ <button id="cancelButton" value="cancel" class="secondary">Cancel</button>
859
+ <button id="sendButton" value="send" class="trailing-container">Send</button>
860
+ </menu>
861
+ </form>
862
+ ` ;
863
+
864
+ dialog . querySelector ( '#cancelButton' ) . addEventListener ( 'click' , ( ) => {
865
+ dialog . close ( ) ;
866
+ dialog . remove ( ) ;
867
+ } ) ;
868
+ dialog . querySelector ( '#sendButton' ) . addEventListener ( 'click' , async ( ) => {
869
+ try {
870
+ const url = 'https://limits.tginfo.me/prop/suggest.php' ;
871
+
872
+ const data = {
873
+ structure : this . structure ,
874
+ localization : this . localization ,
875
+ description : dialog . querySelector ( '#description' ) . value ,
876
+ contact : dialog . querySelector ( '#contact' ) . value ,
877
+ } ;
878
+
879
+ const response = await fetch ( url , {
880
+ method : 'POST' ,
881
+ headers : {
882
+ 'Content-Type' : 'application/json' ,
883
+ } ,
884
+ body : JSON . stringify ( data ) ,
885
+ } ) ;
886
+
887
+ const responseText = await response . text ( ) ;
888
+ if ( response . ok ) {
889
+ alert ( '✅ Suggestion sent successfully:\n\n' + responseText ) ;
890
+ } else {
891
+ alert ( '⛔️ An error occurred while sending the suggestion:\n\n' + responseText ) ;
892
+ }
893
+ } catch ( e ) {
894
+ console . error ( e ) ;
895
+ alert ( 'An error occurred while sending the suggestion: ' + e . message ) ;
896
+ }
897
+ } ) ;
898
+
899
+ document . body . appendChild ( dialog ) ;
900
+ dialog . showModal ( ) ;
901
+ } catch ( e ) {
902
+ console . error ( e ) ;
903
+ alert ( 'An error occurred while sending the suggestion: ' + e . message ) ;
904
+ }
905
+ }
906
+
834
907
static async check ( ) {
835
908
if ( ! ( 'showDirectoryPicker' in window ) ) {
836
909
alert ( 'Your browser does not support the File System Access API. ' +
@@ -1024,13 +1097,23 @@ <h1>Telegram Limits Editor</h1>
1024
1097
helpButton . classList . add ( 'icon' ) ;
1025
1098
helpButton . classList . add ( 'secondary' ) ;
1026
1099
helpButton . textContent = 'help' ;
1100
+ helpButton . title = 'Help & Documentation' ;
1027
1101
helpButton . addEventListener ( 'click' , ( ) => EditorUi . openHelp ( "toolbar" ) ) ;
1028
1102
toolbar . appendChild ( helpButton ) ;
1029
1103
1104
+ const sendButton = document . createElement ( 'button' ) ;
1105
+ sendButton . classList . add ( 'icon' ) ;
1106
+ sendButton . classList . add ( 'secondary' ) ;
1107
+ sendButton . textContent = 'send' ;
1108
+ sendButton . title = 'Send The Edit to @tginfo' ;
1109
+ sendButton . addEventListener ( 'click' , ( ) => EditorUi . suggestEdit ( ) ) ;
1110
+ toolbar . appendChild ( sendButton ) ;
1111
+
1030
1112
const saveButton = document . createElement ( 'button' ) ;
1031
1113
saveButton . classList . add ( 'icon' ) ;
1032
1114
saveButton . classList . add ( 'secondary' ) ;
1033
1115
saveButton . textContent = 'save' ;
1116
+ saveButton . title = 'Save to Disk' ;
1034
1117
saveButton . addEventListener ( 'click' , ( ) => this . save ( ) ) ;
1035
1118
toolbar . appendChild ( saveButton ) ;
1036
1119
0 commit comments