work a bit more on import/export and code highlighting

This commit is contained in:
ansuz
2016-06-22 20:58:50 +02:00
parent 242c9a99e3
commit 31aa09d6f6
5 changed files with 101 additions and 17 deletions

View File

@@ -45,5 +45,17 @@ define([
localStorage[storageKey] = JSON.stringify(out);
};
var importContent = common.importContent = function (type, f) {
return function () {
var $files = $('<input type="file">').click()
$files.on('change', function (e) {
var file = e.target.files[0];
var reader = new FileReader();
reader.onload = function (e) { f(e.target.result); };
reader.readAsText(file, type);
});
};
};
return common;
});