Adapting...
This commit is contained in:
parent
00eb8119ec
commit
0a98aaa1e6
|
@ -1,8 +1,53 @@
|
||||||
include = function (filepath, isAbsolute) {
|
/*
|
||||||
if (isAbsolute === undefined || isAbsolute == false) {
|
* Global object.
|
||||||
filepath = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath);
|
*
|
||||||
}
|
* This object can't be initialized when common.js is first read since the authorAccess object isn't available yet
|
||||||
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath))));
|
*
|
||||||
text = String(text);
|
*/
|
||||||
eval(text);
|
__required__ = {
|
||||||
|
};
|
||||||
|
|
||||||
|
CommonsOperationsUtil = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil;
|
||||||
|
|
||||||
|
require = function (filepath) {
|
||||||
|
// Check if the object has been initialized
|
||||||
|
if (Object.keys(__required__).length == 0) {
|
||||||
|
var currentPath = CommonsOperationsUtil.expandAndResolvePath(authorAccess, 'commons.js');
|
||||||
|
__required__.baseURIs =[currentPath];
|
||||||
|
__required__.required = {
|
||||||
|
};
|
||||||
|
__required__.required[currentPath] = true;
|
||||||
|
}
|
||||||
|
var basePathFile = (new java.io.File(__required__.baseURIs[__required__.baseURIs.length - 1])).getParentFile();
|
||||||
|
filepath = new java.io.File(basePathFile, filepath).toString();
|
||||||
|
if (__required__.required[filepath] == undefined) {
|
||||||
|
__required__.baseURIs.push(filepath);
|
||||||
|
__required__.required[filepath] = true;
|
||||||
|
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath))));
|
||||||
|
text = String(text);
|
||||||
|
eval(text);
|
||||||
|
__required__.baseURIs.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
startDebugger = function () {
|
||||||
|
|
||||||
|
var runnable = {
|
||||||
|
run: function () {
|
||||||
|
main.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var context = Packages.org.mozilla.javascript.Context.getCurrentContext();
|
||||||
|
// Within the current context...
|
||||||
|
var contextFactory = context.getFactory();
|
||||||
|
var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__);
|
||||||
|
// and the scope of the runnable variable's parent ...
|
||||||
|
var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger');
|
||||||
|
// start a debugging session ...
|
||||||
|
main.setExitAction(java.lang.Runnable(runnable));
|
||||||
|
// , clean the resources at exit time...
|
||||||
|
main.setVisible(true);
|
||||||
|
// and make it visible/
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<serialized version="21.1" xml:space="preserve">
|
<serialized version="22.0" xml:space="preserve">
|
||||||
<serializableOrderedMap>
|
<serializableOrderedMap>
|
||||||
<entry>
|
<entry>
|
||||||
<String>document.types</String>
|
<String>document.types</String>
|
||||||
|
@ -795,7 +795,7 @@
|
||||||
<entry>
|
<entry>
|
||||||
<String>script</String>
|
<String>script</String>
|
||||||
<String>doOperation = function () {
|
<String>doOperation = function () {
|
||||||
include('debugger.js');
|
// include('debugger.js');
|
||||||
startDebugger();
|
startDebugger();
|
||||||
}
|
}
|
||||||
</String>
|
</String>
|
||||||
|
@ -845,7 +845,7 @@
|
||||||
<entry>
|
<entry>
|
||||||
<String>script</String>
|
<String>script</String>
|
||||||
<String>doOperation = function () {
|
<String>doOperation = function () {
|
||||||
include('hello.js');
|
require('hello.js');
|
||||||
hello();
|
hello();
|
||||||
}</String>
|
}</String>
|
||||||
</entry>
|
</entry>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
doOperation = function () {
|
||||||
|
require('hello.js');
|
||||||
|
hello();
|
||||||
|
}
|
||||||
|
doOperation();
|
Loading…
Reference in New Issue