/usr/share/javascript/yui3/get-nodejs/get-nodejs.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('get-nodejs', function(Y) {
/**
* NodeJS specific Get module used to load remote resources. It contains the same signature as the default Get module so there is no code change needed.
* Note: There is an added method called Get.domScript, which is the same as Get.script in a browser, it simply loads the script into the dom tree
* so that you can call outerHTML on the document to print it to the screen.
* @module get-nodejs
*/
var path = require('path');
Y.config.base = path.join(__dirname, '../');
console.log(Y.config);
YUI.add('get', function() { });
var end = function(cb, msg, result) {
if (Y.Lang.isFunction(cb.onEnd)) {
cb.onEnd.call(Y, msg, result);
}
}, pass = function(cb) {
if (Y.Lang.isFunction(cb.onSuccess)) {
cb.onSuccess.call(Y, cb);
}
end(cb, 'success', 'success');
}, fail = function(cb, er) {
if (Y.Lang.isFunction(cb.onFailure)) {
cb.onFailure.call(Y, er, cb);
}
end(cb, er, 'fail');
};
Y.Get = function() {};
/**
* Override for Get.script for loading local or remote YUI modules.
*/
Y.Get.script = function(s, cb) {
var A = Y.Array,
urls = A(s), url, i, l = urls.length;
for (i=0; i<l; i++) {
url = urls[i];
url = url.replace(/'/g, '%27');
// doesn't need to be blocking, so don't block.
include(url, function(err) {
if (!Y.config) {
Y.config = {
debug: true
};
}
if (err) {
if (err.stack) {
A.each(err.stack.split('\n'), function(frame) {
});
} else {
console.log(err);
}
} else {
pass(cb);
}
});
}
};
var vm = require('vm'),
fs = require('fs');
var include = function(url, cb) {
var mod = fs.readFileSync(url, 'utf8');
var script = vm.createScript(mod, url);
var box = {
YUI: {
add: function() {
console.log('YUI in the sandbox');
console.log(arguments);
YUI.apply(YUI, arguments);
cb();
}
}
};
script.runInNewContext(box);
};
}, '3.5.1' ,{requires:['yui-base']});
|