_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q48300 | train | function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
value = "" + value + "... | javascript | {
"resource": ""
} | |
q48301 | train | function () {
return !!storage && function() {
// in mobile safari if safe browsing is enabled, window.storage
// is defined but setItem calls throw exceptions.
var success = true
var value = Math.random()
try {
storage.se... | javascript | {
"resource": ""
} | |
q48302 | train | function( callback ) {
var me = this;
root( this, function( store ) {
ls( store.createReader(), function( entries ) {
if ( callback ) me.fn( 'keys', callback ).call( me, entries );
});
});
return this;
} | javascript | {
"resource": ""
} | |
q48303 | train | function( objs, callback ) {
var me = this;
var saved = [];
for ( var i = 0, il = objs.length; i < il; i++ ) {
me.save( objs[i], function( obj ) {
saved.push( obj );
if ( saved.length === il && callback ) {
... | javascript | {
"resource": ""
} | |
q48304 | train | function () {
for (var i = 0, l = methods.length; i < l; i++) {
this.evented(methods[i])
}
} | javascript | {
"resource": ""
} | |
q48305 | onupgradeneeded | train | function onupgradeneeded() {
self.db = request.result;
self.transaction = request.transaction;
// NB! in case of a version conflict, we don't try to migrate,
// instead just throw away the old store and create a new one.
// this happens if somebody changed th... | javascript | {
"resource": ""
} |
q48306 | onsuccess | train | function onsuccess(event) {
// remember the db instance
self.db = event.target.result;
// storage is now possible
self.store = true;
// execute all pending operations
while (self.waiting.length) {
self.waiting.shift().call(self);
... | javascript | {
"resource": ""
} |
q48307 | train | function (property, callback) {
// if only one arg we count the collection
if ([].slice.call(arguments).length === 1) {
callback = property
property = 'key'
}
var c = 0
this.each(function(e){
if (e[property]) c++
})
this.fn('... | javascript | {
"resource": ""
} | |
q48308 | train | function (property, callback) {
var sum = 0
this.each(function(e){
if (e[property]) sum += e[property]
})
this.fn('sum', callback).call(this, sum)
} | javascript | {
"resource": ""
} | |
q48309 | train | function (property, callback) {
this.sum(property, function (sum) {
this.count(property, function (count) {
this.fn('avg', callback).call(this, sum/count)
})
})
} | javascript | {
"resource": ""
} | |
q48310 | train | function() {
// ever notice we do this sort thing lots?
var args = [].slice.call(arguments)
, tmpl = args.shift()
, last = args[args.length - 1]
, qs = tmpl.match(/\?/g)
, q = qs && qs.length > 0 ? interpolate(tmpl, args.slice(0, qs.le... | javascript | {
"resource": ""
} | |
q48311 | showDiff | train | function showDiff(acediff, editor, startLine, endLine, className) {
var editor = acediff.editors[editor];
if (endLine < startLine) { // can this occur? Just in case.
endLine = startLine;
}
const classNames = `${className} ${(endLine > startLine) ? 'lines' : 'targetOnly'}`;
endLine--; // because endLine ... | javascript | {
"resource": ""
} |
q48312 | updateGap | train | function updateGap(acediff, editor, scroll) {
clearDiffs(acediff);
decorate(acediff);
// reposition the copy containers containing all the arrows
positionCopyContainers(acediff);
} | javascript | {
"resource": ""
} |
q48313 | getSingleDiffInfo | train | function getSingleDiffInfo(editor, offset, diffString) {
const info = {
startLine: 0,
startChar: 0,
endLine: 0,
endChar: 0,
};
const endCharNum = offset + diffString.length;
let runningTotal = 0;
let startLineSet = false,
endLineSet = false;
editor.lineLengths.forEach((lineLength, lineI... | javascript | {
"resource": ""
} |
q48314 | createCopyContainers | train | function createCopyContainers(acediff) {
acediff.copyRightContainer = document.createElement('div');
acediff.copyRightContainer.setAttribute('class', acediff.options.classes.copyRightContainer);
acediff.copyLeftContainer = document.createElement('div');
acediff.copyLeftContainer.setAttribute('class', acediff.op... | javascript | {
"resource": ""
} |
q48315 | generatePrefixed | train | function generatePrefixed(prefix) {
let output = '';
let children = '';
for (const part of allParts) {
const parts = prefix.concat([part]);
if (prefix.indexOf(part) !== -1 || !verify(parts, true)) {
// Function already in prefix or not allowed here
continue;
}
// If `parts` is not sorted, we alias i... | javascript | {
"resource": ""
} |
q48316 | hasChildren | train | function hasChildren(parts) {
// Concatenate the chain with each other part, and see if any concatenations are valid functions
const validChildren = allParts
.filter(newPart => parts.indexOf(newPart) === -1)
.map(newPart => parts.concat([newPart]))
.filter(longer => verify(longer, false));
return validChildre... | javascript | {
"resource": ""
} |
q48317 | exists | train | function exists(parts) {
if (verify(parts, false)) {
// Valid function name
return true;
}
if (!verify(parts, true)) {
// Not valid prefix
return false;
}
// Valid prefix, check whether it has members
for (const prefix of allParts) {
if (parts.indexOf(prefix) === -1 && exists(parts.concat([prefix]))) ... | javascript | {
"resource": ""
} |
q48318 | hash | train | function hash (str) {
return crypto
.createHash('sha1')
.update(str, 'ascii')
.digest('base64')
.replace(PLUS_GLOBAL_REGEXP, '-')
.replace(SLASH_GLOBAL_REGEXP, '_')
.replace(EQUAL_GLOBAL_REGEXP, '')
} | javascript | {
"resource": ""
} |
q48319 | train | function(servers, options) {
this.servers = servers;
this.seq = 0;
this.options = merge(options || {},
{failoverTime: 60, retries: 2, retry_delay: 0.2, expires: 0, logger: console});
} | javascript | {
"resource": ""
} | |
q48320 | prompt | train | function prompt (next) {
var fields = ['name', 'author', 'description', 'homepage'];
app.prompt.override = {name: name};
app.prompt.start();
app.prompt.addProperties(info, fields, next);
} | javascript | {
"resource": ""
} |
q48321 | ensureDestroy | train | function ensureDestroy(callback) {
app.prompt.get(['destroy'], function (err, result) {
if (result.destroy !== 'yes' && result.destroy !== 'y') {
app.log.warn('Destructive operation cancelled');
return callback(true);
}
callback();
});
} | javascript | {
"resource": ""
} |
q48322 | executeCommand | train | function executeCommand(parts, callback) {
var name,
shouldLoad = true,
command,
usage;
if (typeof parts === 'undefined' || typeof parts === 'function') {
throw(new Error('parts is a required argument of type Array'));
}
name = parts.shift();
if (app.cli.source || ap... | javascript | {
"resource": ""
} |
q48323 | randomatic | train | function randomatic(pattern, length, options) {
if (typeof pattern === 'undefined') {
throw new Error('randomatic expects a string or number.');
}
var custom = false;
if (arguments.length === 1) {
if (typeof pattern === 'string') {
length = pattern.length;
} else if (isNumber(pattern)) {
... | javascript | {
"resource": ""
} |
q48324 | train | function (port = 9090) {
return store => {
const getId = idGenerator();
// initialize socket connection
const socket = io('http://localhost:' + port);
// register event noting connection to sockets (client app)
let initEvent = buildEvent(getId(), 'CONNECTED TO SERVER', 'Successfully connected Vuet... | javascript | {
"resource": ""
} | |
q48325 | buildEvent | train | function buildEvent (id, title, display, hidden = {}) {
const eventObj = {
id,
title,
display,
hidden,
status: 'active',
timestamp: new Date(Date.now()).toISOString()
};
return eventObj;
} | javascript | {
"resource": ""
} |
q48326 | sendScreenshot | train | function sendScreenshot (name, runId, metaData, properties, compareSettings, png) {
return _callServer('post', 'runs/' + runId + '/screenshots', null, {
meta: JSON.stringify(metaData),
properties: JSON.stringify(properties),
compareSettings: JSON.stringify(compareSettings),
screenshotName: name,
file: {
v... | javascript | {
"resource": ""
} |
q48327 | initRun | train | function initRun (projectName, suiteName, branchName) {
if(_disabled) {
return q.resolve();
}
return _client.createRun(projectName, suiteName, branchName).then( function (createdRun) {
if (createdRun) {
_logMessage('created run with ID ' + createdRun.run_id);
return _writeRunIdFile(JSON.... | javascript | {
"resource": ""
} |
q48328 | takeScreenshot | train | function takeScreenshot (name) {
if(_disabled) {
return q.resolve();
}
return browser.driver.controlFlow().execute(function () {
return q.all([_getProperties(browser), _getMetaData(browser), browser.takeScreenshot(), _readRunIdFile()]).then(function (results) {
var properties = results[0],
... | javascript | {
"resource": ""
} |
q48329 | cleanup | train | function cleanup (exitCode) {
if(_disabled) {
return q.resolve();
}
var defer = q.defer();
_readRunIdFile().then(function (run) {
_logMessage('test finished. Your results can be viewed at: ' +
'http://' + _hostname + ':' + _port + '/#/' + run.project_id + '/' + run.suite_id + '/' + run.run_id + ... | javascript | {
"resource": ""
} |
q48330 | extractionFunction | train | function extractionFunction(type) {
if (utils.isObject(type)) {
return type
}
else if (!fns.hasOwnProperty(type)) {
throw new FieldError('Unknown DimExtractionFn type: ' + type)
}
var args = utils.args(arguments, 1)
, fn = {
type: type
}
fns[type].apply(fn, args)
return fn
} | javascript | {
"resource": ""
} |
q48331 | loadFields | train | function loadFields(list, callback) {
list.forEach(loadMethods)
function loadMethods(field) {
var module = require('./fields/' + field + '.js')
, methods
if (typeof module === 'function' || typeof module === 'string') {
methods = {}
methods[field] = module
}
else {
methods ... | javascript | {
"resource": ""
} |
q48332 | Query | train | function Query(client, rawQuery) {
if (client) {
/**
* If set, query is attached to given client instance
*
* @private
* @type {Druid|Client}
*/
this.client = client
}
/**
* Actual query object
*
* @private
*/
this._query = {
queryType: this._queryType
}
i... | javascript | {
"resource": ""
} |
q48333 | aggregation | train | function aggregation(type, name) {
if (utils.isObject(type)) {
return type
}
if (!name) {
throw new FieldError('Missing aggregation output name')
}
else if (!aggregations.hasOwnProperty(type)) {
throw new FieldError('Unknown aggregation type: ' + type)
}
var args = utils.args(arguments, 2)
... | javascript | {
"resource": ""
} |
q48334 | asyncMap | train | function asyncMap(array, iterator, done) {
if (!array || !array.length) {
return done(null, [])
}
var error
, out = []
, todo = array.length
array.forEach(exec)
function exec(item) {
process.nextTick(function tick() {
iterator(item, add)
})
}
function add(err, data) {
if ... | javascript | {
"resource": ""
} |
q48335 | getLessLoaded | train | function getLessLoaded(client, dataSource) {
var ids = client.dataSources[dataSource]
, nodes
, node
nodes = ids.map(id2client)
function id2client(id) {
return client.nodes[id]
}
node = nodes.reduce(lessLoaded)
function lessLoaded(nodeA, nodeB) {
if (nodeA.active < nodeB.active) {
... | javascript | {
"resource": ""
} |
q48336 | getNodeData | train | function getNodeData(client, id, callback) {
var path = client.discoveryPath + '/' + id
, preferSSL = client.options.preferSSL
client.zk.getData(path, handleData)
function handleData(err, jsonBuffer) {
if (err) {
return callback(new DruidError('Error getting node data', err))
}
debug('Zoo... | javascript | {
"resource": ""
} |
q48337 | initZookeeper | train | function initZookeeper(client, connectionString) {
var zk = zookeeper.createClient(connectionString, client.options.zookeeper)
var error = false
var connected = false
client.ready = false
client.zk = zk
zk.connect()
zk.on('connected', onconnected)
zk.on('expired', setError)
zk.on('authenticationFail... | javascript | {
"resource": ""
} |
q48338 | Druid | train | function Druid(connectionString, discoveryPath, options) {
EventEmitter.call(this)
this.setMaxListeners(0)
if (arguments.length === 2) {
options = {}
}
/**
* Services discovery path
*
* @protected
* @type {string}
*/
this.discoveryPath = discoveryPath
/**
* Client options
*
... | javascript | {
"resource": ""
} |
q48339 | filter | train | function filter(type) {
if (utils.isObject(type)) {
return type
}
else if (!filters.hasOwnProperty(type)) {
throw new FieldError('Bad filter type: ' + type)
}
var args = utils.args(arguments, 1)
, filter = {
type: type
}
filters[type].apply(filter, args)
return filter
} | javascript | {
"resource": ""
} |
q48340 | dataSource | train | function dataSource(type) {
if (arguments.length === 1 && (utils.isObject(type) || typeof type === 'string')) {
return type
}
else if (!ds.hasOwnProperty(type)) {
throw new FieldError('Unknown data source type: ' + type)
}
var args = utils.args(arguments, 1)
, dataSource = {
type: type
... | javascript | {
"resource": ""
} |
q48341 | orderBy | train | function orderBy(dimension, direction) {
if (arguments.length === 1) {
direction = 'ASCENDING'
}
if (!dimension) {
throw new FieldError('Dimension is not specified')
}
else if (!~['ascending', 'descending'].indexOf(direction.toLowerCase())) {
throw new FieldError('Bad orderBy direction: ' + direc... | javascript | {
"resource": ""
} |
q48342 | sort | train | function sort(type) {
if (!~SORT_TYPES.indexOf(type)) {
throw new FieldError('Sorting type can be ' + SORT_TYPES.join(' or '))
}
return {
type: type
}
} | javascript | {
"resource": ""
} |
q48343 | dimension | train | function dimension(dimension, outputName, fn) {
if (!dimension) {
throw new FieldError('At least dimension must be specified')
}
if (arguments.length === 1 && typeof dimension === 'object') {
return dimension
}
if (arguments.length === 1) {
return {
type: 'default',
dimension: d... | javascript | {
"resource": ""
} |
q48344 | query | train | function query(type, value, caseSensitive) {
if (utils.isObject(type)) {
return type
}
else if (!type || !value) {
throw new FieldError('Type or value is not specified')
}
// InsensitiveContainsSearchQuerySpec
else if (type === 'insensitive_contains') {
return {
type: 'insensitive_contai... | javascript | {
"resource": ""
} |
q48345 | limitSpec | train | function limitSpec(type, limit, orderByColumns) {
if (utils.isObject(type)) {
return type
}
if (typeof limit !== 'number') {
limit = parseInt(limit, 10)
}
if (type !== 'default') {
throw new FieldError('Currently only DefaultLimitSpec is supported')
}
else if (isNaN(limit)) {
throw new F... | javascript | {
"resource": ""
} |
q48346 | context | train | function context(value) {
var out = {}
value = value || {}
;['priority', 'timeout'].forEach(function eachIntKey(key) {
if (value.hasOwnProperty(key)) {
out[key] = parseInt(value[key], 10)
if (isNaN(out[key])) {
throw new FieldTypeError('context.' + key, 'number')
}
}
})
... | javascript | {
"resource": ""
} |
q48347 | postAggregation | train | function postAggregation(type, name) {
if (utils.isObject(type)) {
return type
}
if (!name) {
throw new FieldError('Missing post-aggregation name')
}
else if (!postAggregations.hasOwnProperty(type)) {
throw new FieldError('Unknown post-aggregation type: ' + type)
}
var args = utils.args(argu... | javascript | {
"resource": ""
} |
q48348 | toInclude | train | function toInclude(value) {
if (Array.isArray(value)) {
return {
type: 'list',
columns: value
}
}
else if (typeof value === 'string' && (value === 'all' || value === 'none')) {
return {
type: value
}
}
else if (utils.isObject(value)) {
return value
}
else {
thr... | javascript | {
"resource": ""
} |
q48349 | interval | train | function interval(start, end) {
if (arguments.length === 1 && typeof start === 'string') {
return start
}
else if (arguments.length === 2) {
var interval = utils.args(arguments, 0)
return interval.map(function(original) {
var arg = utils.date(original)
if (!arg) {
throw new Field... | javascript | {
"resource": ""
} |
q48350 | having | train | function having(type) {
if (utils.isObject(type)) {
return type
}
else if (!specs.hasOwnProperty(type)) {
throw new FieldError('Bad having type: ' + type)
}
var args = utils.args(arguments, 1)
, having = {
type: type
}
specs[type].apply(having, args)
return having
} | javascript | {
"resource": ""
} |
q48351 | createBody | train | function createBody(ast) {
if (util.hasType(ast, 'tbody')) return;
var open = ast.nodes.shift();
var close = ast.nodes.pop();
var started;
var nodes = [];
var tbody;
var len = ast.nodes.length;
var idx = -1;
while (++idx < len) {
var node = ast.nodes[idx];
if (node.type === 'tr' && !started) ... | javascript | {
"resource": ""
} |
q48352 | needsSpace | train | function needsSpace(a, b) {
var aa = a.slice(-1);
var bb = b.charAt(0);
if (bb === '.' && /\w/.test(b.charAt(1)) && aa !== '\n') {
return true;
}
if (utils.isEndingChar(bb)) {
return false;
}
if (aa === '`' && !/\s/.test(a.charAt(a.length - 2))) {
return true;
}
if (/[*_]/.test(aa) && ... | javascript | {
"resource": ""
} |
q48353 | Breakdance | train | function Breakdance(options) {
if (typeof options === 'string') {
let proto = Object.create(Breakdance.prototype);
Breakdance.call(proto);
return proto.render.apply(proto, arguments);
}
if (!(this instanceof Breakdance)) {
let proto = Object.create(Breakdance.prototype);
Breakdance.call(proto... | javascript | {
"resource": ""
} |
q48354 | replaceStringInAsset | train | function replaceStringInAsset(asset, source, target) {
const sourceRE = new RegExp(source, 'g');
if (typeof asset === 'string') {
return asset.replace(sourceRE, target);
}
// ReplaceSource
if ('_source' in asset) {
asset._source = replaceStringInAsset(asset._source, source, target)... | javascript | {
"resource": ""
} |
q48355 | reHashChunk | train | function reHashChunk(chunk, assets, hashFn, nameMap) {
const isMainFile = file => file.endsWith('.js') || file.endsWith('.css');
// Update the name of the main files
chunk.files.filter(isMainFile).forEach((oldChunkName, index) => {
const asset = assets[oldChunkName];
const { fullHash, short... | javascript | {
"resource": ""
} |
q48356 | replaceOldHashForNewInChunkFiles | train | function replaceOldHashForNewInChunkFiles(chunk, assets, oldHashToNewHashMap) {
chunk.files.forEach(file => {
Object.keys(oldHashToNewHashMap).forEach(oldHash => {
const newHash = oldHashToNewHashMap[oldHash];
replaceStringInAsset(assets[file], oldHash, newHash);
});
});
... | javascript | {
"resource": ""
} |
q48357 | AnimationFrame | train | function AnimationFrame(options) {
if (!(this instanceof AnimationFrame)) return new AnimationFrame(options)
options || (options = {})
// Its a frame rate.
if (typeof options == 'number') options = {frameRate: options}
options.useNative != null || (options.useNative = true)
this.options = optio... | javascript | {
"resource": ""
} |
q48358 | Intersector | train | function Intersector () {
this.arrowHelper = this.createArrowHelper();
this.raycaster = new THREE.Raycaster(new THREE.Vector3(), new THREE.Vector3(), 0, 0.2);
} | javascript | {
"resource": ""
} |
q48359 | HandBody | train | function HandBody (el, handComponent) {
this.el = el;
this.handComponent = handComponent;
this.system = this.el.sceneEl.systems.leap;
this.physics = this.el.sceneEl.systems.physics;
this.physics.addComponent(this);
this.palmBody = /** @type {CANNON.Body} */ null;
this.fingerBodies = /** @type {{string: C... | javascript | {
"resource": ""
} |
q48360 | HandMesh | train | function HandMesh(options) {
this.options = options = Object.assign({}, DEFAULTS, options || {});
this.options.jointColor = this.options.jointColor || JOINT_COLORS[numInstances % 2];
this.object3D = new THREE.Object3D();
this.material = !isNaN(options.opacity) ? new THREE.MeshPhongMaterial({
fog: ... | javascript | {
"resource": ""
} |
q48361 | exists | train | function exists(el, arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].element.isEqualNode(el))
return arr[i];
}
return false;
} | javascript | {
"resource": ""
} |
q48362 | argsByRules | train | function argsByRules(argsArray, rules) {
var params = rules || ['x', 'y', 'width', 'height'],
args = {};
for (var i = 0; i < argsArray.length; i++) {
if (typeof(argsArray[i]) === "object")
args["style"] = argsArray[i];
else
if (params.length)
args[params.shift()] = argsArray[i];
}
... | javascript | {
"resource": ""
} |
q48363 | smartCoordinates | train | function smartCoordinates(args) {
var x = args.x,
y = args.y;
var paper = Origami.getPaper(),
elmWidth = paper.element.width,
elmHeight = paper.element.height,
radius = (args.r || 0);
var width = (args.width || radius),
height = (args.height || width);
var axis = {
x: [ 'right', 'cent... | javascript | {
"resource": ""
} |
q48364 | defineDocumentStyles | train | function defineDocumentStyles() {
for (var i = 0; i < document.styleSheets.length; i++) {
var mysheet = document.styleSheets[i],
myrules = mysheet.cssRules ? mysheet.cssRules : mysheet.rules;
config.documentStyles.push(myrules);
}
} | javascript | {
"resource": ""
} |
q48365 | styleRuleValueFrom | train | function styleRuleValueFrom(selector, documentStyleRules) {
for (var j = 0; j < documentStyleRules.length; j++) {
if (documentStyleRules[j].selectorText && documentStyleRules[j].selectorText.toLowerCase() === selector) {
return documentStyleRules[j].style;
}
}
} | javascript | {
"resource": ""
} |
q48366 | setterFor | train | function setterFor(objName) {
return function(name, value) {
if(this["_"+objName+"sUsed"] === true) {
this["_"+objName+"s"] = myUtil.extend({}, this["_"+objName+"s"]);
this["_"+objName+"sUsed"] = false;
}
var obj = this["_"+objName+"s"];
if(!(name in obj))
throw new Error("Unknown "+objName+" `"+name... | javascript | {
"resource": ""
} |
q48367 | TermState | train | function TermState(options) {
TermState.super_.call(this, {
decodeStrings: false
});
options = myUtil.extend({
attributes: {},
}, options);
this._defaultAttr = myUtil.extend({
fg: null,
bg: null,
bold: false,
underline: false,
italic: false,
blink: false,
inverse: false
}, options.attributes);
... | javascript | {
"resource": ""
} |
q48368 | getWidth | train | function getWidth(stringWidth, str) {
if (!stringWidth || !stringWidth.toLowerCase)
return str.length;
switch (stringWidth.toLowerCase()) {
case "wcwidth":
return wcwidth(str);
case "dbcs":
return dbcswidth(str);
case "length":
return str.length;
default:
return str.length;
}
} | javascript | {
"resource": ""
} |
q48369 | indexOfWidth | train | function indexOfWidth(stringWidth, str, width) {
if (stringWidth === false)
return width;
for (var i = 0; i <= str.length; i++) {
if (getWidth(stringWidth, str.substr(0, i)) > width)
return i - 1;
}
return str.length;
} | javascript | {
"resource": ""
} |
q48370 | substrWidth | train | function substrWidth(stringWidth, str, startWidth, width) {
var length = width;
var start = startWidth;
var prefixSpace = 0, suffixSpace;
if (stringWidth !== false) {
start = indexOfWidth(stringWidth, str, startWidth);
if (getWidth(stringWidth, str.substr(0, start)) < startWidth) {
start++;
prefixSpace = ... | javascript | {
"resource": ""
} |
q48371 | Terminal | train | function Terminal(options) {
Terminal.super_.call(this, { decodeStrings: false });
this.options = myUtil.extend({
columns: 80,
rows: 24,
attributes: {}
}, options || {});
this.rows = ~~this.rows;
this.columns = ~~this.columns;
this.state = new TermState(this.options);
this.oldChunk = null;
this.on("pipe"... | javascript | {
"resource": ""
} |
q48372 | ShadowAlphaBroken | train | function ShadowAlphaBroken() {
var cv = NewCanvas(3,3), c, i;
if(!cv)
return false;
c = cv.getContext('2d');
c.strokeStyle = '#000';
c.shadowColor = '#fff';
c.shadowBlur = 3;
c.globalAlpha = 0;
c.strokeRect(2,2,2,2);
c.globalAlpha = 1;
i = c.getImageData(2,2,1,1);
cv = null;
return (i.data[0... | javascript | {
"resource": ""
} |
q48373 | RoundImage | train | function RoundImage(i, r, iw, ih, s) {
var cv, c, r1 = parseFloat(r), l = max(iw, ih);
cv = NewCanvas(iw, ih);
if(!cv)
return null;
if(r.indexOf('%') > 0)
r1 = l * r1 / 100;
else
r1 = r1 * s;
c = cv.getContext('2d');
c.globalCompositeOperation = 'source-over';
c.fillStyle = '#fff';
if(r1 >... | javascript | {
"resource": ""
} |
q48374 | AddShadowToImage | train | function AddShadowToImage(i, w, h, scale, sc, sb, so) {
var sw = abs(so[0]), sh = abs(so[1]),
cw = w + (sw > sb ? sw + sb : sb * 2) * scale,
ch = h + (sh > sb ? sh + sb : sb * 2) * scale,
xo = scale * ((sb || 0) + (so[0] < 0 ? sw : 0)),
yo = scale * ((sb || 0) + (so[1] < 0 ? sh : 0)), cv, c;
cv = Ne... | javascript | {
"resource": ""
} |
q48375 | train | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_colour",
"name": "COLOUR",
"colour": "#ff0000"
}
],
"output": "Colour",
"colour": Blockly.Blocks.colour.HUE,
"helpUrl": Blockly.Msg.COLOUR_PICKER_HELPURL
}... | javascript | {
"resource": ""
} | |
q48376 | train | function() {
this.jsonInit({
"message0": Blockly.Msg.COLOUR_RANDOM_TITLE,
"output": "Colour",
"colour": Blockly.Blocks.colour.HUE,
"tooltip": Blockly.Msg.COLOUR_RANDOM_TOOLTIP,
"helpUrl": Blockly.Msg.COLOUR_RANDOM_HELPURL
});
} | javascript | {
"resource": ""
} | |
q48377 | train | function() {
this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendValueInput('RED')
.setCheck('Number')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_RGB_TITLE)
.appendField(Blockly.Msg.COLOUR_RGB_RED);
th... | javascript | {
"resource": ""
} | |
q48378 | train | function() {
this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL);
this.setColour(Blockly.Blocks.colour.HUE);
this.appendValueInput('COLOUR1')
.setCheck('Colour')
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.COLOUR_BLEND_TITLE)
.appendField(Blockly.Msg.COLOUR_BLEND_CO... | javascript | {
"resource": ""
} | |
q48379 | train | function() {
this.appendDummyInput()
.appendField('dropdown')
.appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
this.optionCount_ = 3;
this.updateShape_();
this.setPreviousStatement(true, 'Field');
this.setNextStatement(true, 'Field');
this.setMutator(new Blockly.Mut... | javascript | {
"resource": ""
} | |
q48380 | train | function() {
this.setColour(160);
this.appendDummyInput()
.appendField('option');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip('Add a new option to the dropdown menu.');
this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=386');
this.contex... | javascript | {
"resource": ""
} | |
q48381 | train | function() {
this.setColour(160);
this.appendDummyInput()
.appendField('variable')
.appendField(new Blockly.FieldTextInput('item'), 'TEXT')
.appendField(',')
.appendField(new Blockly.FieldTextInput('NAME'), 'FIELDNAME');
this.setPreviousStatement(true, 'Field');
this.setN... | javascript | {
"resource": ""
} | |
q48382 | train | function() {
this.typeCount_ = 2;
this.updateShape_();
this.setOutput(true, 'Type');
this.setMutator(new Blockly.Mutator(['type_group_item']));
this.setColour(230);
this.setTooltip('Allows more than one type to be accepted.');
this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=67... | javascript | {
"resource": ""
} | |
q48383 | train | function() {
this.appendDummyInput()
.appendField('hue:')
.appendField(new Blockly.FieldAngle('0', this.validator), 'HUE');
this.setOutput(true, 'Colour');
this.setTooltip('Paint the block with this colour.');
this.setHelpUrl('https://www.youtube.com/watch?v=s2_xaEvcVI0#t=55');
} | javascript | {
"resource": ""
} | |
q48384 | train | function() {
this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
this.setColour(Blockly.Blocks.variables.HUE);
this.appendDummyInput()
.appendField(new Blockly.FieldVariable(
Blockly.Msg.VARIABLES_DEFAULT_NAME), 'VAR');
this.setOutput(true);
this.setTooltip(Blockly.Msg.VARIABLES_GET_... | javascript | {
"resource": ""
} | |
q48385 | train | function() {
this.jsonInit({
"message0": Blockly.Msg.VARIABLES_SET,
"args0": [
{
"type": "field_variable",
"name": "VAR",
"variable": Blockly.Msg.VARIABLES_DEFAULT_NAME
},
{
"type": "input_value",
"name": "VALUE"
}
]... | javascript | {
"resource": ""
} | |
q48386 | train | function() {
this.jsonInit({
"message0": Blockly.Msg.CONTROLS_FOR_TITLE,
"args0": [
{
"type": "field_variable",
"name": "VAR",
"variable": null
},
{
"type": "input_value",
"name": "FROM",
"check": "Number",
"al... | javascript | {
"resource": ""
} | |
q48387 | train | function() {
this.jsonInit({
"message0": Blockly.Msg.CONTROLS_FOREACH_TITLE,
"args0": [
{
"type": "field_variable",
"name": "VAR",
"variable": null
},
{
"type": "input_value",
"name": "LIST",
"check": "Array"
}
... | javascript | {
"resource": ""
} | |
q48388 | updateBlocks | train | function updateBlocks(blocks) {
for (var i = 0, block; block = blocks[i]; i++) {
block.customUpdate && block.customUpdate();
}
} | javascript | {
"resource": ""
} |
q48389 | train | function(hasStatements) {
if (this.hasStatements_ === hasStatements) {
return;
}
if (hasStatements) {
this.appendStatementInput('STACK')
.appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO);
if (this.getInput('RETURN')) {
this.moveInputBefore('STACK', 'RETURN');
}
... | javascript | {
"resource": ""
} | |
q48390 | train | function() {
// Check for duplicated arguments.
var badArg = false;
var hash = {};
for (var i = 0; i < this.arguments_.length; i++) {
if (hash['arg_' + this.arguments_[i].toLowerCase()]) {
badArg = true;
break;
}
hash['arg_' + this.arguments_[i].toLowerCase()] = true;
... | javascript | {
"resource": ""
} | |
q48391 | train | function(opt_paramIds) {
var container = document.createElement('mutation');
if (opt_paramIds) {
container.setAttribute('name', this.getFieldValue('NAME'));
}
for (var i = 0; i < this.arguments_.length; i++) {
var parameter = document.createElement('arg');
parameter.setAttribute('name'... | javascript | {
"resource": ""
} | |
q48392 | train | function(xmlElement) {
this.arguments_ = [];
for (var i = 0, childNode; childNode = xmlElement.childNodes[i]; i++) {
if (childNode.nodeName.toLowerCase() == 'arg') {
this.arguments_.push(childNode.getAttribute('name'));
}
}
this.updateParams_();
Blockly.Procedures.mutateCallers(t... | javascript | {
"resource": ""
} | |
q48393 | train | function(options) {
// Add option to create caller.
var option = {enabled: true};
var name = this.getFieldValue('NAME');
option.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace('%1', name);
var xmlMutation = goog.dom.createDom('mutation');
xmlMutation.setAttribute('name', name);
for (var i = ... | javascript | {
"resource": ""
} | |
q48394 | train | function() {
var nameField = new Blockly.FieldTextInput(
Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,
Blockly.Procedures.rename);
nameField.setSpellcheck(false);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE)
.appendField(nameField, 'NAME')
... | javascript | {
"resource": ""
} | |
q48395 | train | function() {
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
this.appendStatementInput('STACK');
this.appendDummyInput('STATEMENT_INPUT')
.appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
.appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEM... | javascript | {
"resource": ""
} | |
q48396 | train | function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getProcedureCall())) {
this.setFieldValue(newName, 'NAME');
this.setTooltip(
(this.outputConnection ? Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP :
Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP)
.replace('%1',... | javascript | {
"resource": ""
} | |
q48397 | train | function(paramNames, paramIds) {
// Data structures:
// this.arguments = ['x', 'y']
// Existing param names.
// this.quarkConnections_ {piua: null, f8b_: Blockly.Connection}
// Look-up of paramIds to connections plugged into the call block.
// this.quarkIds_ = ['piua', 'f8b_']
// ... | javascript | {
"resource": ""
} | |
q48398 | train | function() {
for (var i = 0; i < this.arguments_.length; i++) {
var field = this.getField('ARGNAME' + i);
if (field) {
// Ensure argument name is up to date.
// The argument name field is deterministic based on the mutation,
// no need to fire a change event.
Blockly.Even... | javascript | {
"resource": ""
} | |
q48399 | train | function(options) {
var option = {enabled: true};
option.text = Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;
var name = this.getProcedureCall();
var workspace = this.workspace;
option.callback = function() {
var def = Blockly.Procedures.getDefinition(name, workspace);
def && def.select();
}... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.