Tech Tangents:Sandbox: Difference between revisions

From Tech Tangents
Jump to navigation Jump to search
(Replaced content with "<html> <script> var param = { filename: 'File_1.jpg', format: 'json', ignorewarnings: 1 }, fileInput = $( '<input/>' ).attr( 'type', 'file' ), submitBtn = $( '<input/>' ).attr( 'type', 'button' ).attr( 'value', 'Upload' ), api = new mw.Api(); $( '#bodyContent' ).append( [ fileInput, submitBtn ] ); $( submitBtn ).on( 'click', function () { api.upload( fileInput[ 0 ], param ).done( function ( data ) { console.log( data.upload.filename + ' has sucessfull...")
Tag: Replaced
No edit summary
Line 1: Line 1:
<html>
<html>


<script>
  <input type="file" />
var param = {
  <input type="button" id="tt-button" value="Upload" />
filename: 'File_1.jpg',
format: 'json',
ignorewarnings: 1
},
fileInput = $( '<input/>' ).attr( 'type', 'file' ),
submitBtn = $( '<input/>' ).attr( 'type', 'button' ).attr( 'value', 'Upload' ),
api = new mw.Api();


$( '#bodyContent' ).append( [ fileInput, submitBtn ] );
  <script>
    window.addEventListener("load", () => {
      const api = new mw.Api();


$( submitBtn ).on( 'click', function () {
      document.getElementById("tt-button", () => {
api.upload( fileInput[ 0 ], param ).done( function ( data ) {
        let param = {
console.log( data.upload.filename + ' has sucessfully uploaded.' );
          filename: "File_1.jpg",
} ).fail( function ( data ) {
          format: "json",
console.log( data );
          ignorewarnings: 1,
} );
        };
} );
 
</script>
        api
          .upload(fileInput[0], param)
          .done(function (data) {
            console.log(data.upload.filename + " has sucessfully uploaded.");
          })
          .fail(function (data) {
            console.log(data);
          });
      });
    });
  </script>
</html>
</html>

Revision as of 20:35, 6 September 2024