_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q61100
validation
function(ctl) { var len = ctl.items && ctl.items.length; return utils.sha256(ctl.id + ':' + len).substring(0, 8); }
javascript
{ "resource": "" }
q61101
validation
function(attrs) { for (var k in attrs) if (attrs.hasOwnProperty(k)) this.out.push(' ' + k + '="' + attrs[k] + '"'); }
javascript
{ "resource": "" }
q61102
validation
function(walk) { var _super = BlockCompiler.prototype.emitParagraph.bind(this); if (this.tryGroup('checkbox', walk)) return; if (this.tryGroup('radio', walk)) return; if (this.trySortableGroup(walk)) return; if (this.tryAssociativeGroup(walk)) return; return _super(walk); }
javascript
{ "resource": "" }
q61103
validation
function(type, walk) { if (!this.atGroupMarker(type, walk)) return false; // Find the end of the block, checking for adjacent blocks var startIdx = walk.position; var found = false; while (walk.hasCurrent() && !found) { walk.scrollToTerm().skipWhitespaces(); if (!this.atGroupMarker(type, walk)) found = true; } var g = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); this.emitGroup(type, g); return true; }
javascript
{ "resource": "" }
q61104
validation
function(walk) { if (!walk.at('^ ')) return false; // Find the end of the block, checking for adjacent blocks var startIdx = walk.position; var found = false; while (walk.hasCurrent() && !found) { walk.scrollToTerm().skipWhitespaces(); if (!walk.at('^ ')) found = true; } var g = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); this.emitSortableGroup(g); return true; }
javascript
{ "resource": "" }
q61105
validation
function(walk) { if (!walk.at('@ ')) return false; // Find the end of the block, checking for adjacent blocks var startIdx = walk.position; var found = false; while (!found && walk.hasCurrent()) { walk.scrollToTerm().skipBlankLines(); if (walk.atSpaces(this.blockIndent)) { var i = walk.position; walk.skipWhitespaces(); if (!walk.at('@') && !walk.at('*')) { found = true; walk.startFrom(i); } } else found = true; } var g = this.stripSelector(new SubWalker(walk, startIdx, walk.position)); this.emitAssociativeGroup(g); return true; }
javascript
{ "resource": "" }
q61106
validation
function(walk) { if (this.emitText(walk)) return; if (this.tryInputText(walk)) return; if (this.tryInputRegex(walk)) return; if (this.tryInputTextWithDefault(walk)) return; if (this.trySelectMenu(walk)) return; var _super = InlineCompiler.prototype.emitNormal.bind(this); return _super(walk); }
javascript
{ "resource": "" }
q61107
validation
function (walk) { if (!walk.at('{{')) return false; var endIdx = walk.indexOf(']}'); if (endIdx === null) return false; var str = walk.substring(walk.position + 2, endIdx); var data = str.split('}['); if (data.length != 2) return false; var size = data[0].length; var value = data[0].trim(); var defaultValue = data[1].trim(); if (!defaultValue) return false; var ctl = this.formCompiler.createCtl('inputText'); ctl.value = value; ctl.defaultValue = defaultValue; this.out.push('<input'); this.emitAttrs({ id: ctl.id, name: ctl.id, class: ctl.type, type: 'text', size: size, value: defaultValue }); this.out.push('/>'); walk.startFrom(endIdx).skip(2); }
javascript
{ "resource": "" }
q61108
validation
function(walk) { if (!walk.at('({')) return false; var endIdx = walk.indexOf('})'); if (endIdx === null) return false; // We got a select menu walk.skip(2); var ctl = this.formCompiler.createCtl('selectMenu'); ctl.items = []; this.out.push('<select'); this.emitAttrs({ id: ctl.id, name: ctl.id, class: ctl.type }); this.out.push('>'); this.emitMenuItems(ctl, new SubWalker(walk, walk.position, endIdx)); this.out.push('</select>'); walk.startFrom(endIdx).skip(2); return true; }
javascript
{ "resource": "" }
q61109
validation
function() { // The `solution` markup is built by distributing correct values // across the controls and disabling them var $ = cheerio.load(this.form.html.template); this.form.controls.forEach(function(ctl) { switch(ctl.type) { case 'checkboxGroup': case 'radioGroup': ctl.items.forEach(function(item) { var input = $('input#' + item.id); input.attr('disabled', 'disabled'); if (item.value) input.attr('checked', 'checked'); }); break; case 'selectMenu': var select = $('select#' + ctl.id); select.attr('disabled', 'disabled'); ctl.items.forEach(function(item) { if (item.value) select.val(item.id); }); break; case 'inputText': var input = $('input#' + ctl.id); input.val(ctl.value); input.attr('disabled', 'disabled'); break; case 'associativeGroup': var ag = $('fieldset#' + ctl.id); ag.addClass('disabled'); utils.associativeGroupCategories(ctl).forEach(function(category) { var $dropTarget = ag .find('#category-' + category.item.id) .find('.dropTarget'); category.items.forEach(function(item) { var $item = ag.find('#item-' + item.id); $dropTarget.append($item); }); }); break; } }, this); this.form.html.solution = $.html(); // The `prompt` markup $ = cheerio.load(this.form.html.template); // Solution blocks are removed $('.solution').remove(); // Sortable items are shuffled utils.shuffle($, '.sortableGroup'); utils.shuffle($, '.associativeGroup .items'); this.form.html.prompt = $.html(); }
javascript
{ "resource": "" }
q61110
validation
function(o){ if (Ext.isString(o)) { o = { text: o }; } o = Ext.applyIf(o || {}, { text: this.busyText, iconCls: this.busyIconCls }); return this.setStatus(o); }
javascript
{ "resource": "" }
q61111
trailer
validation
function trailer(file, fn) { return through({objectMode: true}, function (a, e, cb) { this.push(a) cb() }, function (cb) { var self = this fn(function (err, val) { if (err) { return cb(err) } if (val) { if (typeof val === 'string') { val = new Buffer(string) } var f = new File({ path: file, contents: val }) self.push(f) } cb() }) }) }
javascript
{ "resource": "" }
q61112
validation
function() { var fw, ix = 0; // Find front most window and focus that each (this.windows, function(w) { if (w.zIndex > ix) { fw = w; ix = w.zIndex; } }); return fw; }
javascript
{ "resource": "" }
q61113
validation
function() { var me = this, mon = me.monitor; if (mon) { mon.unbind(); me.monitor = null; } me.clearListeners(); me.checkValidityTask.cancel(); me.checkDirtyTask.cancel(); }
javascript
{ "resource": "" }
q61114
validation
function(errors) { var me = this, e, eLen, error, value, key; function mark(fieldId, msg) { var field = me.findField(fieldId); if (field) { field.markInvalid(msg); } } if (Ext.isArray(errors)) { eLen = errors.length; for (e = 0; e < eLen; e++) { error = errors[e]; mark(error.id, error.msg); } } else if (errors instanceof Ext.data.Errors) { eLen = errors.items.length; for (e = 0; e < eLen; e++) { error = errors.items[e]; mark(error.field, error.message); } } else { for (key in errors) { if (errors.hasOwnProperty(key)) { value = errors[key]; mark(key, value, errors); } } } return this; }
javascript
{ "resource": "" }
q61115
validation
function(values) { var me = this, v, vLen, val, field; function setVal(fieldId, val) { var field = me.findField(fieldId); if (field) { field.setValue(val); if (me.trackResetOnLoad) { field.resetOriginalValue(); } } } // Suspend here because setting the value on a field could trigger // a layout, for example if an error gets set, or it's a display field Ext.suspendLayouts(); if (Ext.isArray(values)) { // array of objects vLen = values.length; for (v = 0; v < vLen; v++) { val = values[v]; setVal(val.id, val.value); } } else { // object hash Ext.iterate(values, setVal); } Ext.resumeLayouts(true); return this; }
javascript
{ "resource": "" }
q61116
validation
function() { Ext.suspendLayouts(); var me = this, fields = me.getFields().items, f, fLen = fields.length; for (f = 0; f < fLen; f++) { fields[f].clearInvalid(); } Ext.resumeLayouts(true); return me; }
javascript
{ "resource": "" }
q61117
getInfoSync
validation
function getInfoSync(dir) { var fullname = path.join(dir, '.epm/CONFIG'); if (!fs.existsSync(fullname)) { return { name: 'unknown', engine: 'unknown', path: dir }; } var info = JSON.parse(fs.readFileSync(fullname, 'utf-8')); return { name: info.name || 'unknown', engine: info.engine || 'unknown', path: dir }; }
javascript
{ "resource": "" }
q61118
getDirectories
validation
function getDirectories(dir, cb) { fs.readdir(dir, function(err, objects){ if (err) { return cb && cb(err); } var dirs = objects.filter(function(item){ return fs.statSync(path.join(dir, item)).isDirectory(); }); cb && cb(null, dirs) }) }
javascript
{ "resource": "" }
q61119
getDirectoriesSync
validation
function getDirectoriesSync(dir) { return fs.readdirSync(dir) .filter(function(item){ return fs.statSync(path.join(dir, item)).isDirectory(); }); }
javascript
{ "resource": "" }
q61120
isRepoSync
validation
function isRepoSync(dir){ var dirs if (dir instanceof Array){ dirs = dir } else { dirs = getDirectoriesSync(dir) } var res = dirs.filter(function(name){ return name.match(/\.epm/ig) }); return res.length > 0; }
javascript
{ "resource": "" }
q61121
validation
function(parent, records, suppressEvent) { var me = this, insertIndex = me.indexOf(parent) + 1, toAdd = []; // Used by the TreeView to bracket recursive expand & collapse ops // and refresh the size. This is most effective when folder nodes are loaded, // and this method is able to recurse. if (!suppressEvent) { me.fireEvent('beforeexpand', parent, records, insertIndex); } me.handleNodeExpand(parent, records, toAdd); // The add event from this insertion is handled by TreeView.onAdd. // That implementation calls parent and then ensures the previous sibling's joining lines are correct. // The datachanged event is relayed by the TreeStore. Internally, that's not used. me.insert(insertIndex, toAdd); // Triggers the TreeView's onExpand method which calls refreshSize, // and fires its afteritemexpand event if (!suppressEvent) { me.fireEvent('expand', parent, records); } }
javascript
{ "resource": "" }
q61122
validation
function(parent, records, toAdd) { var me = this, ln = records ? records.length : 0, i, record; // recursive is hardcoded to true in TreeView. if (!me.recursive && parent !== me.node) { return; } if (parent !== this.node && !me.isVisible(parent)) { return; } if (ln) { // The view items corresponding to these are rendered. // Loop through and expand any of the non-leaf nodes which are expanded for (i = 0; i < ln; i++) { record = records[i]; // Add to array being collected by recursion when child nodes are loaded. // Must be done here in loop so that child nodes are inserted into the stream in place // in recursive calls. toAdd.push(record); if (record.isExpanded()) { if (record.isLoaded()) { // Take a shortcut - appends to toAdd array me.handleNodeExpand(record, record.childNodes, toAdd); } else { // Might be asynchronous if child nodes are not immediately available record.set('expanded', false); record.expand(); } } } } }
javascript
{ "resource": "" }
q61123
validation
function(parent, records, suppressEvent, callback, scope) { var me = this, collapseIndex = me.indexOf(parent) + 1, node, lastNodeIndexPlus, sibling, found; if (!me.recursive && parent !== me.node) { return; } // Used by the TreeView to bracket recursive expand & collapse ops. // The TreeViewsets up the animWrap object if we are animating. // It also caches the collapse callback to call when it receives the // end collapse event. See below. if (!suppressEvent) { me.fireEvent('beforecollapse', parent, records, collapseIndex, callback, scope); } // Only attempt to remove the records if they are there. // Collapsing an ancestor node *immediately removes from the view, ALL its descendant nodes at all levels*. // But if the collapse was recursive, all descendant root nodes will still fire their // events. But we must ignore those events here - we have nothing to do. if (records.length && me.data.contains(records[0])) { // Calculate the index *one beyond* the last node we are going to remove // Need to loop up the tree to find the nearest view sibling, since it could // exist at some level above the current node. node = parent; while (node.parentNode) { sibling = node.nextSibling; if (sibling) { found = true; lastNodeIndexPlus = me.indexOf(sibling); break; } else { node = node.parentNode; } } if (!found) { lastNodeIndexPlus = me.getCount(); } // Remove the whole collapsed node set. me.removeAt(collapseIndex, lastNodeIndexPlus - collapseIndex); } // Triggers the TreeView's onCollapse method which calls refreshSize, // and fires its afteritecollapse event if (!suppressEvent) { me.fireEvent('collapse', parent, records, collapseIndex); } }
javascript
{ "resource": "" }
q61124
inlineAndCompile
validation
function inlineAndCompile(filenames, options, reporter, callback, errback) { var depTarget = options && options.depTarget; var referrerName = options && options.referrer; var basePath; if (referrerName) { // The compile occurs two directories down from current directory, // in src/node. Thus the names will appear as eg ../src/x. // We want something like referrerName/src/x. So we need to give // the normalize() the 'package' or root name with src/node append // to represent the referrer from here. referrerName = referrerName && referrerName + 'src/node'; // The basePath will replace options.referrer in our final filename. // Since we are in src/node, we need to back up two directories. basePath = path.join(__dirname, '../../'); } else { basePath = path.resolve('./') + '/'; } basePath = basePath.replace(/\\/g, '/'); var scriptsCount = options.scripts.length; var loadCount = 0; var elements = []; var hooks = new InlineLoaderHooks(reporter, basePath, elements, depTarget); var loader = new TraceurLoader(hooks); function appendEvaluateModule(name, referrerName) { var normalizedName = traceur.ModuleStore.normalize(name, referrerName); // Create tree for System.get('normalizedName'); var tree = traceur.codegeneration.module.createModuleEvaluationStatement(normalizedName); elements.push(tree); } function loadNext() { var loadAsScript = scriptsCount && (loadCount < scriptsCount); var doEvaluateModule = false; var loadFunction = loader.import; var name = filenames[loadCount]; if (loadAsScript) { loadFunction = loader.loadAsScript; } else { name = name.replace(/\.js$/,''); if (options.modules !== 'inline' && options.modules !== 'instantiate') doEvaluateModule = true; } var loadOptions = {referrerName: referrerName}; var codeUnit = loadFunction.call(loader, name, loadOptions).then( function() { if (doEvaluateModule) appendEvaluateModule(name, referrerName); loadCount++; if (loadCount < filenames.length) { loadNext(); } else if (depTarget) { callback(null); } else { var tree = allLoaded(basePath, reporter, elements); callback(tree); } }, function(err) { errback(err); }).catch(function(ex) { console.error('Internal error ' + (ex.stack || ex)); }); } loadNext(); }
javascript
{ "resource": "" }
q61125
Simple
validation
function Simple() { // If arguments passed in, try and parse the simple date if(arguments.length > 0) { this._parse(arguments[0]); } else { // Note that all dates and times are UTC internally! var date = new Date(); this._year = date.getUTCFullYear(); this._month = date.getUTCMonth(); this._day = date.getUTCDay(); this._hours = date.getUTCHours(); this._minutes = date.getUTCMinutes(); this._seconds = date.getUTCSeconds(); this._tzHours = 0; this._tzMinutes = 0; } }
javascript
{ "resource": "" }
q61126
validation
function () { var me = this, ret = { minWidth: 20, width: Ext.themeName === 'neptune' ? 70 : 60, items: [], enableOverflow: true }; Ext.each(this.quickStart, function (item) { ret.items.push({ tooltip: { text: item.name, align: 'bl-tl' }, //tooltip: item.name, overflowText: item.name, iconCls: item.iconCls, module: item.module, handler: me.onQuickStartClick, scope: me }); }); return ret; }
javascript
{ "resource": "" }
q61127
applyEachOptimization
validation
function applyEachOptimization(rel){ var originalRel = rel rel = JSON.parse(JSON.stringify(rel)) //console.log('rel: ' + JSON.stringify(rel)) try{ var newImplicits = [rel.params[1].implicits[0]] var bindingsUsed = _.extend({}, rel.params[1].bindingsUsed) //1. extract macro params to one or more ~:property maps var maps = [] var failed = false var newMacroExpr = replaceMacroPropertyExpressions(rel.params[1].expr, rel.params[1].implicits, function(macroPropertyExpr){ if(macroPropertyExpr.schemaType.type === 'map'){ failed = true return } var uid = 'extproperty_'+Math.random() var bu = {} bu[uid] = true var m = { type: 'view', view: 'map', params: [ rel.params[0], { type: 'macro', manyImplicits: 1, expr: {type: 'param', name: uid, schemaType: rel.params[0].schemaType.members}, bindingsUsed: bu, implicits: [uid], schemaType: rel.params[0].schemaType.members, implicitTypes: [rel.params[0].schemaType.members] },{ type: 'macro', manyImplicits: 1, expr: JSON.parse(JSON.stringify(macroPropertyExpr)), bindingsUsed: bu, implicits: [rel.params[1].implicits[0]], schemaType: macroPropertyExpr.schemaType, implicitTypes: [rel.params[1].implicitTypes[0]] } ], willBeOptimized: true, uid: uid } m.schemaType = {type: 'map', key: m.params[1].schemaType, value: m.params[2].schemaType} maps.push(applyEachOptimizationToView(m)) newImplicits.push(uid) bindingsUsed[uid] = true _.assertDefined(macroPropertyExpr.schemaType) return {type: 'param', name: uid, schemaType: macroPropertyExpr.schemaType} }) if(failed) return originalRel var newMacro = { type: 'macro', expr: newMacroExpr, manyImplicits: newImplicits.length, implicits: newImplicits, implicitTypes: [rel.params[0].schemaType.members], bindingsUsed: bindingsUsed,//newImplicits schemaType: newMacroExpr.schemaType } //console.log('created m: ' + JSON.stringify(newMacro, null, 2)) return { type: 'view', view: 'each-optimization', params: [rel.params[0], newMacro].concat(maps), schemaType: rel.schemaType, code: rel.code } }catch(e){ //console.log('could not optimize each + e.stack) return originalRel } }
javascript
{ "resource": "" }
q61128
makeSyncOpGenericGetChangesBetween
validation
function makeSyncOpGenericGetChangesBetween(handle, ws, rel, recurse, paramFuncs){ //paramFuncs.forEach(function(pf){ for(var i=0;i<paramFuncs.length;++i){ var pf = paramFuncs[i] if(pf.isMacro){ //_.errout('cannot apply this method if a param is a macro: ' + JSON.stringify(rel)) return makeGenericGetChangesBetween(handle, ws, rel) } } //}) //console.log(new Error().stack) function syncGenericGetChangesBetween(bindings, startEditId, endEditId, cb){ _.assertLength(arguments, 4) if(startEditId === endEditId) _.errout('wasting time') var snaps = [] var editIds = [] var has = {} //console.log('getting ' + JSON.stringify(rel)) var cdl = _.latch(paramFuncs.length, function(){ if(editIds.length === 0){ //console.log('no changes ' + startEditId + ' ' + endEditId) cb([]) return } handle.getStateAt(bindings, startEditId, function(startState){ handle.getStateAt(bindings, endEditId, function(state){ if(startState === state){ cb([]) }else{ var es = ws.diffFinder(startState, state) var changes = [] es.forEach(function(e){ e.editId = endEditId changes.push(e) }) cb(changes) } }) }) }) //console.log('here2') for(var i=0;i<paramFuncs.length;++i){ paramFuncs[i].getChangesBetween(bindings, startEditId, endEditId, function(changes){ changes.forEach(function(c){ var editId = c.editId if(has[editId]) return has[editId] = true editIds.push(editId) }) cdl() }) } } return syncGenericGetChangesBetween }
javascript
{ "resource": "" }
q61129
validation
function (key, task, done, ttl) { const queue = this.queue; const semaphore = this.semaphore; if (!ttl) ttl = this.ttl; const runTask = (res) => new Promise((resolve) => task( (...args) => resolve(Response.setData(res, args)) ) ); const startThenRunTask = (lock_key) => queue.start(key, Response.factory(ttl)) .then(runTask) .then(queue.dequeue.bind(null, key)) .then(() => semaphore.release(key, lock_key)) .catch((err) => { semaphore.release(key, lock_key); throw err; }) ; const startIfNotWaiting = () => Promise.all([ queue.isWaiting(key) , semaphore.lock(key) ]) .then(([ is_waiting, lock_key ]) => (!is_waiting && lock_key) ? startThenRunTask(lock_key) : null ) return queue .add(key, done) .then(startIfNotWaiting) ; }
javascript
{ "resource": "" }
q61130
Iterator
validation
function Iterator(options, fn) { if (typeof options === 'function') { fn = options; options = {}; } if (typeof fn !== 'function') { throw new TypeError('Iterator expects `fn` to be a function.'); } this.options = options || {}; this.fn = fn; }
javascript
{ "resource": "" }
q61131
domGen
validation
function domGen(tagName) { /** * Generates a dom with the given params. * @param {object} [opts] The options to pass as the second arg of $('<tag/>', arg) * @param {object[]} args The objects to append to the element * @return {jQuery} */ return (opts, ...args) => { if (!seemLikePlainObject(opts)) { args.unshift(opts) opts = undefined } return $('<' + tagName + '/>', opts).append(...[].concat(...args)) } }
javascript
{ "resource": "" }
q61132
validation
function(v){ var ots = Object.prototype.toString; var s=typeof v; if(s=='object'){ if(v){ if((ots.call(v).indexOf('HTML')!==-1 && ots.call(v).indexOf('Element')!=-1)){return 'element'} if(v instanceof Array||(!(v instanceof Object)&&(ots.call(v)=='[object Array]')||typeof v.length=='number'&&typeof v.splice!='undefined'&&typeof v.propertyIsEnumerable!='undefined'&&!v.propertyIsEnumerable('splice'))){return 'array'} if(!(v instanceof Object)&&(ots.call(v)=='[object Function]'|| typeof v.call!='undefined'&& typeof v.propertyIsEnumerable!='undefined'&&!v.propertyIsEnumerable('call'))){return 'function'} } return 'null'; } else if(s=='function'&&typeof v.call=='undefined'){return 'object'} return s; }
javascript
{ "resource": "" }
q61133
validation
function(identifier){ if(!Bella.contains(this.lines, identifier)){ this.lines.push(identifier); this.Event.onAddOnlineUser(identifier); return true; } return false; }
javascript
{ "resource": "" }
q61134
validation
function(value) { value = value || ''; return this.setStyle({ left : value, right : value, top : value, bottom : value, 'z-index' : '', position : STATIC }); }
javascript
{ "resource": "" }
q61135
validation
function() { var me = this, offsetParent = me.dom.offsetParent, x = me.getStyle('left'); if (!x || x === 'auto') { x = 0; } else if (me.pxRe.test(x)) { x = parseFloat(x); } else { x = me.getX(); if (offsetParent) { x -= Element.getX(offsetParent); } } return x; }
javascript
{ "resource": "" }
q61136
validation
function() { var me = this, offsetParent = me.dom.offsetParent, style = me.getStyle(['left', 'top']), x = style.left, y = style.top; if (!x || x === 'auto') { x = 0; } else if (me.pxRe.test(x)) { x = parseFloat(x); } else { x = me.getX(); if (offsetParent) { x -= Element.getX(offsetParent); } } if (!y || y === 'auto') { y = 0; } else if (me.pxRe.test(y)) { y = parseFloat(y); } else { y = me.getY(); if (offsetParent) { y -= Element.getY(offsetParent); } } return [x, y]; }
javascript
{ "resource": "" }
q61137
validation
function() { var me = this, offsetParent = me.dom.offsetParent, y = me.getStyle('top'); if (!y || y === 'auto') { y = 0; } else if (me.pxRe.test(y)) { y = parseFloat(y); } else { y = me.getY(); if (offsetParent) { y -= Element.getY(offsetParent); } } return y; }
javascript
{ "resource": "" }
q61138
validation
function(pos, zIndex, x, y) { var me = this; if (!pos && me.isStyle(POSITION, STATIC)) { me.setStyle(POSITION, RELATIVE); } else if (pos) { me.setStyle(POSITION, pos); } if (zIndex) { me.setStyle(ZINDEX, zIndex); } if (x || y) { me.setXY([x || false, y || false]); } }
javascript
{ "resource": "" }
q61139
validation
function(x, y, width, height, animate) { return this.setBox({ x: x, y: y, width: width, height: height }, animate); }
javascript
{ "resource": "" }
q61140
validation
function(left, top) { var me = this, style = me.dom.style; style.left = me.addUnits(left); style.top = me.addUnits(top); return me; }
javascript
{ "resource": "" }
q61141
validation
function(rec){ var me = this, node = me.getNode(rec, true), el = me.el, adjustmentY = 0, adjustmentX = 0, elRegion = el.getRegion(), nodeRegion; // Viewable region must not include scrollbars, so use // DOM client dimensions elRegion.bottom = elRegion.top + el.dom.clientHeight; elRegion.right = elRegion.left + el.dom.clientWidth; if (node) { nodeRegion = Ext.fly(node).getRegion(); // node is above if (nodeRegion.top < elRegion.top) { adjustmentY = nodeRegion.top - elRegion.top; // node is below } else if (nodeRegion.bottom > elRegion.bottom) { adjustmentY = nodeRegion.bottom - elRegion.bottom; } // node is left if (nodeRegion.left < elRegion.left) { adjustmentX = nodeRegion.left - elRegion.left; // node is right } else if (nodeRegion.right > elRegion.right) { adjustmentX = nodeRegion.right - elRegion.right; } if (adjustmentX || adjustmentY) { me.scrollBy(adjustmentX, adjustmentY, false); } el.focus(); } }
javascript
{ "resource": "" }
q61142
validation
function(card) { var me = this, previous; card = me.getComponent(card); if (card) { previous = me.getActiveTab(); if (previous !== card && me.fireEvent('beforetabchange', me, card, previous) === false) { return false; } // We may be passed a config object, so add it. // Without doing a layout! if (!card.isComponent) { Ext.suspendLayouts(); card = me.add(card); Ext.resumeLayouts(); } // MUST set the activeTab first so that the machinery which listens for show doesn't // think that the show is "driving" the activation and attempt to recurse into here. me.activeTab = card; // Attempt to switch to the requested card. Suspend layouts because if that was successful // we have to also update the active tab in the tab bar which is another layout operation // and we must coalesce them. Ext.suspendLayouts(); me.layout.setActiveItem(card); // Read the result of the card layout. Events dear boy, events! card = me.activeTab = me.layout.getActiveItem(); // Card switch was not vetoed by an event listener if (card && card !== previous) { // Update the active tab in the tab bar and resume layouts. me.tabBar.setActiveTab(card.tab); Ext.resumeLayouts(true); // previous will be undefined or this.activeTab at instantiation if (previous !== card) { me.fireEvent('tabchange', me, card, previous); } } // Card switch was vetoed by an event listener. Resume layouts (Nothing should have changed on a veto). else { Ext.resumeLayouts(true); } return card; } }
javascript
{ "resource": "" }
q61143
validation
function() { var me = this, // Ensure the calculated result references a Component result = me.getComponent(me.activeTab); // Sanitize the result in case the active tab is no longer there. if (result && me.items.indexOf(result) != -1) { me.activeTab = result; } else { me.activeTab = null; } return me.activeTab; }
javascript
{ "resource": "" }
q61144
validation
function(syncId, blockCb, makeCb, reifyCb, cb){ _.assertLength(arguments, 5) //_.assertFunction(listenerCb) //_.assertFunction(objectCb) _.assertFunction(blockCb) _.assertFunction(makeCb) _.assertFunction(reifyCb) _.assertFunction(cb); _.assertString(syncId) var e = {syncId: syncId}; //applyRequestId(e, wrapper.bind(undefined, cb, makeCb)); log('BEGAN SYNC CLIENT') w.beginSync(e); /*syncListenersByRequestId[e.requestId]*/ syncListenersBySyncId[syncId] = {block: blockCb, make: makeCb, reify: reifyCb} cb(makeSyncHandle(syncId, makeCb)) }
javascript
{ "resource": "" }
q61145
resize
validation
function resize() { var deltaSize, d = ed.getDoc(), body = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight; // Get height differently depending on the browser used myHeight = tinymce.isIE ? body.scrollHeight : (tinymce.isWebKit && body.clientHeight == 0 ? 0 : body.offsetHeight); // Don't make it smaller than the minimum height if (myHeight > t.autoresize_min_height) resizeHeight = myHeight; // If a maximum height has been defined don't exceed this height if (t.autoresize_max_height && myHeight > t.autoresize_max_height) { resizeHeight = t.autoresize_max_height; body.style.overflowY = "auto"; de.style.overflowY = "auto"; // Old IE } else { body.style.overflowY = "hidden"; de.style.overflowY = "hidden"; // Old IE body.scrollTop = 0; } // Resize content element if (resizeHeight !== oldSize) { deltaSize = resizeHeight - oldSize; DOM.setStyle(DOM.get(ed.id + '_ifr'), 'height', resizeHeight + 'px'); oldSize = resizeHeight; // WebKit doesn't decrease the size of the body element until the iframe gets resized // So we need to continue to resize the iframe down until the size gets fixed if (tinymce.isWebKit && deltaSize < 0) resize(); } }
javascript
{ "resource": "" }
q61146
LoaderType
validation
function LoaderType(options, fn) { if (!(this instanceof LoaderType)) { return new LoaderType(options); } LoaderStack.call(this); this.iterator = new Iterator(options, fn); }
javascript
{ "resource": "" }
q61147
validation
function(oldKey, newKey) { var me = this, map = me.map, indexMap = me.indexMap, index = me.indexOfKey(oldKey), item; if (index > -1) { item = map[oldKey]; delete map[oldKey]; delete indexMap[oldKey]; map[newKey] = item; indexMap[newKey] = index; me.keys[index] = newKey; me.generation++; } }
javascript
{ "resource": "" }
q61148
validation
function(objs) { var me = this, key; if (arguments.length > 1 || Ext.isArray(objs)) { me.insert(me.length, arguments.length > 1 ? arguments : objs); } else { for (key in objs) { if (objs.hasOwnProperty(key)) { if (me.allowFunctions || typeof objs[key] != 'function') { me.add(key, objs[key]); } } } } }
javascript
{ "resource": "" }
q61149
validation
function(fn, scope){ var items = Ext.Array.push([], this.items), // each safe for removal i = 0, len = items.length, item; for (; i < len; i++) { item = items[i]; if (fn.call(scope || item, item, i, len) === false) { break; } } }
javascript
{ "resource": "" }
q61150
validation
function(index, keys, objects) { var me = this, itemKey, removeIndex, i, len = keys.length, fireAdd = me.hasListeners.add, syncIndices; // External key(s) passed. We cannot reliably find an object's index using the key extraction fn. // Set a flag for use by contains, indexOf and remove if (objects != null) { me.useLinearSearch = true } // No external keys: calculate keys array if not passed else { objects = keys; keys = new Array(len); for (i = 0; i < len; i++) { keys[i] = this.getKey(objects[i]); } } // First, remove duplicates of the keys. If a removal point is less than insertion index, decr insertion index me.suspendEvents(); for (i = 0; i < len; i++) { // Must use indexOf - map might be out of sync removeIndex = me.indexOfKey(keys[i]); if (removeIndex !== -1) { if (removeIndex < index) { index--; } me.removeAt(removeIndex); } } me.resumeEvents(); // If we are appending and the indices are in sync, its cheap to kep them that way syncIndices = index === me.length && me.indexGeneration === me.generation; // Insert the new items and new keys in at the insertion point Ext.Array.insert(me.items, index, objects); Ext.Array.insert(me.keys, index, keys); me.length += len; me.generation++; if (syncIndices) { me.indexGeneration = me.generation; } for (i = 0; i < len; i++, index++) { itemKey = keys[i]; if (itemKey != null) { me.map[itemKey] = objects[i]; // If the index is still in sync, keep it that way if (syncIndices) { me.indexMap[itemKey] = index; } } if (fireAdd) { me.fireEvent('add', index, objects[i], itemKey); } } return objects; }
javascript
{ "resource": "" }
q61151
validation
function(o) { var me = this, removeKey, index; // If // We have not been forced into using linear lookup by a usage of the 2 arg form of add // and // The key extraction function yields a key // Then use indexOfKey. This will use the indexMap - rebuilding it if necessary. if (!me.useLinearSearch && (removeKey = me.getKey(o))) { index = me.indexOfKey(removeKey); } // Otherwise we have to do it the slow way with a linear search. else { index = Ext.Array.indexOf(me.items, o); } return (index === -1) ? false : me.removeAt(index); }
javascript
{ "resource": "" }
q61152
validation
function(items) { var me = this, i; if (items || me.hasListeners.remove) { // Only perform expensive item-by-item removal if there's a listener or specific items if (items) { for (i = items.length - 1; i >= 0; --i) { me.remove(items[i]); } } else { while (me.length) { me.removeAt(0); } } } else { me.length = me.items.length = me.keys.length = 0; me.map = {}; me.indexMap = {}; me.generation++; me.indexGeneration = me.generation; } }
javascript
{ "resource": "" }
q61153
validation
function(o) { var me = this, key; if (o != null) { // If // We have not been forced into using linear lookup by a usage of the 2 arg form of add // and // The key extraction function yields a key // Then use the map to determine object presence. if (!me.useLinearSearch && (key = me.getKey(o))) { return this.map[key] != null; } // Fallback: Use linear search return Ext.Array.indexOf(this.items, o) !== -1; } return false; }
javascript
{ "resource": "" }
q61154
validation
function(property, root, start, end) { var values = this.extractValues(property, root), length = values.length, sum = 0, i; start = start || 0; end = (end || end === 0) ? end : length - 1; for (i = start; i <= end; i++) { sum += values[i]; } return sum; }
javascript
{ "resource": "" }
q61155
validation
function(property, root, allowNull) { var values = this.extractValues(property, root), length = values.length, hits = {}, unique = [], value, strValue, i; for (i = 0; i < length; i++) { value = values[i]; strValue = String(value); if ((allowNull || !Ext.isEmpty(value)) && !hits[strValue]) { hits[strValue] = true; unique.push(value); } } return unique; }
javascript
{ "resource": "" }
q61156
validation
function() { var me = this, copy = new this.self(me.initialConfig); copy.add(me.keys, me.items); return copy; }
javascript
{ "resource": "" }
q61157
validation
function(data, force_absolute) { var self = this, editor = self.editor, baseUri = editor.documentBaseURI, sources, attrs, img, i; data.params.src = self.convertUrl(data.params.src, force_absolute); attrs = data.video.attrs; if (attrs) attrs.src = self.convertUrl(attrs.src, force_absolute); if (attrs) attrs.poster = self.convertUrl(attrs.poster, force_absolute); sources = toArray(data.video.sources); if (sources) { for (i = 0; i < sources.length; i++) sources[i].src = self.convertUrl(sources[i].src, force_absolute); } img = self.editor.dom.create('img', { id : data.id, style : data.style, align : data.align, hspace : data.hspace, vspace : data.vspace, src : self.editor.theme.url + '/img/trans.gif', 'class' : 'mceItemMedia mceItem' + self.getType(data.type).name, 'data-mce-json' : JSON.serialize(data, "'") }); img.width = data.width = normalizeSize(data.width || (data.type == 'audio' ? "300" : "320")); img.height = data.height = normalizeSize(data.height || (data.type == 'audio' ? "32" : "240")); return img; }
javascript
{ "resource": "" }
q61158
validation
function(value) { var i, values, typeItem; // Find type by checking the classes values = tinymce.explode(value, ' '); for (i = 0; i < values.length; i++) { typeItem = this.lookup[values[i]]; if (typeItem) return typeItem; } }
javascript
{ "resource": "" }
q61159
addPlayer
validation
function addPlayer(video_src, poster_src) { var baseUri, flashVars, flashVarsOutput, params, flashPlayer; flashPlayer = editor.getParam('flash_video_player_url', self.convertUrl(self.url + '/moxieplayer.swf')); if (flashPlayer) { baseUri = editor.documentBaseURI; data.params.src = flashPlayer; // Convert the movie url to absolute urls if (editor.getParam('flash_video_player_absvideourl', true)) { video_src = baseUri.toAbsolute(video_src || '', true); poster_src = baseUri.toAbsolute(poster_src || '', true); } // Generate flash vars flashVarsOutput = ''; flashVars = editor.getParam('flash_video_player_flashvars', {url : '$url', poster : '$poster'}); tinymce.each(flashVars, function(value, name) { // Replace $url and $poster variables in flashvars value value = value.replace(/\$url/, video_src || ''); value = value.replace(/\$poster/, poster_src || ''); if (value.length > 0) flashVarsOutput += (flashVarsOutput ? '&' : '') + name + '=' + escape(value); }); if (flashVarsOutput.length) data.params.flashvars = flashVarsOutput; params = editor.getParam('flash_video_player_params', { allowfullscreen: true, allowscriptaccess: true }); tinymce.each(params, function(value, name) { data.params[name] = "" + value; }); } }
javascript
{ "resource": "" }
q61160
validation
function(binding){ var me = this, keyCode = binding.key, i, len; if (me.processing) { me.bindings = bindings.slice(0); } if (Ext.isArray(binding)) { for (i = 0, len = binding.length; i < len; i++) { me.addBinding(binding[i]); } return; } me.bindings.push(Ext.apply({ keyCode: me.processKeys(keyCode) }, binding)); }
javascript
{ "resource": "" }
q61161
validation
function(binding){ var me = this, bindings = me.bindings, len = bindings.length, i, item, keys; if (me.processing) { me.bindings = bindings.slice(0); } keys = me.processKeys(binding.key); for (i = 0; i < len; ++i) { item = bindings[i]; if (item.fn === binding.fn && item.scope === binding.scope) { if (binding.alt == item.alt && binding.crtl == item.crtl && binding.shift == item.shift) { if (Ext.Array.equals(item.keyCode, keys)) { Ext.Array.erase(me.bindings, i, 1); return; } } } } }
javascript
{ "resource": "" }
q61162
validation
function(binding, event){ if (this.checkModifiers(binding, event)) { var key = event.getKey(), handler = binding.fn || binding.handler, scope = binding.scope || this, keyCode = binding.keyCode, defaultEventAction = binding.defaultEventAction, i, len, keydownEvent = new Ext.EventObjectImpl(event); for (i = 0, len = keyCode.length; i < len; ++i) { if (key === keyCode[i]) { if (handler.call(scope, key, event) !== true && defaultEventAction) { keydownEvent[defaultEventAction](); } break; } } } }
javascript
{ "resource": "" }
q61163
validation
function(binding, e) { var keys = ['shift', 'ctrl', 'alt'], i = 0, len = keys.length, val, key; for (; i < len; ++i){ key = keys[i]; val = binding[key]; if (!(val === undefined || (val === e[key + 'Key']))) { return false; } } return true; }
javascript
{ "resource": "" }
q61164
validation
function(key, fn, scope) { var keyCode, shift, ctrl, alt; if (Ext.isObject(key) && !Ext.isArray(key)) { keyCode = key.key; shift = key.shift; ctrl = key.ctrl; alt = key.alt; } else { keyCode = key; } this.addBinding({ key: keyCode, shift: shift, ctrl: ctrl, alt: alt, fn: fn, scope: scope }); }
javascript
{ "resource": "" }
q61165
validation
function() { var me = this; if (!me.enabled) { me.target.on(me.eventName, me.handleTargetEvent, me); me.enabled = true; } }
javascript
{ "resource": "" }
q61166
validation
function() { var me = this; if (me.enabled) { me.target.removeListener(me.eventName, me.handleTargetEvent, me); me.enabled = false; } }
javascript
{ "resource": "" }
q61167
validation
function(removeTarget) { var me = this, target = me.target; me.bindings = []; me.disable(); if (removeTarget === true) { if (target.isComponent) { target.destroy(); } else { target.remove(); } } delete me.target; }
javascript
{ "resource": "" }
q61168
validation
function () { var me = this, items = me.flushQueue.clear(), length = items.length, i; if (length) { ++me.flushCount; for (i = 0; i < length; ++i) { items[i].flush(); } } }
javascript
{ "resource": "" }
q61169
validation
function (parent, el) { var id = el.id, children = parent.children, items = this.items; if(children) { Ext.Array.remove(children, items[id]); } delete items[id]; }
javascript
{ "resource": "" }
q61170
validation
function () { var me = this, layouts = me.layoutQueue.clear(), length = layouts.length, i; ++me.cycleCount; // This value is incremented by ContextItem#setProp whenever new values are set // (thereby detecting forward progress): me.progressCount = 0; for (i = 0; i < length; ++i) { me.runLayout(me.currentLayout = layouts[i]); } me.currentLayout = null; return me.progressCount > 0; }
javascript
{ "resource": "" }
q61171
validation
function (layout) { var me = this, ownerContext = me.getCmp(layout.owner); layout.pending = false; if (ownerContext.state.blocks) { return; } // We start with the assumption that the layout will finish and if it does not, it // must clear this flag. It turns out this is much simpler than knowing when a layout // is done (100% correctly) when base classes and derived classes are collaborating. // Knowing that some part of the layout is not done is much more obvious. layout.done = true; ++layout.calcCount; ++me.calcCount; layout.calculate(ownerContext); if (layout.done) { me.layoutDone(layout); if (layout.completeLayout) { me.queueCompletion(layout); } if (layout.finalizeLayout) { me.queueFinalize(layout); } } else if (!layout.pending && !layout.invalid && !(layout.blockCount + layout.triggerCount - layout.firedTriggers)) { // A layout that is not done and has no blocks or triggers that will queue it // automatically, must be queued now: me.queueLayout(layout); } }
javascript
{ "resource": "" }
q61172
validation
function(item, width, height) { var items = item, len = 1, contextItem, i; // NOTE: we don't pre-check for validity because: // - maybe only one dimension is valid // - the diagnostics layer will track the setProp call to help find who is trying // (but failing) to set a property // - setProp already checks this anyway if (item.isComposite) { items = item.elements; len = items.length; item = items[0]; } else if (!item.dom && !item.el) { // array by process of elimination len = items.length; item = items[0]; } // else len = 1 and items = item (to avoid error on "items[++i]") for (i = 0; i < len; ) { contextItem = this.get(item); contextItem.setSize(width, height); item = items[++i]; // this accomodation avoids making an array of 1 } }
javascript
{ "resource": "" }
q61173
validation
function(model, setOnStore) { var me = this; me.model = Ext.ModelManager.getModel(model); me.setReader(this.reader); me.setWriter(this.writer); if (setOnStore && me.store) { me.store.setModel(me.model); } }
javascript
{ "resource": "" }
q61174
validation
function(reader) { var me = this, needsCopy = true, current = me.reader; if (reader === undefined || typeof reader == 'string') { reader = { type: reader }; needsCopy = false; } if (reader.isReader) { reader.setModel(me.model); } else { if (needsCopy) { reader = Ext.apply({}, reader); } Ext.applyIf(reader, { proxy: me, model: me.model, type : me.defaultReaderType }); reader = Ext.createByAlias('reader.' + reader.type, reader); } if (reader !== current && reader.onMetaChange) { reader.onMetaChange = Ext.Function.createSequence(reader.onMetaChange, this.onMetaChange, this); } me.reader = reader; return me.reader; }
javascript
{ "resource": "" }
q61175
validation
function(writer) { var me = this, needsCopy = true; if (writer === undefined || typeof writer == 'string') { writer = { type: writer }; needsCopy = false; } if (!writer.isWriter) { if (needsCopy) { writer = Ext.apply({}, writer); } Ext.applyIf(writer, { model: me.model, type : me.defaultWriterType }); writer = Ext.createByAlias('writer.' + writer.type, writer); } me.writer = writer; return me.writer; }
javascript
{ "resource": "" }
q61176
getRequiredFilename
validation
function getRequiredFilename (name, callback) { var filepath = path.join(LOG_DIR, name); function getStats () { fs.stat(filepath, function (err, stats) { if (err) { callback(err, null); } else if (stats && stats.size >= MAX_FILE_SIZE) { createFile(); } else { callback(null, name); } }); } function createFile () { fs.writeFile(filepath, '[]', function (err) { if (err) { callback(err, null); } else { callback(null, name); } }); } fs.exists(filepath, function (exists) { if (exists) { getStats(); } else { createFile(); } }); }
javascript
{ "resource": "" }
q61177
getWriteFunction
validation
function getWriteFunction(log) { return function writeLogFile (name, qcb) { var dir = path.join(LOG_DIR, name); function readFile (cb) { fs.readFile(dir, cb); } function updateLogs (logs, cb) { logs.push(log.toJSON()); cb(null, logs); } function writeFile (str, cb) { fs.writeFile(dir, str, cb); } async.waterfall([ readFile, safejson.parse, updateLogs, safejson.stringify, writeFile ], qcb); }; }
javascript
{ "resource": "" }
q61178
getLogsObject
validation
function getLogsObject (name, callback) { fs.readFile(path.join(LOG_DIR, name), function (err, data) { if (err) { return callback(err, null); } safejson.parse(data, function (err, logArray) { if (err) { return callback(err, null); } callback(null, { logs: logArray }); }); }); }
javascript
{ "resource": "" }
q61179
deleteFile
validation
function deleteFile(name, callback) { fs.unlink(path.join(LOG_DIR, name), callback); }
javascript
{ "resource": "" }
q61180
validation
function () { this.port = DEFAULT_STUBBATTI_PORT; this.app = express(); this.console = global.console; var stubbatti = this; this.app[KILL_METHOD](KILL_PATH, function (req, res) { res.set('Connection', 'close'); res.end(); stubbatti.stop(); }); }
javascript
{ "resource": "" }
q61181
bravojs_print
validation
function bravojs_print() { var output=""; var i; var stdout; for (i=0; i < arguments.length; i++) output += arguments[i] + (i===arguments.length - 1 ? "" : " "); output.replace(/\t/, " "); if (typeof window.document != "undefined" && (stdout = window.document.getElementById('stdout'))) { output += "\n"; if (typeof stdout.value !== "undefined") { stdout.value += output; if (stdout.focus) stdout.focus(); if (stdout.tagName === "TEXTAREA") stdout.scrollTop = stdout.scrollHeight; } else { if (typeof stdout.innerText !== "undefined") { stdout.innerText = stdout.innerText.slice(0,-1) + output + " "; /* IE normalizes trailing newlines away */ } else stdout.textContent += output; } } else if (typeof console === "object" && console.print) { console.print(output); } else if (typeof console === "object" && console.log) { console.log(output); } // WebWorker else if (typeof importScripts === "function" && typeof postMessage === "function") { postMessage({type: "log", data: output}); } else alert(" * BravoJS stdout: " + output); }
javascript
{ "resource": "" }
q61182
Setting
validation
function Setting(settingSpec, settings) { this._settings = settings; Object.keys(settingSpec).forEach(function(key) { this[key] = settingSpec[key]; }, this); this.type = types.getType(this.type); if (this.type == null) { throw new Error('In ' + this.name + ': can\'t find type for: ' + JSON.stringify(settingSpec.type)); } if (!this.name) { throw new Error('Setting.name == undefined. Ignoring.', this); } if (!this.defaultValue === undefined) { throw new Error('Setting.defaultValue == undefined', this); } if (this.onChange) { this.on('change', this.onChange.bind(this)) } this.set(this.defaultValue); }
javascript
{ "resource": "" }
q61183
validation
function() { var reply = []; this.getSettingNames().forEach(function(setting) { reply.push({ 'key': setting, 'value': this.getSetting(setting).get() }); }, this); return reply; }
javascript
{ "resource": "" }
q61184
validation
function(data) { // We iterate over data rather than keys so we don't forget values // which don't have a setting yet. for (var key in data) { if (data.hasOwnProperty(key)) { var setting = this._settings[key]; if (setting) { var value = setting.type.parse(data[key]); this.set(key, value); } else { this.set(key, data[key]); } } } }
javascript
{ "resource": "" }
q61185
validation
function() { return this.getSettingNames().map(function(key) { return this._settings[key].type.stringify(this.get(key)); }.bind(this)); }
javascript
{ "resource": "" }
q61186
validation
function(statuses) { var combined = Status.VALID; for (var i = 0; i < statuses.length; i++) { if (statuses[i].valueOf() > combined.valueOf()) { combined = statuses[i]; } } return combined; }
javascript
{ "resource": "" }
q61187
defaultArgsProvider
validation
function defaultArgsProvider(request, callback) { var args = request.args, params = request.command.params; for (var i = 0; i < params.length; i++) { var param = params[i]; // If the parameter is already valid, then don't ask for it anymore. if (request.getParamStatus(param) != Status.VALID || // Ask for optional parameters as well. param.defaultValue === null) { var paramPrompt = param.description; if (param.defaultValue === null) { paramPrompt += " (optional)"; } var value = prompt(paramPrompt, param.defaultValue || ""); // No value but required -> nope. if (!value) { callback(); return; } else { args[param.name] = value; } } } callback(); }
javascript
{ "resource": "" }
q61188
execute
validation
function execute() { command.exec(env, request.args, request); // If the request isn't asnync and isn't done, then make it done. if (!request.isAsync && !request.isDone) { request.done(); } }
javascript
{ "resource": "" }
q61189
consume_doctype_or_comment
validation
function consume_doctype_or_comment (proc_stack) { let html = "<!"; proc_stack.tSkip(2); html += proc_stack.tAcceptUntil(">") + proc_stack.tAccept(); return html; }
javascript
{ "resource": "" }
q61190
consume_opening_or_closing_tag
validation
function consume_opening_or_closing_tag (proc_stack) { proc_stack.tSkip(); let is_closing = proc_stack.tSkipIf("/"); let tag_name = proc_stack.tAcceptUntilSet(TAG_NAME_DELIMITER).toLocaleLowerCase(); if (!/^[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*)?$/.test(tag_name)) { throw new SyntaxError(`Invalid HTML tag name "${tag_name}"`); } if (!is_closing && /^zc-/.test(tag_name)) { return consume_directive_tag(proc_stack, tag_name); } let parts = []; // Parts are needed for attribute value directives let html = "<" + (is_closing ? "/" : "") + tag_name; let done = false; while (!done) { html += proc_stack.tAcceptUntilSet(ATTR_VAL_START_OR_TAG_END_DELIMITER); let c = proc_stack.tAccept(); html += c; switch (c) { case "\"": parts.push(html); Array.prototype.push.apply(parts, consume_char_data_with_entity_directives(proc_stack, false, "\"")); html = proc_stack.tAccept(); break; case ">": done = true; break; default: throw new Error(`INTERR Invalid char after ATTR_VAL_START_OR_TAG_END_DELIMITER`); } } parts.push(html); return parts; }
javascript
{ "resource": "" }
q61191
consume_directive_entity
validation
function consume_directive_entity (proc_stack) { let pos = proc_stack._tGetNPos(); proc_stack.tSkip(4); let directive_name = proc_stack.tAcceptUntil("("); proc_stack.tSkip(); let raw_args = {}; do { proc_stack.tSkipWhile(WHITESPACE); if (proc_stack.tPeek() == ")") { break; } let arg_name = proc_stack.tAcceptUntil("="); proc_stack.tSkip(); raw_args[arg_name] = consume_char_data_with_entity_directives(proc_stack, true, ",", ")"); } while (proc_stack.tSkipIf(",")); if (!proc_stack.tSkipIf(")")) { throw new SyntaxError(`HTML directive entity is missing closing parenthesis`); } proc_stack.tSkipIf(";"); return new DirectiveExpr(proc_stack, pos, directive_name, raw_args); }
javascript
{ "resource": "" }
q61192
validation
function (method, path, cb) { http.request({hostname: DEFAULT_HOST, port: DEFAULT_PORT, path: path, method: method}, function (res) { res.pipe(concat({encoding: 'string'}, function (data) { cb(data, res.headers, res.statusCode); })); }).end(); }
javascript
{ "resource": "" }
q61193
init
validation
function init() { SXE.initElementDialog('del'); if (SXE.currentAction == "update") { setFormValue('datetime', tinyMCEPopup.editor.dom.getAttrib(SXE.updateElement, 'datetime')); setFormValue('cite', tinyMCEPopup.editor.dom.getAttrib(SXE.updateElement, 'cite')); SXE.showRemoveButton(); } }
javascript
{ "resource": "" }
q61194
validation
function() { var me = this, obj = me.getStorageObject(), ids = me.getIds(), len = ids.length, i; //remove all the records for (i = 0; i < len; i++) { obj.removeItem(me.getRecordKey(ids[i])); } //remove the supporting objects obj.removeItem(me.getRecordCounterKey()); obj.removeItem(me.getTreeKey()); obj.removeItem(me.id); // clear the cache me.cache = {}; }
javascript
{ "resource": "" }
q61195
validation
function(packageName, version) { Ext.versions[packageName] = new Version(version); Ext.lastRegisteredVersion = Ext.versions[packageName]; return this; }
javascript
{ "resource": "" }
q61196
validation
function(packageName, since, closure, scope) { if (Version.compare(Ext.getVersion(packageName), since) < 1) { closure.call(scope); } }
javascript
{ "resource": "" }
q61197
setFromObject
validation
function setFromObject(object) { Object.keys(object).forEach((name) => { options[name] = object[name]; }); }
javascript
{ "resource": "" }
q61198
addOptions
validation
function addOptions(flags) { Object.keys(options).forEach(function(name) { var dashedName = toDashCase(name); if ((name in parseOptions) && (name in transformOptions)) { flags.option('--' + dashedName + ' [true|false|parse]', descriptions[name]); flags.on(dashedName, (value) => setOption(dashedName, value)); } // If the option value is null then it's not a boolean option and should // be added separately. else if (options[name] !== null) { flags.option('--' + dashedName, descriptions[name]); flags.on(dashedName, () => setOption(dashedName, true)); } }); flags.option('--referrer <name>', 'Bracket output code with System.referrerName=<name>', (name) => { setOption('referrer', name); return name; }); flags.option('--type-assertion-module <path>', 'Absolute path to the type assertion module.', (path) => { setOption('type-assertion-module', path); return path; }); flags.option('--script <fileName>', 'Parse as Script (must precede modules)', (fileName) => { options.scripts.push(fileName); }); }
javascript
{ "resource": "" }
q61199
addFeatureOption
validation
function addFeatureOption(name, kind) { if (kind === EXPERIMENTAL) experimentalOptions[name] = true; Object.defineProperty(parseOptions, name, { get: function() { return !!options[name]; }, enumerable: true, configurable: true }); Object.defineProperty(transformOptions, name, { get: function() { var v = options[name]; if (v === 'parse') return false; return v; }, enumerable: true, configurable: true }); var defaultValue = options[name] || kind === ON_BY_DEFAULT; options[name] = defaultValue; defaultValues[name] = defaultValue; }
javascript
{ "resource": "" }