Testing...
This commit is contained in:
parent
b3cb52a8ab
commit
f1060d6007
|
@ -5,61 +5,39 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shortcuts aka imports
|
||||||
|
*/
|
||||||
out = Packages.java.lang.System.out;
|
out = Packages.java.lang.System.out;
|
||||||
|
|
||||||
out.println('commons.js');
|
|
||||||
|
|
||||||
__required__ = {
|
|
||||||
};
|
|
||||||
|
|
||||||
CommonsOperationsUtil = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil;
|
CommonsOperationsUtil = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function require
|
||||||
|
*
|
||||||
|
*/
|
||||||
require = function (filepath) {
|
require = function (filepath) {
|
||||||
// Check if the object has been initialized
|
// Check if the object has been initialized
|
||||||
if (Object.keys(__required__).length == 0) {
|
if (Object.keys(require).length == 0) {
|
||||||
var currentPath = CommonsOperationsUtil.expandAndResolvePath(authorAccess, 'commons.js');
|
var currentPath = CommonsOperationsUtil.expandAndResolvePath(authorAccess, 'commons.js');
|
||||||
__required__.baseURIs =[currentPath];
|
require.urisStack =[currentPath];
|
||||||
__required__.required = {
|
require.urisSet = {
|
||||||
};
|
};
|
||||||
__required__.required[currentPath] = true;
|
require.urisSet[currentPath] = true;
|
||||||
}
|
}
|
||||||
var currentFilePath = __required__.baseURIs[__required__.baseURIs.length - 1];
|
var currentFilePath = require.urisStack[require.urisStack.length - 1];
|
||||||
out.println('filepath: ' + filepath);
|
|
||||||
out.println('current filepath: ' + currentFilePath);
|
|
||||||
var currentURI = new java.net.URI(currentFilePath);
|
var currentURI = new java.net.URI(currentFilePath);
|
||||||
var targetURI = currentURI.resolve(filepath);
|
var targetURI = currentURI.resolve(filepath);
|
||||||
filepath = targetURI.toString();
|
filepath = targetURI.toString();
|
||||||
out.println('filepath: ' + filepath);
|
if (require.urisSet[filepath] == undefined) {
|
||||||
if (__required__.required[filepath] == undefined) {
|
require.urisStack.push(filepath);
|
||||||
__required__.baseURIs.push(filepath);
|
require.urisSet[filepath] = true;
|
||||||
__required__.required[filepath] = true;
|
|
||||||
var uri = new java.net.URI(filepath);
|
var uri = new java.net.URI(filepath);
|
||||||
out.println('New, inclusion needed: ' + uri.toString());
|
out.println('Including ' + uri.toString());
|
||||||
var text = new java.lang.String(java.nio.file.Files.readAllBytes( java.nio.file.Paths.get(targetURI) ));
|
var text = new java.lang.String(java.nio.file.Files.readAllBytes( java.nio.file.Paths.get(targetURI) ));
|
||||||
text = String(text);
|
text = String(text);
|
||||||
eval(text);
|
eval(text);
|
||||||
__required__.baseURIs.pop();
|
require.urisStack.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,6 @@
|
||||||
require('hello.js');
|
require('hello.js');
|
||||||
require('./commons.js');
|
require('./commons.js');
|
||||||
|
require('subdir/child.js');
|
||||||
|
|
||||||
hello = function (){
|
hello = function (){
|
||||||
Packages.java.lang.System.out.println("Hello world.");
|
Packages.java.lang.System.out.println("Hello world.");
|
||||||
|
|
|
@ -795,7 +795,7 @@
|
||||||
<entry>
|
<entry>
|
||||||
<String>script</String>
|
<String>script</String>
|
||||||
<String>doOperation = function () {
|
<String>doOperation = function () {
|
||||||
// include('debugger.js');
|
require('debugger.js');
|
||||||
startDebugger();
|
startDebugger();
|
||||||
}
|
}
|
||||||
</String>
|
</String>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
out.println('message from the subdir: ' + filepath);
|
||||||
|
require('../hello.js');
|
||||||
|
require('../commons.js');
|
||||||
|
require('child.js');
|
Loading…
Reference in New Issue