@@ -66,5 +66,56 @@ const loadWorkspace = () => {
66
66
} ;
67
67
} ;
68
68
69
+ const uploadToPastebin = ( ) => {
70
+ const code = luaGenerator . workspaceToCode ( ws ) ;
71
+ const xhr = new XMLHttpRequest ( ) ;
72
+ xhr . open ( 'POST' , 'https://pastebin.com/api/api_post.php' , true ) ;
73
+ xhr . setRequestHeader ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ;
74
+ xhr . onreadystatechange = ( ) => {
75
+ if ( xhr . readyState == 4 && xhr . status == 200 ) {
76
+ const url = xhr . responseText ;
77
+ const a = document . createElement ( 'a' ) ;
78
+ a . href = url ;
79
+ a . target = '_blank' ;
80
+ a . click ( ) ;
81
+ }
82
+ } ;
83
+ xhr . send ( `api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_key=d43a286490fa94b7d413dd2f5eb8d38d&api_folder_key=5BbL8uf5&api_option=paste&api_paste_code=${ encodeURIComponent ( code ) } &api_paste_private=1&api_paste_name=${ ( fileName . value || 'workspace' ) + ' | lua (' + Math . random ( ) . toString ( 36 ) . substring ( 7 ) + ')' } &api_paste_format=lua` ) ;
84
+ }
85
+
86
+ const uploadWorkspaceToPastebin = ( ) => {
87
+ const workspace = save ( ws ) ;
88
+ const xhr = new XMLHttpRequest ( ) ;
89
+ xhr . open ( 'POST' , 'https://pastebin.com/api/api_post.php' , true ) ;
90
+ xhr . setRequestHeader ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ;
91
+ xhr . onreadystatechange = ( ) => {
92
+ if ( xhr . readyState == 4 && xhr . status == 200 ) {
93
+ const url = xhr . responseText ;
94
+ const a = document . createElement ( 'a' ) ;
95
+ a . href = url ;
96
+ a . target = '_blank' ;
97
+ a . click ( ) ;
98
+ }
99
+ } ;
100
+ xhr . send ( `api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_key=d43a286490fa94b7d413dd2f5eb8d38d&api_folder_key=5BbL8uf5&api_option=paste&api_paste_code=${ encodeURIComponent ( workspace ) } &api_paste_private=1&api_paste_name=${ ( fileName . value || 'workspace' ) + ' | workspace (' + Math . random ( ) . toString ( 36 ) . substring ( 7 ) + ')' } &api_paste_format=json` ) ;
101
+ }
102
+
103
+ const loadWorkspaceFromPastebin = ( ) => {
104
+ const id = prompt ( 'Enter pastebin ID' ) ;
105
+ if ( ! id ) return ;
106
+ const xhr = new XMLHttpRequest ( ) ;
107
+ xhr . open ( 'GET' , `pastebin.php?id=${ id } ` , true ) ;
108
+ xhr . onreadystatechange = ( ) => {
109
+ if ( xhr . readyState == 4 && xhr . status == 200 ) {
110
+ load ( ws , xhr . responseText ) ;
111
+ console . log ( xhr . responseText ) ;
112
+ }
113
+ } ;
114
+ xhr . send ( ) ;
115
+ }
116
+
69
117
downloadButton . onclick = downloadWorkspace ;
118
+ uploadButton . onclick = uploadToPastebin ;
119
+ uploadWorkspaceButton . onclick = uploadWorkspaceToPastebin ;
120
+ loadWorkspaceButton . onclick = loadWorkspaceFromPastebin ;
70
121
loadButton . onclick = loadWorkspace ;
0 commit comments