Skip to content

@cw /app.js
Last active

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
App = function();
App.prototype.write_file = function(filename, code) {
var elements, elem, evt;
// remove existing WriteFileElem
elements = document.getElementsByTagName('WriteFileElem');
while (elements[0]) elements[0].parentNode.removeChild(elements[0]);
// make new WriteFileElem and hide it
elem = document.createElement("WriteFileElem");
elem.setAttribute("filename", filename);
elem.setAttribute("encoding", "ascii");
elem.setAttribute("style", "display:none");
// set content to passed `code` string
elem.innerHTML = code;
// trigger WriteFile event
evt = document.createEvent("Events");
evt.initEvent("WriteFile", true, false);
return elem.dispatchEvent(evt);
<WriteFileElem filename="/Users/joe/Desktop/writefile.txt" encoding="ascii">
innerHTML of this element will be written to filename attribute value, if it doesn't already exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.