_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q23300 | loadCss | train | function loadCss (css, name) {
if (css) {
cssLoader.insertStyleElement(document, document.head, css, name, false)
}
} | javascript | {
"resource": ""
} |
q23301 | ssEnabled | train | function ssEnabled () {
let support = false
try {
window.sessionStorage.setItem('_t', 1)
window.sessionStorage.removeItem('_t')
support = true
} catch (e) {}
return support
} | javascript | {
"resource": ""
} |
q23302 | dependArray | train | function dependArray (value) {
for (let e, i = 0, l = value.length; i < l; i++) {
e = value[i]
e && e.__ob__ && e.__ob__.dep.depend()
if (Array.isArray(e)) {
dependArray(e)
}
}
} | javascript | {
"resource": ""
} |
q23303 | train | function () {
function impl (element) {
customElement.call(this, element)
}
impl.prototype = Object.create(customElement.prototype)
return impl
} | javascript | {
"resource": ""
} | |
q23304 | forwardTransitionAndCreate | train | function forwardTransitionAndCreate (shell, options) {
let {sourcePageId, targetPageId, targetPageMeta, onComplete} = options
let loading = getLoading(targetPageMeta, {transitionContainsHeader: shell.transitionContainsHeader})
loading.classList.add('slide-enter', 'slide-enter-active')
css(loading, 'display', 'b... | javascript | {
"resource": ""
} |
q23305 | backwardTransitionAndCreate | train | function backwardTransitionAndCreate (shell, options) {
let {
targetPageId,
targetPageMeta,
sourcePageId,
sourcePageMeta,
onComplete
} = options
// Goto root page, resume scroll position (Only appears in backward)
let rootPageScrollPosition = 0
fixRootPageScroll(shell, {targetPageId})
if... | javascript | {
"resource": ""
} |
q23306 | skipTransitionAndCreate | train | function skipTransitionAndCreate (shell, options) {
let {sourcePageId, targetPageId, onComplete} = options
hideAllIFrames()
fixRootPageScroll(shell, {sourcePageId, targetPageId})
onComplete && onComplete()
let iframe = getIFrame(targetPageId)
css(iframe, 'z-index', activeZIndex++)
shell.afterSwitchPage... | javascript | {
"resource": ""
} |
q23307 | createBaseElementProto | train | function createBaseElementProto () {
if (baseElementProto) {
return baseElementProto
}
// Base element inherits from HTMLElement
let proto = Object.create(HTMLElement.prototype)
/**
* Created callback of MIPElement. It will initialize the element.
*/
proto.createdCallback = function () {
// ... | javascript | {
"resource": ""
} |
q23308 | createMipElementProto | train | function createMipElementProto (name) {
let proto = Object.create(createBaseElementProto())
proto.name = name
return proto
} | javascript | {
"resource": ""
} |
q23309 | getErrorMess | train | function getErrorMess (code, name) {
let mess
switch (code) {
case eCode.siteExceed:
mess = 'storage space need less than 4k'
break
case eCode.lsExceed:
mess = 'Uncaught DOMException: Failed to execute setItem on Storage: Setting the value of ' +
name + ' exceeded the quota at ' + ... | javascript | {
"resource": ""
} |
q23310 | matches | train | function matches (element, selector) {
if (!element || element.nodeType !== 1) {
return false
}
return nativeMatches.call(element, selector)
} | javascript | {
"resource": ""
} |
q23311 | closestTo | train | function closestTo (element, selector, target) {
let closestElement = closest(element, selector)
return contains(target, closestElement) ? closestElement : null
} | javascript | {
"resource": ""
} |
q23312 | create | train | function create (str) {
createTmpElement.innerHTML = str
if (!createTmpElement.children.length) {
return null
}
let children = Array.prototype.slice.call(createTmpElement.children)
createTmpElement.innerHTML = ''
return children.length > 1 ? children : children[0]
} | javascript | {
"resource": ""
} |
q23313 | onDocumentState | train | function onDocumentState (doc, stateFn, callback) {
let ready = stateFn(doc)
if (ready) {
callback(doc)
return
}
const readyListener = () => {
if (!stateFn(doc)) {
return
}
if (!ready) {
ready = true
callback(doc)
}
doc.removeEventListener('readystatechange', r... | javascript | {
"resource": ""
} |
q23314 | insert | train | function insert (parent, children) {
if (!parent || !children) {
return
}
let nodes = Array.prototype.slice.call(children)
if (nodes.length === 0) {
nodes.push(children)
}
for (let i = 0; i < nodes.length; i++) {
if (this.contains(nodes[i], parent)) {
continue
}
if (nodes[i] !== pa... | javascript | {
"resource": ""
} |
q23315 | prefixProperty | train | function prefixProperty (property) {
property = property.replace(camelReg, (match, first, char) => (first ? char : char.toUpperCase()))
if (prefixCache[property]) {
return prefixCache[property]
}
let prop
if (!(property in supportElement.style)) {
for (let i = 0; i < PREFIX_TYPE.length; i++) {
... | javascript | {
"resource": ""
} |
q23316 | unitProperty | train | function unitProperty (property, value) {
if (value !== +value) {
return value
}
if (unitCache[property]) {
return value + unitCache[property]
}
supportElement.style[property] = 0
let propValue = supportElement.style[property]
let match = propValue.match && propValue.match(UNIT_REG)
if (matc... | javascript | {
"resource": ""
} |
q23317 | isLayoutSizeDefined | train | function isLayoutSizeDefined (layout) {
return (
layout === LAYOUT.FIXED ||
layout === LAYOUT.FIXED_HEIGHT ||
layout === LAYOUT.RESPONSIVE ||
layout === LAYOUT.FILL ||
layout === LAYOUT.FLEX_ITEM ||
layout === LAYOUT.INTRINSIC
)
} | javascript | {
"resource": ""
} |
q23318 | checkComponents | train | function checkComponents (options) {
for (const key in options.components) {
const lower = key.toLowerCase()
if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
warn(
'Do not use built-in or reserved HTML elements as component ' +
'id: ' + key
)
}
}
} | javascript | {
"resource": ""
} |
q23319 | lastChildElement | train | function lastChildElement (parent, callback) {
for (let child = parent.lastElementChild; child; child = child.previousElementSibling) {
if (callback(child)) {
return child
}
}
return null
} | javascript | {
"resource": ""
} |
q23320 | isInternalNode | train | function isInternalNode (node) {
let tagName = (typeof node === 'string') ? node : node.tagName
if (tagName && tagName.toLowerCase().indexOf('mip-i-') === 0) {
return true
}
if (node.tagName && (node.hasAttribute('placeholder') ||
node.hasAttribute('fallback') ||
node.hasAttribute('overflow')))... | javascript | {
"resource": ""
} |
q23321 | touchHandler | train | function touchHandler (event) {
let opt = this._opt
opt.preventDefault && event.preventDefault()
opt.stopPropagation && event.stopPropagation()
// 如果 touchstart 没有被触发(可能被子元素的 touchstart 回调触发了 stopPropagation),
// 那么后续的手势将取消计算
if (event.type !== 'touchstart' && !dataProcessor.startTime) {
return
}
... | javascript | {
"resource": ""
} |
q23322 | listenersHelp | train | function listenersHelp (element, events, handler, method) {
let list = events.split(' ')
for (let i = 0, len = list.length; i < len; i++) {
let item = list[i]
if (method === false) {
element.removeEventListener(item, handler)
} else {
element.addEventListener(item, handler, false)
}
}
... | javascript | {
"resource": ""
} |
q23323 | flushWatcherQueue | train | function flushWatcherQueue () {
flushing = true
let watcher
let id
queue.sort((a, b) => a.id - b.id)
for (index = 0; index < queue.length; index++) {
watcher = queue[index]
id = watcher.id
has[id] = null
watcher.run()
// in dev build, check and stop circular updates.
if (process.env.... | javascript | {
"resource": ""
} |
q23324 | createEvent | train | function createEvent (type, data) {
let event = document.createEvent(specialEvents[type] || 'Event')
event.initEvent(type, true, true)
data && (event.data = data)
return event
} | javascript | {
"resource": ""
} |
q23325 | listenOnce | train | function listenOnce (element, eventType, listener, optEvtListenerOpts) {
let unlisten = listen(element, eventType, event => {
unlisten()
listener(event)
}, optEvtListenerOpts)
return unlisten
} | javascript | {
"resource": ""
} |
q23326 | loadPromise | train | function loadPromise (eleOrWindow) {
if (isLoaded(eleOrWindow)) {
return Promise.resolve(eleOrWindow)
}
let loadingPromise = new Promise((resolve, reject) => {
// Listen once since IE 5/6/7 fire the onload event continuously for
// animated GIFs.
let {tagName} = eleOrWindow
if (tagName === 'A... | javascript | {
"resource": ""
} |
q23327 | ParseArea | train | function ParseArea(obj) {
if (!obj) return;
if (obj.areas) {
for (var i in obj.areas) {
AddRideName(obj.areas[i]);
ParseArea(obj.areas[i]);
}
}
if (obj.items) {
for (var j in obj.items) {
AddRideName(obj.items[j]);
ParseArea(obj.i... | javascript | {
"resource": ""
} |
q23328 | train | function(context) {
var evaluate = function(rules, createRule) {
var i;
rules = rules || [];
for (i = 0; i < rules.length; i++) {
if (typeof(rules[i]) === "function") {
if (rules[i](context)) {
return defaultHandleToken("named-ident")(context);
}
} else if (createRul... | javascript | {
"resource": ""
} | |
q23329 | last | train | function last(thing) {
return thing.charAt ? thing.charAt(thing.length - 1) : thing[thing.length - 1];
} | javascript | {
"resource": ""
} |
q23330 | merge | train | function merge(defaultObject, objectToMerge) {
var key;
if (!objectToMerge) {
return defaultObject;
}
for (key in objectToMerge) {
defaultObject[key] = objectToMerge[key];
}
return defaultObject;
} | javascript | {
"resource": ""
} |
q23331 | getNextWhile | train | function getNextWhile(tokens, index, direction, matcher) {
var count = 1,
token;
direction = direction || 1;
while (token = tokens[index + (direction * count++)]) {
if (!matcher(token)) {
return token;
}
}
return undefined;
} | javascript | {
"resource": ""
} |
q23332 | createHashMap | train | function createHashMap(wordMap, boundary, caseInsensitive) {
//creates a hash table where the hash is the first character of the word
var newMap = { },
i,
word,
firstChar;
for (i = 0; i < wordMap.length; i++) {
word = caseInsensitive ? wordMap[i].toUpperCase() : wordMap[i];
firstChar = word.char... | javascript | {
"resource": ""
} |
q23333 | switchToEmbeddedLanguageIfNecessary | train | function switchToEmbeddedLanguageIfNecessary(context) {
var i,
embeddedLanguage;
for (i = 0; i < context.language.embeddedLanguages.length; i++) {
if (!languages[context.language.embeddedLanguages[i].language]) {
//unregistered language
continue;
}
embeddedLanguage = clone(conte... | javascript | {
"resource": ""
} |
q23334 | switchBackFromEmbeddedLanguageIfNecessary | train | function switchBackFromEmbeddedLanguageIfNecessary(context) {
var current = last(context.embeddedLanguageStack),
lang;
if (current && current.switchBack(context)) {
context.language = languages[current.parentLanguage];
lang = context.embeddedLanguageStack.pop();
//restore old items
co... | javascript | {
"resource": ""
} |
q23335 | highlightRecursive | train | function highlightRecursive(node) {
var match,
languageId,
currentNodeCount,
j,
nodes,
k,
partialContext,
container,
codeContainer;
if (this.isAlreadyHighlighted(node) || (match = this.matchSunlightNode(node)) === null) {
return;
}
languageId = match[1]... | javascript | {
"resource": ""
} |
q23336 | train | function (attr) {
if (attr.indexOf('{attribution.') === -1) {
return attr;
}
return attr.replace(/\{attribution.(\w*)\}/,
function (match, attributionName) {
return attributionReplacer(providers[attributionName].options.attribution);
}
);
} | javascript | {
"resource": ""
} | |
q23337 | train | function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {
return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);
} | javascript | {
"resource": ""
} | |
q23338 | train | function (p, p1, maxIndex, minIndex) {
var points = this._originalPoints,
p2, p3;
minIndex = minIndex || 0;
// Check all previous line segments (beside the immediately previous) for intersections
for (var j = maxIndex; j > minIndex; j--) {
p2 = points[j - 1];
p3 = points[j];
if (L.LineUtil.segmen... | javascript | {
"resource": ""
} | |
q23339 | train | function (handler) {
return [
{
enabled: handler.deleteLastVertex,
title: L.drawLocal.draw.toolbar.undo.title,
text: L.drawLocal.draw.toolbar.undo.text,
callback: handler.deleteLastVertex,
context: handler
},
{
title: L.drawLocal.draw.toolbar.actions.title,
text: L.drawLocal.draw.... | javascript | {
"resource": ""
} | |
q23340 | train | function (providerName) {
if (providerName === 'ignored') {
return true;
}
// reduce the number of layers previewed for some providers
if (providerName.startsWith('HERE') || providerName.startsWith('OpenWeatherMap') || providerName.startsWith('MapBox')) {
var whitelist = [
// API threshold almost reac... | javascript | {
"resource": ""
} | |
q23341 | compile | train | function compile(content, data) {
return content.replace(/\${(\w+)}/gi, function (match, name) {
return data[name] ? data[name] : '';
});
} | javascript | {
"resource": ""
} |
q23342 | getFilePath | train | function getFilePath(sourcePath, filename, subDir) {
if (subDir === void 0) { subDir = ''; }
var filePath = filename
.replace(path.resolve(sourcePath), '')
.replace(path.basename(filename), '');
if (subDir) {
filePath = filePath.replace(subDir + path.sep, '');
}
if (/^[\/\\]/... | javascript | {
"resource": ""
} |
q23343 | generateIndex | train | function generateIndex(opts, files, subDir) {
if (subDir === void 0) { subDir = ''; }
var shouldExport = opts.export;
var isES6 = opts.es6;
var content = '';
var dirMap = {};
switch (opts.ext) {
case 'js':
content += '/* eslint-disable */\n';
break;
case '... | javascript | {
"resource": ""
} |
q23344 | getSvgoConfig | train | function getSvgoConfig(svgo) {
if (!svgo) {
return require('../../default/svgo');
}
else if (typeof svgo === 'string') {
return require(path.join(process.cwd(), svgo));
}
else {
return svgo;
}
} | javascript | {
"resource": ""
} |
q23345 | getViewBox | train | function getViewBox(svgoResult) {
var viewBoxMatch = svgoResult.data.match(/viewBox="([-\d\.]+\s[-\d\.]+\s[-\d\.]+\s[-\d\.]+)"/);
var viewBox = '0 0 200 200';
if (viewBoxMatch && viewBoxMatch.length > 1) {
viewBox = viewBoxMatch[1];
}
else if (svgoResult.info.height && svgoResult.info.width)... | javascript | {
"resource": ""
} |
q23346 | addPid | train | function addPid(content) {
var shapeReg = /<(path|rect|circle|polygon|line|polyline|ellipse)\s/gi;
var id = 0;
content = content.replace(shapeReg, function (match) {
return match + ("pid=\"" + id++ + "\" ");
});
return content;
} | javascript | {
"resource": ""
} |
q23347 | getHtmlInfo | train | function getHtmlInfo(element) {
if (!element)
return null;
var tagName = element.tagName;
if (!tagName)
return null;
tagName = tagName.toUpperCase();
var infos = axs.constants.TAG_TO_IMPLICIT_SEMANTIC_INFO[tagName];
if (!infos || !infos.length)
... | javascript | {
"resource": ""
} |
q23348 | getRequired | train | function getRequired(element) {
var elementRole = axs.utils.getRoles(element);
if (!elementRole || !elementRole.applied)
return [];
var appliedRole = elementRole.applied;
if (!appliedRole.valid)
return [];
return appliedRole.details['mustcontain'] || [];
... | javascript | {
"resource": ""
} |
q23349 | tableDoesNotHaveHeaderRow | train | function tableDoesNotHaveHeaderRow(rows) {
var headerRow = rows[0];
var headerCells = headerRow.children;
for (var i = 0; i < headerCells.length; i++) {
if (headerCells[i].tagName != 'TH') {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q23350 | tableDoesNotHaveHeaderColumn | train | function tableDoesNotHaveHeaderColumn(rows) {
for (var i = 0; i < rows.length; i++) {
if (rows[i].children[0].tagName != 'TH') {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q23351 | tableDoesNotHaveGridLayout | train | function tableDoesNotHaveGridLayout(rows) {
var headerCells = rows[0].children;
for (var i = 1; i < headerCells.length; i++) {
if (headerCells[i].tagName != 'TH') {
return true;
}
}
for (var i = 1; i < rows.length; i++) {
if (rows[i].... | javascript | {
"resource": ""
} |
q23352 | isLayoutTable | train | function isLayoutTable(element) {
if (element.childElementCount == 0) {
return true;
}
if (element.hasAttribute('role') && element.getAttribute('role') != 'presentation') {
return false;
}
if (element.getAttribute('role') == 'presentation') {
... | javascript | {
"resource": ""
} |
q23353 | hasDirectTextDescendantXpath | train | function hasDirectTextDescendantXpath() {
var selectorResults = ownerDocument.evaluate(axs.properties.TEXT_CONTENT_XPATH,
element,
null,
XPathResult.ANY_... | javascript | {
"resource": ""
} |
q23354 | train | function(auditRuleName, selectors) {
if (!(auditRuleName in this.rules_))
this.rules_[auditRuleName] = {};
if (!('ignore' in this.rules_[auditRuleName]))
this.rules_[auditRuleName].ignore = [];
Array.prototype.push.call(this.rules_[auditRuleName].ignore, selectors);
} | javascript | {
"resource": ""
} | |
q23355 | train | function(auditRuleName, severity) {
if (!(auditRuleName in this.rules_))
this.rules_[auditRuleName] = {};
this.rules_[auditRuleName].severity = severity;
} | javascript | {
"resource": ""
} | |
q23356 | train | function(auditRuleName, config) {
if (!(auditRuleName in this.rules_))
this.rules_[auditRuleName] = {};
this.rules_[auditRuleName].config = config;
} | javascript | {
"resource": ""
} | |
q23357 | train | function(auditRuleName) {
if (!(auditRuleName in this.rules_))
return null;
if (!('config' in this.rules_[auditRuleName]))
return null;
return this.rules_[auditRuleName].config;
} | javascript | {
"resource": ""
} | |
q23358 | labeledByATab | train | function labeledByATab(element) {
if (element.hasAttribute('aria-labelledby')) {
var labelingElements = document.querySelectorAll('#' + element.getAttribute('aria-labelledby'));
return labelingElements.length === 1 && labelingElements[0].getAttribute('role') === 'tab';
}
... | javascript | {
"resource": ""
} |
q23359 | controlledByATab | train | function controlledByATab(element) {
var controlledBy = document.querySelectorAll('[role="tab"][aria-controls="' + element.id + '"]')
return element.id && (controlledBy.length === 1);
} | javascript | {
"resource": ""
} |
q23360 | arrowFnToNormalFn | train | function arrowFnToNormalFn(string) {
var match = string.match(/^([\s\S]+?)=\>(\s*{)?([\s\S]*?)(}\s*)?$/);
if (!match) {
return string;
}
var args = match[1];
var body = match[3];
var needsReturn = !(match[2] && match[4]);
args = args.replace(/^(\s*\(\s*)([\s\S]*?)(\s*\)\s*)$/, '$2');
if (needsR... | javascript | {
"resource": ""
} |
q23361 | extend | train | function extend(filename, async) {
if (async._waterfall !== undefined) {
return;
}
async._waterfall = async.waterfall;
async.waterfall = function (_tasks, callback) {
let tasks = _tasks.map(function (t) {
let fn = function () {
console.log("async " + filename + ": " + t.name);
t.ap... | javascript | {
"resource": ""
} |
q23362 | worker | train | function worker(message) {
console.log(`Processing "${message.message.data}"...`);
setTimeout(() => {
console.log(`Finished procesing "${message.message.data}".`);
isProcessed = true;
}, 30000);
} | javascript | {
"resource": ""
} |
q23363 | setGlobalEval | train | function setGlobalEval( elems, refElements ) {
var elem,
i = 0;
for ( ; (elem = elems[i]) != null; i++ ) {
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
}
} | javascript | {
"resource": ""
} |
q23364 | signalKill | train | function signalKill(childProcess, callback) {
childProcess.emit('signalKill');
if (IS_WINDOWS) {
const taskkill = spawn('taskkill', ['/F', '/T', '/PID', childProcess.pid]);
taskkill.on('exit', (exitStatus) => {
if (exitStatus) {
return callback(
new Error(`Unable to forcefully termin... | javascript | {
"resource": ""
} |
q23365 | signalTerm | train | function signalTerm(childProcess, callback) {
childProcess.emit('signalTerm');
if (IS_WINDOWS) {
// On Windows, there is no such way as SIGTERM or SIGINT. The closest
// thing is to interrupt the process with Ctrl+C. Under the hood, that
// generates '\u0003' character on stdin of the process and if
... | javascript | {
"resource": ""
} |
q23366 | check | train | function check() {
if (terminated) {
// Successfully terminated
clearTimeout(t);
return callback();
}
if ((Date.now() - start) < timeout) {
// Still not terminated, try again
signalTerm(childProcess, (err) => {
if (err) { return callback(err); }
t = setTimeout(c... | javascript | {
"resource": ""
} |
q23367 | applyLoggingOptions | train | function applyLoggingOptions(config) {
if (config.color === false) {
logger.transports.console.colorize = false;
reporterOutputLogger.transports.console.colorize = false;
}
// TODO https://github.com/apiaryio/dredd/issues/1346
if (config.loglevel) {
const loglevel = config.loglevel.toLowerCase();
... | javascript | {
"resource": ""
} |
q23368 | performRequest | train | function performRequest(uri, transactionReq, options, callback) {
if (typeof options === 'function') { [options, callback] = [{}, options]; }
const logger = options.logger || defaultLogger;
const request = options.request || defaultRequest;
const httpOptions = Object.assign({}, options.http || {});
httpOptio... | javascript | {
"resource": ""
} |
q23369 | getBodyAsBuffer | train | function getBodyAsBuffer(body, encoding) {
return body instanceof Buffer
? body
: Buffer.from(`${body || ''}`, normalizeBodyEncoding(encoding));
} | javascript | {
"resource": ""
} |
q23370 | normalizeContentLengthHeader | train | function normalizeContentLengthHeader(headers, body, options = {}) {
const logger = options.logger || defaultLogger;
const modifiedHeaders = Object.assign({}, headers);
const calculatedValue = Buffer.byteLength(body);
const name = caseless(modifiedHeaders).has('Content-Length');
if (name) {
const value =... | javascript | {
"resource": ""
} |
q23371 | createTransactionResponse | train | function createTransactionResponse(response, body) {
const transactionRes = {
statusCode: response.statusCode,
headers: Object.assign({}, response.headers),
};
if (Buffer.byteLength(body || '')) {
transactionRes.bodyEncoding = detectBodyEncoding(body);
transactionRes.body = body.toString(transacti... | javascript | {
"resource": ""
} |
q23372 | train | function(evt) {
var li = evt.target;
if (li !== this) {
while (li && !/li/i.test(li.nodeName)) {
li = li.parentNode;
}
if (li && evt.button === 0) { // Only select on left click
evt.preventDefault();
me.select(li, evt.target, evt);
}
}
} | javascript | {
"resource": ""
} | |
q23373 | train | function (i) {
var lis = this.ul.children;
if (this.selected) {
lis[this.index].setAttribute("aria-selected", "false");
}
this.index = i;
if (i > -1 && lis.length > 0) {
lis[i].setAttribute("aria-selected", "true");
this.status.textContent = lis[i].textContent + ", list item " + (i + 1) + " of " ... | javascript | {
"resource": ""
} | |
q23374 | determineTitle | train | function determineTitle(title, notitle, lines, info) {
var defaultTitle = '**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*';
if (notitle) return '';
if (title) return title;
return info.hasStart ? lines[info.startIdx + 2] : defaultTitle;
} | javascript | {
"resource": ""
} |
q23375 | train | function (element, closeAll) {
var expanded = typeof closeAll !== 'undefined' ? closeAll : childRulesExpanded(element);
if (expanded) {
element.textContent = 'close all';
element.classList.remove('closed');
element.classList.add('expanded');
} else {
... | javascript | {
"resource": ""
} | |
q23376 | resolveOrigin | train | function resolveOrigin(url) {
var a = document.createElement('a');
a.href = url;
var protocol = a.protocol.length > 4 ? a.protocol : window.location.protocol;
var host = a.host.length ? a.port === '80' || a.port === '443' ? a.hostname : a.host : window.location.host;
return a.origin || protocol + "//" + host;... | javascript | {
"resource": ""
} |
q23377 | resolveValue | train | function resolveValue(model, property) {
var unwrappedContext = typeof model[property] === 'function' ? model[property]() : model[property];
return Postmate.Promise.resolve(unwrappedContext);
} | javascript | {
"resource": ""
} |
q23378 | Postmate | train | function Postmate(_ref2) {
var _ref2$container = _ref2.container,
container = _ref2$container === void 0 ? typeof container !== 'undefined' ? container : document.body : _ref2$container,
model = _ref2.model,
url = _ref2.url,
_ref2$classListArray = _ref2.classListArray,
classL... | javascript | {
"resource": ""
} |
q23379 | Model | train | function Model(model) {
this.child = window;
this.model = model;
this.parent = this.child.parent;
return this.sendHandshakeReply();
} | javascript | {
"resource": ""
} |
q23380 | train | function(profileDataGridNode)
{
if (!profileDataGridNode)
return;
this.save();
var currentNode = profileDataGridNode;
var focusNode = profileDataGridNode;
while (currentNode.parent && (currentNode instanceof WebInspector.ProfileDataGridNode)) {
curr... | javascript | {
"resource": ""
} | |
q23381 | train | function()
{
if (!this._totalSize) {
this._totalSize = this._isVertical ? this.contentElement.offsetWidth : this.contentElement.offsetHeight;
this._totalSizeOtherDimension = this._isVertical ? this.contentElement.offsetHeight : this.contentElement.offsetWidth;
}
retur... | javascript | {
"resource": ""
} | |
q23382 | train | function(dipWidth, dipHeight, scale)
{
this._scale = scale;
this._dipWidth = dipWidth ? Math.max(dipWidth, 1) : 0;
this._dipHeight = dipHeight ? Math.max(dipHeight, 1) : 0;
this._updateUI();
} | javascript | {
"resource": ""
} | |
q23383 | typeWeight | train | function typeWeight(treeElement)
{
var type = treeElement.type();
if (type === WebInspector.NavigatorTreeOutline.Types.Domain) {
if (treeElement.titleText === WebInspector.targetManager.inspectedPageDomain())
return 1;
return 2;
}
if (type === ... | javascript | {
"resource": ""
} |
q23384 | buildInspectorUrl | train | function buildInspectorUrl(inspectorHost, inspectorPort, debugPort, isHttps) {
var host = inspectorHost == '0.0.0.0' ? '127.0.0.1' : inspectorHost;
var port = inspectorPort;
var protocol = isHttps ? 'https' : 'http';
var isUnixSocket = !/^\d+$/.test(port);
if (isUnixSocket) {
host = path.resolve(__dirnam... | javascript | {
"resource": ""
} |
q23385 | buildWebSocketUrl | train | function buildWebSocketUrl(inspectorHost, inspectorPort, debugPort, isSecure) {
var parts = {
protocol: isSecure ? 'wss:' : 'ws:',
hostname: inspectorHost == '0.0.0.0' ? '127.0.0.1' : inspectorHost,
port: inspectorPort,
pathname: '/',
search: '?port=' + debugPort,
slashes: true
};
return ... | javascript | {
"resource": ""
} |
q23386 | train | function()
{
if (!this._searchResults || !this._searchResults.length)
return;
var index = this._selectedSearchResult ? this._searchResults.indexOf(this._selectedSearchResult) : -1;
this._jumpToSearchResult(index + 1);
} | javascript | {
"resource": ""
} | |
q23387 | getSelectorFromElement | train | function getSelectorFromElement($element) {
var selector = $element.data('target'),
$selector = void 0;
if (!selector) {
selector = $element.attr('href') || '';
selector = /^#[a-z]/i.test(selector) ? selector : null;
}
$selector = $(selector);
... | javascript | {
"resource": ""
} |
q23388 | pass1 | train | function pass1(elem) {
xs[elem] = blockG.inEdges(elem).reduce(function(acc, e) {
return Math.max(acc, xs[e.v] + blockG.edge(e));
}, 0);
} | javascript | {
"resource": ""
} |
q23389 | pass2 | train | function pass2(elem) {
var min = blockG.outEdges(elem).reduce(function(acc, e) {
return Math.min(acc, xs[e.w] - blockG.edge(e));
}, Number.POSITIVE_INFINITY);
var node = g.node(elem);
if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) {
xs[elem] = Math.max(xs[elem], min... | javascript | {
"resource": ""
} |
q23390 | train | function () {
this.worker = new Worker('./js/optimizer-worker.js')
this.worker.onmessage = function (event) {
switch (event.data.command) {
case 'optimized':
Optimizer.oncomplete(event.data.id, event.data.output, event.data.saved)
}
}
this.worker.onerror = function (event) ... | javascript | {
"resource": ""
} | |
q23391 | checkFrames | train | function checkFrames(frames){
var width = frames[0].width,
height = frames[0].height,
duration = frames[0].duration;
for(var i = 1; i < frames.length; i++){
if(frames[i].width != width) throw "Frame " + (i + 1) + " has a different width";
if(frames[i].height != height) throw "Frame " + (i + 1) + "... | javascript | {
"resource": ""
} |
q23392 | parseWebP | train | function parseWebP(riff){
var VP8 = riff.RIFF[0].WEBP[0];
var frame_start = VP8.indexOf('\x9d\x01\x2a'); //A VP8 keyframe starts with the 0x9d012a header
for(var i = 0, c = []; i < 4; i++) c[i] = VP8.charCodeAt(frame_start + 3 + i);
var width, horizontal_scale, height, vertical_scale, tmp;
//the co... | javascript | {
"resource": ""
} |
q23393 | decodeBase64WebPDataURL | train | function decodeBase64WebPDataURL(url) {
if (typeof url !== "string" || !url.match(/^data:image\/webp;base64,/i)) {
return false;
}
return window.atob(url.substring("data:image\/webp;base64,".length));
} | javascript | {
"resource": ""
} |
q23394 | renderAsWebP | train | function renderAsWebP(canvas, quality) {
var
frame = canvas.toDataURL('image/webp', {quality: quality});
return decodeBase64WebPDataURL(frame);
} | javascript | {
"resource": ""
} |
q23395 | writeEBML | train | function writeEBML(buffer, bufferFileOffset, ebml) {
// Is the ebml an array of sibling elements?
if (Array.isArray(ebml)) {
for (var i = 0; i < ebml.length; i++) {
writeEBML(buffer, bufferFileOffset, ebml[i]);
}
// Is this some sor... | javascript | {
"resource": ""
} |
q23396 | createSeekHead | train | function createSeekHead() {
var
seekPositionEBMLTemplate = {
"id": 0x53AC, // SeekPosition
"size": 5, // Allows for 32GB video files
"data": 0 // We'll overwrite this when the file is complete
... | javascript | {
"resource": ""
} |
q23397 | writeHeader | train | function writeHeader() {
seekHead = createSeekHead();
var
ebmlHeader = {
"id": 0x1a45dfa3, // EBML
"data": [
{
"id": 0x4286, // EBMLVersion
... | javascript | {
"resource": ""
} |
q23398 | flushClusterFrameBuffer | train | function flushClusterFrameBuffer() {
if (clusterFrameBuffer.length == 0) {
return;
}
// First work out how large of a buffer we need to hold the cluster data
var
rawImageSize = 0;
... | javascript | {
"resource": ""
} |
q23399 | rewriteSeekHead | train | function rewriteSeekHead() {
var
seekHeadBuffer = new ArrayBufferDataStream(seekHead.size),
oldPos = blobBuffer.pos;
// Write the rewritten SeekHead element's data payload to the stream (don't need to update the id or size)
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.