Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View app.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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;
document.documentElement.appendChild(elem);
// trigger WriteFile event
evt = document.createEvent("Events");
evt.initEvent("WriteFile", true, false);
return elem.dispatchEvent(evt);
};
View app.js
1 2 3 4 5 6 7
<html>
<body>
<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.
</WriteFileElem>
</body>
</html>
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.