_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q54000 | train | function() {
var obj;
// not that the modal viewer is no longer active
DataSaver.updateValue('modalActive', 'false');
modalViewer.active = false;
//Add active class to modal
$('#sg-modal-container').removeClass('active');
// remove the active class from all of the checkbo... | javascript | {
"resource": ""
} | |
q54001 | train | function(patternData, iframePassback, switchText) {
// if this is a styleguide view close the modal
if (iframePassback) {
modalViewer.hide();
}
// gather the data that will fill the modal window
panelsViewer.gatherPanels(patternData, iframePassback, switchText);
} | javascript | {
"resource": ""
} | |
q54002 | train | function(pos) {
// remove active class
els = document.querySelectorAll('#sg-annotations > .sg-annotations-list > li');
for (i = 0; i < els.length; ++i) {
els[i].classList.remove('active');
}
// add active class to called element and scroll to it
for (i = 0; i < els.length; ++i) {... | javascript | {
"resource": ""
} | |
q54003 | train | function(switchText) {
// note that the modal is active and set switchText
if ((switchText === undefined) || (switchText)) {
switchText = true;
DataSaver.updateValue('modalActive', 'true');
modalViewer.active = true;
}
// send a message to the pattern
var obj = JSON.strin... | javascript | {
"resource": ""
} | |
q54004 | train | function(templateRendered, patternPartial) {
var els = templateRendered.querySelectorAll('#sg-'+patternPartial+'-tabs li');
for (var i = 0; i < els.length; ++i) {
els[i].onclick = function(e) {
e.preventDefault();
var patternPartial = this.getAttribute('data-patternpartial');
... | javascript | {
"resource": ""
} | |
q54005 | train | function(panels, patternData, iframePassback, switchText) {
// count how many panels have rendered content
var panelContentCount = 0;
for (var i = 0; i < panels.length; ++i) {
if (panels[i].content !== undefined) {
panelContentCount++;
}
}
// see if the count of panels with con... | javascript | {
"resource": ""
} | |
q54006 | sizeiframe | train | function sizeiframe(size,animate) {
var theSize;
if(size>maxViewportWidth) { //If the entered size is larger than the max allowed viewport size, cap value at max vp size
theSize = maxViewportWidth;
} else if(size<minViewportWidth) { //If the entered size is less than the minimum allowed viewport size... | javascript | {
"resource": ""
} |
q54007 | reservoirStream | train | function reservoirStream(collection, size, opts) {
opts = _defaults(opts || {}, {
chunkSize: RESERVOIR_CHUNK_SIZE,
promoteValues: true
});
var reservoir = new Reservoir(size);
var stream = es.through(
function write(data) {
// fill reservoir with ids
reservoir.pushSome(data);
},
... | javascript | {
"resource": ""
} |
q54008 | transform | train | function transform(chunk, encoding, cb) {
// only transform for raw bytes
if (raw) {
var response = BSON.deserialize(chunk);
response.cursor.firstBatch.forEach(function(doc) {
this.push(BSON.serialize(doc));
}.bind(this));
return cb();
}
// otherwise go back to the main s... | javascript | {
"resource": ""
} |
q54009 | gulpWPpot | train | function gulpWPpot (options) {
if (options !== undefined && !isObject(options)) {
throw new PluginError('gulp-wp-pot', 'Require a argument of type object.');
}
const files = [];
const stream = through.obj(function (file, enc, cb) {
if (file.isStream()) {
this.emit('error', new PluginError('gulp-... | javascript | {
"resource": ""
} |
q54010 | replaceEndian | train | function replaceEndian (options, matchedPart, first, separator, second, third) {
var parts
var hasSingleDigit = Math.min(first.length, second.length, third.length) === 1
var hasQuadDigit = Math.max(first.length, second.length, third.length) === 4
var preferredOrder = typeof options.preferredOrder === 'string' ?... | javascript | {
"resource": ""
} |
q54011 | CircleButton | train | function CircleButton(props) {
let icon;
if (props.icon) {
const Icon = props.icon;
icon = (
<Icon
className={classnames(styles.icon, props.iconClassName)}
width={props.iconWidth}
height={props.iconHeight}
x={props.iconX}
y={props.iconY}
/>
);
}
co... | javascript | {
"resource": ""
} |
q54012 | RecentActivityPanel | train | function RecentActivityPanel(props) {
const { title, expanded, onPanelToggle } = props;
const toggleButton = {
label: <ToggleIcon expanded={expanded} />,
onClick: onPanelToggle,
placement: 'right'
};
if (!props.currentContact) {
return null;
}
const containerClass = classnames(styles.contain... | javascript | {
"resource": ""
} |
q54013 | hasProperty | train | function hasProperty(obj, propName) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && propName in obj;
} | javascript | {
"resource": ""
} |
q54014 | train | function (options) {
// Initialize the Faye client if it hasn't been initialized
if (_.isUndefined(this._fayeClient)) {
var pushUrl = new URI(this.apiURL).subdomain('push').path('faye').toString();
this._fayeClient = new Faye.Client(pushUrl);
// We don't support websock... | javascript | {
"resource": ""
} | |
q54015 | oauth2TokenParser | train | function oauth2TokenParser(options) {
function parseOauth2Token(req, res, next) {
req.oauth2 = { accessToken: null};
var tokenFromHeader = parseHeader(req);
if (tokenFromHeader) {
req.oauth2.accessToken = tokenFromHeader;
}
var tokenFromBody = null;
... | javascript | {
"resource": ""
} |
q54016 | acceptParser | train | function acceptParser(accepts) {
var acceptable = accepts;
if (!Array.isArray(acceptable)) {
acceptable = [acceptable];
}
assert.arrayOfString(acceptable, 'acceptable');
acceptable = acceptable.filter(function (a) {
return (a);
}).map(function (a) {
return ((a.index... | javascript | {
"resource": ""
} |
q54017 | authorizationParser | train | function authorizationParser(options) {
function parseAuthorization(req, res, next) {
req.authorization = {};
req.username = 'anonymous';
if (!req.headers.authorization) {
return (next());
}
var pieces = req.headers.authorization.split(' ', 2);
if (!pi... | javascript | {
"resource": ""
} |
q54018 | createReqIdHeaders | train | function createReqIdHeaders(opts) {
assert.object(opts, 'opts');
assert.arrayOfString(opts.headers, 'opts.headers');
var headers = opts.headers.concat(DEFAULT_HEADERS);
return function reqIdHeaders(req, res, next) {
for (var i = 0; i < headers.length; i++) {
var val = req.header(... | javascript | {
"resource": ""
} |
q54019 | queryParser | train | function queryParser(options) {
var opts = options || {};
assert.object(opts, 'opts');
function parseQueryString(req, res, next) {
if (!req.getQuery()) {
req.query = {};
return next();
}
req.query = qs.parse(req.getQuery(), opts);
if (opts.mapPara... | javascript | {
"resource": ""
} |
q54020 | rangeParser | train | function rangeParser (size, str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string')
}
var index = str.indexOf('=')
if (index === -1) {
return -2
}
// split the range string
var arr = str.slice(index + 1).split(',')
var ranges = []
// add ranges t... | javascript | {
"resource": ""
} |
q54021 | combineRanges | train | function combineRanges (ranges) {
var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart)
for (var j = 0, i = 1; i < ordered.length; i++) {
var range = ordered[i]
var current = ordered[j]
if (range.start > current.end + 1) {
// next range
ordered[++j] = range
} else if (range.end... | javascript | {
"resource": ""
} |
q54022 | mapWithIndex | train | function mapWithIndex (range, index) {
return {
start: range.start,
end: range.end,
index: index
}
} | javascript | {
"resource": ""
} |
q54023 | sourceList | train | function sourceList(manifest) {
const sourceTypes = [
["desktop", "js"],
["desktop", "css"],
["mobile", "js"],
["config", "js"],
["config", "css"]
];
const list = sourceTypes
.map(t => manifest[t[0]] && manifest[t[0]][t[1]])
.filter(i => !!i)
.reduce((a, b) => a.concat(b), [])
... | javascript | {
"resource": ""
} |
q54024 | createContentsZip | train | function createContentsZip(pluginDir, manifest) {
return new Promise((res, rej) => {
const output = new streamBuffers.WritableStreamBuffer();
const zipFile = new ZipFile();
let size = null;
output.on("finish", () => {
debug(`plugin.zip: ${size} bytes`);
res(output.getContents());
});
... | javascript | {
"resource": ""
} |
q54025 | fileMapToBuffer | train | function fileMapToBuffer(fileMap) {
return Promise.all(
Array.from(fileMap.entries()).map(([path, file]) =>
readArrayBuffer(file).then(buffer => ({ buffer, path }))
)
)
.then(results => {
const zipFile = new yazl.ZipFile();
results.forEach(result => {
zipFile.addBuffer(Buffer.f... | javascript | {
"resource": ""
} |
q54026 | zip | train | function zip(contentsZip, publicKey, signature) {
debug(`zip(): start`);
return new Promise((res, rej) => {
const output = new streamBuffers.WritableStreamBuffer();
const zipFile = new ZipFile();
output.on("finish", () => {
debug(`zip(): output finish event`);
res(output.getContents());
... | javascript | {
"resource": ""
} |
q54027 | rezip | train | function rezip(contentsZip) {
return preprocessToRezip(contentsZip).then(
({ zipFile, entries, manifestJson, manifestPath }) => {
validateManifest(entries, manifestJson, manifestPath);
return rezipContents(zipFile, entries, manifestJson, manifestPath);
}
);
} | javascript | {
"resource": ""
} |
q54028 | validateContentsZip | train | function validateContentsZip(contentsZip) {
return preprocessToRezip(contentsZip).then(
({ entries, manifestJson, manifestPath }) =>
validateManifest(entries, manifestJson, manifestPath)
);
} | javascript | {
"resource": ""
} |
q54029 | preprocessToRezip | train | function preprocessToRezip(contentsZip) {
return zipEntriesFromBuffer(contentsZip).then(result => {
const manifestList = Array.from(result.entries.keys()).filter(
file => path.basename(file) === "manifest.json"
);
if (manifestList.length === 0) {
throw new Error("The zip file has no manifest.j... | javascript | {
"resource": ""
} |
q54030 | validateRelativePath | train | function validateRelativePath(pluginDir) {
return str => {
try {
const stat = fs.statSync(path.join(pluginDir, str));
return stat.isFile();
} catch (e) {
return false;
}
};
} | javascript | {
"resource": ""
} |
q54031 | validateMaxFileSize | train | function validateMaxFileSize(pluginDir) {
return (maxBytes, filePath) => {
try {
const stat = fs.statSync(path.join(pluginDir, filePath));
return stat.size <= maxBytes;
} catch (e) {
return false;
}
};
} | javascript | {
"resource": ""
} |
q54032 | hex2a | train | function hex2a(hex) {
return Array.from(hex)
.map(s => {
if (s >= "0" && s <= "9") {
return String.fromCharCode(s.charCodeAt(0) + N_TO_A);
} else if (s >= "a" && s <= "f") {
return String.fromCharCode(s.charCodeAt(0) + A_TO_K);
}
throw new Error(`invalid char: ${s}`);
}... | javascript | {
"resource": ""
} |
q54033 | index | train | function index(options) {
return {
kronos: {
position: 'relative',
display: 'flex',
color: 'hsl(0, 0%, 50%)',
'& *': {
fontFamily: options.font,
boxSizing: 'border-box',
userSelect: 'none',
},
},
input: {
border: '1px solid transparent',
bo... | javascript | {
"resource": ""
} |
q54034 | train | function(name, source){
var oldSource = this.sources[name];
if (name in this.fields.sources == false)
{
/** @cut */ basis.dev.warn('basis.data.object.Merge#setSource: can\'t set source with name `' + name + '` as not specified by fields configuration');
return;
}
// ignor... | javascript | {
"resource": ""
} | |
q54035 | compatibleStyleSheetInsertRule | train | function compatibleStyleSheetInsertRule(rule, index){
// fetch selector and style from rule description
var m = rule.match(/^([^{]+)\{(.*)\}\s*$/);
if (m)
{
var selectors = m[1].trim().split(/\s*,\s*/);
for (var i = 0; i < selectors.length; i++)
this.addRule(selectors[i], m[2] || nul... | javascript | {
"resource": ""
} |
q54036 | getStyleSheet | train | function getStyleSheet(id, createIfNotExists){
if (!id)
id = 'DefaultGenericStyleSheet';
if (!cssStyleSheets[id])
if (createIfNotExists)
cssStyleSheets[id] = new StyleSheet(addStyleSheet());
return cssStyleSheets[id];
} | javascript | {
"resource": ""
} |
q54037 | setStyleProperty | train | function setStyleProperty(node, property, value){
var mapping = styleMapping[property];
var key = mapping ? mapping.key : camelize(property.replace(/^-ms-/, 'ms-'));
if (!key)
return;
if (mapping && mapping.getter)
value = mapping.getter(value);
var imp = !!IMPORTANT_REGEXP.test(value... | javascript | {
"resource": ""
} |
q54038 | setStyle | train | function setStyle(node, style){
for (var key in style)
setStyleProperty(node, key, style[key]);
return node;
} | javascript | {
"resource": ""
} |
q54039 | train | function(){
var headerElement = this.header.element;
var footerElement = this.footer ? this.footer.element : null;
//
// Sync header html
//
var headerOuterHTML = domUtils.outerHTML(headerElement);
if (this.shadowHeaderHTML_ != headerOuterHTML)
{
this.shadowHeade... | javascript | {
"resource": ""
} | |
q54040 | getLocation | train | function getLocation(template, loc){
if (loc)
return (template.sourceUrl || '') + ':' + loc.start.line + ':' + (loc.start.column + 1);
} | javascript | {
"resource": ""
} |
q54041 | handleInsert | train | function handleInsert(node, newNode, refChild){
return newNode != null
? node.insertBefore(isNode(newNode) ? newNode : createText(newNode), refChild || null)
: null;
} | javascript | {
"resource": ""
} |
q54042 | train | function(filter, result){
var node;
if (!result)
result = [];
this.reset();
while (node = this.next(filter))
result.push(node);
return result;
} | javascript | {
"resource": ""
} | |
q54043 | train | function(filter){
filter = filter || this.filter;
var cursor = this.cursor_ || this.root_;
do
{
var node = cursor[this.a]; // next child
while (!node)
{
if (cursor === this.root_)
return this.cursor_ = null;
node = cursor[this.b]; // nex... | javascript | {
"resource": ""
} | |
q54044 | train | function(filter){
filter = filter || this.filter;
var cursor = this.cursor_;
var prevSibling = this.c; // previous sibling
var prevChild = this.d; // previous child
do
{
var node = cursor ? cursor[prevSibling] : this.root_[prevChild];
if (node)
{
... | javascript | {
"resource": ""
} | |
q54045 | tag | train | function tag(node, tagName){
var element = get(node) || document;
if (tagName == '*' && element.all)
return arrayFrom(element.all);
else
return arrayFrom(element.getElementsByTagName(tagName || '*'));
} | javascript | {
"resource": ""
} |
q54046 | axis | train | function axis(root, axis, filter){
var result = [];
var walker;
var cursor;
filter = typeof filter == 'string' ? getter(filter) : filter || basis.fn.$true;
if (axis & (AXIS_SELF | AXIS_ANCESTOR_OR_SELF | AXIS_DESCENDANT_OR_SELF))
if (filter(root))
result.push(root);
switch (axis... | javascript | {
"resource": ""
} |
q54047 | findAncestor | train | function findAncestor(node, matchFunction, bound){
while (node && node !== bound)
{
if (matchFunction(node))
break;
node = node.parentNode;
}
return node || null;
} | javascript | {
"resource": ""
} |
q54048 | createFragment | train | function createFragment(){
var result = document.createDocumentFragment();
var len = arguments.length;
var array = createFragment.array = [];
for (var i = 0; i < len; i++)
array.push(handleInsert(result, arguments[i]));
return result;
} | javascript | {
"resource": ""
} |
q54049 | createElement | train | function createElement(config){
var isConfig = config != undefined && typeof config != 'string';
var description = (isConfig ? config.description : config) || '';
var elementName = 'div'; // modern browsers become case sensetive for tag names for xhtml
var element;
// fetch tag name
var m = de... | javascript | {
"resource": ""
} |
q54050 | insert | train | function insert(node, source, insertPoint, refChild){
node = get(node) || node; // TODO: remove
switch (insertPoint) {
case undefined: // insertPoint omitted
case INSERT_END:
refChild = null;
break;
case INSERT_BEGIN:
refChild = node[FIRST_CHILD];
break;
case... | javascript | {
"resource": ""
} |
q54051 | replace | train | function replace(oldNode, newNode){
return oldNode[PARENT_NODE] ? oldNode[PARENT_NODE].replaceChild(newNode, oldNode) : oldNode;
} | javascript | {
"resource": ""
} |
q54052 | swap | train | function swap(nodeA, nodeB){
if (nodeA === nodeB || comparePosition(nodeA, nodeB) & (POSITION_CONTAINED_BY | POSITION_CONTAINS | POSITION_DISCONNECTED))
return false;
replace(nodeA, testElement);
replace(nodeB, nodeA);
replace(testElement, nodeB);
return true;
} | javascript | {
"resource": ""
} |
q54053 | clone | train | function clone(node, noChildren){
var result = node.cloneNode(!noChildren);
if (result.attachEvent) // clear event handlers for IE
axis(result, AXIS_DESCENDANT_OR_SELF).forEach(eventUtils.clearHandlers);
return result;
} | javascript | {
"resource": ""
} |
q54054 | clear | train | function clear(node){
node = get(node);
while (node[LAST_CHILD])
node.removeChild(node[LAST_CHILD]);
return node;
} | javascript | {
"resource": ""
} |
q54055 | focus | train | function focus(node, select){
// try catch block here because browsers throw unexpected exeption in some cases
try {
node = get(node);
node.focus();
if (select && node.select) // && typeof node.select == 'function'
// temporary removed because IE returns 'objec... | javascript | {
"resource": ""
} |
q54056 | toBytes | train | function toBytes(input){
var output = [];
var len = input.length;
for (var i = 0; i < len; i++)
{
var c = input.charCodeAt(i);
output.push(c & 0xFF, c >> 8);
}
return output;
} | javascript | {
"resource": ""
} |
q54057 | fromBytes | train | function fromBytes(input){
var output = '';
var len = input.length;
var i = 0;
var b1;
var b2;
while (i < len)
{
b1 = input[i++] || 0;
b2 = input[i++] || 0;
output += String.fromCharCode((b2 << 8) | b1);
}
return output;
} | javascript | {
"resource": ""
} |
q54058 | toUTF8 | train | function toUTF8(input){
var output = '';
var len = input.length;
for (var i = 0; i < len; i++)
{
var c = input.charCodeAt(i);
if (c < 128)
output += chars[c];
else
if (c < 2048)
output += chars[(c >> 6) | 192] +
chars[(c & 63) | 128];
... | javascript | {
"resource": ""
} |
q54059 | toUTF8Bytes | train | function toUTF8Bytes(input){
// utf16 -> utf8
input = toUTF8(input);
// string -> array of bytes
var len = input.length;
var output = new Array(len);
for (var i = 0; i < len; i++)
output[i] = input.charCodeAt(i);
return output;
} | javascript | {
"resource": ""
} |
q54060 | fromUTF8 | train | function fromUTF8(input){
var output = '';
var len = input.length;
var i = 0;
var c1;
var c2;
var c3;
while (i < len)
{
c1 = input.charCodeAt(i++);
if (c1 < 128)
output += chars[c1];
else
{
c2 = input.charCodeAt(i++);
if (c1 & 32)
... | javascript | {
"resource": ""
} |
q54061 | extendBinding | train | function extendBinding(binding, extension){
/** @cut */ var info = basis.dev.getInfo(extension, 'map');
binding.bindingId = bindingSeed++;
for (var key in extension)
{
var def = null;
var value = extension[key];
// NOTE: check for Node, because first extendBinding invoke before Node... | javascript | {
"resource": ""
} |
q54062 | train | function(actionName, event){
var action = this.action[actionName];
if (action)
action.call(this, event);
/** @cut */ if (!action)
/** @cut */ basis.dev.warn('template call `' + actionName + '` action, but it isn\'t defined in action list');
} | javascript | {
"resource": ""
} | |
q54063 | train | function(select){
var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;
if (focusElement)
{
if (focusTimer)
focusTimer = basis.clearImmediate(focusTimer);
focusTimer = basis.setImmediate(function(){
try {
focusElement.f... | javascript | {
"resource": ""
} | |
q54064 | train | function(){
var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;
if (focusElement)
try {
focusElement.blur();
} catch(e) {}
} | javascript | {
"resource": ""
} | |
q54065 | train | function(super_){
return {
// methods
insertBefore: function(newChild, refChild){
/** @cut */ if (this.noChildNodesElement_)
/** @cut */ {
/** @cut */ delete this.noChildNodesElement_;
/** @cut */ basis.dev.warn('basis.ui: Template has no childNodesElement container, ... | javascript | {
"resource": ""
} | |
q54066 | track | train | function track(event){
try {
// TODO look up for event.data.transformer before setting data
tracker.set(event);
} catch(e) {
/** @cut */ basis.dev.error(namespace + '.track(): Error during tracking event processing', event, e);
}
} | javascript | {
"resource": ""
} |
q54067 | getCssSelectorFromPath | train | function getCssSelectorFromPath(path, selector){
return parsePath(path).map(function(role){
if (!role.role)
return '';
var start = escapeQuotes(role.role);
var end = (role.subrole ? '/' + escapeQuotes(role.subrole) : '') + '"]';
if (role.roleId)
{
if (selector && role.roleId == '*')
... | javascript | {
"resource": ""
} |
q54068 | checkShow | train | function checkShow(){
/**
* Checks visibility of an element on a page in a browser
* @param {HTMLElement} element some DOM node
* @private
* @return {boolean}
*/
function isVisible(element){
if (getComputedStyle(element, 'visibility') != 'visible')
return false;
var box = getBoundingRe... | javascript | {
"resource": ""
} |
q54069 | isVisible | train | function isVisible(element){
if (getComputedStyle(element, 'visibility') != 'visible')
return false;
var box = getBoundingRect(element);
if (!box.width || !box.height)
return false;
return true;
} | javascript | {
"resource": ""
} |
q54070 | getSelectorList | train | function getSelectorList(eventName){
if (hasOwnProperty.call(eventMap, eventName))
return eventMap[eventName];
var selectorList = eventMap[eventName] = [];
var inputTimeout = null;
switch (eventName) {
case SHOW_EVENT:
selectorList.visible = {};
setInterval(checkShow, VISIBLE_CHECK_INTERVA... | javascript | {
"resource": ""
} |
q54071 | getEventList | train | function getEventList(selector){
var selectorStr = stringifyPath(selector);
if (hasOwnProperty.call(selectorMap, selectorStr))
return selectorMap[selectorStr];
var eventList = selectorMap[selectorStr] = [];
eventList.selectorStr = selectorStr;
eventList.selector = selector;
return eventList;
} | javascript | {
"resource": ""
} |
q54072 | stringifyRole | train | function stringifyRole(role){
if (typeof role == 'string')
return role;
if (!role)
return '';
return [
role.role || '',
role.roleId ? '(' + role.roleId + ')' : '',
role.subrole ? '/' + role.subrole : ''
].join('');
} | javascript | {
"resource": ""
} |
q54073 | parsePath | train | function parsePath(value){
if (!Array.isArray(value))
value = String(value || '').trim().split(/\s+/);
return value.map(function(part){
if (typeof part == 'string')
return parseRole(part);
return part || {
role: '',
roleId: '',
subrole: ''
};
});
} | javascript | {
"resource": ""
} |
q54074 | isPathMatchSelector | train | function isPathMatchSelector(path, selector){
function isMatch(path, selector){
path = typeof path == 'string' ? parseRole(path) : path || '';
selector = typeof selector == 'string' ? parseRole(selector) : selector || '';
return selector.role == path.role &&
(selector.roleId == '*' || selector... | javascript | {
"resource": ""
} |
q54075 | getInfo | train | function getInfo(path){
var result = [];
if (typeof path == 'string')
path = parsePath(path);
for (var key in selectorMap)
if (isPathMatchSelector(path, selectorMap[key].selector))
result.push.apply(result, selectorMap[key].map(function(item){
return basis.object.extend({
selecto... | javascript | {
"resource": ""
} |
q54076 | getPathByNode | train | function getPathByNode(node){
var cursor = node;
var path = [];
var role;
while (cursor && cursor !== document)
{
if (role = cursor.getAttribute('role-marker'))
path.unshift(parseRole(role));
cursor = cursor.parentNode;
}
return path;
} | javascript | {
"resource": ""
} |
q54077 | loadMap | train | function loadMap(map){
if (!map)
{
/** @cut */ basis.dev.warn(namespace + '.loadMap(): Wrong value for map');
return;
}
for (var key in map)
{
var eventsMap = map[key];
if (!eventsMap)
{
/** @cut */ basis.dev.warn(namespace + '.loadMap(): Value of map should be an object for path: ... | javascript | {
"resource": ""
} |
q54078 | addDispatcher | train | function addDispatcher(dispatcher, events, transformer){
if (!dispatcher || typeof dispatcher.addHandler != 'function')
{
/** @cut */ basis.dev.warn(namespace + '.addDispatcher(): First argument should have `addHandler` method');
return;
}
if (typeof events == 'string')
events = events.split(/\s+/)... | javascript | {
"resource": ""
} |
q54079 | fromBytes | train | function fromBytes(input){
var len = input.length;
var output = '';
for (var i = 0; i < len; i++)
output += chars[input[i]];
return output;
} | javascript | {
"resource": ""
} |
q54080 | getDelta | train | function getDelta(inserted, deleted){
var delta = {};
var result;
if (inserted && inserted.length)
result = delta.inserted = inserted;
if (deleted && deleted.length)
result = delta.deleted = deleted;
if (result)
return delta;
} | javascript | {
"resource": ""
} |
q54081 | train | function(minuend, subtrahend){
var delta;
var operandsChanged = false;
var oldMinuend = this.minuend;
var oldSubtrahend = this.subtrahend;
minuend = resolveDataset(this, this.setMinuend, minuend, 'minuendRA_');
subtrahend = resolveDataset(this, this.setSubtrahend, subtrahend, 'subtrahendRA_');
... | javascript | {
"resource": ""
} | |
q54082 | resolveResource | train | function resolveResource(ref, baseURI){
// ref ~ "#123"
if (/^#\d+$/.test(ref))
return templateList[ref.substr(1)];
// ref ~ "id:foo"
if (/^id:/.test(ref))
return resolveSourceByDocumentId(ref.substr(3));
// ref ~ "foo.bar.baz"
if (/^[a-z0-9\.]+$/i.test(ref) && !/\.tmpl$/.test(ref)... | javascript | {
"resource": ""
} |
q54083 | templateSourceUpdate | train | function templateSourceUpdate(){
if (this.destroyBuilder)
buildTemplate.call(this);
var cursor = this;
while (cursor = cursor.attaches_)
cursor.handler.call(cursor.context);
} | javascript | {
"resource": ""
} |
q54084 | buildTemplate | train | function buildTemplate(){
// build new declaration
var declaration = getDeclFromSource(this.source, this.baseURI, false, {
isolate: this.getIsolatePrefix()
});
// make functions and assign to template
var destroyBuilder = this.destroyBuilder;
var instances = {};
var funcs = this.build... | javascript | {
"resource": ""
} |
q54085 | train | function(object, actionCallback, updateCallback, bindings, bindingInterface){
buildTemplate.call(this);
return this.createInstance(object, actionCallback, updateCallback, bindings, bindingInterface);
} | javascript | {
"resource": ""
} | |
q54086 | train | function(source){
var oldSource = this.source;
if (oldSource != source)
{
if (typeof source == 'string')
{
var m = source.match(/^([a-z]+):/);
if (m)
{
source = source.substr(m[0].length);
switch (m[1])
{
... | javascript | {
"resource": ""
} | |
q54087 | train | function(config){
this.ruleRet_ = [];
this.templates_ = [];
this.rule = config.rule;
var events = config.events;
if (events && events.length)
{
this.ruleEvents = {};
for (var i = 0, eventName; eventName = events[i]; i++)
this.ruleEvents[eventName] = true;
... | javascript | {
"resource": ""
} | |
q54088 | switcher | train | function switcher(events, rule){
if (!rule)
{
rule = events;
events = null;
}
if (typeof events == 'string')
events = events.split(/\s+/);
return new TemplateSwitchConfig({
rule: rule,
events: events
});
} | javascript | {
"resource": ""
} |
q54089 | createDispatcher | train | function createDispatcher(eventName){
var eventFunction = events[eventName];
if (!eventFunction)
{
eventFunction = function(){
var cursor = this;
var args;
var fn;
while (cursor = cursor.handler)
{
// callback call
fn = cursor.callbacks[eve... | javascript | {
"resource": ""
} |
q54090 | train | function(callbacks, context){
/** @cut */ if (!callbacks)
/** @cut */ basis.dev.warn(namespace + '.Emitter#addHandler: callbacks is not an object (', callbacks, ')');
context = context || this;
// warn about duplicates
/** @cut */ var cursor = this;
/** @cut */ while (cursor = cu... | javascript | {
"resource": ""
} | |
q54091 | checkUrl | train | function checkUrl(){
var newPath = location.hash.substr(1) || '';
if (newPath != currentPath)
{
// check for recursion
if (preventRecursion(newPath))
return;
// save current path
currentPath = newPath;
var routesToLeave = [];
var routesToEnter = [];
var r... | javascript | {
"resource": ""
} |
q54092 | get | train | function get(params){
var path = params.path;
var config = params.config;
if (path instanceof Route)
return path;
var route;
// If there is no config specified - it should be a plain route, so we try to reuse it
if (!config)
route = plainRoutesByPath[path];
if (!route && param... | javascript | {
"resource": ""
} |
q54093 | add | train | function add(path, callback, context){
var route = get({
path: path,
autocreate: true
});
route.callbacks_.push({
cb_: callback,
context: context,
callback: typeof callback != 'function' ? callback || {} : {
match: callback
}
});
initSchedule.add(route);... | javascript | {
"resource": ""
} |
q54094 | remove | train | function remove(route, callback, context){
var route = get({
path: route
});
if (!route)
return;
for (var i = 0, cb; cb = route.callbacks_[i]; i++)
{
if (cb.cb_ === callback && cb.context === context)
{
route.callbacks_.splice(i, 1);
if (route.value && call... | javascript | {
"resource": ""
} |
q54095 | navigate | train | function navigate(path, replace){
if (replace)
location.replace(location.pathname + '#' + path);
else
location.hash = path;
if (started)
checkUrl();
} | javascript | {
"resource": ""
} |
q54096 | train | function(rule){
rule = basis.getter(rule || UNION);
if (this.rule !== rule)
{
var oldRule = this.rule;
this.rule = rule;
this.emit_ruleChanged(oldRule);
return this.applyRule();
}
} | javascript | {
"resource": ""
} | |
q54097 | train | function(scope){
var memberMap = this.members_;
var rule = this.rule;
var sourceCount = this.sources.length;
var inserted = [];
var deleted = [];
var memberCounter;
var isMember;
var delta;
if (!scope)
scope = memberMap;
for (var objectId in scope)
{
memberCount... | javascript | {
"resource": ""
} | |
q54098 | train | function(source){
// this -> sourceInfo
var merge = this.owner;
var sourcesMap_ = merge.sourcesMap_;
var dataset = resolveDataset(this, merge.updateDataset_, source, 'adapter', merge);
var inserted;
var deleted;
var delta;
if (this.dataset === dataset)
return;
if (dataset)
... | javascript | {
"resource": ""
} | |
q54099 | train | function(source){
if (!source || (typeof source != 'object' && typeof source != 'function'))
{
/** @cut */ basis.dev.warn(this.constructor.className + '.addSource: value should be a dataset instance or to be able to resolve in dataset');
return;
}
if (this.hasSource(source))
{
/**... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.