_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q60100 | cleanup | validation | function cleanup(ctx, cb) {
cleanupRun = true
var msg = "Shutting down Sauce Connector"
console.log(msg)
ctx.comment(msg)
if (connectorProc) connectorProc.kill("SIGINT")
// Give Sauce Connector 5 seconds to gracefully stop before sending SIGKILL
setTimeout(function() {
if (connectorProc) connectorProc... | javascript | {
"resource": ""
} |
q60101 | startConnector | validation | function startConnector(username, apiKey, exitCb) {
var jarPath = process.env.SAUCE_JAR || path.join(__dirname, "thirdparty", "Sauce-Connect.jar")
var jcmd = "java"
var jargs = ["-Xmx64m", "-jar", jarPath, username, apiKey]
var screencmd = "java -Xmx64m -jar " + jarPath + " [USERNAME] [API KEY]"
... | javascript | {
"resource": ""
} |
q60102 | parseResponseType | validation | function parseResponseType (req) {
if (req.query && req.query.responseType) {
if (req.query.responseType == 'modal') {
// suport for old we.js contentOnly api
req.query.responseType = req.we.config.defaultResponseType;
req.query.contentOnly = true;
}
req.headers.accept = mime.getType(re... | javascript | {
"resource": ""
} |
q60103 | Plugin | validation | function Plugin (pluginPath) {
this.pluginPath = pluginPath;
this.we = we;
this.events = this.we.events;
this.hooks = this.we.hooks;
this.router = this.we.router;
/**
* Plugin Assets
* @type {Object}
*/
this.assets = {
js: {},
css: {}
};
this['package.jso... | javascript | {
"resource": ""
} |
q60104 | validation | function(inputPath, outputPath, outputCharset){
var target = path.resolve(inputPath),
result = {
'success': true,
'files': []
};
if(fs.existsSync(target)){
if(fs.statSync(target).isDirectory()) {
var targets = fs.readdir... | javascript | {
"resource": ""
} | |
q60105 | Theme | validation | function Theme (name, projectPath, options) {
if (!name || (typeof name !== 'string') ) {
return new Error('Param name is required for instantiate a new Theme object');
}
if (!options) options = {};
this.we = we;
this.hooks = this.we.hooks;
this.events = this.we.events;
const self = ... | javascript | {
"resource": ""
} |
q60106 | parseRecord | validation | function parseRecord(req, res, record) {
for (var associationName in res.locals.Model.associations) {
if (!record[associationName]) {
if ( record.dataValues[ associationName + 'Id' ] ) {
record.dataValues[ associationName ] = record[ associationName + 'Id' ];
}
} else {
if (record.da... | javascript | {
"resource": ""
} |
q60107 | Compiler | validation | function Compiler(config, op){
this.outputFilePath = op;
this.modules = {};
this.fileList = [];
this.analyzedModules = [];
this.combinedModules = [];
this.buildComboModules = [];
this.buildAnalyzedModules = [];
this.config = config;
this.packages = config.packages;
} | javascript | {
"resource": ""
} |
q60108 | PluginManager | validation | function PluginManager (we) {
this.we = we;
projectPath = we.projectPath;
// npm module folder from node_modules
this.nodeModulesPath = path.resolve(projectPath, 'node_modules');
this.configs = we.configs;
this.plugins = {};
this.pluginNames = this.getPluginsList();
// a list of plugin.js files get fr... | javascript | {
"resource": ""
} |
q60109 | staticConfig | validation | function staticConfig (projectPath, app) {
if (!projectPath) throw new Error('project path is required for load static configs');
// return configs if already is loaded
if (app.staticConfigsIsLoad) return app.config;
// - load and merge project configs
let projectConfigFolder = app.projectConfigFolder;
... | javascript | {
"resource": ""
} |
q60110 | normalizePort | validation | function normalizePort (val) {
let port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
} | javascript | {
"resource": ""
} |
q60111 | onListening | validation | function onListening () {
let addr = server.address(),
bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
we.log.info('Run in '+we.env+' enviroment and listening on ' + bind);
if (process.send) {
process.send('ready');
}
... | javascript | {
"resource": ""
} |
q60112 | dateToDateTime | validation | function dateToDateTime(d) {
if (d) {
var date = moment(d);
// return null if not is valid
if (!date.isValid()) return null;
// return data in datetime format
return date.format('YYYY-MM-DD HH:mm:ss');
} else {
return null;
}
} | javascript | {
"resource": ""
} |
q60113 | oldIsPlugin | validation | function oldIsPlugin (nodeModulePath) {
// then check if the npm module is one plugin
try {
if (fs.statSync( path.resolve( nodeModulePath, 'plugin.js' ) )) {
return true;
} else {
return false;
}
} catch (e) {
retu... | javascript | {
"resource": ""
} |
q60114 | resolveTreeGreedy | validation | function resolveTreeGreedy (module, opts, cb) {
if(!cb) cb = opts, opts = null
opts = opts || {}
opts.filter = function (pkg, root) {
if(!pkg) return
if(!root.tree[pkg.name]) {
root.tree[pkg.name] = pkg
pkg.parent = root
}
else {
pkg.parent.tree[pkg.name] = p... | javascript | {
"resource": ""
} |
q60115 | listRecusively | validation | function listRecusively (marker) {
options.marker = marker;
self.listObjectsPage(
options,
function (error, nextMarker, s3Objects) {
if (error) {
return callback(error);
}
// Send all of these S3 object definitions to be piped onwards.
s3Objects.forEach(fu... | javascript | {
"resource": ""
} |
q60116 | createClass | validation | function createClass() {
var mixins, definition;
switch(arguments.length) {
case 0:
throw new Error('class definition required');
break;
case 1:
mixins = [];
definition = arguments[0];
break;
default:
mixins = arguments[0];
definition = arguments[1];
break... | javascript | {
"resource": ""
} |
q60117 | superMethod | validation | function superMethod(methodname) {
var func = null;
var p = this.__proto__;
if(!p) throw new Error('invalid parameters');
for(p = p.__proto__; !isEmpty(p); p = p.__proto__) {
var method = p[methodname];
if(typeof method === 'function') {
func = method;
break;
}
}
if(! func) throw new... | javascript | {
"resource": ""
} |
q60118 | subOf | validation | function subOf(child, mixin) {
if(child === mixin) return true;
if(child && child.constructors) {
for(var i in child.constructors) {
var parent = child.constructors[i];
// avoid dead loop
if(parent === child) continue;
if(parent === mixin) return true;
if(subOf(parent, mixin)) re... | javascript | {
"resource": ""
} |
q60119 | _zero | validation | function _zero(_arg, _cb) {
if (!_arg.create) {
_cb();
return;
}
// We need to stub this out now since we won't write the file to manta
// until writeback runs on this file.
var now = new Date().toUTCString();
var info = {
extension: '... | javascript | {
"resource": ""
} |
q60120 | rename | validation | function rename(obj) {
return rename_(function(parsedPath) {
return {
extname: obj.extname || parsedPath.extname,
dirname: (obj.dirnamePrefix || '') + parsedPath.dirname,
basename: parsedPath.basename
};
});
} | javascript | {
"resource": ""
} |
q60121 | update_db | validation | function update_db(p, stats, _cb) {
var key = sprintf(FILES_KEY_FMT, p);
var k1 = sprintf(FHANDLE_KEY_FMT, p);
var k2 = sprintf(FNAME_KEY_FMT, stats._fhandle);
self.db.batch()
.put(key, stats)
.put(k1, stats._fhandle)
.put(k2, p)
.write(fu... | javascript | {
"resource": ""
} |
q60122 | process_entry | validation | function process_entry(val, nextent) {
if (!val || !val._tmp_pathname) {
// if this is somehow missing, just skip it since we can't check
// to see if the file is dirty
nextent();
return;
}
var nm = val._tmp_pathname;
delete val._tmp_pathn... | javascript | {
"resource": ""
} |
q60123 | _prepopulate_metadata | validation | function _prepopulate_metadata(_arg, _cb) {
var entry;
try {
entry = JSON.parse(_arg);
} catch (e) {
_cb();
return;
}
var nm = path.join(entry.parent, entry.name);
var k = sprintf(FILES_KEY_FMT, nm);
// if already in LRU cach... | javascript | {
"resource": ""
} |
q60124 | check_object | validation | function check_object(now, key, p, c_info) {
// keep track of how many files we're in the process of checking via
// callback so we can know when to emit the 'ready' event
stale_check_cnt++;
if (!c_info.last_stat || (now - c_info.last_stat) > self.ttl_ms) {
// consider it st... | javascript | {
"resource": ""
} |
q60125 | validation | function (soajs, id, cb) {
checkForMongo(soajs);
var id1;
try {
id1 = mongo.ObjectId(id);
return id1;
}
catch (e) {
soajs.log.error(e);
throw e;
}
} | javascript | {
"resource": ""
} | |
q60126 | validation | function (soajs, combo, cb) {
checkForMongo(soajs);
mongo.findOne(combo.collection, combo.condition || {}, combo.fields || null, combo.options || null, cb);
} | javascript | {
"resource": ""
} | |
q60127 | validation | function (soajs, combo, cb) {
checkForMongo(soajs);
mongo.remove(combo.collection, combo.condition, cb);
} | javascript | {
"resource": ""
} | |
q60128 | call | validation | function call() {
var args = [xdhq, 3];
var i = 0;
while (i < arguments.length)
args.push(arguments[i++]);
njsq._call.apply(null, args);
} | javascript | {
"resource": ""
} |
q60129 | initBLModel | validation | function initBLModel(req, res, cb) {
let modelName = config.model;
if (req.soajs.servicesConfig && req.soajs.servicesConfig.model) {
modelName = req.soajs.servicesConfig.model;
}
if (process.env.SOAJS_TEST && req.soajs.inputmaskData.model) {
modelName = req.soajs.inputmaskData.model;
... | javascript | {
"resource": ""
} |
q60130 | getAssetDir | validation | function getAssetDir() {
var dir = path.dirname(process.argv[1]);
if (isDev()) {
let epeiosPath = getEpeiosPath();
return path.resolve(epeiosPath, "tools/xdhq/examples/common/", path.relative(path.resolve(epeiosPath, "tools/xdhq/examples/NJS/"), path.resolve(dir))); // No final '/'.
} else
return path.... | javascript | {
"resource": ""
} |
q60131 | validation | function (req, cb) {
let config = req.soajs.config;
let loginMode = config.loginMode;
if (req.soajs.tenantOauth && req.soajs.tenantOauth.loginMode) {
loginMode = req.soajs.tenantOauth.loginMode;
}
function getLocal() {
let condition = {'userId': req.soaj... | javascript | {
"resource": ""
} | |
q60132 | validation | function (req, cb) {
let config = req.soajs.config;
let loginMode = config.loginMode;
if (req.soajs.tenantOauth && req.soajs.tenantOauth.loginMode) {
loginMode = req.soajs.tenantOauth.loginMode;
}
let criteria = {
"userId.loginMode": loginMode,
... | javascript | {
"resource": ""
} | |
q60133 | validation | function (req, cb) {
let criteria = {
"clientId": req.soajs.inputmaskData.clientId
};
let combo = {
collection: tokenCollectionName,
condition: criteria
};
libProduct.model.removeEntry(req.soajs, combo, function (error, result) {
le... | javascript | {
"resource": ""
} | |
q60134 | validation | function (req, cb) {
if (req.soajs && req.soajs.tenantOauth && req.soajs.tenantOauth.secret && req.soajs.tenant && req.soajs.tenant.id) {
let secret = req.soajs.tenantOauth.secret;
let tenantId = req.soajs.tenant.id.toString();
let basic = Auth.generate(tenantId, secret);
... | javascript | {
"resource": ""
} | |
q60135 | requireModel | validation | function requireModel(filePath, cb) {
//check if file exist. if not return error
fs.exists(filePath, function (exists) {
if (!exists) {
return cb(new Error("Requested Model Not Found!"));
}
libProduct.model = require(filePath);... | javascript | {
"resource": ""
} |
q60136 | noCallbackHandler | validation | function noCallbackHandler(ctx, connectMiddleware, next) {
connectMiddleware(ctx.req, ctx.res)
return next()
} | javascript | {
"resource": ""
} |
q60137 | withCallbackHandler | validation | function withCallbackHandler(ctx, connectMiddleware, next) {
return new Promise((resolve, reject) => {
connectMiddleware(ctx.req, ctx.res, err => {
if (err) reject(err)
else resolve(next())
})
})
} | javascript | {
"resource": ""
} |
q60138 | koaConnect | validation | function koaConnect(connectMiddleware) {
const handler = connectMiddleware.length < 3
? noCallbackHandler
: withCallbackHandler
return function koaConnect(ctx, next) {
return handler(ctx, connectMiddleware, next)
}
} | javascript | {
"resource": ""
} |
q60139 | makeOrdinal | validation | function makeOrdinal(words) {
// Ends with *00 (100, 1000, etc.) or *teen (13, 14, 15, 16, 17, 18, 19)
if (ENDS_WITH_DOUBLE_ZERO_PATTERN.test(words) || ENDS_WITH_TEEN_PATTERN.test(words)) {
return words + 'th';
}
// Ends with *y (20, 30, 40, 50, 60, 70, 80, 90)
else if (ENDS_WITH_Y_PATTERN.t... | javascript | {
"resource": ""
} |
q60140 | getPermission | validation | function getPermission() {
var permission = NotificationAPI.permission;
/**
* True if permission is granted, else false.
*
* @memberof! webNotification
* @alias webNotification.permissionGranted
* @public
*/
... | javascript | {
"resource": ""
} |
q60141 | validation | function (title, options, callback) {
var autoClose = 0;
if (options.autoClose && (typeof options.autoClose === 'number')) {
autoClose = options.autoClose;
}
//defaults the notification icon to the website favicon.ico
if (!options.icon) {
options.icon = '... | javascript | {
"resource": ""
} | |
q60142 | validation | function (argumentsArray) {
//callback is always the last argument
var callback = noop;
if (argumentsArray.length && (typeof argumentsArray[argumentsArray.length - 1] === 'function')) {
callback = argumentsArray.pop();
}
var title = null;
var options = null;
... | javascript | {
"resource": ""
} | |
q60143 | OktaAPIGroups | validation | function OktaAPIGroups(apiToken, domain, preview)
{
if(apiToken == undefined || domain == undefined)
{
throw new Error("OktaAPI requires an API token and a domain");
}
this.domain = domain;
if(preview == undefined) this.preview = false;
else this.preview = preview;
this.request = ne... | javascript | {
"resource": ""
} |
q60144 | OktaAPISessions | validation | function OktaAPISessions(apiToken, domain, preview)
{
if(apiToken == undefined || domain == undefined)
{
throw new Error("OktaAPI requires an API token and a domain");
}
this.domain = domain;
if(preview == undefined) this.preview = false;
else this.preview = preview;
this.request = ... | javascript | {
"resource": ""
} |
q60145 | OktaAPI | validation | function OktaAPI(apiToken, domain, preview) {
if(apiToken == undefined || domain == undefined) {
throw new Error("OktaAPI requires an API token and a domain");
}
this.domain = domain;
if(preview == undefined) this.preview = false;
else this.preview = preview;
this.request = new NetworkAb... | javascript | {
"resource": ""
} |
q60146 | constructGroup | validation | function constructGroup(name, description) {
var profile = {};
profile.name = name;
profile.description = description;
return profile;
} | javascript | {
"resource": ""
} |
q60147 | change | validation | function change(evt) {
evt = evt || win.event;
if ('readystatechange' === evt.type) {
readystate.change(docReadyState());
if (complete !== docReadyState()) return;
}
if ('load' === evt.type) readystate.change('complete');
else readystate.change('interactive');
//
// House keep... | javascript | {
"resource": ""
} |
q60148 | UTF8ArrayToString | validation | function UTF8ArrayToString(u8Array, idx) {
var u0, u1, u2, u3, u4, u5;
var str = '';
while (1) {
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
u0 = u8Array[idx++];
if (!u0) return str;
... | javascript | {
"resource": ""
} |
q60149 | lengthBytesUTF32 | validation | function lengthBytesUTF32(str) {
var len = 0;
for (var i = 0; i < str.length; ++i) {
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
// See http://unicode.org/faq/utf_bom.html#utf16-3
... | javascript | {
"resource": ""
} |
q60150 | constructProfile | validation | function constructProfile(firstName, lastName, email, login, mobilePhone, customAttribs) {
var profile = {};
profile.login = (login ? login : email);
profile.email = email;
profile.firstName = firstName;
profile.lastName = lastName;
profile.mobilePhone = mobilePhone;
if(customAttribs != unde... | javascript | {
"resource": ""
} |
q60151 | constructCredentials | validation | function constructCredentials(password, question, answer) {
var credentials = {};
if(password) credentials.password = constructPassword(password);
if(question && answer) credentials.recovery_question = constructRecoveryQuestion(question, answer);
return credentials;
} | javascript | {
"resource": ""
} |
q60152 | validation | function(method, where, what, query, callback) {
var opts = {};
if(what == undefined) opts.body = "";
else opts.body = JSON.stringify(what);
opts.headers = {};
opts.headers['Content-Length'] = opts.body.length;
opts.headers['Content-Type'] = "application/json";
opts.headers['Authorization'] ... | javascript | {
"resource": ""
} | |
q60153 | constructAppModel | validation | function constructAppModel(id, name, label, created, lastUpdated, status,
features, signOnMode, accessibility, visibility,
credentials, settings, links, embedded) {
var model = {};
if(id) model.id = id;
if(name) model.name = name;
if(label) model... | javascript | {
"resource": ""
} |
q60154 | constructAppUserModel | validation | function constructAppUserModel(id, externalId, created, lastUpdated, scope, status,
statusChanged, passwordChanged, syncState, lastSync,
credentials, lastSync, links) {
var model = {};
if(id) model.id = id;
if(externalId) model.externalId = externalI... | javascript | {
"resource": ""
} |
q60155 | constructAppGroupModel | validation | function constructAppGroupModel(id, lastUpdated, priority, links) {
var model = {};
if(id) model.id = id;
if(lastUpdated) model.lastUpdated = lastUpdated;
if(priority) model.priority = priority;
if(links) model.links = links;
return model;
} | javascript | {
"resource": ""
} |
q60156 | validation | function (rawErrors) {
var normalizedErrors = [];
if (
typeof rawErrors === 'string' ||
(typeof rawErrors === 'object' && !Array.isArray(rawErrors))
) {
// Only one error set, which we can assume was for a single property
rawErrors = [rawErrors];
}
if (rawErrors != null) {
canReflect.eachIndex(... | javascript | {
"resource": ""
} | |
q60157 | getResultSeverity | validation | function getResultSeverity (result, config) {
// Count all errors
return result.reduce((previous, message) => {
let severity
if (message.fatal) {
return previous + 1
}
severity = message.messages[0] ? message.messages[0].severity : 0
if (severity === 2) {
return previous + 1
}... | javascript | {
"resource": ""
} |
q60158 | validation | function (inputNode, options = {}) {
this.formatter = require('eslint/lib/formatters/stylish')
if (!(this instanceof StandardValidationFilter)) {
return new StandardValidationFilter(inputNode, options)
}
// set inputTree
Filter.call(this, inputNode)
this.node = inputNode
this.console = options.console... | javascript | {
"resource": ""
} | |
q60159 | _boolToNum | validation | function _boolToNum(value, numTrue, numFalse, defaultVal) {
if (typeof value === 'boolean') {
return value ? numTrue : numFalse;
}
return typeof value === 'number' ? value : defaultVal;
} | javascript | {
"resource": ""
} |
q60160 | validation | function() {
if ((cachedWidth = element.offsetWidth) != lastWidth || (cachedHeight = element.offsetHeight) != lastHeight) {
dirty = true;
lastWidth = cachedWidth;
lastHeight = cachedHeight;
}
reset();
} | javascript | {
"resource": ""
} | |
q60161 | validation | function(element, callback) {
var me = this;
var elementType = Object.prototype.toString.call(element);
var isCollectionTyped = me._isCollectionTyped = ('[object Array]' === elementType ||
('[object NodeList]' === elementType) ||
('[object HTMLCollection]' === elementTy... | javascript | {
"resource": ""
} | |
q60162 | wrapFn | validation | function wrapFn(mocker, fn) {
return function() {
//Copy the arguments this function was called with
var args = Array.prototype.slice.call(arguments);
//Save the arguments to the log
mocker.history.push(args);
return fn.apply(this, arguments);
};
} | javascript | {
"resource": ""
} |
q60163 | pass | validation | function pass(part, suiteIndex, testIndex) {
var o;
var isSuite = false;
if (typeof testIndex === 'number') {
o = suites[suiteIndex].tests[testIndex];
} else {
isSuite = true;
o = suites[suiteIndex];
}
display.pass(part, o);
if ( isSuite ) { // Suite -------------------... | javascript | {
"resource": ""
} |
q60164 | fail | validation | function fail(part, suiteIndex, testIndex, msg) {
if (typeof testIndex === 'string') {
msg = testIndex;
testIndex = undefined;
}
var o;
var isSuite = false;
if (typeof testIndex === 'number') {
o = suites[suiteIndex].tests[testIndex];
if (typeof msg === 'string') {
... | javascript | {
"resource": ""
} |
q60165 | prepareJson | validation | function prepareJson(shares) {
/*jshint maxcomplexity:11 */
/*jshint maxstatements:23 */
let json = [];
for (let i = 0; i < shares.length; i++) {
let share = shares[i];
json[i] = {};
json[i].id = share.id;
let status = '?';
switch (share.state) {
case 0:
status = 'stopped';... | javascript | {
"resource": ""
} |
q60166 | validation | function (content) {
// Test against regex list
var interpolateTest = _.templateSettings.interpolate.test(content);
if (interpolateTest) {
_.templateSettings.interpolate.lastIndex = 0;
return true;
}
var evaluateTest = _.templateSettings.evaluate.test(content);
if ... | javascript | {
"resource": ""
} | |
q60167 | validation | function (match, strUntilValue, name, value, index) {
var self = this;
var expression = value;
if (!this.isRelevantTagAttr(this.currentTag, name)) {
return;
}
// Try and set "root" directory when a dynamic attribute is found
if (isTemplate(value)) {
if (pathIsAbsolute(value... | javascript | {
"resource": ""
} | |
q60168 | refresh | validation | function refresh(entry) {
if (entry !== freshEnd) {
if (!staleEnd) {
staleEnd = entry;
} else if (staleEnd === entry) {
staleEnd = entry.n;
}
link(entry.n, entry.p);
link(entry, freshEnd);
freshEnd = entry;
freshEnd.n... | javascript | {
"resource": ""
} |
q60169 | link | validation | function link(nextEntry, prevEntry) {
if (nextEntry !== prevEntry) {
if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify
if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify
}
} | javascript | {
"resource": ""
} |
q60170 | validation | function(key, value, writeAttr, attrName) {
// TODO: decide whether or not to throw an error if "class"
// is set through this function since it may cause $updateClass to
// become unstable.
var node = this.$$element[0],
booleanKey = getBooleanAttrName(node, key),
... | javascript | {
"resource": ""
} | |
q60171 | groupScan | validation | function groupScan(node, attrStart, attrEnd) {
var nodes = [];
var depth = 0;
if (attrStart && node.hasAttribute && node.hasAttribute(attrStart)) {
do {
if (!node) {
throw $compileMinErr('uterdir',
'Unterminated attribute, found \'{0}\' but no matchi... | javascript | {
"resource": ""
} |
q60172 | mergeTemplateAttributes | validation | function mergeTemplateAttributes(dst, src) {
var srcAttr = src.$attr,
dstAttr = dst.$attr;
// reapply the old attributes to the new element
forEach(dst, function(value, key) {
if (key.charAt(0) !== '$') {
if (src[key] && src[key] !== value) {
if (value.length) ... | javascript | {
"resource": ""
} |
q60173 | replaceWith | validation | function replaceWith($rootElement, elementsToRemove, newNode) {
var firstElementToRemove = elementsToRemove[0],
removeCount = elementsToRemove.length,
parent = firstElementToRemove.parentNode,
i, ii;
if ($rootElement) {
for (i = 0, ii = $rootElement.length; i < ii; i++... | javascript | {
"resource": ""
} |
q60174 | encodePath | validation | function encodePath(path) {
var segments = path.split('/'),
i = segments.length;
while (i--) {
// decode forward slashes to prevent them from being double encoded
segments[i] = encodeUriSegment(segments[i].replace(/%2F/g, '/'));
}
return segments.join('/');
} | javascript | {
"resource": ""
} |
q60175 | isPure | validation | function isPure(node, parentIsPure) {
switch (node.type) {
// Computed members might invoke a stateful toString()
case AST.MemberExpression:
if (node.computed) {
return false;
}
break;
// Unary always convert to primative
case AST.UnaryExpression:
return PURITY_ABSOLUT... | javascript | {
"resource": ""
} |
q60176 | $$SanitizeUriProvider | validation | function $$SanitizeUriProvider() {
var aHrefSanitizationWhitelist = /^\s*(https?|s?ftp|mailto|tel|file):/,
imgSrcSanitizationWhitelist = /^\s*((https?|ftp|file|blob):|data:image\/)/;
/**
* @description
* Retrieves or overrides the default regular expression that is used for whitelisting of safe
* url... | javascript | {
"resource": ""
} |
q60177 | urlsAreSameOrigin | validation | function urlsAreSameOrigin(url1, url2) {
url1 = urlResolve(url1);
url2 = urlResolve(url2);
return (url1.protocol === url2.protocol &&
url1.host === url2.host);
} | javascript | {
"resource": ""
} |
q60178 | getBaseUrl | validation | function getBaseUrl() {
if (window.document.baseURI) {
return window.document.baseURI;
}
// `document.baseURI` is available everywhere except IE
if (!baseUrlParsingNode) {
baseUrlParsingNode = window.document.createElement('a');
baseUrlParsingNode.href = '.';
// Work-around for IE bug describe... | javascript | {
"resource": ""
} |
q60179 | formatNumber | validation | function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
if (!(isString(number) || isNumber(number)) || isNaN(number)) return '';
var isInfinity = !isFinite(number);
var isZero = false;
var numStr = Math.abs(number) + '',
formattedText = '',
parsedNumber;
if (isInfinity) {
... | javascript | {
"resource": ""
} |
q60180 | defaults | validation | function defaults(dst, src) {
forEach(src, function(value, key) {
if (!isDefined(dst[key])) {
dst[key] = value;
}
});
} | javascript | {
"resource": ""
} |
q60181 | validation | function(playAnimation) {
if (!animationCompleted) {
animationPaused = !playAnimation;
if (timings.animationDuration) {
var value = blockKeyframeAnimations(node, animationPaused);
if (animationPaused) {
temporaryStyles.push(value);
... | javascript | {
"resource": ""
} | |
q60182 | validation | function(scope, $element, attrs, ctrl, $transclude) {
var previousElement, previousScope;
scope.$watchCollection(attrs.ngAnimateSwap || attrs['for'], function(value) {
if (previousElement) {
$animate.leave(previousElement);
}
if (previousScope) {
previousScope.$de... | javascript | {
"resource": ""
} | |
q60183 | validation | function($scope, element, attrs) {
var src = attrs.ngMessagesInclude || attrs.src;
$templateRequest(src).then(function(html) {
if ($scope.$$destroyed) return;
if (isString(html) && !html.trim()) {
// Empty template - nothing to compile
replaceElementWithMarke... | javascript | {
"resource": ""
} | |
q60184 | locale_locales__getSetGlobalLocale | validation | function locale_locales__getSetGlobalLocale (key, values) {
var data;
if (key) {
if (typeof values === 'undefined') {
data = locale_locales__getLocale(key);
}
else {
data = defineLocale(key, values);
}
if (data)... | javascript | {
"resource": ""
} |
q60185 | configFromString | validation | function configFromString(config) {
var matched = aspNetJsonRegex.exec(config._i);
if (matched !== null) {
config._d = new Date(+matched[1]);
return;
}
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
... | javascript | {
"resource": ""
} |
q60186 | duration_humanize__getSetRelativeTimeThreshold | validation | function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
if (thresholds[threshold] === undefined) {
return false;
}
if (limit === undefined) {
return thresholds[threshold];
}
thresholds[threshold] = limit;
return true;
} | javascript | {
"resource": ""
} |
q60187 | validation | function(element, parent, options) {
options = options || {};
$mdUtil.disableScrollAround._count = Math.max(0, $mdUtil.disableScrollAround._count || 0);
$mdUtil.disableScrollAround._count++;
if ($mdUtil.disableScrollAround._restoreScroll) {
return $mdUtil.disableScrollAround._restoreSc... | javascript | {
"resource": ""
} | |
q60188 | sanitizeAndConfigure | validation | function sanitizeAndConfigure(scope, options) {
var selectEl = element.find('md-select-menu');
if (!options.target) {
throw new Error($mdUtil.supplant(ERROR_TARGET_EXPECTED, [options.target]));
}
angular.extend(options, {
isRemoved: false,
target: angular.... | javascript | {
"resource": ""
} |
q60189 | refreshPosition | validation | function refreshPosition(item) {
// Find the top of an item by adding to the offsetHeight until we reach the
// content element.
var current = item.element[0];
item.top = 0;
item.left = 0;
item.right = 0;
while (current && current !== contentEl[0]) {
item.top += curren... | javascript | {
"resource": ""
} |
q60190 | MdToastController | validation | function MdToastController($mdToast, $scope) {
// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in
// interimElements. The $mdCompiler simulates the $onInit hook for all versions.
this.$onInit = function() {
var self = this;
if (self.highlightAction) {
$sc... | javascript | {
"resource": ""
} |
q60191 | positionDropdown | validation | function positionDropdown () {
if (!elements) {
return $mdUtil.nextTick(positionDropdown, false, $scope);
}
var dropdownHeight = ($scope.dropdownItems || MAX_ITEMS) * ITEM_HEIGHT;
var hrect = elements.wrap.getBoundingClientRect(),
vrect = elements.snap.getBoundingClientRect(),
... | javascript | {
"resource": ""
} |
q60192 | correctHorizontalAlignment | validation | function correctHorizontalAlignment () {
var dropdown = elements.scrollContainer.getBoundingClientRect(),
styles = {};
if (dropdown.right > root.right - MENU_PADDING) {
styles.left = (hrect.right - dropdown.width) + 'px';
}
elements.$.scrollContainer.css(styles);
} | javascript | {
"resource": ""
} |
q60193 | gatherElements | validation | function gatherElements () {
var snapWrap = gatherSnapWrap();
elements = {
main: $element[0],
scrollContainer: $element[0].querySelector('.md-virtual-repeat-container'),
scroller: $element[0].querySelector('.md-virtual-repeat-scroller'),
ul: $element.find('ul')[0],
input: $el... | javascript | {
"resource": ""
} |
q60194 | selectedItemChange | validation | function selectedItemChange (selectedItem, previousSelectedItem) {
updateModelValidators();
if (selectedItem) {
getDisplayValue(selectedItem).then(function (val) {
$scope.searchText = val;
handleSelectedItemChange(selectedItem, previousSelectedItem);
});
} else if (previousSele... | javascript | {
"resource": ""
} |
q60195 | handleSearchText | validation | function handleSearchText (searchText, previousSearchText) {
ctrl.index = getDefaultIndex();
// do nothing on init
if (searchText === previousSearchText) return;
updateModelValidators();
getDisplayValue($scope.selectedItem).then(function (val) {
// clear selected item if search text no long... | javascript | {
"resource": ""
} |
q60196 | keydown | validation | function keydown (event) {
switch (event.keyCode) {
case $mdConstant.KEY_CODE.DOWN_ARROW:
if (ctrl.loading) return;
event.stopPropagation();
event.preventDefault();
ctrl.index = Math.min(ctrl.index + 1, ctrl.matches.length - 1);
updateScroll();
reportMessages(... | javascript | {
"resource": ""
} |
q60197 | getDisplayValue | validation | function getDisplayValue (item) {
return $q.when(getItemText(item) || item).then(function(itemText) {
if (itemText && !angular.isString(itemText)) {
$log.warn('md-autocomplete: Could not resolve display value to a string. ' +
'Please check the `md-item-text` attribute.');
}
retu... | javascript | {
"resource": ""
} |
q60198 | updateScroll | validation | function updateScroll () {
if (!elements.li[0]) return;
var height = elements.li[0].offsetHeight,
top = height * ctrl.index,
bot = top + height,
hgt = elements.scroller.clientHeight,
scrollTop = elements.scroller.scrollTop;
if (top < scrollTop) {
scrollTo(top);
} el... | javascript | {
"resource": ""
} |
q60199 | MdChipsCtrl | validation | function MdChipsCtrl ($scope, $attrs, $mdConstant, $log, $element, $timeout, $mdUtil,
$exceptionHandler) {
/** @type {$timeout} **/
this.$timeout = $timeout;
/** @type {Object} */
this.$mdConstant = $mdConstant;
/** @type {angular.$scope} */
this.$scope = $scope;
/** @type {angula... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.