_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q35400 | train | function (filename, arg, callback) {
console.log('*** git-hooks.js run', filename, arg);
var hookName = path.basename(filename);
var hooksDirname = path.resolve(path.dirname(filename), '../../.githooks', hookName);
if (fsHelpers.exists(hooksDirname)) {
var list = fs.readdirSyn... | javascript | {
"resource": ""
} | |
q35401 | runHooks | train | function runHooks(hooks, args, callback) {
console.log('*** git-hooks.js runHooks', hooks, args);
if (!hooks.length) {
callback(0);
return;
}
try {
var hook = spawnHook(hooks.shift(), args);
hook.on('close', function (code) {
if (code === 0) {
... | javascript | {
"resource": ""
} |
q35402 | train | function () {
if (this._duration) {
return this._duration;
}
if (this._start && this._end) {
return moment.duration(this._end - this._start);
}
else {
return moment.duration(0);
}
} | javascript | {
"resource": ""
} | |
q35403 | createFilter | train | function createFilter(filterExpression) {
if (typeof filterExpression === 'undefined') {
throw new Error('Filter expression should be defined');
}
if (isSimpleType(filterExpression)) {
return simpleTypeFilter(filterExpression);
} else if (isCustomPredicate(filterExpression)) {
return customPredicat... | javascript | {
"resource": ""
} |
q35404 | toUnicode | train | function toUnicode(charCode) {
var result = charCode.toString(16).toUpperCase();
while (result.length < 4) result = '0' + result;
return '\\u' + result;
} | javascript | {
"resource": ""
} |
q35405 | PermissionError | train | function PermissionError(message, userName, actionKey) {
this.name = "PermissionError";
this.message = message || (userName && actionKey) ? "Permission Error. User " + userName + " is not authorized to " + actionKey : "Permission Error";
this.localizedMessageKey = "permission-error";
} | javascript | {
"resource": ""
} |
q35406 | create | train | function create(opt_options) {
function runInclude(file, encoding, callback) {
if (file.isNull()) {
return callback(null, file);
}
if (file.isStream()) {
this.emit('error', new PluginError(PLUGIN_NAME,
'Streams not supported!'));
}
if (file.isBuffer()) {
addIncludesToFi... | javascript | {
"resource": ""
} |
q35407 | addIncludesToFile | train | async function addIncludesToFile(file,
opt_options) {
const overrideMap = await readComponentsMap('./amp-versions.json');
const html = file.contents.toString();
const newHtml = await addIncludesToHtml(html, overrideMap, opt_options);
file.contents = new Buffer(newHtml);
return file;
} | javascript | {
"resource": ""
} |
q35408 | addIncludesToHtml | train | async function addIncludesToHtml(html, overrideMap,
opt_options) {
let instance = await amphtmlValidator.getInstance();
const options = opt_options || {};
if (options.updateComponentsMap) {
await updateComponentMap();
}
const versionMap = await readComponentsMap(COMPONENTS_MAP_PATH);
const result =... | javascript | {
"resource": ""
} |
q35409 | updateComponentMap | train | async function updateComponentMap() {
const response = await fetch(GITHUB_AMPHTML_TREE_URL);
const data = await response.json();
const pairs = data.tree.map((item) => item.path.match(REGEX_EXTENSION_DIR))
.filter((match) => match && !match[1].endsWith('impl'))
.map((match) => [... | javascript | {
"resource": ""
} |
q35410 | writeComponentsMap | train | function writeComponentsMap(path, componentsMap) {
return new Promise((resolve, reject) => {
const data = JSON.stringify(componentsMap);
fs.writeFile(path, data, (err) => {
if (err) {
return reject(err);
}
resolve(data.length);
});
});
} | javascript | {
"resource": ""
} |
q35411 | readComponentsMap | train | async function readComponentsMap(path) {
return new Promise((resolve, reject) => {
fs.readFile(path, (err, data) => {
if (err) {
return resolve({});
}
resolve(JSON.parse(data));
});
});
} | javascript | {
"resource": ""
} |
q35412 | createAmpCustomElementTag | train | function createAmpCustomElementTag(tagName, version) {
const scriptType = AMP_SCRIPT_TYPE_MAP[tagName] || 'custom-element';
return `<script async ${scriptType}="${tagName}" ` +
`src="https://cdn.ampproject.org/v0/${tagName}-${version}.js"></script>`;
} | javascript | {
"resource": ""
} |
q35413 | train | function( cssFileUrl )
{
if ( this.$.createStyleSheet )
this.$.createStyleSheet( cssFileUrl );
else
{
var link = new CKEDITOR.dom.element( 'link' );
link.setAttributes(
{
rel :'stylesheet',
type : 'text/css',
href : cssFileUrl
});
this.getHead().app... | javascript | {
"resource": ""
} | |
q35414 | train | function()
{
var head = this.$.getElementsByTagName( 'head' )[0];
if ( !head )
head = this.getDocumentElement().append( new CKEDITOR.dom.element( 'head' ), true );
else
head = new CKEDITOR.dom.element( head );
return (
this.getHead = function()
{
return head;
})();
} | javascript | {
"resource": ""
} | |
q35415 | isActionsExistsInPermissionActions | train | function isActionsExistsInPermissionActions(allActions, schemaActions) {
return utils.contains(allActions.sort().join(), schemaActions.sort().join());
} | javascript | {
"resource": ""
} |
q35416 | insertSettingsPluginsPermission | train | function insertSettingsPluginsPermission(app, next) {
var pluginsHome = utils.getRootPath() + "/plugins",
settingsPlugins = Object.keys(plugins.getSettingsPlugins());
var dbActionInstance = DBActions.getSimpleInstance(app, "SchemaPermissions");
var pluginInstanceHandler = require(utils.getLibPath() ... | javascript | {
"resource": ""
} |
q35417 | train | function()
{
this.fire( 'beforeGetData' );
var eventData = this._.data;
if ( typeof eventData != 'string' )
{
var element = this.element;
if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
eventData = element.is( 'textarea' ) ? element.getValue() : element.getHtml... | javascript | {
"resource": ""
} | |
q35418 | train | function( writer, filter )
{
var comment = this.value;
if ( filter )
{
if ( !( comment = filter.onComment( comment, this ) ) )
return;
if ( typeof comment != 'string' )
{
comment.parent = this.parent;
comment.writeHtml( writer, filter );
return;
}
}
writer.comm... | javascript | {
"resource": ""
} | |
q35419 | RetryPolicy | train | function RetryPolicy(options) {
options = options || {};
if (typeof options.maxAttempts === 'number') {
this.maxAttempts = options.maxAttempts;
}
else {
this.maxAttempts = RetryPolicy.DEFAULT_MAX_ATTEMPTS;
}
if (typeof options.codes === 'function') {
this.isRetryable = options.codes;
}
els... | javascript | {
"resource": ""
} |
q35420 | train | function(command, arg) {
if (!arg) {
arg = 'default';
}
if (!commands[command]) {
grunt.fail.fatal('Command [' + command + '] not found.');
}
// Check arg
if (typeof (commands[command]) !== 'function') {
if (!commands[command][arg]) {
grunt.fail.fatal('Argument [' + a... | javascript | {
"resource": ""
} | |
q35421 | _calculateDerivative | train | function _calculateDerivative(out, state, job, t, dt, d) {
vec3.scaleAndAdd(state.position, state.position, d.velocity, dt);
vec3.scaleAndAdd(state.momentum, state.momentum, d.force, dt);
_geometry.scaleAndAddQuat(state.orientation, state.orientation, d.spin, dt);
vec3.scaleAndAdd(state.angularMomentum, state.a... | javascript | {
"resource": ""
} |
q35422 | Cache | train | function Cache(maxSize, debug, storage) {
this.maxSize_ = maxSize || -1;
this.debug_ = debug || false;
this.storage_ = storage || new Cache.BasicCacheStorage();
this.fillFactor_ = .75;
this.stats_ = {};
this.stats_['hits'] = 0;
this.stats_['misses'] = 0;
this.log_('Initialized cache wi... | javascript | {
"resource": ""
} |
q35423 | Prompt | train | function Prompt() {
BasePrompt.apply(this, arguments);
if (typeof this.question.source !== 'function') {
throw new TypeError('expected source to be defined');
}
this.currentChoices = [];
this.firstRender = true;
this.selected = 0;
// Make sure no default is set (so it won't be printed)
this.questi... | javascript | {
"resource": ""
} |
q35424 | insertCallback | train | function insertCallback(error, data) {
console.log(require('util').inspect(error ? error.message : data, { showHidden: true, colors: true, depth: 2 }));
} | javascript | {
"resource": ""
} |
q35425 | train | function(tag, confImage, callback) {
grunt.log.subhead(actioning[action] + ' image [' + tag + ']');
async.waterfall([
// Step 1: search for a running container with the same image
function(cb) {
docker.listContainers({
all : 1,
// filters: (action !== 'unpause') ? '{... | javascript | {
"resource": ""
} | |
q35426 | PluginRender | train | function PluginRender(pluginInstance, rendererInstance) {
this._view = "index.jade";
this._locals = {};
var ns = pluginInstance.pluginNamespace, obj = PluginHelper.getPluginIdAndIId(ns), pluginId = obj.pluginId,
req = PluginHelper.cloneRequest(rendererInstance.req, pluginId), res = rendererInstance... | javascript | {
"resource": ""
} |
q35427 | filter | train | function filter(socket, message, rinfo) {
const isAllowedAddress = socket.remoteAddress === rinfo.address;
const isAllowedPort = socket.remotePort === rinfo.port;
return isAllowedAddress && isAllowedPort;
} | javascript | {
"resource": ""
} |
q35428 | propsStream | train | function propsStream(options) {
if (!_.isObject(options)) {
options = {};
}
return through.obj(function(chunk, enc, cb) {
var webpackOptions = chunk[FIELD_NAME] || {};
webpackOptions = _.merge(webpackOptions, options);
chunk[FIELD_NAME] = webpackOptions;
cb(null, ... | javascript | {
"resource": ""
} |
q35429 | train | function (logger, key, options) {
return new Promise((resolve, reject) => {
var url = `http://${options.host}:${options.port}/v1/kv/${key}`;
logger.trace(`GET ${url}`);
request.get(url)
.timeout(options.timeout)
.then((res) => {
logger.trace(`GET ${... | javascript | {
"resource": ""
} | |
q35430 | train | function()
{
var heightType = this.getDialog().getContentElement( 'info', 'htmlHeightType' ),
labelElement = heightType.getElement(),
inputElement = this.getInputElement(),
ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
... | javascript | {
"resource": ""
} | |
q35431 | createGraphIterators | train | function createGraphIterators(graph) {
return {
/**
* Creates a vertex iterator stream. This is an entry point for all traversal
* starting with a node.
*
* @param {string|number} [startFrom] vertex id to start iteration from.
* If this argument is omitted, then all graph nodes are iter... | javascript | {
"resource": ""
} |
q35432 | normalizeRoute | train | function normalizeRoute(path, parent) {
if (path[0] === '/' || path[0] === '') {
return path; // absolute route
}
if (!parent) {
return path; // no need for a join
}
return `${parent.route}/${path}`; // join
} | javascript | {
"resource": ""
} |
q35433 | plugin | train | function plugin() {
return function(files, metalsmith, done) {
Object.keys(files).forEach(function(file) {
if (!~file.indexOf('.html')) return;
var $ = cheerio.load(files[file].contents);
var links = $('a');
for (var i = links.length - 1; i >= 0; i--) {
var url = links[i].attribs.h... | javascript | {
"resource": ""
} |
q35434 | image | train | function image(filename) {
if (!filename) return;
var ext = filename.split('.')[filename.split('.').length - 1];
return ~extensions.join().indexOf(ext);
} | javascript | {
"resource": ""
} |
q35435 | callItems | train | function callItems( currentEntry )
{
var isNode = currentEntry.type
|| currentEntry instanceof CKEDITOR.htmlParser.fragment;
for ( var i = 0 ; i < this.length ; i++ )
{
// Backup the node info before filtering.
if ( isNode )
{
var orgType = currentEntry.type,
orgName = currentEn... | javascript | {
"resource": ""
} |
q35436 | train | function (dir, appname, version) {
if (appname) {
dir = path.join(dir, appname);
if (version) {
dir = path.join(dir, version);
}
}
return dir;
} | javascript | {
"resource": ""
} | |
q35437 | deletePage | train | function deletePage(req, res, next) {
var that = this, db = that.getDB(), DBActions = that.getDBActionsLib(),
dbAction = DBActions.getAuthInstance(req, PAGE_SCHEMA, PAGE_PERMISSION_SCHEMA_ENTRY);
var params = req.params;
var pageId = params.id;
if (!pageId) {
that.setErrorMessage(req, "N... | javascript | {
"resource": ""
} |
q35438 | setupWatcher | train | function setupWatcher(app, dbAction, name) {
dbAction.get("findByName", name, function (err, theme) {
if (!err && theme) {
require(utils.getLibPath() + "/static/ThemesWatcher").cacheAndWatchTheme(app, theme);
}
});
} | javascript | {
"resource": ""
} |
q35439 | filterAndSortAvailableServers | train | function filterAndSortAvailableServers (serverArray) {
var copyOfServerArray = JSON.parse(JSON.stringify(serverArray));
copyOfServerArray.sort(function (itemOne, itemTwo) {
return sortValue(itemOne) - sortValue(itemTwo);
});
// Filter servers we've too-recently disconnected ... | javascript | {
"resource": ""
} |
q35440 | ValidatedPath | train | function ValidatedPath(path, firstPathPart, pathRemainder) {
this.path = path;
this.firstPathPart = firstPathPart;
this.pathRemainder = pathRemainder;
} | javascript | {
"resource": ""
} |
q35441 | streamHandler | train | function streamHandler(stream) {
return stream
.pipe(plumber())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('.', {includeContent: true, sourceRoot: '.'}))
.pipe(gulp.dest(dest));
} | javascript | {
"resource": ""
} |
q35442 | reducer | train | function reducer(context, action, target, state) {
const newState = Object.assign({}, state);
let actor;
switch(action.type) {
case INIT_CONTEXT_ACTION_TYPE:
newState.days = context.reduce((acc, actor, name) => {
if(name.indexOf("_weekDay") > 0)
acc.push(name);
return acc;
}, []);
return n... | javascript | {
"resource": ""
} |
q35443 | emitBuffer | train | function emitBuffer() {
if (!this._buffer) {
return;
}
for (var i = this._marker; i < this._buffer.length; i++) {
var data = this._buffer[i];
if (data.writable === true) {
break;
} else if (data.writable === false) {
emitBuffer.call(data);
} else {
this.emit('data', data, 'ut... | javascript | {
"resource": ""
} |
q35444 | setOptions | train | function setOptions( options ){
if( this.addListener ){
for( var opt in options ){
if( typeof( options[ opt ] ) !== 'function' || !(/^on[A-z]/).test(opt)){
continue;
}
this.addListener( removeOn( opt ), options[ opt ]);
... | javascript | {
"resource": ""
} |
q35445 | sanitize | train | function sanitize(htmlText, opt_uriPolicy, opt_nmTokenPolicy) {
var out = [];
makeHtmlSanitizer(
function sanitizeAttribs(tagName, attribs) {
for (var i = 0; i < attribs.length; i += 2) {
var attribName = attribs[i];
var value = attribs[i + 1];
var atype = null, attri... | javascript | {
"resource": ""
} |
q35446 | onDown | train | function onDown(e) {
// Prevent interaction offset calculations happening while
// the user is dragging the map.
//
// Store this event so that we can compare it to the
// up event
_downLock = true;
var _e = (e.type !== "MSPointerDown" && e.type !== "pointerdown"... | javascript | {
"resource": ""
} |
q35447 | initTouch | train | function initTouch()
{
var startX,
startY,
touchStartX,
touchStartY,
moved,
moving = false;
container.unbind('touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick').bind(
'touchstart.jsp',
function(e)
{
... | javascript | {
"resource": ""
} |
q35448 | train | function(vars) {
var c = this.compiled = this.compiled || this.get('compiled') || this.compile();
var rendered = c(vars);
return rendered;
} | javascript | {
"resource": ""
} | |
q35449 | train | function(args) {
var self = this;
// var date = new Date();
this.trigger('loadModelStarted');
$.when(this.elder('fetch', args)).done(function(ev){
self.trigger('loadModelCompleted', ev);
// var dateComplete = new Date()
// console.log('completed in '+(dateComplete - date)... | javascript | {
"resource": ""
} | |
q35450 | train | function(ev, obj, retrigEvent) {
if(!retrigEvent) {
retrigEvent = ev;
}
var self = this;
obj.bind && obj.bind(ev, function() {
self.trigger(retrigEvent);
}, self)
} | javascript | {
"resource": ""
} | |
q35451 | train | function() {
var self = this;
this.trigger('clean');
this.clearSubViews();
// remove from parent
if(this._parent) {
this._parent.removeView(this);
this._parent = null;
}
this.remove();
this.unbind();
// remove this model binding
if (this.model ... | javascript | {
"resource": ""
} | |
q35452 | train | function(ev) {
if(ev && ev.preventDefault) {
ev.preventDefault();
};
if(ev && ev.stopPropagation) {
ev.stopPropagation();
};
} | javascript | {
"resource": ""
} | |
q35453 | train | function() {
_.each(cdb.core.View.views, function(view) {
_.each(view, function(prop, k) {
if( k !== '_parent' &&
view.hasOwnProperty(k) &&
prop instanceof cdb.core.View &&
view._subviews[prop.cid] === undefined) {
console.log("=========");
... | javascript | {
"resource": ""
} | |
q35454 | train | function() {
var e = this.get('extra_params') || e;
e.cache_buster = new Date().getTime();
this.set('extra_params', e);
this.trigger('change', this);
} | javascript | {
"resource": ""
} | |
q35455 | train | function(model, col, options) {
if (this.size() > 0) {
// Assign an order of 0 to the first layer
this.at(0).set({ order: 0 });
if (this.size() > 1) {
var layersByType = {};
for (var i = 1; i < this.size(); ++i) {
var layer = this.at(i);
var layerType = layer.... | javascript | {
"resource": ""
} | |
q35456 | train | function(options) {
if (typeof options != "object" || options.length) {
if (this.options.debug) {
throw (options + ' options has to be an object');
} else {
return;
}
}
// Set options
_.defaults(this.options, options);
} | javascript | {
"resource": ""
} | |
q35457 | train | function(bounds, mapSize) {
var z = this.getBoundsZoom(bounds, mapSize);
if(z === null) {
return;
}
// project -> calculate center -> unproject
var swPoint = cdb.geo.Map.latlngToMercator(bounds[0], z);
var nePoint = cdb.geo.Map.latlngToMercator(bounds[1], z);
var center = cdb.geo.Map... | javascript | {
"resource": ""
} | |
q35458 | train | function(boundsSWNE, mapSize) {
// sometimes the map reports size = 0 so return null
if(mapSize.x === 0 || mapSize.y === 0) return null;
var size = [mapSize.x, mapSize.y],
zoom = this.get('minZoom') || 0,
maxZoom = this.get('maxZoom') || 24,
ne = boundsSWNE[1],
sw = boundsSWNE[0],
bounds... | javascript | {
"resource": ""
} | |
q35459 | train | function() {
var result = [];
for (var s in this._subviews) {
if(this._subviews[s] instanceof cdb.geo.ui.Infowindow) {
result.push(this._subviews[s]);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q35460 | train | function() {
this._unbindModel();
this.map.bind('change:view_bounds_sw', this._changeBounds, this);
this.map.bind('change:view_bounds_ne', this._changeBounds, this);
this.map.bind('change:zoom', this._setZoom, this);
this.map.bind('change:scrollwheel', this._setScrollWheel, this);
... | javascript | {
"resource": ""
} | |
q35461 | train | function() {
this.map.unbind('change:view_bounds_sw', null, this);
this.map.unbind('change:view_bounds_ne', null, this);
this.map.unbind('change:zoom', null, this);
this.map.unbind('change:scrollwheel', null, this);
this.map.unbind('change:keyboard', null, this);
this.map... | javascript | {
"resource": ""
} | |
q35462 | train | function(attributes) {
var fields = this.get('fields');
this.set('content', cdb.geo.ui.InfowindowModel.contentForFields(attributes, fields));
} | javascript | {
"resource": ""
} | |
q35463 | train | function() {
if(this.template) {
// If there is content, destroy the jscrollpane first, then remove the content.
var $jscrollpane = this.$(".cartodb-popup-content");
if ($jscrollpane.length > 0 && $jscrollpane.data() != null) {
$jscrollpane.data().jsp && $jscrollpane.data().jsp.destroy()... | javascript | {
"resource": ""
} | |
q35464 | train | function() {
var template = this.model.get('template') ?
this.model.get('template') :
cdb.templates.getTemplate(this._getModelTemplate());
if(typeof(template) !== 'function') {
this.template = new cdb.core.Template({
template: template,
type: this.model.get('template_type') ||... | javascript | {
"resource": ""
} | |
q35465 | train | function(ev) {
// If the mouse down come from jspVerticalBar
// dont stop the propagation, but if the event
// is a touchstart, stop the propagation
var come_from_scroll = (($(ev.target).closest(".jspVerticalBar").length > 0) && (ev.type != "touchstart"));
if (!come_from_scroll) {
ev.stopProp... | javascript | {
"resource": ""
} | |
q35466 | train | function(fields, template_name) {
var fields_sanitized = [];
if (fields && fields.length > 0) {
var self = this;
fields_sanitized = _.map(fields, function(field,i) {
// Return whole attribute sanitized
return self._sanitizeField(field, template_name, field.index || i);
});
... | javascript | {
"resource": ""
} | |
q35467 | train | function($el) {
this._stopSpinner();
var $el = this.$el.find('.loading');
if ($el) {
// Check if it is dark or other to change color
var template_dark = this.model.get('template_name').search('dark') != -1;
if (template_dark) {
this.spin_options.color = '#FFF';
} else {
... | javascript | {
"resource": ""
} | |
q35468 | train | function() {
var content = this.model.get("content");
if (content && content.fields && content.fields.length > 0) {
return (content.fields[0].value || '').toString();
}
return false;
} | javascript | {
"resource": ""
} | |
q35469 | train | function() {
if (!this._containsCover()) return;
var self = this;
var $cover = this.$(".cover");
var $img = $cover.find("img");
var $shadow = this.$(".shadow");
var url = this._getCoverURL();
if (!this._isValidURL(url)) {
$img.hide();
$shadow.hide();
cdb.log.info("Header... | javascript | {
"resource": ""
} | |
q35470 | train | function(url) {
if (url) {
var urlPattern = /^(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-|]*[\w@?^=%&\/~+#-])?$/
return String(url).match(urlPattern) != null ? true : false;
}
return false;
} | javascript | {
"resource": ""
} | |
q35471 | train | function() {
this.model.set({
content: {
fields: [{
title: null,
alternative_name: null,
value: 'Loading content...',
index: null,
type: "loading"
}],
data: {}
}
})
return this;
} | javascript | {
"resource": ""
} | |
q35472 | train | function(delay) {
if (!cdb.core.util.ie || (cdb.core.util.browser.ie && cdb.core.util.browser.ie.version > 8)) {
this.$el.css({
'marginBottom':'-10px',
'display': 'block',
'visibility':'visible',
opacity:0
});
this.$el
.delay(delay)
.animate({
o... | javascript | {
"resource": ""
} | |
q35473 | train | function() {
if (!$.browser.msie || ($.browser.msie && parseInt($.browser.version) > 8 )) {
var self = this;
this.$el.animate({
marginBottom: "-10px",
opacity: "0",
display: "block"
}, 180, function() {
self.$el.css({visibility: "hidden"});
});
}... | javascript | {
"resource": ""
} | |
q35474 | train | function () {
var offset = this.model.get("offset");
if (!this.model.get("autoPan") || this.isHidden()) { return; }
var
x = this.$el.position().left,
y = this.$el.position().top,
containerHeight = this.$el.outerHeight(true) + 15, // Adding some more space
contai... | javascript | {
"resource": ""
} | |
q35475 | train | function(pos) {
var props = {};
if(pos.indexOf('top') !== -1) {
props.top = this.options.pos_margin;
} else if(pos.indexOf('bottom') !== -1) {
props.bottom = this.options.pos_margin;
}
if(pos.indexOf('left') !== -1) {
props.left = this.options.pos_margin;
} else if(pos.indexOf... | javascript | {
"resource": ""
} | |
q35476 | train | function(payload) {
var self = this;
if (this.options.compressor) {
return this.options.compressor;
}
payload = payload || JSON.stringify(this.toJSON());
if (!this.options.force_compress && payload.length < this.options.MAX_GET_SIZE) {
return function(data, level, callback) {
ca... | javascript | {
"resource": ""
} | |
q35477 | train | function(params, included) {
if(!params) return '';
var url_params = [];
included = included || _.keys(params);
for(var i in included) {
var k = included[i]
var p = params[k];
if(p) {
if (_.isArray(p)) {
for (var j = 0, len = p.length; j < len; j++) {
url_... | javascript | {
"resource": ""
} | |
q35478 | train | function(layer, callback) {
layer = layer == undefined ? 0: layer;
var self = this;
this.getTiles(function(urls) {
if(!urls) {
callback(null);
return;
}
if(callback) {
callback(self._tileJSONfromTiles(layer, urls));
}
});
} | javascript | {
"resource": ""
} | |
q35479 | train | function(number) {
var layers = {}
var c = 0;
for(var i = 0; i < this.layers.length; ++i) {
var layer = this.layers[i];
layers[i] = c;
if(layer.options && !layer.options.hidden) {
++c;
}
}
return layers[number];
} | javascript | {
"resource": ""
} | |
q35480 | train | function(index) {
var layers = [];
for(var i = 0; i < this.layers.length; ++i) {
var layer = this.layers[i];
if(this._isLayerVisible(layer)) {
layers.push(i);
}
}
if (index >= layers.length) {
return -1;
}
return +layers[index];
} | javascript | {
"resource": ""
} | |
q35481 | train | function(layer, attributes) {
if(attributes === undefined) {
attributes = layer;
layer = 0;
}
if(layer >= this.getLayerCount() && layer < 0) {
throw new Error("layer does not exist");
}
if(typeof(attributes) == 'string') {
attributes = attributes.split(',');
}
for(... | javascript | {
"resource": ""
} | |
q35482 | train | function(layer, style, version) {
if(version === undefined) {
version = style;
style = layer;
layer = 0;
}
version = version || cartodb.CARTOCSS_DEFAULT_VERSION;
this.layers[layer].options.cartocss = style;
this.layers[layer].options.cartocss_version = version;
this._definiti... | javascript | {
"resource": ""
} | |
q35483 | train | function(layer, b) {
// shift arguments to maintain caompatibility
if(b == undefined) {
b = layer;
layer = 0;
}
var layerInteraction;
this.interactionEnabled[layer] = b;
if(!b) {
layerInteraction = this.interaction[layer];
if(layerInteraction) {
layerInteraction.r... | javascript | {
"resource": ""
} | |
q35484 | train | function() {
var xyz = {z: 4, x: 6, y: 6}
, self = this
, img = new Image()
, urls = this._tileJSON()
getTiles(function(urls) {
var grid_url = urls.tiles[0]
.replace(/\{z\}/g,xyz.z)
.replace(/\{x\}/g,xyz.x)
.replace(/\{y\}/g,xyz.y);
this.options.aja... | javascript | {
"resource": ""
} | |
q35485 | train | function(container, className) {
// Check if any cartodb-logo exists within container
var a = [];
var re = new RegExp('\\b' + className + '\\b');
var els = container.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a.length... | javascript | {
"resource": ""
} | |
q35486 | train | function(position, timeout, container) {
var self = this;
setTimeout(function() {
if (!self.isWadusAdded(container, 'cartodb-logo')) {
var cartodb_link = document.createElement("div");
var is_retina = self.isRetinaBrowser();
cartodb_link.setAttribute('class','cartodb-logo');
... | javascript | {
"resource": ""
} | |
q35487 | train | function(layerModel, leafletLayer, leafletMap) {
this.leafletLayer = leafletLayer;
this.leafletMap = leafletMap;
this.model = layerModel;
this.setModel(layerModel);
this.type = layerModel.get('type') || layerModel.get('kind');
this.type = this.type.toLowerCase();
} | javascript | {
"resource": ""
} | |
q35488 | train | function (tilePoint) {
var EMPTY_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
this._adjustTilePoint(tilePoint);
var tiles = [EMPTY_GIF];
if(this.tilejson) {
tiles = this.tilejson.tiles;
}
var index = (tilePoint.x + tilePoint.y) % tiles.length;
... | javascript | {
"resource": ""
} | |
q35489 | train | function(opacity) {
if (isNaN(opacity) || opacity>1 || opacity<0) {
throw new Error(opacity + ' is not a valid value');
}
// Leaflet only accepts 0-0.99... Weird!
this.options.opacity = Math.min(opacity, 0.99);
if (this.options.visible) {
L.TileLayer.prototype.setOpacity.call(this, th... | javascript | {
"resource": ""
} | |
q35490 | train | function(map) {
var self = this;
this.options.map = map;
// Add cartodb logo
if (this.options.cartodb_logo != false)
cdb.geo.common.CartoDBLogo.addWadus({ left:8, bottom:8 }, 0, map._container);
this.__update(function() {
// if while the layer was processed in the server is removed
... | javascript | {
"resource": ""
} | |
q35491 | train | function(map) {
if(this.options.added) {
this.options.added = false;
L.TileLayer.prototype.onRemove.call(this, map);
}
} | javascript | {
"resource": ""
} | |
q35492 | train | function(done) {
var self = this;
this.fire('updated');
this.fire('loading');
var map = this.options.map;
this.getTiles(function(urls, err) {
if(urls) {
self.tilejson = urls;
self.setUrl(self.tilejson.tiles[0]);
// manage interaction
self._reloadInteraction();
... | javascript | {
"resource": ""
} | |
q35493 | train | function(attribution) {
this._checkLayer();
// Remove old one
this.map.attributionControl.removeAttribution(
cdb.core.sanitize.html(this.options.attribution)
);
// Change text
this.map.attributionControl.addAttribution(
cdb.core.sanitize.html(attribution)
);
// Set new attrib... | javascript | {
"resource": ""
} | |
q35494 | train | function(map, o) {
var layer_point = this._findPos(map,o);
if (!layer_point || isNaN(layer_point.x) || isNaN(layer_point.y)) {
// If layer_point doesn't contain x and y,
// we can't calculate event map position
return false;
}
var latlng = map.layerPointToLatLng(layer_point);
var... | javascript | {
"resource": ""
} | |
q35495 | train | function() {
var b = this.map_leaflet.getBounds();
var sw = b.getSouthWest();
var ne = b.getNorthEast();
return [
[sw.lat, sw.lng],
[ne.lat, ne.lng]
];
} | javascript | {
"resource": ""
} | |
q35496 | train | function(layerModel, gmapsLayer, gmapsMap) {
this.gmapsLayer = gmapsLayer;
this.map = this.gmapsMap = gmapsMap;
this.model = layerModel;
this.model.bind('change', this._update, this);
this.type = layerModel.get('type') || layerModel.get('kind');
this.type = this.type.toLowerCase();
} | javascript | {
"resource": ""
} | |
q35497 | train | function() {
var self = this;
var index = -1;
this.gmapsMap.overlayMapTypes.forEach(
function(layer, i) {
if (layer == self) {
index = i;
}
}
);
return index;
} | javascript | {
"resource": ""
} | |
q35498 | train | function() {
if(!this.isBase) {
var self = this;
var idx = this._searchLayerIndex();
if(idx >= 0) {
this.gmapsMap.overlayMapTypes.removeAt(idx);
} else if (this.gmapsLayer.setMap){
this.gmapsLayer.setMap(null);
}
this.model.unbind(null, null, this);
this.unb... | javascript | {
"resource": ""
} | |
q35499 | train | function(layerModel, gmapsMap) {
var self = this;
_.bindAll(this, 'featureOut', 'featureOver', 'featureClick');
var opts = _.clone(layerModel.attributes);
opts.map = gmapsMap;
var // preserve the user's callbacks
_featureOver = opts.featureOver,
_featureOut = opts.featureOut,
_featureClick = opt... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.