_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q43700 | train | function (files, callback) {
//loop on all files and write them
async.each(files, function (fileObj, mCb) {
var data = swagger.cloneObj(fileObj.data);
//if tokens, replace all occurences with corresponding values
if (fileObj.tokens) {
for (var i in fileObj.tokens) {
var regexp = new RegExp("%"... | javascript | {
"resource": ""
} | |
q43701 | train | function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this.testCategory = name;
return construct(original, args);
} | javascript | {
"resource": ""
} | |
q43702 | createWordNode | train | function createWordNode (item) {
var wordNode = parser.createParentNode('Word')
if (options && options.pos) {
wordNode.data = item
}
var textNode = parser.createTextNode('Text', item.surface_form)
parser.add(textNode, wordNode)
return wordNode
} | javascript | {
"resource": ""
} |
q43703 | createTextNode | train | function createTextNode (type, item) {
var node = parser.createTextNode(type, item.surface_form)
if (options && options.pos) {
node.data = item
}
return node
} | javascript | {
"resource": ""
} |
q43704 | XError | train | function XError(/*code, message, data, privateData, cause*/) {
if (Error.captureStackTrace) Error.captureStackTrace(this, this);
else this.stack = new Error().stack;
var code, message, data, cause, privateData;
for(var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if(XError.isXError(arg) || arg ... | javascript | {
"resource": ""
} |
q43705 | cpuAverage | train | function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores
for(var i = 0, len = cpus.length; i < len; i++) {
//Select CPU core
var cpu = cpus[i];
//Total u... | javascript | {
"resource": ""
} |
q43706 | train | function(r, g, b, a) {
var rnum = typeof r === "number";
if (rnum
&& typeof g === "number"
&& typeof b === "number") {
//default alpha to one
a = typeof a === "number" ? a : 1.0;
} else {
r = g = b = a = rnum ? r : 1.0;
}
if (this.premultiplied) {
r *= a;
g *= a;
b *= a;
}
... | javascript | {
"resource": ""
} | |
q43707 | ParseJapaneseBasic | train | function ParseJapaneseBasic (file, options) {
var offset = 0
var line = 1
var column = 1
var position
if (!(this instanceof ParseJapaneseBasic)) {
return new ParseJapaneseBasic(file, options)
}
if (file && file.message) {
this.file = file
} else {
options = file
}
position = options &... | javascript | {
"resource": ""
} |
q43708 | ParamedicRunner | train | function ParamedicRunner(_platformId,_plugins,_callback,bJustBuild,nPort,msTimeout,browserify,bSilent,bVerbose,platformPath) {
this.tunneledUrl = "";
this.port = nPort;
this.justBuild = bJustBuild;
this.plugins = _plugins;
this.platformId = _platformId;
this.callback = _callback;
this.tempFo... | javascript | {
"resource": ""
} |
q43709 | findImports | train | function findImports(filePath, result) {
var importPaths = getImportPaths(filePath);
var importPathsAbs = resolveImportPaths(filePath, importPaths);
if( importPathsAbs.length )
result.full[filePath] = importPathsAbs;
importPathsAbs.forEach(function(path){
if (result.simple.indexOf(path) === -1) {
... | javascript | {
"resource": ""
} |
q43710 | getImportPaths | train | function getImportPaths(filePath){
var importPaths = [];
try{
var contents = fs.readFileSync(filePath).toString('utf8');
importPaths = parseImpt(contents);
}
catch(exception){}
return importPaths;
} | javascript | {
"resource": ""
} |
q43711 | updatePosition | train | function updatePosition(instance, tetherBounds) {
const x = tetherBounds.x + (instance.horizontalAlignment === HORIZONTAL_ALIGN.LEFT ? 0 : tetherBounds.width)
const y = tetherBounds.y + (instance.verticalAlignment === VERTICAL_ALIGN.TOP ? 0 : tetherBounds.height)
if (transformsSupported) {
instance._... | javascript | {
"resource": ""
} |
q43712 | updateAttributes | train | function updateAttributes(instance) {
if (instance.horizontalAlignment !== instance._lastHorizontalAlignment) {
const horizontalAlignment = instance.horizontalAlignment === HORIZONTAL_ALIGN.LEFT ? 'left' : 'right'
instance._root.setAttribute('data-horizontal-align', horizontalAlignment)
instance._... | javascript | {
"resource": ""
} |
q43713 | getTetherBounds | train | function getTetherBounds(tether) {
const bounds = tether.getBoundingClientRect()
const width = bounds.width
const height = bounds.height
let x = 0
let y = 0
let tetherOffsetContainer = tether
while (tetherOffsetContainer) {
x += tetherOffsetContainer.offsetLeft
y += tetherOffset... | javascript | {
"resource": ""
} |
q43714 | getContentDimensions | train | function getContentDimensions(instance) {
const contentElement = instance._root.firstElementChild
if (!contentElement) {
return {
width: 0,
height: 0,
}
}
let width
let height
if (window.devicePixelRatio > 1) {
// This is much less performant, so we use in only... | javascript | {
"resource": ""
} |
q43715 | train | function( collectionID, criteria, cursor, limit) {
collectionID = collectionID.toLowerCase();
var deferred = q.defer();
// acquire a connection from the pool
db.getClient().then( function(dbClient) {
if ( !dbClient ) {
throw Error("Fai... | javascript | {
"resource": ""
} | |
q43716 | train | function( collectionID, key ) {
collectionID = collectionID.toLowerCase();
var deferred = q.defer();
schemaSyncer.prepCollection(collectionID)
.then( function() {
sqliteObj.find( collectionID, {'_id': key}, false, 1 ).then(
// success
... | javascript | {
"resource": ""
} | |
q43717 | train | function( collectionID, key ) {
collectionID = collectionID.toLowerCase();
var deferred = q.defer();
// acquire a connection from the pool
db.getClient().then( function(dbClient) {
if ( !dbClient ) {
throw Error("Failed to acquire sqli... | javascript | {
"resource": ""
} | |
q43718 | Comment | train | function Comment() {
this.type = 'func'; //func or attr
this.descs = [];
this.attr = {
name: null
};
this.func = {
name: null,
params: null
};
this.clazz = null; //class
this.zuper = null; //super
this.tags = {
/*
name:[val1,val2]
*/
... | javascript | {
"resource": ""
} |
q43719 | train | function(name, value) {
name = name.trim();
value = (value || "").trim();
switch (name) {
//The following are single allowed.
case 'return':
case 'copyright':
case 'author':
case 'since':
case 'description':
case... | javascript | {
"resource": ""
} | |
q43720 | SourceTextParser | train | function SourceTextParser(sourceText, classes, methods) {
this.Comments = [];
this.sourceText = sourceText;
this.classes = classes;
this.methods = methods;
} | javascript | {
"resource": ""
} |
q43721 | train | function() {
var line, lines = this.sourceText.split(/\n/mg),
lineLen = lines.length;
var inCommenting, curComment, closeCommentIdx;
for (var i = 0; i < lineLen; ++i) {
line = lines[i].trim();
if (line.startsWith('/**')) {
inCommenting = true... | javascript | {
"resource": ""
} | |
q43722 | createPage | train | function createPage(filename) {
let page = {
path: filename,
rawContent: fs.readFileSync(filename, "utf8"),
name: path.basename(filename).replace(/\.[^/.]+$/, ""),
filename: path.basename(filename),
folder: path.dirname(filename),
ext: path... | javascript | {
"resource": ""
} |
q43723 | train | function( model ) {
model.unbind( 'destroy', this.unregister );
var coll = this.getCollection( model );
coll && coll.remove( model );
} | javascript | {
"resource": ""
} | |
q43724 | train | function( collection ) {
if ( this.related ) {
this.related
.unbind( 'relational:add', this.handleAddition )
.unbind( 'relational:remove', this.handleRemoval )
.unbind( 'relational:reset', this.handleReset )
}
if ( !collection || !( collection instanceof Backbone.Collection ) ) {
collec... | javascript | {
"resource": ""
} | |
q43725 | train | function( attributes, options ) {
var model = this;
// 'build' is a possible entrypoint; it's possible no model hierarchy has been determined yet.
this.initializeModelHierarchy();
// Determine what type of (sub)model should be built if applicable.
// Lookup the proper subModelType in 'this._subModels'.... | javascript | {
"resource": ""
} | |
q43726 | train | function (element) {
var event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
} | javascript | {
"resource": ""
} | |
q43727 | train | function(event) {
var inputs = $(event.target).parents("form").eq(0).find(":input:visible");
var inputIndex = inputs.index(event.target);
// If at end of focusable elements return false, if not move forward one.
if (inputIndex == inputs.length - 1) {
// return false on last form input so we know t... | javascript | {
"resource": ""
} | |
q43728 | valid | train | function valid(connote) {
if (typeof connote != "string") {
return false;
}
connote = connote.trim().toUpperCase();
// handle 14 character couriers please
if (connote.length === 14 && connote.indexOf("CP") === 0) {
return false;
}
return [10, 14, 18, 21, 39, 40].indexOf(connote.length) != -1;
} | javascript | {
"resource": ""
} |
q43729 | enforce | train | function enforce(targetFunction) {
assert(_.isFunction(targetFunction), 'argument to wrap must be a function');
assert(
_.isObject(targetFunction.$schema),
`Function "${targetFunction.name}" has no $schema property.`);
assert(
_.isArray(targetFunction.$schema.arguments),
`Function "${targetFunctio... | javascript | {
"resource": ""
} |
q43730 | wrappedFunc | train | function wrappedFunc(...args) {
if (!args.length) {
throw new Error(
`Function "${fnName}" invoked without arguments, callback required.`);
}
//
// Splice callback out of arguments array.
//
let originalCb = _.last(args);
assert(
_.isFunction(originalCb),
`Function... | javascript | {
"resource": ""
} |
q43731 | countSubTreeDepth | train | function countSubTreeDepth(scope) {
var thisLevelDepth = 0,
childNodes = scope.childNodes(),
childNode,
childDepth,
i;
if (!childNodes || childNodes.length === 0) {
return 0;
}
for (i = childNodes.length - 1; i >... | javascript | {
"resource": ""
} |
q43732 | train | function (parent, siblings, index) {
this.parent = parent;
this.siblings = siblings.slice(0);
// If source node is in the target nodes
var i = this.siblings.indexOf(this.source);
if (i > -1) {
this.siblings.splice(i, 1);
... | javascript | {
"resource": ""
} | |
q43733 | encrypt | train | function encrypt(message) {
if (this.secure && this.cipher && this.secret) {
if (this.secret === 'secret') {
console.warn('PLEASE change default secret password!');
}
debug('%s encrypt message with %s', this.name, this.cipher);
var cipher = crypto.createCipher(this.cipher, this.secret);
retu... | javascript | {
"resource": ""
} |
q43734 | decrypt | train | function decrypt(message) {
if (this.secure && this.cipher && this.secret) {
if (this.secret === 'secret') {
console.warn('PLEASE change default secret password!');
}
debug('%s decrypt message with %s', this.name, this.cipher);
var decipher = crypto.createDecipher(this.cipher, this.secret);
... | javascript | {
"resource": ""
} |
q43735 | verifyAddress | train | function verifyAddress(address) {
var ifs = os.networkInterfaces();
var nics = Object.keys(ifs);
var i, j, match = false;
nicLoop:
for (i = 0; i < nics.length; i++) {
var nic = ifs[nics[i]];
for (j = 0; j < nic.length; j++) {
if (nic[j].address === address && !nic[j].internal) {
... | javascript | {
"resource": ""
} |
q43736 | flatten | train | function flatten(arr) {
return arr.reduce(function (flat, toFlatten) {
// See if this index is an array that itself needs to be flattened.
if(toFlatten.some && toFlatten.some(Array.isArray)) {
return flat.concat(flatten(toFlatten));
// Otherwise just add the current index to ... | javascript | {
"resource": ""
} |
q43737 | Registrations | train | function Registrations() {
Object.defineProperty(this,'_registrations',{
value: {}
,enumerable: false
,configurable: false
,writable: false
})
this.get = this.get.bind(this)
this.put = this.put.bind(this)
this.clear = this.clear.bind(this)
this.has = this.has.bind... | javascript | {
"resource": ""
} |
q43738 | assembleAttrsFromServer | train | function assembleAttrsFromServer(seedData, formObjectClass) {
// Early return when there was no serialized object provided by the server
if (!seedData) { return {} }
// Otherwise assemble main and submodels' fields
let attrs = merge({}, seedData.fields, seedData.errors)
// TODO: reenable this, but consider t... | javascript | {
"resource": ""
} |
q43739 | addCtrActionsToRouter | train | function addCtrActionsToRouter(ctr, router, name, options) {
for(let prop in ctr) {
if(ctr[prop] instanceof Function) {
const info = new RouteInfo(ctr, name, prop, ctr[prop], options)
/**
* e.g. router.get(path, Middleware).
*/
const path ... | javascript | {
"resource": ""
} |
q43740 | train | function( path) {
var stat = null;
try {
stat = fs.statSync( path );
} catch (err) {
console.log(err);
}
return ( stat && stat.isFile() );
} | javascript | {
"resource": ""
} | |
q43741 | loadHighlighter | train | function loadHighlighter () {
var headElem = d.querySelector('head');
headElem.appendChild(h('link', {
rel: 'stylesheet',
href: 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/default.min.css'
}));
headElem.appendChild(h('script', {
src: 'http://cdnjs.cloudflare.com/ajax/libs/highli... | javascript | {
"resource": ""
} |
q43742 | algebraRing | train | function algebraRing (identities, given) {
// A ring is a group, with multiplication.
const ring = group({
identity: identities[0],
contains: given.contains,
equality: given.equality,
compositionLaw: given.addition,
inversion: given.negation
})
// operators
function multiplication () {
... | javascript | {
"resource": ""
} |
q43743 | __pandocAvailable | train | function __pandocAvailable(cb) {
var test = spawn('pandoc', ['--help']);
test.on('error', function() {
console.error('Pandoc not found');
cb('Pandoc not found');
});
test.on('exit', function() { cb(null); });
test.stdin.end();
} | javascript | {
"resource": ""
} |
q43744 | train | function(user, permissions, options) {
if (!permissions || _.isString(permissions)) {
if (!initialized) {
throw "You must initialize FacebookUtils before calling link.";
}
requestedPermissions = permissions;
return user._linkWith("facebook", options);
} else {
... | javascript | {
"resource": ""
} | |
q43745 | expand | train | function expand(source, opts) {
opts = opts || {};
var re = opts.re = opts.re || '.'
, isre = (re instanceof RegExp)
, o = {}, k, v, parts, i, p;
for(k in source) {
v = source[k];
if(isre ? !re.test(k) : !~k.indexOf(re)) {
o[k] = v;
}else{
parts = k.split(re);
p = o;
fo... | javascript | {
"resource": ""
} |
q43746 | validateFile | train | function validateFile(path, rollCall) {
var stat = path ? fs.statSync(path) : {
size : 0
};
if (!stat.size) {
rollCall.error('Failed to find any entries in "' + path + '" (file size: ' + stat.size + ')');
return false;
}
return true;
} | javascript | {
"resource": ""
} |
q43747 | updateFiles | train | function updateFiles(files, func, bpath, eh) {
try {
if (Array.isArray(files) && typeof func === 'function') {
for (var i = 0; i < files.length; i++) {
var p = path.join(bpath, files[i]), au = '';
var content = rbot.file.read(p, {
encoding : rbot.file.defaultEncoding
});
var ec = func(content... | javascript | {
"resource": ""
} |
q43748 | pickToArray | train | function pickToArray (entities, property, deep) {
if (!(entities instanceof Array) && !isPlainObject(entities)) {
throw new Error('Expecting entity to be object or array of objects')
} else if (typeof property !== 'string' && !(property instanceof Array)) {
throw new Error('Expecting property to be string o... | javascript | {
"resource": ""
} |
q43749 | loadFile | train | function loadFile(path) {
if ( config.asReference && config.asReference.loadFile ) {
return config.asReference.loadFile( path );
} else if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
var fs = require.nodeRequire('fs');
var file = fs.... | javascript | {
"resource": ""
} |
q43750 | escape | train | function escape(content) {
return content.replace(/(["'\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r");
} | javascript | {
"resource": ""
} |
q43751 | areArgumentsValid | train | function areArgumentsValid(args) {
var isValid = args.every(function(arg) {
if (Array.isArray(arg)) {
return areArgumentsValid(arg);
}
return (arg !== null && typeof arg === 'object');
});
return isValid;
} | javascript | {
"resource": ""
} |
q43752 | mapStateToProps | train | function mapStateToProps (state) {
return {
account: state.account ? state.entities.accounts[state.account.id] : null,
router: state.router
}
} | javascript | {
"resource": ""
} |
q43753 | train | function() {
var clone = new CKEDITOR.dom.range( this.root );
clone.startContainer = this.startContainer;
clone.startOffset = this.startOffset;
clone.endContainer = this.endContainer;
clone.endOffset = this.endOffset;
clone.collapsed = this.collapsed;
return clone;
} | javascript | {
"resource": ""
} | |
q43754 | getLengthOfPrecedingTextNodes | train | function getLengthOfPrecedingTextNodes( node ) {
var sum = 0;
while ( ( node = node.getPrevious() ) && node.type == CKEDITOR.NODE_TEXT )
sum += node.getLength();
return sum;
} | javascript | {
"resource": ""
} |
q43755 | train | function() {
var startNode = this.startContainer,
endNode = this.endContainer,
startOffset = this.startOffset,
endOffset = this.endOffset,
childCount;
if ( startNode.type == CKEDITOR.NODE_ELEMENT ) {
childCount = startNode.getChildCount();
if ( childCount > startOffset )
startNode = ... | javascript | {
"resource": ""
} | |
q43756 | train | function( includeSelf, ignoreTextNode ) {
var start = this.startContainer,
end = this.endContainer,
ancestor;
if ( start.equals( end ) ) {
if ( includeSelf && start.type == CKEDITOR.NODE_ELEMENT && this.startOffset == this.endOffset - 1 )
ancestor = start.getChild( this.startOffset );
else
... | javascript | {
"resource": ""
} | |
q43757 | getValidEnlargeable | train | function getValidEnlargeable( enlargeable ) {
return enlargeable && enlargeable.type == CKEDITOR.NODE_ELEMENT && enlargeable.hasAttribute( 'contenteditable' ) ?
null : enlargeable;
} | javascript | {
"resource": ""
} |
q43758 | train | function( mode, selectContents, shrinkOnBlockBoundary ) {
// Unable to shrink a collapsed range.
if ( !this.collapsed ) {
mode = mode || CKEDITOR.SHRINK_TEXT;
var walkerRange = this.clone();
var startContainer = this.startContainer,
endContainer = this.endContainer,
startOffset = this.star... | javascript | {
"resource": ""
} | |
q43759 | train | function( node ) {
this.optimizeBookmark();
this.trim( false, true );
var startContainer = this.startContainer;
var startOffset = this.startOffset;
var nextNode = startContainer.getChild( startOffset );
if ( nextNode )
node.insertBefore( nextNode );
else
startContainer.append( node );
... | javascript | {
"resource": ""
} | |
q43760 | train | function( range ) {
this.setStart( range.startContainer, range.startOffset );
this.setEnd( range.endContainer, range.endOffset );
} | javascript | {
"resource": ""
} | |
q43761 | train | function( startNode, startOffset ) {
// W3C requires a check for the new position. If it is after the end
// boundary, the range should be collapsed to the new start. It seams
// we will not need this check for our use of this class so we can
// ignore it for now.
// Fixing invalid range start inside dt... | javascript | {
"resource": ""
} | |
q43762 | train | function( endNode, endOffset ) {
// W3C requires a check for the new position. If it is before the start
// boundary, the range should be collapsed to the new end. It seams we
// will not need this check for our use of this class so we can ignore
// it for now.
// Fixing invalid range end inside dtd emp... | javascript | {
"resource": ""
} | |
q43763 | train | function( toSplit ) {
if ( !this.collapsed )
return null;
// Extract the contents of the block from the selection point to the end
// of its contents.
this.setEndAt( toSplit, CKEDITOR.POSITION_BEFORE_END );
var documentFragment = this.extractContents();
// Duplicate the element after it.
var ... | javascript | {
"resource": ""
} | |
q43764 | train | function() {
var walkerRange = this.clone();
// Optimize and analyze the range to avoid DOM destructive nature of walker. (#5780)
walkerRange.optimize();
if ( walkerRange.startContainer.type != CKEDITOR.NODE_ELEMENT || walkerRange.endContainer.type != CKEDITOR.NODE_ELEMENT )
return null;
var walker... | javascript | {
"resource": ""
} | |
q43765 | train | function() {
// The reference element contains a zero-width space to avoid
// a premature removal. The view is to be scrolled with respect
// to this element.
var reference = new CKEDITOR.dom.element.createFromHtml( '<span> </span>', this.document ),
afterCaretNode, startContainerText, isStartText... | javascript | {
"resource": ""
} | |
q43766 | shallowEquals | train | function shallowEquals(objA, objB) {
var returnVal = false;
if (objA === objB || objA === null && objB === null) {
returnVal = true;
}
if (!returnVal) {
var propsEqual = true;
if (Object.keys(objA).length === Object.keys(objB).length) {
for (var key in objA) {
propsEqual = propsEqual && objA[key] ===... | javascript | {
"resource": ""
} |
q43767 | checkCommentForSuppress | train | function checkCommentForSuppress(node) {
// Skip if types aren't provided or the comment is empty.
if (!node || !node.value || node.value.length === 0) {
return;
}
const match = node.value.match(/@suppress \{(.*?)\}/);
if (match && match.length === 2) {
if (!blacklistedTyp... | javascript | {
"resource": ""
} |
q43768 | toBoolFunction | train | function toBoolFunction(selector, condition) {
if (arguments.length == 2) {
selector = toBoolFunction(selector);
condition = toBoolFunction(condition);
return function () {
return condition(selector.apply(this, arguments));
};
} else {
condition = selector;
}
var alternate = false;
t... | javascript | {
"resource": ""
} |
q43769 | objectToFunction | train | function objectToFunction(obj) {
var fns = Object.keys(obj)
.map(function (key) {
return toBoolFunction(key, obj[key]);
});
return function(o){
for (var i = 0; i < fns.length; i++) {
if (!fns[i](o)) return false;
}
return true;
}
} | javascript | {
"resource": ""
} |
q43770 | stringToFunction | train | function stringToFunction(str) {
// immediate such as "> 20"
if (/^ *\W+/.test(str)) return new Function('_', 'return _ ' + str);
// properties such as "name.first" or "age > 18"
var fn = new Function('_', 'return _.' + str);
return fn
} | javascript | {
"resource": ""
} |
q43771 | train | function(apiKey, host, port, reqOpts) {
var iod = this
if (_.isObject(host)) {
reqOpts = host
host = null
}
else if (_.isObject(port)) {
reqOpts = port
port = null
}
if (!apiKey) throw Error('IOD apiKey is missing!')
else if (host && !url.parse(host, false, true).protocol) {
throw Error('Protocol not... | javascript | {
"resource": ""
} | |
q43772 | insert_token | train | function insert_token(item) {
var $this_token = $($(input).data("settings").tokenFormatter(item));
var readonly = item.readonly === true ? true : false;
if(readonly) $this_token.addClass($(input).data("settings").classes.tokenReadOnly);
$this_token.addClass($(input).data("setti... | javascript | {
"resource": ""
} |
q43773 | add_token | train | function add_token (item) {
var callback = $(input).data("settings").onAdd;
// See if the token already exists and select it if we don't want duplicates
if(token_count > 0 && $(input).data("settings").preventDuplicates) {
var found_existing_token = null;
token_... | javascript | {
"resource": ""
} |
q43774 | select_token | train | function select_token (token) {
if (!$(input).data("settings").disabled) {
token.addClass($(input).data("settings").classes.selectedToken);
selected_token = token.get(0);
// Hide input box
input_box.val("");
// Hide dropdown if it is visi... | javascript | {
"resource": ""
} |
q43775 | deselect_token | train | function deselect_token (token, position) {
token.removeClass($(input).data("settings").classes.selectedToken);
selected_token = null;
if(position === POSITION.BEFORE) {
input_token.insertBefore(token);
selected_token_index--;
} else if(position === P... | javascript | {
"resource": ""
} |
q43776 | toggle_select_token | train | function toggle_select_token(token) {
var previous_selected_token = selected_token;
if(selected_token) {
deselect_token($(selected_token), POSITION.END);
}
if(previous_selected_token === token.get(0)) {
deselect_token(token, POSITION.END);
... | javascript | {
"resource": ""
} |
q43777 | delete_token | train | function delete_token (token) {
// Remove the id from the saved list
var token_data = $.data(token.get(0), "tokeninput");
var callback = $(input).data("settings").onDelete;
var index = token.prevAll().length;
if(index > selected_token_index) index--;
// Dele... | javascript | {
"resource": ""
} |
q43778 | update_hidden_input | train | function update_hidden_input(saved_tokens, hidden_input) {
var token_values = $.map(saved_tokens, function (el) {
if(typeof $(input).data("settings").tokenValue == 'function')
return $(input).data("settings").tokenValue.call(this, el);
return el[$(input).data("sett... | javascript | {
"resource": ""
} |
q43779 | highlight_term | train | function highlight_term(value, term) {
return value.replace(
new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" + regexp_escape(term) + ")(?![^<>]*>)(?![^&;]+;)",
"gi"
), function(match, p1) {
return "<b>" + escapeHTML(p1) + "</b>";
}
... | javascript | {
"resource": ""
} |
q43780 | excludeCurrent | train | function excludeCurrent(results) {
if ($(input).data("settings").excludeCurrent) {
var currentTokens = $(input).data("tokenInputObject").getTokens(),
trimmedList = [];
if (currentTokens.length) {
$.each(results, function(index, value) {
... | javascript | {
"resource": ""
} |
q43781 | populate_dropdown | train | function populate_dropdown (query, results) {
// exclude current tokens if configured
results = excludeCurrent(results);
if(results && results.length) {
dropdown.empty();
var dropdown_ul = $("<ul/>")
.appendTo(dropdown)
.mous... | javascript | {
"resource": ""
} |
q43782 | select_dropdown_item | train | function select_dropdown_item (item) {
if(item) {
if(selected_dropdown_item) {
deselect_dropdown_item($(selected_dropdown_item));
}
item.addClass($(input).data("settings").classes.selectedDropdownItem);
selected_dropdown_item = item.ge... | javascript | {
"resource": ""
} |
q43783 | deselect_dropdown_item | train | function deselect_dropdown_item (item) {
item.removeClass($(input).data("settings").classes.selectedDropdownItem);
selected_dropdown_item = null;
} | javascript | {
"resource": ""
} |
q43784 | computeURL | train | function computeURL() {
var url = $(input).data("settings").url;
if(typeof $(input).data("settings").url == 'function') {
url = $(input).data("settings").url.call($(input).data("settings"));
}
return url;
} | javascript | {
"resource": ""
} |
q43785 | _matchAllFields | train | function _matchAllFields(fields, matchAnyRegex) {
var regExp = regExps ? matchAnyRegex ? regExps.any : regExps.all : null;
if (regExp) {
for (var i = 0; i < fields.length; ++i) {
parentBuilder.field(fields[i]).is("$regex", regExp);
}
}
return paren... | javascript | {
"resource": ""
} |
q43786 | _matchAnyField | train | function _matchAnyField(fields, matchAnyRegex) {
var regExp = regExps ? matchAnyRegex ? regExps.any : regExps.all : null;
if (regExp) {
var orBuilder = parentBuilder.either();
for (var i = 0; i < fields.length; ++i) {
orBuilder = orBuilder.or().field(fields[i]).is... | javascript | {
"resource": ""
} |
q43787 | train | function (parentBuilder, field) {
if (!dataUtils.isValidStr(field)) throw "Invalid field, should be a string: " + dataUtils.JSONstringify(field);
/**
* Ensures a comparison of the field with the value.
* @param {string} comparator e.g. "$gt", "$gte", etc.
* @param {*} value
* @returns {Quer... | javascript | {
"resource": ""
} | |
q43788 | train | function () {
var _orBuilder = this;
var _queries = [];
var _currentChildBuilder = new ChildQueryBuilder(_orBuilder);
/**
* Process the current OR entry, and continue adding to this OR
* query group.
* @returns {ChildQueryBuilder} A new {@link ChildQueryBuilder}
* child in this OR g... | javascript | {
"resource": ""
} | |
q43789 | init | train | function init(configuration){
var self = {
config : configuration,
adapters : [],
getWhenCurrentWritesDone : getWhenCurrentWritesDone
};
_.each(self.config.adapters, function(adapter){
var adapterInstance;
try {
adapterInstance = require('./adapters/' + ... | javascript | {
"resource": ""
} |
q43790 | initWithFile | train | function initWithFile(configPath){
var configString = fs.readFileSync(path.resolve(configPath));
this.config = JSON.parse(configString);
this.init(this.config);
return this;
} | javascript | {
"resource": ""
} |
q43791 | _write | train | function _write(type, category, message){
var config = this.config;
this.adapters.forEach(function(adapter) {
//Check configuration to see if we should continue.
if(adapter.config.filter && (adapter.config.filter.indexOf(type) > -1)){
return;
}
//We are not filterin... | javascript | {
"resource": ""
} |
q43792 | clone | train | function clone(args, baseDir, privKey, cb) {
run(baseDir, privKey, "git clone " + args, cb)
} | javascript | {
"resource": ""
} |
q43793 | train | function (spec) {
spec.addMatchers({
/**
* Array contains all elements of another array
* @param needles another array
* @returns {Boolean} true/false
*/
toContainAll: function(needles) {
var haystack = this.actual;
return needles.every(function (elem) {
... | javascript | {
"resource": ""
} | |
q43794 | train | function(data) {
var filePath = data.filePath;
var noExtensionFilePath = data.noExtensionFilePath;
var fileName = data.fileName;
var noExtensionFileName = data.noExtensionFileName;
return [
"describe('" + noExtensionFilePath + "', function() {",
"});",
].join('\n');
} | javascript | {
"resource": ""
} | |
q43795 | extract | train | function extract (query) {
var toSplice = []
var extracted = []
return function (prev, curr, index, array) {
if (prev !== extracted) {
if (testValue(prev, query)) {
extracted.push(prev)
toSplice.push(index - 1)
}
}
if (testValue(curr, query)) {
extracted.push(curr)
... | javascript | {
"resource": ""
} |
q43796 | getNewRouteInfo | train | function getNewRouteInfo(that, newRoutePath, path, pathToEmit) {
var indexes = getDivergenceIndexes(that.currentPath, path, newRoutePath)
if(indexes === undefined) {
return undefined
}
var routeDivergenceIndex = indexes.routeIndex
var pathDivergenceIndex = indexes.pa... | javascript | {
"resource": ""
} |
q43797 | loopThroughHandlers | train | function loopThroughHandlers(lastFuture, n) {
if(n < routes.length) {
var route = routes[n].route
var handler = route[handlerProperty]
if(direction === -1) {
var originalIndexFromCurrentRoutes = currentRoutes.length - n - 1
... | javascript | {
"resource": ""
} |
q43798 | urlToId | train | function urlToId(hypemUrl) {
var trimmedUrl = _.trim(hypemUrl);
if (_.startsWith(trimmedUrl, HYPEM_TRACK_URL)) {
var parsedUrl = url.parse(hypemUrl);
var pathname = parsedUrl.pathname; // '/trach/31jfi/...'
var hypemId = pathname.split("/")[2];
return hype... | javascript | {
"resource": ""
} |
q43799 | getById | train | function getById(hypemId, callback) {
var options = {
method: 'HEAD',
url: HYPEM_GO_URL + hypemId,
followRedirect: false,
timeout: FIVE_SECONDS_IN_MILLIS
};
request(options, function (error, response) {
if (error || response.statusCode... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.