Browse Source

Merge pull request #1477 from yann300/bugFix

Mix - bug fixes
cl-refactor
Gav Wood 10 years ago
parent
commit
02c3714bb5
  1. 10
      mix/qml/CodeEditorView.qml
  2. 7
      mix/qml/WebPreview.qml

10
mix/qml/CodeEditorView.qml

@ -11,6 +11,16 @@ Item {
signal breakpointsChanged(string documentId)
signal isCleanChanged(var isClean, string documentId)
function getDocumentIdByName(fileName)
{
for (var i = 0; i < editorListModel.count; i++) {
if (editorListModel.get(i).fileName === fileName) {
return editorListModel.get(i).documentId;
}
}
return null;
}
function getDocumentText(documentId) {
for (var i = 0; i < editorListModel.count; i++) {
if (editorListModel.get(i).documentId === documentId) {

7
mix/qml/WebPreview.qml

@ -155,18 +155,19 @@ Item {
//document request
if (urlPath === "/")
urlPath = "/index.html";
var documentId = urlPath.substr(urlPath.lastIndexOf("/") + 1);
var documentName = urlPath.substr(urlPath.lastIndexOf("/") + 1);
var documentId = projectModel.codeEditor.getDocumentIdByName(documentName);
var content = "";
if (projectModel.codeEditor.isDocumentOpen(documentId))
content = projectModel.codeEditor.getDocumentText(documentId);
else
{
var doc = projectModel.getDocument(documentId);
if (doc !== undefined)
if (doc)
content = fileIo.readFile(doc.path);
}
if (documentId === urlInput.text.replace(httpServer.url + "/", "")) {
if (documentName === urlInput.text.replace(httpServer.url + "/", "")) {
//root page, inject deployment script
content = "<script>web3=parent.web3;contracts=parent.contracts;</script>\n" + content;
_request.setResponseContentType("text/html");

Loading…
Cancel
Save