code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
CartoDBNamedMap = function(opts) { this.options = _.defaults(opts, default_options); this.tiles = 0; this.tilejson = null; this.interaction = []; if (!opts.named_map && !opts.sublayers) { throw new Error('cartodb-gmaps needs at least the named_map'); } // Add CartoDB logo if (this.options.cartodb_logo != false) cdb.geo.common.CartoDBLogo.addWadus({ left: 74, bottom:8 }, 2000, this.options.map.getDiv()); wax.g.connector.call(this, opts); // lovely wax connector overwrites options so set them again // TODO: remove wax.connector here _.extend(this.options, opts); this.projector = new Projector(opts.map); NamedMap.call(this, this.options.named_map, this.options); CartoDBLayerCommon.call(this); // precache this.update(); }
remove layer from the map and unbind events
CartoDBNamedMap
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
CartoDBLayerGroup = function(opts) { this.options = _.defaults(opts, default_options); this.tiles = 0; this.tilejson = null; this.interaction = []; if (!opts.layer_definition && !opts.sublayers) { throw new Error('cartodb-leaflet needs at least the layer_definition or sublayer list'); } // if only sublayers is available, generate layer_definition from it if(!opts.layer_definition) { opts.layer_definition = LayerDefinition.layerDefFromSubLayers(opts.sublayers); } // Add CartoDB logo if (this.options.cartodb_logo != false) cdb.geo.common.CartoDBLogo.addWadus({ left: 74, bottom:8 }, 2000, this.options.map.getDiv()); wax.g.connector.call(this, opts); // lovely wax connector overwrites options so set them again // TODO: remove wax.connector here _.extend(this.options, opts); this.projector = new Projector(opts.map); LayerDefinition.call(this, opts.layer_definition, this.options); CartoDBLayerCommon.call(this); // precache this.update(); }
remove layer from the map and unbind events
CartoDBLayerGroup
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function setImageOpacityIE8(img, opacity) { var v = Math.round(opacity*100); if (v >= 99) { img.style.filter = OPACITY_FILTER; } else { img.style.filter = "alpha(opacity=" + (opacity) + ");"; } }
remove layer from the map and unbind events
setImageOpacityIE8
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
finished = function() { loadTime.end(); self.tiles--; if (self.tiles === 0) { self.finishLoading && self.finishLoading(); } }
remove layer from the map and unbind events
finished
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function LayerGroupView(base) { var GMapsCartoDBLayerGroupView = function(layerModel, gmapsMap) { var self = this; var hovers = []; _.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 = opts.featureClick; var previousEvent; var eventTimeout = -1; opts.featureOver = function(e, latlon, pxPos, data, layer) { if (!hovers[layer]) { self.trigger('layerenter', e, latlon, pxPos, data, layer); } hovers[layer] = 1; _featureOver && _featureOver.apply(this, arguments); self.featureOver && self.featureOver.apply(this, arguments); // if the event is the same than before just cancel the event // firing because there is a layer on top of it if (e.timeStamp === previousEvent) { clearTimeout(eventTimeout); } eventTimeout = setTimeout(function() { self.trigger('mouseover', e, latlon, pxPos, data, layer); self.trigger('layermouseover', e, latlon, pxPos, data, layer); }, 0); previousEvent = e.timeStamp; }; opts.featureOut = function(m, layer) { if (hovers[layer]) { self.trigger('layermouseout', layer); } hovers[layer] = 0; if(!_.any(hovers)) { self.trigger('mouseout'); } _featureOut && _featureOut.apply(this, arguments); self.featureOut && self.featureOut.apply(this, arguments); }; opts.featureClick = _.debounce(function() { _featureClick && _featureClick.apply(this, arguments); self.featureClick && self.featureClick.apply(opts, arguments); }, 10); //CartoDBLayerGroup.call(this, opts); base.call(this, opts); cdb.geo.GMapsLayerView.call(this, layerModel, this, gmapsMap); }; _.extend( GMapsCartoDBLayerGroupView.prototype, cdb.geo.GMapsLayerView.prototype, base.prototype, { _update: function() { this.setOptions(this.model.attributes); }, reload: function() { this.model.invalidate(); }, remove: function() { cdb.geo.GMapsLayerView.prototype.remove.call(this); this.clear(); }, featureOver: function(e, latlon, pixelPos, data, layer) { // dont pass gmaps LatLng this.trigger('featureOver', e, [latlon.lat(), latlon.lng()], pixelPos, data, layer); }, featureOut: function(e, layer) { this.trigger('featureOut', e, layer); }, featureClick: function(e, latlon, pixelPos, data, layer) { // dont pass leaflet lat/lon this.trigger('featureClick', e, [latlon.lat(), latlon.lng()], pixelPos, data, layer); }, error: function(e) { if(this.model) { //trigger the error form _checkTiles in the model this.model.trigger('error', e?e.errors:'unknown error'); this.model.trigger('tileError', e?e.errors:'unknown error'); } }, ok: function(e) { this.model.trigger('tileOk'); }, tilesOk: function(e) { this.model.trigger('tileOk'); }, loading: function() { this.trigger("loading"); }, finishLoading: function() { this.trigger("load"); } }); return GMapsCartoDBLayerGroupView; }
Creates an instance of a google.maps Point
LayerGroupView
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
GMapsCartoDBLayerGroupView = function(layerModel, gmapsMap) { var self = this; var hovers = []; _.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 = opts.featureClick; var previousEvent; var eventTimeout = -1; opts.featureOver = function(e, latlon, pxPos, data, layer) { if (!hovers[layer]) { self.trigger('layerenter', e, latlon, pxPos, data, layer); } hovers[layer] = 1; _featureOver && _featureOver.apply(this, arguments); self.featureOver && self.featureOver.apply(this, arguments); // if the event is the same than before just cancel the event // firing because there is a layer on top of it if (e.timeStamp === previousEvent) { clearTimeout(eventTimeout); } eventTimeout = setTimeout(function() { self.trigger('mouseover', e, latlon, pxPos, data, layer); self.trigger('layermouseover', e, latlon, pxPos, data, layer); }, 0); previousEvent = e.timeStamp; }; opts.featureOut = function(m, layer) { if (hovers[layer]) { self.trigger('layermouseout', layer); } hovers[layer] = 0; if(!_.any(hovers)) { self.trigger('mouseout'); } _featureOut && _featureOut.apply(this, arguments); self.featureOut && self.featureOut.apply(this, arguments); }; opts.featureClick = _.debounce(function() { _featureClick && _featureClick.apply(this, arguments); self.featureClick && self.featureClick.apply(opts, arguments); }, 10); //CartoDBLayerGroup.call(this, opts); base.call(this, opts); cdb.geo.GMapsLayerView.call(this, layerModel, this, gmapsMap); }
Creates an instance of a google.maps Point
GMapsCartoDBLayerGroupView
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function PathView(geometryModel) { var self = this; // events to link var events = [ 'click', 'dblclick', 'mousedown', 'mouseover', 'mouseout', ]; this._eventHandlers = {}; this.model = geometryModel; this.points = []; var style = _.clone(geometryModel.get('style')) || {}; this.geom = new GeoJSON ( geometryModel.get('geojson'), style ); /*_.each(this.geom._layers, function(g) { g.setStyle(geometryModel.get('style')); g.on('edit', function() { geometryModel.set('geojson', L.GeoJSON.toGeoJSON(self.geom)); }, self); }); */ _.bindAll(this, '_updateModel'); var self = this; function bindPath(p) { google.maps.event.addListener(p, 'insert_at', self._updateModel); /* google.maps.event.addListener(p, 'remove_at', this._updateModel); google.maps.event.addListener(p, 'set_at', this._updateModel); */ } // TODO: check this conditions if(this.geom.getPaths) { var paths = this.geom.getPaths(); if (paths && paths[0]) { // More than one path for(var i = 0; i < paths.length; ++i) { bindPath(paths[i]); } } else { // One path bindPath(paths); google.maps.event.addListener(this.geom, 'mouseup', this._updateModel); } } else { // More than one path if (this.geom.length) { for(var i = 0; i < this.geom.length; ++i) { bindPath(this.geom[i].getPath()); google.maps.event.addListener(this.geom[i], 'mouseup', this._updateModel); } } else { // One path bindPath(this.geom.getPath()); google.maps.event.addListener(this.geom, 'mouseup', this._updateModel); } } /*for(var i = 0; i < events.length; ++i) { var e = events[i]; this.geom.on(e, self._eventHandler(e)); }*/ }
view for other geometries (polygons/lines)
PathView
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function bindPath(p) { google.maps.event.addListener(p, 'insert_at', self._updateModel); /* google.maps.event.addListener(p, 'remove_at', this._updateModel); google.maps.event.addListener(p, 'set_at', this._updateModel); */ }
view for other geometries (polygons/lines)
bindPath
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function _coord(latlng) { return [latlng.lng(), latlng.lat()]; }
view for other geometries (polygons/lines)
_coord
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function _coords(latlngs) { var c = []; for(var i = 0; i < latlngs.length; ++i) { c.push(_coord(latlngs.getAt(i))); } return c; }
view for other geometries (polygons/lines)
_coords
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function loaded () { if (self.checkModules(layers)) { cdb.config.unbind('moduleLoaded', loaded); done(); } }
check if all the modules needed to create layers are loaded
loaded
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function BackboneActions(model) { var actions = { set: function() { var args = arguments; return O.Action({ enter: function() { model.set.apply(model, args); } }); }, reset: function() { var args = arguments; return O.Action({ enter: function() { model.reset.apply(model, args); } }); } }; return actions; }
check if all the modules needed to create layers are loaded
BackboneActions
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function SetStepAction(vis, step) { return O.Action(function() { vis.setAnimationStep(step); }); }
check if all the modules needed to create layers are loaded
SetStepAction
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function AnimationTrigger(vis, step) { var t = O.Trigger(); vis.on('change:step', function (layer, currentStep) { if (currentStep === step) { t.trigger(); } }); return t; }
check if all the modules needed to create layers are loaded
AnimationTrigger
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function PrevTrigger(seq, step) { var t = O.Trigger(); var c = PrevTrigger._callbacks; if (!c) { c = PrevTrigger._callbacks = [] O.Keys().left().then(function() { for (var i = 0; i < c.length; ++i) { if (c[i] === seq.current()) { t.trigger(); return; } } }); } c.push(step); return t; }
check if all the modules needed to create layers are loaded
PrevTrigger
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function NextTrigger(seq, step) { var t = O.Trigger(); var c = NextTrigger._callbacks; if (!c) { c = NextTrigger._callbacks = [] O.Keys().right().then(function() { for (var i = 0; i < c.length; ++i) { if (c[i] === seq.current()) { t.trigger(); return; } } }); } c.push(step); return t; }
check if all the modules needed to create layers are loaded
NextTrigger
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function WaitAction(seq, ms) { return O.Step(O.Sleep(ms), O.Action(function() { seq.next(); })); }
check if all the modules needed to create layers are loaded
WaitAction
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function goTo(seq, i) { return function() { seq.current(i); } }
check if all the modules needed to create layers are loaded
goTo
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function search_overlay(name) { if (!vizjson.overlays) return null; for(var i = 0; i < vizjson.overlays.length; ++i) { if (vizjson.overlays[i].type === name) { return vizjson.overlays[i]; } } }
check if all the modules needed to create layers are loaded
search_overlay
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function remove_overlay(name) { if (!vizjson.overlays) return; for(var i = 0; i < vizjson.overlays.length; ++i) { if (vizjson.overlays[i].type === name) { vizjson.overlays.splice(i, 1); return; } } }
check if all the modules needed to create layers are loaded
remove_overlay
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function _applyLayerOptions(layers) { for(var i = 1; i < layers.length; ++i) { var o = layers[i].options; o.no_cdn = opt.no_cdn; o.force_cors = opt.force_cors; if(token) { o.auth_token = token; } } }
check if all the modules needed to create layers are loaded
_applyLayerOptions
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
S4 = function() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); }
adds an infowindow to the map controlled by layer events. it enables interaction and overrides the layer interacivity ``fields`` array of column names ``map`` native map object, leaflet of gmaps ``layer`` cartodb layer (or sublayer)
S4
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function transformToHTTP(tilesTemplate) { for(var url in HTTPS_TO_HTTP) { if(tilesTemplate.indexOf(url) !== -1) { return tilesTemplate.replace(url, HTTPS_TO_HTTP[url]) } } return tilesTemplate; }
adds an infowindow to the map controlled by layer events. it enables interaction and overrides the layer interacivity ``fields`` array of column names ``map`` native map object, leaflet of gmaps ``layer`` cartodb layer (or sublayer)
transformToHTTP
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function transformToHTTPS(tilesTemplate) { for(var url in HTTPS_TO_HTTP) { var httpsUrl = HTTPS_TO_HTTP[url]; if(tilesTemplate.indexOf(httpsUrl) !== -1) { return tilesTemplate.replace(httpsUrl, url); } } return tilesTemplate; }
adds an infowindow to the map controlled by layer events. it enables interaction and overrides the layer interacivity ``fields`` array of column names ``map`` native map object, leaflet of gmaps ``layer`` cartodb layer (or sublayer)
transformToHTTPS
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function normalizeOptions(vis, data) { if(data.infowindow && data.infowindow.fields) { if(data.interactivity) { if(data.interactivity.indexOf('cartodb_id') === -1) { data.interactivity = data.interactivity + ",cartodb_id"; } } else { data.interactivity = 'cartodb_id'; } } // if https is forced if(vis.https) { data.tiler_protocol = 'https'; data.tiler_port = 443; data.sql_api_protocol = 'https'; data.sql_api_port = 443; } data.cartodb_logo = vis.cartodb_logo == undefined ? data.cartodb_logo : vis.cartodb_logo; }
adds an infowindow to the map controlled by layer events. it enables interaction and overrides the layer interacivity ``fields`` array of column names ``map`` native map object, leaflet of gmaps ``layer`` cartodb layer (or sublayer)
normalizeOptions
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
cartoLayer = function(vis, data) { normalizeOptions(vis, data); // if sublayers are included that means a layergroup should // be created if(data.sublayers) { data.type = 'layergroup'; return new cdb.geo.CartoDBGroupLayer(data); } return new cdb.geo.CartoDBLayer(data); }
adds an infowindow to the map controlled by layer events. it enables interaction and overrides the layer interacivity ``fields`` array of column names ``map`` native map object, leaflet of gmaps ``layer`` cartodb layer (or sublayer)
cartoLayer
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function _getLayerJson(layer, callback) { var url = null; if(layer.layers !== undefined || ((layer.kind || layer.type) !== undefined)) { // layer object contains the layer data _.defer(function() { callback(layer); }); return; } else if(layer.table !== undefined && layer.user !== undefined) { // layer object points to cartodbjson url = cartodbUrl(layer); } else if(layer.indexOf) { // fetch from url url = layer; } if(url) { cdb.core.Loader.get(url, callback); } else { _.defer(function() { callback(null); }); } }
given layer params fetchs the layer json
_getLayerJson
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function createLayer() { layerView = viz.createLayer(layerData, { no_base_layer: true }); var torqueLayer; var mobileEnabled = /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); var addMobileLayout = (options.mobile_layout && mobileEnabled) || options.force_mobile; if(!layerView) { promise.trigger('error', "layer not supported"); return promise; } if(options.infowindow) { viz.addInfowindow(layerView); } if(options.tooltip) { viz.addTooltip(layerView); } if(options.legends) { var layerModel = cdb.vis.Layers.create(layerData.type || layerData.kind, viz, layerData); viz._addLegends(viz._createLayerLegendView(layerModel.attributes, layerView)) } if(options.time_slider && layerView.model.get('type') === 'torque') { if (!addMobileLayout) { // don't add the overlay if we are in mobile viz.addTimeSlider(layerView); } torqueLayer = layerView; } if (addMobileLayout) { options.mapView = map.viz.mapView; viz.addOverlay({ type: 'mobile', layerView: layerView, overlays: [], torqueLayer: torqueLayer, options: options }); } callback && callback(layerView); promise.trigger('done', layerView); }
create a layer for the specified map @param map should be a L.Map object, or equivalent depending on what provider you have. @param layer should be an url or a javascript object with the data to create the layer @param options layer options
createLayer
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function SQL(options) { if(cartodb === this || window === this) { return new SQL(options); } if(!options.user) { throw new Error("user should be provided"); } var loc = new String(window.location.protocol); loc = loc.slice(0, loc.length - 1); if(loc == 'file') { loc = 'https'; } this.ajax = options.ajax || (typeof(jQuery) !== 'undefined' ? jQuery.ajax: reqwest); if(!this.ajax) { throw new Error("jQuery or reqwest should be loaded"); } this.options = _.defaults(options, { version: 'v2', protocol: loc, jsonp: typeof(jQuery) !== 'undefined' ? !jQuery.support.cors: false }) if (!this.options.sql_api_template) { var opts = this.options; var template = null; if(opts && opts.completeDomain) { template = opts.completeDomain; } else { var host = opts.host || 'carto.com'; var protocol = opts.protocol || 'https'; template = protocol + '://{user}.' + host; } this.options.sql_api_template = template; } }
create a layer for the specified map @param map should be a L.Map object, or equivalent depending on what provider you have. @param layer should be an url or a javascript object with the data to create the layer @param options layer options
SQL
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
clamp = function(x, min, max) { return x < min ? min : x > max ? max : x; }
var sql = new SQL('cartodb_username'); sql.execute("select * from {{ table }} where id = {{ id }}", { table: 'test', id: '1' })
clamp
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function PathView(geometryModel) { var self = this; // events to link var events = [ 'click', 'dblclick', 'mousedown', 'mouseover', 'mouseout', ]; this._eventHandlers = {}; this.model = geometryModel; this.points = []; this.geom = L.GeoJSON.geometryToLayer(geometryModel.get('geojson')); this.geom.setStyle(geometryModel.get('style')); /*for(var i = 0; i < events.length; ++i) { var e = events[i]; this.geom.on(e, self._eventHandler(e)); }*/ }
view for other geometries (polygons/lines)
PathView
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function PathView(geometryModel) { var self = this; // events to link var events = [ 'click', 'dblclick', 'mousedown', 'mouseover', 'mouseout', ]; this._eventHandlers = {}; this.model = geometryModel; this.points = []; var style = _.clone(geometryModel.get('style')) || {}; this.geom = new GeoJSON ( geometryModel.get('geojson'), style ); /*_.each(this.geom._layers, function(g) { g.setStyle(geometryModel.get('style')); g.on('edit', function() { geometryModel.set('geojson', L.GeoJSON.toGeoJSON(self.geom)); }, self); }); */ _.bindAll(this, '_updateModel'); var self = this; function bindPath(p) { google.maps.event.addListener(p, 'insert_at', self._updateModel); /* google.maps.event.addListener(p, 'remove_at', this._updateModel); google.maps.event.addListener(p, 'set_at', this._updateModel); */ } // TODO: check this conditions if(this.geom.getPaths) { var paths = this.geom.getPaths(); if (paths && paths[0]) { // More than one path for(var i = 0; i < paths.length; ++i) { bindPath(paths[i]); } } else { // One path bindPath(paths); google.maps.event.addListener(this.geom, 'mouseup', this._updateModel); } } else { // More than one path if (this.geom.length) { for(var i = 0; i < this.geom.length; ++i) { bindPath(this.geom[i].getPath()); google.maps.event.addListener(this.geom[i], 'mouseup', this._updateModel); } } else { // One path bindPath(this.geom.getPath()); google.maps.event.addListener(this.geom, 'mouseup', this._updateModel); } } /*for(var i = 0; i < events.length; ++i) { var e = events[i]; this.geom.on(e, self._eventHandler(e)); }*/ }
view for other geometries (polygons/lines)
PathView
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function bindPath(p) { google.maps.event.addListener(p, 'insert_at', self._updateModel); /* google.maps.event.addListener(p, 'remove_at', this._updateModel); google.maps.event.addListener(p, 'set_at', this._updateModel); */ }
view for other geometries (polygons/lines)
bindPath
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function _coord(latlng) { return [latlng.lng(), latlng.lat()]; }
view for other geometries (polygons/lines)
_coord
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function _coords(latlngs) { var c = []; for(var i = 0; i < latlngs.length; ++i) { c.push(_coord(latlngs.getAt(i))); } return c; }
view for other geometries (polygons/lines)
_coords
javascript
CartoDB/cartodb
vendor/assets/javascripts/cartodb.uncompressed.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/cartodb.uncompressed.js
BSD-3-Clause
function mousePosition(evt) { // IE: if (window.event && window.event.contentOverflow !== undefined) { return { x: window.event.offsetX, y: window.event.offsetY }; } // Webkit: if (evt.offsetX !== undefined && evt.offsetY !== undefined) { return { x: evt.offsetX, y: evt.offsetY }; } // Firefox: var wrapper = evt.target.parentNode.parentNode; return { x: evt.layerX - wrapper.offsetLeft, y: evt.layerY - wrapper.offsetTop }; }
Return mouse position relative to the element el.
mousePosition
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function hsv2rgb(hsv) { var R, G, B, X, C; var h = (hsv.h % 360) / 60; C = hsv.v * hsv.s; X = C * (1 - Math.abs(h % 2 - 1)); R = G = B = hsv.v - C; h = ~~h; R += [C, X, 0, 0, X, C][h]; G += [X, C, C, X, 0, 0][h]; B += [0, 0, X, C, C, X][h]; var r = Math.floor(R * 255); var g = Math.floor(G * 255); var b = Math.floor(B * 255); return { r: r, g: g, b: b, hex: "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1) }; }
Convert HSV representation to RGB HEX string. Credits to http://www.raphaeljs.com
hsv2rgb
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function rgb2hsv(rgb) { var r = rgb.r; var g = rgb.g; var b = rgb.b; if (rgb.r > 1 || rgb.g > 1 || rgb.b > 1) { r /= 255; g /= 255; b /= 255; } var H, S, V, C; V = Math.max(r, g, b); C = V - Math.min(r, g, b); H = (C == 0 ? null : V == r ? (g - b) / C + (g < b ? 6 : 0) : V == g ? (b - r) / C + 2 : (r - g) / C + 4); H = (H % 6) * 60; S = C == 0 ? 0 : C / V; return { h: H, s: S, v: V }; }
Convert RGB representation to HSV. r, g, b can be either in <0,1> range or <0,255> range. Credits to http://www.raphaeljs.com
rgb2hsv
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function slideListener(ctx, slideElement, pickerElement) { return function(evt) { evt = evt || window.event; var mouse = mousePosition(evt); ctx.h = mouse.y / slideElement.offsetHeight * 360 + hueOffset; ctx.s = ctx.v = 1; var c = hsv2rgb({ h: ctx.h, s: 1, v: 1 }); pickerElement.style.backgroundColor = c.hex; ctx.callback && ctx.callback(c.hex, { h: ctx.h - hueOffset, s: ctx.s, v: ctx.v }, { r: c.r, g: c.g, b: c.b }, undefined, mouse); } }
Return click event handler for the slider. Sets picker background color and calls ctx.callback if provided.
slideListener
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function pickerListener(ctx, pickerElement) { return function(evt) { evt = evt || window.event; var mouse = mousePosition(evt), width = pickerElement.offsetWidth, height = pickerElement.offsetHeight; ctx.s = mouse.x / width; ctx.v = (height - mouse.y) / height; var c = hsv2rgb(ctx); ctx.callback && ctx.callback(c.hex, { h: ctx.h - hueOffset, s: ctx.s, v: ctx.v }, { r: c.r, g: c.g, b: c.b }, mouse); } }
Return click event handler for the picker. Calls ctx.callback if provided.
pickerListener
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function ColorPicker(slideElement, pickerElement, callback) { if (!(this instanceof ColorPicker)) return new ColorPicker(slideElement, pickerElement, callback); this.h = 0; this.s = 1; this.v = 1; if (!callback) { // call of the form ColorPicker(element, funtion(hex, hsv, rgb) { ... }), i.e. the no-hassle call. var element = slideElement; element.innerHTML = colorpickerHTMLSnippet; this.slideElement = element.getElementsByClassName('slide')[0]; this.pickerElement = element.getElementsByClassName('picker')[0]; var slideIndicator = element.getElementsByClassName('slide-indicator')[0]; var pickerIndicator = element.getElementsByClassName('picker-indicator')[0]; ColorPicker.fixIndicators(slideIndicator, pickerIndicator); this.callback = function(hex, hsv, rgb, pickerCoordinate, slideCoordinate) { ColorPicker.positionIndicators(slideIndicator, pickerIndicator, slideCoordinate, pickerCoordinate); pickerElement(hex, hsv, rgb); }; } else { this.callback = callback; this.pickerElement = pickerElement; this.slideElement = slideElement; } if (type == 'SVG') { // Generate uniq IDs for linearGradients so that we don't have the same IDs within one document. // Then reference those gradients in the associated rectangles. var slideClone = slide.cloneNode(true); var pickerClone = picker.cloneNode(true); var hsvGradient = slideClone.getElementById('gradient-hsv'); var hsvRect = slideClone.getElementsByTagName('rect')[0]; if (hsvGradient) { hsvGradient.id = 'gradient-hsv-' + uniqID; hsvRect.setAttribute('fill', 'url(#' + hsvGradient.id + ')'); } var blackAndWhiteGradients = [pickerClone.getElementById('gradient-black'), pickerClone.getElementById('gradient-white')]; var whiteAndBlackRects = pickerClone.getElementsByTagName('rect'); if (blackAndWhiteGradients[0]) { blackAndWhiteGradients[0].id = 'gradient-black-' + uniqID; whiteAndBlackRects[1].setAttribute('fill', 'url(#' + blackAndWhiteGradients[0].id + ')'); } if (blackAndWhiteGradients[1]) { blackAndWhiteGradients[1].id = 'gradient-white-' + uniqID; whiteAndBlackRects[0].setAttribute('fill', 'url(#' + blackAndWhiteGradients[1].id + ')'); } this.slideElement.appendChild(slideClone); this.pickerElement.appendChild(pickerClone); uniqID++; } else { this.slideElement.innerHTML = slide; this.pickerElement.innerHTML = picker; } addEventListener(this.slideElement, 'click', slideListener(this, this.slideElement, this.pickerElement)); addEventListener(this.pickerElement, 'click', pickerListener(this, this.pickerElement)); enableDragging(this, this.slideElement, slideListener(this, this.slideElement, this.pickerElement)); enableDragging(this, this.pickerElement, pickerListener(this, this.pickerElement)); }
ColorPicker. @param {DOMElement} slideElement HSV slide element. @param {DOMElement} pickerElement HSV picker element. @param {Function} callback Called whenever the color is changed provided chosen color in RGB HEX format as the only argument.
ColorPicker
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function addEventListener(element, event, listener) { if (element.attachEvent) { element.attachEvent('on' + event, listener); } else if (element.addEventListener) { element.addEventListener(event, listener, false); } }
ColorPicker. @param {DOMElement} slideElement HSV slide element. @param {DOMElement} pickerElement HSV picker element. @param {Function} callback Called whenever the color is changed provided chosen color in RGB HEX format as the only argument.
addEventListener
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function removeEventListener(element, event, listener) { if (element.attachEvent) { element.detachEvent('on' + event, listener); } else if (element.addEventListener) { element.removeEventListener(event, listener, false); } }
ColorPicker. @param {DOMElement} slideElement HSV slide element. @param {DOMElement} pickerElement HSV picker element. @param {Function} callback Called whenever the color is changed provided chosen color in RGB HEX format as the only argument.
removeEventListener
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function enableDragging(ctx, element, listener) { var mousedown = false; addEventListener(element, 'mousedown', function(evt) { mousedown = true; }); addEventListener(element, 'mouseup', function(evt) { mousedown = false; }); addEventListener(element, 'mouseout', function(evt) { mousedown = false; }); addEventListener(element, 'mousemove', function(evt) { if (mousedown) { listener(evt); } }); }
Enable drag&drop color selection. @param {object} ctx ColorPicker instance. @param {DOMElement} element HSV slide element or HSV picker element. @param {Function} listener Function that will be called whenever mouse is dragged over the element with event object as argument.
enableDragging
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function disableDragging(ctx, element, listener) { removeEventListener(element, 'mousedown'); removeEventListener(element, 'mouseup'); removeEventListener(element, 'mouseout'); removeEventListener(element, 'mousemove'); }
Enable drag&drop color selection. @param {object} ctx ColorPicker instance. @param {DOMElement} element HSV slide element or HSV picker element. @param {Function} listener Function that will be called whenever mouse is dragged over the element with event object as argument.
disableDragging
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function setColor(ctx, hsv, rgb, hex) { ctx.h = hsv.h % 360; ctx.s = hsv.s; ctx.v = hsv.v; var c = hsv2rgb(ctx); var mouseSlide = { y: (ctx.h * ctx.slideElement.offsetHeight) / 360, x: 0 // not important }; var pickerHeight = ctx.pickerElement.offsetHeight; var mousePicker = { x: ctx.s * ctx.pickerElement.offsetWidth, y: pickerHeight - ctx.v * pickerHeight }; ctx.pickerElement.style.backgroundColor = hsv2rgb({ h: ctx.h, s: 1, v: 1 }).hex; ctx.callback && ctx.callback(hex || c.hex, { h: ctx.h, s: ctx.s, v: ctx.v }, rgb || { r: c.r, g: c.g, b: c.b }, mousePicker, mouseSlide); return ctx; }
Sets color of the picker in hsv/rgb/hex format. @param {object} ctx ColorPicker instance. @param {object} hsv Object of the form: { h: <hue>, s: <saturation>, v: <value> }. @param {object} rgb Object of the form: { r: <red>, g: <green>, b: <blue> }. @param {string} hex String of the form: #RRGGBB.
setColor
javascript
CartoDB/cartodb
vendor/assets/javascripts/colorpicker.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/colorpicker.js
BSD-3-Clause
function path(d, i) { if (typeof pointRadius === "function") pointCircle = d3_path_circle(pointRadius.apply(this, arguments)); pathType(d); var result = buffer.length ? buffer.join("") : null; buffer = []; return result; }
Returns a function that, given a GeoJSON object (e.g., a feature), returns the corresponding SVG path. The function can be customized by overriding the projection. Point features are mapped to circles with a default radius of 4.5px; the radius can be specified either as a constant or a function that is evaluated per object.
path
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function project(coordinates) { return projection(coordinates).join(","); }
Returns a function that, given a GeoJSON object (e.g., a feature), returns the corresponding SVG path. The function can be customized by overriding the projection. Point features are mapped to circles with a default radius of 4.5px; the radius can be specified either as a constant or a function that is evaluated per object.
project
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function polygonArea(coordinates) { var sum = area(coordinates[0]), // exterior ring i = 0, // coordinates.index n = coordinates.length; while (++i < n) sum -= area(coordinates[i]); // holes return sum; }
Returns a function that, given a GeoJSON object (e.g., a feature), returns the corresponding SVG path. The function can be customized by overriding the projection. Point features are mapped to circles with a default radius of 4.5px; the radius can be specified either as a constant or a function that is evaluated per object.
polygonArea
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function polygonCentroid(coordinates) { var polygon = d3.geom.polygon(coordinates[0].map(projection)), // exterior ring area = polygon.area(), centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1), x = centroid[0], y = centroid[1], z = area, i = 0, // coordinates index n = coordinates.length; while (++i < n) { polygon = d3.geom.polygon(coordinates[i].map(projection)); // holes area = polygon.area(); centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1); x -= centroid[0]; y -= centroid[1]; z -= area; } return [x, y, 6 * z]; // weighted centroid }
Returns a function that, given a GeoJSON object (e.g., a feature), returns the corresponding SVG path. The function can be customized by overriding the projection. Point features are mapped to circles with a default radius of 4.5px; the radius can be specified either as a constant or a function that is evaluated per object.
polygonCentroid
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function area(coordinates) { return Math.abs(d3.geom.polygon(coordinates.map(projection)).area()); }
Returns a function that, given a GeoJSON object (e.g., a feature), returns the corresponding SVG path. The function can be customized by overriding the projection. Point features are mapped to circles with a default radius of 4.5px; the radius can be specified either as a constant or a function that is evaluated per object.
area
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_path_circle(radius) { return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + (-2 * radius) + "a" + radius + "," + radius + " 0 1,1 0," + (+2 * radius) + "z"; }
Returns a function that, given a GeoJSON object (e.g., a feature), returns the corresponding SVG path. The function can be customized by overriding the projection. Point features are mapped to circles with a default radius of 4.5px; the radius can be specified either as a constant or a function that is evaluated per object.
d3_path_circle
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_bounds(o, f) { if (d3_geo_boundsTypes.hasOwnProperty(o.type)) d3_geo_boundsTypes[o.type](o, f); }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_bounds
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsFeature(o, f) { d3_geo_bounds(o.geometry, f); }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsFeature
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsFeatureCollection(o, f) { for (var a = o.features, i = 0, n = a.length; i < n; i++) { d3_geo_bounds(a[i].geometry, f); } }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsFeatureCollection
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsGeometryCollection(o, f) { for (var a = o.geometries, i = 0, n = a.length; i < n; i++) { d3_geo_bounds(a[i], f); } }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsGeometryCollection
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsLineString(o, f) { for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { f.apply(null, a[i]); } }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsLineString
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsMultiLineString(o, f) { for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { for (var b = a[i], j = 0, m = b.length; j < m; j++) { f.apply(null, b[j]); } } }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsMultiLineString
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsMultiPolygon(o, f) { for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) { for (var b = a[i][0], j = 0, m = b.length; j < m; j++) { f.apply(null, b[j]); } } }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsMultiPolygon
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsPoint(o, f) { f.apply(null, o.coordinates); }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsPoint
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_boundsPolygon(o, f) { for (var a = o.coordinates[0], i = 0, n = a.length; i < n; i++) { f.apply(null, a[i]); } }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_boundsPolygon
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function circle() { // TODO render a circle as a Polygon }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
circle
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function visible(point) { return arc.distance(point) < radians; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
visible
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function clip(coordinates) { var i = -1, n = coordinates.length, clipped = [], p0, p1, p2, d0, d1; while (++i < n) { d1 = arc.distance(p2 = coordinates[i]); if (d1 < radians) { if (p1) clipped.push(d3_geo_greatArcInterpolate(p1, p2)((d0 - radians) / (d0 - d1))); clipped.push(p2); p0 = p1 = null; } else { p1 = p2; if (!p0 && clipped.length) { clipped.push(d3_geo_greatArcInterpolate(clipped[clipped.length - 1], p1)((radians - d0) / (d1 - d0))); p0 = p1; } } d0 = d1; } // Close the clipped polygon if necessary. p0 = coordinates[0]; p1 = clipped[0]; if (p1 && p2[0] === p0[0] && p2[1] === p0[1] && !(p2[0] === p1[0] && p2[1] === p1[1])) { clipped.push(p1); } return resample(clipped); }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
clip
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function resample(coordinates) { var i = 0, n = coordinates.length, j, m, resampled = n ? [coordinates[0]] : coordinates, resamples, origin = arc.source(); while (++i < n) { resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates; for (j = 0, m = resamples.length; ++j < m;) resampled.push(resamples[j]); } arc.source(origin); return resampled; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
resample
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function greatArc() { var d = greatArc.distance.apply(this, arguments), // initializes the interpolator, too t = 0, dt = precision / d, coordinates = [p0]; while ((t += dt) < 1) coordinates.push(interpolate(t)); coordinates.push(p1); return {type: "LineString", coordinates: coordinates}; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
greatArc
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_greatArcSource(d) { return d.source; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_greatArcSource
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_greatArcTarget(d) { return d.target; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_greatArcTarget
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_greatArcInterpolator() { var x0, y0, cy0, sy0, kx0, ky0, x1, y1, cy1, sy1, kx1, ky1, d, k; function interpolate(t) { var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; return [ Math.atan2(y, x) / d3_geo_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians ]; } interpolate.distance = function() { if (d == null) k = 1 / Math.sin(d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0))))); return d; }; interpolate.source = function(_) { var cx0 = Math.cos(x0 = _[0] * d3_geo_radians), sx0 = Math.sin(x0); cy0 = Math.cos(y0 = _[1] * d3_geo_radians); sy0 = Math.sin(y0); kx0 = cy0 * cx0; ky0 = cy0 * sx0; d = null; return interpolate; }; interpolate.target = function(_) { var cx1 = Math.cos(x1 = _[0] * d3_geo_radians), sx1 = Math.sin(x1); cy1 = Math.cos(y1 = _[1] * d3_geo_radians); sy1 = Math.sin(y1); kx1 = cy1 * cx1; ky1 = cy1 * sx1; d = null; return interpolate; }; return interpolate; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_greatArcInterpolator
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function interpolate(t) { var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; return [ Math.atan2(y, x) / d3_geo_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians ]; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
interpolate
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function d3_geo_greatArcInterpolate(a, b) { var i = d3_geo_greatArcInterpolator().source(a).target(b); i.distance(); return i; }
Given a GeoJSON object, returns the corresponding bounding box. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude.
d3_geo_greatArcInterpolate
javascript
CartoDB/cartodb
vendor/assets/javascripts/d3.v2.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/d3.v2.js
BSD-3-Clause
function error(type) { throw RangeError(errors[type]); }
A generic error utility function. @private @param {String} type The error type. @returns {Error} Throws a `RangeError` with the applicable error message.
error
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function map(array, fn) { var length = array.length; var result = []; while (length--) { result[length] = fn(array[length]); } return result; }
A generic `Array#map` utility function. @private @param {Array} array The array to iterate over. @param {Function} callback The function that gets called for every array item. @returns {Array} A new array of values returned by the callback function.
map
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function mapDomain(string, fn) { var parts = string.split('@'); var result = ''; if (parts.length > 1) { // In email addresses, only the domain name should be punycoded. Leave // the local part (i.e. everything up to `@`) intact. result = parts[0] + '@'; string = parts[1]; } var labels = string.split(regexSeparators); var encoded = map(labels, fn).join('.'); return result + encoded; }
A simple `Array#map`-like wrapper to work with domain name strings or email addresses. @private @param {String} domain The domain name or email address. @param {Function} callback The function that gets called for every character. @returns {Array} A new string of characters returned by the callback function.
mapDomain
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function ucs2decode(string) { var output = [], counter = 0, length = string.length, value, extra; while (counter < length) { value = string.charCodeAt(counter++); if (value >= 0xD800 && value <= 0xDBFF && counter < length) { // high surrogate, and there is a next character extra = string.charCodeAt(counter++); if ((extra & 0xFC00) == 0xDC00) { // low surrogate output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); } else { // unmatched surrogate; only append this code unit, in case the next // code unit is the high surrogate of a surrogate pair output.push(value); counter--; } } else { output.push(value); } } return output; }
Creates an array containing the numeric code points of each Unicode character in the string. While JavaScript uses UCS-2 internally, this function will convert a pair of surrogate halves (each of which UCS-2 exposes as separate characters) into a single code point, matching UTF-16. @see `punycode.ucs2.encode` @see <https://mathiasbynens.be/notes/javascript-encoding> @memberOf punycode.ucs2 @name decode @param {String} string The Unicode input string (UCS-2). @returns {Array} The new array of code points.
ucs2decode
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function ucs2encode(array) { return map(array, function(value) { var output = ''; if (value > 0xFFFF) { value -= 0x10000; output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); value = 0xDC00 | value & 0x3FF; } output += stringFromCharCode(value); return output; }).join(''); }
Creates a string based on an array of numeric code points. @see `punycode.ucs2.decode` @memberOf punycode.ucs2 @name encode @param {Array} codePoints The array of numeric code points. @returns {String} The new Unicode string (UCS-2).
ucs2encode
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function basicToDigit(codePoint) { if (codePoint - 48 < 10) { return codePoint - 22; } if (codePoint - 65 < 26) { return codePoint - 65; } if (codePoint - 97 < 26) { return codePoint - 97; } return base; }
Converts a basic code point into a digit/integer. @see `digitToBasic()` @private @param {Number} codePoint The basic numeric code point value. @returns {Number} The numeric value of a basic code point (for use in representing integers) in the range `0` to `base - 1`, or `base` if the code point does not represent a value.
basicToDigit
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function digitToBasic(digit, flag) { // 0..25 map to ASCII a..z or A..Z // 26..35 map to ASCII 0..9 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); }
Converts a digit/integer into a basic code point. @see `basicToDigit()` @private @param {Number} digit The numeric value of a basic code point. @returns {Number} The basic code point whose value (when used for representing integers) is `digit`, which needs to be in the range `0` to `base - 1`. If `flag` is non-zero, the uppercase form is used; else, the lowercase form is used. The behavior is undefined if `flag` is non-zero and `digit` has no uppercase form.
digitToBasic
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function adapt(delta, numPoints, firstTime) { var k = 0; delta = firstTime ? floor(delta / damp) : delta >> 1; delta += floor(delta / numPoints); for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { delta = floor(delta / baseMinusTMin); } return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); }
Bias adaptation function as per section 3.4 of RFC 3492. http://tools.ietf.org/html/rfc3492#section-3.4 @private
adapt
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function decode(input) { // Don't use UCS-2 var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, /** Cached calculation results */ baseMinusT; // Handle the basic code points: let `basic` be the number of input code // points before the last delimiter, or `0` if there is none, then copy // the first basic code points to the output. basic = input.lastIndexOf(delimiter); if (basic < 0) { basic = 0; } for (j = 0; j < basic; ++j) { // if it's not a basic code point if (input.charCodeAt(j) >= 0x80) { error('not-basic'); } output.push(input.charCodeAt(j)); } // Main decoding loop: start just after the last delimiter if any basic code // points were copied; start at the beginning otherwise. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { // `index` is the index of the next character to be consumed. // Decode a generalized variable-length integer into `delta`, // which gets added to `i`. The overflow checking is easier // if we increase `i` as we go, then subtract off its starting // value at the end to obtain `delta`. for (oldi = i, w = 1, k = base; /* no condition */; k += base) { if (index >= inputLength) { error('invalid-input'); } digit = basicToDigit(input.charCodeAt(index++)); if (digit >= base || digit > floor((maxInt - i) / w)) { error('overflow'); } i += digit * w; t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); if (digit < t) { break; } baseMinusT = base - t; if (w > floor(maxInt / baseMinusT)) { error('overflow'); } w *= baseMinusT; } out = output.length + 1; bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`, // incrementing `n` each time, so we'll fix that now: if (floor(i / out) > maxInt - n) { error('overflow'); } n += floor(i / out); i %= out; // Insert `n` at position `i` of the output output.splice(i++, 0, n); } return ucs2encode(output); }
Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. @memberOf punycode @param {String} input The Punycode string of ASCII-only symbols. @returns {String} The resulting string of Unicode symbols.
decode
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function encode(input) { var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], /** `inputLength` will hold the number of code points in `input`. */ inputLength, /** Cached calculation results */ handledCPCountPlusOne, baseMinusT, qMinusT; // Convert the input in UCS-2 to Unicode input = ucs2decode(input); // Cache the length inputLength = input.length; // Initialize the state n = initialN; delta = 0; bias = initialBias; // Handle the basic code points for (j = 0; j < inputLength; ++j) { currentValue = input[j]; if (currentValue < 0x80) { output.push(stringFromCharCode(currentValue)); } } handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled; // `basicLength` is the number of basic code points. // Finish the basic string - if it is not empty - with a delimiter if (basicLength) { output.push(delimiter); } // Main encoding loop: while (handledCPCount < inputLength) { // All non-basic code points < n have been handled already. Find the next // larger one: for (m = maxInt, j = 0; j < inputLength; ++j) { currentValue = input[j]; if (currentValue >= n && currentValue < m) { m = currentValue; } } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, // but guard against overflow handledCPCountPlusOne = handledCPCount + 1; if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { error('overflow'); } delta += (m - n) * handledCPCountPlusOne; n = m; for (j = 0; j < inputLength; ++j) { currentValue = input[j]; if (currentValue < n && ++delta > maxInt) { error('overflow'); } if (currentValue == n) { // Represent delta as a generalized variable-length integer for (q = delta, k = base; /* no condition */; k += base) { t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); if (q < t) { break; } qMinusT = q - t; baseMinusT = base - t; output.push( stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) ); q = floor(qMinusT / baseMinusT); } output.push(stringFromCharCode(digitToBasic(q, 0))); bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); delta = 0; ++handledCPCount; } } ++delta; ++n; } return output.join(''); }
Converts a string of Unicode symbols (e.g. a domain name label) to a Punycode string of ASCII-only symbols. @memberOf punycode @param {String} input The string of Unicode symbols. @returns {String} The resulting Punycode string of ASCII-only symbols.
encode
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function toUnicode(input) { return mapDomain(input, function(string) { return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string; }); }
Converts a Punycode string representing a domain name or an email address to Unicode. Only the Punycoded parts of the input will be converted, i.e. it doesn't matter if you call it on a string that has already been converted to Unicode. @memberOf punycode @param {String} input The Punycoded domain name or email address to convert to Unicode. @returns {String} The Unicode representation of the given Punycode string.
toUnicode
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function toASCII(input) { return mapDomain(input, function(string) { return regexNonASCII.test(string) ? 'xn--' + encode(string) : string; }); }
Converts a Unicode string representing a domain name or an email address to Punycode. Only the non-ASCII parts of the domain name will be converted, i.e. it doesn't matter if you call it with a domain that's already in ASCII. @memberOf punycode @param {String} input The domain name or email address to convert, as a Unicode string. @returns {String} The Punycode representation of the given domain name or email address.
toASCII
javascript
CartoDB/cartodb
vendor/assets/javascripts/html2canvas.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/html2canvas.js
BSD-3-Clause
function mk_block_toSource() { return "Markdown.mk_block( " + uneval(this.toString()) + ", " + uneval(this.trailing) + ", " + uneval(this.lineNumber) + " )"; }
toHTMLTree( markdown, [dialect] ) -> JsonML toHTMLTree( md_tree ) -> JsonML - markdown (String): markdown string to parse - dialect (String | Dialect): the dialect to use, defaults to gruber - md_tree (Markdown.JsonML): parsed markdown tree Turn markdown into HTML, represented as a JsonML tree. If a string is given to this function, it is first parsed into a markdown tree by calling [[parse]].
mk_block_toSource
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function mk_block_inspect() { var util = require("util"); return "Markdown.mk_block( " + util.inspect(this.toString()) + ", " + util.inspect(this.trailing) + ", " + util.inspect(this.lineNumber) + " )"; }
toHTMLTree( markdown, [dialect] ) -> JsonML toHTMLTree( md_tree ) -> JsonML - markdown (String): markdown string to parse - dialect (String | Dialect): the dialect to use, defaults to gruber - md_tree (Markdown.JsonML): parsed markdown tree Turn markdown into HTML, represented as a JsonML tree. If a string is given to this function, it is first parsed into a markdown tree by calling [[parse]].
mk_block_inspect
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function count_lines( str ) { var n = 0, i = -1; while ( ( i = str.indexOf("\n", i + 1) ) !== -1 ) n++; return n; }
toHTMLTree( markdown, [dialect] ) -> JsonML toHTMLTree( md_tree ) -> JsonML - markdown (String): markdown string to parse - dialect (String | Dialect): the dialect to use, defaults to gruber - md_tree (Markdown.JsonML): parsed markdown tree Turn markdown into HTML, represented as a JsonML tree. If a string is given to this function, it is first parsed into a markdown tree by calling [[parse]].
count_lines
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function regex_for_depth( depth ) { return new RegExp( // m[1] = indent, m[2] = list_type "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" + // m[3] = cont "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})" ); }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
regex_for_depth
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function expand_tab( input ) { return input.replace( / {0,3}\t/g, " " ); }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
expand_tab
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function add(li, loose, inline, nl) { if ( loose ) { li.push( [ "para" ].concat(inline) ); return; } // Hmmm, should this be any block level element or just paras? var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para" ? li[li.length -1] : li; // If there is already some content in this list, add the new line in if ( nl && li.length > 1 ) inline.unshift(nl); for ( var i = 0; i < inline.length; i++ ) { var what = inline[i], is_str = typeof what == "string"; if ( is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) { add_to[ add_to.length-1 ] += what; } else { add_to.push( what ); } } }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
add
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function get_contained_blocks( depth, blocks ) { var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ), replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"), ret = []; while ( blocks.length > 0 ) { if ( re.exec( blocks[0] ) ) { var b = blocks.shift(), // Now remove that indent x = b.replace( replace, ""); ret.push( mk_block( x, b.trailing, b.lineNumber ) ); } else { break; } } return ret; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
get_contained_blocks
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function paragraphify(s, i, stack) { var list = s.list; var last_li = list[list.length-1]; if ( last_li[1] instanceof Array && last_li[1][0] == "para" ) { return; } if ( i + 1 == stack.length ) { // Last stack frame // Keep the same array, but replace the contents last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ) ); } else { var sublist = last_li.pop(); last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ), sublist ); } }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
paragraphify
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function make_list( m ) { var list = bullet_list.exec( m[2] ) ? ["bulletlist"] : ["numberlist"]; stack.push( { list: list, indent: m[1] } ); return list; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
make_list
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function add(x) { //D:self.debug(" adding output", uneval(x)); if ( typeof x == "string" && typeof out[out.length-1] == "string" ) out[ out.length-1 ] += x; else out.push(x); }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
add
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function strong_em( tag, md ) { var state_slot = tag + "_state", other_slot = tag == "strong" ? "em_state" : "strong_state"; function CloseTag(len) { this.len_after = len; this.name = "close_" + md; } return function ( text, orig_match ) { if ( this[state_slot][0] == md ) { // Most recent em is of this type //D:this.debug("closing", md); this[state_slot].shift(); // "Consume" everything to go back to the recrusion in the else-block below return[ text.length, new CloseTag(text.length-md.length) ]; } else { // Store a clone of the em/strong states var other = this[other_slot].slice(), state = this[state_slot].slice(); this[state_slot].unshift(md); //D:this.debug_indent += " "; // Recurse var res = this.processInline( text.substr( md.length ) ); //D:this.debug_indent = this.debug_indent.substr(2); var last = res[res.length - 1]; //D:this.debug("processInline from", tag + ": ", uneval( res ) ); var check = this[state_slot].shift(); if ( last instanceof CloseTag ) { res.pop(); // We matched! Huzzah. var consumed = text.length - last.len_after; return [ consumed, [ tag ].concat(res) ]; } else { // Restore the state of the other kind. We might have mistakenly closed it. this[other_slot] = other; this[state_slot] = state; // We can't reuse the processed result as it could have wrong parsing contexts in it. return [ md.length, md ]; } } }; // End returned function }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
strong_em
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function CloseTag(len) { this.len_after = len; this.name = "close_" + md; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
CloseTag
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function split_meta_hash( meta_string ) { var meta = meta_string.split( "" ), parts = [ "" ], in_quotes = false; while ( meta.length ) { var letter = meta.shift(); switch ( letter ) { case " " : // if we're in a quoted section, keep it if ( in_quotes ) { parts[ parts.length - 1 ] += letter; } // otherwise make a new part else { parts.push( "" ); } break; case "'" : case '"' : // reverse the quotes and move straight on in_quotes = !in_quotes; break; case "\\" : // shift off the next letter to be used straight away. // it was escaped so we'll keep it whatever it is letter = meta.shift(); default : parts[ parts.length - 1 ] += letter; break; } } return parts; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
split_meta_hash
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
_split_on_unescaped = function(s, ch) { ch = ch || '\\s'; if (ch.match(/^[\\|\[\]{}?*.+^$]$/)) { ch = '\\' + ch; } var res = [ ], r = new RegExp('^((?:\\\\.|[^\\\\' + ch + '])*)' + ch + '(.*)'), m; while(m = s.match(r)) { res.push(m[1]); s = m[2]; } res.push(s); return res; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
_split_on_unescaped
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
isEmpty = function( obj ) { for ( var key in obj ) { if ( hasOwnProperty.call( obj, key ) ) { return false; } } return true; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
isEmpty
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function extract_attr( jsonml ) { return isArray(jsonml) && jsonml.length > 1 && typeof jsonml[ 1 ] === "object" && !( isArray(jsonml[ 1 ]) ) ? jsonml[ 1 ] : undefined; }
Markdown.dialects.Gruber The default dialect that follows the rules set out by John Gruber's markdown.pl as closely as possible. Well actually we follow the behaviour of that script which in some places is not exactly what the syntax web page says.
extract_attr
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause
function escapeHTML( text ) { return text.replace( /&/g, "&amp;" ) .replace( /</g, "&lt;" ) .replace( />/g, "&gt;" ) .replace( /"/g, "&quot;" ) .replace( /'/g, "&#39;" ); }
renderJsonML( jsonml[, options] ) -> String - jsonml (Array): JsonML array to render to XML - options (Object): options Converts the given JsonML into well-formed XML. The options currently understood are: - root (Boolean): wether or not the root node should be included in the output, or just its children. The default `false` is to not include the root itself.
escapeHTML
javascript
CartoDB/cartodb
vendor/assets/javascripts/markdown.js
https://github.com/CartoDB/cartodb/blob/master/vendor/assets/javascripts/markdown.js
BSD-3-Clause