_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q61000
TripCase
validation
function TripCase (options) { if (!options || !options.email || !options.password) throw 'Missing required options'; this.email = options.email; this.password = options.password; this.session = null; return this; }
javascript
{ "resource": "" }
q61001
trmv
validation
function trmv (A, x, isLower) { var dot = blas1.dot; var n = A.shape[1]; var i = 0; if (isLower) { for (i = n - 1; i >= 0; i--) { x.set(i, dot(A.pick(i, null).hi(i + 1), x.hi(i + 1))); } } else { for (i = 0; i < n; i++) { x.set(i, dot(A.pick(i, null).lo(i), x.lo(i))); } } return true; }
javascript
{ "resource": "" }
q61002
validation
function () { this.TYPE = { TAG: 'tag', USER: 'user' } this.urlRules = { tag: { rule: /((https?):\/\/)?(www\.)?instagram.com\/explore\/tags\/([\w_]+)/mi }, user: { rule: /((https?):\/\/)?(www\.)?instagram\.com\/([\w._]+)\/?/mi } } }
javascript
{ "resource": "" }
q61003
siteAppsAdmin
validation
function siteAppsAdmin(req, res, cb) { var { themeData } = res.locals; const { apps, getInheritTheme, themes } = req.app.locals; if (!themeData.managingSite) cb(); else { // provide function for apps/themes to add pages res.locals.addPages = function(appPages) { addPages(req, res, appPages); } let mgSiteApps = themeData.authSites[themeData.managingSite].zsApps; if (mgSiteApps) { req.app.debug('Site has apps %o', mgSiteApps); // iterate managingSite apps _.forEach(mgSiteApps, function(key) { if (apps[key] && apps[key].main) { let main = require(`${apps[key].path}/${apps[key].main}`); // check if middleware for admin is provided if (main.admin) { main.admin(req, res); } } }); } let mgSiteTheme = themeData.authSites[themeData.managingSite].zsTheme; if (mgSiteTheme) { let themeTree = getInheritTheme(mgSiteTheme); // iterate managingSite themetree _.forEach(themeTree, function(v, key) { if (themes[key] && themes[key].main) { let main = require(`${themes[key].path}/${themes[key].main}`); // check if middleware for admin is provided if (main.admin) { main.admin(req, res); } } }); } cb(); } }
javascript
{ "resource": "" }
q61004
sanitize
validation
function sanitize(str) { const symbolMap = { '\'': '\\textquotesingle{}', '"': '\\textquotedbl{}', '`': '\\textasciigrave{}', '^': '\\textasciicircum{}', '~': '\\textasciitilde{}', '<': '\\textless{}', '>': '\\textgreater{}', '|': '\\textbar{}', '\\': '\\textbackslash{}', '{': '\\{', '}': '\\}', '$': '\\$', '&': '\\&', '#': '\\#', '_': '\\_', '%': '\\%' } return Array.from(str) .map(char => symbolMap[char] || char) .join('') }
javascript
{ "resource": "" }
q61005
execute
validation
function execute(target, prop, ...args) { return _.isFunction(target[prop]) ? target[prop](...args) : target[prop]; }
javascript
{ "resource": "" }
q61006
loadUsrInfo
validation
function loadUsrInfo(token, app, zlSite, next) { app.models.zlUser.findById(token.userId, (err, usr) => { if (err) next(err); else if (usr) { zlSite.user = _.cloneDeep(usr); if (!zlSite.user.usrPhoto && zlSite.user.email) { // use gravatar let graHash = md5(zlSite.user.email.toLowerCase()); zlSite.user.usrPhoto = `https://www.gravatar.com/avatar/${graHash}?s=100&d=mm` } next(); } else { // user must no longer exist next(); } }); }
javascript
{ "resource": "" }
q61007
metaData
validation
function metaData(req, res, next) { var zlSite = res.locals.zlSite; // favicons if (zlSite.zsOptions && zlSite.zsOptions.favicons) { res.locals.favicons = zlSite.zsOptions.favicons; } // title res.locals.title = zlSite.zsName; // robots: default for seo (themes like Admin may set beforehand) if (!res.locals.robots) res.locals.robots = 'INDEX, FOLLOW'; next(); }
javascript
{ "resource": "" }
q61008
trsv
validation
function trsv (A, x, isLower) { var dot = blas1.dot; var n = A.shape[1]; var i = 0; if (isLower) { x.set(0, x.get(0) / A.get(0, 0)); for (i = 1; i < n; i++) { x.set(i, (x.get(i) - dot(A.pick(i, null).hi(i), x.hi(i))) / A.get(i, i)); } } else { x.set(n - 1, x.get(n - 1) / A.get(n - 1, n - 1)); for (i = n - 2; i >= 0; i--) { x.set(i, (x.get(i) - dot(A.pick(i, null).lo(i + 1), x.lo(i + 1))) / A.get(i, i)); } } return true; }
javascript
{ "resource": "" }
q61009
validation
function(scContent) { if (_.isEmpty(scContent['data'])) { return; } let columns = []; if (scContent['columns']) { // already have columns columns = scContent['columns']; } else { // make columns headers from data let model = this._modelInfo(scContent['forModel']); _.forEach(_.head(scContent['data']), function(value, key) { if (!model.prop[key] || model.prop[key]['id']) { // no need to display Id column OR column not from model (programatic) return; } columns.push({ title: key.replace(model.ns, ''), data: key }); }); } return columns; }
javascript
{ "resource": "" }
q61010
validation
function(modelData, scContent) { if (scContent['treeData']) { // this data must be represented as hierarchical data (tree) let parentColumn = scContent.treeData.parentColumn; let rootParent = (scContent.treeData['root'])?scContent.treeData['root']:0; let childColumn = scContent.idColumn; // keep track of deepest level scContent.treeData['deepestLevel'] = 0; let orderStart = 1; function sortData(all, top, data, sort, level) { if (level > scContent.treeData['deepestLevel']) { scContent.treeData['deepestLevel'] = level; } _.forEach(_.filter(all, [parentColumn, top]), function(val) { val = val.toJSON(); val['treeDisplayOrder'] = sort; val['treeLevel'] = level; data.push(val); // check if have children if (_.find(all, [parentColumn, val[childColumn]])) { data = sortData(all, val[childColumn], data, orderStart, (level + 1)); } sort++; }); return data; } return sortData(modelData, rootParent, [], orderStart, 0); } else { var data = []; _.forEach(modelData, function(val) { data.push(val.toJSON()); }); return data; } }
javascript
{ "resource": "" }
q61011
validation
function(res, scContent, post, cb) { let model = this._modelInfo(scContent['forModel']); // get list of expected model props let fields = this.makeFormFields(res, scContent); let data = {}; let where = null; _.forEach(fields, function(val) { if (val.isId) { if (post[val.name]) where = {[val.name]: post[val.name]} } else if (val.name in post) { if (val.embedIn) { data[val.embedIn] = Object.assign({}, data[val.embedIn], {[val.name]: post[val.name]}); } else data[val.name] = post[val.name]; } }); // add forceVals if (scContent.forceVals) { _.forEach(scContent.forceVals, function(val, key) { data[key] = val; }); } // save data if (where) { // update existing model.model.upsertWithWhere(where, data, (err, inst) => { cb(err, inst); }); } else { model.model.create(data, (err, inst) => { cb(err, inst); }); } }
javascript
{ "resource": "" }
q61012
validation
function(forModel) { let model = { model: app.models[forModel], prop: app.models[forModel].definition.properties, settings: app.models[forModel].settings, meta: app.models[forModel].settings.zlMeta, ns: '' }; if (model.meta && model.meta['Namespace']) { model.ns = model.meta['Namespace']; } return model; }
javascript
{ "resource": "" }
q61013
validation
function (modMeth, filter, cb = (err, val, cb) => cb()) { this.promises.push( new Promise((resolve, reject) => { modMeth(...filter, (err, val) => { cb(err, val, resolve); }); })); }
javascript
{ "resource": "" }
q61014
_embedGetter
validation
function _embedGetter(self, fields, embedGetter, key) { let allOpts = []; self.res.locals.emiter.emit('get-options', embedGetter, allOpts); if (allOpts) { allOpts.forEach(function(obj) { obj.embedIn = key; }); fields.push(...allOpts); } }
javascript
{ "resource": "" }
q61015
shouldFetchContents
validation
function shouldFetchContents(state, scsId) { const page = state.pages[scsId]; if (page.contents.length === 0) { return true } else if (page.isFetching) { return false } else { return page.didInvalidate } }
javascript
{ "resource": "" }
q61016
bundleServer
validation
function bundleServer(app, promises) { var { themes, config } = app.locals; // iterate all themes _.forEach(themes, function(val, theme) { promises.push( new Promise(function(resolve) { // make bundle config for server-renderer readyBundle(app, '', theme, resolve, (wpConfig, sitePath, appBundled, done) => { // if wpConfig is empty that means packages was not changed, so skip if (!wpConfig) return; // Webpack specific for bundled file let conf = { output: { filename: `${config.contentPath}/build/${theme}/server-render.js` }, entry: `${themes[appBundled].path}/${themes[appBundled].zealderConfig.serverRenderFile}` }; var webpackConfig = merge(webpackServer, wpConfig, conf); webpack(webpackConfig, (err, stats) => { if (err) throw new Error(err.stack || err); const info = stats.toJson(); if (stats.hasErrors()) app.error(info.errors); done(); }); }); })); }); }
javascript
{ "resource": "" }
q61017
validation
function(active, suppressEvent){ if(this.active != active){ this.active = active; if (suppressEvent !== true) { this.fireEvent(active ? 'activate' : 'deactivate', this); } } }
javascript
{ "resource": "" }
q61018
validation
function(dataview) { /** * @property dataview * @type Ext.view.View * The DataView bound to this instance */ this.dataview = dataview; dataview.mon(dataview, { beforecontainerclick: this.cancelClick, scope: this, render: { fn: this.onRender, scope: this, single: true } }); }
javascript
{ "resource": "" }
q61019
hmacSign
validation
function hmacSign (input, algorithm, secret) { return crypto.createHmac(algorithm, secret).update(input).digest('base64') }
javascript
{ "resource": "" }
q61020
sign
validation
function sign (input, algorithm, secret) { const alg = algorithmMap[algorithm] if (!alg) { throw new Error(errorMap['002'].message) } const type = typeMap[algorithm] let signature switch (type) { case 'hmac': signature = hmacSign(input, alg, secret) break case 'sign': signature = rsaSign(input, alg, secret) break default: signature = hmacSign(input, alg, secret) break } return signature }
javascript
{ "resource": "" }
q61021
hmacVerify
validation
function hmacVerify (input, algorithm, secret, signature) { try { const verify = signature === hmacSign(input, algorithm, secret) if (!verify) { errorMap['006'].message = 'Unvalid secret for hmac verify, signature verification failed' errorMap['006'].error = new Error(errorMap['006'].message) } return verify } catch (e) { errorMap['006'].message = 'Exception error in hamc verify, signature verification failed' errorMap['006'].error = e return false } }
javascript
{ "resource": "" }
q61022
rsaVerify
validation
function rsaVerify (input, algorithm, publicSecret, signature) { try { // verify with rsa_public_key.pem const verify = crypto.createVerify(algorithm).update(input).verify( publicSecret, base64URLUnescape(signature), 'base64' ) if (!verify) { errorMap['006'].message = 'Unvalid public secret for rsa verify, signature verification failed' errorMap['006'].error = new Error(errorMap['006'].message) } return verify } catch (e) { errorMap['006'].message = 'Exception error in rsa verify, signature verification failed' errorMap['006'].error = e return false } }
javascript
{ "resource": "" }
q61023
verify
validation
function verify (input, algorithm, secret, signature) { const alg = algorithmMap[algorithm] if (!alg) { errorMap['006'].message = 'Algorithm not recognized, signature verification failed' errorMap['006'].message = new Error(errorMap['006'].message) return false } const type = typeMap[algorithm] switch (type) { case 'hmac': return hmacVerify(input, alg, secret, signature) case 'sign': return rsaVerify(input, alg, secret, signature) default: return hmacVerify(input, alg, secret, signature) } }
javascript
{ "resource": "" }
q61024
getType
validation
function getType(v) { var result = ''; if (v == null) { result = v + ''; } else { result = typeof v; if (result == 'object' || result == 'function') { result = illa.classByType[illa.classByType.toString.call(v)] || 'object'; } } return result; }
javascript
{ "resource": "" }
q61025
addProps
validation
function addProps(obj) { var rest = []; for (var _i = 1; _i < arguments.length; _i++) { rest[_i - 1] = arguments[_i]; } for (var i = 0, n = rest.length; i < n; i += 2) { if (illa.isString(rest[i])) { obj[rest[i]] = rest[i + 1]; } } return obj; }
javascript
{ "resource": "" }
q61026
validation
function(type) { var me = this, oldType = me.type; me.type = type; if (me.rendered) { if (oldType) { me.toolEl.removeCls(me.baseCls + '-' + oldType); } me.toolEl.addCls(me.baseCls + '-' + type); } else { me.renderData.type = type; } return me; }
javascript
{ "resource": "" }
q61027
validation
function () { var me = this, locked = me.lockable.lockedGrid.headerCt.getColumnsState(), normal = me.lockable.normalGrid.headerCt.getColumnsState(); return locked.concat(normal); }
javascript
{ "resource": "" }
q61028
it
validation
function it(type, value) { var i, t; if (type === '(color)' || type === '(range)') { t = {type: type}; } else if (type === '(punctuator)' || (type === '(identifier)' && is_own(syntax, value))) { t = syntax[value] || syntax['(error)']; } else { t = syntax[type]; } t = Object.create(t); if (type === '(string)' || type === '(range)') { if (jx.test(value)) { warningAt("Script URL.", line, from); } } if (type === '(identifier)') { t.identifier = true; if (value === '__iterator__' || value === '__proto__') { errorAt("Reserved name '{a}'.", line, from, value); } else if (option.nomen && (value.charAt(0) === '_' || value.charAt(value.length - 1) === '_')) { warningAt("Unexpected {a} in '{b}'.", line, from, "dangling '_'", value); } } t.value = value; t.line = line; t.character = character; t.from = from; i = t.id; if (i !== '(endline)') { prereg = i && (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) || i === 'return'); } return t; }
javascript
{ "resource": "" }
q61029
advance
validation
function advance(id, t) { switch (token.id) { case '(number)': if (nexttoken.id === '.') { warning( "A dot following a number can be confused with a decimal point.", token); } break; case '-': if (nexttoken.id === '-' || nexttoken.id === '--') { warning("Confusing minusses."); } break; case '+': if (nexttoken.id === '+' || nexttoken.id === '++') { warning("Confusing plusses."); } break; } if (token.type === '(string)' || token.identifier) { anonname = token.value; } if (id && nexttoken.id !== id) { if (t) { if (nexttoken.id === '(end)') { warning("Unmatched '{a}'.", t, t.id); } else { warning( "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", nexttoken, id, t.id, t.line, nexttoken.value); } } else if (nexttoken.type !== '(identifier)' || nexttoken.value !== id) { warning("Expected '{a}' and instead saw '{b}'.", nexttoken, id, nexttoken.value); } } prevtoken = token; token = nexttoken; for (;;) { nexttoken = lookahead.shift() || lex.token(); if (nexttoken.id === '(end)' || nexttoken.id === '(error)') { return; } if (nexttoken.type === 'special') { doOption(); } else { if (nexttoken.id !== '(endline)') { break; } } } }
javascript
{ "resource": "" }
q61030
doBegin
validation
function doBegin(n) { if (n !== 'html' && !option.fragment) { if (n === 'div' && option.adsafe) { error("ADSAFE: Use the fragment option."); } else { error("Expected '{a}' and instead saw '{b}'.", token, 'html', n); } } if (option.adsafe) { if (n === 'html') { error( "Currently, ADsafe does not operate on whole HTML documents. It operates on <div> fragments and .js files.", token); } if (option.fragment) { if (n !== 'div') { error("ADsafe violation: Wrap the widget in a div.", token); } } else { error("Use the fragment option.", token); } } option.browser = true; assume(); }
javascript
{ "resource": "" }
q61031
validation
function(records) { var ghost = this.createGhost(records), store = ghost.store; store.removeAll(); store.add(records); return ghost.getEl(); }
javascript
{ "resource": "" }
q61032
visibilityChange
validation
function visibilityChange(ev) { // {{{2 var that = this; if (this.visibilityTimeout) { clearTimeout(this.visibilityTimeout); this.visibilityTimeout = undefined; } switch (document.visibilityState) { case 'hidden': // console.log('DOCUMENT HIDE'); // Wait 10 seconds before peer disconnect. this.visibilityTimeout = setTimeout(function() { that.visibilityTimeout = undefined; O.gw.disconnect(); }, 10 * 1000); return; case 'visible': // console.log('DOCUMENT SHOW'); if (! O.gw.isConnected()) { O.gw.connect(); } return; } }
javascript
{ "resource": "" }
q61033
validation
function (key, done) { var val = null; if(cache.hasOwnProperty(key)) { val = cache[key]; } return done(null, val); }
javascript
{ "resource": "" }
q61034
_returnMap
validation
function _returnMap(callback, file, created){ if(typeof file === 'string'){ var map = foldermap.mapSync(file); Object.defineProperty(map, '_created', {value:created}); } else { var map = {}; for(var i in file){ map[i] = foldermap.mapSync(file[i]); Object.defineProperty(map[i], '_created', {value:created}); } } callback(null, map); }
javascript
{ "resource": "" }
q61035
readyCb
validation
function readyCb(cb){ //if(opened) return //opened = true if(exports.slowGet){//special debug hook - specifies millisecond delay for testing setTimeout(function(){ cb(undefined, api.getView(viewId, historicalKey)) },exports.slowGet) }else{ var viewObj = api.getView(viewId, historicalKey) if(!viewObj) _.errout('could not find view object: ' + viewId) cb(undefined, viewObj) } }
javascript
{ "resource": "" }
q61036
fileStatus
validation
function fileStatus(prev, stat, filename, dir, fn) { var fullname = path.join(dir, filename) // is a deleted file? /*if (!fs.existsSync(fullname)) { return fn && fn(null, { stats: undefined, code: -1}); }*/ // is a file added? if (prev === undefined || prev === null) { fn && fn(null, { stats: {mtime: stat.mtime, size: stat.size}, code: 1}); return; } var mtimeChange = stat.mtime.valueOf() != prev.stats.mtime.valueOf(); var sizeChange = stat.size != prev.stats.size; // has changes ? if (!mtimeChange && !sizeChange) { return fn && fn(null, { stats: {mtime: stat.mtime, size: stat.size}, code: 0}); } // the file has change fn && fn(null, { stats: {mtime: stat.mtime, size: stat.size}, code: 2}); }
javascript
{ "resource": "" }
q61037
getFiles
validation
function getFiles(dir, pattern, fn) { if ("function" === typeof pattern) { fn = pattern; pattern = undefined; } pattern = pattern || /.*/ig; fs.readdir(dir, function(err, files){ if (err) return fn && fn(err); async.map( files, function(f, cb) { fs.stat(path.join(dir, f), function(err, stats){ if (err) return cb && cb(err); cb && cb(null, { filename: f, stats: stats }) }) }, function(err, stats){ if (err) return fn && fn(err); var fstats = stats.filter(function(f){ return f.stats.isFile() && pattern.test(f.filename); }); fn && fn(null, fstats); }); }); }
javascript
{ "resource": "" }
q61038
validation
function(key, value) { // if we have no value, it means we need to get the key from the object if (value === undefined) { value = key; key = this.getKey(value); } return [key, value]; }
javascript
{ "resource": "" }
q61039
validation
function(key) { var me = this, value; if (me.containsKey(key)) { value = me.map[key]; delete me.map[key]; --me.length; if (me.hasListeners.remove) { me.fireEvent('remove', me, key, value); } return true; } return false; }
javascript
{ "resource": "" }
q61040
validation
function(fn, scope) { // copy items so they may be removed during iteration. var items = Ext.apply({}, this.map), key, length = this.length; scope = scope || this; for (key in items) { if (items.hasOwnProperty(key)) { if (fn.call(scope, key, items[key], length) === false) { break; } } } return this; }
javascript
{ "resource": "" }
q61041
validation
function() { var hash = new this.self(this.initialConfig), map = this.map, key; hash.suspendEvents(); for (key in map) { if (map.hasOwnProperty(key)) { hash.add(key, map[key]); } } hash.resumeEvents(); return hash; }
javascript
{ "resource": "" }
q61042
validation
function (astList, context, callback) { var retval = new Array(astList.length); asyncEach(astList, function (ast, i, done) { run(ast, context, function (err, val) { if (err) { callback(err); } else { retval[i] = val; done(); } }); }, callback, null, retval); }
javascript
{ "resource": "" }
q61043
validation
function (astList, context, callback) { var retval = new Array(2); var i = 0; var getOpArgs2_callback = function (err, val) { if (err) { callback(err); } else { retval[i] = val; i++; if (i >= 2) callback(null, retval); } }; run(astList[1], context, getOpArgs2_callback); run(astList[2], context, getOpArgs2_callback); }
javascript
{ "resource": "" }
q61044
peekTokenNoLineTerminator
validation
function peekTokenNoLineTerminator() { var t = peekToken(); var start = lastToken.location.end.offset; var end = t.location.start.offset; for (var i = start; i < end; i++) { var code = input.charCodeAt(i); if (isLineTerminator(code)) return null; // If we have a block comment we need to skip it since new lines inside // the comment are not significant. if (code === 47) { // '/' code = input.charCodeAt(++i); // End of line comments always mean a new line is present. if (code === 47) // '/' return null; i = input.indexOf('*/', i) + 2; } } return t; }
javascript
{ "resource": "" }
q61045
validation
function () { // create new instance based on class meta data var instance = _.clone(modelView) // get number of args var numArgs = arguments.length // if function is passed a single object then these arguments will // be passed directly to the view instance func if (numArgs === 1 && typeof arguments[0] === 'object') { instance.args = arguments[0] } // otherwise create args as empty object else { instance.args = {} // if there are arguments then they must be string property names if (numArgs > 0) { // create properties instance.args.properties = [] // check that all args are strings for (var i=0; i < numArgs; i++) { assert(typeof arguments[i] === 'string', 'invalid argument '+arguments[i]) // add argument to list of properties instance.args.properties[i] = arguments[i] } } } // set modelViewInstanceId on instance setModelViewInstanceId(instance) // set class properties instance.class = 'ImmutableCoreModelViewInstance' instance.ImmutableCoreModelViewInstance = true // return instance object return instance }
javascript
{ "resource": "" }
q61046
CI
validation
function CI(pull_request, branch, build_number, builder) { this.pull_request = pull_request; this.branch = branch; this.build_number = build_number; this.builder = builder; this.GetVersion = GetVersion; this.GetPullRequest = GetPullRequest; this.PublishGitTag = PublishGitTag; this.MergeDownstream = MergeDownstream; }
javascript
{ "resource": "" }
q61047
validation
function(table, config) { config = Ext.apply({}, config); table = this.table = Ext.get(table); var configFields = config.fields || [], configColumns = config.columns || [], fields = [], cols = [], headers = table.query("thead th"), i = 0, len = headers.length, data = table.dom, width, height, store, col, text, name; for (; i < len; ++i) { col = headers[i]; text = col.innerHTML; name = 'tcol-' + i; fields.push(Ext.applyIf(configFields[i] || {}, { name: name, mapping: 'td:nth(' + (i + 1) + ')/@innerHTML' })); cols.push(Ext.applyIf(configColumns[i] || {}, { text: text, dataIndex: name, width: col.offsetWidth, tooltip: col.title, sortable: true })); } if (config.width) { width = config.width; } else { width = table.getWidth() + 1; } if (config.height) { height = config.height; } Ext.applyIf(config, { store: { data: data, fields: fields, proxy: { type: 'memory', reader: { record: 'tbody tr', type: 'xml' } } }, columns: cols, width: width, height: height }); this.callParent([config]); if (config.remove !== false) { // Don't use table.remove() as that destroys the row/cell data in the table in // IE6-7 so it cannot be read by the data reader. data.parentNode.removeChild(data); } }
javascript
{ "resource": "" }
q61048
weight
validation
function weight(word) { return HAMMING_TABLE[ (word >> 0x00) & 0xF ] + HAMMING_TABLE[ (word >> 0x04) & 0xF ] + HAMMING_TABLE[ (word >> 0x08) & 0xF ] + HAMMING_TABLE[ (word >> 0x0C) & 0xF ] + HAMMING_TABLE[ (word >> 0x10) & 0xF ] + HAMMING_TABLE[ (word >> 0x14) & 0xF ] + HAMMING_TABLE[ (word >> 0x18) & 0xF ] + HAMMING_TABLE[ (word >> 0x1C) & 0xF ]; }
javascript
{ "resource": "" }
q61049
highest
validation
function highest(word) { word |= word >> 1; word |= word >> 2; word |= word >> 4; word |= word >> 8; word |= word >> 16; // We have to use a zero-fill right shift here, or the word will overflow when // the highest bit is in the leftmost position. return position((word >>> 1) + 1); }
javascript
{ "resource": "" }
q61050
onSelection
validation
function onSelection(ev) { // {{{2 if (ev) { ev.stopPropagation(); ev.stopImmediatePropagation(); ev.preventDefault(); } setTimeout(function() { if (window.getSelection) { if (window.getSelection().empty) { // Chrome window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { // Firefox window.getSelection().removeAllRanges(); } } else if (document.selection) { // IE? document.selection.empty(); } }); return false; }
javascript
{ "resource": "" }
q61051
multiplyDuration
validation
function multiplyDuration(startDuration, multiplier) { if(!isFinite(multiplier) || multiplier <= 0) { throw new Error('Invalid Multiplier'); } var newDuration = {}, hasTime = false, duration = ''; if(startDuration.getSeconds()) { newDuration.seconds = Math.round(startDuration.getSeconds()*multiplier); } if(startDuration.getMinutes()) { newDuration.minutes = Math.round(startDuration.getMinutes()*multiplier); } if(startDuration.getHours()) { newDuration.hours = Math.round(startDuration.getHours()*multiplier); } if(startDuration.getDays()) { newDuration.days = Math.round(startDuration.getDays()*multiplier); } if(startDuration.getMonths()) { newDuration.months = Math.round(startDuration.getMonths()*multiplier); } if(startDuration.getYears()) { newDuration.years = Math.round(startDuration.getYears()*multiplier); } if(newDuration.seconds) { hasTime = true; duration = newDuration.seconds+'S'+duration; } if(newDuration.minutes) { hasTime = true; duration = newDuration.minutes+'M'+duration; } if(newDuration.hours) { hasTime = true; duration = newDuration.hours+'H'+duration; } if(hasTime) { duration = 'T'+duration; } if(newDuration.days) { duration = newDuration.days+'D'+duration; } if(newDuration.months) { duration = newDuration.months+'M'+duration; } if(newDuration.years) { duration = newDuration.years+'Y'+duration; } if(!duration) { throw new Error('Invalid Duration Multiplier'); } return new Duration('P'+duration); }
javascript
{ "resource": "" }
q61052
zipDates
validation
function zipDates(start, end) { if(start.month != undefined && end.month == undefined) { end.month = 1; } if(start.month == undefined && end.month != undefined) { start.month = 1; } if(start.day != undefined && end.day == undefined) { end.day = 1; } if(start.day == undefined && end.day != undefined) { start.day = 1; } if(start.hours != undefined && end.hours == undefined) { end.hours = 0; } if(start.hours == undefined && end.hours != undefined) { start.hours = 0; } if(start.minutes != undefined && end.minutes == undefined) { end.minutes = 0; } if(start.minutes == undefined && end.minutes != undefined) { start.minutes = 0; } if(start.seconds != undefined && end.seconds == undefined) { end.seconds = 0; } if(start.seconds == undefined && end.seconds != undefined) { start.seconds = 0; } }
javascript
{ "resource": "" }
q61053
zipDuration
validation
function zipDuration(date, duration) { var toSet = {}; if(duration.getSeconds()) { toSet = { seconds: true, minutes: true, hours: true, days: true, months: true }; } else if(duration.getMinutes()) { toSet = { minutes: true, hours: true, days: true, months: true }; } else if(duration.getHours()) { toSet = { hours: true, days: true, months: true }; } else if(duration.getDays()) { toSet = { days: true, months: true }; } else if(duration.getMonths()) { toSet = { months: true }; } else { return; } if(toSet.seconds && date.seconds == undefined) { date.seconds = 0; } if(toSet.minutes && date.minutes == undefined) { date.minutes = 0; } if(toSet.hours && date.hours == undefined) { date.hours = 0; } if(toSet.days && date.day == undefined) { date.day = 1; } if(toSet.months && date.month == undefined) { date.month = 1; } }
javascript
{ "resource": "" }
q61054
getObjFromDate
validation
function getObjFromDate(date, adjustTimezone) { var obj = { year: date.getYear(), month: date.getMonth(), day: date.getDay(), hours: date.getHours(), minutes: date.getMinutes(), seconds: date.getSeconds() } if(adjustTimezone) { if(obj.minutes != undefined && date.getTZMinutes() != undefined) { obj.minutes += date.getTZMinutes(); } if(obj.hours != undefined && date.getTZHours() != undefined) { obj.hours += date.getTZHours(); } } return obj; }
javascript
{ "resource": "" }
q61055
Range
validation
function Range(str) { var range = str; // If range starts with A, its approximate if(range.charAt(0) == 'A') { this._approximate = true; range = str.substr(1); } var parts = range.split('/'); if(parts.length != 2 || (!parts[0] && !parts[1])) { throw new Error('Invalid Date Range'); } if(parts[0]) { try { this.start = new Simple(parts[0]); } catch(e) { throw new Error(e.message+' in Range Start Date'); } } if(parts[1]) { if(parts[1].charAt(0) == 'P') { if(!this.start) { throw new Error('A Range may not end with a duration if missing a start date'); } try { this.duration = new Duration(parts[1]); } catch(e) { throw new Error(e.message+' in Range End Date'); } // Use duration and calculate end date this.end = GedUtil.addDuration(this.start, this.duration); } else { try { this.end = new Simple(parts[1]); } catch(e) { throw new Error(e.message+' in Range End Date'); } if(this.start) { this.duration = GedUtil.getDuration(this.start, this.end); } } } }
javascript
{ "resource": "" }
q61056
validation
function() { Ext.data.flash.BinaryXhr.flashPluginActive = true; Ext.data.flash.BinaryXhr.flashPlugin = document.getElementById("ext-flash-polyfill"); Ext.globalEvents.fireEvent("flashready"); // let all pending connections know }
javascript
{ "resource": "" }
q61057
validation
function(javascriptId, state, data) { var connection; // Identify the request this is for connection = this.liveConnections[Number(javascriptId)]; // Make sure its a native number if (connection) { connection.onFlashStateChange(state, data); } //<debug> else { Ext.warn.log("onFlashStateChange for unknown connection ID: " + javascriptId); } //</debug> }
javascript
{ "resource": "" }
q61058
validation
function (body) { var me = this; me.body = body; if (!Ext.data.flash.BinaryXhr.flashPluginActive) { Ext.globalEvents.addListener("flashready", me.onFlashReady, me); } else { this.onFlashReady(); } }
javascript
{ "resource": "" }
q61059
validation
function() { var me = this, req, status; me.javascriptId = Ext.data.flash.BinaryXhr.registerConnection(me); // Create the request object we're sending to flash req = { method: me.method, // ignored since we always POST binary data url: me.url, user: me.user, password: me.password, mimeType: me.mimeType, requestHeaders: me.requestHeaders, body: me.body, javascriptId: me.javascriptId }; status = Ext.data.flash.BinaryXhr.flashPlugin.postBinary(req); }
javascript
{ "resource": "" }
q61060
validation
function (state) { var me = this; if (me.readyState != state) { me.readyState = state; me.onreadystatechange(); } }
javascript
{ "resource": "" }
q61061
validation
function (data) { var me = this; // parse data and set up variables so that listeners can use this XHR this.status = data.status || 0; // we get back no response headers, so fake what we know: me.responseHeaders = {}; if (me.mimeType) { me.responseHeaders["content-type"] = me.mimeType; } if (data.reason == "complete") { // Transfer complete and data received this.responseBytes = data.data; me.responseHeaders["content-length"] = data.data.length; } else if (data.reason == "error" || data.reason == "securityError") { this.statusText = data.text; me.responseHeaders["content-length"] = 0; // we don't get the error response data } //<debug> else { Ext.Error.raise("Unkown reason code in data: " + data.reason); } //</debug> }
javascript
{ "resource": "" }
q61062
consume_string
validation
function consume_string (proc_stack) { let delim = proc_stack.tAccept(); let str = delim; let escaping = 0; let done = false; while (!done) { let c = proc_stack.tAccept(); if (c == "\\") { escaping ^= 1; } else { if (c == delim && !escaping) { done = true; } else if (c == "\r" || c == "\n") { if (!escaping) { throw new SyntaxError(`Unterminated JavaScript string`); } if (c == "\r" && proc_stack.tPeek() == "\n") { proc_stack.tSkip(); } } escaping = 0; } str += c; } return str; }
javascript
{ "resource": "" }
q61063
consume_template
validation
function consume_template (proc_stack) { let template = "`"; proc_stack.tSkip(1); let escaping = 0; let done = false; while (!done) { let c = proc_stack.tAccept(); if (c == "\\") { escaping ^= 1; } else { if (c == "`" && !escaping) { done = true; } escaping = 0; } template += c; } return template; }
javascript
{ "resource": "" }
q61064
HttpLog
validation
function HttpLog () { var args = arguer.apply(_constructorFormat, arguments); if (args instanceof Error) return httpLog(args); if (args.response instanceof Http.IncomingMessage && args.response.statusCode) return httpLog(args.response.statusCode, Http.STATUS_CODES[args.response.statusCode]); if (args.error instanceof HttpLog) return args.error; var log; if (args.error) { log = args.error; } else if (args.message !== undefined || (args.status !== undefined && args.data !== null) || args.data) { log = new Error(args.message); } else { return HttpLog.none; } log.__proto__ = HttpLog.prototype; if (args.status !== undefined) log.status = args.status; log.data = args.data || {}; return log; }
javascript
{ "resource": "" }
q61065
validation
function(animate){ var me = this; me.setVisible(!me.isVisible(), me.anim(animate)); return me; }
javascript
{ "resource": "" }
q61066
skipWhitespaceNodes
validation
function skipWhitespaceNodes(e, next) { while (e && (e.nodeType === 8 || (e.nodeType === 3 && /^[ \t\n\r]*$/.test(e.nodeValue)))) { e = next(e); } return e; }
javascript
{ "resource": "" }
q61067
createNewLi
validation
function createNewLi(ed, e) { if (isEnterWithoutShift(e) && isEndOfListItem()) { var node = ed.selection.getNode(); var li = ed.dom.create("li"); var parentLi = ed.dom.getParent(node, 'li'); ed.dom.insertAfter(li, parentLi); // Move caret to new list element. if (tinymce.isIE6 || tinymce.isIE7 || tinyMCE.isIE8) { // Removed this line since it would create an odd <&nbsp;> tag and placing the caret inside an empty LI is handled and should be handled by the selection logic //li.appendChild(ed.dom.create("&nbsp;")); // IE needs an element within the bullet point ed.selection.setCursorLocation(li, 1); } else { ed.selection.setCursorLocation(li, 0); } e.preventDefault(); } }
javascript
{ "resource": "" }
q61068
setCursorPositionToOriginalLi
validation
function setCursorPositionToOriginalLi(li) { var list = ed.dom.getParent(li, 'ol,ul'); if (list != null) { var lastLi = list.lastChild; // Removed this line since IE9 would report an DOM character error and placing the caret inside an empty LI is handled and should be handled by the selection logic //lastLi.appendChild(ed.getDoc().createElement('')); ed.selection.setCursorLocation(lastLi, 0); } }
javascript
{ "resource": "" }
q61069
listener
validation
function listener(bot) { return function(buffer) { var line = buffer.toString(); var truncatedLine = line.slice(0,line.length-1); if (current_actions && !isNaN(parseInt(truncatedLine)) && parseInt(truncatedLine) < current_actions.length) { var action = current_actions[parseInt(truncatedLine)]; current_actions = null; if (typeof action === "string") { bot(platform, { sessionId: sessionId }, { type: 'action', message: action, action: action }, oncomplete); } else if (action.url) { request(action.url, function (error, response, body) { var article = unfluff(body); console.log(bot_name + ' > Processed Body For ' + article.title); console.log('\n'+article.text+'\n'); oncomplete(null, null, null, function() {}); }); } else { bot(platform, { sessionId: sessionId }, { type: 'action', message: ''+action.payload, action: action.payload }, oncomplete); } } else { current_actions = null; bot(platform, { sessionId: sessionId }, { type: 'message', message: truncatedLine }, oncomplete); } }; }
javascript
{ "resource": "" }
q61070
validation
function(uuid) { if ( ! uuid.match(UUID.rvalid)) { //Need a real UUID for this... return false; } // Get hexadecimal components of uuid var hex = uuid.replace(/[\-{}]/g, ''); // Binary Value var bin = ''; for (var i = 0; i < hex.length; i += 2) { // Convert each character to a bit bin += String.fromCharCode(parseInt(hex.charAt(i) + hex.charAt(i + 1), 16)); } return bin; }
javascript
{ "resource": "" }
q61071
validation
function(c) { // (note parentheses for precence) var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f); return String.fromCharCode(cc); }
javascript
{ "resource": "" }
q61072
validation
function( obj ) { if ( !obj ) { obj = promise; } else { for ( var key in promise ) { obj[ key ] = promise[ key ]; } } return obj; }
javascript
{ "resource": "" }
q61073
validation
function(config) { var me = this, comp; if (arguments.length === 2) { //<debug> if (Ext.isDefined(Ext.global.console)) { Ext.global.console.warn('Ext.LoadMask: LoadMask now uses a standard 1 arg constructor: use the target config'); } //</debug> comp = config; config = arguments[1]; } else { comp = config.target; } // Element support to be deprecated if (!comp.isComponent) { //<debug> if (Ext.isDefined(Ext.global.console)) { Ext.global.console.warn('Ext.LoadMask: LoadMask for elements has been deprecated, use Ext.dom.Element.mask & Ext.dom.Element.unmask'); } //</debug> comp = Ext.get(comp); this.isElement = true; } me.ownerCt = comp; if (!this.isElement) { me.bindComponent(comp); } me.callParent([config]); if (me.store) { me.bindStore(me.store, true); } }
javascript
{ "resource": "" }
q61074
validation
function(store, initial) { var me = this; me.mixins.bindable.bindStore.apply(me, arguments); store = me.store; if (store && store.isLoading()) { me.onBeforeLoad(); } }
javascript
{ "resource": "" }
q61075
callback
validation
function callback (key, err, result) { delete waiting[key]; results[key] = result; context.log(err); checkDone(); }
javascript
{ "resource": "" }
q61076
validation
function (events) { var me = this, i, event, stateEventsByName; if (me.stateful && me.getStateId()) { if (typeof events == 'string') { events = Array.prototype.slice.call(arguments, 0); } stateEventsByName = me.stateEventsByName || (me.stateEventsByName = {}); for (i = events.length; i--; ) { event = events[i]; if (!stateEventsByName[event]) { stateEventsByName[event] = 1; me.on(event, me.onStateChange, me); } } } }
javascript
{ "resource": "" }
q61077
validation
function(){ var me = this, id = me.stateful && me.getStateId(), hasListeners = me.hasListeners, state; if (id) { state = Ext.state.Manager.get(id); if (state) { state = Ext.apply({}, state); if (!hasListeners.beforestaterestore || me.fireEvent('beforestaterestore', me, state) !== false) { me.applyState(state); if (hasListeners.staterestore) { me.fireEvent('staterestore', me, state); } } } } }
javascript
{ "resource": "" }
q61078
validation
function (propName, state, stateName) { var me = this, value = me[propName], config = me.initialConfig; if (me.hasOwnProperty(propName)) { if (!config || config[propName] !== value) { if (state) { state[stateName || propName] = value; } return true; } } return false; }
javascript
{ "resource": "" }
q61079
validation
function (propNames, state) { var me = this, i, n; if (typeof propNames == 'string') { me.savePropToState(propNames, state); } else { for (i = 0, n = propNames.length; i < n; ++i) { me.savePropToState(propNames[i], state); } } return state; }
javascript
{ "resource": "" }
q61080
validation
function(){ var me = this, task = me.stateTask; if (task) { task.destroy(); me.stateTask = null; } me.clearListeners(); }
javascript
{ "resource": "" }
q61081
validation
function () { var me = this; if (!me.active) { me.active = new Date(); me.startTime = me.getTime(); me.onStart(); me.fireEvent('start', me); } }
javascript
{ "resource": "" }
q61082
validation
function () { var me = this; if (me.active) { me.active = null; me.onStop(); me.fireEvent('stop', me); } }
javascript
{ "resource": "" }
q61083
enter
validation
function enter(node, parent) { if(!node.body)return; for(var i = 0; i < node.body.length; i++){ // Function to append a statement after the current statement var append = [].splice.bind(node.body, i+1, 0); // Get all comments associated with the current statement var current = node.body[i]; var comment = [].concat(current.leadingComments, current.trailingComments); // For every comment find the @examples and @expose tags for(var j in comment){ if(!comment[j])continue; var test = parseComment(comment[j], append); if(test)tests.push(test); } } }
javascript
{ "resource": "" }
q61084
parseComment
validation
function parseComment(comment, append){ // separatet so that this code could be parsed var escapedollar = '----esacepedollar'+'---'+'jsdoc-at-examples---'; function unescape(result){ return result.replace(new RegExp(escapedollar,'g'), '$$'); } // escape $ in comments comment.value = comment.value.replace(/\$/g, escapedollar); var expose, examples, current, statement; var test = { setup: [], tests: [], teardown: [] }; var hastest = false; // Normalize comment comment = comment.value.replace(/\$/g, '$$$').replace(/\r/g,''); // Remove empty lines from comment comment = comment.replace(/\$/g, '$$$').replace(RegExp(spansLine('')), ''); // Build @expose and @examples regex expose = RegExp(spansLine('@expose\\s*('+identifier()+'*)'),'g'); examples = RegExp(spansLine('@examples')+'((?:'+spansLine('.*//.*')+')*)','g'); while (current = expose.exec(comment)){ statement = buildExpose(unescape(current[1])); if(statement)append(statement); } while(current = splitLines(examples.exec(comment))){ for(var i in current){ if(parseExampleLine(current[i][0], current[i][1], test)){ hastest = true; } } } return hastest ? test : null; }
javascript
{ "resource": "" }
q61085
parseExampleLine
validation
function parseExampleLine(left, right, result){ if(!left || !right)return false; // did not find test if(right === 'setup' || right === 'teardown'){ result[right].push(left); }else{ var test = { left: wrapEval(left), title: (left + ' // ' + right).replace(/"/g, '\\"') }; if(right === 'throws'){ test.type = right; test.right = ''; }else{ test.type = 'deepEqual'; test.right = right; } // MAYBE TODO: Filter strings to reduce false positives if(RegExp(matchIdentifierName('done')).test(left)){ test.type += 'Async'; } result.tests.push(test); } return true; }
javascript
{ "resource": "" }
q61086
matchIdentifierName
validation
function matchIdentifierName(name){ var noid = identifier().replace('[', '[^'); noid = '(^|$|' + noid + ')'; return noid+name+noid; }
javascript
{ "resource": "" }
q61087
validation
function(index, silent) { var me = this; if (!index) { index = 0; } else if (!Ext.isNumber(index)) { index = Ext.Array.indexOf(me.items, index); } me.items[index].disabled = false; me.up('tablepanel').el.select('.' + Ext.baseCSSPrefix + 'action-col-' + index).removeCls(me.disabledCls); if (!silent) { me.fireEvent('enable', me); } }
javascript
{ "resource": "" }
q61088
validation
function(index, silent) { var me = this; if (!index) { index = 0; } else if (!Ext.isNumber(index)) { index = Ext.Array.indexOf(me.items, index); } me.items[index].disabled = true; me.up('tablepanel').el.select('.' + Ext.baseCSSPrefix + 'action-col-' + index).addCls(me.disabledCls); if (!silent) { me.fireEvent('disable', me); } }
javascript
{ "resource": "" }
q61089
validation
function(readOnly) { var me = this, inputEl = me.inputEl; readOnly = !!readOnly; me[readOnly ? 'addCls' : 'removeCls'](me.readOnlyCls); me.readOnly = readOnly; if (inputEl) { inputEl.dom.readOnly = readOnly; } else if (me.rendering) { me.setReadOnlyOnBoxReady = true; } me.fireEvent('writeablechange', me, readOnly); }
javascript
{ "resource": "" }
q61090
validation
function(active){ var me = this, msgTarget = me.msgTarget, prop; if (me.rendered) { if (msgTarget == 'title' || msgTarget == 'qtip') { if (me.rendered) { prop = msgTarget == 'qtip' ? 'data-errorqtip' : 'title'; } me.getActionEl().dom.setAttribute(prop, active || ''); } else { me.updateLayout(); } } }
javascript
{ "resource": "" }
q61091
validation
function(){ var sorters = this.sorters.items, len = sorters.length, i = 0, sorter; for (; i < len; ++i) { sorter = sorters[i]; if (!sorter.isGrouper) { return sorter; } } return null; }
javascript
{ "resource": "" }
q61092
getPreviewCss
validation
function getPreviewCss(ed, fmt) { var name, previewElm, dom = ed.dom, previewCss = '', parentFontSize, previewStylesName; previewStyles = ed.settings.preview_styles; // No preview forced if (previewStyles === false) return ''; // Default preview if (!previewStyles) previewStyles = 'font-family font-size font-weight text-decoration text-transform color background-color'; // Removes any variables since these can't be previewed function removeVars(val) { return val.replace(/%(\w+)/g, ''); }; // Create block/inline element to use for preview name = fmt.block || fmt.inline || 'span'; previewElm = dom.create(name); // Add format styles to preview element each(fmt.styles, function(value, name) { value = removeVars(value); if (value) dom.setStyle(previewElm, name, value); }); // Add attributes to preview element each(fmt.attributes, function(value, name) { value = removeVars(value); if (value) dom.setAttrib(previewElm, name, value); }); // Add classes to preview element each(fmt.classes, function(value) { value = removeVars(value); if (!dom.hasClass(previewElm, value)) dom.addClass(previewElm, value); }); // Add the previewElm outside the visual area dom.setStyles(previewElm, {position: 'absolute', left: -0xFFFF}); ed.getBody().appendChild(previewElm); // Get parent container font size so we can compute px values out of em/% for older IE:s parentFontSize = dom.getStyle(ed.getBody(), 'fontSize', true); parentFontSize = /px$/.test(parentFontSize) ? parseInt(parentFontSize, 10) : 0; each(previewStyles.split(' '), function(name) { var value = dom.getStyle(previewElm, name, true); // If background is transparent then check if the body has a background color we can use if (name == 'background-color' && /transparent|rgba\s*\([^)]+,\s*0\)/.test(value)) { value = dom.getStyle(ed.getBody(), name, true); // Ignore white since it's the default color, not the nicest fix if (dom.toHex(value).toLowerCase() == '#ffffff') { return; } } // Old IE won't calculate the font size so we need to do that manually if (name == 'font-size') { if (/em|%$/.test(value)) { if (parentFontSize === 0) { return; } // Convert font size from em/% to px value = parseFloat(value, 10) / (/%$/.test(value) ? 100 : 1); value = (value * parentFontSize) + 'px'; } } previewCss += name + ':' + value + ';'; }); dom.remove(previewElm); return previewCss; }
javascript
{ "resource": "" }
q61093
HTTPError
validation
function HTTPError() { var args = Array.prototype.slice.call(arguments); if(!(this instanceof HTTPError)) { var self = new HTTPError(); return FUNCTION(self).apply(self, args); } var headers, msg, code; ARRAY(args).forEach(function HTTPError_foreach(arg) { if(typeof arg === 'object') { headers = arg; } if(typeof arg === 'string') { msg = arg; } if(typeof arg === 'number') { code = arg; } }); code = code || 500; msg = msg || (''+code+' '+require('http').STATUS_CODES[code]); headers = headers || {}; Error.call(this); Error.captureStackTrace(this, this); this.code = code; this.message = msg; this.headers = headers; }
javascript
{ "resource": "" }
q61094
validation
function() { var tip = this.tip; if (!tip) { tip = this.tip = Ext.create('Ext.tip.QuickTip', { ui: 'form-invalid' }); tip.tagConfig = Ext.apply({}, {attribute: 'errorqtip'}, tip.tagConfig); } }
javascript
{ "resource": "" }
q61095
validation
function() { var doc = me.getDoc(); if (doc.body || doc.readyState === 'complete') { Ext.TaskManager.stop(task); me.setDesignMode(true); Ext.defer(me.initEditor, 10, me); } }
javascript
{ "resource": "" }
q61096
validation
function(sourceEditMode) { var me = this, iframe = me.iframeEl, textarea = me.textareaEl, hiddenCls = Ext.baseCSSPrefix + 'hidden', btn = me.getToolbar().getComponent('sourceedit'); if (!Ext.isBoolean(sourceEditMode)) { sourceEditMode = !me.sourceEditMode; } me.sourceEditMode = sourceEditMode; if (btn.pressed !== sourceEditMode) { btn.toggle(sourceEditMode); } if (sourceEditMode) { me.disableItems(true); me.syncValue(); iframe.addCls(hiddenCls); textarea.removeCls(hiddenCls); textarea.dom.removeAttribute('tabIndex'); textarea.focus(); me.inputEl = textarea; } else { if (me.initialized) { me.disableItems(me.readOnly); } me.pushValue(); iframe.removeCls(hiddenCls); textarea.addCls(hiddenCls); textarea.dom.setAttribute('tabIndex', -1); me.deferFocus(); me.inputEl = iframe; } me.fireEvent('editmodechange', me, sourceEditMode); me.updateLayout(); }
javascript
{ "resource": "" }
q61097
validation
function() { var me = this, i, l, btns, doc, name, queriedName, fontSelect, toolbarSubmenus; if (me.readOnly) { return; } if (!me.activated) { me.onFirstFocus(); return; } btns = me.getToolbar().items.map; doc = me.getDoc(); if (me.enableFont && !Ext.isSafari2) { // When querying the fontName, Chrome may return an Array of font names // with those containing spaces being placed between single-quotes. queriedName = doc.queryCommandValue('fontName'); name = (queriedName ? queriedName.split(",")[0].replace(/^'/,'').replace(/'$/,'') : me.defaultFont).toLowerCase(); fontSelect = me.fontSelect.dom; if (name !== fontSelect.value || name != queriedName) { fontSelect.value = name; } } function updateButtons() { for (i = 0, l = arguments.length, name; i < l; i++) { name = arguments[i]; btns[name].toggle(doc.queryCommandState(name)); } } if(me.enableFormat){ updateButtons('bold', 'italic', 'underline'); } if(me.enableAlignments){ updateButtons('justifyleft', 'justifycenter', 'justifyright'); } if(!Ext.isSafari2 && me.enableLists){ updateButtons('insertorderedlist', 'insertunorderedlist'); } // Ensure any of our toolbar's owned menus are hidden. // The overflow menu must control itself. toolbarSubmenus = me.toolbar.query('menu'); for (i = 0; i < toolbarSubmenus.length; i++) { toolbarSubmenus[i].hide(); } me.syncValue(); }
javascript
{ "resource": "" }
q61098
validation
function(input) { this.reset(); // Prepare form this.form = { signature: utils.sha256(input), text: input, html: { prompt: '', template: '', solution: '' }, controls: [] }; // Inject formCompiler into inline compiler this.inline.formCompiler = this; // Render form this.form.html.template = this.append(input).outToString(); this.prepareHtml(); return this.form; }
javascript
{ "resource": "" }
q61099
validation
function(type) { var ctl = { type: type }; var idx = this.form.controls.length; var id = this.form.signature + ':' + idx; ctl.id = 'c-' + utils.sha256(id).substring(0, 8); this.form.controls.push(ctl); return ctl; }
javascript
{ "resource": "" }