Commit 06fd9e9d authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Editor: Add Mimetype guess

parent 594a96c5
......@@ -9,6 +9,7 @@
<script src="../lib/rsvp.js" type="text/javascript"></script>
<script src="../lib/renderjs.js" type="text/javascript"></script>
<script src="../lib/jio-latest.js" type="text/javascript"></script>
<script src="../lib/mimetype.js" type="text/javascript"></script>
<script src="./gadget_global.js" type="text/javascript"></script>
<!-- Custom -->
......
/*global window, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, loopEventListener, jIO) {
(function (window, rJS, loopEventListener, jIO, mimeType) {
"use strict";
var CODE_CONTENT_KEY = "text_content";
......@@ -9,6 +9,9 @@
var content,
url = gadget.props.element.querySelector("form.crib-editor-get .url").value,
mimetype = gadget.props.element.querySelector("form.crib-editor-save .mimetype").value;
if (!mimetype) {
mimetype = mimeType.lookup(url, false, "application/octet-stream");
}
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget('codeeditor');
......@@ -34,6 +37,9 @@
})
.push(function (data) {
type = data.type;
if (!type || type === "application/octet-stream") {
type = mimeType.lookup(url, false, "application/octet-stream");
}
return jIO.util.readBlobAsText(data, type);
})
.push(function (evt) {
......@@ -128,4 +134,4 @@
return RSVP.all(promise_list);
});
});
}(window, rJS, loopEventListener, jIO));
\ No newline at end of file
}(window, rJS, loopEventListener, jIO, mimeType));
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment