Tech Tangents:Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<html> | <html> | ||
<script | <script> | ||
function make_page(crsf_token) | |||
{ | |||
console.log(crsf_token); | |||
} | |||
function upload_file() | |||
{ | |||
let fileInput = document.getElementById("tt-input"); | |||
let license = "=={{int:license-header}}==\n{{Non-free game cover}}", | |||
api = new mw.Api(); | |||
let param = { | |||
filename: fileInput.files[0].name, | |||
format: "json", | |||
ignorewarnings: 1, | |||
text: license | |||
}; | |||
api.upload(fileInput.files[0], param) | |||
.done(function (data) { | |||
console.log(data.upload.filename + " has sucessfully uploaded."); | |||
api.getEditToken() | |||
.done(function (data) { | |||
make_page(data); | |||
}).fail(function (data) { | |||
// I DON't CARE | |||
}); | |||
}) | |||
.fail(function (data) { | |||
console.log(data); | |||
}); | |||
} | |||
window.addEventListener("load", () => { | |||
let button = document.getElementById("tt-button"); | |||
let upload_result = false; | |||
button.addEventListener("click", () => {upload_file()}); | |||
}); | |||
</script> | |||
<input type="file" id="tt-input"/> | <input type="file" id="tt-input"/> | ||
<input type="button" id="tt-button" value="Upload" /> | <input type="button" id="tt-button" value="Upload" /> | ||
</html> | </html> |
Revision as of 18:21, 7 September 2024