_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q60000 | authenticate | validation | function authenticate ({username, password, clientToken, agent}) {
return fetch(`${YGGDRASIL_API}/authenticate`, {
method: 'POST',
body: JSON.stringify({
agent,
username,
password,
clientToken,
requestUser: true
}),
headers: {
'user-agent': USER_AGENT,
'Conten... | javascript | {
"resource": ""
} |
q60001 | isValid | validation | function isValid ({accessToken, clientToken}) {
return fetch(`${YGGDRASIL_API}/validate`, {
method: 'POST',
body: JSON.stringify({
accessToken,
clientToken
}),
headers: {
'user-agent': USER_AGENT,
'content-type': 'application/json'
}
})
.then(handleErrors)
.then(r... | javascript | {
"resource": ""
} |
q60002 | lookupProfileAt | validation | function lookupProfileAt (name, date, agent = 'minecraft') {
const hasDate = typeof date !== 'undefined'
const query = hasDate
? `/users/profiles/${agent}/${name}?at=${date}`
: `/users/profiles/${agent}/${name}`
return fetch(`${CORE_API}${query}`, {
headers: {
'user-agent': USER_AGENT,
'a... | javascript | {
"resource": ""
} |
q60003 | setSkin | validation | function setSkin ({accessToken}, profileId, skinUrl, isSlim = false) {
const params = new URLSearchParams()
params.append('model', isSlim ? 'slim' : '')
params.append('url', skinUrl)
return fetch(`${CORE_API}/user/profile/${profileId}/skin`, {
method: 'POST',
body: params,
headers: {
'user-ag... | javascript | {
"resource": ""
} |
q60004 | coerceControllerAlias | validation | function coerceControllerAlias(property) {
return computed(property, {
get() {
let controllerName = this.get('controllerName') || this.get('routeName');
let controller = this.get('controller') || this.controllerFor(controllerName);
return controller.get(property);
},
set(key, value) {
... | javascript | {
"resource": ""
} |
q60005 | encode | validation | function encode() {
var data = this.data;
var length = 11;
var sender = this.sender;
var target = this.target;
var header = new Buffer(9);
var content = !data || isBuffer(data) ? data : this.encode(data);
if (content) length += content.length;
header.writeUInt8(length, 0);
header.writeUInt8(sender.s... | javascript | {
"resource": ""
} |
q60006 | isValid | validation | function isValid(message) {
if (!Constants.equals(message.slice(4, 16))) return false;
var checksum = message.readUInt16BE(message.length - 2);
return checksum === crc(message.slice(16, -2));
} | javascript | {
"resource": ""
} |
q60007 | source | validation | function source(message) {
var ip = [];
for (var i = 0; i < 4; i++) ip.push(message[i]);
return ip.join('.');
} | javascript | {
"resource": ""
} |
q60008 | parse | validation | function parse(resource) {
if (typeof resource === 'object') return resource;
var config = url.parse(resource);
return {
port: config.port,
device: config.auth,
gateway: config.hostname
};
} | javascript | {
"resource": ""
} |
q60009 | getComponentDescendants | validation | function getComponentDescendants (root, component, onlyChildren, includeSelf) {
var node = rquery_getDOMNode(component),
descendants = [];
if (onlyChildren) {
descendants = node.children;
} else {
descendants = node.getElementsByTagName('*');
}
// convert to array
descendan... | javascript | {
"resource": ""
} |
q60010 | flushDeferredPadding | validation | function flushDeferredPadding(blocks) {
if (!padding)
return;
let prevBlock = blocks[blocks.length - 2];
prevBlock.text += padding;
} | javascript | {
"resource": ""
} |
q60011 | validation | function(e) {
e.data.handler.over = true;
$.iframeTracker.retrieveFocus();
try {
e.data.handler.overCallback(this, e);
} catch (ex) {}
} | javascript | {
"resource": ""
} | |
q60012 | validation | function(e) {
e.data.handler.over = false;
$.iframeTracker.retrieveFocus();
try {
e.data.handler.outCallback(this, e);
} catch (ex) {}
} | javascript | {
"resource": ""
} | |
q60013 | validation | function() {
if (document.activeElement && document.activeElement.tagName === "IFRAME") {
$.iframeTracker.focusRetriever.focus();
$.iframeTracker.focusRetrieved = true;
}
} | javascript | {
"resource": ""
} | |
q60014 | validation | function(e) {
for (var i in this.handlersList) {
if (this.handlersList[i].over === true) {
try {
this.handlersList[i].blurCallback(e);
} catch (ex) {}
}
}
} | javascript | {
"resource": ""
} | |
q60015 | funcWithReturnFromSnippet | validation | function funcWithReturnFromSnippet(js) {
// auto-"return"
if (js.indexOf('return') === -1) {
if (js.substring(js.length - 1) === ';') {
js = js.substring(0, js.length - 1);
}
js = 'return (' + js + ')';
}
// Expose level definitions to condition func context
var ... | javascript | {
"resource": ""
} |
q60016 | parseArgv | validation | function parseArgv(argv) {
var parsed = {
args: [],
help: false,
color: null,
paginate: null,
outputMode: OM_LONG,
jsonIndent: 2,
level: null,
strict: false,
pids: null,
pidsType: null,
timeFormat: TIME_UTC // one of the TIME_ ... | javascript | {
"resource": ""
} |
q60017 | processStdin | validation | function processStdin(opts, stylize, callback) {
var leftover = ''; // Left-over partial line from last chunk.
var stdin = process.stdin;
stdin.resume();
stdin.setEncoding('utf8');
stdin.on('data', function (chunk) {
var lines = chunk.split(/\r\n|\n/);
var length = lines.length;
... | javascript | {
"resource": ""
} |
q60018 | getPids | validation | function getPids(cb) {
if (opts.pidsType === 'num') {
return cb(null, opts.pids);
}
if (process.platform === 'sunos') {
execFile('/bin/pgrep', ['-lf', opts.pids],
function (pidsErr, stdout, stderr) {
if (pidsErr) {
... | javascript | {
"resource": ""
} |
q60019 | processFile | validation | function processFile(file, opts, stylize, callback) {
var stream = fs.createReadStream(file);
if (/\.gz$/.test(file)) {
stream = stream.pipe(require('zlib').createGunzip());
}
// Manually decode streams - lazy load here as per node/lib/fs.js
var decoder = new (require('string_decoder')
... | javascript | {
"resource": ""
} |
q60020 | MochaWorkerReporter | validation | function MochaWorkerReporter (runner) {
EVENTS.forEach(function (eventName) {
runner.on(eventName, function (test, error) {
var data = {
'event' : eventName,
'test' : clean(test, error)
};
try {
process.send({
type : 'testResults',
data : data
... | javascript | {
"resource": ""
} |
q60021 | CucumberReporter | validation | function CucumberReporter (eventMediator) {
var options = {
snippets : true,
stream : process.stdout,
useColors : true
};
this.failureCount = 0;
this.eventMediator = eventMediator;
this.formatter = DotFormatter(options);
// all feature files are finished
this.eventMediator.on('end', ... | javascript | {
"resource": ""
} |
q60022 | closest | validation | function closest (element, selector) {
while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
if (typeof element.matches === 'function' &&
element.matches(selector)) {
return element;
}
element = element.parentNode;
}
} | javascript | {
"resource": ""
} |
q60023 | delegate | validation | function delegate(elements, selector, type, callback, useCapture) {
// Handle the regular Element usage
if (typeof elements.addEventListener === 'function') {
return _delegate.apply(null, arguments);
}
// Handle Element-less usage, it defaults to global delegation
if (typeof type === 'funct... | javascript | {
"resource": ""
} |
q60024 | listener | validation | function listener(element, selector, type, callback) {
return function(e) {
e.delegateTarget = closest_1(e.target, selector);
if (e.delegateTarget) {
callback.call(element, e);
}
}
} | javascript | {
"resource": ""
} |
q60025 | listenNode | validation | function listenNode(node, type, callback) {
node.addEventListener(type, callback);
return {
destroy: function() {
node.removeEventListener(type, callback);
}
}
} | javascript | {
"resource": ""
} |
q60026 | listenNodeList | validation | function listenNodeList(nodeList, type, callback) {
Array.prototype.forEach.call(nodeList, function(node) {
node.addEventListener(type, callback);
});
return {
destroy: function() {
Array.prototype.forEach.call(nodeList, function(node) {
node.removeEventListener(... | javascript | {
"resource": ""
} |
q60027 | listenSelector | validation | function listenSelector(selector, type, callback) {
return delegate_1(document.body, selector, type, callback);
} | javascript | {
"resource": ""
} |
q60028 | getAttributeValue | validation | function getAttributeValue(suffix, element) {
var attribute = 'data-clipboard-' + suffix;
if (!element.hasAttribute(attribute)) {
return;
}
return element.getAttribute(attribute);
} | javascript | {
"resource": ""
} |
q60029 | AssetLoader | validation | function AssetLoader(manifest, loader) {
this.assets = loadAssets(manifest, loader, function(err) {
if (err) {
console.error(err);
}
});
} | javascript | {
"resource": ""
} |
q60030 | FontLoader | validation | function FontLoader(fontFamiliesArray, delegate, timeout) {
// Public
this.delegate = delegate;
this.timeout = (typeof timeout !== "undefined") ? timeout : 3000;
// Private
this._fontFamiliesArray = fontFamiliesArray.slice(0);
this._testContainer = null;
this._adobeBlankSizeWatcher = null;
this._timeou... | javascript | {
"resource": ""
} |
q60031 | validation | function(sizeWatcher) {
var watchedElement = sizeWatcher.getWatchedElement();
if (sizeWatcher === this._adobeBlankSizeWatcher) {
this._adobeBlankLoaded(watchedElement);
} else {
this._elementSizeChanged(watchedElement);
}
} | javascript | {
"resource": ""
} | |
q60032 | SizeWatcher | validation | function SizeWatcher(element, options) {
this._element = element;
this._delegate = options.delegate;
this._size = null;
this._continuous = !!options.continuous;
this._direction = options.direction ? options.direction : SizeWatcher.directions.both;
this._dimension = options.dimension ? options.dimension : Si... | javascript | {
"resource": ""
} |
q60033 | validation | function(prefab) {
/**
* The name of a prefab to instantiate for the particle, as defined in <code>prefabs.json</code>.
* @member {string}
*/
this.prefab = prefab;
/**
* The origin point in which to create particles.
*
* If the origin is a number it represents an entity and a r... | javascript | {
"resource": ""
} | |
q60034 | centerEntityOnPoint | validation | function centerEntityOnPoint(game, entity, point) {
var size = game.entities.getComponent(entity, "size");
var position = game.entities.addComponent(entity, "position");
position.x = point.x - (size.width / 2);
position.y = point.y - (size.height / 2);
} | javascript | {
"resource": ""
} |
q60035 | choosePointInEntity | validation | function choosePointInEntity(game, entity) {
var position = game.entities.getComponent(entity, "position");
var size = game.entities.getComponent(entity, "size");
if (size === undefined) {
return {
"x": position.x,
"y": position.y
};
}
return {
"x": random.inRange(position.x, (position... | javascript | {
"resource": ""
} |
q60036 | makeBuffer | validation | function makeBuffer(width, height, drawFun) {
var canvas = makeCanvas(width, height);
var ctx = canvas.getContext("2d");
// when image smoothing is enabled, the image gets blurred and the pixel data isn't correct even when the image shouldn't be scaled which breaks NinePatch
if (platform.isEjecta()) {
ctx.i... | javascript | {
"resource": ""
} |
q60037 | flipBufferHorizontally | validation | function flipBufferHorizontally(buffer) {
return makeBuffer(buffer.width, buffer.height, function(context) {
context.scale(-1, 1);
context.drawImage(buffer, -buffer.width, 0);
});
} | javascript | {
"resource": ""
} |
q60038 | flipBufferVertically | validation | function flipBufferVertically(buffer) {
return makeBuffer(buffer.width, buffer.height, function(context) {
context.scale(1, -1);
context.drawImage(buffer, 0, -buffer.height);
});
} | javascript | {
"resource": ""
} |
q60039 | rotateClockwise | validation | function rotateClockwise(buffer) {
var w = buffer.height;
var h = buffer.width;
var w2 = Math.floor(w / 2);
var h2 = Math.floor(h / 2);
return makeBuffer(w, h, function(context) {
context.translate(w2, h2);
context.rotate(Math.PI / 2);
context.drawImage(buffer, -h2, -w2);
});
} | javascript | {
"resource": ""
} |
q60040 | chromeStorageGet | validation | function chromeStorageGet(keys, callback) {
window.chrome.storage.sync.get(keys, function(data) {
if (window.chrome.runtime.lastError) {
callback(window.chrome.runtime.lastError);
} else {
callback(undefined, data);
}
});
} | javascript | {
"resource": ""
} |
q60041 | chromeStorageSet | validation | function chromeStorageSet(data, callback) {
window.chrome.storage.sync.set(data, function() {
callback(window.chrome.runtime.lastError);
});
} | javascript | {
"resource": ""
} |
q60042 | SoundManager | validation | function SoundManager(manifest) {
/**
* A flag signifying if sounds have been muted through {@link SoundManager#mute}.
* @member {boolean}
* @private
*/
this.muted = false;
/**
* A key-value object that stores named looping sounds.
* @member {object}
* @private
*/
this.looping = {};
/... | javascript | {
"resource": ""
} |
q60043 | validation | function (program, callback) {
var config = configHelpers.getConfig();
config.plugins = config.plugins || {};
var loadPlugin = function (pluginName, cb) {
pluginHelpers.loadPlugin(pluginName, program, cb);
};
Object.keys(config.plugins).forEach(loadPlugin);
nodeHelpers.invoke(callback);
... | javascript | {
"resource": ""
} | |
q60044 | validation | function (program, app, callback) {
var attachPlugin = function (pluginName, cb) {
pluginHelpers.start(pluginName, program, app, cb);
};
var plugins = Object.keys(pluginHelpers.loadedPlugins)
async.eachSeries(plugins, attachPlugin, function() {
callback();
});
} | javascript | {
"resource": ""
} | |
q60045 | validation | function (callback) {
var plugins = Object.keys(pluginHelpers.loadedPlugins || {});
async.eachSeries(plugins, pluginHelpers.stop, callback);
} | javascript | {
"resource": ""
} | |
q60046 | validation | function (program, callback) {
var cozyLight = require('./cozy-light');
applicationHelpers.resetDefaultPort();
cozyLight.setStarted();
// start app
var app = express();
var morgand = morgan('combined');
if (expressLog) {
app.use(morgand);
}
pluginHelpers.startAll(program, ap... | javascript | {
"resource": ""
} | |
q60047 | validation | function (apporplugin) {
try {
configHelpers.enable(apporplugin);
logger.info(apporplugin + ' enabled');
} catch (err) {
logger.error(
'Cannot enable given app or plugin, ' +
apporplugin +
' cannot find it in the config file.');
}
} | javascript | {
"resource": ""
} | |
q60048 | validation | function (apporplugin) {
try {
configHelpers.disable(apporplugin);
logger.info(apporplugin + ' disabled');
} catch (err) {
logger.error(
'Cannot disable given app or plugin, ' +
apporplugin +
' cannot find it in the config file.');
logger.raw(err);
}
} | javascript | {
"resource": ""
} | |
q60049 | validation | function (callback) {
var cozyLight = require('./cozy-light');
if (cozyLight.getStatus() === 'started') {
cozyLight.setStopped();
logger.info('Stopping apps...');
return applicationHelpers.stopAll(function (appErr) {
if (appErr) {
logger.error('An error occurred while stoppin... | javascript | {
"resource": ""
} | |
q60050 | validation | function (callback) {
var cozyLight = require('./cozy-light');
logger.info('Restarting...');
actions.stop(function(){
configHelpers.loadConfigFile();
cozyLight.routes = {};
logger.info('Starting all apps...');
pluginHelpers.loadAll(this.program, function() {
actions.start(t... | javascript | {
"resource": ""
} | |
q60051 | validation | function (app, callback) {
var cozyLight = require('./cozy-light');
var config = configHelpers.getConfig();
logger.info('Uninstalling ' + app + '...');
if (config.apps[app] === undefined) {
logger.error(app + ' is not installed.');
nodeHelpers.invoke(callback, true);
} else {
var m... | javascript | {
"resource": ""
} | |
q60052 | validation | function (plugin, callback){
var cozyLight = require('./cozy-light');
var config = configHelpers.getConfig();
logger.info('Removing ' + plugin + '...');
if (config.plugins[plugin] === undefined) {
logger.error(plugin + ' is not installed.');
nodeHelpers.invoke(callback, true);
} else {... | javascript | {
"resource": ""
} | |
q60053 | validation | function (distroName, actions, callback) {
if (distros[distroName] !== undefined) {
var distro = distros[distroName];
logger.info('Installing plugins...');
async.eachSeries(distro.plugins, function addPlugin (pluginName, cb) {
actions.installPlugin(pluginName, cb);
}, function instal... | javascript | {
"resource": ""
} | |
q60054 | validation | function (distroName) {
logger.raw('\n\x1B[36m* ' + distroName + '\x1B[39m');
var logAttributeList = function (key) {
logger.raw(' \x1B[32m' + key + ':\x1B[39m');
var list = distros[distroName][key];
if (list !== undefined && list.length > 0) {
list.forEach(function displayListElem... | javascript | {
"resource": ""
} | |
q60055 | saveWallet | validation | function saveWallet(filename, walletData) {
return new Promise((resolve, reject) => {
fs.writeFile(filename, JSON.stringify(walletData, null, 2), function(err) {
if (err) return reject(console.error(err))
//console.log(`${name}.json written successfully.`)
return resolve()
})
})
} | javascript | {
"resource": ""
} |
q60056 | openWallet | validation | function openWallet(filename) {
try {
// Delete the cached copy of the wallet. This allows testing of list-wallets.
delete require.cache[require.resolve(filename)]
const walletInfo = require(filename)
return walletInfo
} catch (err) {
throw new Error(`Could not open ${filename}`)
}
} | javascript | {
"resource": ""
} |
q60057 | changeAddrFromMnemonic | validation | function changeAddrFromMnemonic(walletInfo, index, BITBOX) {
// root seed buffer
const rootSeed = BITBOX.Mnemonic.toSeed(walletInfo.mnemonic)
// master HDNode
if (walletInfo.network === "testnet")
var masterHDNode = BITBOX.HDNode.fromSeed(rootSeed, "testnet")
else var masterHDNode = BITBOX.HDNode.fromSee... | javascript | {
"resource": ""
} |
q60058 | getUTXOs | validation | async function getUTXOs(walletInfo, BITBOX) {
try {
const retArray = []
// Loop through each address that has a balance.
for (var i = 0; i < walletInfo.hasBalance.length; i++) {
const thisAddr = walletInfo.hasBalance[i].cashAddress
// Get the UTXOs for that address.
const u = await BIT... | javascript | {
"resource": ""
} |
q60059 | validation | function (cozyHome, port) {
fs.mkdirsSync(cozyHome);
configHelpers.setHomePath(cozyHome);
configHelpers.setMainAppPort(parseInt(port));
configHelpers.setDefaultAppsPort(parseInt(port) + 100);
configHelpers.copyDependency('pouchdb');
configHelpers.createConfigFile();
configHelpers.watcher ... | javascript | {
"resource": ""
} | |
q60060 | validation | function () {
var filePath = configHelpers.getConfigPath();
config = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
return config;
} | javascript | {
"resource": ""
} | |
q60061 | validation | function () {
var configString = JSON.stringify(config, null, 2);
fs.writeFileSync(configHelpers.getConfigPath(), configString);
} | javascript | {
"resource": ""
} | |
q60062 | validation | function () {
var exists = fs.existsSync(configHelpers.getConfigPath());
if (!exists) {
config = { apps: {}, plugins: {} };
configHelpers.saveConfig();
}
} | javascript | {
"resource": ""
} | |
q60063 | validation | function (name) {
var destPath = configHelpers.modulePath(name);
var sourcePath = pathExtra.join(__dirname, '..', 'node_modules', name);
if (!fs.existsSync(destPath)) {
fs.copySync(sourcePath, destPath);
}
} | javascript | {
"resource": ""
} | |
q60064 | validation | function (app, manifest) {
if (manifest.type === undefined) {
manifest.type = 'classic';
}
config.apps[app] = {
name: manifest.name,
displayName: manifest.displayName,
version: manifest.version,
description: manifest.description,
type: manifest.type
};
configHelpe... | javascript | {
"resource": ""
} | |
q60065 | validation | function (app) {
var ret = false;
if (config.apps[app] !== undefined) {
delete config.apps[app];
configHelpers.saveConfig();
ret = true;
}
return ret;
} | javascript | {
"resource": ""
} | |
q60066 | validation | function (plugin, manifest) {
if (config.plugins === undefined) {
config.plugins = {};
}
config.plugins[plugin] = {
name: manifest.name,
displayName: manifest.displayName,
version: manifest.version,
description: manifest.description
};
configHelpers.saveConfig();
} | javascript | {
"resource": ""
} | |
q60067 | validation | function (plugin) {
var ret = false;
if (config.plugins[plugin] !== undefined) {
delete config.plugins[plugin];
configHelpers.saveConfig();
ret = true;
}
return ret;
} | javascript | {
"resource": ""
} | |
q60068 | validation | function (apporplugin) {
if (config.plugins[apporplugin] !== undefined) {
config.plugins[apporplugin].disabled = undefined;
configHelpers.saveConfig();
} else if (config.apps[apporplugin] !== undefined) {
config.apps[apporplugin].disabled = undefined;
configHelpers.saveConfig();
} el... | javascript | {
"resource": ""
} | |
q60069 | validation | function () {
var plugins = {};
Object.keys(config.plugins || {}).forEach(function(name){
var template = '';
//if (loadedPlugins[name] && loadedPlugins[name].getTemplate) {
// template = loadedPlugins[name].getTemplate(config);
//}
plugins[name] = {
name: config.plugins[na... | javascript | {
"resource": ""
} | |
q60070 | validation | function () {
var apps = {};
var baseUrl = configHelpers.getServerUrl();
Object.keys(config.apps || {}).forEach(function(name){
apps[name] = {
name: config.apps[name].name,
displayName: config.apps[name].displayName,
version: config.apps[name].version,
url: baseUrl + '/... | javascript | {
"resource": ""
} | |
q60071 | validation | function (app, callback) {
var options = {
local: true,
dir: configHelpers.getModulesPath(),
prefix: ''
};
npm.load(options, function () {
app = pathExtra.resolve(npmHelpers.initialWd, app);
npm.commands.link([app], callback);
});
} | javascript | {
"resource": ""
} | |
q60072 | validation | function (app, callback) {
var options = {
dir: configHelpers.getModulesPath(),
prefix: ''
};
npm.load(options, function () {
npm.commands.uninstall([app], callback);
});
} | javascript | {
"resource": ""
} | |
q60073 | validation | function (app, callback) {
var appPath = pathExtra.resolve(npmHelpers.initialWd, app);
var manifestPath = pathExtra.join(appPath, 'package.json');
if (fs.existsSync(appPath) && fs.existsSync(manifestPath)) {
fs.readFile(manifestPath, function checkError (err, manifest) {
if (err) {
... | javascript | {
"resource": ""
} | |
q60074 | validation | function (msg) {
// Convert binary blobs into native buffers pre-send
if (msg && msg.message && msg.message.message &&
msg.message.message.binary) {
var out = [], i = 0;
for (i = 0; i < msg.message.message.binary.length; i += 1) {
out.push(new Buffer(new Uint8Array(msg.message.messag... | javascript | {
"resource": ""
} | |
q60075 | validation | function (script) {
var file, name;
try {
//TODO: enforce constrained location of loaded files.
if (script.indexOf('node://') === 0) {
name = script.substr(7);
}
file = fs.readFileSync(name);
vm.runInContext(file, freedomVM, name);
} catch (e) {
console.error(e);
... | javascript | {
"resource": ""
} | |
q60076 | sortPitches | validation | function sortPitches (pitches) {
return pitches.map(Pitch).sort(function (a, b) {
return a - b
}).map(function (pitch) {
return pitch.sciPitch()
})
} | javascript | {
"resource": ""
} |
q60077 | parseNavItem | validation | function parseNavItem (item) {
if (item.route === req.path) {
item.isActive = true;
}
// replace object by array structure
var childArray = [];
for (var child in item.children) {
var subItem = parseNavItem( item.children[ child ] );
if (subIte... | javascript | {
"resource": ""
} |
q60078 | userHasAccess | validation | function userHasAccess (item) {
if (typeof item.isSecure !== 'boolean' || item.isSecure === false) {
// page has no security settings or false, let user pass
return true;
} else {
// page is secured, check if user has access
var pageRoles = item.roles;
... | javascript | {
"resource": ""
} |
q60079 | validation | function(scope){
if(!scope) throw('textAngular Error: A toolbar requires a scope');
if(!scope.name || scope.name === '') throw('textAngular Error: A toolbar requires a name');
if(toolbars[scope.name]) throw('textAngular Error: A toolbar with name "' + scope.name + '" already exists');
toolbars[scope.name] =... | javascript | {
"resource": ""
} | |
q60080 | validation | function(name){
var result = [], _this = this;
angular.forEach(this.retrieveEditor(name).toolbars, function(name){
result.push(_this.retrieveToolbar(name));
});
return result;
} | javascript | {
"resource": ""
} | |
q60081 | validation | function(newTaTools){
// pass a partial struct of the taTools, this allows us to update the tools on the fly, will not change the defaults.
var _this = this;
angular.forEach(newTaTools, function(_newTool, key){
_this.updateToolDisplay(key, _newTool);
});
} | javascript | {
"resource": ""
} | |
q60082 | validation | function(toolKey, _newTool){
var _this = this;
angular.forEach(toolbars, function(toolbarScope, toolbarKey){
_this.updateToolbarToolDisplay(toolbarKey, toolKey, _newTool);
});
} | javascript | {
"resource": ""
} | |
q60083 | validation | function(toolbarKey, toolKey, _newTool){
if(toolbars[toolbarKey]) toolbars[toolbarKey].updateToolDisplay(toolKey, _newTool);
else throw('textAngular Error: No Toolbar with name "' + toolbarKey + '" exists');
} | javascript | {
"resource": ""
} | |
q60084 | validation | function(toolbarKey, toolKey){
if(toolbars[toolbarKey]) toolbars[toolbarKey].updateToolDisplay(toolKey, taTools[toolKey], true);
else throw('textAngular Error: No Toolbar with name "' + toolbarKey + '" exists');
} | javascript | {
"resource": ""
} | |
q60085 | validation | function(toolKey){
delete taTools[toolKey];
angular.forEach(toolbars, function(toolbarScope){
delete toolbarScope.tools[toolKey];
for(var i = 0; i < toolbarScope.toolbar.length; i++){
var toolbarIndex;
for(var j = 0; j < toolbarScope.toolbar[i].length; j++){
if(toolbarScope.toolbar[i][j] =... | javascript | {
"resource": ""
} | |
q60086 | validation | function(toolKey, toolDefinition, group, index){
taRegisterTool(toolKey, toolDefinition);
angular.forEach(toolbars, function(toolbarScope){
toolbarScope.addTool(toolKey, toolDefinition, group, index);
});
} | javascript | {
"resource": ""
} | |
q60087 | validation | function(toolKey, toolDefinition, toolbarKey, group, index){
taRegisterTool(toolKey, toolDefinition);
toolbars[toolbarKey].addTool(toolKey, toolDefinition, group, index);
} | javascript | {
"resource": ""
} | |
q60088 | validation | function(element, attribute){
var resultingElements = [];
var childNodes = element.children();
if(childNodes.length){
angular.forEach(childNodes, function(child){
resultingElements = resultingElements.concat(taDOM.getByAttribute(angular.element(child), attribute));
});
}
if(element.attr(attr... | javascript | {
"resource": ""
} | |
q60089 | validation | function (elem, eventName, callback) {
var listener = function (event) {
event = event || window.event;
var target = event.target || event.srcElement;
var block = callback.apply(elem, [event, target]);
if (block === false) {
if (!!event.preventDefault) event.preventDefault();
else {
event.ret... | javascript | {
"resource": ""
} | |
q60090 | validation | function (elem, event, listener) {
if (elem.detachEvent) { // IE only. The "on" is mandatory.
elem.detachEvent("on" + event, listener);
} else { // Other browsers.
elem.removeEventListener(event, listener, false);
}
} | javascript | {
"resource": ""
} | |
q60091 | addOrSubtractDurationFromMoment | validation | function addOrSubtractDurationFromMoment(mom, duration, isAdding, ignoreUpdateOffset) {
var milliseconds = duration._milliseconds,
days = duration._days,
months = duration._months,
minutes,
hours,
currentDate;
if (milliseconds) {
m... | javascript | {
"resource": ""
} |
q60092 | getLangDefinition | validation | function getLangDefinition(key) {
if (!key) {
return moment.fn._lang;
}
if (!languages[key] && hasModule) {
try {
require('./lang/' + key);
} catch (e) {
// call with no params to set to default
return moment.fn.... | javascript | {
"resource": ""
} |
q60093 | formatMoment | validation | function formatMoment(m, format) {
var i = 5;
function replaceLongDateFormatTokens(input) {
return m.lang().longDateFormat(input) || input;
}
while (i-- && localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormat... | javascript | {
"resource": ""
} |
q60094 | addTimeToArrayFromToken | validation | function addTimeToArrayFromToken(token, input, config) {
var a, datePartArray = config._a;
switch (token) {
// MONTH
case 'M' : // fall through to MM
case 'MM' :
datePartArray[1] = (input == null) ? 0 : ~~input - 1;
break;
case 'MMM' : // fall thr... | javascript | {
"resource": ""
} |
q60095 | makeDateFromStringAndFormat | validation | function makeDateFromStringAndFormat(config) {
// This array is used to make a Date, either with `new Date` or `Date.UTC`
var tokens = config._f.match(formattingTokens),
string = config._i,
i, parsedInput;
config._a = [];
for (i = 0; i < tokens.length; i++) {
... | javascript | {
"resource": ""
} |
q60096 | makeDateFromString | validation | function makeDateFromString(config) {
var i,
string = config._i,
match = isoRegex.exec(string);
if (match) {
// match[2] should be "T" or undefined
config._f = 'YYYY-MM-DD' + (match[2] || " ");
for (i = 0; i < 4; i++) {
if (iso... | javascript | {
"resource": ""
} |
q60097 | _loadProcessor | validation | function _loadProcessor(processorName) {
const compatibleVersion = compatibleProcessors[processorName]
// Check if module is compatible
if(compatibleVersion === undefined) {
const error = new Error(`Processor ${processorName} is not supported yet.`)
error.code = 'MODULE_NOT_SUPPORTED'
throw error
}
return ... | javascript | {
"resource": ""
} |
q60098 | getJson | validation | function getJson(filename, cb) {
fs.readFile(filename, function(err, data) {
if (err) return cb(err, null)
try {
var json = JSON.parse(data)
cb(null, json)
} catch(e) {
cb(e, null)
}
})
} | javascript | {
"resource": ""
} |
q60099 | sauceConfigured | validation | function sauceConfigured(config) {
var sauceAccessKey = config.access_key
var sauceUsername = config.username
if (!sauceAccessKey || !sauceUsername) {
return false
}
return true
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.