add server upload buttons and Ctrl-S bindings to mode_editor

in combination with PUT support in ./static.py (or whatever other web server)
this allows people to save both the highlighting rules and the demo documents right
from the mode editor for a better workflow.
This commit is contained in:
Matthias S. Benkmann 2014-12-07 17:38:15 +01:00
commit 8919b113d1
4 changed files with 73 additions and 2 deletions

View file

@ -22,6 +22,19 @@ exports.get = function (url, callback) {
xhr.send(null);
};
exports.put = function (url, data, callback) {
var xhr = new XMLHttpRequest();
xhr.open('PUT', url, true);
xhr.onreadystatechange = function () {
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(data);
};
exports.loadScript = function(path, callback) {
var head = dom.getDocumentHead();
var s = document.createElement('script');