_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q35700 | prepareResponse | train | function prepareResponse(response) {
Safe.log('Received response: ', response);
return response.text().then(function(text) {
// If we get a 2xx...
Safe.log('Launcher returned status '+response.status);
if (response.ok) {
// If not an authorized request, or not encrypted, no decryption necessary
... | javascript | {
"resource": ""
} |
q35701 | parseSafeMessage | train | function parseSafeMessage(message, status) {
if (typeof message === 'object') {
return {status: message.errorCode, message: message.description};
} else {
return {status: status, message: message};
}
} | javascript | {
"resource": ""
} |
q35702 | train | function(next) {
if (!extension[type] || typeof extension[type] !== 'function') {
return next();
}
// Invoke type hook implemetation.
extension[type](result, function(error, newItems) {
if (error) {
return next(error);
}
utils.extend(... | javascript | {
"resource": ""
} | |
q35703 | CHS | train | function CHS( cylinder, head, sector ) {
if( !(this instanceof CHS) )
return new CHS( cylinder, head, sector )
if( Buffer.isBuffer( cylinder ) )
return CHS.fromBuffer( cylinder )
/** @type {Number} Cylinder */
this.cylinder = cylinder & 0x03FF
/** @type {Number} Head */
this.head = head & 0xFF
... | javascript | {
"resource": ""
} |
q35704 | train | function( target ) {
target.cylinder = this.cylinder
target.head = this.head
target.sector = this.sector
return target
} | javascript | {
"resource": ""
} | |
q35705 | train | function( buffer, offset ) {
if( !Buffer.isBuffer( buffer ) )
throw new TypeError( 'Value must be a buffer' )
offset = offset || 0
return this.fromNumber( buffer.readUIntLE( offset, 3 ) )
} | javascript | {
"resource": ""
} | |
q35706 | compose | train | function compose(...fns) {
return function(x) {
return fns.reduceRight((result, val) => val(result), x);
};
} | javascript | {
"resource": ""
} |
q35707 | tickify | train | function tickify(fn, {delay} = {}) {
delay = delay || 10;
return function() {
return setTimeout(() => fn.apply(this, arguments), delay);
};
} | javascript | {
"resource": ""
} |
q35708 | memoify | train | function memoify(fn, {hash, cache} = {}) {
hash = hash || identify;
cache = cache = {};
function memoified(...args) {
var key = hash(...args);
return key in cache ? cache[key] : cache[key] = fn.call(this, ...args);
}
memoified.clear = () => cache = {};
return memoified;
} | javascript | {
"resource": ""
} |
q35709 | logify | train | function logify(fn) {
return function() {
console.log("entering", fn.name);
var ret = fn.apply(this, arguments);
console.log("leaving", fn.name);
return ret;
};
} | javascript | {
"resource": ""
} |
q35710 | onceify | train | function onceify(f) {
var ran, ret;
return function() {
return ran ? ret : (ran=true, ret=f.apply(this,arguments));
};
} | javascript | {
"resource": ""
} |
q35711 | wrapify | train | function wrapify(fn, before = noop, after = noop) {
return function(...args) {
before.call(this);
var ret = fn.call(this, ...args);
after.call(this);
return ret;
};
} | javascript | {
"resource": ""
} |
q35712 | parseBody | train | function parseBody(fn){
//get arguments to function as array of strings
var body=fn.body=fn.body|| //cache result in `body` property of function
fn.toString() //get string version of function
.replace(/\/\/.*$|\/\*[\s\S]*?\*\//mg, '') //strip comments
.replace(/^\s*$/mg, '') ... | javascript | {
"resource": ""
} |
q35713 | convertProfNode | train | function convertProfNode (node) {
var res = {
functionName: node.functionName,
lineNumber: node.lineNumber,
callUID: node.callUid,
hitCount: node.selfSamplesCount,
url: node.scriptName,
children: []
};
for (var i = 0; i < node.childrenCount; i++) {
res.children.push(convertProfNode(node.getChild(i)));
... | javascript | {
"resource": ""
} |
q35714 | writeProfile | train | function writeProfile() {
var format;
if (/\.cpuprofile$/.test(argv.o)) {
format = 'cpuprofile';
}
var prof = stopCPU('global', format);
fs.writeFileSync(argv.o, prof);
var fname = JSON.stringify(argv.o);
console.warn('Profile written to', fname + '\nTry `kcachegrind',... | javascript | {
"resource": ""
} |
q35715 | walkBemJson | train | function walkBemJson(bemJson, cb) {
let result;
if (Array.isArray(bemJson)) {
result = [];
bemJson.forEach((childBemJson, i) => {
result[i] = walkBemJson(childBemJson, cb);
});
} else if (bemJson instanceof Object) {
result = {};
Object.keys(bemJson).forEach((key) => {
result[key]... | javascript | {
"resource": ""
} |
q35716 | AdapterJsRTCObjectFactory | train | function AdapterJsRTCObjectFactory(logger) {
Utils.checkArguments(arguments, 1);
this.createIceServers = function (urls, username, password) {
if (typeof(createIceServers) !== "undefined") {
return createIceServers(urls, username, password);
}
else {
logger.erro... | javascript | {
"resource": ""
} |
q35717 | onlySmHere | train | function onlySmHere(jsonFileName,isIndent,outFileName){
if (fs.existsSync(jsonFileName)) {
var fcount = JSON.parse(fs.readFileSync(jsonFileName));
var foooo = [];
if(fs.existsSync('SUMMARY.md')){
fcount = lodash.without(fcount,...haslisted.hasListed('SUMMARY.md'));
}
... | javascript | {
"resource": ""
} |
q35718 | State | train | function State(config) {
this._ = require('lodash');
this._name = config.name;
this._isInitial = config.isInitial;
this._isTerminal = config.isTerminal;
this._outgoingTransitions = config.outgoingTransitions;
this.accept = config.accept;
this._validateConfig(config);
// Transform any value-based tra... | javascript | {
"resource": ""
} |
q35719 | removeDir | train | function removeDir(dirPath, cleanOnly) {
var files;
try {
files = fs.readdirSync(dirPath);
} catch(e) {
return;
}
if (files.length > 0) {
for (var i = 0; i < files.length; i++) {
var filePath = path.join(dirPath, files[i]);
if (fs.statSync(filePath).isFile())
fs.unlinkSync(fi... | javascript | {
"resource": ""
} |
q35720 | loadAndSaveShoots | train | function loadAndSaveShoots(settings, folderPath) {
var promisesPool = [];
var semaphore = new Semaphore({rooms: 6});
settings.pages.forEach((page) => {
settings.sizes.forEach((size) => {
promisesPool.push(semaphore.add(() => {
return new Promise((resolve, reject) => {
console.log(`S... | javascript | {
"resource": ""
} |
q35721 | getModule | train | function getModule (filename) {
const file = files(filename)
const module = file.default || file
if (module.commit) {
throw new Error('[vssr] <%= dir.store %>/' + filename.replace('./', '') + ' should export a method which returns a Vuex instance.')
}
if (module.state && typeof module.state !== 'function'... | javascript | {
"resource": ""
} |
q35722 | filenamify | train | function filenamify(url) {
let res = filenamifyUrl(url);
if (res.length >= 60) {
res = res.substr(0, 60) +
'-md5-' +
crypto.createHash('md5').update(url, 'utf8').digest('hex');
}
return res;
} | javascript | {
"resource": ""
} |
q35723 | hasExpired | train | function hasExpired(headers, refresh) {
if (!headers) {
log('response is not in cache');
return true;
}
if (refresh === 'force') {
log('response in cache but refresh requested');
return true;
}
if (refresh === 'never') {
log('response in cache and considered to be alway... | javascript | {
"resource": ""
} |
q35724 | addPendingFetch | train | function addPendingFetch(url) {
let resolve = null;
let reject = null;
let promise = new Promise((innerResolve, innerReject) => {
resolve = innerResolve;
reject = innerReject;
});
pendingFetches[url] = { promise, resolve, reject };
} | javascript | {
"resource": ""
} |
q35725 | fetchWithRetry | train | async function fetchWithRetry(url, options, remainingAttempts) {
try {
return await baseFetch(url, options);
}
catch (err) {
if (remainingAttempts <= 0) throw err;
log('fetch attempt failed, sleep and try again');
await sleep(2000 + Math.floor(Math.random() * 8000));
... | javascript | {
"resource": ""
} |
q35726 | train | function(pModel)
{
// First create a "lookup" of primary keys that point back to tables
console.log('--> ... creating contextual Index ==> Table lookups ...');
var tmpIndices = {};
for(var tmpTable in pModel.Tables)
{
for (var j = 0; j < pModel.Tables[tmpTable].Columns.length; j++)
{
if (pModel.Tables[tmpTa... | javascript | {
"resource": ""
} | |
q35727 | _delete | train | function _delete(name) {
observers[name].unobserve();
delete observers[name];
delete u [name];
delete shadow [name];
} | javascript | {
"resource": ""
} |
q35728 | add | train | function add(name) {
function set(v) {
var oldValue = shadow[name];
if (oldValue === v) return;
o[name] = v;
notifier.notify({type: 'update', object: u, name, oldValue});
shadow[name] = oldValue.change(v);
}
// When property on upwardable object is accessed, report it and ret... | javascript | {
"resource": ""
} |
q35729 | objectObserver | train | function objectObserver(changes) {
changes.forEach(({type, name}) => {
switch (type) {
case 'add': o[name] = u[name]; break;
case 'delete': delete o[name]; break;
}
});
} | javascript | {
"resource": ""
} |
q35730 | buildMessageBuilder | train | function buildMessageBuilder(section) {
const logOptions = process.env.X2_LOG || '';
const msgBuilder = new Array();
if (!/(^|,)nots(,|$)/i.test(logOptions))
msgBuilder.push(() => (new Date()).toISOString());
if (!/(^|,)nopid(,|$)/i.test(logOptions))
msgBuilder.push(() => String(process.pid));
let m;
con... | javascript | {
"resource": ""
} |
q35731 | makeSheet | train | function makeSheet(scope) {
var style = document.createElement('style');
document.head.appendChild(style);
var sheet = style.sheet;
if (scope) {
style.setAttribute('scoped', "scoped");
if (!scopedSupported) {
scope.dataset[scopedStyleIdsProp] = (scope.dataset[scopedStyleIdsProp] || "") + " " +
... | javascript | {
"resource": ""
} |
q35732 | Concept | train | function Concept(concept) {
if (!(concept.prefLabel && concept.id && concept.type === 'Concept')) {
throw new Error('Invalid concept: "' + concept.id + '"');
}
this.id = concept.id;
this.prefLabel = concept.prefLabel;
this.altLabel = concept.altLabel;
this.hiddenLabel = concept.hiddenLabel;
this.defin... | javascript | {
"resource": ""
} |
q35733 | train | function () {
// Get stored auth data.
var stored = this.storage.get();
// If nothing stored, proceed with new authorization
if (!stored) {
this.log('No auth data stored, starting authorization from scratch...');
return this.auth.authorize();
}
// Otherwise, set the auth data on th... | javascript | {
"resource": ""
} | |
q35734 | train | function () {
this.log('Authorizing...');
// Generate new asymmetric key pair and nonce, e.g. public-key encryption
var asymKeys = nacl.box.keyPair(),
asymNonce = nacl.randomBytes(nacl.box.nonceLength);
// The payload for the request
var authPayload = {
app: this.app,
publicKey... | javascript | {
"resource": ""
} | |
q35735 | train | function () {
this.log('Checking if authorized...');
return this.Request.get('/auth').auth().execute()
// let's use our own function here, that resolve true or false,
// rather than throwing an error if invalid token
.then(function () {
this.log('Authorized');
return true;
... | javascript | {
"resource": ""
} | |
q35736 | train | function () {
this.log('Deauthorizing...');
return this.Request.delete('/auth').auth().execute()
.then(function (response) {
// Clear auth data from storage upon deauthorization
this.storage.clear();
clearAuthData.call(this);
this.log('Deauthorized and cleared from storage... | javascript | {
"resource": ""
} | |
q35737 | model | train | function model(M, prop) {
const bmiLens = L(
prop,
// if we don't have <prop> property yet, then use these default values
L.defaults({weight: 80, height: 180}),
// add "read-only" bmi property to our BMI model that is derived from weight and height
L.augment({bmi: ({weight: w, height: h}) => Math.... | javascript | {
"resource": ""
} |
q35738 | beginsWith | train | function beginsWith(haystack, needles) {
let needle;
for (let i = 0, u = needles.length; i < u; ++i) {
needle = needles[i];
if (haystack.substr(0, needle.length) === needle) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q35739 | mergeQuery | train | function mergeQuery(path, newQuery) {
let parsed, properties, query, queryString;
// Return the original path if the query to merge is empty.
if (Object.keys(newQuery).length === 0) {
return path;
}
// Parse the original path.
parsed = url.parse(path, true);
// Merge the queries to f... | javascript | {
"resource": ""
} |
q35740 | runSync | train | function runSync(context, func, callback)
{
var result
, requiresContext = isArrowFunction(func)
;
try
{
if (requiresContext)
{
result = func.call(null, context);
}
else
{
result = func.call(context);
}
}
catch (ex)
{
// pass error as error-first callback
... | javascript | {
"resource": ""
} |
q35741 | runAsync | train | function runAsync(context, func, callback)
{
var result
, requiresContext = isArrowFunction(func)
;
if (requiresContext)
{
result = func.call(null, context, callback);
}
else
{
result = func.call(context, callback);
}
return result;
} | javascript | {
"resource": ""
} |
q35742 | async | train | function async(func)
{
function wrapper()
{
var context = this;
var args = arguments;
process.nextTick(function()
{
func.apply(context, args);
});
}
return wrapper;
} | javascript | {
"resource": ""
} |
q35743 | traceSources | train | function traceSources(node, original) {
var i,
source,
sources;
if (!(node instanceof EffectNode) && !(node instanceof TransformNode)) {
return false;
}
sources = node.sources;
for (i in sources) {
if (sources.hasOwnProperty(i)) {
source = sources[i];
if (source === original... | javascript | {
"resource": ""
} |
q35744 | makePolygonsArray | train | function makePolygonsArray(poly) {
if (!poly || !poly.length || !Array.isArray(poly)) {
return [];
}
if (!Array.isArray(poly[0])) {
return [poly];
}
if (Array.isArray(poly[0]) && !isNaN(poly[0][0])) {
return [poly];
}
return poly;
} | javascript | {
"resource": ""
} |
q35745 | longestCommonPathPrefix | train | function longestCommonPathPrefix(stra, strb) {
const minlen = min(stra.length, strb.length);
let common = 0;
let lastSep = -1;
for (; common < minlen; ++common) {
const chr = stra[common];
if (chr !== strb[common]) {
break;
}
if (chr === sep) {
lastSep = common;
}
}
if (commo... | javascript | {
"resource": ""
} |
q35746 | relpath | train | function relpath(basePath, absPath) {
let base = dedot(basePath);
let abs = dedot(absPath);
// Find the longest common prefix that ends with a separator.
const commonPrefix = longestCommonPathPrefix(base, abs);
// Remove the common path elements.
base = apply(substring, base, [ commonPrefix ]);
abs = appl... | javascript | {
"resource": ""
} |
q35747 | createOptionsForServerSpec | train | function createOptionsForServerSpec(serverSpec) {
var options = {
forceNew: true, // Make a new connection each time
reconnection: false // Don't try and reconnect automatically
};
// If the server spec contains a socketResource setting we use
// that otherwise leave t... | javascript | {
"resource": ""
} |
q35748 | Chickadee | train | function Chickadee(options) {
var self = this;
options = options || {};
self.associations = options.associationManager ||
new associationManager(options);
self.routes = {
"/associations": require('./routes/associations'),
"/contextat": require('./routes/contextat'),
"/context... | javascript | {
"resource": ""
} |
q35749 | convertOptionsParamsToIds | train | function convertOptionsParamsToIds(req, instance, options, callback) {
var err;
if(options.id) {
var isValidID = reelib.identifier.isValid(options.id);
if(!isValidID) {
err = 'Invalid id';
}
options.ids = [options.id];
delete options.id;
callback(err);
}
else if(options.directory)... | javascript | {
"resource": ""
} |
q35750 | hex | train | function hex(n) {
return crypto.randomBytes(Math.ceil(n / 2)).toString('hex').slice(0, n);
} | javascript | {
"resource": ""
} |
q35751 | exportKs | train | function exportKs (password, privateKey, salt, iv, type, option = {}) {
if (!password || !privateKey || !type) {
throw new Error('Missing parameter! Make sure password, privateKey and type provided')
}
if (!crypto.isPrivateKey(privateKey)) {
throw new Error('given Private Key is not a valid Private Key s... | javascript | {
"resource": ""
} |
q35752 | verifyAndDecrypt | train | function verifyAndDecrypt(derivedKey, iv, ciphertext, algo, mac) {
if (typeof algo !== 'string') {
throw new Error('Cipher method is invalid. Unable to proceed')
}
var key;
if (crypto.createMac(derivedKey, ciphertext) !== mac) {
throw new Error('message authentication code mismatch');
}
key = deriv... | javascript | {
"resource": ""
} |
q35753 | buildJs | train | function buildJs() {
// Construct a stream for the JS sources of our plugin, don't read file contents when compiling TypeScript.
var sourceStream = gulp.src( config.Sources.Scripts, {
cwd : config.WorkingDirectory,
read : true
} );
return sourceStream
.pipe( jscs() )
.pipe( jscs.reporter() )
.pipe( jsVa... | javascript | {
"resource": ""
} |
q35754 | _fetchSubreddit | train | function _fetchSubreddit(subreddit) {
const reducer = (prev, {data: {url}}) => prev.push(url) && prev;
const jsonUri = `https://www.reddit.com/r/${subreddit}/.json`;
return fetch(jsonUri)
.then((res) => res.json())
.then((res) => res.data.children.reduce(reducer, []))
.then((urls) => ({subreddit, urls... | javascript | {
"resource": ""
} |
q35755 | _fetchRandomSubreddit | train | function _fetchRandomSubreddit(count=1, subreddit='random', fetchOpts={}) {
const _fetchSubredditUrl = (subreddit, fetchOpts) => {
return fetch(`https://www.reddit.com/r/${subreddit}`, fetchOpts)
.then(({url}) => {
return {
json: `${url}.json`,
name: getSubredditName(url),
... | javascript | {
"resource": ""
} |
q35756 | getSubredditName | train | function getSubredditName(url) {
try {
// This will throw a `TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null` if the RegExp fails.
const [input, name] = new RegExp('^https?://(?:www.)?reddit.com/r/(.*?)/?$').exec(url);
return name;
} catch (err) {
return null;
}
} | javascript | {
"resource": ""
} |
q35757 | relativePosition | train | function relativePosition(rect, targetRect, rel) {
var x, y, w, h, targetW, targetH;
x = targetRect.x;
y = targetRect.y;
w = rect.w;
h = rect.h;
targetW = targetRect.w;
targetH = targetRect.h;
rel = (rel || '').split('');
if (rel[0] === 'b') {
y += target... | javascript | {
"resource": ""
} |
q35758 | inflate | train | function inflate(rect, w, h) {
return create(rect.x - w, rect.y - h, rect.w + w * 2, rect.h + h * 2);
} | javascript | {
"resource": ""
} |
q35759 | intersect | train | function intersect(rect, cropRect) {
var x1, y1, x2, y2;
x1 = max(rect.x, cropRect.x);
y1 = max(rect.y, cropRect.y);
x2 = min(rect.x + rect.w, cropRect.x + cropRect.w);
y2 = min(rect.y + rect.h, cropRect.y + cropRect.h);
if (x2 - x1 < 0 || y2 - y1 < 0) {
return null;
... | javascript | {
"resource": ""
} |
q35760 | clamp | train | function clamp(rect, clampRect, fixedSize) {
var underflowX1, underflowY1, overflowX2, overflowY2,
x1, y1, x2, y2, cx2, cy2;
x1 = rect.x;
y1 = rect.y;
x2 = rect.x + rect.w;
y2 = rect.y + rect.h;
cx2 = clampRect.x + clampRect.w;
cy2 = clampRect.y + clampRect.h;
u... | javascript | {
"resource": ""
} |
q35761 | fromClientRect | train | function fromClientRect(clientRect) {
return create(clientRect.left, clientRect.top, clientRect.width, clientRect.height);
} | javascript | {
"resource": ""
} |
q35762 | train | function (callback, element) {
if (requestAnimationFramePromise) {
requestAnimationFramePromise.then(callback);
return;
}
requestAnimationFramePromise = new Promise(function (resolve) {
if (!element) {
element = document.body;
}
req... | javascript | {
"resource": ""
} | |
q35763 | train | function (editor, callback, time) {
var timer;
timer = wrappedSetInterval(function () {
if (!editor.removed) {
callback();
} else {
clearInterval(timer);
}
}, time);
return timer;
} | javascript | {
"resource": ""
} | |
q35764 | addEvent | train | function addEvent(target, name, callback, capture) {
if (target.addEventListener) {
target.addEventListener(name, callback, capture || false);
} else if (target.attachEvent) {
target.attachEvent('on' + name, callback);
}
} | javascript | {
"resource": ""
} |
q35765 | removeEvent | train | function removeEvent(target, name, callback, capture) {
if (target.removeEventListener) {
target.removeEventListener(name, callback, capture || false);
} else if (target.detachEvent) {
target.detachEvent('on' + name, callback);
}
} | javascript | {
"resource": ""
} |
q35766 | getTargetFromShadowDom | train | function getTargetFromShadowDom(event, defaultTarget) {
var path, target = defaultTarget;
// When target element is inside Shadow DOM we need to take first element from path
// otherwise we'll get Shadow Root parent, not actual target element
// Normalize target for WebComponents v0 implementa... | javascript | {
"resource": ""
} |
q35767 | fix | train | function fix(originalEvent, data) {
var name, event = data || {}, undef;
// Dummy function that gets replaced on the delegation state functions
function returnFalse() {
return false;
}
// Dummy function that gets replaced on the delegation state functions
function returnTru... | javascript | {
"resource": ""
} |
q35768 | is | train | function is(obj, type) {
if (!type) {
return obj !== undefined;
}
if (type == 'array' && Arr.isArray(obj)) {
return true;
}
return typeof obj == type;
} | javascript | {
"resource": ""
} |
q35769 | create | train | function create(s, p, root) {
var self = this, sp, ns, cn, scn, c, de = 0;
// Parse : <prefix> <class>:<super class>
s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);
cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name
// Create namespace for new class
ns = self.createNS(s[3].replace... | javascript | {
"resource": ""
} |
q35770 | walk | train | function walk(o, f, n, s) {
s = s || this;
if (o) {
if (n) {
o = o[n];
}
Arr.each(o, function (o, i) {
if (f.call(s, o, i, n) === false) {
return false;
}
walk(o, f, n, s);
});
}
} | javascript | {
"resource": ""
} |
q35771 | createNS | train | function createNS(n, o) {
var i, v;
o = o || window;
n = n.split('.');
for (i = 0; i < n.length; i++) {
v = n[i];
if (!o[v]) {
o[v] = {};
}
o = o[v];
}
return o;
} | javascript | {
"resource": ""
} |
q35772 | resolve | train | function resolve(n, o) {
var i, l;
o = o || window;
n = n.split('.');
for (i = 0, l = n.length; i < l; i++) {
o = o[n[i]];
if (!o) {
break;
}
}
return o;
} | javascript | {
"resource": ""
} |
q35773 | train | function (selector, context) {
var self = this, match, node;
if (!selector) {
return self;
}
if (selector.nodeType) {
self.context = self[0] = selector;
self.length = 1;
return self;
}
if (context && context.nodeType) {
... | javascript | {
"resource": ""
} | |
q35774 | train | function (items, sort) {
var self = this, nodes, i;
if (isString(items)) {
return self.add(DomQuery(items));
}
if (sort !== false) {
nodes = DomQuery.unique(self.toArray().concat(DomQuery.makeArray(items)));
self.length = nodes.length;
for (i = 0... | javascript | {
"resource": ""
} | |
q35775 | train | function () {
var self = this, node, i = this.length;
while (i--) {
node = self[i];
Event.clean(node);
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
return this;
} | javascript | {
"resource": ""
} | |
q35776 | train | function () {
var self = this, node, i = this.length;
while (i--) {
node = self[i];
while (node.firstChild) {
node.removeChild(node.firstChild);
}
}
return this;
} | javascript | {
"resource": ""
} | |
q35777 | train | function (value) {
var self = this, i;
if (isDefined(value)) {
i = self.length;
try {
while (i--) {
self[i].innerHTML = value;
}
} catch (ex) {
// Workaround for "Unknown runtime error" when DIV is added to P on IE
... | javascript | {
"resource": ""
} | |
q35778 | train | function (value) {
var self = this, i;
if (isDefined(value)) {
i = self.length;
while (i--) {
if ("innerText" in self[i]) {
self[i].innerText = value;
} else {
self[0].textContent = value;
}
}
retur... | javascript | {
"resource": ""
} | |
q35779 | train | function () {
var self = this;
if (self[0] && self[0].parentNode) {
return domManipulate(self, arguments, function (node) {
this.parentNode.insertBefore(node, this);
});
}
return self;
} | javascript | {
"resource": ""
} | |
q35780 | train | function () {
var self = this;
if (self[0] && self[0].parentNode) {
return domManipulate(self, arguments, function (node) {
this.parentNode.insertBefore(node, this.nextSibling);
}, true);
}
return self;
} | javascript | {
"resource": ""
} | |
q35781 | train | function (className, state) {
var self = this;
// Functions are not supported
if (typeof className != 'string') {
return self;
}
if (className.indexOf(' ') !== -1) {
each(className.split(' '), function () {
self.toggleClass(this, state);
... | javascript | {
"resource": ""
} | |
q35782 | train | function (name) {
return this.each(function () {
if (typeof name == 'object') {
Event.fire(this, name.type, name);
} else {
Event.fire(this, name);
}
});
} | javascript | {
"resource": ""
} | |
q35783 | train | function (selector) {
var i, l, ret = [];
for (i = 0, l = this.length; i < l; i++) {
DomQuery.find(selector, this[i], ret);
}
return DomQuery(ret);
} | javascript | {
"resource": ""
} | |
q35784 | train | function (selector) {
if (typeof selector == 'function') {
return DomQuery(grep(this.toArray(), function (item, i) {
return selector(i, item);
}));
}
return DomQuery(DomQuery.filter(selector, this.toArray()));
} | javascript | {
"resource": ""
} | |
q35785 | train | function (selector) {
var result = [];
if (selector instanceof DomQuery) {
selector = selector[0];
}
this.each(function (i, node) {
while (node) {
if (typeof selector == 'string' && DomQuery(node).is(selector)) {
result.push(node);
... | javascript | {
"resource": ""
} | |
q35786 | train | function (node) {
return Tools.toArray((node.nodeName === "iframe" ? node.contentDocument || node.contentWindow.document : node).childNodes);
} | javascript | {
"resource": ""
} | |
q35787 | nativeDecode | train | function nativeDecode(text) {
var elm;
elm = document.createElement("div");
elm.innerHTML = text;
return elm.textContent || elm.innerText || text;
} | javascript | {
"resource": ""
} |
q35788 | train | function (text, attr) {
return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function (chr) {
// Multi byte sequence convert it to a single entity
if (chr.length > 1) {
return '&#' + (((chr.charCodeAt(0) - 0xD800) * 0x400) + (chr.charCodeAt(1) - 0xDC00) + 0x10000) + ';'... | javascript | {
"resource": ""
} | |
q35789 | train | function (text) {
return text.replace(entityRegExp, function (all, numeric) {
if (numeric) {
if (numeric.charAt(0).toLowerCase() === 'x') {
numeric = parseInt(numeric.substr(1), 16);
} else {
numeric = parseInt(numeric, 10);
}
... | javascript | {
"resource": ""
} | |
q35790 | wait | train | function wait(testCallback, waitCallback) {
if (!testCallback()) {
// Wait for timeout
if ((new Date().getTime()) - startTime < maxLoadTime) {
Delay.setTimeout(waitCallback);
} else {
failed();
}
}
} | javascript | {
"resource": ""
} |
q35791 | waitForGeckoLinkLoaded | train | function waitForGeckoLinkLoaded() {
wait(function () {
try {
// Accessing the cssRules will throw an exception until the CSS file is loaded
var cssRules = style.sheet.cssRules;
passed();
return !!cssRules;
} catch (ex) {
... | javascript | {
"resource": ""
} |
q35792 | DOMUtils | train | function DOMUtils(doc, settings) {
var self = this, blockElementsMap;
self.doc = doc;
self.win = window;
self.files = {};
self.counter = 0;
self.stdMode = !isIE || doc.documentMode >= 8;
self.boxModel = !isIE || doc.compatMode == "CSS1Compat" || self.stdMode;
self.styleS... | javascript | {
"resource": ""
} |
q35793 | train | function (win) {
var doc, rootElm;
win = !win ? this.win : win;
doc = win.document;
rootElm = this.boxModel ? doc.documentElement : doc.body;
// Returns viewport size excluding scrollbars
return {
x: win.pageXOffset || rootElm.scrollLeft,
y: win.page... | javascript | {
"resource": ""
} | |
q35794 | train | function (elm) {
var self = this, pos, size;
elm = self.get(elm);
pos = self.getPos(elm);
size = self.getSize(elm);
return {
x: pos.x, y: pos.y,
w: size.w, h: size.h
};
} | javascript | {
"resource": ""
} | |
q35795 | train | function (elm) {
var self = this, w, h;
elm = self.get(elm);
w = self.getStyle(elm, 'width');
h = self.getStyle(elm, 'height');
// Non pixel value, then force offset/clientWidth
if (w.indexOf('px') === -1) {
w = 0;
}
// Non pixel value, then f... | javascript | {
"resource": ""
} | |
q35796 | train | function (node, selector, root, collect) {
var self = this, selectorVal, result = [];
node = self.get(node);
collect = collect === undefined;
// Default root on inline mode
root = root || (self.getRoot().nodeName != 'BODY' ? self.getRoot().parentNode : null);
// Wrap n... | javascript | {
"resource": ""
} | |
q35797 | train | function (elm) {
var name;
if (elm && this.doc && typeof elm == 'string') {
name = elm;
elm = this.doc.getElementById(elm);
// IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick
if (elm && elm.i... | javascript | {
"resource": ""
} | |
q35798 | train | function (name, attrs, html) {
return this.add(this.doc.createElement(name), name, attrs, html, 1);
} | javascript | {
"resource": ""
} | |
q35799 | train | function (name, attrs, html) {
var outHtml = '', key;
outHtml += '<' + name;
for (key in attrs) {
if (attrs.hasOwnProperty(key) && attrs[key] !== null && typeof attrs[key] != 'undefined') {
outHtml += ' ' + key + '="' + this.encode(attrs[key]) + '"';
}
}... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.