_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q56500 | setupTimer | train | function setupTimer(opts) {
var name, timer;
name = opts.name || node.game.timer.name;
timer = node.timer.getTimer(name);
if (!timer) {
node.warn('setup("timer"): timer not found: ' + name);
return false;
... | javascript | {
"resource": ""
} |
q56501 | completed | train | function completed(event) {
var iframeDoc;
// IE < 10 (also 11?) gives 'Permission Denied' if trying to access
// the iframeDoc from the context of the function above.
// We need to re-get it from the DOM.
iframeDoc = J.getIFrameDocument(iframe);
... | javascript | {
"resource": ""
} |
q56502 | train | function(w, data) {
return (w.senderToNameMap[data.id] || data.id) + ' ' +
| javascript | {
"resource": ""
} | |
q56503 | FacePainter | train | function FacePainter(canvas, settings) {
this.canvas = new W.Canvas(canvas);
this.scaleX = canvas.width / ChernoffFaces.defaults.canvas.width;
| javascript | {
"resource": ""
} |
q56504 | objToLK | train | function objToLK(obj) {
var p, objLow;
objLow = {};
for (p in obj) {
if (obj.hasOwnProperty(p)) {
| javascript | {
"resource": ""
} |
q56505 | invalidRange | train | function invalidRange(res) {
var body = 'Requested Range Not Satisfiable';
res.setHeader('Content-Type', | javascript | {
"resource": ""
} |
q56506 | train | function( page, desiredHeight ) {
var pageParent = page.parent(),
toolbarsAffectingHeight = [],
// We use this function to filter fixed toolbars with option updatePagePadding set to
// true (which is the default) from our height subtraction, because fixed toolbars with
... | javascript | {
"resource": ""
} | |
q56507 | train | function( height ) {
var page = $( "." + $.mobile.activePageClass ),
pageHeight = page.height(),
pageOuterHeight = page.outerHeight( true );
height = compensateToolbars( page,
( typeof height === "number" ) ? height : $.mobile.getScreenHeight() );... | javascript | {
"resource": ""
} | |
q56508 | train | function() {
var offset = this.element.offset(),
scrollTop = this.window.scrollTop(),
screenHeight = $.mobile.getScreenHeight();
if ( offset.top < scrollTop || ( offset.top - scrollTop ) > screenHeight ) {
this.element.addClass( "ui-loader-fakefix... | javascript | {
"resource": ""
} | |
q56509 | train | function( url, data ) {
data = data || {};
//if there's forward history, wipe it
if ( this.getNext() ) {
this.clearForward();
}
// if the hash is included in the data make sure the shape
// is consistent for comparison
| javascript | {
"resource": ""
} | |
q56510 | train | function( historyEntry, direction ) {
// make sure to create a new object to pass down as the navigate event data
| javascript | {
"resource": ""
} | |
q56511 | train | function( href ) {
// we should do nothing if the user wants to manage their url base
// manually
if ( !$.mobile.dynamicBaseEnabled ) {
return;
| javascript | {
"resource": ""
} | |
q56512 | train | function() {
var options = this.options,
keepNative = $.trim( options.keepNative || "" ),
globalValue = $.trim( $.mobile.keepNative ),
optionValue = $.trim( options.keepNativeDefault ),
// Check if $.mobile.keepNative has changed from the factory default
... | javascript | {
"resource": ""
} | |
q56513 | train | function() {
var hist = $.mobile.navigate.history;
if ( this._isCloseable ) {
this._isCloseable = false;
// If the hash listening is enabled and there is at least one preceding history
// entry it's ok to go back. Initial pages with the dialog hash state are an examp... | javascript | {
"resource": ""
} | |
q56514 | train | function( options ) {
var key,
accordion = this._ui.accordion,
accordionWidget = this._ui.accordionWidget;
// Copy options
options = $.extend( {}, options );
if ( accordion.length && !accordionWidget ) {
this._ui.accordionWidget =
accordi... | javascript | {
"resource": ""
} | |
q56515 | train | function() {
var dstOffset = this.handle.offset();
this._popup.offset( {
left: dstOffset.left + ( this.handle.width() - this._popup.width() ) / 2, | javascript | {
"resource": ""
} | |
q56516 | train | function() {
var screen = this._ui.screen,
popupHeight = this._ui.container.outerHeight( true ),
screenHeight = screen.removeAttr( "style" ).height(),
// Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where
// the browser hangs if the screen cove... | javascript | {
"resource": ""
} | |
q56517 | train | function( theEvent ) {
var target,
targetElement = theEvent.target,
ui = this._ui;
if ( !this._isOpen ) {
return;
}
if ( targetElement !== ui.container[ 0 ] ) {
target = $( targetElement );
if ( !$.contains( ui.container[ 0 ],... | javascript | {
"resource": ""
} | |
q56518 | train | function() {
var ua = navigator.userAgent,
platform = navigator.platform,
// Rendering engine is Webkit, and capture major version
wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ),
wkversion = !!wkmatch && wkmatch[ 1 ],
os = null,
self = t... | javascript | {
"resource": ""
} | |
q56519 | train | function() {
var $el = this.element,
header = $el.hasClass( "ui-header" ),
offset = Math.abs( $el.offset().top - this.window.scrollTop() );
if ( !header ) {
| javascript | {
"resource": ""
} | |
q56520 | train | function( p, dir, desired, s, best ) {
var result, r, diff, desiredForArrow = {}, tip = {};
// If the arrow has no wiggle room along the edge of the popup, it cannot
// be displayed along the requested edge without it sticking out.
if ( s.arFull[ p.dimKey ] > s.guideDims[ p.dimKey ] ) {... | javascript | {
"resource": ""
} | |
q56521 | train | function (event) {
var target = event.target;
var e = event;
var ev;
// [CDP modified]: set target.clientX.
if (null == target.clientX || null == target.clientY) {
if (null != e.pageX && null != e.pageY) {
... | javascript | {
"resource": ""
} | |
q56522 | setupByCopy | train | function setupByCopy() {
let task_dir;
let required_tasks;
try {
const config = require(path.join(process.cwd(), 'project.config'));
required_tasks = config.required_tasks;
if (!required_tasks) {
throw Error('no task required.');
}
task_dir = config.dir.t... | javascript | {
"resource": ""
} |
q56523 | train | function () {
var encTable = this._tables[0], decTable = this._tables[1],
sbox = encTable[4], sboxInv = decTable[4],
i, x, xInv, d=[], th=[], x2, x4, x8, s, tEnc, tDec;
// Compute double and third tables
for (i = 0; i < 256; i++) {
th[( d[i] = i<<1 ^ (i>>7)*283 )^i]=i;
}
for (x = xI... | javascript | {
"resource": ""
} | |
q56524 | train | function (input, dir) {
if (input.length !== 4) {
throw new sjcl.exception.invalid("invalid aes block size");
}
var key = this._key[dir],
// state variables a,b,c,d are loaded with pre-whitened data
a = input[0] ^ key[0],
b = input[dir ? 3 : 1] ^ key[1],
c = ... | javascript | {
"resource": ""
} | |
q56525 | train | function (a, bstart, bend) {
a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);
| javascript | {
"resource": ""
} | |
q56526 | train | function(a, bstart, blength) {
// FIXME: this Math.floor is not necessary at all, but for some reason
// seems to suppress a bug in the Chromium JIT.
var x, sh = Math.floor((-bstart-blength) & 31);
if ((bstart + blength - 1 ^ bstart) & -32) {
// it crosses a boundary
x = | javascript | {
"resource": ""
} | |
q56527 | train | function (a1, a2) {
if (a1.length === 0 || a2.length === 0) {
return a1.concat(a2);
}
var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
if (shift === 32) {
| javascript | {
"resource": ""
} | |
q56528 | train | function (a) {
var l = a.length, x;
if (l === 0) { return | javascript | {
"resource": ""
} | |
q56529 | train | function (a, len) {
if (a.length * 32 < len) { return a; }
a = a.slice(0, Math.ceil(len / 32));
var l = | javascript | {
"resource": ""
} | |
q56530 | train | function (a, b) {
if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
return false;
}
var | javascript | {
"resource": ""
} | |
q56531 | train | function (a, shift, carry, out) {
var i, last2=0, shift2;
if (out === undefined) { out = []; }
for (; shift >= 32; shift -= 32) {
out.push(carry);
carry = 0;
}
if (shift === 0) {
return out.concat(a);
}
for (i=0; i<a.length; i++) {
out.push(carry | a[i]>>>shift);
... | javascript | {
"resource": ""
} | |
q56532 | train | function (arr) {
var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp;
for (i=0; i<bl/8; i++) {
if ((i&3) | javascript | {
"resource": ""
} | |
q56533 | train | function (str) {
str = unescape(encodeURIComponent(str));
var out = [], i, tmp=0;
for (i=0; i<str.length; i++) {
tmp = tmp << 8 | str.charCodeAt(i);
if ((i&3) === 3) {
out.push(tmp);
tmp = 0; | javascript | {
"resource": ""
} | |
q56534 | train | function (arr) {
var out = "", i;
for (i=0; i<arr.length; i++) {
out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
}
| javascript | {
"resource": ""
} | |
q56535 | train | function (str) {
var i, out=[], len;
str = str.replace(/\s|0x/g, "");
len = str.length;
str = str + "00000000";
for (i=0; i<str.length; i+=8) {
| javascript | {
"resource": ""
} | |
q56536 | train | function (arr, _noEquals, _url) {
var out = "", i, bits=0, c = sjcl.codec.base64._chars, ta=0, bl = sjcl.bitArray.bitLength(arr);
if (_url) {
c = c.substr(0,62) + '-_';
}
for (i=0; out.length * 6 < bl; ) {
out += c.charAt((ta ^ arr[i]>>>bits) >>> 26);
if (bits < 6) {
| javascript | {
"resource": ""
} | |
q56537 | train | function(str, _url) {
str = str.replace(/\s|=/g,'');
var out = [], i, bits=0, c = sjcl.codec.base64._chars, ta=0, x;
if (_url) {
c = c.substr(0,62) + '-_';
}
for (i=0; i<str.length; i++) {
x = c.indexOf(str.charAt(i));
if (x < 0) {
throw new sjcl.exception.invalid("this isn... | javascript | {
"resource": ""
} | |
q56538 | train | function (data) {
if (typeof data === "string") {
data = sjcl.codec.utf8String.toBits(data);
}
var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
ol = this._length,
| javascript | {
"resource": ""
} | |
q56539 | train | function (words) {
var i, tmp, a, b,
w = words.slice(0),
h = this._h,
k = this._key,
h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],
h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];
/* Rationale for placement of |0 :
* If a value can overflow is original 32 bits by a factor of more th... | javascript | {
"resource": ""
} | |
q56540 | train | function(prf, plaintext, iv, adata, tlen) {
var L, out = plaintext.slice(0), tag, w=sjcl.bitArray, ivl = w.bitLength(iv) / 8, ol = w.bitLength(out) / 8;
tlen = tlen || 64;
adata = adata || [];
if (ivl < 7) {
throw new sjcl.exception.invalid("ccm: iv must be at least | javascript | {
"resource": ""
} | |
q56541 | train | function(prf, ciphertext, iv, adata, tlen) {
tlen = tlen || 64;
adata = adata || [];
var L,
w=sjcl.bitArray,
ivl = w.bitLength(iv) / 8,
ol = w.bitLength(ciphertext),
out = w.clamp(ciphertext, ol - tlen),
tag = w.bitSlice(ciphertext, ol - tlen), tag2;
ol = (ol - ... | javascript | {
"resource": ""
} | |
q56542 | train | function(prf, data, iv, tag, tlen, L) {
var enc, i, w=sjcl.bitArray, xor = w._xor4, ctr, l = data.length, bl=w.bitLength(data);
// start the ctr
ctr = w.concat([w.partial(8,L-1)],iv).concat([0,0,0]).slice(0,4);
// en/decrypt the tag
tag = w.bitSlice(xor(tag,prf.encrypt(ctr)), 0, tlen);
// en/... | javascript | {
"resource": ""
} | |
q56543 | train | function(prp, plaintext, iv, adata, tlen, premac) {
if (sjcl.bitArray.bitLength(iv) !== 128) {
throw new sjcl.exception.invalid("ocb iv must be 128 bits");
}
var i,
times2 = sjcl.mode.ocb2._times2,
w = sjcl.bitArray,
xor = w._xor4,
checksum = [0,0,0,0],
delta = ... | javascript | {
"resource": ""
} | |
q56544 | train | function(prp, adata) {
var i,
times2 = sjcl.mode.ocb2._times2,
w = sjcl.bitArray,
xor = w._xor4,
checksum = [0,0,0,0],
delta = prp.encrypt([0,0,0,0]),
bi;
delta = xor(delta,times2(times2(delta)));
for (i=0; i+4<adata.length; i+=4) {
delta = times2(delt... | javascript | {
"resource": ""
} | |
q56545 | train | function (prf, plaintext, iv, adata, tlen) {
var out, data = plaintext.slice(0), w=sjcl.bitArray;
tlen = tlen || 128;
adata = adata || [];
// encrypt | javascript | {
"resource": ""
} | |
q56546 | train | function (prf, ciphertext, iv, adata, tlen) {
var out, data = ciphertext.slice(0), tag, w=sjcl.bitArray, l=w.bitLength(data);
tlen = tlen || 128;
adata = adata || [];
// Slice tag out of data
if (tlen <= l) {
tag = w.bitSlice(data, l-tlen);
data = w.bitSlice(data, 0, l-tlen);
} else... | javascript | {
"resource": ""
} | |
q56547 | train | function(encrypt, prf, data, adata, iv, tlen) {
var H, J0, S0, enc, i, ctr, tag, last, l, bl, abl, ivbl, w=sjcl.bitArray;
// Calculate data lengths
l = data.length;
bl = w.bitLength(data);
abl = w.bitLength(adata);
ivbl = w.bitLength(iv);
// Calculate the parameters
H = prf.encrypt([0,... | javascript | {
"resource": ""
} | |
q56548 | train | function (paranoia) {
var entropyRequired = this._PARANOIA_LEVELS[ (paranoia !== undefined) ? paranoia : this._defaultParanoia ];
if (this._strength && this._strength >= entropyRequired) {
return (this._poolEntropy[0] > this._BITS_PER_RESEED && (new Date()).valueOf() > this._nextReseed) ?
this._R... | javascript | {
"resource": ""
} | |
q56549 | train | function (paranoia) {
var entropyRequired = this._PARANOIA_LEVELS[ paranoia ? paranoia : this._defaultParanoia ];
if (this._strength >= entropyRequired) {
return 1.0;
} else { | javascript | {
"resource": ""
} | |
q56550 | train | function () {
if (this._collectorsStarted) { return; }
this._eventListener = {
loadTimeCollector: this._bind(this._loadTimeCollector),
mouseCollector: this._bind(this._mouseCollector),
keyboardCollector: this._bind(this._keyboardCollector),
accelerometerCollector: this._bind(this._accel... | javascript | {
"resource": ""
} | |
q56551 | train | function () {
if (!this._collectorsStarted) { return; }
if (window.removeEventListener) {
window.removeEventListener("load", this._eventListener.loadTimeCollector, false);
window.removeEventListener("mousemove", this._eventListener.mouseCollector, false);
window.removeEventListener("keypress"... | javascript | {
"resource": ""
} | |
q56552 | train | function (name, cb) {
var i, j, cbs=this._callbacks[name], jsTemp=[];
/* I'm not sure if this is necessary; in C++, iterating over a
* collection and modifying it at the same time is a no-no.
*/
for (j in cbs) {
if (cbs.hasOwnProperty(j) && cbs[j] === cb) | javascript | {
"resource": ""
} | |
q56553 | train | function () {
for (var i=0; i<4; i++) {
this._counter[i] = this._counter[i]+1 | 0;
if | javascript | {
"resource": ""
} | |
q56554 | train | function (seedWords) {
this._key = sjcl.hash.sha256.hash(this._key.concat(seedWords));
this._cipher = new sjcl.cipher.aes(this._key);
for (var i=0; i<4; i++) {
| javascript | {
"resource": ""
} | |
q56555 | train | function (full) {
var reseedData = [], strength = 0, i;
this._nextReseed = reseedData[0] =
(new Date()).valueOf() + this._MILLISECONDS_PER_RESEED;
for (i=0; i<16; i++) {
/* On some browsers, this is cryptographically random. So we might
* as well toss it in the pot and stir...
*... | javascript | {
"resource": ""
} | |
q56556 | train | function (obj) {
var i, out='{', comma='';
for (i in obj) {
if (obj.hasOwnProperty(i)) {
if (!i.match(/^[a-z0-9]+$/i)) {
throw new sjcl.exception.invalid("json encode: invalid property name");
}
out += comma + '"' + i + '":';
comma = ',';
switch (typeof o... | javascript | {
"resource": ""
} | |
q56557 | train | function (target, src, requireSame) {
if (target === undefined) { target = {}; }
if (src === undefined) { return target; }
var i;
for (i in src) {
if (src.hasOwnProperty(i)) { | javascript | {
"resource": ""
} | |
q56558 | train | function (plus, minus) {
var out = {}, i;
for (i in plus) {
if (plus.hasOwnProperty(i) && plus[i] !== minus[i]) {
| javascript | {
"resource": ""
} | |
q56559 | train | function (src, filter) {
var out = {}, i;
for (i=0; i<filter.length; i++) {
if (src[filter[i]] !== undefined) {
| javascript | {
"resource": ""
} | |
q56560 | train | function (singular) {
var self = this;
this.singluer = singular;
this.requireDefaultFile = false;
// [CDP customize]
this.folderName = '..\\..\\app\\res\\locales';
// [CDP customize]
this.formatLine = function (key, value) {
var v2 = '' + value;
return ' "' + key + '": "' + ... | javascript | {
"resource": ""
} | |
q56561 | train | function() {
this.requireDefaultFile = true;
this.folderName = 'conf';
this.isDefaultLocale = function (localeKey) {
if (localeKey == 'en-us' || localeKey == 'en-US') {
return true;
}
return false;
};
this.getDefaultFilePath = function (folderPath) {
retur... | javascript | {
"resource": ""
} | |
q56562 | findExcelFile | train | function findExcelFile() {
var files = fso.getFolder(".").Files;
for (var e = new Enumerator(files) ; !e.atEnd() ; e.moveNext()) {
var file = e.item();
// [CDP customize]
var extXLSX = '.xlsx';
var extODS = '.ods';
if (file.Name.substr(file.Name.length - extXLSX.length) =... | javascript | {
"resource": ""
} |
q56563 | getNodeFromFiles | train | function getNodeFromFiles(scriptFile, mapFile) {
if (fs.existsSync(scriptFile) && fs.existsSync(mapFile)) {
try {
return SourceNode.fromStringWithSourceMap(
getScriptFromFile(scriptFile),
new SourceMapConsumer(getMapFromMapFile(mapFile))
);
| javascript | {
"resource": ""
} |
q56564 | getNodeFromCode | train | function getNodeFromCode(code) {
if (convert.mapFileCommentRegex.test(code)) {
try {
return SourceNode.fromStringWithSourceMap(
convertCode2Script(code),
new SourceMapConsumer(convert.fromComment(code).toObject())
| javascript | {
"resource": ""
} |
q56565 | getCodeFromNode | train | function getCodeFromNode(node, renameSources, options) {
const code_map = getCodeMap(node);
const rename = renameSources;
const objMap = code_map.map.toJSON();
let i, n;
if (rename) {
if ('string' === typeof rename) {
for (i = 0, n = objMap.sources.length; i < n; i++) {
... | javascript | {
"resource": ""
} |
q56566 | separateScriptAndMapFromScriptFile | train | function separateScriptAndMapFromScriptFile(scriptFile, multiline, mapPath) {
const node = getNodeFromScriptFile(scriptFile);
mapPath = mapPath || path.basename(scriptFile) + '.map';
return {
script: node.toString().replace(/\r\n/gm, '\n') + (
multiline
| javascript | {
"resource": ""
} |
q56567 | getCodeMap | train | function getCodeMap(node) {
const code_map = node.toStringWithSourceMap();
// patch
node.walkSourceContents(function (sourceFile, | javascript | {
"resource": ""
} |
q56568 | Config | train | function Config(opts) {
_.extend(this, {
appName: 'ndm', // used by rc.
serviceJsonPath: path.resolve(process.cwd(), 'service.json'),
tmpServiceJsonPath: null, // used during install phase.
logsDirectory: this.defaultLogsDirectory(),
env: process.env,
uid: null,
gid: null,
console: nul... | javascript | {
"resource": ""
} |
q56569 | getLaunchStoryboardContentsJSON | train | function getLaunchStoryboardContentsJSON(splashScreens, launchStoryboardImagesDir) {
var platformLaunchStoryboardImages = mapLaunchStoryboardContents(splashScreens, launchStoryboardImagesDir);
var contentsJSON = {
images: [],
info: {
author: 'Xcode',
version: 1
}... | javascript | {
"resource": ""
} |
q56570 | checkIfBuildSettingsNeedUpdatedForLaunchStoryboard | train | function checkIfBuildSettingsNeedUpdatedForLaunchStoryboard(platformConfig, infoPlist) {
var hasLaunchStoryboardImages = platformHasLaunchStoryboardImages(platformConfig);
var hasLegacyLaunchImages = platformHasLegacyLaunchImages(platformConfig);
var currentLaunchStoryboard = infoPlist[UI_LAUNCH_STORYBOARD_... | javascript | {
"resource": ""
} |
q56571 | NativeBridge | train | function NativeBridge(feature, options) {
if (!(this instanceof NativeBridge)) {
return new NativeBridge(feature, options);
}
this._feature = | javascript | {
"resource": ""
} |
q56572 | moving_maximum | train | function moving_maximum(array, n) {
var nums = [];
for (i in array) {
if (_.isNumber(array[i])) {
nums.push(array[i]);
if (nums.length > n) | javascript | {
"resource": ""
} |
q56573 | apply_moving_filter | train | function apply_moving_filter(set, filter, n) {
if (!_.isNumber(n)) { n = 3; }
for (series | javascript | {
"resource": ""
} |
q56574 | time_format | train | function time_format(options) {
if (_.isString(options.time)) {
/* Translate the string we've been given into a format */
switch(options.time) {
case 'days':
case 'Days':
return "%d/%m";
case 'hours':
case 'Hours':
return "%H:%M";
default: /* Presume | javascript | {
"resource": ""
} |
q56575 | setup_gnuplot | train | function setup_gnuplot(gnuplot, options) {
if (options.format === 'svg') { /* Setup gnuplot for SVG */
gnuplot.stdin.write('set term svg fname \"Helvetica\" fsize 14\n');
} else if (options.format == 'pdf') {
/* PDF: setup Gnuplot output to postscript so ps2pdf can interpret it */
gnuplot.stdin.write('s... | javascript | {
"resource": ""
} |
q56576 | PlatformBase | train | function PlatformBase(opts) {
_.extend(this, {
platform: null,
// path to template to | javascript | {
"resource": ""
} |
q56577 | train | function(vector) {
var n = this.elements.length;
var V = vector.elements || vector;
if (n != V.length) { return false; }
do {
if (Math.abs(this.elements[n-1] | javascript | {
"resource": ""
} | |
q56578 | train | function(vector) {
var V = vector.elements || vector;
var i, product = 0, n = this.elements.length;
if (n != V.length) { return null; }
do { | javascript | {
"resource": ""
} | |
q56579 | train | function(obj) {
if (obj.anchor) { return obj.distanceFrom(this); }
var V = obj.elements || obj;
if (V.length != this.elements.length) { return null; }
var sum = 0, part;
| javascript | {
"resource": ""
} | |
q56580 | train | function() {
if (!this.isSquare()) { return null; }
var tr = this.elements[0][0], n = this.elements.length - 1, k = n, i;
do { i = k | javascript | {
"resource": ""
} | |
q56581 | train | function(obj) {
if (obj.normal) { return obj.distanceFrom(this); }
if (obj.direction) {
// obj is a line
if (this.isParallelTo(obj)) { return this.distanceFrom(obj.anchor); }
var N = this.direction.cross(obj.direction).toUnitVector().elements;
var A = this.anchor.elements, B = obj.anchor... | javascript | {
"resource": ""
} | |
q56582 | train | function(anchor, direction) {
// Need to do this so that line's properties are not
// references to the arguments passed in
anchor = Vector.create(anchor);
direction = Vector.create(direction);
if (anchor.elements.length == 2) {anchor.elements.push(0); }
if (direction.elements.length == 2) { dir... | javascript | {
"resource": ""
} | |
q56583 | _getExtension | train | function _getExtension(file) {
var ret;
if (file) {
var fileTypes = file.split(".");
var len = fileTypes.length;
if (0 === len) {
| javascript | {
"resource": ""
} |
q56584 | _getScriptElements | train | function _getScriptElements($typeLazy) {
var scripts;
var src = $typeLazy.attr("src");
if (!src) {
src = $typeLazy.data("src");
}
if ("js" === _getExtension(src).toLowerCase()) {
return $typeLazy;
} else {
if (requirejs && typeof requir... | javascript | {
"resource": ""
} |
q56585 | _appendSync | train | function _appendSync($script) {
var _src = $script.attr("src");
if (!_src) {
_src = $script.data("src");
}
var _url = function ($elem) {
var ret = _src;
if (requirejs && typeof requirejs.toUrl === "function") {
ret = requirejs.toUrl(re... | javascript | {
"resource": ""
} |
q56586 | Service | train | function Service(opts) {
_.extend(this,
{
description: '',
utils: require('./utils'),
logger: require('./logger')
},
require('./config')(),
opts
);
// scoped modules contain a '/' (@foo/bar).
// this causes problems when generating logs/scripts | javascript | {
"resource": ""
} |
q56587 | parseServiceJson | train | function parseServiceJson(serviceNameFilter, serviceJson) {
var services = [],
config = require('./config')();
Object.keys(serviceJson).forEach(function(serviceName) {
if (serviceName === 'env' || serviceName === 'args') return;
var serviceConfig = serviceJson[serviceName],
processCount = servic... | javascript | {
"resource": ""
} |
q56588 | train | function(uri, method, headers, data, encType) {
var config = this.config;
var flags = [];
var str;
method = method || 'GET';
if (data && method.toLowerCase() === 'get') {
uri += this.buildQueryString(data);
}
str = ['curl', this.buildFlag('X', method.toUpperCase(), 0, ''), '"' + uri... | javascript | {
"resource": ""
} | |
q56589 | findNodeModules | train | function findNodeModules(cwd) {
var parts = cwd.split(path.sep)
while (parts.length > 0) {
var target = path.join(parts.join(path.sep), 'node_modules')
| javascript | {
"resource": ""
} |
q56590 | train | function () {
Meta.globalTag ('dummy')
$assertEveryCalled (function (mkay1, mkay2) { var this_ = undefined
var Trait = $trait ({
somethingHappened: $trigger () })
var Other = $trait ({
somethingHappened: $dummy (function (_42) { $assert (this, ... | javascript | {
"resource": ""
} | |
q56591 | tryFullscreen | train | function tryFullscreen(shell) {
//Request full screen
var elem = shell.element
if(shell._wantFullscreen && !shell._fullscreenActive) {
var fs = elem.requestFullscreen ||
elem.requestFullScreen ||
elem.webkitRequestFullscreen ||
elem.webkitRequestFullScreen ||
| javascript | {
"resource": ""
} |
q56592 | setKeyState | train | function setKeyState(shell, key, state) {
var ps = shell._curKeyState[key]
if(ps !== state) {
if(state) {
shell._pressCount[key]++
| javascript | {
"resource": ""
} |
q56593 | tick | train | function tick(shell) {
var skip = hrtime() + shell.frameSkip
, pCount = shell._pressCount
, rCount = shell._releaseCount
, i, s, t
, tr = shell._tickRate
, n = keyNames.length
while(!shell._paused &&
hrtime() >= shell._lastTick + tr) {
//Skip frames if we are over budget
if(... | javascript | {
"resource": ""
} |
q56594 | handleKeyUp | train | function handleKeyUp(shell, ev) {
handleEvent(shell, ev)
var kc = physicalKeyCode(ev.keyCode || ev.char || ev.which | javascript | {
"resource": ""
} |
q56595 | handleKeyDown | train | function handleKeyDown(shell, ev) {
if(!isFocused(shell)) {
return
}
handleEvent(shell, ev)
if(ev.metaKey) {
//Hack: Clear key state when meta gets pressed to prevent keys sticking
handleBlur(shell, ev)
} else { | javascript | {
"resource": ""
} |
q56596 | handleMouseWheel | train | function handleMouseWheel(shell, ev) {
handleEvent(shell, ev)
var scale = 1
switch(ev.deltaMode) {
case 0: //Pixel
scale = 1
break
case 1: //Line
scale = 12
break
case 2: //Page
scale = shell.height
break | javascript | {
"resource": ""
} |
q56597 | createPointerEvaluator | train | function createPointerEvaluator(target) {
// Use cache to store already received values.
var cache = {};
return function(pointer) {
if (!isValidJSONPointer(pointer)) {
// If it's not, an exception will be thrown.
throw new ReferenceError(ErrorMessage.INVALID_POINTER);
}
// ... | javascript | {
"resource": ""
} |
q56598 | isValidJSONPointer | train | function isValidJSONPointer(pointer) {
if (!_.isString(pointer)) {
// If it's not a string, it obviously is not valid.
return false;
}
// If it is string and is an empty string, it's valid.
if ('' === pointer) {
return true;
}
// If it is non-empty string, it must | javascript | {
"resource": ""
} |
q56599 | getPointedValue | train | function getPointedValue(target, pointer) {
// If not object, an exception will be thrown.
if (!_.isPlainObject(target)) {
throw new ReferenceError(ErrorMessage.INVALID_DOCUMENT_TYPE);
}
// target is already parsed, create an evaluator for it.
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.