|
|
@ -104,6 +104,7 @@ THE SOFTWARE. |
|
|
|
SOL_CACHE_FILE = getFiles()[0]; |
|
|
|
SOL_CACHE_FILE = getFiles()[0]; |
|
|
|
|
|
|
|
|
|
|
|
editor.setValue( window.localStorage[SOL_CACHE_FILE], -1); |
|
|
|
editor.setValue( window.localStorage[SOL_CACHE_FILE], -1); |
|
|
|
|
|
|
|
editor.resize(true); |
|
|
|
session.setMode("ace/mode/javascript"); |
|
|
|
session.setMode("ace/mode/javascript"); |
|
|
|
session.setTabSize(4); |
|
|
|
session.setTabSize(4); |
|
|
|
session.setUseSoftTabs(true); |
|
|
|
session.setUseSoftTabs(true); |
|
|
@ -278,7 +279,7 @@ THE SOFTWARE. |
|
|
|
$('#ghostbar').remove(); |
|
|
|
$('#ghostbar').remove(); |
|
|
|
$(document).unbind('mousemove'); |
|
|
|
$(document).unbind('mousemove'); |
|
|
|
dragging = false; |
|
|
|
dragging = false; |
|
|
|
setEditorSize(delta) |
|
|
|
setEditorSize(delta); |
|
|
|
window.localStorage.setItem(EDITOR_SIZE_CACHE_KEY, delta); |
|
|
|
window.localStorage.setItem(EDITOR_SIZE_CACHE_KEY, delta); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -346,7 +347,7 @@ THE SOFTWARE. |
|
|
|
var onChange = function() { |
|
|
|
var onChange = function() { |
|
|
|
var input = editor.getValue(); |
|
|
|
var input = editor.getValue(); |
|
|
|
if (input === "") { |
|
|
|
if (input === "") { |
|
|
|
window.localStorage.setItem(SOL_CACHE_FILE, '') |
|
|
|
window.localStorage.setItem(SOL_CACHE_FILE, ''); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (input === previousInput) |
|
|
|
if (input === previousInput) |
|
|
@ -364,18 +365,18 @@ THE SOFTWARE. |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function includeLocalImports(input) { |
|
|
|
function includeLocalImports(input) { |
|
|
|
var importRegex = /import\s[\'\"]([^\'\"]+)[\'\"];/g |
|
|
|
var importRegex = /import\s[\'\"]([^\'\"]+)[\'\"];/g; |
|
|
|
var imports = []; |
|
|
|
var imports = []; |
|
|
|
var matches = []; |
|
|
|
var matches = []; |
|
|
|
var match; |
|
|
|
var match; |
|
|
|
while ((match = importRegex.exec(input)) !== null) { |
|
|
|
while ((match = importRegex.exec(input)) !== null) { |
|
|
|
if (match[1] && getFiles().indexOf(fileKey(match[1])) !== -1) { |
|
|
|
if (match[1] && getFiles().indexOf(fileKey(match[1])) !== -1) { |
|
|
|
imports.push(match[1]) |
|
|
|
imports.push(match[1]); |
|
|
|
matches.push(match[0]) |
|
|
|
matches.push(match[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (var i in imports) { |
|
|
|
for (var i in imports) { |
|
|
|
imported = includeLocalImports(window.localStorage.getItem( fileKey(imports[i]) )) |
|
|
|
imported = includeLocalImports(window.localStorage.getItem( fileKey(imports[i]) )); |
|
|
|
input = input.replace(matches[i], imported); |
|
|
|
input = input.replace(matches[i], imported); |
|
|
|
} |
|
|
|
} |
|
|
|
return input; |
|
|
|
return input; |
|
|
@ -393,19 +394,23 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
var renderError = function(message) { |
|
|
|
var renderError = function(message) { |
|
|
|
var type = message.match(/^[0-9:]* Warning: /) ? 'warning' : 'error'; |
|
|
|
var type = message.match(/^[0-9:]* Warning: /) ? 'warning' : 'error'; |
|
|
|
$('#output') |
|
|
|
var $error = $('<pre class="' + type + '"></pre>').text(message); |
|
|
|
.append($('<pre class="' + type + '"></pre>').text(message)); |
|
|
|
$('#output').append( $error ); |
|
|
|
var err = message.match(/^:([0-9]*):([0-9]*)/) |
|
|
|
var err = message.match(/^:([0-9]*):([0-9]*)/); |
|
|
|
if (err && err.length) { |
|
|
|
if (err && err.length) { |
|
|
|
var errLine = parseInt(err[1], 10) - 1; |
|
|
|
var errLine = parseInt(err[1], 10) - 1; |
|
|
|
var errCol = err[2] ? parseInt(err[2], 10) : 0; |
|
|
|
var errCol = err[2] ? parseInt(err[2], 10) : 0; |
|
|
|
sourceAnnotations[sourceAnnotations.length] ={ |
|
|
|
sourceAnnotations[sourceAnnotations.length] = { |
|
|
|
row: errLine, |
|
|
|
row: errLine, |
|
|
|
column: errCol, |
|
|
|
column: errCol, |
|
|
|
text: message, |
|
|
|
text: message, |
|
|
|
type: type |
|
|
|
type: type |
|
|
|
}; |
|
|
|
}; |
|
|
|
editor.getSession().setAnnotations(sourceAnnotations); |
|
|
|
editor.getSession().setAnnotations(sourceAnnotations); |
|
|
|
|
|
|
|
$error.click(function(ev){ |
|
|
|
|
|
|
|
editor.focus(); |
|
|
|
|
|
|
|
editor.gotoLine(errLine + 1, errCol - 1, true); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|