id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
900
Dogfalo/materialize
dist/js/materialize.js
function () { _this15.el.style.display = 'none'; _this15.$overlay.remove(); // Call onCloseEnd callback if (typeof _this15.options.onCloseEnd === 'function') { _this15.options.onCloseEnd.call(_this15, _this15.el); } }
javascript
function () { _this15.el.style.display = 'none'; _this15.$overlay.remove(); // Call onCloseEnd callback if (typeof _this15.options.onCloseEnd === 'function') { _this15.options.onCloseEnd.call(_this15, _this15.el); } }
[ "function", "(", ")", "{", "_this15", ".", "el", ".", "style", ".", "display", "=", "'none'", ";", "_this15", ".", "$overlay", ".", "remove", "(", ")", ";", "// Call onCloseEnd callback", "if", "(", "typeof", "_this15", ".", "options", ".", "onCloseEnd", "===", "'function'", ")", "{", "_this15", ".", "options", ".", "onCloseEnd", ".", "call", "(", "_this15", ",", "_this15", ".", "el", ")", ";", "}", "}" ]
Handle modal ready callback
[ "Handle", "modal", "ready", "callback" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L3135-L3143
901
Dogfalo/materialize
dist/js/materialize.js
Materialbox
function Materialbox(el, options) { _classCallCheck(this, Materialbox); var _this16 = _possibleConstructorReturn(this, (Materialbox.__proto__ || Object.getPrototypeOf(Materialbox)).call(this, Materialbox, el, options)); _this16.el.M_Materialbox = _this16; /** * Options for the modal * @member Materialbox#options * @prop {Number} [inDuration=275] - Length in ms of enter transition * @prop {Number} [outDuration=200] - Length in ms of exit transition * @prop {Function} onOpenStart - Callback function called before materialbox is opened * @prop {Function} onOpenEnd - Callback function called after materialbox is opened * @prop {Function} onCloseStart - Callback function called before materialbox is closed * @prop {Function} onCloseEnd - Callback function called after materialbox is closed */ _this16.options = $.extend({}, Materialbox.defaults, options); _this16.overlayActive = false; _this16.doneAnimating = true; _this16.placeholder = $('<div></div>').addClass('material-placeholder'); _this16.originalWidth = 0; _this16.originalHeight = 0; _this16.originInlineStyles = _this16.$el.attr('style'); _this16.caption = _this16.el.getAttribute('data-caption') || ''; // Wrap _this16.$el.before(_this16.placeholder); _this16.placeholder.append(_this16.$el); _this16._setupEventHandlers(); return _this16; }
javascript
function Materialbox(el, options) { _classCallCheck(this, Materialbox); var _this16 = _possibleConstructorReturn(this, (Materialbox.__proto__ || Object.getPrototypeOf(Materialbox)).call(this, Materialbox, el, options)); _this16.el.M_Materialbox = _this16; /** * Options for the modal * @member Materialbox#options * @prop {Number} [inDuration=275] - Length in ms of enter transition * @prop {Number} [outDuration=200] - Length in ms of exit transition * @prop {Function} onOpenStart - Callback function called before materialbox is opened * @prop {Function} onOpenEnd - Callback function called after materialbox is opened * @prop {Function} onCloseStart - Callback function called before materialbox is closed * @prop {Function} onCloseEnd - Callback function called after materialbox is closed */ _this16.options = $.extend({}, Materialbox.defaults, options); _this16.overlayActive = false; _this16.doneAnimating = true; _this16.placeholder = $('<div></div>').addClass('material-placeholder'); _this16.originalWidth = 0; _this16.originalHeight = 0; _this16.originInlineStyles = _this16.$el.attr('style'); _this16.caption = _this16.el.getAttribute('data-caption') || ''; // Wrap _this16.$el.before(_this16.placeholder); _this16.placeholder.append(_this16.$el); _this16._setupEventHandlers(); return _this16; }
[ "function", "Materialbox", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "Materialbox", ")", ";", "var", "_this16", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "Materialbox", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "Materialbox", ")", ")", ".", "call", "(", "this", ",", "Materialbox", ",", "el", ",", "options", ")", ")", ";", "_this16", ".", "el", ".", "M_Materialbox", "=", "_this16", ";", "/**\n * Options for the modal\n * @member Materialbox#options\n * @prop {Number} [inDuration=275] - Length in ms of enter transition\n * @prop {Number} [outDuration=200] - Length in ms of exit transition\n * @prop {Function} onOpenStart - Callback function called before materialbox is opened\n * @prop {Function} onOpenEnd - Callback function called after materialbox is opened\n * @prop {Function} onCloseStart - Callback function called before materialbox is closed\n * @prop {Function} onCloseEnd - Callback function called after materialbox is closed\n */", "_this16", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "Materialbox", ".", "defaults", ",", "options", ")", ";", "_this16", ".", "overlayActive", "=", "false", ";", "_this16", ".", "doneAnimating", "=", "true", ";", "_this16", ".", "placeholder", "=", "$", "(", "'<div></div>'", ")", ".", "addClass", "(", "'material-placeholder'", ")", ";", "_this16", ".", "originalWidth", "=", "0", ";", "_this16", ".", "originalHeight", "=", "0", ";", "_this16", ".", "originInlineStyles", "=", "_this16", ".", "$el", ".", "attr", "(", "'style'", ")", ";", "_this16", ".", "caption", "=", "_this16", ".", "el", ".", "getAttribute", "(", "'data-caption'", ")", "||", "''", ";", "// Wrap", "_this16", ".", "$el", ".", "before", "(", "_this16", ".", "placeholder", ")", ";", "_this16", ".", "placeholder", ".", "append", "(", "_this16", ".", "$el", ")", ";", "_this16", ".", "_setupEventHandlers", "(", ")", ";", "return", "_this16", ";", "}" ]
Construct Materialbox instance @constructor @param {Element} el @param {Object} options
[ "Construct", "Materialbox", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L3327-L3360
902
Dogfalo/materialize
dist/js/materialize.js
_createToast
function _createToast() { var toast = document.createElement('div'); toast.classList.add('toast'); // Add custom classes onto toast if (!!this.options.classes.length) { $(toast).addClass(this.options.classes); } // Set content if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') { toast.appendChild(this.message); // Check if it is jQuery object } else if (!!this.message.jquery) { $(toast).append(this.message[0]); // Insert as html; } else { toast.innerHTML = this.message; } // Append toasft Toast._container.appendChild(toast); return toast; }
javascript
function _createToast() { var toast = document.createElement('div'); toast.classList.add('toast'); // Add custom classes onto toast if (!!this.options.classes.length) { $(toast).addClass(this.options.classes); } // Set content if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') { toast.appendChild(this.message); // Check if it is jQuery object } else if (!!this.message.jquery) { $(toast).append(this.message[0]); // Insert as html; } else { toast.innerHTML = this.message; } // Append toasft Toast._container.appendChild(toast); return toast; }
[ "function", "_createToast", "(", ")", "{", "var", "toast", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "toast", ".", "classList", ".", "add", "(", "'toast'", ")", ";", "// Add custom classes onto toast", "if", "(", "!", "!", "this", ".", "options", ".", "classes", ".", "length", ")", "{", "$", "(", "toast", ")", ".", "addClass", "(", "this", ".", "options", ".", "classes", ")", ";", "}", "// Set content", "if", "(", "typeof", "HTMLElement", "===", "'object'", "?", "this", ".", "message", "instanceof", "HTMLElement", ":", "this", ".", "message", "&&", "typeof", "this", ".", "message", "===", "'object'", "&&", "this", ".", "message", "!==", "null", "&&", "this", ".", "message", ".", "nodeType", "===", "1", "&&", "typeof", "this", ".", "message", ".", "nodeName", "===", "'string'", ")", "{", "toast", ".", "appendChild", "(", "this", ".", "message", ")", ";", "// Check if it is jQuery object", "}", "else", "if", "(", "!", "!", "this", ".", "message", ".", "jquery", ")", "{", "$", "(", "toast", ")", ".", "append", "(", "this", ".", "message", "[", "0", "]", ")", ";", "// Insert as html;", "}", "else", "{", "toast", ".", "innerHTML", "=", "this", ".", "message", ";", "}", "// Append toasft", "Toast", ".", "_container", ".", "appendChild", "(", "toast", ")", ";", "return", "toast", ";", "}" ]
Create toast and append it to toast container
[ "Create", "toast", "and", "append", "it", "to", "toast", "container" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L5163-L5188
903
Dogfalo/materialize
dist/js/materialize.js
Sidenav
function Sidenav(el, options) { _classCallCheck(this, Sidenav); var _this31 = _possibleConstructorReturn(this, (Sidenav.__proto__ || Object.getPrototypeOf(Sidenav)).call(this, Sidenav, el, options)); _this31.el.M_Sidenav = _this31; _this31.id = _this31.$el.attr('id'); /** * Options for the Sidenav * @member Sidenav#options * @prop {String} [edge='left'] - Side of screen on which Sidenav appears * @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav * @prop {Number} [inDuration=250] - Length in ms of enter transition * @prop {Number} [outDuration=200] - Length in ms of exit transition * @prop {Function} onOpenStart - Function called when sidenav starts entering * @prop {Function} onOpenEnd - Function called when sidenav finishes entering * @prop {Function} onCloseStart - Function called when sidenav starts exiting * @prop {Function} onCloseEnd - Function called when sidenav finishes exiting */ _this31.options = $.extend({}, Sidenav.defaults, options); /** * Describes open/close state of Sidenav * @type {Boolean} */ _this31.isOpen = false; /** * Describes if Sidenav is fixed * @type {Boolean} */ _this31.isFixed = _this31.el.classList.contains('sidenav-fixed'); /** * Describes if Sidenav is being draggeed * @type {Boolean} */ _this31.isDragged = false; // Window size variables for window resize checks _this31.lastWindowWidth = window.innerWidth; _this31.lastWindowHeight = window.innerHeight; _this31._createOverlay(); _this31._createDragTarget(); _this31._setupEventHandlers(); _this31._setupClasses(); _this31._setupFixed(); Sidenav._sidenavs.push(_this31); return _this31; }
javascript
function Sidenav(el, options) { _classCallCheck(this, Sidenav); var _this31 = _possibleConstructorReturn(this, (Sidenav.__proto__ || Object.getPrototypeOf(Sidenav)).call(this, Sidenav, el, options)); _this31.el.M_Sidenav = _this31; _this31.id = _this31.$el.attr('id'); /** * Options for the Sidenav * @member Sidenav#options * @prop {String} [edge='left'] - Side of screen on which Sidenav appears * @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav * @prop {Number} [inDuration=250] - Length in ms of enter transition * @prop {Number} [outDuration=200] - Length in ms of exit transition * @prop {Function} onOpenStart - Function called when sidenav starts entering * @prop {Function} onOpenEnd - Function called when sidenav finishes entering * @prop {Function} onCloseStart - Function called when sidenav starts exiting * @prop {Function} onCloseEnd - Function called when sidenav finishes exiting */ _this31.options = $.extend({}, Sidenav.defaults, options); /** * Describes open/close state of Sidenav * @type {Boolean} */ _this31.isOpen = false; /** * Describes if Sidenav is fixed * @type {Boolean} */ _this31.isFixed = _this31.el.classList.contains('sidenav-fixed'); /** * Describes if Sidenav is being draggeed * @type {Boolean} */ _this31.isDragged = false; // Window size variables for window resize checks _this31.lastWindowWidth = window.innerWidth; _this31.lastWindowHeight = window.innerHeight; _this31._createOverlay(); _this31._createDragTarget(); _this31._setupEventHandlers(); _this31._setupClasses(); _this31._setupFixed(); Sidenav._sidenavs.push(_this31); return _this31; }
[ "function", "Sidenav", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "Sidenav", ")", ";", "var", "_this31", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "Sidenav", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "Sidenav", ")", ")", ".", "call", "(", "this", ",", "Sidenav", ",", "el", ",", "options", ")", ")", ";", "_this31", ".", "el", ".", "M_Sidenav", "=", "_this31", ";", "_this31", ".", "id", "=", "_this31", ".", "$el", ".", "attr", "(", "'id'", ")", ";", "/**\n * Options for the Sidenav\n * @member Sidenav#options\n * @prop {String} [edge='left'] - Side of screen on which Sidenav appears\n * @prop {Boolean} [draggable=true] - Allow swipe gestures to open/close Sidenav\n * @prop {Number} [inDuration=250] - Length in ms of enter transition\n * @prop {Number} [outDuration=200] - Length in ms of exit transition\n * @prop {Function} onOpenStart - Function called when sidenav starts entering\n * @prop {Function} onOpenEnd - Function called when sidenav finishes entering\n * @prop {Function} onCloseStart - Function called when sidenav starts exiting\n * @prop {Function} onCloseEnd - Function called when sidenav finishes exiting\n */", "_this31", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "Sidenav", ".", "defaults", ",", "options", ")", ";", "/**\n * Describes open/close state of Sidenav\n * @type {Boolean}\n */", "_this31", ".", "isOpen", "=", "false", ";", "/**\n * Describes if Sidenav is fixed\n * @type {Boolean}\n */", "_this31", ".", "isFixed", "=", "_this31", ".", "el", ".", "classList", ".", "contains", "(", "'sidenav-fixed'", ")", ";", "/**\n * Describes if Sidenav is being draggeed\n * @type {Boolean}\n */", "_this31", ".", "isDragged", "=", "false", ";", "// Window size variables for window resize checks", "_this31", ".", "lastWindowWidth", "=", "window", ".", "innerWidth", ";", "_this31", ".", "lastWindowHeight", "=", "window", ".", "innerHeight", ";", "_this31", ".", "_createOverlay", "(", ")", ";", "_this31", ".", "_createDragTarget", "(", ")", ";", "_this31", ".", "_setupEventHandlers", "(", ")", ";", "_this31", ".", "_setupClasses", "(", ")", ";", "_this31", ".", "_setupFixed", "(", ")", ";", "Sidenav", ".", "_sidenavs", ".", "push", "(", "_this31", ")", ";", "return", "_this31", ";", "}" ]
Construct Sidenav instance and set up overlay @constructor @param {Element} el @param {Object} options
[ "Construct", "Sidenav", "instance", "and", "set", "up", "overlay" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L5486-L5538
904
Dogfalo/materialize
dist/js/materialize.js
ScrollSpy
function ScrollSpy(el, options) { _classCallCheck(this, ScrollSpy); var _this35 = _possibleConstructorReturn(this, (ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy)).call(this, ScrollSpy, el, options)); _this35.el.M_ScrollSpy = _this35; /** * Options for the modal * @member Modal#options * @prop {Number} [throttle=100] - Throttle of scroll handler * @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to * @prop {String} [activeClass='active'] - Class applied to active elements * @prop {Function} [getActiveElement] - Used to find active element */ _this35.options = $.extend({}, ScrollSpy.defaults, options); // setup ScrollSpy._elements.push(_this35); ScrollSpy._count++; ScrollSpy._increment++; _this35.tickId = -1; _this35.id = ScrollSpy._increment; _this35._setupEventHandlers(); _this35._handleWindowScroll(); return _this35; }
javascript
function ScrollSpy(el, options) { _classCallCheck(this, ScrollSpy); var _this35 = _possibleConstructorReturn(this, (ScrollSpy.__proto__ || Object.getPrototypeOf(ScrollSpy)).call(this, ScrollSpy, el, options)); _this35.el.M_ScrollSpy = _this35; /** * Options for the modal * @member Modal#options * @prop {Number} [throttle=100] - Throttle of scroll handler * @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to * @prop {String} [activeClass='active'] - Class applied to active elements * @prop {Function} [getActiveElement] - Used to find active element */ _this35.options = $.extend({}, ScrollSpy.defaults, options); // setup ScrollSpy._elements.push(_this35); ScrollSpy._count++; ScrollSpy._increment++; _this35.tickId = -1; _this35.id = ScrollSpy._increment; _this35._setupEventHandlers(); _this35._handleWindowScroll(); return _this35; }
[ "function", "ScrollSpy", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "ScrollSpy", ")", ";", "var", "_this35", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "ScrollSpy", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "ScrollSpy", ")", ")", ".", "call", "(", "this", ",", "ScrollSpy", ",", "el", ",", "options", ")", ")", ";", "_this35", ".", "el", ".", "M_ScrollSpy", "=", "_this35", ";", "/**\n * Options for the modal\n * @member Modal#options\n * @prop {Number} [throttle=100] - Throttle of scroll handler\n * @prop {Number} [scrollOffset=200] - Offset for centering element when scrolled to\n * @prop {String} [activeClass='active'] - Class applied to active elements\n * @prop {Function} [getActiveElement] - Used to find active element\n */", "_this35", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "ScrollSpy", ".", "defaults", ",", "options", ")", ";", "// setup", "ScrollSpy", ".", "_elements", ".", "push", "(", "_this35", ")", ";", "ScrollSpy", ".", "_count", "++", ";", "ScrollSpy", ".", "_increment", "++", ";", "_this35", ".", "tickId", "=", "-", "1", ";", "_this35", ".", "id", "=", "ScrollSpy", ".", "_increment", ";", "_this35", ".", "_setupEventHandlers", "(", ")", ";", "_this35", ".", "_handleWindowScroll", "(", ")", ";", "return", "_this35", ";", "}" ]
Construct ScrollSpy instance @constructor @param {Element} el @param {Object} options
[ "Construct", "ScrollSpy", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L6129-L6155
905
Dogfalo/materialize
dist/js/materialize.js
Slider
function Slider(el, options) { _classCallCheck(this, Slider); var _this40 = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, Slider, el, options)); _this40.el.M_Slider = _this40; /** * Options for the modal * @member Slider#options * @prop {Boolean} [indicators=true] - Show indicators * @prop {Number} [height=400] - height of slider * @prop {Number} [duration=500] - Length in ms of slide transition * @prop {Number} [interval=6000] - Length in ms of slide interval */ _this40.options = $.extend({}, Slider.defaults, options); // setup _this40.$slider = _this40.$el.find('.slides'); _this40.$slides = _this40.$slider.children('li'); _this40.activeIndex = _this40.$slides.filter(function (item) { return $(item).hasClass('active'); }).first().index(); if (_this40.activeIndex != -1) { _this40.$active = _this40.$slides.eq(_this40.activeIndex); } _this40._setSliderHeight(); // Set initial positions of captions _this40.$slides.find('.caption').each(function (el) { _this40._animateCaptionIn(el, 0); }); // Move img src into background-image _this40.$slides.find('img').each(function (el) { var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; if ($(el).attr('src') !== placeholderBase64) { $(el).css('background-image', 'url("' + $(el).attr('src') + '")'); $(el).attr('src', placeholderBase64); } }); _this40._setupIndicators(); // Show active slide if (_this40.$active) { _this40.$active.css('display', 'block'); } else { _this40.$slides.first().addClass('active'); anim({ targets: _this40.$slides.first()[0], opacity: 1, duration: _this40.options.duration, easing: 'easeOutQuad' }); _this40.activeIndex = 0; _this40.$active = _this40.$slides.eq(_this40.activeIndex); // Update indicators if (_this40.options.indicators) { _this40.$indicators.eq(_this40.activeIndex).addClass('active'); } } // Adjust height to current slide _this40.$active.find('img').each(function (el) { anim({ targets: _this40.$active.find('.caption')[0], opacity: 1, translateX: 0, translateY: 0, duration: _this40.options.duration, easing: 'easeOutQuad' }); }); _this40._setupEventHandlers(); // auto scroll _this40.start(); return _this40; }
javascript
function Slider(el, options) { _classCallCheck(this, Slider); var _this40 = _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).call(this, Slider, el, options)); _this40.el.M_Slider = _this40; /** * Options for the modal * @member Slider#options * @prop {Boolean} [indicators=true] - Show indicators * @prop {Number} [height=400] - height of slider * @prop {Number} [duration=500] - Length in ms of slide transition * @prop {Number} [interval=6000] - Length in ms of slide interval */ _this40.options = $.extend({}, Slider.defaults, options); // setup _this40.$slider = _this40.$el.find('.slides'); _this40.$slides = _this40.$slider.children('li'); _this40.activeIndex = _this40.$slides.filter(function (item) { return $(item).hasClass('active'); }).first().index(); if (_this40.activeIndex != -1) { _this40.$active = _this40.$slides.eq(_this40.activeIndex); } _this40._setSliderHeight(); // Set initial positions of captions _this40.$slides.find('.caption').each(function (el) { _this40._animateCaptionIn(el, 0); }); // Move img src into background-image _this40.$slides.find('img').each(function (el) { var placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; if ($(el).attr('src') !== placeholderBase64) { $(el).css('background-image', 'url("' + $(el).attr('src') + '")'); $(el).attr('src', placeholderBase64); } }); _this40._setupIndicators(); // Show active slide if (_this40.$active) { _this40.$active.css('display', 'block'); } else { _this40.$slides.first().addClass('active'); anim({ targets: _this40.$slides.first()[0], opacity: 1, duration: _this40.options.duration, easing: 'easeOutQuad' }); _this40.activeIndex = 0; _this40.$active = _this40.$slides.eq(_this40.activeIndex); // Update indicators if (_this40.options.indicators) { _this40.$indicators.eq(_this40.activeIndex).addClass('active'); } } // Adjust height to current slide _this40.$active.find('img').each(function (el) { anim({ targets: _this40.$active.find('.caption')[0], opacity: 1, translateX: 0, translateY: 0, duration: _this40.options.duration, easing: 'easeOutQuad' }); }); _this40._setupEventHandlers(); // auto scroll _this40.start(); return _this40; }
[ "function", "Slider", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "Slider", ")", ";", "var", "_this40", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "Slider", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "Slider", ")", ")", ".", "call", "(", "this", ",", "Slider", ",", "el", ",", "options", ")", ")", ";", "_this40", ".", "el", ".", "M_Slider", "=", "_this40", ";", "/**\n * Options for the modal\n * @member Slider#options\n * @prop {Boolean} [indicators=true] - Show indicators\n * @prop {Number} [height=400] - height of slider\n * @prop {Number} [duration=500] - Length in ms of slide transition\n * @prop {Number} [interval=6000] - Length in ms of slide interval\n */", "_this40", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "Slider", ".", "defaults", ",", "options", ")", ";", "// setup", "_this40", ".", "$slider", "=", "_this40", ".", "$el", ".", "find", "(", "'.slides'", ")", ";", "_this40", ".", "$slides", "=", "_this40", ".", "$slider", ".", "children", "(", "'li'", ")", ";", "_this40", ".", "activeIndex", "=", "_this40", ".", "$slides", ".", "filter", "(", "function", "(", "item", ")", "{", "return", "$", "(", "item", ")", ".", "hasClass", "(", "'active'", ")", ";", "}", ")", ".", "first", "(", ")", ".", "index", "(", ")", ";", "if", "(", "_this40", ".", "activeIndex", "!=", "-", "1", ")", "{", "_this40", ".", "$active", "=", "_this40", ".", "$slides", ".", "eq", "(", "_this40", ".", "activeIndex", ")", ";", "}", "_this40", ".", "_setSliderHeight", "(", ")", ";", "// Set initial positions of captions", "_this40", ".", "$slides", ".", "find", "(", "'.caption'", ")", ".", "each", "(", "function", "(", "el", ")", "{", "_this40", ".", "_animateCaptionIn", "(", "el", ",", "0", ")", ";", "}", ")", ";", "// Move img src into background-image", "_this40", ".", "$slides", ".", "find", "(", "'img'", ")", ".", "each", "(", "function", "(", "el", ")", "{", "var", "placeholderBase64", "=", "'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='", ";", "if", "(", "$", "(", "el", ")", ".", "attr", "(", "'src'", ")", "!==", "placeholderBase64", ")", "{", "$", "(", "el", ")", ".", "css", "(", "'background-image'", ",", "'url(\"'", "+", "$", "(", "el", ")", ".", "attr", "(", "'src'", ")", "+", "'\")'", ")", ";", "$", "(", "el", ")", ".", "attr", "(", "'src'", ",", "placeholderBase64", ")", ";", "}", "}", ")", ";", "_this40", ".", "_setupIndicators", "(", ")", ";", "// Show active slide", "if", "(", "_this40", ".", "$active", ")", "{", "_this40", ".", "$active", ".", "css", "(", "'display'", ",", "'block'", ")", ";", "}", "else", "{", "_this40", ".", "$slides", ".", "first", "(", ")", ".", "addClass", "(", "'active'", ")", ";", "anim", "(", "{", "targets", ":", "_this40", ".", "$slides", ".", "first", "(", ")", "[", "0", "]", ",", "opacity", ":", "1", ",", "duration", ":", "_this40", ".", "options", ".", "duration", ",", "easing", ":", "'easeOutQuad'", "}", ")", ";", "_this40", ".", "activeIndex", "=", "0", ";", "_this40", ".", "$active", "=", "_this40", ".", "$slides", ".", "eq", "(", "_this40", ".", "activeIndex", ")", ";", "// Update indicators", "if", "(", "_this40", ".", "options", ".", "indicators", ")", "{", "_this40", ".", "$indicators", ".", "eq", "(", "_this40", ".", "activeIndex", ")", ".", "addClass", "(", "'active'", ")", ";", "}", "}", "// Adjust height to current slide", "_this40", ".", "$active", ".", "find", "(", "'img'", ")", ".", "each", "(", "function", "(", "el", ")", "{", "anim", "(", "{", "targets", ":", "_this40", ".", "$active", ".", "find", "(", "'.caption'", ")", "[", "0", "]", ",", "opacity", ":", "1", ",", "translateX", ":", "0", ",", "translateY", ":", "0", ",", "duration", ":", "_this40", ".", "options", ".", "duration", ",", "easing", ":", "'easeOutQuad'", "}", ")", ";", "}", ")", ";", "_this40", ".", "_setupEventHandlers", "(", ")", ";", "// auto scroll", "_this40", ".", "start", "(", ")", ";", "return", "_this40", ";", "}" ]
Construct Slider instance and set up overlay @constructor @param {Element} el @param {Object} options
[ "Construct", "Slider", "instance", "and", "set", "up", "overlay" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L7183-L7266
906
Dogfalo/materialize
dist/js/materialize.js
Pushpin
function Pushpin(el, options) { _classCallCheck(this, Pushpin); var _this47 = _possibleConstructorReturn(this, (Pushpin.__proto__ || Object.getPrototypeOf(Pushpin)).call(this, Pushpin, el, options)); _this47.el.M_Pushpin = _this47; /** * Options for the modal * @member Pushpin#options */ _this47.options = $.extend({}, Pushpin.defaults, options); _this47.originalOffset = _this47.el.offsetTop; Pushpin._pushpins.push(_this47); _this47._setupEventHandlers(); _this47._updatePosition(); return _this47; }
javascript
function Pushpin(el, options) { _classCallCheck(this, Pushpin); var _this47 = _possibleConstructorReturn(this, (Pushpin.__proto__ || Object.getPrototypeOf(Pushpin)).call(this, Pushpin, el, options)); _this47.el.M_Pushpin = _this47; /** * Options for the modal * @member Pushpin#options */ _this47.options = $.extend({}, Pushpin.defaults, options); _this47.originalOffset = _this47.el.offsetTop; Pushpin._pushpins.push(_this47); _this47._setupEventHandlers(); _this47._updatePosition(); return _this47; }
[ "function", "Pushpin", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "Pushpin", ")", ";", "var", "_this47", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "Pushpin", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "Pushpin", ")", ")", ".", "call", "(", "this", ",", "Pushpin", ",", "el", ",", "options", ")", ")", ";", "_this47", ".", "el", ".", "M_Pushpin", "=", "_this47", ";", "/**\n * Options for the modal\n * @member Pushpin#options\n */", "_this47", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "Pushpin", ".", "defaults", ",", "options", ")", ";", "_this47", ".", "originalOffset", "=", "_this47", ".", "el", ".", "offsetTop", ";", "Pushpin", ".", "_pushpins", ".", "push", "(", "_this47", ")", ";", "_this47", ".", "_setupEventHandlers", "(", ")", ";", "_this47", ".", "_updatePosition", "(", ")", ";", "return", "_this47", ";", "}" ]
Construct Pushpin instance @constructor @param {Element} el @param {Object} options
[ "Construct", "Pushpin", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L8185-L8203
907
Dogfalo/materialize
dist/js/materialize.js
FloatingActionButton
function FloatingActionButton(el, options) { _classCallCheck(this, FloatingActionButton); var _this48 = _possibleConstructorReturn(this, (FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton)).call(this, FloatingActionButton, el, options)); _this48.el.M_FloatingActionButton = _this48; /** * Options for the fab * @member FloatingActionButton#options * @prop {Boolean} [direction] - Direction fab menu opens * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition */ _this48.options = $.extend({}, FloatingActionButton.defaults, options); _this48.isOpen = false; _this48.$anchor = _this48.$el.children('a').first(); _this48.$menu = _this48.$el.children('ul').first(); _this48.$floatingBtns = _this48.$el.find('ul .btn-floating'); _this48.$floatingBtnsReverse = _this48.$el.find('ul .btn-floating').reverse(); _this48.offsetY = 0; _this48.offsetX = 0; _this48.$el.addClass("direction-" + _this48.options.direction); if (_this48.options.direction === 'top') { _this48.offsetY = 40; } else if (_this48.options.direction === 'right') { _this48.offsetX = -40; } else if (_this48.options.direction === 'bottom') { _this48.offsetY = -40; } else { _this48.offsetX = 40; } _this48._setupEventHandlers(); return _this48; }
javascript
function FloatingActionButton(el, options) { _classCallCheck(this, FloatingActionButton); var _this48 = _possibleConstructorReturn(this, (FloatingActionButton.__proto__ || Object.getPrototypeOf(FloatingActionButton)).call(this, FloatingActionButton, el, options)); _this48.el.M_FloatingActionButton = _this48; /** * Options for the fab * @member FloatingActionButton#options * @prop {Boolean} [direction] - Direction fab menu opens * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition */ _this48.options = $.extend({}, FloatingActionButton.defaults, options); _this48.isOpen = false; _this48.$anchor = _this48.$el.children('a').first(); _this48.$menu = _this48.$el.children('ul').first(); _this48.$floatingBtns = _this48.$el.find('ul .btn-floating'); _this48.$floatingBtnsReverse = _this48.$el.find('ul .btn-floating').reverse(); _this48.offsetY = 0; _this48.offsetX = 0; _this48.$el.addClass("direction-" + _this48.options.direction); if (_this48.options.direction === 'top') { _this48.offsetY = 40; } else if (_this48.options.direction === 'right') { _this48.offsetX = -40; } else if (_this48.options.direction === 'bottom') { _this48.offsetY = -40; } else { _this48.offsetX = 40; } _this48._setupEventHandlers(); return _this48; }
[ "function", "FloatingActionButton", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "FloatingActionButton", ")", ";", "var", "_this48", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "FloatingActionButton", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "FloatingActionButton", ")", ")", ".", "call", "(", "this", ",", "FloatingActionButton", ",", "el", ",", "options", ")", ")", ";", "_this48", ".", "el", ".", "M_FloatingActionButton", "=", "_this48", ";", "/**\n * Options for the fab\n * @member FloatingActionButton#options\n * @prop {Boolean} [direction] - Direction fab menu opens\n * @prop {Boolean} [hoverEnabled=true] - Enable hover vs click\n * @prop {Boolean} [toolbarEnabled=false] - Enable toolbar transition\n */", "_this48", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "FloatingActionButton", ".", "defaults", ",", "options", ")", ";", "_this48", ".", "isOpen", "=", "false", ";", "_this48", ".", "$anchor", "=", "_this48", ".", "$el", ".", "children", "(", "'a'", ")", ".", "first", "(", ")", ";", "_this48", ".", "$menu", "=", "_this48", ".", "$el", ".", "children", "(", "'ul'", ")", ".", "first", "(", ")", ";", "_this48", ".", "$floatingBtns", "=", "_this48", ".", "$el", ".", "find", "(", "'ul .btn-floating'", ")", ";", "_this48", ".", "$floatingBtnsReverse", "=", "_this48", ".", "$el", ".", "find", "(", "'ul .btn-floating'", ")", ".", "reverse", "(", ")", ";", "_this48", ".", "offsetY", "=", "0", ";", "_this48", ".", "offsetX", "=", "0", ";", "_this48", ".", "$el", ".", "addClass", "(", "\"direction-\"", "+", "_this48", ".", "options", ".", "direction", ")", ";", "if", "(", "_this48", ".", "options", ".", "direction", "===", "'top'", ")", "{", "_this48", ".", "offsetY", "=", "40", ";", "}", "else", "if", "(", "_this48", ".", "options", ".", "direction", "===", "'right'", ")", "{", "_this48", ".", "offsetX", "=", "-", "40", ";", "}", "else", "if", "(", "_this48", ".", "options", ".", "direction", "===", "'bottom'", ")", "{", "_this48", ".", "offsetY", "=", "-", "40", ";", "}", "else", "{", "_this48", ".", "offsetX", "=", "40", ";", "}", "_this48", ".", "_setupEventHandlers", "(", ")", ";", "return", "_this48", ";", "}" ]
Construct FloatingActionButton instance @constructor @param {Element} el @param {Object} options
[ "Construct", "FloatingActionButton", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L8352-L8388
908
Dogfalo/materialize
dist/js/materialize.js
CharacterCounter
function CharacterCounter(el, options) { _classCallCheck(this, CharacterCounter); var _this61 = _possibleConstructorReturn(this, (CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter)).call(this, CharacterCounter, el, options)); _this61.el.M_CharacterCounter = _this61; /** * Options for the character counter */ _this61.options = $.extend({}, CharacterCounter.defaults, options); _this61.isInvalid = false; _this61.isValidLength = false; _this61._setupCounter(); _this61._setupEventHandlers(); return _this61; }
javascript
function CharacterCounter(el, options) { _classCallCheck(this, CharacterCounter); var _this61 = _possibleConstructorReturn(this, (CharacterCounter.__proto__ || Object.getPrototypeOf(CharacterCounter)).call(this, CharacterCounter, el, options)); _this61.el.M_CharacterCounter = _this61; /** * Options for the character counter */ _this61.options = $.extend({}, CharacterCounter.defaults, options); _this61.isInvalid = false; _this61.isValidLength = false; _this61._setupCounter(); _this61._setupEventHandlers(); return _this61; }
[ "function", "CharacterCounter", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "CharacterCounter", ")", ";", "var", "_this61", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "CharacterCounter", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "CharacterCounter", ")", ")", ".", "call", "(", "this", ",", "CharacterCounter", ",", "el", ",", "options", ")", ")", ";", "_this61", ".", "el", ".", "M_CharacterCounter", "=", "_this61", ";", "/**\n * Options for the character counter\n */", "_this61", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "CharacterCounter", ".", "defaults", ",", "options", ")", ";", "_this61", ".", "isInvalid", "=", "false", ";", "_this61", ".", "isValidLength", "=", "false", ";", "_this61", ".", "_setupCounter", "(", ")", ";", "_this61", ".", "_setupEventHandlers", "(", ")", ";", "return", "_this61", ";", "}" ]
Construct CharacterCounter instance @constructor @param {Element} el @param {Object} options
[ "Construct", "CharacterCounter", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L10307-L10324
909
Dogfalo/materialize
dist/js/materialize.js
Carousel
function Carousel(el, options) { _classCallCheck(this, Carousel); var _this62 = _possibleConstructorReturn(this, (Carousel.__proto__ || Object.getPrototypeOf(Carousel)).call(this, Carousel, el, options)); _this62.el.M_Carousel = _this62; /** * Options for the carousel * @member Carousel#options * @prop {Number} duration * @prop {Number} dist * @prop {Number} shift * @prop {Number} padding * @prop {Number} numVisible * @prop {Boolean} fullWidth * @prop {Boolean} indicators * @prop {Boolean} noWrap * @prop {Function} onCycleTo */ _this62.options = $.extend({}, Carousel.defaults, options); // Setup _this62.hasMultipleSlides = _this62.$el.find('.carousel-item').length > 1; _this62.showIndicators = _this62.options.indicators && _this62.hasMultipleSlides; _this62.noWrap = _this62.options.noWrap || !_this62.hasMultipleSlides; _this62.pressed = false; _this62.dragged = false; _this62.offset = _this62.target = 0; _this62.images = []; _this62.itemWidth = _this62.$el.find('.carousel-item').first().innerWidth(); _this62.itemHeight = _this62.$el.find('.carousel-item').first().innerHeight(); _this62.dim = _this62.itemWidth * 2 + _this62.options.padding || 1; // Make sure dim is non zero for divisions. _this62._autoScrollBound = _this62._autoScroll.bind(_this62); _this62._trackBound = _this62._track.bind(_this62); // Full Width carousel setup if (_this62.options.fullWidth) { _this62.options.dist = 0; _this62._setCarouselHeight(); // Offset fixed items when indicators. if (_this62.showIndicators) { _this62.$el.find('.carousel-fixed-item').addClass('with-indicators'); } } // Iterate through slides _this62.$indicators = $('<ul class="indicators"></ul>'); _this62.$el.find('.carousel-item').each(function (el, i) { _this62.images.push(el); if (_this62.showIndicators) { var $indicator = $('<li class="indicator-item"></li>'); // Add active to first by default. if (i === 0) { $indicator[0].classList.add('active'); } _this62.$indicators.append($indicator); } }); if (_this62.showIndicators) { _this62.$el.append(_this62.$indicators); } _this62.count = _this62.images.length; // Cap numVisible at count _this62.options.numVisible = Math.min(_this62.count, _this62.options.numVisible); // Setup cross browser string _this62.xform = 'transform'; ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) { var e = prefix + 'Transform'; if (typeof document.body.style[e] !== 'undefined') { _this62.xform = e; return false; } return true; }); _this62._setupEventHandlers(); _this62._scroll(_this62.offset); return _this62; }
javascript
function Carousel(el, options) { _classCallCheck(this, Carousel); var _this62 = _possibleConstructorReturn(this, (Carousel.__proto__ || Object.getPrototypeOf(Carousel)).call(this, Carousel, el, options)); _this62.el.M_Carousel = _this62; /** * Options for the carousel * @member Carousel#options * @prop {Number} duration * @prop {Number} dist * @prop {Number} shift * @prop {Number} padding * @prop {Number} numVisible * @prop {Boolean} fullWidth * @prop {Boolean} indicators * @prop {Boolean} noWrap * @prop {Function} onCycleTo */ _this62.options = $.extend({}, Carousel.defaults, options); // Setup _this62.hasMultipleSlides = _this62.$el.find('.carousel-item').length > 1; _this62.showIndicators = _this62.options.indicators && _this62.hasMultipleSlides; _this62.noWrap = _this62.options.noWrap || !_this62.hasMultipleSlides; _this62.pressed = false; _this62.dragged = false; _this62.offset = _this62.target = 0; _this62.images = []; _this62.itemWidth = _this62.$el.find('.carousel-item').first().innerWidth(); _this62.itemHeight = _this62.$el.find('.carousel-item').first().innerHeight(); _this62.dim = _this62.itemWidth * 2 + _this62.options.padding || 1; // Make sure dim is non zero for divisions. _this62._autoScrollBound = _this62._autoScroll.bind(_this62); _this62._trackBound = _this62._track.bind(_this62); // Full Width carousel setup if (_this62.options.fullWidth) { _this62.options.dist = 0; _this62._setCarouselHeight(); // Offset fixed items when indicators. if (_this62.showIndicators) { _this62.$el.find('.carousel-fixed-item').addClass('with-indicators'); } } // Iterate through slides _this62.$indicators = $('<ul class="indicators"></ul>'); _this62.$el.find('.carousel-item').each(function (el, i) { _this62.images.push(el); if (_this62.showIndicators) { var $indicator = $('<li class="indicator-item"></li>'); // Add active to first by default. if (i === 0) { $indicator[0].classList.add('active'); } _this62.$indicators.append($indicator); } }); if (_this62.showIndicators) { _this62.$el.append(_this62.$indicators); } _this62.count = _this62.images.length; // Cap numVisible at count _this62.options.numVisible = Math.min(_this62.count, _this62.options.numVisible); // Setup cross browser string _this62.xform = 'transform'; ['webkit', 'Moz', 'O', 'ms'].every(function (prefix) { var e = prefix + 'Transform'; if (typeof document.body.style[e] !== 'undefined') { _this62.xform = e; return false; } return true; }); _this62._setupEventHandlers(); _this62._scroll(_this62.offset); return _this62; }
[ "function", "Carousel", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "Carousel", ")", ";", "var", "_this62", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "Carousel", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "Carousel", ")", ")", ".", "call", "(", "this", ",", "Carousel", ",", "el", ",", "options", ")", ")", ";", "_this62", ".", "el", ".", "M_Carousel", "=", "_this62", ";", "/**\n * Options for the carousel\n * @member Carousel#options\n * @prop {Number} duration\n * @prop {Number} dist\n * @prop {Number} shift\n * @prop {Number} padding\n * @prop {Number} numVisible\n * @prop {Boolean} fullWidth\n * @prop {Boolean} indicators\n * @prop {Boolean} noWrap\n * @prop {Function} onCycleTo\n */", "_this62", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "Carousel", ".", "defaults", ",", "options", ")", ";", "// Setup", "_this62", ".", "hasMultipleSlides", "=", "_this62", ".", "$el", ".", "find", "(", "'.carousel-item'", ")", ".", "length", ">", "1", ";", "_this62", ".", "showIndicators", "=", "_this62", ".", "options", ".", "indicators", "&&", "_this62", ".", "hasMultipleSlides", ";", "_this62", ".", "noWrap", "=", "_this62", ".", "options", ".", "noWrap", "||", "!", "_this62", ".", "hasMultipleSlides", ";", "_this62", ".", "pressed", "=", "false", ";", "_this62", ".", "dragged", "=", "false", ";", "_this62", ".", "offset", "=", "_this62", ".", "target", "=", "0", ";", "_this62", ".", "images", "=", "[", "]", ";", "_this62", ".", "itemWidth", "=", "_this62", ".", "$el", ".", "find", "(", "'.carousel-item'", ")", ".", "first", "(", ")", ".", "innerWidth", "(", ")", ";", "_this62", ".", "itemHeight", "=", "_this62", ".", "$el", ".", "find", "(", "'.carousel-item'", ")", ".", "first", "(", ")", ".", "innerHeight", "(", ")", ";", "_this62", ".", "dim", "=", "_this62", ".", "itemWidth", "*", "2", "+", "_this62", ".", "options", ".", "padding", "||", "1", ";", "// Make sure dim is non zero for divisions.", "_this62", ".", "_autoScrollBound", "=", "_this62", ".", "_autoScroll", ".", "bind", "(", "_this62", ")", ";", "_this62", ".", "_trackBound", "=", "_this62", ".", "_track", ".", "bind", "(", "_this62", ")", ";", "// Full Width carousel setup", "if", "(", "_this62", ".", "options", ".", "fullWidth", ")", "{", "_this62", ".", "options", ".", "dist", "=", "0", ";", "_this62", ".", "_setCarouselHeight", "(", ")", ";", "// Offset fixed items when indicators.", "if", "(", "_this62", ".", "showIndicators", ")", "{", "_this62", ".", "$el", ".", "find", "(", "'.carousel-fixed-item'", ")", ".", "addClass", "(", "'with-indicators'", ")", ";", "}", "}", "// Iterate through slides", "_this62", ".", "$indicators", "=", "$", "(", "'<ul class=\"indicators\"></ul>'", ")", ";", "_this62", ".", "$el", ".", "find", "(", "'.carousel-item'", ")", ".", "each", "(", "function", "(", "el", ",", "i", ")", "{", "_this62", ".", "images", ".", "push", "(", "el", ")", ";", "if", "(", "_this62", ".", "showIndicators", ")", "{", "var", "$indicator", "=", "$", "(", "'<li class=\"indicator-item\"></li>'", ")", ";", "// Add active to first by default.", "if", "(", "i", "===", "0", ")", "{", "$indicator", "[", "0", "]", ".", "classList", ".", "add", "(", "'active'", ")", ";", "}", "_this62", ".", "$indicators", ".", "append", "(", "$indicator", ")", ";", "}", "}", ")", ";", "if", "(", "_this62", ".", "showIndicators", ")", "{", "_this62", ".", "$el", ".", "append", "(", "_this62", ".", "$indicators", ")", ";", "}", "_this62", ".", "count", "=", "_this62", ".", "images", ".", "length", ";", "// Cap numVisible at count", "_this62", ".", "options", ".", "numVisible", "=", "Math", ".", "min", "(", "_this62", ".", "count", ",", "_this62", ".", "options", ".", "numVisible", ")", ";", "// Setup cross browser string", "_this62", ".", "xform", "=", "'transform'", ";", "[", "'webkit'", ",", "'Moz'", ",", "'O'", ",", "'ms'", "]", ".", "every", "(", "function", "(", "prefix", ")", "{", "var", "e", "=", "prefix", "+", "'Transform'", ";", "if", "(", "typeof", "document", ".", "body", ".", "style", "[", "e", "]", "!==", "'undefined'", ")", "{", "_this62", ".", "xform", "=", "e", ";", "return", "false", ";", "}", "return", "true", ";", "}", ")", ";", "_this62", ".", "_setupEventHandlers", "(", ")", ";", "_this62", ".", "_scroll", "(", "_this62", ".", "offset", ")", ";", "return", "_this62", ";", "}" ]
Construct Carousel instance @constructor @param {Element} el @param {Object} options
[ "Construct", "Carousel", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L10487-L10571
910
Dogfalo/materialize
dist/js/materialize.js
TapTarget
function TapTarget(el, options) { _classCallCheck(this, TapTarget); var _this67 = _possibleConstructorReturn(this, (TapTarget.__proto__ || Object.getPrototypeOf(TapTarget)).call(this, TapTarget, el, options)); _this67.el.M_TapTarget = _this67; /** * Options for the select * @member TapTarget#options * @prop {Function} onOpen - Callback function called when feature discovery is opened * @prop {Function} onClose - Callback function called when feature discovery is closed */ _this67.options = $.extend({}, TapTarget.defaults, options); _this67.isOpen = false; // setup _this67.$origin = $('#' + _this67.$el.attr('data-target')); _this67._setup(); _this67._calculatePositioning(); _this67._setupEventHandlers(); return _this67; }
javascript
function TapTarget(el, options) { _classCallCheck(this, TapTarget); var _this67 = _possibleConstructorReturn(this, (TapTarget.__proto__ || Object.getPrototypeOf(TapTarget)).call(this, TapTarget, el, options)); _this67.el.M_TapTarget = _this67; /** * Options for the select * @member TapTarget#options * @prop {Function} onOpen - Callback function called when feature discovery is opened * @prop {Function} onClose - Callback function called when feature discovery is closed */ _this67.options = $.extend({}, TapTarget.defaults, options); _this67.isOpen = false; // setup _this67.$origin = $('#' + _this67.$el.attr('data-target')); _this67._setup(); _this67._calculatePositioning(); _this67._setupEventHandlers(); return _this67; }
[ "function", "TapTarget", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "TapTarget", ")", ";", "var", "_this67", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "TapTarget", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "TapTarget", ")", ")", ".", "call", "(", "this", ",", "TapTarget", ",", "el", ",", "options", ")", ")", ";", "_this67", ".", "el", ".", "M_TapTarget", "=", "_this67", ";", "/**\n * Options for the select\n * @member TapTarget#options\n * @prop {Function} onOpen - Callback function called when feature discovery is opened\n * @prop {Function} onClose - Callback function called when feature discovery is closed\n */", "_this67", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "TapTarget", ".", "defaults", ",", "options", ")", ";", "_this67", ".", "isOpen", "=", "false", ";", "// setup", "_this67", ".", "$origin", "=", "$", "(", "'#'", "+", "_this67", ".", "$el", ".", "attr", "(", "'data-target'", ")", ")", ";", "_this67", ".", "_setup", "(", ")", ";", "_this67", ".", "_calculatePositioning", "(", ")", ";", "_this67", ".", "_setupEventHandlers", "(", ")", ";", "return", "_this67", ";", "}" ]
Construct TapTarget instance @constructor @param {Element} el @param {Object} options
[ "Construct", "TapTarget", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L11267-L11291
911
Dogfalo/materialize
dist/js/materialize.js
FormSelect
function FormSelect(el, options) { _classCallCheck(this, FormSelect); // Don't init if browser default version var _this68 = _possibleConstructorReturn(this, (FormSelect.__proto__ || Object.getPrototypeOf(FormSelect)).call(this, FormSelect, el, options)); if (_this68.$el.hasClass('browser-default')) { return _possibleConstructorReturn(_this68); } _this68.el.M_FormSelect = _this68; /** * Options for the select * @member FormSelect#options */ _this68.options = $.extend({}, FormSelect.defaults, options); _this68.isMultiple = _this68.$el.prop('multiple'); // Setup _this68.el.tabIndex = -1; _this68._keysSelected = {}; _this68._valueDict = {}; // Maps key to original and generated option element. _this68._setupDropdown(); _this68._setupEventHandlers(); return _this68; }
javascript
function FormSelect(el, options) { _classCallCheck(this, FormSelect); // Don't init if browser default version var _this68 = _possibleConstructorReturn(this, (FormSelect.__proto__ || Object.getPrototypeOf(FormSelect)).call(this, FormSelect, el, options)); if (_this68.$el.hasClass('browser-default')) { return _possibleConstructorReturn(_this68); } _this68.el.M_FormSelect = _this68; /** * Options for the select * @member FormSelect#options */ _this68.options = $.extend({}, FormSelect.defaults, options); _this68.isMultiple = _this68.$el.prop('multiple'); // Setup _this68.el.tabIndex = -1; _this68._keysSelected = {}; _this68._valueDict = {}; // Maps key to original and generated option element. _this68._setupDropdown(); _this68._setupEventHandlers(); return _this68; }
[ "function", "FormSelect", "(", "el", ",", "options", ")", "{", "_classCallCheck", "(", "this", ",", "FormSelect", ")", ";", "// Don't init if browser default version", "var", "_this68", "=", "_possibleConstructorReturn", "(", "this", ",", "(", "FormSelect", ".", "__proto__", "||", "Object", ".", "getPrototypeOf", "(", "FormSelect", ")", ")", ".", "call", "(", "this", ",", "FormSelect", ",", "el", ",", "options", ")", ")", ";", "if", "(", "_this68", ".", "$el", ".", "hasClass", "(", "'browser-default'", ")", ")", "{", "return", "_possibleConstructorReturn", "(", "_this68", ")", ";", "}", "_this68", ".", "el", ".", "M_FormSelect", "=", "_this68", ";", "/**\n * Options for the select\n * @member FormSelect#options\n */", "_this68", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "FormSelect", ".", "defaults", ",", "options", ")", ";", "_this68", ".", "isMultiple", "=", "_this68", ".", "$el", ".", "prop", "(", "'multiple'", ")", ";", "// Setup", "_this68", ".", "el", ".", "tabIndex", "=", "-", "1", ";", "_this68", ".", "_keysSelected", "=", "{", "}", ";", "_this68", ".", "_valueDict", "=", "{", "}", ";", "// Maps key to original and generated option element.", "_this68", ".", "_setupDropdown", "(", ")", ";", "_this68", ".", "_setupEventHandlers", "(", ")", ";", "return", "_this68", ";", "}" ]
Construct FormSelect instance @constructor @param {Element} el @param {Object} options
[ "Construct", "FormSelect", "instance" ]
1122efadad8f1433d404696f7613e3cc13fb83a4
https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L11621-L11649
912
dcloudio/mui
examples/hello-mui/js/mui.js
function(target) { parentNode = target.parentNode; if (parentNode) { if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } else { parentNode = parentNode.parentNode; if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } } } }
javascript
function(target) { parentNode = target.parentNode; if (parentNode) { if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } else { parentNode = parentNode.parentNode; if (parentNode.classList.contains(CLASS_OFF_CANVAS_WRAP)) { return parentNode; } } } }
[ "function", "(", "target", ")", "{", "parentNode", "=", "target", ".", "parentNode", ";", "if", "(", "parentNode", ")", "{", "if", "(", "parentNode", ".", "classList", ".", "contains", "(", "CLASS_OFF_CANVAS_WRAP", ")", ")", "{", "return", "parentNode", ";", "}", "else", "{", "parentNode", "=", "parentNode", ".", "parentNode", ";", "if", "(", "parentNode", ".", "classList", ".", "contains", "(", "CLASS_OFF_CANVAS_WRAP", ")", ")", "{", "return", "parentNode", ";", "}", "}", "}", "}" ]
hash to offcanvas
[ "hash", "to", "offcanvas" ]
ff74c90a1671a552f3604b1288bf38a4126312d0
https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L6002-L6014
913
MoePlayer/DPlayer
demo/modernizr.js
computedStyle
function computedStyle(elem, pseudo, prop) { var result; if ('getComputedStyle' in window) { result = getComputedStyle.call(window, elem, pseudo); var console = window.console; if (result !== null) { if (prop) { result = result.getPropertyValue(prop); } } else { if (console) { var method = console.error ? 'error' : 'log'; console[method].call(console, 'getComputedStyle returning null, its possible modernizr test results are inaccurate'); } } } else { result = !pseudo && elem.currentStyle && elem.currentStyle[prop]; } return result; }
javascript
function computedStyle(elem, pseudo, prop) { var result; if ('getComputedStyle' in window) { result = getComputedStyle.call(window, elem, pseudo); var console = window.console; if (result !== null) { if (prop) { result = result.getPropertyValue(prop); } } else { if (console) { var method = console.error ? 'error' : 'log'; console[method].call(console, 'getComputedStyle returning null, its possible modernizr test results are inaccurate'); } } } else { result = !pseudo && elem.currentStyle && elem.currentStyle[prop]; } return result; }
[ "function", "computedStyle", "(", "elem", ",", "pseudo", ",", "prop", ")", "{", "var", "result", ";", "if", "(", "'getComputedStyle'", "in", "window", ")", "{", "result", "=", "getComputedStyle", ".", "call", "(", "window", ",", "elem", ",", "pseudo", ")", ";", "var", "console", "=", "window", ".", "console", ";", "if", "(", "result", "!==", "null", ")", "{", "if", "(", "prop", ")", "{", "result", "=", "result", ".", "getPropertyValue", "(", "prop", ")", ";", "}", "}", "else", "{", "if", "(", "console", ")", "{", "var", "method", "=", "console", ".", "error", "?", "'error'", ":", "'log'", ";", "console", "[", "method", "]", ".", "call", "(", "console", ",", "'getComputedStyle returning null, its possible modernizr test results are inaccurate'", ")", ";", "}", "}", "}", "else", "{", "result", "=", "!", "pseudo", "&&", "elem", ".", "currentStyle", "&&", "elem", ".", "currentStyle", "[", "prop", "]", ";", "}", "return", "result", ";", "}" ]
wrapper around getComputedStyle, to fix issues with Firefox returning null when called inside of a hidden iframe @access private @function computedStyle @param {HTMLElement|SVGElement} - The element we want to find the computed styles of @param {string|null} [pseudoSelector]- An optional pseudo element selector (e.g. :before), of null if none @returns {CSSStyleDeclaration}
[ "wrapper", "around", "getComputedStyle", "to", "fix", "issues", "with", "Firefox", "returning", "null", "when", "called", "inside", "of", "a", "hidden", "iframe" ]
f5c53f082634a6e5af56cfc72978ad7bad49b989
https://github.com/MoePlayer/DPlayer/blob/f5c53f082634a6e5af56cfc72978ad7bad49b989/demo/modernizr.js#L817-L839
914
MoePlayer/DPlayer
demo/modernizr.js
getBody
function getBody() { // After page load injecting a fake body doesn't work so check if body exists var body = document.body; if (!body) { // Can't use the real body create a fake one. body = createElement(isSVG ? 'svg' : 'body'); body.fake = true; } return body; }
javascript
function getBody() { // After page load injecting a fake body doesn't work so check if body exists var body = document.body; if (!body) { // Can't use the real body create a fake one. body = createElement(isSVG ? 'svg' : 'body'); body.fake = true; } return body; }
[ "function", "getBody", "(", ")", "{", "// After page load injecting a fake body doesn't work so check if body exists", "var", "body", "=", "document", ".", "body", ";", "if", "(", "!", "body", ")", "{", "// Can't use the real body create a fake one.", "body", "=", "createElement", "(", "isSVG", "?", "'svg'", ":", "'body'", ")", ";", "body", ".", "fake", "=", "true", ";", "}", "return", "body", ";", "}" ]
getBody returns the body of a document, or an element that can stand in for the body if a real body does not exist @access private @function getBody @returns {HTMLElement|SVGElement} Returns the real body of a document, or an artificially created element that stands in for the body
[ "getBody", "returns", "the", "body", "of", "a", "document", "or", "an", "element", "that", "can", "stand", "in", "for", "the", "body", "if", "a", "real", "body", "does", "not", "exist" ]
f5c53f082634a6e5af56cfc72978ad7bad49b989
https://github.com/MoePlayer/DPlayer/blob/f5c53f082634a6e5af56cfc72978ad7bad49b989/demo/modernizr.js#L853-L864
915
quilljs/quill
core/quill.js
modify
function modify(modifier, source, index, shift) { if ( !this.isEnabled() && source === Emitter.sources.USER && !this.allowReadOnlyEdits ) { return new Delta(); } let range = index == null ? null : this.getSelection(); const oldDelta = this.editor.delta; const change = modifier(); if (range != null) { if (index === true) { index = range.index; // eslint-disable-line prefer-destructuring } if (shift == null) { range = shiftRange(range, change, source); } else if (shift !== 0) { range = shiftRange(range, index, shift, source); } this.setSelection(range, Emitter.sources.SILENT); } if (change.length() > 0) { const args = [Emitter.events.TEXT_CHANGE, change, oldDelta, source]; this.emitter.emit(Emitter.events.EDITOR_CHANGE, ...args); if (source !== Emitter.sources.SILENT) { this.emitter.emit(...args); } } return change; }
javascript
function modify(modifier, source, index, shift) { if ( !this.isEnabled() && source === Emitter.sources.USER && !this.allowReadOnlyEdits ) { return new Delta(); } let range = index == null ? null : this.getSelection(); const oldDelta = this.editor.delta; const change = modifier(); if (range != null) { if (index === true) { index = range.index; // eslint-disable-line prefer-destructuring } if (shift == null) { range = shiftRange(range, change, source); } else if (shift !== 0) { range = shiftRange(range, index, shift, source); } this.setSelection(range, Emitter.sources.SILENT); } if (change.length() > 0) { const args = [Emitter.events.TEXT_CHANGE, change, oldDelta, source]; this.emitter.emit(Emitter.events.EDITOR_CHANGE, ...args); if (source !== Emitter.sources.SILENT) { this.emitter.emit(...args); } } return change; }
[ "function", "modify", "(", "modifier", ",", "source", ",", "index", ",", "shift", ")", "{", "if", "(", "!", "this", ".", "isEnabled", "(", ")", "&&", "source", "===", "Emitter", ".", "sources", ".", "USER", "&&", "!", "this", ".", "allowReadOnlyEdits", ")", "{", "return", "new", "Delta", "(", ")", ";", "}", "let", "range", "=", "index", "==", "null", "?", "null", ":", "this", ".", "getSelection", "(", ")", ";", "const", "oldDelta", "=", "this", ".", "editor", ".", "delta", ";", "const", "change", "=", "modifier", "(", ")", ";", "if", "(", "range", "!=", "null", ")", "{", "if", "(", "index", "===", "true", ")", "{", "index", "=", "range", ".", "index", ";", "// eslint-disable-line prefer-destructuring", "}", "if", "(", "shift", "==", "null", ")", "{", "range", "=", "shiftRange", "(", "range", ",", "change", ",", "source", ")", ";", "}", "else", "if", "(", "shift", "!==", "0", ")", "{", "range", "=", "shiftRange", "(", "range", ",", "index", ",", "shift", ",", "source", ")", ";", "}", "this", ".", "setSelection", "(", "range", ",", "Emitter", ".", "sources", ".", "SILENT", ")", ";", "}", "if", "(", "change", ".", "length", "(", ")", ">", "0", ")", "{", "const", "args", "=", "[", "Emitter", ".", "events", ".", "TEXT_CHANGE", ",", "change", ",", "oldDelta", ",", "source", "]", ";", "this", ".", "emitter", ".", "emit", "(", "Emitter", ".", "events", ".", "EDITOR_CHANGE", ",", "...", "args", ")", ";", "if", "(", "source", "!==", "Emitter", ".", "sources", ".", "SILENT", ")", "{", "this", ".", "emitter", ".", "emit", "(", "...", "args", ")", ";", "}", "}", "return", "change", ";", "}" ]
Handle selection preservation and TEXT_CHANGE emission common to modification APIs
[ "Handle", "selection", "preservation", "and", "TEXT_CHANGE", "emission", "common", "to", "modification", "APIs" ]
8ff5b872eb5fe2fc3653a55439acb6f59b12ab2e
https://github.com/quilljs/quill/blob/8ff5b872eb5fe2fc3653a55439acb6f59b12ab2e/core/quill.js#L544-L574
916
quilljs/quill
blots/block.js
blockDelta
function blockDelta(blot, filter = true) { return blot .descendants(LeafBlot) .reduce((delta, leaf) => { if (leaf.length() === 0) { return delta; } return delta.insert(leaf.value(), bubbleFormats(leaf, {}, filter)); }, new Delta()) .insert('\n', bubbleFormats(blot)); }
javascript
function blockDelta(blot, filter = true) { return blot .descendants(LeafBlot) .reduce((delta, leaf) => { if (leaf.length() === 0) { return delta; } return delta.insert(leaf.value(), bubbleFormats(leaf, {}, filter)); }, new Delta()) .insert('\n', bubbleFormats(blot)); }
[ "function", "blockDelta", "(", "blot", ",", "filter", "=", "true", ")", "{", "return", "blot", ".", "descendants", "(", "LeafBlot", ")", ".", "reduce", "(", "(", "delta", ",", "leaf", ")", "=>", "{", "if", "(", "leaf", ".", "length", "(", ")", "===", "0", ")", "{", "return", "delta", ";", "}", "return", "delta", ".", "insert", "(", "leaf", ".", "value", "(", ")", ",", "bubbleFormats", "(", "leaf", ",", "{", "}", ",", "filter", ")", ")", ";", "}", ",", "new", "Delta", "(", ")", ")", ".", "insert", "(", "'\\n'", ",", "bubbleFormats", "(", "blot", ")", ")", ";", "}" ]
It is important for cursor behavior BlockEmbeds use tags that are block level elements
[ "It", "is", "important", "for", "cursor", "behavior", "BlockEmbeds", "use", "tags", "that", "are", "block", "level", "elements" ]
8ff5b872eb5fe2fc3653a55439acb6f59b12ab2e
https://github.com/quilljs/quill/blob/8ff5b872eb5fe2fc3653a55439acb6f59b12ab2e/blots/block.js#L168-L178
917
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/JSDOMParser.js
function (quote) { var str; var n = this.html.indexOf(quote, this.currentChar); if (n === -1) { this.currentChar = this.html.length; str = null; } else { str = this.html.substring(this.currentChar, n); this.currentChar = n + 1; } return str; }
javascript
function (quote) { var str; var n = this.html.indexOf(quote, this.currentChar); if (n === -1) { this.currentChar = this.html.length; str = null; } else { str = this.html.substring(this.currentChar, n); this.currentChar = n + 1; } return str; }
[ "function", "(", "quote", ")", "{", "var", "str", ";", "var", "n", "=", "this", ".", "html", ".", "indexOf", "(", "quote", ",", "this", ".", "currentChar", ")", ";", "if", "(", "n", "===", "-", "1", ")", "{", "this", ".", "currentChar", "=", "this", ".", "html", ".", "length", ";", "str", "=", "null", ";", "}", "else", "{", "str", "=", "this", ".", "html", ".", "substring", "(", "this", ".", "currentChar", ",", "n", ")", ";", "this", ".", "currentChar", "=", "n", "+", "1", ";", "}", "return", "str", ";", "}" ]
Called after a quote character is read. This finds the next quote character and returns the text string in between.
[ "Called", "after", "a", "quote", "character", "is", "read", ".", "This", "finds", "the", "next", "quote", "character", "and", "returns", "the", "text", "string", "in", "between", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L885-L897
918
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/JSDOMParser.js
function (retPair) { var c = this.nextChar(); // Read the Element tag name var strBuf = this.strBuf; strBuf.length = 0; while (whitespace.indexOf(c) == -1 && c !== ">" && c !== "/") { if (c === undefined) return false; strBuf.push(c); c = this.nextChar(); } var tag = strBuf.join(''); if (!tag) return false; var node = new Element(tag); // Read Element attributes while (c !== "/" && c !== ">") { if (c === undefined) return false; while (whitespace.indexOf(this.html[this.currentChar++]) != -1); this.currentChar--; c = this.nextChar(); if (c !== "/" && c !== ">") { --this.currentChar; this.readAttribute(node); } } // If this is a self-closing tag, read '/>' var closed = false; if (c === "/") { closed = true; c = this.nextChar(); if (c !== ">") { this.error("expected '>' to close " + tag); return false; } } retPair[0] = node; retPair[1] = closed; return true; }
javascript
function (retPair) { var c = this.nextChar(); // Read the Element tag name var strBuf = this.strBuf; strBuf.length = 0; while (whitespace.indexOf(c) == -1 && c !== ">" && c !== "/") { if (c === undefined) return false; strBuf.push(c); c = this.nextChar(); } var tag = strBuf.join(''); if (!tag) return false; var node = new Element(tag); // Read Element attributes while (c !== "/" && c !== ">") { if (c === undefined) return false; while (whitespace.indexOf(this.html[this.currentChar++]) != -1); this.currentChar--; c = this.nextChar(); if (c !== "/" && c !== ">") { --this.currentChar; this.readAttribute(node); } } // If this is a self-closing tag, read '/>' var closed = false; if (c === "/") { closed = true; c = this.nextChar(); if (c !== ">") { this.error("expected '>' to close " + tag); return false; } } retPair[0] = node; retPair[1] = closed; return true; }
[ "function", "(", "retPair", ")", "{", "var", "c", "=", "this", ".", "nextChar", "(", ")", ";", "// Read the Element tag name", "var", "strBuf", "=", "this", ".", "strBuf", ";", "strBuf", ".", "length", "=", "0", ";", "while", "(", "whitespace", ".", "indexOf", "(", "c", ")", "==", "-", "1", "&&", "c", "!==", "\">\"", "&&", "c", "!==", "\"/\"", ")", "{", "if", "(", "c", "===", "undefined", ")", "return", "false", ";", "strBuf", ".", "push", "(", "c", ")", ";", "c", "=", "this", ".", "nextChar", "(", ")", ";", "}", "var", "tag", "=", "strBuf", ".", "join", "(", "''", ")", ";", "if", "(", "!", "tag", ")", "return", "false", ";", "var", "node", "=", "new", "Element", "(", "tag", ")", ";", "// Read Element attributes", "while", "(", "c", "!==", "\"/\"", "&&", "c", "!==", "\">\"", ")", "{", "if", "(", "c", "===", "undefined", ")", "return", "false", ";", "while", "(", "whitespace", ".", "indexOf", "(", "this", ".", "html", "[", "this", ".", "currentChar", "++", "]", ")", "!=", "-", "1", ")", ";", "this", ".", "currentChar", "--", ";", "c", "=", "this", ".", "nextChar", "(", ")", ";", "if", "(", "c", "!==", "\"/\"", "&&", "c", "!==", "\">\"", ")", "{", "--", "this", ".", "currentChar", ";", "this", ".", "readAttribute", "(", "node", ")", ";", "}", "}", "// If this is a self-closing tag, read '/>'", "var", "closed", "=", "false", ";", "if", "(", "c", "===", "\"/\"", ")", "{", "closed", "=", "true", ";", "c", "=", "this", ".", "nextChar", "(", ")", ";", "if", "(", "c", "!==", "\">\"", ")", "{", "this", ".", "error", "(", "\"expected '>' to close \"", "+", "tag", ")", ";", "return", "false", ";", "}", "}", "retPair", "[", "0", "]", "=", "node", ";", "retPair", "[", "1", "]", "=", "closed", ";", "return", "true", ";", "}" ]
Parses and returns an Element node. This is called after a '<' has been read. @returns an array; the first index of the array is the parsed node; the second index is a boolean indicating whether this is a void Element
[ "Parses", "and", "returns", "an", "Element", "node", ".", "This", "is", "called", "after", "a", "<", "has", "been", "read", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L941-L987
919
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/JSDOMParser.js
function (str) { var strlen = str.length; if (this.html.substr(this.currentChar, strlen).toLowerCase() === str.toLowerCase()) { this.currentChar += strlen; return true; } return false; }
javascript
function (str) { var strlen = str.length; if (this.html.substr(this.currentChar, strlen).toLowerCase() === str.toLowerCase()) { this.currentChar += strlen; return true; } return false; }
[ "function", "(", "str", ")", "{", "var", "strlen", "=", "str", ".", "length", ";", "if", "(", "this", ".", "html", ".", "substr", "(", "this", ".", "currentChar", ",", "strlen", ")", ".", "toLowerCase", "(", ")", "===", "str", ".", "toLowerCase", "(", ")", ")", "{", "this", ".", "currentChar", "+=", "strlen", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
If the current input matches this string, advance the input index; otherwise, do nothing. @returns whether input matched string
[ "If", "the", "current", "input", "matches", "this", "string", "advance", "the", "input", "index", ";", "otherwise", "do", "nothing", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L995-L1002
920
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/JSDOMParser.js
function (str) { var index = this.html.indexOf(str, this.currentChar) + str.length; if (index === -1) this.currentChar = this.html.length; this.currentChar = index; }
javascript
function (str) { var index = this.html.indexOf(str, this.currentChar) + str.length; if (index === -1) this.currentChar = this.html.length; this.currentChar = index; }
[ "function", "(", "str", ")", "{", "var", "index", "=", "this", ".", "html", ".", "indexOf", "(", "str", ",", "this", ".", "currentChar", ")", "+", "str", ".", "length", ";", "if", "(", "index", "===", "-", "1", ")", "this", ".", "currentChar", "=", "this", ".", "html", ".", "length", ";", "this", ".", "currentChar", "=", "index", ";", "}" ]
Searches the input until a string is found and discards all input up to and including the matched string.
[ "Searches", "the", "input", "until", "a", "string", "is", "found", "and", "discards", "all", "input", "up", "to", "and", "including", "the", "matched", "string", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L1008-L1013
921
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/JSDOMParser.js
function () { var c = this.nextChar(); if (c === undefined) return null; // Read any text as Text node if (c !== "<") { --this.currentChar; var textNode = new Text(); var n = this.html.indexOf("<", this.currentChar); if (n === -1) { textNode.innerHTML = this.html.substring(this.currentChar, this.html.length); this.currentChar = this.html.length; } else { textNode.innerHTML = this.html.substring(this.currentChar, n); this.currentChar = n; } return textNode; } c = this.peekNext(); // Read Comment node. Normally, Comment nodes know their inner // textContent, but we don't really care about Comment nodes (we throw // them away in readChildren()). So just returning an empty Comment node // here is sufficient. if (c === "!" || c === "?") { // We're still before the ! or ? that is starting this comment: this.currentChar++; return this.discardNextComment(); } // If we're reading a closing tag, return null. This means we've reached // the end of this set of child nodes. if (c === "/") { --this.currentChar; return null; } // Otherwise, we're looking at an Element node var result = this.makeElementNode(this.retPair); if (!result) return null; var node = this.retPair[0]; var closed = this.retPair[1]; var localName = node.localName; // If this isn't a void Element, read its child nodes if (!closed) { this.readChildren(node); var closingTag = "</" + localName + ">"; if (!this.match(closingTag)) { this.error("expected '" + closingTag + "' and got " + this.html.substr(this.currentChar, closingTag.length)); return null; } } // Only use the first title, because SVG might have other // title elements which we don't care about (medium.com // does this, at least). if (localName === "title" && !this.doc.title) { this.doc.title = node.textContent.trim(); } else if (localName === "head") { this.doc.head = node; } else if (localName === "body") { this.doc.body = node; } else if (localName === "html") { this.doc.documentElement = node; } return node; }
javascript
function () { var c = this.nextChar(); if (c === undefined) return null; // Read any text as Text node if (c !== "<") { --this.currentChar; var textNode = new Text(); var n = this.html.indexOf("<", this.currentChar); if (n === -1) { textNode.innerHTML = this.html.substring(this.currentChar, this.html.length); this.currentChar = this.html.length; } else { textNode.innerHTML = this.html.substring(this.currentChar, n); this.currentChar = n; } return textNode; } c = this.peekNext(); // Read Comment node. Normally, Comment nodes know their inner // textContent, but we don't really care about Comment nodes (we throw // them away in readChildren()). So just returning an empty Comment node // here is sufficient. if (c === "!" || c === "?") { // We're still before the ! or ? that is starting this comment: this.currentChar++; return this.discardNextComment(); } // If we're reading a closing tag, return null. This means we've reached // the end of this set of child nodes. if (c === "/") { --this.currentChar; return null; } // Otherwise, we're looking at an Element node var result = this.makeElementNode(this.retPair); if (!result) return null; var node = this.retPair[0]; var closed = this.retPair[1]; var localName = node.localName; // If this isn't a void Element, read its child nodes if (!closed) { this.readChildren(node); var closingTag = "</" + localName + ">"; if (!this.match(closingTag)) { this.error("expected '" + closingTag + "' and got " + this.html.substr(this.currentChar, closingTag.length)); return null; } } // Only use the first title, because SVG might have other // title elements which we don't care about (medium.com // does this, at least). if (localName === "title" && !this.doc.title) { this.doc.title = node.textContent.trim(); } else if (localName === "head") { this.doc.head = node; } else if (localName === "body") { this.doc.body = node; } else if (localName === "html") { this.doc.documentElement = node; } return node; }
[ "function", "(", ")", "{", "var", "c", "=", "this", ".", "nextChar", "(", ")", ";", "if", "(", "c", "===", "undefined", ")", "return", "null", ";", "// Read any text as Text node", "if", "(", "c", "!==", "\"<\"", ")", "{", "--", "this", ".", "currentChar", ";", "var", "textNode", "=", "new", "Text", "(", ")", ";", "var", "n", "=", "this", ".", "html", ".", "indexOf", "(", "\"<\"", ",", "this", ".", "currentChar", ")", ";", "if", "(", "n", "===", "-", "1", ")", "{", "textNode", ".", "innerHTML", "=", "this", ".", "html", ".", "substring", "(", "this", ".", "currentChar", ",", "this", ".", "html", ".", "length", ")", ";", "this", ".", "currentChar", "=", "this", ".", "html", ".", "length", ";", "}", "else", "{", "textNode", ".", "innerHTML", "=", "this", ".", "html", ".", "substring", "(", "this", ".", "currentChar", ",", "n", ")", ";", "this", ".", "currentChar", "=", "n", ";", "}", "return", "textNode", ";", "}", "c", "=", "this", ".", "peekNext", "(", ")", ";", "// Read Comment node. Normally, Comment nodes know their inner", "// textContent, but we don't really care about Comment nodes (we throw", "// them away in readChildren()). So just returning an empty Comment node", "// here is sufficient.", "if", "(", "c", "===", "\"!\"", "||", "c", "===", "\"?\"", ")", "{", "// We're still before the ! or ? that is starting this comment:", "this", ".", "currentChar", "++", ";", "return", "this", ".", "discardNextComment", "(", ")", ";", "}", "// If we're reading a closing tag, return null. This means we've reached", "// the end of this set of child nodes.", "if", "(", "c", "===", "\"/\"", ")", "{", "--", "this", ".", "currentChar", ";", "return", "null", ";", "}", "// Otherwise, we're looking at an Element node", "var", "result", "=", "this", ".", "makeElementNode", "(", "this", ".", "retPair", ")", ";", "if", "(", "!", "result", ")", "return", "null", ";", "var", "node", "=", "this", ".", "retPair", "[", "0", "]", ";", "var", "closed", "=", "this", ".", "retPair", "[", "1", "]", ";", "var", "localName", "=", "node", ".", "localName", ";", "// If this isn't a void Element, read its child nodes", "if", "(", "!", "closed", ")", "{", "this", ".", "readChildren", "(", "node", ")", ";", "var", "closingTag", "=", "\"</\"", "+", "localName", "+", "\">\"", ";", "if", "(", "!", "this", ".", "match", "(", "closingTag", ")", ")", "{", "this", ".", "error", "(", "\"expected '\"", "+", "closingTag", "+", "\"' and got \"", "+", "this", ".", "html", ".", "substr", "(", "this", ".", "currentChar", ",", "closingTag", ".", "length", ")", ")", ";", "return", "null", ";", "}", "}", "// Only use the first title, because SVG might have other", "// title elements which we don't care about (medium.com", "// does this, at least).", "if", "(", "localName", "===", "\"title\"", "&&", "!", "this", ".", "doc", ".", "title", ")", "{", "this", ".", "doc", ".", "title", "=", "node", ".", "textContent", ".", "trim", "(", ")", ";", "}", "else", "if", "(", "localName", "===", "\"head\"", ")", "{", "this", ".", "doc", ".", "head", "=", "node", ";", "}", "else", "if", "(", "localName", "===", "\"body\"", ")", "{", "this", ".", "doc", ".", "body", "=", "node", ";", "}", "else", "if", "(", "localName", "===", "\"html\"", ")", "{", "this", ".", "doc", ".", "documentElement", "=", "node", ";", "}", "return", "node", ";", "}" ]
Reads the next child node from the input. If we're reading a closing tag, or if we've reached the end of input, return null. @returns the node
[ "Reads", "the", "next", "child", "node", "from", "the", "input", ".", "If", "we", "re", "reading", "a", "closing", "tag", "or", "if", "we", "ve", "reached", "the", "end", "of", "input", "return", "null", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L1051-L1124
922
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/JSDOMParser.js
function (html, url) { this.html = html; var doc = this.doc = new Document(url); this.readChildren(doc); // If this is an HTML document, remove root-level children except for the // <html> node if (doc.documentElement) { for (var i = doc.childNodes.length; --i >= 0;) { var child = doc.childNodes[i]; if (child !== doc.documentElement) { doc.removeChild(child); } } } return doc; }
javascript
function (html, url) { this.html = html; var doc = this.doc = new Document(url); this.readChildren(doc); // If this is an HTML document, remove root-level children except for the // <html> node if (doc.documentElement) { for (var i = doc.childNodes.length; --i >= 0;) { var child = doc.childNodes[i]; if (child !== doc.documentElement) { doc.removeChild(child); } } } return doc; }
[ "function", "(", "html", ",", "url", ")", "{", "this", ".", "html", "=", "html", ";", "var", "doc", "=", "this", ".", "doc", "=", "new", "Document", "(", "url", ")", ";", "this", ".", "readChildren", "(", "doc", ")", ";", "// If this is an HTML document, remove root-level children except for the", "// <html> node", "if", "(", "doc", ".", "documentElement", ")", "{", "for", "(", "var", "i", "=", "doc", ".", "childNodes", ".", "length", ";", "--", "i", ">=", "0", ";", ")", "{", "var", "child", "=", "doc", ".", "childNodes", "[", "i", "]", ";", "if", "(", "child", "!==", "doc", ".", "documentElement", ")", "{", "doc", ".", "removeChild", "(", "child", ")", ";", "}", "}", "}", "return", "doc", ";", "}" ]
Parses an HTML string and returns a JS implementation of the Document.
[ "Parses", "an", "HTML", "string", "and", "returns", "a", "JS", "implementation", "of", "the", "Document", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L1129-L1146
923
laurent22/joplin
ElectronClient/app/main.js
envFromArgs
function envFromArgs(args) { if (!args) return 'prod'; const envIndex = args.indexOf('--env'); const devIndex = args.indexOf('dev'); if (envIndex === devIndex - 1) return 'dev'; return 'prod'; }
javascript
function envFromArgs(args) { if (!args) return 'prod'; const envIndex = args.indexOf('--env'); const devIndex = args.indexOf('dev'); if (envIndex === devIndex - 1) return 'dev'; return 'prod'; }
[ "function", "envFromArgs", "(", "args", ")", "{", "if", "(", "!", "args", ")", "return", "'prod'", ";", "const", "envIndex", "=", "args", ".", "indexOf", "(", "'--env'", ")", ";", "const", "devIndex", "=", "args", ".", "indexOf", "(", "'dev'", ")", ";", "if", "(", "envIndex", "===", "devIndex", "-", "1", ")", "return", "'dev'", ";", "return", "'prod'", ";", "}" ]
Flags are parsed properly in BaseApplication, however it's better to have the env as early as possible to enable debugging capabilities.
[ "Flags", "are", "parsed", "properly", "in", "BaseApplication", "however", "it", "s", "better", "to", "have", "the", "env", "as", "early", "as", "possible", "to", "enable", "debugging", "capabilities", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ElectronClient/app/main.js#L19-L25
924
laurent22/joplin
ElectronClient/app/main.js
profileFromArgs
function profileFromArgs(args) { if (!args) return null; const profileIndex = args.indexOf('--profile'); if (profileIndex <= 0 || profileIndex >= args.length - 1) return null; const profileValue = args[profileIndex + 1]; return profileValue ? profileValue : null; }
javascript
function profileFromArgs(args) { if (!args) return null; const profileIndex = args.indexOf('--profile'); if (profileIndex <= 0 || profileIndex >= args.length - 1) return null; const profileValue = args[profileIndex + 1]; return profileValue ? profileValue : null; }
[ "function", "profileFromArgs", "(", "args", ")", "{", "if", "(", "!", "args", ")", "return", "null", ";", "const", "profileIndex", "=", "args", ".", "indexOf", "(", "'--profile'", ")", ";", "if", "(", "profileIndex", "<=", "0", "||", "profileIndex", ">=", "args", ".", "length", "-", "1", ")", "return", "null", ";", "const", "profileValue", "=", "args", "[", "profileIndex", "+", "1", "]", ";", "return", "profileValue", "?", "profileValue", ":", "null", ";", "}" ]
Likewise, we want to know if a profile is specified early, in particular to save the window state data.
[ "Likewise", "we", "want", "to", "know", "if", "a", "profile", "is", "specified", "early", "in", "particular", "to", "save", "the", "window", "state", "data", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ElectronClient/app/main.js#L29-L35
925
laurent22/joplin
ReactNativeClient/lib/import-enex-md-gen.js
function(lines) { let output = []; let newlineCount = 0; for (let i = 0; i < lines.length; i++) { const line = lines[i]; if (!line.trim()) { newlineCount++; } else { newlineCount = 0; } if (newlineCount >= 2) continue; output.push(line); } return output; }
javascript
function(lines) { let output = []; let newlineCount = 0; for (let i = 0; i < lines.length; i++) { const line = lines[i]; if (!line.trim()) { newlineCount++; } else { newlineCount = 0; } if (newlineCount >= 2) continue; output.push(line); } return output; }
[ "function", "(", "lines", ")", "{", "let", "output", "=", "[", "]", ";", "let", "newlineCount", "=", "0", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "lines", ".", "length", ";", "i", "++", ")", "{", "const", "line", "=", "lines", "[", "i", "]", ";", "if", "(", "!", "line", ".", "trim", "(", ")", ")", "{", "newlineCount", "++", ";", "}", "else", "{", "newlineCount", "=", "0", ";", "}", "if", "(", "newlineCount", ">=", "2", ")", "continue", ";", "output", ".", "push", "(", "line", ")", ";", "}", "return", "output", ";", "}" ]
To simplify the result, we only allow up to one empty line between blocks of text
[ "To", "simplify", "the", "result", "we", "only", "allow", "up", "to", "one", "empty", "line", "between", "blocks", "of", "text" ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ReactNativeClient/lib/import-enex-md-gen.js#L108-L124
926
laurent22/joplin
ReactNativeClient/lib/reducer.js
handleItemDelete
function handleItemDelete(state, action) { let newState = Object.assign({}, state); const map = { 'FOLDER_DELETE': ['folders', 'selectedFolderId'], 'NOTE_DELETE': ['notes', 'selectedNoteIds'], 'TAG_DELETE': ['tags', 'selectedTagId'], 'SEARCH_DELETE': ['searches', 'selectedSearchId'], }; const listKey = map[action.type][0]; const selectedItemKey = map[action.type][1]; let previousIndex = 0; let newItems = []; const items = state[listKey]; for (let i = 0; i < items.length; i++) { let item = items[i]; if (item.id == action.id) { previousIndex = i; continue; } newItems.push(item); } newState = Object.assign({}, state); newState[listKey] = newItems; if (previousIndex >= newItems.length) { previousIndex = newItems.length - 1; } const newId = previousIndex >= 0 ? newItems[previousIndex].id : null; newState[selectedItemKey] = action.type === 'NOTE_DELETE' ? [newId] : newId; if (!newId && newState.notesParentType !== 'Folder') { newState.notesParentType = 'Folder'; } return newState; }
javascript
function handleItemDelete(state, action) { let newState = Object.assign({}, state); const map = { 'FOLDER_DELETE': ['folders', 'selectedFolderId'], 'NOTE_DELETE': ['notes', 'selectedNoteIds'], 'TAG_DELETE': ['tags', 'selectedTagId'], 'SEARCH_DELETE': ['searches', 'selectedSearchId'], }; const listKey = map[action.type][0]; const selectedItemKey = map[action.type][1]; let previousIndex = 0; let newItems = []; const items = state[listKey]; for (let i = 0; i < items.length; i++) { let item = items[i]; if (item.id == action.id) { previousIndex = i; continue; } newItems.push(item); } newState = Object.assign({}, state); newState[listKey] = newItems; if (previousIndex >= newItems.length) { previousIndex = newItems.length - 1; } const newId = previousIndex >= 0 ? newItems[previousIndex].id : null; newState[selectedItemKey] = action.type === 'NOTE_DELETE' ? [newId] : newId; if (!newId && newState.notesParentType !== 'Folder') { newState.notesParentType = 'Folder'; } return newState; }
[ "function", "handleItemDelete", "(", "state", ",", "action", ")", "{", "let", "newState", "=", "Object", ".", "assign", "(", "{", "}", ",", "state", ")", ";", "const", "map", "=", "{", "'FOLDER_DELETE'", ":", "[", "'folders'", ",", "'selectedFolderId'", "]", ",", "'NOTE_DELETE'", ":", "[", "'notes'", ",", "'selectedNoteIds'", "]", ",", "'TAG_DELETE'", ":", "[", "'tags'", ",", "'selectedTagId'", "]", ",", "'SEARCH_DELETE'", ":", "[", "'searches'", ",", "'selectedSearchId'", "]", ",", "}", ";", "const", "listKey", "=", "map", "[", "action", ".", "type", "]", "[", "0", "]", ";", "const", "selectedItemKey", "=", "map", "[", "action", ".", "type", "]", "[", "1", "]", ";", "let", "previousIndex", "=", "0", ";", "let", "newItems", "=", "[", "]", ";", "const", "items", "=", "state", "[", "listKey", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", "++", ")", "{", "let", "item", "=", "items", "[", "i", "]", ";", "if", "(", "item", ".", "id", "==", "action", ".", "id", ")", "{", "previousIndex", "=", "i", ";", "continue", ";", "}", "newItems", ".", "push", "(", "item", ")", ";", "}", "newState", "=", "Object", ".", "assign", "(", "{", "}", ",", "state", ")", ";", "newState", "[", "listKey", "]", "=", "newItems", ";", "if", "(", "previousIndex", ">=", "newItems", ".", "length", ")", "{", "previousIndex", "=", "newItems", ".", "length", "-", "1", ";", "}", "const", "newId", "=", "previousIndex", ">=", "0", "?", "newItems", "[", "previousIndex", "]", ".", "id", ":", "null", ";", "newState", "[", "selectedItemKey", "]", "=", "action", ".", "type", "===", "'NOTE_DELETE'", "?", "[", "newId", "]", ":", "newId", ";", "if", "(", "!", "newId", "&&", "newState", ".", "notesParentType", "!==", "'Folder'", ")", "{", "newState", ".", "notesParentType", "=", "'Folder'", ";", "}", "return", "newState", ";", "}" ]
When deleting a note, tag or folder
[ "When", "deleting", "a", "note", "tag", "or", "folder" ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ReactNativeClient/lib/reducer.js#L119-L159
927
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(nodeList, filterFn) { for (var i = nodeList.length - 1; i >= 0; i--) { var node = nodeList[i]; var parentNode = node.parentNode; if (parentNode) { if (!filterFn || filterFn.call(this, node, i, nodeList)) { parentNode.removeChild(node); } } } }
javascript
function(nodeList, filterFn) { for (var i = nodeList.length - 1; i >= 0; i--) { var node = nodeList[i]; var parentNode = node.parentNode; if (parentNode) { if (!filterFn || filterFn.call(this, node, i, nodeList)) { parentNode.removeChild(node); } } } }
[ "function", "(", "nodeList", ",", "filterFn", ")", "{", "for", "(", "var", "i", "=", "nodeList", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "var", "node", "=", "nodeList", "[", "i", "]", ";", "var", "parentNode", "=", "node", ".", "parentNode", ";", "if", "(", "parentNode", ")", "{", "if", "(", "!", "filterFn", "||", "filterFn", ".", "call", "(", "this", ",", "node", ",", "i", ",", "nodeList", ")", ")", "{", "parentNode", ".", "removeChild", "(", "node", ")", ";", "}", "}", "}", "}" ]
Iterates over a NodeList, calls `filterFn` for each node and removes node if function returned `true`. If function is not passed, removes all the nodes in node list. @param NodeList nodeList The nodes to operate on @param Function filterFn the function to use as a filter @return void
[ "Iterates", "over", "a", "NodeList", "calls", "filterFn", "for", "each", "node", "and", "removes", "node", "if", "function", "returned", "true", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L175-L185
928
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(nodeList, newTagName) { for (var i = nodeList.length - 1; i >= 0; i--) { var node = nodeList[i]; this._setNodeTag(node, newTagName); } }
javascript
function(nodeList, newTagName) { for (var i = nodeList.length - 1; i >= 0; i--) { var node = nodeList[i]; this._setNodeTag(node, newTagName); } }
[ "function", "(", "nodeList", ",", "newTagName", ")", "{", "for", "(", "var", "i", "=", "nodeList", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "var", "node", "=", "nodeList", "[", "i", "]", ";", "this", ".", "_setNodeTag", "(", "node", ",", "newTagName", ")", ";", "}", "}" ]
Iterates over a NodeList, and calls _setNodeTag for each node. @param NodeList nodeList The nodes to operate on @param String newTagName the new tag name to use @return void
[ "Iterates", "over", "a", "NodeList", "and", "calls", "_setNodeTag", "for", "each", "node", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L194-L199
929
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function() { var slice = Array.prototype.slice; var args = slice.call(arguments); var nodeLists = args.map(function(list) { return slice.call(list); }); return Array.prototype.concat.apply([], nodeLists); }
javascript
function() { var slice = Array.prototype.slice; var args = slice.call(arguments); var nodeLists = args.map(function(list) { return slice.call(list); }); return Array.prototype.concat.apply([], nodeLists); }
[ "function", "(", ")", "{", "var", "slice", "=", "Array", ".", "prototype", ".", "slice", ";", "var", "args", "=", "slice", ".", "call", "(", "arguments", ")", ";", "var", "nodeLists", "=", "args", ".", "map", "(", "function", "(", "list", ")", "{", "return", "slice", ".", "call", "(", "list", ")", ";", "}", ")", ";", "return", "Array", ".", "prototype", ".", "concat", ".", "apply", "(", "[", "]", ",", "nodeLists", ")", ";", "}" ]
Concat all nodelists passed as arguments. @return ...NodeList @return Array
[ "Concat", "all", "nodelists", "passed", "as", "arguments", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L252-L259
930
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(node) { var classesToPreserve = this._classesToPreserve; var className = (node.getAttribute("class") || "") .split(/\s+/) .filter(function(cls) { return classesToPreserve.indexOf(cls) != -1; }) .join(" "); if (className) { node.setAttribute("class", className); } else { node.removeAttribute("class"); } for (node = node.firstElementChild; node; node = node.nextElementSibling) { this._cleanClasses(node); } }
javascript
function(node) { var classesToPreserve = this._classesToPreserve; var className = (node.getAttribute("class") || "") .split(/\s+/) .filter(function(cls) { return classesToPreserve.indexOf(cls) != -1; }) .join(" "); if (className) { node.setAttribute("class", className); } else { node.removeAttribute("class"); } for (node = node.firstElementChild; node; node = node.nextElementSibling) { this._cleanClasses(node); } }
[ "function", "(", "node", ")", "{", "var", "classesToPreserve", "=", "this", ".", "_classesToPreserve", ";", "var", "className", "=", "(", "node", ".", "getAttribute", "(", "\"class\"", ")", "||", "\"\"", ")", ".", "split", "(", "/", "\\s+", "/", ")", ".", "filter", "(", "function", "(", "cls", ")", "{", "return", "classesToPreserve", ".", "indexOf", "(", "cls", ")", "!=", "-", "1", ";", "}", ")", ".", "join", "(", "\" \"", ")", ";", "if", "(", "className", ")", "{", "node", ".", "setAttribute", "(", "\"class\"", ",", "className", ")", ";", "}", "else", "{", "node", ".", "removeAttribute", "(", "\"class\"", ")", ";", "}", "for", "(", "node", "=", "node", ".", "firstElementChild", ";", "node", ";", "node", "=", "node", ".", "nextElementSibling", ")", "{", "this", ".", "_cleanClasses", "(", "node", ")", ";", "}", "}" ]
Removes the class="" attribute from every element in the given subtree, except those that match CLASSES_TO_PRESERVE and the classesToPreserve array from the options object. @param Element @return void
[ "Removes", "the", "class", "=", "attribute", "from", "every", "element", "in", "the", "given", "subtree", "except", "those", "that", "match", "CLASSES_TO_PRESERVE", "and", "the", "classesToPreserve", "array", "from", "the", "options", "object", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L279-L297
931
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function() { var doc = this._doc; // Remove all style tags in head this._removeNodes(doc.getElementsByTagName("style")); if (doc.body) { this._replaceBrs(doc.body); } this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN"); }
javascript
function() { var doc = this._doc; // Remove all style tags in head this._removeNodes(doc.getElementsByTagName("style")); if (doc.body) { this._replaceBrs(doc.body); } this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN"); }
[ "function", "(", ")", "{", "var", "doc", "=", "this", ".", "_doc", ";", "// Remove all style tags in head", "this", ".", "_removeNodes", "(", "doc", ".", "getElementsByTagName", "(", "\"style\"", ")", ")", ";", "if", "(", "doc", ".", "body", ")", "{", "this", ".", "_replaceBrs", "(", "doc", ".", "body", ")", ";", "}", "this", ".", "_replaceNodeTags", "(", "doc", ".", "getElementsByTagName", "(", "\"font\"", ")", ",", "\"SPAN\"", ")", ";", "}" ]
Prepare the HTML document for readability to scrape it. This includes things like stripping javascript, CSS, and handling terrible markup. @return void
[ "Prepare", "the", "HTML", "document", "for", "readability", "to", "scrape", "it", ".", "This", "includes", "things", "like", "stripping", "javascript", "CSS", "and", "handling", "terrible", "markup", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L431-L442
932
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function (node) { var next = node; while (next && (next.nodeType != this.ELEMENT_NODE) && this.REGEXPS.whitespace.test(next.textContent)) { next = next.nextSibling; } return next; }
javascript
function (node) { var next = node; while (next && (next.nodeType != this.ELEMENT_NODE) && this.REGEXPS.whitespace.test(next.textContent)) { next = next.nextSibling; } return next; }
[ "function", "(", "node", ")", "{", "var", "next", "=", "node", ";", "while", "(", "next", "&&", "(", "next", ".", "nodeType", "!=", "this", ".", "ELEMENT_NODE", ")", "&&", "this", ".", "REGEXPS", ".", "whitespace", ".", "test", "(", "next", ".", "textContent", ")", ")", "{", "next", "=", "next", ".", "nextSibling", ";", "}", "return", "next", ";", "}" ]
Finds the next element, starting from the given node, and ignoring whitespace in between. If the given node is an element, the same node is returned.
[ "Finds", "the", "next", "element", "starting", "from", "the", "given", "node", "and", "ignoring", "whitespace", "in", "between", ".", "If", "the", "given", "node", "is", "an", "element", "the", "same", "node", "is", "returned", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L449-L457
933
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(byline) { if (typeof byline == 'string' || byline instanceof String) { byline = byline.trim(); return (byline.length > 0) && (byline.length < 100); } return false; }
javascript
function(byline) { if (typeof byline == 'string' || byline instanceof String) { byline = byline.trim(); return (byline.length > 0) && (byline.length < 100); } return false; }
[ "function", "(", "byline", ")", "{", "if", "(", "typeof", "byline", "==", "'string'", "||", "byline", "instanceof", "String", ")", "{", "byline", "=", "byline", ".", "trim", "(", ")", ";", "return", "(", "byline", ".", "length", ">", "0", ")", "&&", "(", "byline", ".", "length", "<", "100", ")", ";", "}", "return", "false", ";", "}" ]
Check whether the input string could be a byline. This verifies that the input is a string, and that the length is less than 100 chars. @param possibleByline {string} - a string to check whether its a byline. @return Boolean - whether the input string is a byline.
[ "Check", "whether", "the", "input", "string", "could", "be", "a", "byline", ".", "This", "verifies", "that", "the", "input", "is", "a", "string", "and", "that", "the", "length", "is", "less", "than", "100", "chars", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1186-L1192
934
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function() { var metadata = {}; var values = {}; var metaElements = this._doc.getElementsByTagName("meta"); // Match "description", or Twitter's "twitter:description" (Cards) // in name attribute. var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/gi; // Match Facebook's Open Graph title & description properties. var propertyPattern = /^\s*og\s*:\s*(description|title)\s*$/gi; // Find description tags. this._forEachNode(metaElements, function(element) { var elementName = element.getAttribute("name"); var elementProperty = element.getAttribute("property"); if ([elementName, elementProperty].indexOf("author") !== -1) { metadata.byline = element.getAttribute("content"); return; } var name = null; if (namePattern.test(elementName)) { name = elementName; } else if (propertyPattern.test(elementProperty)) { name = elementProperty; } if (name) { var content = element.getAttribute("content"); if (content) { // Convert to lowercase and remove any whitespace // so we can match below. name = name.toLowerCase().replace(/\s/g, ''); values[name] = content.trim(); } } }); if ("description" in values) { metadata.excerpt = values["description"]; } else if ("og:description" in values) { // Use facebook open graph description. metadata.excerpt = values["og:description"]; } else if ("twitter:description" in values) { // Use twitter cards description. metadata.excerpt = values["twitter:description"]; } metadata.title = this._getArticleTitle(); if (!metadata.title) { if ("og:title" in values) { // Use facebook open graph title. metadata.title = values["og:title"]; } else if ("twitter:title" in values) { // Use twitter cards title. metadata.title = values["twitter:title"]; } } return metadata; }
javascript
function() { var metadata = {}; var values = {}; var metaElements = this._doc.getElementsByTagName("meta"); // Match "description", or Twitter's "twitter:description" (Cards) // in name attribute. var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/gi; // Match Facebook's Open Graph title & description properties. var propertyPattern = /^\s*og\s*:\s*(description|title)\s*$/gi; // Find description tags. this._forEachNode(metaElements, function(element) { var elementName = element.getAttribute("name"); var elementProperty = element.getAttribute("property"); if ([elementName, elementProperty].indexOf("author") !== -1) { metadata.byline = element.getAttribute("content"); return; } var name = null; if (namePattern.test(elementName)) { name = elementName; } else if (propertyPattern.test(elementProperty)) { name = elementProperty; } if (name) { var content = element.getAttribute("content"); if (content) { // Convert to lowercase and remove any whitespace // so we can match below. name = name.toLowerCase().replace(/\s/g, ''); values[name] = content.trim(); } } }); if ("description" in values) { metadata.excerpt = values["description"]; } else if ("og:description" in values) { // Use facebook open graph description. metadata.excerpt = values["og:description"]; } else if ("twitter:description" in values) { // Use twitter cards description. metadata.excerpt = values["twitter:description"]; } metadata.title = this._getArticleTitle(); if (!metadata.title) { if ("og:title" in values) { // Use facebook open graph title. metadata.title = values["og:title"]; } else if ("twitter:title" in values) { // Use twitter cards title. metadata.title = values["twitter:title"]; } } return metadata; }
[ "function", "(", ")", "{", "var", "metadata", "=", "{", "}", ";", "var", "values", "=", "{", "}", ";", "var", "metaElements", "=", "this", ".", "_doc", ".", "getElementsByTagName", "(", "\"meta\"", ")", ";", "// Match \"description\", or Twitter's \"twitter:description\" (Cards)", "// in name attribute.", "var", "namePattern", "=", "/", "^\\s*((twitter)\\s*:\\s*)?(description|title)\\s*$", "/", "gi", ";", "// Match Facebook's Open Graph title & description properties.", "var", "propertyPattern", "=", "/", "^\\s*og\\s*:\\s*(description|title)\\s*$", "/", "gi", ";", "// Find description tags.", "this", ".", "_forEachNode", "(", "metaElements", ",", "function", "(", "element", ")", "{", "var", "elementName", "=", "element", ".", "getAttribute", "(", "\"name\"", ")", ";", "var", "elementProperty", "=", "element", ".", "getAttribute", "(", "\"property\"", ")", ";", "if", "(", "[", "elementName", ",", "elementProperty", "]", ".", "indexOf", "(", "\"author\"", ")", "!==", "-", "1", ")", "{", "metadata", ".", "byline", "=", "element", ".", "getAttribute", "(", "\"content\"", ")", ";", "return", ";", "}", "var", "name", "=", "null", ";", "if", "(", "namePattern", ".", "test", "(", "elementName", ")", ")", "{", "name", "=", "elementName", ";", "}", "else", "if", "(", "propertyPattern", ".", "test", "(", "elementProperty", ")", ")", "{", "name", "=", "elementProperty", ";", "}", "if", "(", "name", ")", "{", "var", "content", "=", "element", ".", "getAttribute", "(", "\"content\"", ")", ";", "if", "(", "content", ")", "{", "// Convert to lowercase and remove any whitespace", "// so we can match below.", "name", "=", "name", ".", "toLowerCase", "(", ")", ".", "replace", "(", "/", "\\s", "/", "g", ",", "''", ")", ";", "values", "[", "name", "]", "=", "content", ".", "trim", "(", ")", ";", "}", "}", "}", ")", ";", "if", "(", "\"description\"", "in", "values", ")", "{", "metadata", ".", "excerpt", "=", "values", "[", "\"description\"", "]", ";", "}", "else", "if", "(", "\"og:description\"", "in", "values", ")", "{", "// Use facebook open graph description.", "metadata", ".", "excerpt", "=", "values", "[", "\"og:description\"", "]", ";", "}", "else", "if", "(", "\"twitter:description\"", "in", "values", ")", "{", "// Use twitter cards description.", "metadata", ".", "excerpt", "=", "values", "[", "\"twitter:description\"", "]", ";", "}", "metadata", ".", "title", "=", "this", ".", "_getArticleTitle", "(", ")", ";", "if", "(", "!", "metadata", ".", "title", ")", "{", "if", "(", "\"og:title\"", "in", "values", ")", "{", "// Use facebook open graph title.", "metadata", ".", "title", "=", "values", "[", "\"og:title\"", "]", ";", "}", "else", "if", "(", "\"twitter:title\"", "in", "values", ")", "{", "// Use twitter cards title.", "metadata", ".", "title", "=", "values", "[", "\"twitter:title\"", "]", ";", "}", "}", "return", "metadata", ";", "}" ]
Attempts to get excerpt and byline metadata for the article. @return Object with optional "excerpt" and "byline" properties
[ "Attempts", "to", "get", "excerpt", "and", "byline", "metadata", "for", "the", "article", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1199-L1261
935
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(doc) { this._removeNodes(doc.getElementsByTagName('script'), function(scriptNode) { scriptNode.nodeValue = ""; scriptNode.removeAttribute('src'); return true; }); this._removeNodes(doc.getElementsByTagName('noscript')); }
javascript
function(doc) { this._removeNodes(doc.getElementsByTagName('script'), function(scriptNode) { scriptNode.nodeValue = ""; scriptNode.removeAttribute('src'); return true; }); this._removeNodes(doc.getElementsByTagName('noscript')); }
[ "function", "(", "doc", ")", "{", "this", ".", "_removeNodes", "(", "doc", ".", "getElementsByTagName", "(", "'script'", ")", ",", "function", "(", "scriptNode", ")", "{", "scriptNode", ".", "nodeValue", "=", "\"\"", ";", "scriptNode", ".", "removeAttribute", "(", "'src'", ")", ";", "return", "true", ";", "}", ")", ";", "this", ".", "_removeNodes", "(", "doc", ".", "getElementsByTagName", "(", "'noscript'", ")", ")", ";", "}" ]
Removes script tags from the document. @param Element
[ "Removes", "script", "tags", "from", "the", "document", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1268-L1275
936
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(element) { // There should be exactly 1 element child which is a P: if (element.children.length != 1 || element.children[0].tagName !== "P") { return false; } // And there should be no text nodes with real content return !this._someNode(element.childNodes, function(node) { return node.nodeType === this.TEXT_NODE && this.REGEXPS.hasContent.test(node.textContent); }); }
javascript
function(element) { // There should be exactly 1 element child which is a P: if (element.children.length != 1 || element.children[0].tagName !== "P") { return false; } // And there should be no text nodes with real content return !this._someNode(element.childNodes, function(node) { return node.nodeType === this.TEXT_NODE && this.REGEXPS.hasContent.test(node.textContent); }); }
[ "function", "(", "element", ")", "{", "// There should be exactly 1 element child which is a P:", "if", "(", "element", ".", "children", ".", "length", "!=", "1", "||", "element", ".", "children", "[", "0", "]", ".", "tagName", "!==", "\"P\"", ")", "{", "return", "false", ";", "}", "// And there should be no text nodes with real content", "return", "!", "this", ".", "_someNode", "(", "element", ".", "childNodes", ",", "function", "(", "node", ")", "{", "return", "node", ".", "nodeType", "===", "this", ".", "TEXT_NODE", "&&", "this", ".", "REGEXPS", ".", "hasContent", ".", "test", "(", "node", ".", "textContent", ")", ";", "}", ")", ";", "}" ]
Check if this node has only whitespace and a single P element Returns false if the DIV node contains non-empty text nodes or if it contains no P or more than 1 element. @param Element
[ "Check", "if", "this", "node", "has", "only", "whitespace", "and", "a", "single", "P", "element", "Returns", "false", "if", "the", "DIV", "node", "contains", "non", "-", "empty", "text", "nodes", "or", "if", "it", "contains", "no", "P", "or", "more", "than", "1", "element", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1284-L1295
937
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function (element) { return this._someNode(element.childNodes, function(node) { return this.DIV_TO_P_ELEMS.indexOf(node.tagName) !== -1 || this._hasChildBlockElement(node); }); }
javascript
function (element) { return this._someNode(element.childNodes, function(node) { return this.DIV_TO_P_ELEMS.indexOf(node.tagName) !== -1 || this._hasChildBlockElement(node); }); }
[ "function", "(", "element", ")", "{", "return", "this", ".", "_someNode", "(", "element", ".", "childNodes", ",", "function", "(", "node", ")", "{", "return", "this", ".", "DIV_TO_P_ELEMS", ".", "indexOf", "(", "node", ".", "tagName", ")", "!==", "-", "1", "||", "this", ".", "_hasChildBlockElement", "(", "node", ")", ";", "}", ")", ";", "}" ]
Determine whether element has any children block level elements. @param Element
[ "Determine", "whether", "element", "has", "any", "children", "block", "level", "elements", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1309-L1314
938
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(e, normalizeSpaces) { normalizeSpaces = (typeof normalizeSpaces === 'undefined') ? true : normalizeSpaces; var textContent = e.textContent.trim(); if (normalizeSpaces) { return textContent.replace(this.REGEXPS.normalize, " "); } return textContent; }
javascript
function(e, normalizeSpaces) { normalizeSpaces = (typeof normalizeSpaces === 'undefined') ? true : normalizeSpaces; var textContent = e.textContent.trim(); if (normalizeSpaces) { return textContent.replace(this.REGEXPS.normalize, " "); } return textContent; }
[ "function", "(", "e", ",", "normalizeSpaces", ")", "{", "normalizeSpaces", "=", "(", "typeof", "normalizeSpaces", "===", "'undefined'", ")", "?", "true", ":", "normalizeSpaces", ";", "var", "textContent", "=", "e", ".", "textContent", ".", "trim", "(", ")", ";", "if", "(", "normalizeSpaces", ")", "{", "return", "textContent", ".", "replace", "(", "this", ".", "REGEXPS", ".", "normalize", ",", "\" \"", ")", ";", "}", "return", "textContent", ";", "}" ]
Get the inner text of a node - cross browser compatibly. This also strips out any excess whitespace to be found. @param Element @param Boolean normalizeSpaces (default: true) @return string
[ "Get", "the", "inner", "text", "of", "a", "node", "-", "cross", "browser", "compatibly", ".", "This", "also", "strips", "out", "any", "excess", "whitespace", "to", "be", "found", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1339-L1347
939
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(node, tagName, maxDepth, filterFn) { maxDepth = maxDepth || 3; tagName = tagName.toUpperCase(); var depth = 0; while (node.parentNode) { if (maxDepth > 0 && depth > maxDepth) return false; if (node.parentNode.tagName === tagName && (!filterFn || filterFn(node.parentNode))) return true; node = node.parentNode; depth++; } return false; }
javascript
function(node, tagName, maxDepth, filterFn) { maxDepth = maxDepth || 3; tagName = tagName.toUpperCase(); var depth = 0; while (node.parentNode) { if (maxDepth > 0 && depth > maxDepth) return false; if (node.parentNode.tagName === tagName && (!filterFn || filterFn(node.parentNode))) return true; node = node.parentNode; depth++; } return false; }
[ "function", "(", "node", ",", "tagName", ",", "maxDepth", ",", "filterFn", ")", "{", "maxDepth", "=", "maxDepth", "||", "3", ";", "tagName", "=", "tagName", ".", "toUpperCase", "(", ")", ";", "var", "depth", "=", "0", ";", "while", "(", "node", ".", "parentNode", ")", "{", "if", "(", "maxDepth", ">", "0", "&&", "depth", ">", "maxDepth", ")", "return", "false", ";", "if", "(", "node", ".", "parentNode", ".", "tagName", "===", "tagName", "&&", "(", "!", "filterFn", "||", "filterFn", "(", "node", ".", "parentNode", ")", ")", ")", "return", "true", ";", "node", "=", "node", ".", "parentNode", ";", "depth", "++", ";", "}", "return", "false", ";", "}" ]
Check if a given node has one of its ancestor tag name matching the provided one. @param HTMLElement node @param String tagName @param Number maxDepth @param Function filterFn a filter to invoke to determine whether this node 'counts' @return Boolean
[ "Check", "if", "a", "given", "node", "has", "one", "of", "its", "ancestor", "tag", "name", "matching", "the", "provided", "one", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1485-L1498
940
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(table) { var rows = 0; var columns = 0; var trs = table.getElementsByTagName("tr"); for (var i = 0; i < trs.length; i++) { var rowspan = trs[i].getAttribute("rowspan") || 0; if (rowspan) { rowspan = parseInt(rowspan, 10); } rows += (rowspan || 1); // Now look for column-related info var columnsInThisRow = 0; var cells = trs[i].getElementsByTagName("td"); for (var j = 0; j < cells.length; j++) { var colspan = cells[j].getAttribute("colspan") || 0; if (colspan) { colspan = parseInt(colspan, 10); } columnsInThisRow += (colspan || 1); } columns = Math.max(columns, columnsInThisRow); } return {rows: rows, columns: columns}; }
javascript
function(table) { var rows = 0; var columns = 0; var trs = table.getElementsByTagName("tr"); for (var i = 0; i < trs.length; i++) { var rowspan = trs[i].getAttribute("rowspan") || 0; if (rowspan) { rowspan = parseInt(rowspan, 10); } rows += (rowspan || 1); // Now look for column-related info var columnsInThisRow = 0; var cells = trs[i].getElementsByTagName("td"); for (var j = 0; j < cells.length; j++) { var colspan = cells[j].getAttribute("colspan") || 0; if (colspan) { colspan = parseInt(colspan, 10); } columnsInThisRow += (colspan || 1); } columns = Math.max(columns, columnsInThisRow); } return {rows: rows, columns: columns}; }
[ "function", "(", "table", ")", "{", "var", "rows", "=", "0", ";", "var", "columns", "=", "0", ";", "var", "trs", "=", "table", ".", "getElementsByTagName", "(", "\"tr\"", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "trs", ".", "length", ";", "i", "++", ")", "{", "var", "rowspan", "=", "trs", "[", "i", "]", ".", "getAttribute", "(", "\"rowspan\"", ")", "||", "0", ";", "if", "(", "rowspan", ")", "{", "rowspan", "=", "parseInt", "(", "rowspan", ",", "10", ")", ";", "}", "rows", "+=", "(", "rowspan", "||", "1", ")", ";", "// Now look for column-related info", "var", "columnsInThisRow", "=", "0", ";", "var", "cells", "=", "trs", "[", "i", "]", ".", "getElementsByTagName", "(", "\"td\"", ")", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "cells", ".", "length", ";", "j", "++", ")", "{", "var", "colspan", "=", "cells", "[", "j", "]", ".", "getAttribute", "(", "\"colspan\"", ")", "||", "0", ";", "if", "(", "colspan", ")", "{", "colspan", "=", "parseInt", "(", "colspan", ",", "10", ")", ";", "}", "columnsInThisRow", "+=", "(", "colspan", "||", "1", ")", ";", "}", "columns", "=", "Math", ".", "max", "(", "columns", ",", "columnsInThisRow", ")", ";", "}", "return", "{", "rows", ":", "rows", ",", "columns", ":", "columns", "}", ";", "}" ]
Return an object indicating how many rows and columns this table has.
[ "Return", "an", "object", "indicating", "how", "many", "rows", "and", "columns", "this", "table", "has", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1503-L1527
941
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function(helperIsVisible) { var nodes = this._getAllNodesWithTag(this._doc, ["p", "pre"]); // Get <div> nodes which have <br> node(s) and append them into the `nodes` variable. // Some articles' DOM structures might look like // <div> // Sentences<br> // <br> // Sentences<br> // </div> var brNodes = this._getAllNodesWithTag(this._doc, ["div > br"]); if (brNodes.length) { var set = new Set(); [].forEach.call(brNodes, function(node) { set.add(node.parentNode); }); nodes = [].concat.apply(Array.from(set), nodes); } // FIXME we should have a fallback for helperIsVisible, but this is // problematic because of jsdom's elem.style handling - see // https://github.com/mozilla/readability/pull/186 for context. var score = 0; // This is a little cheeky, we use the accumulator 'score' to decide what to return from // this callback: return this._someNode(nodes, function(node) { if (helperIsVisible && !helperIsVisible(node)) return false; var matchString = node.className + " " + node.id; if (this.REGEXPS.unlikelyCandidates.test(matchString) && !this.REGEXPS.okMaybeItsACandidate.test(matchString)) { return false; } if (node.matches && node.matches("li p")) { return false; } var textContentLength = node.textContent.trim().length; if (textContentLength < 140) { return false; } score += Math.sqrt(textContentLength - 140); if (score > 20) { return true; } return false; }); }
javascript
function(helperIsVisible) { var nodes = this._getAllNodesWithTag(this._doc, ["p", "pre"]); // Get <div> nodes which have <br> node(s) and append them into the `nodes` variable. // Some articles' DOM structures might look like // <div> // Sentences<br> // <br> // Sentences<br> // </div> var brNodes = this._getAllNodesWithTag(this._doc, ["div > br"]); if (brNodes.length) { var set = new Set(); [].forEach.call(brNodes, function(node) { set.add(node.parentNode); }); nodes = [].concat.apply(Array.from(set), nodes); } // FIXME we should have a fallback for helperIsVisible, but this is // problematic because of jsdom's elem.style handling - see // https://github.com/mozilla/readability/pull/186 for context. var score = 0; // This is a little cheeky, we use the accumulator 'score' to decide what to return from // this callback: return this._someNode(nodes, function(node) { if (helperIsVisible && !helperIsVisible(node)) return false; var matchString = node.className + " " + node.id; if (this.REGEXPS.unlikelyCandidates.test(matchString) && !this.REGEXPS.okMaybeItsACandidate.test(matchString)) { return false; } if (node.matches && node.matches("li p")) { return false; } var textContentLength = node.textContent.trim().length; if (textContentLength < 140) { return false; } score += Math.sqrt(textContentLength - 140); if (score > 20) { return true; } return false; }); }
[ "function", "(", "helperIsVisible", ")", "{", "var", "nodes", "=", "this", ".", "_getAllNodesWithTag", "(", "this", ".", "_doc", ",", "[", "\"p\"", ",", "\"pre\"", "]", ")", ";", "// Get <div> nodes which have <br> node(s) and append them into the `nodes` variable.", "// Some articles' DOM structures might look like", "// <div>", "// Sentences<br>", "// <br>", "// Sentences<br>", "// </div>", "var", "brNodes", "=", "this", ".", "_getAllNodesWithTag", "(", "this", ".", "_doc", ",", "[", "\"div > br\"", "]", ")", ";", "if", "(", "brNodes", ".", "length", ")", "{", "var", "set", "=", "new", "Set", "(", ")", ";", "[", "]", ".", "forEach", ".", "call", "(", "brNodes", ",", "function", "(", "node", ")", "{", "set", ".", "add", "(", "node", ".", "parentNode", ")", ";", "}", ")", ";", "nodes", "=", "[", "]", ".", "concat", ".", "apply", "(", "Array", ".", "from", "(", "set", ")", ",", "nodes", ")", ";", "}", "// FIXME we should have a fallback for helperIsVisible, but this is", "// problematic because of jsdom's elem.style handling - see", "// https://github.com/mozilla/readability/pull/186 for context.", "var", "score", "=", "0", ";", "// This is a little cheeky, we use the accumulator 'score' to decide what to return from", "// this callback:", "return", "this", ".", "_someNode", "(", "nodes", ",", "function", "(", "node", ")", "{", "if", "(", "helperIsVisible", "&&", "!", "helperIsVisible", "(", "node", ")", ")", "return", "false", ";", "var", "matchString", "=", "node", ".", "className", "+", "\" \"", "+", "node", ".", "id", ";", "if", "(", "this", ".", "REGEXPS", ".", "unlikelyCandidates", ".", "test", "(", "matchString", ")", "&&", "!", "this", ".", "REGEXPS", ".", "okMaybeItsACandidate", ".", "test", "(", "matchString", ")", ")", "{", "return", "false", ";", "}", "if", "(", "node", ".", "matches", "&&", "node", ".", "matches", "(", "\"li p\"", ")", ")", "{", "return", "false", ";", "}", "var", "textContentLength", "=", "node", ".", "textContent", ".", "trim", "(", ")", ".", "length", ";", "if", "(", "textContentLength", "<", "140", ")", "{", "return", "false", ";", "}", "score", "+=", "Math", ".", "sqrt", "(", "textContentLength", "-", "140", ")", ";", "if", "(", "score", ">", "20", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", ")", ";", "}" ]
Decides whether or not the document is reader-able without parsing the whole thing. @return boolean Whether or not we suspect parse() will suceeed at returning an article object.
[ "Decides", "whether", "or", "not", "the", "document", "is", "reader", "-", "able", "without", "parsing", "the", "whole", "thing", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1702-L1754
942
laurent22/joplin
Clipper/joplin-webclipper/content_scripts/Readability.js
function () { // Avoid parsing too large documents, as per configuration option if (this._maxElemsToParse > 0) { var numTags = this._doc.getElementsByTagName("*").length; if (numTags > this._maxElemsToParse) { throw new Error("Aborting parsing document; " + numTags + " elements found"); } } if (typeof this._doc.documentElement.firstElementChild === "undefined") { this._getNextNode = this._getNextNodeNoElementProperties; } // Remove script tags from the document. this._removeScripts(this._doc); this._prepDocument(); var metadata = this._getArticleMetadata(); this._articleTitle = metadata.title; var articleContent = this._grabArticle(); if (!articleContent) return null; this.log("Grabbed: " + articleContent.innerHTML); this._postProcessContent(articleContent); // If we haven't found an excerpt in the article's metadata, use the article's // first paragraph as the excerpt. This is used for displaying a preview of // the article's content. if (!metadata.excerpt) { var paragraphs = articleContent.getElementsByTagName("p"); if (paragraphs.length > 0) { metadata.excerpt = paragraphs[0].textContent.trim(); } } var textContent = articleContent.textContent; return { title: this._articleTitle, byline: metadata.byline || this._articleByline, dir: this._articleDir, content: articleContent.innerHTML, textContent: textContent, length: textContent.length, excerpt: metadata.excerpt, }; }
javascript
function () { // Avoid parsing too large documents, as per configuration option if (this._maxElemsToParse > 0) { var numTags = this._doc.getElementsByTagName("*").length; if (numTags > this._maxElemsToParse) { throw new Error("Aborting parsing document; " + numTags + " elements found"); } } if (typeof this._doc.documentElement.firstElementChild === "undefined") { this._getNextNode = this._getNextNodeNoElementProperties; } // Remove script tags from the document. this._removeScripts(this._doc); this._prepDocument(); var metadata = this._getArticleMetadata(); this._articleTitle = metadata.title; var articleContent = this._grabArticle(); if (!articleContent) return null; this.log("Grabbed: " + articleContent.innerHTML); this._postProcessContent(articleContent); // If we haven't found an excerpt in the article's metadata, use the article's // first paragraph as the excerpt. This is used for displaying a preview of // the article's content. if (!metadata.excerpt) { var paragraphs = articleContent.getElementsByTagName("p"); if (paragraphs.length > 0) { metadata.excerpt = paragraphs[0].textContent.trim(); } } var textContent = articleContent.textContent; return { title: this._articleTitle, byline: metadata.byline || this._articleByline, dir: this._articleDir, content: articleContent.innerHTML, textContent: textContent, length: textContent.length, excerpt: metadata.excerpt, }; }
[ "function", "(", ")", "{", "// Avoid parsing too large documents, as per configuration option", "if", "(", "this", ".", "_maxElemsToParse", ">", "0", ")", "{", "var", "numTags", "=", "this", ".", "_doc", ".", "getElementsByTagName", "(", "\"*\"", ")", ".", "length", ";", "if", "(", "numTags", ">", "this", ".", "_maxElemsToParse", ")", "{", "throw", "new", "Error", "(", "\"Aborting parsing document; \"", "+", "numTags", "+", "\" elements found\"", ")", ";", "}", "}", "if", "(", "typeof", "this", ".", "_doc", ".", "documentElement", ".", "firstElementChild", "===", "\"undefined\"", ")", "{", "this", ".", "_getNextNode", "=", "this", ".", "_getNextNodeNoElementProperties", ";", "}", "// Remove script tags from the document.", "this", ".", "_removeScripts", "(", "this", ".", "_doc", ")", ";", "this", ".", "_prepDocument", "(", ")", ";", "var", "metadata", "=", "this", ".", "_getArticleMetadata", "(", ")", ";", "this", ".", "_articleTitle", "=", "metadata", ".", "title", ";", "var", "articleContent", "=", "this", ".", "_grabArticle", "(", ")", ";", "if", "(", "!", "articleContent", ")", "return", "null", ";", "this", ".", "log", "(", "\"Grabbed: \"", "+", "articleContent", ".", "innerHTML", ")", ";", "this", ".", "_postProcessContent", "(", "articleContent", ")", ";", "// If we haven't found an excerpt in the article's metadata, use the article's", "// first paragraph as the excerpt. This is used for displaying a preview of", "// the article's content.", "if", "(", "!", "metadata", ".", "excerpt", ")", "{", "var", "paragraphs", "=", "articleContent", ".", "getElementsByTagName", "(", "\"p\"", ")", ";", "if", "(", "paragraphs", ".", "length", ">", "0", ")", "{", "metadata", ".", "excerpt", "=", "paragraphs", "[", "0", "]", ".", "textContent", ".", "trim", "(", ")", ";", "}", "}", "var", "textContent", "=", "articleContent", ".", "textContent", ";", "return", "{", "title", ":", "this", ".", "_articleTitle", ",", "byline", ":", "metadata", ".", "byline", "||", "this", ".", "_articleByline", ",", "dir", ":", "this", ".", "_articleDir", ",", "content", ":", "articleContent", ".", "innerHTML", ",", "textContent", ":", "textContent", ",", "length", ":", "textContent", ".", "length", ",", "excerpt", ":", "metadata", ".", "excerpt", ",", "}", ";", "}" ]
Runs readability. Workflow: 1. Prep the document by removing script tags, css, etc. 2. Build readability's DOM tree. 3. Grab the article content from the current dom tree. 4. Replace the current DOM tree with the new one. 5. Read peacefully. @return void
[ "Runs", "readability", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1768-L1816
943
laurent22/joplin
ReactNativeClient/lib/file-api.js
basicDelta
async function basicDelta(path, getDirStatFn, options) { const outputLimit = 50; const itemIds = await options.allItemIdsHandler(); if (!Array.isArray(itemIds)) throw new Error('Delta API not supported - local IDs must be provided'); const context = basicDeltaContextFromOptions_(options); let newContext = { timestamp: context.timestamp, filesAtTimestamp: context.filesAtTimestamp.slice(), statsCache: context.statsCache, statIdsCache: context.statIdsCache, deletedItemsProcessed: context.deletedItemsProcessed, }; // Stats are cached until all items have been processed (until hasMore is false) if (newContext.statsCache === null) { newContext.statsCache = await getDirStatFn(path); newContext.statsCache.sort(function(a, b) { return a.updated_time - b.updated_time; }); newContext.statIdsCache = newContext.statsCache .filter(item => BaseItem.isSystemPath(item.path)) .map(item => BaseItem.pathToId(item.path)); newContext.statIdsCache.sort(); // Items must be sorted to use binary search below } let output = []; // Find out which files have been changed since the last time. Note that we keep // both the timestamp of the most recent change, *and* the items that exactly match // this timestamp. This to handle cases where an item is modified while this delta // function is running. For example: // t0: Item 1 is changed // t0: Sync items - run delta function // t0: While delta() is running, modify Item 2 // Since item 2 was modified within the same millisecond, it would be skipped in the // next sync if we relied exclusively on a timestamp. for (let i = 0; i < newContext.statsCache.length; i++) { const stat = newContext.statsCache[i]; if (stat.isDir) continue; if (stat.updated_time < context.timestamp) continue; // Special case for items that exactly match the timestamp if (stat.updated_time === context.timestamp) { if (context.filesAtTimestamp.indexOf(stat.path) >= 0) continue; } if (stat.updated_time > newContext.timestamp) { newContext.timestamp = stat.updated_time; newContext.filesAtTimestamp = []; } newContext.filesAtTimestamp.push(stat.path); output.push(stat); if (output.length >= outputLimit) break; } if (!newContext.deletedItemsProcessed) { // Find out which items have been deleted on the sync target by comparing the items // we have to the items on the target. // Note that when deleted items are processed it might result in the output having // more items than outputLimit. This is acceptable since delete operations are cheap. let deletedItems = []; for (let i = 0; i < itemIds.length; i++) { const itemId = itemIds[i]; if (ArrayUtils.binarySearch(newContext.statIdsCache, itemId) < 0) { deletedItems.push({ path: BaseItem.systemPath(itemId), isDeleted: true, }); } } output = output.concat(deletedItems); } newContext.deletedItemsProcessed = true; const hasMore = output.length >= outputLimit; if (!hasMore) { // Clear temporary info from context. It's especially important to remove deletedItemsProcessed // so that they are processed again on the next sync. newContext.statsCache = null; newContext.statIdsCache = null; delete newContext.deletedItemsProcessed; } return { hasMore: hasMore, context: newContext, items: output, }; }
javascript
async function basicDelta(path, getDirStatFn, options) { const outputLimit = 50; const itemIds = await options.allItemIdsHandler(); if (!Array.isArray(itemIds)) throw new Error('Delta API not supported - local IDs must be provided'); const context = basicDeltaContextFromOptions_(options); let newContext = { timestamp: context.timestamp, filesAtTimestamp: context.filesAtTimestamp.slice(), statsCache: context.statsCache, statIdsCache: context.statIdsCache, deletedItemsProcessed: context.deletedItemsProcessed, }; // Stats are cached until all items have been processed (until hasMore is false) if (newContext.statsCache === null) { newContext.statsCache = await getDirStatFn(path); newContext.statsCache.sort(function(a, b) { return a.updated_time - b.updated_time; }); newContext.statIdsCache = newContext.statsCache .filter(item => BaseItem.isSystemPath(item.path)) .map(item => BaseItem.pathToId(item.path)); newContext.statIdsCache.sort(); // Items must be sorted to use binary search below } let output = []; // Find out which files have been changed since the last time. Note that we keep // both the timestamp of the most recent change, *and* the items that exactly match // this timestamp. This to handle cases where an item is modified while this delta // function is running. For example: // t0: Item 1 is changed // t0: Sync items - run delta function // t0: While delta() is running, modify Item 2 // Since item 2 was modified within the same millisecond, it would be skipped in the // next sync if we relied exclusively on a timestamp. for (let i = 0; i < newContext.statsCache.length; i++) { const stat = newContext.statsCache[i]; if (stat.isDir) continue; if (stat.updated_time < context.timestamp) continue; // Special case for items that exactly match the timestamp if (stat.updated_time === context.timestamp) { if (context.filesAtTimestamp.indexOf(stat.path) >= 0) continue; } if (stat.updated_time > newContext.timestamp) { newContext.timestamp = stat.updated_time; newContext.filesAtTimestamp = []; } newContext.filesAtTimestamp.push(stat.path); output.push(stat); if (output.length >= outputLimit) break; } if (!newContext.deletedItemsProcessed) { // Find out which items have been deleted on the sync target by comparing the items // we have to the items on the target. // Note that when deleted items are processed it might result in the output having // more items than outputLimit. This is acceptable since delete operations are cheap. let deletedItems = []; for (let i = 0; i < itemIds.length; i++) { const itemId = itemIds[i]; if (ArrayUtils.binarySearch(newContext.statIdsCache, itemId) < 0) { deletedItems.push({ path: BaseItem.systemPath(itemId), isDeleted: true, }); } } output = output.concat(deletedItems); } newContext.deletedItemsProcessed = true; const hasMore = output.length >= outputLimit; if (!hasMore) { // Clear temporary info from context. It's especially important to remove deletedItemsProcessed // so that they are processed again on the next sync. newContext.statsCache = null; newContext.statIdsCache = null; delete newContext.deletedItemsProcessed; } return { hasMore: hasMore, context: newContext, items: output, }; }
[ "async", "function", "basicDelta", "(", "path", ",", "getDirStatFn", ",", "options", ")", "{", "const", "outputLimit", "=", "50", ";", "const", "itemIds", "=", "await", "options", ".", "allItemIdsHandler", "(", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "itemIds", ")", ")", "throw", "new", "Error", "(", "'Delta API not supported - local IDs must be provided'", ")", ";", "const", "context", "=", "basicDeltaContextFromOptions_", "(", "options", ")", ";", "let", "newContext", "=", "{", "timestamp", ":", "context", ".", "timestamp", ",", "filesAtTimestamp", ":", "context", ".", "filesAtTimestamp", ".", "slice", "(", ")", ",", "statsCache", ":", "context", ".", "statsCache", ",", "statIdsCache", ":", "context", ".", "statIdsCache", ",", "deletedItemsProcessed", ":", "context", ".", "deletedItemsProcessed", ",", "}", ";", "// Stats are cached until all items have been processed (until hasMore is false)", "if", "(", "newContext", ".", "statsCache", "===", "null", ")", "{", "newContext", ".", "statsCache", "=", "await", "getDirStatFn", "(", "path", ")", ";", "newContext", ".", "statsCache", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "return", "a", ".", "updated_time", "-", "b", ".", "updated_time", ";", "}", ")", ";", "newContext", ".", "statIdsCache", "=", "newContext", ".", "statsCache", ".", "filter", "(", "item", "=>", "BaseItem", ".", "isSystemPath", "(", "item", ".", "path", ")", ")", ".", "map", "(", "item", "=>", "BaseItem", ".", "pathToId", "(", "item", ".", "path", ")", ")", ";", "newContext", ".", "statIdsCache", ".", "sort", "(", ")", ";", "// Items must be sorted to use binary search below", "}", "let", "output", "=", "[", "]", ";", "// Find out which files have been changed since the last time. Note that we keep", "// both the timestamp of the most recent change, *and* the items that exactly match", "// this timestamp. This to handle cases where an item is modified while this delta", "// function is running. For example:", "// t0: Item 1 is changed", "// t0: Sync items - run delta function", "// t0: While delta() is running, modify Item 2", "// Since item 2 was modified within the same millisecond, it would be skipped in the", "// next sync if we relied exclusively on a timestamp.", "for", "(", "let", "i", "=", "0", ";", "i", "<", "newContext", ".", "statsCache", ".", "length", ";", "i", "++", ")", "{", "const", "stat", "=", "newContext", ".", "statsCache", "[", "i", "]", ";", "if", "(", "stat", ".", "isDir", ")", "continue", ";", "if", "(", "stat", ".", "updated_time", "<", "context", ".", "timestamp", ")", "continue", ";", "// Special case for items that exactly match the timestamp", "if", "(", "stat", ".", "updated_time", "===", "context", ".", "timestamp", ")", "{", "if", "(", "context", ".", "filesAtTimestamp", ".", "indexOf", "(", "stat", ".", "path", ")", ">=", "0", ")", "continue", ";", "}", "if", "(", "stat", ".", "updated_time", ">", "newContext", ".", "timestamp", ")", "{", "newContext", ".", "timestamp", "=", "stat", ".", "updated_time", ";", "newContext", ".", "filesAtTimestamp", "=", "[", "]", ";", "}", "newContext", ".", "filesAtTimestamp", ".", "push", "(", "stat", ".", "path", ")", ";", "output", ".", "push", "(", "stat", ")", ";", "if", "(", "output", ".", "length", ">=", "outputLimit", ")", "break", ";", "}", "if", "(", "!", "newContext", ".", "deletedItemsProcessed", ")", "{", "// Find out which items have been deleted on the sync target by comparing the items", "// we have to the items on the target.", "// Note that when deleted items are processed it might result in the output having", "// more items than outputLimit. This is acceptable since delete operations are cheap.", "let", "deletedItems", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "itemIds", ".", "length", ";", "i", "++", ")", "{", "const", "itemId", "=", "itemIds", "[", "i", "]", ";", "if", "(", "ArrayUtils", ".", "binarySearch", "(", "newContext", ".", "statIdsCache", ",", "itemId", ")", "<", "0", ")", "{", "deletedItems", ".", "push", "(", "{", "path", ":", "BaseItem", ".", "systemPath", "(", "itemId", ")", ",", "isDeleted", ":", "true", ",", "}", ")", ";", "}", "}", "output", "=", "output", ".", "concat", "(", "deletedItems", ")", ";", "}", "newContext", ".", "deletedItemsProcessed", "=", "true", ";", "const", "hasMore", "=", "output", ".", "length", ">=", "outputLimit", ";", "if", "(", "!", "hasMore", ")", "{", "// Clear temporary info from context. It's especially important to remove deletedItemsProcessed", "// so that they are processed again on the next sync.", "newContext", ".", "statsCache", "=", "null", ";", "newContext", ".", "statIdsCache", "=", "null", ";", "delete", "newContext", ".", "deletedItemsProcessed", ";", "}", "return", "{", "hasMore", ":", "hasMore", ",", "context", ":", "newContext", ",", "items", ":", "output", ",", "}", ";", "}" ]
This is the basic delta algorithm, which can be used in case the cloud service does not have a built-in delta API. OneDrive and Dropbox have one for example, but Nextcloud and obviously the file system do not.
[ "This", "is", "the", "basic", "delta", "algorithm", "which", "can", "be", "used", "in", "case", "the", "cloud", "service", "does", "not", "have", "a", "built", "-", "in", "delta", "API", ".", "OneDrive", "and", "Dropbox", "have", "one", "for", "example", "but", "Nextcloud", "and", "obviously", "the", "file", "system", "do", "not", "." ]
beb428b246cecba4630a3ca57b472f43c0933a43
https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ReactNativeClient/lib/file-api.js#L218-L316
944
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function(target) { var setFn = function(value, key) { target[key] = value; }; for (var i = 1, ilen = arguments.length; i < ilen; ++i) { helpers.each(arguments[i], setFn); } return target; }
javascript
function(target) { var setFn = function(value, key) { target[key] = value; }; for (var i = 1, ilen = arguments.length; i < ilen; ++i) { helpers.each(arguments[i], setFn); } return target; }
[ "function", "(", "target", ")", "{", "var", "setFn", "=", "function", "(", "value", ",", "key", ")", "{", "target", "[", "key", "]", "=", "value", ";", "}", ";", "for", "(", "var", "i", "=", "1", ",", "ilen", "=", "arguments", ".", "length", ";", "i", "<", "ilen", ";", "++", "i", ")", "{", "helpers", ".", "each", "(", "arguments", "[", "i", "]", ",", "setFn", ")", ";", "}", "return", "target", ";", "}" ]
Applies the contents of two or more objects together into the first object. @param {object} target - The target object in which all objects are merged into. @param {object} arg1 - Object containing additional properties to merge in target. @param {object} argN - Additional objects containing properties to merge in target. @returns {object} The `target` object.
[ "Applies", "the", "contents", "of", "two", "or", "more", "objects", "together", "into", "the", "first", "object", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L1955-L1963
945
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function(point, area) { var epsilon = 1e-6; // 1e-6 is margin in pixels for accumulated error. return point.x > area.left - epsilon && point.x < area.right + epsilon && point.y > area.top - epsilon && point.y < area.bottom + epsilon; }
javascript
function(point, area) { var epsilon = 1e-6; // 1e-6 is margin in pixels for accumulated error. return point.x > area.left - epsilon && point.x < area.right + epsilon && point.y > area.top - epsilon && point.y < area.bottom + epsilon; }
[ "function", "(", "point", ",", "area", ")", "{", "var", "epsilon", "=", "1e-6", ";", "// 1e-6 is margin in pixels for accumulated error.", "return", "point", ".", "x", ">", "area", ".", "left", "-", "epsilon", "&&", "point", ".", "x", "<", "area", ".", "right", "+", "epsilon", "&&", "point", ".", "y", ">", "area", ".", "top", "-", "epsilon", "&&", "point", ".", "y", "<", "area", ".", "bottom", "+", "epsilon", ";", "}" ]
Returns true if the point is inside the rectangle @param {object} point - The point to test @param {object} area - The rectangle @returns {boolean} @private
[ "Returns", "true", "if", "the", "point", "is", "inside", "the", "rectangle" ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L2458-L2463
946
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function(options) { var globalDefaults = core_defaults.global; var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize); var font = { family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily), lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.lineHeight, globalDefaults.defaultLineHeight), size), size: size, style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle), weight: null, string: '' }; font.string = toFontString(font); return font; }
javascript
function(options) { var globalDefaults = core_defaults.global; var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize); var font = { family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily), lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.lineHeight, globalDefaults.defaultLineHeight), size), size: size, style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle), weight: null, string: '' }; font.string = toFontString(font); return font; }
[ "function", "(", "options", ")", "{", "var", "globalDefaults", "=", "core_defaults", ".", "global", ";", "var", "size", "=", "valueOrDefault", "(", "options", ".", "fontSize", ",", "globalDefaults", ".", "defaultFontSize", ")", ";", "var", "font", "=", "{", "family", ":", "valueOrDefault", "(", "options", ".", "fontFamily", ",", "globalDefaults", ".", "defaultFontFamily", ")", ",", "lineHeight", ":", "helpers_core", ".", "options", ".", "toLineHeight", "(", "valueOrDefault", "(", "options", ".", "lineHeight", ",", "globalDefaults", ".", "defaultLineHeight", ")", ",", "size", ")", ",", "size", ":", "size", ",", "style", ":", "valueOrDefault", "(", "options", ".", "fontStyle", ",", "globalDefaults", ".", "defaultFontStyle", ")", ",", "weight", ":", "null", ",", "string", ":", "''", "}", ";", "font", ".", "string", "=", "toFontString", "(", "font", ")", ";", "return", "font", ";", "}" ]
Parses font options and returns the font object. @param {object} options - A object that contains font options to be parsed. @return {object} The font object. @todo Support font.* options and renamed to toFont(). @private
[ "Parses", "font", "options", "and", "returns", "the", "font", "object", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L2642-L2656
947
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function(inputs, context, index) { var i, ilen, value; for (i = 0, ilen = inputs.length; i < ilen; ++i) { value = inputs[i]; if (value === undefined) { continue; } if (context !== undefined && typeof value === 'function') { value = value(context); } if (index !== undefined && helpers_core.isArray(value)) { value = value[index]; } if (value !== undefined) { return value; } } }
javascript
function(inputs, context, index) { var i, ilen, value; for (i = 0, ilen = inputs.length; i < ilen; ++i) { value = inputs[i]; if (value === undefined) { continue; } if (context !== undefined && typeof value === 'function') { value = value(context); } if (index !== undefined && helpers_core.isArray(value)) { value = value[index]; } if (value !== undefined) { return value; } } }
[ "function", "(", "inputs", ",", "context", ",", "index", ")", "{", "var", "i", ",", "ilen", ",", "value", ";", "for", "(", "i", "=", "0", ",", "ilen", "=", "inputs", ".", "length", ";", "i", "<", "ilen", ";", "++", "i", ")", "{", "value", "=", "inputs", "[", "i", "]", ";", "if", "(", "value", "===", "undefined", ")", "{", "continue", ";", "}", "if", "(", "context", "!==", "undefined", "&&", "typeof", "value", "===", "'function'", ")", "{", "value", "=", "value", "(", "context", ")", ";", "}", "if", "(", "index", "!==", "undefined", "&&", "helpers_core", ".", "isArray", "(", "value", ")", ")", "{", "value", "=", "value", "[", "index", "]", ";", "}", "if", "(", "value", "!==", "undefined", ")", "{", "return", "value", ";", "}", "}", "}" ]
Evaluates the given `inputs` sequentially and returns the first defined value. @param {Array} inputs - An array of values, falling back to the last value. @param {object} [context] - If defined and the current value is a function, the value is called with `context` as first argument and the result becomes the new input. @param {number} [index] - If defined and the current value is an array, the value at `index` become the new input. @since 2.7.0
[ "Evaluates", "the", "given", "inputs", "sequentially", "and", "returns", "the", "first", "defined", "value", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L2667-L2685
948
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
getRelativePosition
function getRelativePosition(e, chart) { if (e.native) { return { x: e.x, y: e.y }; } return helpers$1.getRelativePosition(e, chart); }
javascript
function getRelativePosition(e, chart) { if (e.native) { return { x: e.x, y: e.y }; } return helpers$1.getRelativePosition(e, chart); }
[ "function", "getRelativePosition", "(", "e", ",", "chart", ")", "{", "if", "(", "e", ".", "native", ")", "{", "return", "{", "x", ":", "e", ".", "x", ",", "y", ":", "e", ".", "y", "}", ";", "}", "return", "helpers$1", ".", "getRelativePosition", "(", "e", ",", "chart", ")", ";", "}" ]
Helper function to get relative position for an event @param {Event|IEvent} event - The event to get the position for @param {Chart} chart - The chart @returns {object} the event position
[ "Helper", "function", "to", "get", "relative", "position", "for", "an", "event" ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L5835-L5844
949
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
fitBox
function fitBox(box) { var minBoxSize = helpers$1.findNextWhere(minBoxSizes, function(minBox) { return minBox.box === box; }); if (minBoxSize) { if (minBoxSize.horizontal) { var scaleMargin = { left: Math.max(outerBoxSizes.left, maxPadding.left), right: Math.max(outerBoxSizes.right, maxPadding.right), top: 0, bottom: 0 }; // Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends // on the margin. Sometimes they need to increase in size slightly box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, chartHeight / 2, scaleMargin); } else { box.update(minBoxSize.width, maxChartAreaHeight); } } }
javascript
function fitBox(box) { var minBoxSize = helpers$1.findNextWhere(minBoxSizes, function(minBox) { return minBox.box === box; }); if (minBoxSize) { if (minBoxSize.horizontal) { var scaleMargin = { left: Math.max(outerBoxSizes.left, maxPadding.left), right: Math.max(outerBoxSizes.right, maxPadding.right), top: 0, bottom: 0 }; // Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends // on the margin. Sometimes they need to increase in size slightly box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, chartHeight / 2, scaleMargin); } else { box.update(minBoxSize.width, maxChartAreaHeight); } } }
[ "function", "fitBox", "(", "box", ")", "{", "var", "minBoxSize", "=", "helpers$1", ".", "findNextWhere", "(", "minBoxSizes", ",", "function", "(", "minBox", ")", "{", "return", "minBox", ".", "box", "===", "box", ";", "}", ")", ";", "if", "(", "minBoxSize", ")", "{", "if", "(", "minBoxSize", ".", "horizontal", ")", "{", "var", "scaleMargin", "=", "{", "left", ":", "Math", ".", "max", "(", "outerBoxSizes", ".", "left", ",", "maxPadding", ".", "left", ")", ",", "right", ":", "Math", ".", "max", "(", "outerBoxSizes", ".", "right", ",", "maxPadding", ".", "right", ")", ",", "top", ":", "0", ",", "bottom", ":", "0", "}", ";", "// Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends", "// on the margin. Sometimes they need to increase in size slightly", "box", ".", "update", "(", "box", ".", "fullWidth", "?", "chartWidth", ":", "maxChartAreaWidth", ",", "chartHeight", "/", "2", ",", "scaleMargin", ")", ";", "}", "else", "{", "box", ".", "update", "(", "minBoxSize", ".", "width", ",", "maxChartAreaHeight", ")", ";", "}", "}", "}" ]
At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could be if the axes are drawn at their minimum sizes. Steps 5 & 6 Function to fit a box
[ "At", "this", "point", "maxChartAreaHeight", "and", "maxChartAreaWidth", "are", "the", "size", "the", "chart", "area", "could", "be", "if", "the", "axes", "are", "drawn", "at", "their", "minimum", "sizes", ".", "Steps", "5", "&", "6", "Function", "to", "fit", "a", "box" ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L6392-L6413
950
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
mergeConfig
function mergeConfig(/* config objects ... */) { return helpers$1.merge({}, [].slice.call(arguments), { merger: function(key, target, source, options) { var tval = target[key] || {}; var sval = source[key]; if (key === 'scales') { // scale config merging is complex. Add our own function here for that target[key] = mergeScaleConfig(tval, sval); } else if (key === 'scale') { // used in polar area & radar charts since there is only one scale target[key] = helpers$1.merge(tval, [core_scaleService.getScaleDefaults(sval.type), sval]); } else { helpers$1._merger(key, target, source, options); } } }); }
javascript
function mergeConfig(/* config objects ... */) { return helpers$1.merge({}, [].slice.call(arguments), { merger: function(key, target, source, options) { var tval = target[key] || {}; var sval = source[key]; if (key === 'scales') { // scale config merging is complex. Add our own function here for that target[key] = mergeScaleConfig(tval, sval); } else if (key === 'scale') { // used in polar area & radar charts since there is only one scale target[key] = helpers$1.merge(tval, [core_scaleService.getScaleDefaults(sval.type), sval]); } else { helpers$1._merger(key, target, source, options); } } }); }
[ "function", "mergeConfig", "(", "/* config objects ... */", ")", "{", "return", "helpers$1", ".", "merge", "(", "{", "}", ",", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ",", "{", "merger", ":", "function", "(", "key", ",", "target", ",", "source", ",", "options", ")", "{", "var", "tval", "=", "target", "[", "key", "]", "||", "{", "}", ";", "var", "sval", "=", "source", "[", "key", "]", ";", "if", "(", "key", "===", "'scales'", ")", "{", "// scale config merging is complex. Add our own function here for that", "target", "[", "key", "]", "=", "mergeScaleConfig", "(", "tval", ",", "sval", ")", ";", "}", "else", "if", "(", "key", "===", "'scale'", ")", "{", "// used in polar area & radar charts since there is only one scale", "target", "[", "key", "]", "=", "helpers$1", ".", "merge", "(", "tval", ",", "[", "core_scaleService", ".", "getScaleDefaults", "(", "sval", ".", "type", ")", ",", "sval", "]", ")", ";", "}", "else", "{", "helpers$1", ".", "_merger", "(", "key", ",", "target", ",", "source", ",", "options", ")", ";", "}", "}", "}", ")", ";", "}" ]
Recursively merge the given config objects as the root options by handling default scale options for the `scales` and `scale` properties, then returns a deep copy of the result, thus doesn't alter inputs.
[ "Recursively", "merge", "the", "given", "config", "objects", "as", "the", "root", "options", "by", "handling", "default", "scale", "options", "for", "the", "scales", "and", "scale", "properties", "then", "returns", "a", "deep", "copy", "of", "the", "result", "thus", "doesn", "t", "alter", "inputs", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L8340-L8357
951
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function() { var me = this; helpers$1.each(me.data.datasets, function(dataset, datasetIndex) { me.getDatasetMeta(datasetIndex).controller.reset(); }, me); }
javascript
function() { var me = this; helpers$1.each(me.data.datasets, function(dataset, datasetIndex) { me.getDatasetMeta(datasetIndex).controller.reset(); }, me); }
[ "function", "(", ")", "{", "var", "me", "=", "this", ";", "helpers$1", ".", "each", "(", "me", ".", "data", ".", "datasets", ",", "function", "(", "dataset", ",", "datasetIndex", ")", "{", "me", ".", "getDatasetMeta", "(", "datasetIndex", ")", ".", "controller", ".", "reset", "(", ")", ";", "}", ",", "me", ")", ";", "}" ]
Reset the elements of all datasets @private
[ "Reset", "the", "elements", "of", "all", "datasets" ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L8686-L8691
952
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function(easingValue) { var me = this; var tooltip = me.tooltip; var args = { tooltip: tooltip, easingValue: easingValue }; if (core_plugins.notify(me, 'beforeTooltipDraw', [args]) === false) { return; } tooltip.draw(); core_plugins.notify(me, 'afterTooltipDraw', [args]); }
javascript
function(easingValue) { var me = this; var tooltip = me.tooltip; var args = { tooltip: tooltip, easingValue: easingValue }; if (core_plugins.notify(me, 'beforeTooltipDraw', [args]) === false) { return; } tooltip.draw(); core_plugins.notify(me, 'afterTooltipDraw', [args]); }
[ "function", "(", "easingValue", ")", "{", "var", "me", "=", "this", ";", "var", "tooltip", "=", "me", ".", "tooltip", ";", "var", "args", "=", "{", "tooltip", ":", "tooltip", ",", "easingValue", ":", "easingValue", "}", ";", "if", "(", "core_plugins", ".", "notify", "(", "me", ",", "'beforeTooltipDraw'", ",", "[", "args", "]", ")", "===", "false", ")", "{", "return", ";", "}", "tooltip", ".", "draw", "(", ")", ";", "core_plugins", ".", "notify", "(", "me", ",", "'afterTooltipDraw'", ",", "[", "args", "]", ")", ";", "}" ]
Draws tooltip unless a plugin returns `false` to the `beforeTooltipDraw` hook, in which case, plugins will not be called on `afterTooltipDraw`. @private
[ "Draws", "tooltip", "unless", "a", "plugin", "returns", "false", "to", "the", "beforeTooltipDraw", "hook", "in", "which", "case", "plugins", "will", "not", "be", "called", "on", "afterTooltipDraw", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L8979-L8994
953
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
getConstraintDimension
function getConstraintDimension(domNode, maxStyle, percentageProperty) { var view = document.defaultView; var parentNode = helpers$1._getParentNode(domNode); var constrainedNode = view.getComputedStyle(domNode)[maxStyle]; var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle]; var hasCNode = isConstrainedValue(constrainedNode); var hasCContainer = isConstrainedValue(constrainedContainer); var infinity = Number.POSITIVE_INFINITY; if (hasCNode || hasCContainer) { return Math.min( hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity, hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity); } return 'none'; }
javascript
function getConstraintDimension(domNode, maxStyle, percentageProperty) { var view = document.defaultView; var parentNode = helpers$1._getParentNode(domNode); var constrainedNode = view.getComputedStyle(domNode)[maxStyle]; var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle]; var hasCNode = isConstrainedValue(constrainedNode); var hasCContainer = isConstrainedValue(constrainedContainer); var infinity = Number.POSITIVE_INFINITY; if (hasCNode || hasCContainer) { return Math.min( hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity, hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity); } return 'none'; }
[ "function", "getConstraintDimension", "(", "domNode", ",", "maxStyle", ",", "percentageProperty", ")", "{", "var", "view", "=", "document", ".", "defaultView", ";", "var", "parentNode", "=", "helpers$1", ".", "_getParentNode", "(", "domNode", ")", ";", "var", "constrainedNode", "=", "view", ".", "getComputedStyle", "(", "domNode", ")", "[", "maxStyle", "]", ";", "var", "constrainedContainer", "=", "view", ".", "getComputedStyle", "(", "parentNode", ")", "[", "maxStyle", "]", ";", "var", "hasCNode", "=", "isConstrainedValue", "(", "constrainedNode", ")", ";", "var", "hasCContainer", "=", "isConstrainedValue", "(", "constrainedContainer", ")", ";", "var", "infinity", "=", "Number", ".", "POSITIVE_INFINITY", ";", "if", "(", "hasCNode", "||", "hasCContainer", ")", "{", "return", "Math", ".", "min", "(", "hasCNode", "?", "parseMaxStyle", "(", "constrainedNode", ",", "domNode", ",", "percentageProperty", ")", ":", "infinity", ",", "hasCContainer", "?", "parseMaxStyle", "(", "constrainedContainer", ",", "parentNode", ",", "percentageProperty", ")", ":", "infinity", ")", ";", "}", "return", "'none'", ";", "}" ]
Returns the max width or height of the given DOM node in a cross-browser compatible fashion @param {HTMLElement} domNode - the node to check the constraint on @param {string} maxStyle - the style that defines the maximum for the direction we are using ('max-width' / 'max-height') @param {string} percentageProperty - property of parent to use when calculating width as a percentage @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser}
[ "Returns", "the", "max", "width", "or", "height", "of", "the", "given", "DOM", "node", "in", "a", "cross", "-", "browser", "compatible", "fashion" ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L9758-L9774
954
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
generateTicks
function generateTicks(generationOptions, dataRange) { var ticks = []; // To get a "nice" value for the tick spacing, we will use the appropriately named // "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks // for details. var MIN_SPACING = 1e-14; var stepSize = generationOptions.stepSize; var unit = stepSize || 1; var maxNumSpaces = generationOptions.maxTicks - 1; var min = generationOptions.min; var max = generationOptions.max; var precision = generationOptions.precision; var rmin = dataRange.min; var rmax = dataRange.max; var spacing = helpers$1.niceNum((rmax - rmin) / maxNumSpaces / unit) * unit; var factor, niceMin, niceMax, numSpaces; // Beyond MIN_SPACING floating point numbers being to lose precision // such that we can't do the math necessary to generate ticks if (spacing < MIN_SPACING && isNullOrUndef(min) && isNullOrUndef(max)) { return [rmin, rmax]; } numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing); if (numSpaces > maxNumSpaces) { // If the calculated num of spaces exceeds maxNumSpaces, recalculate it spacing = helpers$1.niceNum(numSpaces * spacing / maxNumSpaces / unit) * unit; } if (stepSize || isNullOrUndef(precision)) { // If a precision is not specified, calculate factor based on spacing factor = Math.pow(10, helpers$1._decimalPlaces(spacing)); } else { // If the user specified a precision, round to that number of decimal places factor = Math.pow(10, precision); spacing = Math.ceil(spacing * factor) / factor; } niceMin = Math.floor(rmin / spacing) * spacing; niceMax = Math.ceil(rmax / spacing) * spacing; // If min, max and stepSize is set and they make an evenly spaced scale use it. if (stepSize) { // If very close to our whole number, use it. if (!isNullOrUndef(min) && helpers$1.almostWhole(min / spacing, spacing / 1000)) { niceMin = min; } if (!isNullOrUndef(max) && helpers$1.almostWhole(max / spacing, spacing / 1000)) { niceMax = max; } } numSpaces = (niceMax - niceMin) / spacing; // If very close to our rounded value, use it. if (helpers$1.almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) { numSpaces = Math.round(numSpaces); } else { numSpaces = Math.ceil(numSpaces); } niceMin = Math.round(niceMin * factor) / factor; niceMax = Math.round(niceMax * factor) / factor; ticks.push(isNullOrUndef(min) ? niceMin : min); for (var j = 1; j < numSpaces; ++j) { ticks.push(Math.round((niceMin + j * spacing) * factor) / factor); } ticks.push(isNullOrUndef(max) ? niceMax : max); return ticks; }
javascript
function generateTicks(generationOptions, dataRange) { var ticks = []; // To get a "nice" value for the tick spacing, we will use the appropriately named // "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks // for details. var MIN_SPACING = 1e-14; var stepSize = generationOptions.stepSize; var unit = stepSize || 1; var maxNumSpaces = generationOptions.maxTicks - 1; var min = generationOptions.min; var max = generationOptions.max; var precision = generationOptions.precision; var rmin = dataRange.min; var rmax = dataRange.max; var spacing = helpers$1.niceNum((rmax - rmin) / maxNumSpaces / unit) * unit; var factor, niceMin, niceMax, numSpaces; // Beyond MIN_SPACING floating point numbers being to lose precision // such that we can't do the math necessary to generate ticks if (spacing < MIN_SPACING && isNullOrUndef(min) && isNullOrUndef(max)) { return [rmin, rmax]; } numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing); if (numSpaces > maxNumSpaces) { // If the calculated num of spaces exceeds maxNumSpaces, recalculate it spacing = helpers$1.niceNum(numSpaces * spacing / maxNumSpaces / unit) * unit; } if (stepSize || isNullOrUndef(precision)) { // If a precision is not specified, calculate factor based on spacing factor = Math.pow(10, helpers$1._decimalPlaces(spacing)); } else { // If the user specified a precision, round to that number of decimal places factor = Math.pow(10, precision); spacing = Math.ceil(spacing * factor) / factor; } niceMin = Math.floor(rmin / spacing) * spacing; niceMax = Math.ceil(rmax / spacing) * spacing; // If min, max and stepSize is set and they make an evenly spaced scale use it. if (stepSize) { // If very close to our whole number, use it. if (!isNullOrUndef(min) && helpers$1.almostWhole(min / spacing, spacing / 1000)) { niceMin = min; } if (!isNullOrUndef(max) && helpers$1.almostWhole(max / spacing, spacing / 1000)) { niceMax = max; } } numSpaces = (niceMax - niceMin) / spacing; // If very close to our rounded value, use it. if (helpers$1.almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) { numSpaces = Math.round(numSpaces); } else { numSpaces = Math.ceil(numSpaces); } niceMin = Math.round(niceMin * factor) / factor; niceMax = Math.round(niceMax * factor) / factor; ticks.push(isNullOrUndef(min) ? niceMin : min); for (var j = 1; j < numSpaces; ++j) { ticks.push(Math.round((niceMin + j * spacing) * factor) / factor); } ticks.push(isNullOrUndef(max) ? niceMax : max); return ticks; }
[ "function", "generateTicks", "(", "generationOptions", ",", "dataRange", ")", "{", "var", "ticks", "=", "[", "]", ";", "// To get a \"nice\" value for the tick spacing, we will use the appropriately named", "// \"nice number\" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks", "// for details.", "var", "MIN_SPACING", "=", "1e-14", ";", "var", "stepSize", "=", "generationOptions", ".", "stepSize", ";", "var", "unit", "=", "stepSize", "||", "1", ";", "var", "maxNumSpaces", "=", "generationOptions", ".", "maxTicks", "-", "1", ";", "var", "min", "=", "generationOptions", ".", "min", ";", "var", "max", "=", "generationOptions", ".", "max", ";", "var", "precision", "=", "generationOptions", ".", "precision", ";", "var", "rmin", "=", "dataRange", ".", "min", ";", "var", "rmax", "=", "dataRange", ".", "max", ";", "var", "spacing", "=", "helpers$1", ".", "niceNum", "(", "(", "rmax", "-", "rmin", ")", "/", "maxNumSpaces", "/", "unit", ")", "*", "unit", ";", "var", "factor", ",", "niceMin", ",", "niceMax", ",", "numSpaces", ";", "// Beyond MIN_SPACING floating point numbers being to lose precision", "// such that we can't do the math necessary to generate ticks", "if", "(", "spacing", "<", "MIN_SPACING", "&&", "isNullOrUndef", "(", "min", ")", "&&", "isNullOrUndef", "(", "max", ")", ")", "{", "return", "[", "rmin", ",", "rmax", "]", ";", "}", "numSpaces", "=", "Math", ".", "ceil", "(", "rmax", "/", "spacing", ")", "-", "Math", ".", "floor", "(", "rmin", "/", "spacing", ")", ";", "if", "(", "numSpaces", ">", "maxNumSpaces", ")", "{", "// If the calculated num of spaces exceeds maxNumSpaces, recalculate it", "spacing", "=", "helpers$1", ".", "niceNum", "(", "numSpaces", "*", "spacing", "/", "maxNumSpaces", "/", "unit", ")", "*", "unit", ";", "}", "if", "(", "stepSize", "||", "isNullOrUndef", "(", "precision", ")", ")", "{", "// If a precision is not specified, calculate factor based on spacing", "factor", "=", "Math", ".", "pow", "(", "10", ",", "helpers$1", ".", "_decimalPlaces", "(", "spacing", ")", ")", ";", "}", "else", "{", "// If the user specified a precision, round to that number of decimal places", "factor", "=", "Math", ".", "pow", "(", "10", ",", "precision", ")", ";", "spacing", "=", "Math", ".", "ceil", "(", "spacing", "*", "factor", ")", "/", "factor", ";", "}", "niceMin", "=", "Math", ".", "floor", "(", "rmin", "/", "spacing", ")", "*", "spacing", ";", "niceMax", "=", "Math", ".", "ceil", "(", "rmax", "/", "spacing", ")", "*", "spacing", ";", "// If min, max and stepSize is set and they make an evenly spaced scale use it.", "if", "(", "stepSize", ")", "{", "// If very close to our whole number, use it.", "if", "(", "!", "isNullOrUndef", "(", "min", ")", "&&", "helpers$1", ".", "almostWhole", "(", "min", "/", "spacing", ",", "spacing", "/", "1000", ")", ")", "{", "niceMin", "=", "min", ";", "}", "if", "(", "!", "isNullOrUndef", "(", "max", ")", "&&", "helpers$1", ".", "almostWhole", "(", "max", "/", "spacing", ",", "spacing", "/", "1000", ")", ")", "{", "niceMax", "=", "max", ";", "}", "}", "numSpaces", "=", "(", "niceMax", "-", "niceMin", ")", "/", "spacing", ";", "// If very close to our rounded value, use it.", "if", "(", "helpers$1", ".", "almostEquals", "(", "numSpaces", ",", "Math", ".", "round", "(", "numSpaces", ")", ",", "spacing", "/", "1000", ")", ")", "{", "numSpaces", "=", "Math", ".", "round", "(", "numSpaces", ")", ";", "}", "else", "{", "numSpaces", "=", "Math", ".", "ceil", "(", "numSpaces", ")", ";", "}", "niceMin", "=", "Math", ".", "round", "(", "niceMin", "*", "factor", ")", "/", "factor", ";", "niceMax", "=", "Math", ".", "round", "(", "niceMax", "*", "factor", ")", "/", "factor", ";", "ticks", ".", "push", "(", "isNullOrUndef", "(", "min", ")", "?", "niceMin", ":", "min", ")", ";", "for", "(", "var", "j", "=", "1", ";", "j", "<", "numSpaces", ";", "++", "j", ")", "{", "ticks", ".", "push", "(", "Math", ".", "round", "(", "(", "niceMin", "+", "j", "*", "spacing", ")", "*", "factor", ")", "/", "factor", ")", ";", "}", "ticks", ".", "push", "(", "isNullOrUndef", "(", "max", ")", "?", "niceMax", ":", "max", ")", ";", "return", "ticks", ";", "}" ]
Generate a set of linear ticks @param generationOptions the options used to generate the ticks @param dataRange the range of the data @returns {number[]} array of tick values
[ "Generate", "a", "set", "of", "linear", "ticks" ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L11268-L11338
955
BlackrockDigital/startbootstrap-sb-admin-2
vendor/chart.js/Chart.js
function(value) { var exp = Math.floor(helpers$1.log10(value)); var significand = Math.floor(value / Math.pow(10, exp)); return significand * Math.pow(10, exp); }
javascript
function(value) { var exp = Math.floor(helpers$1.log10(value)); var significand = Math.floor(value / Math.pow(10, exp)); return significand * Math.pow(10, exp); }
[ "function", "(", "value", ")", "{", "var", "exp", "=", "Math", ".", "floor", "(", "helpers$1", ".", "log10", "(", "value", ")", ")", ";", "var", "significand", "=", "Math", ".", "floor", "(", "value", "/", "Math", ".", "pow", "(", "10", ",", "exp", ")", ")", ";", "return", "significand", "*", "Math", ".", "pow", "(", "10", ",", "exp", ")", ";", "}" ]
Returns the value of the first tick. @param {number} value - The minimum not zero value. @return {number} The first tick value. @private
[ "Returns", "the", "value", "of", "the", "first", "tick", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L11931-L11936
956
BlackrockDigital/startbootstrap-sb-admin-2
vendor/fontawesome-free/js/fontawesome.js
bindInternal4
function bindInternal4(func, thisContext) { return function (a, b, c, d) { return func.call(thisContext, a, b, c, d); }; }
javascript
function bindInternal4(func, thisContext) { return function (a, b, c, d) { return func.call(thisContext, a, b, c, d); }; }
[ "function", "bindInternal4", "(", "func", ",", "thisContext", ")", "{", "return", "function", "(", "a", ",", "b", ",", "c", ",", "d", ")", "{", "return", "func", ".", "call", "(", "thisContext", ",", "a", ",", "b", ",", "c", ",", "d", ")", ";", "}", ";", "}" ]
Internal helper to bind a function known to have 4 arguments to a given context.
[ "Internal", "helper", "to", "bind", "a", "function", "known", "to", "have", "4", "arguments", "to", "a", "given", "context", "." ]
ddfaceb4a8e65a41f163e2fdc4eab49384b810a1
https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/fontawesome-free/js/fontawesome.js#L1095-L1099
957
parcel-bundler/parcel
packages/core/parcel-bundler/src/scope-hoisting/mangler.js
mangleScope
function mangleScope(scope) { let newNames = new Set(); // Sort bindings so that more frequently referenced bindings get shorter names. let sortedBindings = Object.keys(scope.bindings).sort( (a, b) => scope.bindings[b].referencePaths.length - scope.bindings[a].referencePaths.length ); for (let oldName of sortedBindings) { let i = 0; let newName = ''; do { newName = getIdentifier(i++); } while ( newNames.has(newName) || !canRename(scope, scope.bindings[oldName], newName) ); rename(scope, oldName, newName); newNames.add(newName); } }
javascript
function mangleScope(scope) { let newNames = new Set(); // Sort bindings so that more frequently referenced bindings get shorter names. let sortedBindings = Object.keys(scope.bindings).sort( (a, b) => scope.bindings[b].referencePaths.length - scope.bindings[a].referencePaths.length ); for (let oldName of sortedBindings) { let i = 0; let newName = ''; do { newName = getIdentifier(i++); } while ( newNames.has(newName) || !canRename(scope, scope.bindings[oldName], newName) ); rename(scope, oldName, newName); newNames.add(newName); } }
[ "function", "mangleScope", "(", "scope", ")", "{", "let", "newNames", "=", "new", "Set", "(", ")", ";", "// Sort bindings so that more frequently referenced bindings get shorter names.", "let", "sortedBindings", "=", "Object", ".", "keys", "(", "scope", ".", "bindings", ")", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "scope", ".", "bindings", "[", "b", "]", ".", "referencePaths", ".", "length", "-", "scope", ".", "bindings", "[", "a", "]", ".", "referencePaths", ".", "length", ")", ";", "for", "(", "let", "oldName", "of", "sortedBindings", ")", "{", "let", "i", "=", "0", ";", "let", "newName", "=", "''", ";", "do", "{", "newName", "=", "getIdentifier", "(", "i", "++", ")", ";", "}", "while", "(", "newNames", ".", "has", "(", "newName", ")", "||", "!", "canRename", "(", "scope", ",", "scope", ".", "bindings", "[", "oldName", "]", ",", "newName", ")", ")", ";", "rename", "(", "scope", ",", "oldName", ",", "newName", ")", ";", "newNames", ".", "add", "(", "newName", ")", ";", "}", "}" ]
This is a very specialized mangler designer to mangle only names in the top-level scope. Mangling of names in other scopes happens at a file level inside workers, but we can't mangle the top-level scope until scope hoisting is complete in the packager. Based on code from babel-minify! https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/charset.js
[ "This", "is", "a", "very", "specialized", "mangler", "designer", "to", "mangle", "only", "names", "in", "the", "top", "-", "level", "scope", ".", "Mangling", "of", "names", "in", "other", "scopes", "happens", "at", "a", "file", "level", "inside", "workers", "but", "we", "can", "t", "mangle", "the", "top", "-", "level", "scope", "until", "scope", "hoisting", "is", "complete", "in", "the", "packager", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/scope-hoisting/mangler.js#L16-L40
958
parcel-bundler/parcel
packages/core/parcel-bundler/src/assets/StylusAsset.js
mergeBlocks
function mergeBlocks(blocks) { let finalBlock; for (const block of blocks) { if (!finalBlock) finalBlock = block; else { block.nodes.forEach(node => finalBlock.push(node)); } } return finalBlock; }
javascript
function mergeBlocks(blocks) { let finalBlock; for (const block of blocks) { if (!finalBlock) finalBlock = block; else { block.nodes.forEach(node => finalBlock.push(node)); } } return finalBlock; }
[ "function", "mergeBlocks", "(", "blocks", ")", "{", "let", "finalBlock", ";", "for", "(", "const", "block", "of", "blocks", ")", "{", "if", "(", "!", "finalBlock", ")", "finalBlock", "=", "block", ";", "else", "{", "block", ".", "nodes", ".", "forEach", "(", "node", "=>", "finalBlock", ".", "push", "(", "node", ")", ")", ";", "}", "}", "return", "finalBlock", ";", "}" ]
Puts the content of all given node blocks into the first one, essentially merging them.
[ "Puts", "the", "content", "of", "all", "given", "node", "blocks", "into", "the", "first", "one", "essentially", "merging", "them", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/assets/StylusAsset.js#L217-L226
959
parcel-bundler/parcel
packages/core/parcel-bundler/src/visitors/env.js
morph
function morph(object, newProperties) { for (let key in object) { delete object[key]; } for (let key in newProperties) { object[key] = newProperties[key]; } }
javascript
function morph(object, newProperties) { for (let key in object) { delete object[key]; } for (let key in newProperties) { object[key] = newProperties[key]; } }
[ "function", "morph", "(", "object", ",", "newProperties", ")", "{", "for", "(", "let", "key", "in", "object", ")", "{", "delete", "object", "[", "key", "]", ";", "}", "for", "(", "let", "key", "in", "newProperties", ")", "{", "object", "[", "key", "]", "=", "newProperties", "[", "key", "]", ";", "}", "}" ]
replace object properties
[ "replace", "object", "properties" ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/visitors/env.js#L22-L30
960
parcel-bundler/parcel
packages/core/parcel-bundler/src/transforms/babel/flow.js
getFlowConfig
function getFlowConfig(asset) { if (/^(\/{2}|\/\*+) *@flow/.test(asset.contents.substring(0, 20))) { return { internal: true, babelVersion: 7, config: { plugins: [[require('@babel/plugin-transform-flow-strip-types')]] } }; } return null; }
javascript
function getFlowConfig(asset) { if (/^(\/{2}|\/\*+) *@flow/.test(asset.contents.substring(0, 20))) { return { internal: true, babelVersion: 7, config: { plugins: [[require('@babel/plugin-transform-flow-strip-types')]] } }; } return null; }
[ "function", "getFlowConfig", "(", "asset", ")", "{", "if", "(", "/", "^(\\/{2}|\\/\\*+) *@flow", "/", ".", "test", "(", "asset", ".", "contents", ".", "substring", "(", "0", ",", "20", ")", ")", ")", "{", "return", "{", "internal", ":", "true", ",", "babelVersion", ":", "7", ",", "config", ":", "{", "plugins", ":", "[", "[", "require", "(", "'@babel/plugin-transform-flow-strip-types'", ")", "]", "]", "}", "}", ";", "}", "return", "null", ";", "}" ]
Generates a babel config for stripping away Flow types.
[ "Generates", "a", "babel", "config", "for", "stripping", "away", "Flow", "types", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/transforms/babel/flow.js#L4-L16
961
parcel-bundler/parcel
packages/core/parcel-bundler/src/utils/syncPromise.js
syncPromise
function syncPromise(promise) { let isDone = false; let res, err; promise.then( value => { res = value; isDone = true; }, error => { err = error; isDone = true; } ); deasync.loopWhile(() => !isDone); if (err) { throw err; } return res; }
javascript
function syncPromise(promise) { let isDone = false; let res, err; promise.then( value => { res = value; isDone = true; }, error => { err = error; isDone = true; } ); deasync.loopWhile(() => !isDone); if (err) { throw err; } return res; }
[ "function", "syncPromise", "(", "promise", ")", "{", "let", "isDone", "=", "false", ";", "let", "res", ",", "err", ";", "promise", ".", "then", "(", "value", "=>", "{", "res", "=", "value", ";", "isDone", "=", "true", ";", "}", ",", "error", "=>", "{", "err", "=", "error", ";", "isDone", "=", "true", ";", "}", ")", ";", "deasync", ".", "loopWhile", "(", "(", ")", "=>", "!", "isDone", ")", ";", "if", "(", "err", ")", "{", "throw", "err", ";", "}", "return", "res", ";", "}" ]
Synchronously waits for a promise to return by yielding to the node event loop as needed.
[ "Synchronously", "waits", "for", "a", "promise", "to", "return", "by", "yielding", "to", "the", "node", "event", "loop", "as", "needed", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/utils/syncPromise.js#L7-L29
962
parcel-bundler/parcel
packages/core/parcel-bundler/src/scope-hoisting/shake.js
treeShake
function treeShake(scope) { // Keep passing over all bindings in the scope until we don't remove any. // This handles cases where we remove one binding which had a reference to // another one. That one will get removed in the next pass if it is now unreferenced. let removed; do { removed = false; // Recrawl to get all bindings. scope.crawl(); Object.keys(scope.bindings).forEach(name => { let binding = getUnusedBinding(scope.path, name); // If it is not safe to remove the binding don't touch it. if (!binding) { return; } // Remove the binding and all references to it. binding.path.remove(); binding.referencePaths.concat(binding.constantViolations).forEach(remove); scope.removeBinding(name); removed = true; }); } while (removed); }
javascript
function treeShake(scope) { // Keep passing over all bindings in the scope until we don't remove any. // This handles cases where we remove one binding which had a reference to // another one. That one will get removed in the next pass if it is now unreferenced. let removed; do { removed = false; // Recrawl to get all bindings. scope.crawl(); Object.keys(scope.bindings).forEach(name => { let binding = getUnusedBinding(scope.path, name); // If it is not safe to remove the binding don't touch it. if (!binding) { return; } // Remove the binding and all references to it. binding.path.remove(); binding.referencePaths.concat(binding.constantViolations).forEach(remove); scope.removeBinding(name); removed = true; }); } while (removed); }
[ "function", "treeShake", "(", "scope", ")", "{", "// Keep passing over all bindings in the scope until we don't remove any.", "// This handles cases where we remove one binding which had a reference to", "// another one. That one will get removed in the next pass if it is now unreferenced.", "let", "removed", ";", "do", "{", "removed", "=", "false", ";", "// Recrawl to get all bindings.", "scope", ".", "crawl", "(", ")", ";", "Object", ".", "keys", "(", "scope", ".", "bindings", ")", ".", "forEach", "(", "name", "=>", "{", "let", "binding", "=", "getUnusedBinding", "(", "scope", ".", "path", ",", "name", ")", ";", "// If it is not safe to remove the binding don't touch it.", "if", "(", "!", "binding", ")", "{", "return", ";", "}", "// Remove the binding and all references to it.", "binding", ".", "path", ".", "remove", "(", ")", ";", "binding", ".", "referencePaths", ".", "concat", "(", "binding", ".", "constantViolations", ")", ".", "forEach", "(", "remove", ")", ";", "scope", ".", "removeBinding", "(", "name", ")", ";", "removed", "=", "true", ";", "}", ")", ";", "}", "while", "(", "removed", ")", ";", "}" ]
This is a small small implementation of dead code removal specialized to handle removing unused exports. All other dead code removal happens in workers on each individual file by babel-minify.
[ "This", "is", "a", "small", "small", "implementation", "of", "dead", "code", "removal", "specialized", "to", "handle", "removing", "unused", "exports", ".", "All", "other", "dead", "code", "removal", "happens", "in", "workers", "on", "each", "individual", "file", "by", "babel", "-", "minify", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/scope-hoisting/shake.js#L8-L34
963
parcel-bundler/parcel
packages/core/parcel-bundler/src/scope-hoisting/shake.js
getUnusedBinding
function getUnusedBinding(path, name) { let binding = path.scope.getBinding(name); if (!binding) { return null; } let pure = isPure(binding); if (!binding.referenced && pure) { return binding; } // Is there any references which aren't simple assignments? let bailout = binding.referencePaths.some( path => !isExportAssignment(path) && !isUnusedWildcard(path) ); if (!bailout && pure) { return binding; } return null; }
javascript
function getUnusedBinding(path, name) { let binding = path.scope.getBinding(name); if (!binding) { return null; } let pure = isPure(binding); if (!binding.referenced && pure) { return binding; } // Is there any references which aren't simple assignments? let bailout = binding.referencePaths.some( path => !isExportAssignment(path) && !isUnusedWildcard(path) ); if (!bailout && pure) { return binding; } return null; }
[ "function", "getUnusedBinding", "(", "path", ",", "name", ")", "{", "let", "binding", "=", "path", ".", "scope", ".", "getBinding", "(", "name", ")", ";", "if", "(", "!", "binding", ")", "{", "return", "null", ";", "}", "let", "pure", "=", "isPure", "(", "binding", ")", ";", "if", "(", "!", "binding", ".", "referenced", "&&", "pure", ")", "{", "return", "binding", ";", "}", "// Is there any references which aren't simple assignments?", "let", "bailout", "=", "binding", ".", "referencePaths", ".", "some", "(", "path", "=>", "!", "isExportAssignment", "(", "path", ")", "&&", "!", "isUnusedWildcard", "(", "path", ")", ")", ";", "if", "(", "!", "bailout", "&&", "pure", ")", "{", "return", "binding", ";", "}", "return", "null", ";", "}" ]
Check if a binding is safe to remove and returns it if it is.
[ "Check", "if", "a", "binding", "is", "safe", "to", "remove", "and", "returns", "it", "if", "it", "is", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/scope-hoisting/shake.js#L39-L60
964
parcel-bundler/parcel
packages/core/logger/src/Logger.js
pad
function pad(text, length, align = 'left') { let pad = ' '.repeat(length - stringWidth(text)); if (align === 'right') { return pad + text; } return text + pad; }
javascript
function pad(text, length, align = 'left') { let pad = ' '.repeat(length - stringWidth(text)); if (align === 'right') { return pad + text; } return text + pad; }
[ "function", "pad", "(", "text", ",", "length", ",", "align", "=", "'left'", ")", "{", "let", "pad", "=", "' '", ".", "repeat", "(", "length", "-", "stringWidth", "(", "text", ")", ")", ";", "if", "(", "align", "===", "'right'", ")", "{", "return", "pad", "+", "text", ";", "}", "return", "text", "+", "pad", ";", "}" ]
Pad a string with spaces on either side
[ "Pad", "a", "string", "with", "spaces", "on", "either", "side" ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/logger/src/Logger.js#L213-L220
965
parcel-bundler/parcel
packages/core/parcel-bundler/src/assets/SASSAsset.js
normalizeError
function normalizeError(err) { let message = 'Unknown error'; if (err) { if (err instanceof Error) { return err; } message = err.stack || err.message || err; } return new Error(message); }
javascript
function normalizeError(err) { let message = 'Unknown error'; if (err) { if (err instanceof Error) { return err; } message = err.stack || err.message || err; } return new Error(message); }
[ "function", "normalizeError", "(", "err", ")", "{", "let", "message", "=", "'Unknown error'", ";", "if", "(", "err", ")", "{", "if", "(", "err", "instanceof", "Error", ")", "{", "return", "err", ";", "}", "message", "=", "err", ".", "stack", "||", "err", ".", "message", "||", "err", ";", "}", "return", "new", "Error", "(", "message", ")", ";", "}" ]
Ensures an error inherits from Error
[ "Ensures", "an", "error", "inherits", "from", "Error" ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/assets/SASSAsset.js#L122-L134
966
parcel-bundler/parcel
packages/core/parcel-bundler/src/transforms/babel/jsx.js
getJSXConfig
async function getJSXConfig(asset, isSourceModule) { // Don't enable JSX in node_modules if (!isSourceModule) { return null; } let pkg = await asset.getPackage(); // Find a dependency that we can map to a JSX pragma let pragma = null; for (let dep in JSX_PRAGMA) { if ( pkg && ((pkg.dependencies && pkg.dependencies[dep]) || (pkg.devDependencies && pkg.devDependencies[dep])) ) { pragma = JSX_PRAGMA[dep]; break; } } if (!pragma) { pragma = maybeCreateFallbackPragma(asset); } if (pragma || JSX_EXTENSIONS[path.extname(asset.name)]) { return { internal: true, babelVersion: 7, config: { plugins: [ [ require('@babel/plugin-transform-react-jsx'), { pragma, pragmaFrag: 'React.Fragment' } ] ] } }; } }
javascript
async function getJSXConfig(asset, isSourceModule) { // Don't enable JSX in node_modules if (!isSourceModule) { return null; } let pkg = await asset.getPackage(); // Find a dependency that we can map to a JSX pragma let pragma = null; for (let dep in JSX_PRAGMA) { if ( pkg && ((pkg.dependencies && pkg.dependencies[dep]) || (pkg.devDependencies && pkg.devDependencies[dep])) ) { pragma = JSX_PRAGMA[dep]; break; } } if (!pragma) { pragma = maybeCreateFallbackPragma(asset); } if (pragma || JSX_EXTENSIONS[path.extname(asset.name)]) { return { internal: true, babelVersion: 7, config: { plugins: [ [ require('@babel/plugin-transform-react-jsx'), { pragma, pragmaFrag: 'React.Fragment' } ] ] } }; } }
[ "async", "function", "getJSXConfig", "(", "asset", ",", "isSourceModule", ")", "{", "// Don't enable JSX in node_modules", "if", "(", "!", "isSourceModule", ")", "{", "return", "null", ";", "}", "let", "pkg", "=", "await", "asset", ".", "getPackage", "(", ")", ";", "// Find a dependency that we can map to a JSX pragma", "let", "pragma", "=", "null", ";", "for", "(", "let", "dep", "in", "JSX_PRAGMA", ")", "{", "if", "(", "pkg", "&&", "(", "(", "pkg", ".", "dependencies", "&&", "pkg", ".", "dependencies", "[", "dep", "]", ")", "||", "(", "pkg", ".", "devDependencies", "&&", "pkg", ".", "devDependencies", "[", "dep", "]", ")", ")", ")", "{", "pragma", "=", "JSX_PRAGMA", "[", "dep", "]", ";", "break", ";", "}", "}", "if", "(", "!", "pragma", ")", "{", "pragma", "=", "maybeCreateFallbackPragma", "(", "asset", ")", ";", "}", "if", "(", "pragma", "||", "JSX_EXTENSIONS", "[", "path", ".", "extname", "(", "asset", ".", "name", ")", "]", ")", "{", "return", "{", "internal", ":", "true", ",", "babelVersion", ":", "7", ",", "config", ":", "{", "plugins", ":", "[", "[", "require", "(", "'@babel/plugin-transform-react-jsx'", ")", ",", "{", "pragma", ",", "pragmaFrag", ":", "'React.Fragment'", "}", "]", "]", "}", "}", ";", "}", "}" ]
Generates a babel config for JSX. Attempts to detect react or react-like libraries and changes the pragma accordingly.
[ "Generates", "a", "babel", "config", "for", "JSX", ".", "Attempts", "to", "detect", "react", "or", "react", "-", "like", "libraries", "and", "changes", "the", "pragma", "accordingly", "." ]
84b308511f87d4b69da62bcd352f0ff2f7bd4f1b
https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/transforms/babel/jsx.js#L47-L89
967
aws-amplify/amplify-js
docs/amplify-theme/assets/js/scripts.js
function() { this.scrollToCurrent(); window.addEventListener('hashchange', this.scrollToCurrent.bind(this)); document.body.addEventListener('click', this.delegateAnchors.bind(this)); }
javascript
function() { this.scrollToCurrent(); window.addEventListener('hashchange', this.scrollToCurrent.bind(this)); document.body.addEventListener('click', this.delegateAnchors.bind(this)); }
[ "function", "(", ")", "{", "this", ".", "scrollToCurrent", "(", ")", ";", "window", ".", "addEventListener", "(", "'hashchange'", ",", "this", ".", "scrollToCurrent", ".", "bind", "(", "this", ")", ")", ";", "document", ".", "body", ".", "addEventListener", "(", "'click'", ",", "this", ".", "delegateAnchors", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Establish events, and fix initial scroll position if a hash is provided.
[ "Establish", "events", "and", "fix", "initial", "scroll", "position", "if", "a", "hash", "is", "provided", "." ]
db55ff3dff31c64a246180f39eb0a04a89fd16e1
https://github.com/aws-amplify/amplify-js/blob/db55ff3dff31c64a246180f39eb0a04a89fd16e1/docs/amplify-theme/assets/js/scripts.js#L15-L19
968
aws-amplify/amplify-js
docs/amplify-theme/assets/js/scripts.js
function() { let search_box = document.getElementById("search-input") search_box.onclick = function() { document.getElementById("search-image").style.display = "none"; search_box.style.outline = "none"; search_box.placeholder = "Search"; search_box.style.paddingLeft = "2px"; } }
javascript
function() { let search_box = document.getElementById("search-input") search_box.onclick = function() { document.getElementById("search-image").style.display = "none"; search_box.style.outline = "none"; search_box.placeholder = "Search"; search_box.style.paddingLeft = "2px"; } }
[ "function", "(", ")", "{", "let", "search_box", "=", "document", ".", "getElementById", "(", "\"search-input\"", ")", "search_box", ".", "onclick", "=", "function", "(", ")", "{", "document", ".", "getElementById", "(", "\"search-image\"", ")", ".", "style", ".", "display", "=", "\"none\"", ";", "search_box", ".", "style", ".", "outline", "=", "\"none\"", ";", "search_box", ".", "placeholder", "=", "\"Search\"", ";", "search_box", ".", "style", ".", "paddingLeft", "=", "\"2px\"", ";", "}", "}" ]
Hide magnifying glass in search bar
[ "Hide", "magnifying", "glass", "in", "search", "bar" ]
db55ff3dff31c64a246180f39eb0a04a89fd16e1
https://github.com/aws-amplify/amplify-js/blob/db55ff3dff31c64a246180f39eb0a04a89fd16e1/docs/amplify-theme/assets/js/scripts.js#L358-L366
969
radare/radare2
shlr/www/d3/packages.js
function(nodes) { var map = {}, imports = []; // Compute a map from name to node. nodes.forEach(function(d) { map[d.name] = d; }); // For each import, construct a link from the source to target node. nodes.forEach(function(d) { if (d.imports) d.imports.forEach(function(i) { imports.push({source: map[d.name], target: map[i]}); }); }); return imports; }
javascript
function(nodes) { var map = {}, imports = []; // Compute a map from name to node. nodes.forEach(function(d) { map[d.name] = d; }); // For each import, construct a link from the source to target node. nodes.forEach(function(d) { if (d.imports) d.imports.forEach(function(i) { imports.push({source: map[d.name], target: map[i]}); }); }); return imports; }
[ "function", "(", "nodes", ")", "{", "var", "map", "=", "{", "}", ",", "imports", "=", "[", "]", ";", "// Compute a map from name to node.", "nodes", ".", "forEach", "(", "function", "(", "d", ")", "{", "map", "[", "d", ".", "name", "]", "=", "d", ";", "}", ")", ";", "// For each import, construct a link from the source to target node.", "nodes", ".", "forEach", "(", "function", "(", "d", ")", "{", "if", "(", "d", ".", "imports", ")", "d", ".", "imports", ".", "forEach", "(", "function", "(", "i", ")", "{", "imports", ".", "push", "(", "{", "source", ":", "map", "[", "d", ".", "name", "]", ",", "target", ":", "map", "[", "i", "]", "}", ")", ";", "}", ")", ";", "}", ")", ";", "return", "imports", ";", "}" ]
Return a list of imports for the given array of nodes.
[ "Return", "a", "list", "of", "imports", "for", "the", "given", "array", "of", "nodes", "." ]
bf5e3028810a0ec7c267c6fe4bfad639b4819e35
https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/d3/packages.js#L29-L46
970
radare/radare2
shlr/www/graph/js-graph-it.js
BlocksToMoveVisitor
function BlocksToMoveVisitor() { this.visit = function(element) { if (isBlock(element)) { blocksToMove.push(findBlock(element.id)); return false; } return true; } }
javascript
function BlocksToMoveVisitor() { this.visit = function(element) { if (isBlock(element)) { blocksToMove.push(findBlock(element.id)); return false; } return true; } }
[ "function", "BlocksToMoveVisitor", "(", ")", "{", "this", ".", "visit", "=", "function", "(", "element", ")", "{", "if", "(", "isBlock", "(", "element", ")", ")", "{", "blocksToMove", ".", "push", "(", "findBlock", "(", "element", ".", "id", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "}" ]
this visitor is used to find blocks nested in the element being moved.
[ "this", "visitor", "is", "used", "to", "find", "blocks", "nested", "in", "the", "element", "being", "moved", "." ]
bf5e3028810a0ec7c267c6fe4bfad639b4819e35
https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/js-graph-it.js#L69-L77
971
radare/radare2
shlr/www/graph/js-graph-it.js
getStyle
function getStyle(node, styleProp) { // if not an element if( node.nodeType != 1) return; var value; if (node.currentStyle) { // ie case styleProp = replaceDashWithCamelNotation(styleProp); value = node.currentStyle[styleProp]; } else if (window.getComputedStyle) { // mozilla case value = document.defaultView.getComputedStyle(node, null).getPropertyValue(styleProp); } return value; }
javascript
function getStyle(node, styleProp) { // if not an element if( node.nodeType != 1) return; var value; if (node.currentStyle) { // ie case styleProp = replaceDashWithCamelNotation(styleProp); value = node.currentStyle[styleProp]; } else if (window.getComputedStyle) { // mozilla case value = document.defaultView.getComputedStyle(node, null).getPropertyValue(styleProp); } return value; }
[ "function", "getStyle", "(", "node", ",", "styleProp", ")", "{", "// if not an element", "if", "(", "node", ".", "nodeType", "!=", "1", ")", "return", ";", "var", "value", ";", "if", "(", "node", ".", "currentStyle", ")", "{", "// ie case", "styleProp", "=", "replaceDashWithCamelNotation", "(", "styleProp", ")", ";", "value", "=", "node", ".", "currentStyle", "[", "styleProp", "]", ";", "}", "else", "if", "(", "window", ".", "getComputedStyle", ")", "{", "// mozilla case", "value", "=", "document", ".", "defaultView", ".", "getComputedStyle", "(", "node", ",", "null", ")", ".", "getPropertyValue", "(", "styleProp", ")", ";", "}", "return", "value", ";", "}" ]
This function retrieves the actual value of a style property even if it is set via css.
[ "This", "function", "retrieves", "the", "actual", "value", "of", "a", "style", "property", "even", "if", "it", "is", "set", "via", "css", "." ]
bf5e3028810a0ec7c267c6fe4bfad639b4819e35
https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/js-graph-it.js#L1262-L1278
972
radare/radare2
shlr/www/graph/index.js
resizeCanvas
function resizeCanvas() { var divElement = document.getElementById("mainCanvas"); var screenHeight = window.innerHeight || document.body.offsetHeight; divElement.style.height = (screenHeight - 16) + "px"; }
javascript
function resizeCanvas() { var divElement = document.getElementById("mainCanvas"); var screenHeight = window.innerHeight || document.body.offsetHeight; divElement.style.height = (screenHeight - 16) + "px"; }
[ "function", "resizeCanvas", "(", ")", "{", "var", "divElement", "=", "document", ".", "getElementById", "(", "\"mainCanvas\"", ")", ";", "var", "screenHeight", "=", "window", ".", "innerHeight", "||", "document", ".", "body", ".", "offsetHeight", ";", "divElement", ".", "style", ".", "height", "=", "(", "screenHeight", "-", "16", ")", "+", "\"px\"", ";", "}" ]
Resizes the main canvas to the maximum visible height.
[ "Resizes", "the", "main", "canvas", "to", "the", "maximum", "visible", "height", "." ]
bf5e3028810a0ec7c267c6fe4bfad639b4819e35
https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/index.js#L36-L40
973
radare/radare2
shlr/www/graph/index.js
setMenu
function setMenu() { var url = document.location.href; // strip extension url = stripExtension(url); var ulElement = document.getElementById("menu"); var links = ulElement.getElementsByTagName("A"); var i; for(i = 0; i < links.length; i++) { if(url.indexOf(stripExtension(links[i].href)) == 0) { links[i].className = "active_menu"; return; } } }
javascript
function setMenu() { var url = document.location.href; // strip extension url = stripExtension(url); var ulElement = document.getElementById("menu"); var links = ulElement.getElementsByTagName("A"); var i; for(i = 0; i < links.length; i++) { if(url.indexOf(stripExtension(links[i].href)) == 0) { links[i].className = "active_menu"; return; } } }
[ "function", "setMenu", "(", ")", "{", "var", "url", "=", "document", ".", "location", ".", "href", ";", "// strip extension", "url", "=", "stripExtension", "(", "url", ")", ";", "var", "ulElement", "=", "document", ".", "getElementById", "(", "\"menu\"", ")", ";", "var", "links", "=", "ulElement", ".", "getElementsByTagName", "(", "\"A\"", ")", ";", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "links", ".", "length", ";", "i", "++", ")", "{", "if", "(", "url", ".", "indexOf", "(", "stripExtension", "(", "links", "[", "i", "]", ".", "href", ")", ")", "==", "0", ")", "{", "links", "[", "i", "]", ".", "className", "=", "\"active_menu\"", ";", "return", ";", "}", "}", "}" ]
sets the active menu scanning for a menu item which url is a prefix of the one of the current page ignoring file extension. Nice trick!
[ "sets", "the", "active", "menu", "scanning", "for", "a", "menu", "item", "which", "url", "is", "a", "prefix", "of", "the", "one", "of", "the", "current", "page", "ignoring", "file", "extension", ".", "Nice", "trick!" ]
bf5e3028810a0ec7c267c6fe4bfad639b4819e35
https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/index.js#L47-L61
974
radare/radare2
shlr/www/graph/index.js
stripExtension
function stripExtension(url) { var lastDotPos = url.lastIndexOf('.'); return (lastDotPos <= 0)? url: url.substring (0, lastDotPos - 1); }
javascript
function stripExtension(url) { var lastDotPos = url.lastIndexOf('.'); return (lastDotPos <= 0)? url: url.substring (0, lastDotPos - 1); }
[ "function", "stripExtension", "(", "url", ")", "{", "var", "lastDotPos", "=", "url", ".", "lastIndexOf", "(", "'.'", ")", ";", "return", "(", "lastDotPos", "<=", "0", ")", "?", "url", ":", "url", ".", "substring", "(", "0", ",", "lastDotPos", "-", "1", ")", ";", "}" ]
Strips the file extension and everything after from a url
[ "Strips", "the", "file", "extension", "and", "everything", "after", "from", "a", "url" ]
bf5e3028810a0ec7c267c6fe4bfad639b4819e35
https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/index.js#L66-L70
975
knsv/mermaid
src/diagrams/git/gitGraphRenderer.js
getElementCoords
function getElementCoords (element, coords) { coords = coords || element.node().getBBox() const ctm = element.node().getCTM() const xn = ctm.e + coords.x * ctm.a const yn = ctm.f + coords.y * ctm.d return { left: xn, top: yn, width: coords.width, height: coords.height } }
javascript
function getElementCoords (element, coords) { coords = coords || element.node().getBBox() const ctm = element.node().getCTM() const xn = ctm.e + coords.x * ctm.a const yn = ctm.f + coords.y * ctm.d return { left: xn, top: yn, width: coords.width, height: coords.height } }
[ "function", "getElementCoords", "(", "element", ",", "coords", ")", "{", "coords", "=", "coords", "||", "element", ".", "node", "(", ")", ".", "getBBox", "(", ")", "const", "ctm", "=", "element", ".", "node", "(", ")", ".", "getCTM", "(", ")", "const", "xn", "=", "ctm", ".", "e", "+", "coords", ".", "x", "*", "ctm", ".", "a", "const", "yn", "=", "ctm", ".", "f", "+", "coords", ".", "y", "*", "ctm", ".", "d", "return", "{", "left", ":", "xn", ",", "top", ":", "yn", ",", "width", ":", "coords", ".", "width", ",", "height", ":", "coords", ".", "height", "}", "}" ]
Pass in the element and its pre-transform coords
[ "Pass", "in", "the", "element", "and", "its", "pre", "-", "transform", "coords" ]
7d3578b31aeea3bc9bbc618dcda57d82574eaffb
https://github.com/knsv/mermaid/blob/7d3578b31aeea3bc9bbc618dcda57d82574eaffb/src/diagrams/git/gitGraphRenderer.js#L76-L87
976
youzan/vant
build/build-entry.js
buildDocsEntry
function buildDocsEntry() { const output = join('docs/src/docs-entry.js'); const getName = fullPath => fullPath.replace(/\/(en|zh)/, '.$1').split('/').pop().replace('.md', ''); const docs = glob .sync([ join('docs/**/*.md'), join('packages/**/*.md'), '!**/node_modules/**' ]) .map(fullPath => { const name = getName(fullPath); return `'${name}': () => import('${path.relative(join('docs/src'), fullPath).replace(/\\/g, '/')}')`; }); const content = `${tips} export default { ${docs.join(',\n ')} }; `; fs.writeFileSync(output, content); }
javascript
function buildDocsEntry() { const output = join('docs/src/docs-entry.js'); const getName = fullPath => fullPath.replace(/\/(en|zh)/, '.$1').split('/').pop().replace('.md', ''); const docs = glob .sync([ join('docs/**/*.md'), join('packages/**/*.md'), '!**/node_modules/**' ]) .map(fullPath => { const name = getName(fullPath); return `'${name}': () => import('${path.relative(join('docs/src'), fullPath).replace(/\\/g, '/')}')`; }); const content = `${tips} export default { ${docs.join(',\n ')} }; `; fs.writeFileSync(output, content); }
[ "function", "buildDocsEntry", "(", ")", "{", "const", "output", "=", "join", "(", "'docs/src/docs-entry.js'", ")", ";", "const", "getName", "=", "fullPath", "=>", "fullPath", ".", "replace", "(", "/", "\\/(en|zh)", "/", ",", "'.$1'", ")", ".", "split", "(", "'/'", ")", ".", "pop", "(", ")", ".", "replace", "(", "'.md'", ",", "''", ")", ";", "const", "docs", "=", "glob", ".", "sync", "(", "[", "join", "(", "'docs/**/*.md'", ")", ",", "join", "(", "'packages/**/*.md'", ")", ",", "'!**/node_modules/**'", "]", ")", ".", "map", "(", "fullPath", "=>", "{", "const", "name", "=", "getName", "(", "fullPath", ")", ";", "return", "`", "${", "name", "}", "${", "path", ".", "relative", "(", "join", "(", "'docs/src'", ")", ",", "fullPath", ")", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'/'", ")", "}", "`", ";", "}", ")", ";", "const", "content", "=", "`", "${", "tips", "}", "${", "docs", ".", "join", "(", "',\\n '", ")", "}", "`", ";", "fs", ".", "writeFileSync", "(", "output", ",", "content", ")", ";", "}" ]
generate webpack entry file for markdown docs
[ "generate", "webpack", "entry", "file", "for", "markdown", "docs" ]
21589c9b9fd70b750deed1d31226b8d2c74d62c0
https://github.com/youzan/vant/blob/21589c9b9fd70b750deed1d31226b8d2c74d62c0/build/build-entry.js#L82-L102
977
youzan/vant
build/build-style-entry.js
analyzeDependencies
function analyzeDependencies(component) { const checkList = ['base']; search( dependencyTree({ directory: dir, filename: path.join(dir, component, 'index.js'), filter: path => !~path.indexOf('node_modules') }), component, checkList ); if (!whiteList.includes(component)) { checkList.push(component); } return checkList.filter(item => checkComponentHasStyle(item)); }
javascript
function analyzeDependencies(component) { const checkList = ['base']; search( dependencyTree({ directory: dir, filename: path.join(dir, component, 'index.js'), filter: path => !~path.indexOf('node_modules') }), component, checkList ); if (!whiteList.includes(component)) { checkList.push(component); } return checkList.filter(item => checkComponentHasStyle(item)); }
[ "function", "analyzeDependencies", "(", "component", ")", "{", "const", "checkList", "=", "[", "'base'", "]", ";", "search", "(", "dependencyTree", "(", "{", "directory", ":", "dir", ",", "filename", ":", "path", ".", "join", "(", "dir", ",", "component", ",", "'index.js'", ")", ",", "filter", ":", "path", "=>", "!", "~", "path", ".", "indexOf", "(", "'node_modules'", ")", "}", ")", ",", "component", ",", "checkList", ")", ";", "if", "(", "!", "whiteList", ".", "includes", "(", "component", ")", ")", "{", "checkList", ".", "push", "(", "component", ")", ";", "}", "return", "checkList", ".", "filter", "(", "item", "=>", "checkComponentHasStyle", "(", "item", ")", ")", ";", "}" ]
analyze component dependencies
[ "analyze", "component", "dependencies" ]
21589c9b9fd70b750deed1d31226b8d2c74d62c0
https://github.com/youzan/vant/blob/21589c9b9fd70b750deed1d31226b8d2c74d62c0/build/build-style-entry.js#L42-L60
978
youzan/vant
build/build-style.js
compile
async function compile() { let codes; const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true }); codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8'))); codes = await compileLess(codes, paths); codes = await compilePostcss(codes, paths); codes = await compileCsso(codes); await dest(codes, paths); }
javascript
async function compile() { let codes; const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true }); codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8'))); codes = await compileLess(codes, paths); codes = await compilePostcss(codes, paths); codes = await compileCsso(codes); await dest(codes, paths); }
[ "async", "function", "compile", "(", ")", "{", "let", "codes", ";", "const", "paths", "=", "await", "glob", "(", "[", "'./es/**/*.less'", ",", "'./lib/**/*.less'", "]", ",", "{", "absolute", ":", "true", "}", ")", ";", "codes", "=", "await", "Promise", ".", "all", "(", "paths", ".", "map", "(", "path", "=>", "fs", ".", "readFile", "(", "path", ",", "'utf-8'", ")", ")", ")", ";", "codes", "=", "await", "compileLess", "(", "codes", ",", "paths", ")", ";", "codes", "=", "await", "compilePostcss", "(", "codes", ",", "paths", ")", ";", "codes", "=", "await", "compileCsso", "(", "codes", ")", ";", "await", "dest", "(", "codes", ",", "paths", ")", ";", "}" ]
compile component css
[ "compile", "component", "css" ]
21589c9b9fd70b750deed1d31226b8d2c74d62c0
https://github.com/youzan/vant/blob/21589c9b9fd70b750deed1d31226b8d2c74d62c0/build/build-style.js#L49-L59
979
Tonejs/Tone.js
Tone/component/Envelope.js
invertCurve
function invertCurve(curve){ var out = new Array(curve.length); for (var j = 0; j < curve.length; j++){ out[j] = 1 - curve[j]; } return out; }
javascript
function invertCurve(curve){ var out = new Array(curve.length); for (var j = 0; j < curve.length; j++){ out[j] = 1 - curve[j]; } return out; }
[ "function", "invertCurve", "(", "curve", ")", "{", "var", "out", "=", "new", "Array", "(", "curve", ".", "length", ")", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "curve", ".", "length", ";", "j", "++", ")", "{", "out", "[", "j", "]", "=", "1", "-", "curve", "[", "j", "]", ";", "}", "return", "out", ";", "}" ]
Invert a value curve to make it work for the release @private
[ "Invert", "a", "value", "curve", "to", "make", "it", "work", "for", "the", "release" ]
bb67e9c83d5553dfaa3c10babc147600aa14c147
https://github.com/Tonejs/Tone.js/blob/bb67e9c83d5553dfaa3c10babc147600aa14c147/Tone/component/Envelope.js#L432-L438
980
Tonejs/Tone.js
Tone/signal/TickSignal.js
_wrapScheduleMethods
function _wrapScheduleMethods(method){ return function(value, time){ time = this.toSeconds(time); method.apply(this, arguments); var event = this._events.get(time); var previousEvent = this._events.previousEvent(event); var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time); event.ticks = Math.max(ticksUntilTime, 0); return this; }; }
javascript
function _wrapScheduleMethods(method){ return function(value, time){ time = this.toSeconds(time); method.apply(this, arguments); var event = this._events.get(time); var previousEvent = this._events.previousEvent(event); var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time); event.ticks = Math.max(ticksUntilTime, 0); return this; }; }
[ "function", "_wrapScheduleMethods", "(", "method", ")", "{", "return", "function", "(", "value", ",", "time", ")", "{", "time", "=", "this", ".", "toSeconds", "(", "time", ")", ";", "method", ".", "apply", "(", "this", ",", "arguments", ")", ";", "var", "event", "=", "this", ".", "_events", ".", "get", "(", "time", ")", ";", "var", "previousEvent", "=", "this", ".", "_events", ".", "previousEvent", "(", "event", ")", ";", "var", "ticksUntilTime", "=", "this", ".", "_getTicksUntilEvent", "(", "previousEvent", ",", "time", ")", ";", "event", ".", "ticks", "=", "Math", ".", "max", "(", "ticksUntilTime", ",", "0", ")", ";", "return", "this", ";", "}", ";", "}" ]
Wraps Tone.Signal methods so that they also record the ticks. @param {Function} method @return {Function} @private
[ "Wraps", "Tone", ".", "Signal", "methods", "so", "that", "they", "also", "record", "the", "ticks", "." ]
bb67e9c83d5553dfaa3c10babc147600aa14c147
https://github.com/Tonejs/Tone.js/blob/bb67e9c83d5553dfaa3c10babc147600aa14c147/Tone/signal/TickSignal.js#L46-L56
981
keplergl/kepler.gl
src/reducers/vis-state-updaters.js
computeSplitMapLayers
function computeSplitMapLayers(layers) { const mapLayers = layers.reduce( (newLayers, currentLayer) => ({ ...newLayers, [currentLayer.id]: generateLayerMetaForSplitViews(currentLayer) }), {} ); return [ { layers: mapLayers }, { layers: mapLayers } ]; }
javascript
function computeSplitMapLayers(layers) { const mapLayers = layers.reduce( (newLayers, currentLayer) => ({ ...newLayers, [currentLayer.id]: generateLayerMetaForSplitViews(currentLayer) }), {} ); return [ { layers: mapLayers }, { layers: mapLayers } ]; }
[ "function", "computeSplitMapLayers", "(", "layers", ")", "{", "const", "mapLayers", "=", "layers", ".", "reduce", "(", "(", "newLayers", ",", "currentLayer", ")", "=>", "(", "{", "...", "newLayers", ",", "[", "currentLayer", ".", "id", "]", ":", "generateLayerMetaForSplitViews", "(", "currentLayer", ")", "}", ")", ",", "{", "}", ")", ";", "return", "[", "{", "layers", ":", "mapLayers", "}", ",", "{", "layers", ":", "mapLayers", "}", "]", ";", "}" ]
This method will compute the default maps custom list based on the current layers status @param {Array<Object>} layers @returns {Array<Object>} split map settings
[ "This", "method", "will", "compute", "the", "default", "maps", "custom", "list", "based", "on", "the", "current", "layers", "status" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/vis-state-updaters.js#L1094-L1110
982
keplergl/kepler.gl
src/reducers/vis-state-updaters.js
removeLayerFromSplitMaps
function removeLayerFromSplitMaps(state, layer) { return state.splitMaps.map(settings => { const {layers} = settings; /* eslint-disable no-unused-vars */ const {[layer.id]: _, ...newLayers} = layers; /* eslint-enable no-unused-vars */ return { ...settings, layers: newLayers }; }); }
javascript
function removeLayerFromSplitMaps(state, layer) { return state.splitMaps.map(settings => { const {layers} = settings; /* eslint-disable no-unused-vars */ const {[layer.id]: _, ...newLayers} = layers; /* eslint-enable no-unused-vars */ return { ...settings, layers: newLayers }; }); }
[ "function", "removeLayerFromSplitMaps", "(", "state", ",", "layer", ")", "{", "return", "state", ".", "splitMaps", ".", "map", "(", "settings", "=>", "{", "const", "{", "layers", "}", "=", "settings", ";", "/* eslint-disable no-unused-vars */", "const", "{", "[", "layer", ".", "id", "]", ":", "_", ",", "...", "newLayers", "}", "=", "layers", ";", "/* eslint-enable no-unused-vars */", "return", "{", "...", "settings", ",", "layers", ":", "newLayers", "}", ";", "}", ")", ";", "}" ]
Remove an existing layer from split map settings @param {Object} state `visState` @param {Object} layer @returns {Object} Maps of custom layer objects
[ "Remove", "an", "existing", "layer", "from", "split", "map", "settings" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/vis-state-updaters.js#L1118-L1129
983
keplergl/kepler.gl
src/reducers/vis-state-updaters.js
addNewLayersToSplitMap
function addNewLayersToSplitMap(splitMaps, layers) { const newLayers = Array.isArray(layers) ? layers : [layers]; if (!splitMaps || !splitMaps.length || !newLayers.length) { return splitMaps; } // add new layer to both maps, // don't override, if layer.id is already in splitMaps.settings.layers return splitMaps.map(settings => ({ ...settings, layers: { ...settings.layers, ...newLayers.reduce( (accu, newLayer) => newLayer.config.isVisible ? { ...accu, [newLayer.id]: settings.layers[newLayer.id] ? settings.layers[newLayer.id] : generateLayerMetaForSplitViews(newLayer) } : accu, {} ) } })); }
javascript
function addNewLayersToSplitMap(splitMaps, layers) { const newLayers = Array.isArray(layers) ? layers : [layers]; if (!splitMaps || !splitMaps.length || !newLayers.length) { return splitMaps; } // add new layer to both maps, // don't override, if layer.id is already in splitMaps.settings.layers return splitMaps.map(settings => ({ ...settings, layers: { ...settings.layers, ...newLayers.reduce( (accu, newLayer) => newLayer.config.isVisible ? { ...accu, [newLayer.id]: settings.layers[newLayer.id] ? settings.layers[newLayer.id] : generateLayerMetaForSplitViews(newLayer) } : accu, {} ) } })); }
[ "function", "addNewLayersToSplitMap", "(", "splitMaps", ",", "layers", ")", "{", "const", "newLayers", "=", "Array", ".", "isArray", "(", "layers", ")", "?", "layers", ":", "[", "layers", "]", ";", "if", "(", "!", "splitMaps", "||", "!", "splitMaps", ".", "length", "||", "!", "newLayers", ".", "length", ")", "{", "return", "splitMaps", ";", "}", "// add new layer to both maps,", "// don't override, if layer.id is already in splitMaps.settings.layers", "return", "splitMaps", ".", "map", "(", "settings", "=>", "(", "{", "...", "settings", ",", "layers", ":", "{", "...", "settings", ".", "layers", ",", "...", "newLayers", ".", "reduce", "(", "(", "accu", ",", "newLayer", ")", "=>", "newLayer", ".", "config", ".", "isVisible", "?", "{", "...", "accu", ",", "[", "newLayer", ".", "id", "]", ":", "settings", ".", "layers", "[", "newLayer", ".", "id", "]", "?", "settings", ".", "layers", "[", "newLayer", ".", "id", "]", ":", "generateLayerMetaForSplitViews", "(", "newLayer", ")", "}", ":", "accu", ",", "{", "}", ")", "}", "}", ")", ")", ";", "}" ]
Add new layers to both existing maps @param {Object} splitMaps @param {Object|Array<Object>} layers @returns {Array<Object>} new splitMaps
[ "Add", "new", "layers", "to", "both", "existing", "maps" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/vis-state-updaters.js#L1137-L1164
984
keplergl/kepler.gl
src/reducers/vis-state-updaters.js
toggleLayerFromSplitMaps
function toggleLayerFromSplitMaps(state, layer) { return state.splitMaps.map(settings => { const {layers} = settings; const newLayers = { ...layers, [layer.id]: generateLayerMetaForSplitViews(layer) }; return { ...settings, layers: newLayers }; }); }
javascript
function toggleLayerFromSplitMaps(state, layer) { return state.splitMaps.map(settings => { const {layers} = settings; const newLayers = { ...layers, [layer.id]: generateLayerMetaForSplitViews(layer) }; return { ...settings, layers: newLayers }; }); }
[ "function", "toggleLayerFromSplitMaps", "(", "state", ",", "layer", ")", "{", "return", "state", ".", "splitMaps", ".", "map", "(", "settings", "=>", "{", "const", "{", "layers", "}", "=", "settings", ";", "const", "newLayers", "=", "{", "...", "layers", ",", "[", "layer", ".", "id", "]", ":", "generateLayerMetaForSplitViews", "(", "layer", ")", "}", ";", "return", "{", "...", "settings", ",", "layers", ":", "newLayers", "}", ";", "}", ")", ";", "}" ]
Hide an existing layers from custom map layer objects @param {Object} state @param {Object} layer @returns {Object} Maps of custom layer objects
[ "Hide", "an", "existing", "layers", "from", "custom", "map", "layer", "objects" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/vis-state-updaters.js#L1172-L1185
985
keplergl/kepler.gl
examples/demo-app/src/utils/cloud-providers/dropbox.js
authLink
function authLink(path = 'auth') { return dropbox.getAuthenticationUrl( `${window.location.origin}/${path}`, btoa(JSON.stringify({handler: 'dropbox', origin: window.location.origin})) ) }
javascript
function authLink(path = 'auth') { return dropbox.getAuthenticationUrl( `${window.location.origin}/${path}`, btoa(JSON.stringify({handler: 'dropbox', origin: window.location.origin})) ) }
[ "function", "authLink", "(", "path", "=", "'auth'", ")", "{", "return", "dropbox", ".", "getAuthenticationUrl", "(", "`", "${", "window", ".", "location", ".", "origin", "}", "${", "path", "}", "`", ",", "btoa", "(", "JSON", ".", "stringify", "(", "{", "handler", ":", "'dropbox'", ",", "origin", ":", "window", ".", "location", ".", "origin", "}", ")", ")", ")", "}" ]
Generate auth link url to open to be used to handle OAuth2 @param {string} path
[ "Generate", "auth", "link", "url", "to", "open", "to", "be", "used", "to", "handle", "OAuth2" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/utils/cloud-providers/dropbox.js#L49-L54
986
keplergl/kepler.gl
examples/demo-app/src/utils/cloud-providers/dropbox.js
shareFile
function shareFile(metadata) { return dropbox.sharingCreateSharedLinkWithSettings({ path: metadata.path_display || metadata.path_lower }).then( // Update URL to avoid CORS issue // Unfortunately this is not the ideal scenario but it will make sure people // can share dropbox urls with users without the dropbox account (publish on twitter, facebook) result => ({ ...result, folder_link: KEPLER_DROPBOX_FOLDER_LINK, url: overrideUrl(result.url) }) ); }
javascript
function shareFile(metadata) { return dropbox.sharingCreateSharedLinkWithSettings({ path: metadata.path_display || metadata.path_lower }).then( // Update URL to avoid CORS issue // Unfortunately this is not the ideal scenario but it will make sure people // can share dropbox urls with users without the dropbox account (publish on twitter, facebook) result => ({ ...result, folder_link: KEPLER_DROPBOX_FOLDER_LINK, url: overrideUrl(result.url) }) ); }
[ "function", "shareFile", "(", "metadata", ")", "{", "return", "dropbox", ".", "sharingCreateSharedLinkWithSettings", "(", "{", "path", ":", "metadata", ".", "path_display", "||", "metadata", ".", "path_lower", "}", ")", ".", "then", "(", "// Update URL to avoid CORS issue", "// Unfortunately this is not the ideal scenario but it will make sure people", "// can share dropbox urls with users without the dropbox account (publish on twitter, facebook)", "result", "=>", "(", "{", "...", "result", ",", "folder_link", ":", "KEPLER_DROPBOX_FOLDER_LINK", ",", "url", ":", "overrideUrl", "(", "result", ".", "url", ")", "}", ")", ")", ";", "}" ]
It will set access to file to public @param {Object} metadata metadata response from uploading the file @returns {Promise<DropboxTypes.sharing.FileLinkMetadataReference | DropboxTypes.sharing.FolderLinkMetadataReference | DropboxTypes.sharing.SharedLinkMetadataReference>}
[ "It", "will", "set", "access", "to", "file", "to", "public" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/utils/cloud-providers/dropbox.js#L92-L105
987
keplergl/kepler.gl
examples/demo-app/src/utils/cloud-providers/dropbox.js
getAccessToken
function getAccessToken() { let token = dropbox.getAccessToken(); if (!token && window.localStorage) { const jsonString = window.localStorage.getItem('dropbox'); token = jsonString && JSON.parse(jsonString).token; if (token) { dropbox.setAccessToken(token); } } return (token || '') !== '' ? token : null; }
javascript
function getAccessToken() { let token = dropbox.getAccessToken(); if (!token && window.localStorage) { const jsonString = window.localStorage.getItem('dropbox'); token = jsonString && JSON.parse(jsonString).token; if (token) { dropbox.setAccessToken(token); } } return (token || '') !== '' ? token : null; }
[ "function", "getAccessToken", "(", ")", "{", "let", "token", "=", "dropbox", ".", "getAccessToken", "(", ")", ";", "if", "(", "!", "token", "&&", "window", ".", "localStorage", ")", "{", "const", "jsonString", "=", "window", ".", "localStorage", ".", "getItem", "(", "'dropbox'", ")", ";", "token", "=", "jsonString", "&&", "JSON", ".", "parse", "(", "jsonString", ")", ".", "token", ";", "if", "(", "token", ")", "{", "dropbox", ".", "setAccessToken", "(", "token", ")", ";", "}", "}", "return", "(", "token", "||", "''", ")", "!==", "''", "?", "token", ":", "null", ";", "}" ]
Provides the current dropbox auth token. If stored in localStorage is set onto dropbox handler and returned @returns {any}
[ "Provides", "the", "current", "dropbox", "auth", "token", ".", "If", "stored", "in", "localStorage", "is", "set", "onto", "dropbox", "handler", "and", "returned" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/utils/cloud-providers/dropbox.js#L150-L161
988
keplergl/kepler.gl
scripts/documentation.js
_appendActionToUpdaters
function _appendActionToUpdaters(node, actionMap) { if (node.members && node.members.static.length) { node.members.static = node.members.static.map(nd => _appendActionToUpdaters(nd, actionMap)); } const updater = node.name; const action = Object.values(actionMap) .find(action => action.updaters.find(up => up.name === updater)); if (!action) { return node; } const actionName = action.name; const mdContent = ` * __Action__: [${BT}${actionName}${BT}](../actions/actions.md#${actionName.toLowerCase()}) `; return _appendListToDescription(node, mdContent); }
javascript
function _appendActionToUpdaters(node, actionMap) { if (node.members && node.members.static.length) { node.members.static = node.members.static.map(nd => _appendActionToUpdaters(nd, actionMap)); } const updater = node.name; const action = Object.values(actionMap) .find(action => action.updaters.find(up => up.name === updater)); if (!action) { return node; } const actionName = action.name; const mdContent = ` * __Action__: [${BT}${actionName}${BT}](../actions/actions.md#${actionName.toLowerCase()}) `; return _appendListToDescription(node, mdContent); }
[ "function", "_appendActionToUpdaters", "(", "node", ",", "actionMap", ")", "{", "if", "(", "node", ".", "members", "&&", "node", ".", "members", ".", "static", ".", "length", ")", "{", "node", ".", "members", ".", "static", "=", "node", ".", "members", ".", "static", ".", "map", "(", "nd", "=>", "_appendActionToUpdaters", "(", "nd", ",", "actionMap", ")", ")", ";", "}", "const", "updater", "=", "node", ".", "name", ";", "const", "action", "=", "Object", ".", "values", "(", "actionMap", ")", ".", "find", "(", "action", "=>", "action", ".", "updaters", ".", "find", "(", "up", "=>", "up", ".", "name", "===", "updater", ")", ")", ";", "if", "(", "!", "action", ")", "{", "return", "node", ";", "}", "const", "actionName", "=", "action", ".", "name", ";", "const", "mdContent", "=", "`", "${", "BT", "}", "${", "actionName", "}", "${", "BT", "}", "${", "actionName", ".", "toLowerCase", "(", ")", "}", "`", ";", "return", "_appendListToDescription", "(", "node", ",", "mdContent", ")", ";", "}" ]
Add action to linked updaters @param {Object} node @param {Object} actionMap
[ "Add", "action", "to", "linked", "updaters" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/scripts/documentation.js#L143-L163
989
keplergl/kepler.gl
scripts/documentation.js
_cleanUpTOCChildren
function _cleanUpTOCChildren(node) { if (!Array.isArray(node.children)) { return node; } if (_isExampleOrParameterLink(node)) { return null; } const filteredChildren = node.children.reduce((accu, nd) => { accu.push(_cleanUpTOCChildren(nd)); return accu; }, []).filter(n => n); if (!filteredChildren.length) { return null; } return { ...node, children: filteredChildren }; }
javascript
function _cleanUpTOCChildren(node) { if (!Array.isArray(node.children)) { return node; } if (_isExampleOrParameterLink(node)) { return null; } const filteredChildren = node.children.reduce((accu, nd) => { accu.push(_cleanUpTOCChildren(nd)); return accu; }, []).filter(n => n); if (!filteredChildren.length) { return null; } return { ...node, children: filteredChildren }; }
[ "function", "_cleanUpTOCChildren", "(", "node", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "node", ".", "children", ")", ")", "{", "return", "node", ";", "}", "if", "(", "_isExampleOrParameterLink", "(", "node", ")", ")", "{", "return", "null", ";", "}", "const", "filteredChildren", "=", "node", ".", "children", ".", "reduce", "(", "(", "accu", ",", "nd", ")", "=>", "{", "accu", ".", "push", "(", "_cleanUpTOCChildren", "(", "nd", ")", ")", ";", "return", "accu", ";", "}", ",", "[", "]", ")", ".", "filter", "(", "n", "=>", "n", ")", ";", "if", "(", "!", "filteredChildren", ".", "length", ")", "{", "return", "null", ";", "}", "return", "{", "...", "node", ",", "children", ":", "filteredChildren", "}", ";", "}" ]
Remove example and parameter link from TOC
[ "Remove", "example", "and", "parameter", "link", "from", "TOC" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/scripts/documentation.js#L204-L227
990
keplergl/kepler.gl
src/schemas/vis-state-schema.js
geojsonSizeFieldV0ToV1
function geojsonSizeFieldV0ToV1(config) { const defaultRaiuds = 10; const defaultRadiusRange = [0, 50]; // if extruded, sizeField is most likely used for height if (config.visConfig.extruded) { return 'heightField'; } // if show stroke enabled, sizeField is most likely used for stroke if (config.visConfig.stroked) { return 'sizeField'; } // if radius changed, or radius Range Changed, sizeField is most likely used for radius // this is the most unreliable guess, that's why we put it in the end if ( config.visConfig.radius !== defaultRaiuds || config.visConfig.radiusRange.some((d, i) => d !== defaultRadiusRange[i]) ) { return 'radiusField'; } return 'sizeField'; }
javascript
function geojsonSizeFieldV0ToV1(config) { const defaultRaiuds = 10; const defaultRadiusRange = [0, 50]; // if extruded, sizeField is most likely used for height if (config.visConfig.extruded) { return 'heightField'; } // if show stroke enabled, sizeField is most likely used for stroke if (config.visConfig.stroked) { return 'sizeField'; } // if radius changed, or radius Range Changed, sizeField is most likely used for radius // this is the most unreliable guess, that's why we put it in the end if ( config.visConfig.radius !== defaultRaiuds || config.visConfig.radiusRange.some((d, i) => d !== defaultRadiusRange[i]) ) { return 'radiusField'; } return 'sizeField'; }
[ "function", "geojsonSizeFieldV0ToV1", "(", "config", ")", "{", "const", "defaultRaiuds", "=", "10", ";", "const", "defaultRadiusRange", "=", "[", "0", ",", "50", "]", ";", "// if extruded, sizeField is most likely used for height", "if", "(", "config", ".", "visConfig", ".", "extruded", ")", "{", "return", "'heightField'", ";", "}", "// if show stroke enabled, sizeField is most likely used for stroke", "if", "(", "config", ".", "visConfig", ".", "stroked", ")", "{", "return", "'sizeField'", ";", "}", "// if radius changed, or radius Range Changed, sizeField is most likely used for radius", "// this is the most unreliable guess, that's why we put it in the end", "if", "(", "config", ".", "visConfig", ".", "radius", "!==", "defaultRaiuds", "||", "config", ".", "visConfig", ".", "radiusRange", ".", "some", "(", "(", "d", ",", "i", ")", "=>", "d", "!==", "defaultRadiusRange", "[", "i", "]", ")", ")", "{", "return", "'radiusField'", ";", "}", "return", "'sizeField'", ";", "}" ]
in v1 geojson stroke base on -> sizeField height based on -> heightField radius based on -> radiusField here we make our wiredst guess on which channel sizeField belongs to
[ "in", "v1", "geojson", "stroke", "base", "on", "-", ">", "sizeField", "height", "based", "on", "-", ">", "heightField", "radius", "based", "on", "-", ">", "radiusField", "here", "we", "make", "our", "wiredst", "guess", "on", "which", "channel", "sizeField", "belongs", "to" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/schemas/vis-state-schema.js#L40-L64
991
keplergl/kepler.gl
src/components/kepler-gl.js
mergeActions
function mergeActions(actions, userActions) { const overrides = {}; for (const key in userActions) { if (userActions.hasOwnProperty(key) && actions.hasOwnProperty(key)) { overrides[key] = userActions[key]; } } return {...actions, ...overrides}; }
javascript
function mergeActions(actions, userActions) { const overrides = {}; for (const key in userActions) { if (userActions.hasOwnProperty(key) && actions.hasOwnProperty(key)) { overrides[key] = userActions[key]; } } return {...actions, ...overrides}; }
[ "function", "mergeActions", "(", "actions", ",", "userActions", ")", "{", "const", "overrides", "=", "{", "}", ";", "for", "(", "const", "key", "in", "userActions", ")", "{", "if", "(", "userActions", ".", "hasOwnProperty", "(", "key", ")", "&&", "actions", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "overrides", "[", "key", "]", "=", "userActions", "[", "key", "]", ";", "}", "}", "return", "{", "...", "actions", ",", "...", "overrides", "}", ";", "}" ]
Override default maps-gl actions with user defined actions using the same key
[ "Override", "default", "maps", "-", "gl", "actions", "with", "user", "defined", "actions", "using", "the", "same", "key" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/components/kepler-gl.js#L374-L383
992
keplergl/kepler.gl
examples/demo-app/src/actions.js
loadRemoteRawData
function loadRemoteRawData(url) { if (!url) { // TODO: we should return reject with an appropriate error return Promise.resolve(null) } return new Promise((resolve, reject) => { request(url, (error, result) => { if (error) { reject(error); } const responseError = detectResponseError(result); if (responseError) { reject(responseError); return; } resolve(result.response) }) }); }
javascript
function loadRemoteRawData(url) { if (!url) { // TODO: we should return reject with an appropriate error return Promise.resolve(null) } return new Promise((resolve, reject) => { request(url, (error, result) => { if (error) { reject(error); } const responseError = detectResponseError(result); if (responseError) { reject(responseError); return; } resolve(result.response) }) }); }
[ "function", "loadRemoteRawData", "(", "url", ")", "{", "if", "(", "!", "url", ")", "{", "// TODO: we should return reject with an appropriate error", "return", "Promise", ".", "resolve", "(", "null", ")", "}", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "request", "(", "url", ",", "(", "error", ",", "result", ")", "=>", "{", "if", "(", "error", ")", "{", "reject", "(", "error", ")", ";", "}", "const", "responseError", "=", "detectResponseError", "(", "result", ")", ";", "if", "(", "responseError", ")", "{", "reject", "(", "responseError", ")", ";", "return", ";", "}", "resolve", "(", "result", ".", "response", ")", "}", ")", "}", ")", ";", "}" ]
Load a file from a remote URL @param url @returns {Promise<any>}
[ "Load", "a", "file", "from", "a", "remote", "URL" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/actions.js#L165-L184
993
keplergl/kepler.gl
examples/demo-app/src/actions.js
loadRemoteSampleMap
function loadRemoteSampleMap(options) { return (dispatch) => { // Load configuration first const {configUrl, dataUrl} = options; Promise .all([loadRemoteConfig(configUrl), loadRemoteData(dataUrl)]) .then( ([config, data]) => { // TODO: these two actions can be merged dispatch(loadRemoteResourceSuccess(data, config, options)); dispatch(toggleModal(null)); }, error => { if (error) { const {target = {}} = error; const {status, responseText} = target; dispatch(loadRemoteResourceError({status, message: `${responseText} - ${LOADING_SAMPLE_ERROR_MESSAGE} ${options.id} (${configUrl})`}, configUrl)); } } ); } }
javascript
function loadRemoteSampleMap(options) { return (dispatch) => { // Load configuration first const {configUrl, dataUrl} = options; Promise .all([loadRemoteConfig(configUrl), loadRemoteData(dataUrl)]) .then( ([config, data]) => { // TODO: these two actions can be merged dispatch(loadRemoteResourceSuccess(data, config, options)); dispatch(toggleModal(null)); }, error => { if (error) { const {target = {}} = error; const {status, responseText} = target; dispatch(loadRemoteResourceError({status, message: `${responseText} - ${LOADING_SAMPLE_ERROR_MESSAGE} ${options.id} (${configUrl})`}, configUrl)); } } ); } }
[ "function", "loadRemoteSampleMap", "(", "options", ")", "{", "return", "(", "dispatch", ")", "=>", "{", "// Load configuration first", "const", "{", "configUrl", ",", "dataUrl", "}", "=", "options", ";", "Promise", ".", "all", "(", "[", "loadRemoteConfig", "(", "configUrl", ")", ",", "loadRemoteData", "(", "dataUrl", ")", "]", ")", ".", "then", "(", "(", "[", "config", ",", "data", "]", ")", "=>", "{", "// TODO: these two actions can be merged", "dispatch", "(", "loadRemoteResourceSuccess", "(", "data", ",", "config", ",", "options", ")", ")", ";", "dispatch", "(", "toggleModal", "(", "null", ")", ")", ";", "}", ",", "error", "=>", "{", "if", "(", "error", ")", "{", "const", "{", "target", "=", "{", "}", "}", "=", "error", ";", "const", "{", "status", ",", "responseText", "}", "=", "target", ";", "dispatch", "(", "loadRemoteResourceError", "(", "{", "status", ",", "message", ":", "`", "${", "responseText", "}", "${", "LOADING_SAMPLE_ERROR_MESSAGE", "}", "${", "options", ".", "id", "}", "${", "configUrl", "}", "`", "}", ",", "configUrl", ")", ")", ";", "}", "}", ")", ";", "}", "}" ]
Load remote map with config and data @param options {configUrl, dataUrl} @returns {Function}
[ "Load", "remote", "map", "with", "config", "and", "data" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/actions.js#L223-L245
994
keplergl/kepler.gl
scripts/action-table-maker.js
addActionHandler
function addActionHandler(path, actionMap, filePath) { const {init} = path.node; if (init && Array.isArray(init.properties)) { init.properties.forEach(property => { const {key, value} = property; if (key && value && key.property && value.property) { const actionType = key.property.name; const updater = value.name; actionMap[actionType] = actionMap[actionType] || createActionNode(actionType); actionMap[actionType].updaters.push({ updater: value.object.name, name: value.property.name, path: filePath }); } }) } }
javascript
function addActionHandler(path, actionMap, filePath) { const {init} = path.node; if (init && Array.isArray(init.properties)) { init.properties.forEach(property => { const {key, value} = property; if (key && value && key.property && value.property) { const actionType = key.property.name; const updater = value.name; actionMap[actionType] = actionMap[actionType] || createActionNode(actionType); actionMap[actionType].updaters.push({ updater: value.object.name, name: value.property.name, path: filePath }); } }) } }
[ "function", "addActionHandler", "(", "path", ",", "actionMap", ",", "filePath", ")", "{", "const", "{", "init", "}", "=", "path", ".", "node", ";", "if", "(", "init", "&&", "Array", ".", "isArray", "(", "init", ".", "properties", ")", ")", "{", "init", ".", "properties", ".", "forEach", "(", "property", "=>", "{", "const", "{", "key", ",", "value", "}", "=", "property", ";", "if", "(", "key", "&&", "value", "&&", "key", ".", "property", "&&", "value", ".", "property", ")", "{", "const", "actionType", "=", "key", ".", "property", ".", "name", ";", "const", "updater", "=", "value", ".", "name", ";", "actionMap", "[", "actionType", "]", "=", "actionMap", "[", "actionType", "]", "||", "createActionNode", "(", "actionType", ")", ";", "actionMap", "[", "actionType", "]", ".", "updaters", ".", "push", "(", "{", "updater", ":", "value", ".", "object", ".", "name", ",", "name", ":", "value", ".", "property", ".", "name", ",", "path", ":", "filePath", "}", ")", ";", "}", "}", ")", "}", "}" ]
Parse actionHandler declaration to map updater to action type @param {Object} path - AST node @param {Object} actionMap @param {string} filePath
[ "Parse", "actionHandler", "declaration", "to", "map", "updater", "to", "action", "type" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/scripts/action-table-maker.js#L71-L91
995
keplergl/kepler.gl
scripts/action-table-maker.js
addActionCreator
function addActionCreator(path, actionMap, filePath) { const {node, parentPath} = path; if (node.arguments.length && parentPath.node && parentPath.node.id) { const action = parentPath.node.id.name; const firstArg = node.arguments[0]; const actionType = firstArg.property ? firstArg.property.name : firstArg.name; const {loc} = parentPath.node actionMap[actionType] = actionMap[actionType] || createActionNode(actionType); actionMap[actionType].action = {name: action, path: `${filePath}#L${loc.start.line}-L${loc.end.line}`}; } }
javascript
function addActionCreator(path, actionMap, filePath) { const {node, parentPath} = path; if (node.arguments.length && parentPath.node && parentPath.node.id) { const action = parentPath.node.id.name; const firstArg = node.arguments[0]; const actionType = firstArg.property ? firstArg.property.name : firstArg.name; const {loc} = parentPath.node actionMap[actionType] = actionMap[actionType] || createActionNode(actionType); actionMap[actionType].action = {name: action, path: `${filePath}#L${loc.start.line}-L${loc.end.line}`}; } }
[ "function", "addActionCreator", "(", "path", ",", "actionMap", ",", "filePath", ")", "{", "const", "{", "node", ",", "parentPath", "}", "=", "path", ";", "if", "(", "node", ".", "arguments", ".", "length", "&&", "parentPath", ".", "node", "&&", "parentPath", ".", "node", ".", "id", ")", "{", "const", "action", "=", "parentPath", ".", "node", ".", "id", ".", "name", ";", "const", "firstArg", "=", "node", ".", "arguments", "[", "0", "]", ";", "const", "actionType", "=", "firstArg", ".", "property", "?", "firstArg", ".", "property", ".", "name", ":", "firstArg", ".", "name", ";", "const", "{", "loc", "}", "=", "parentPath", ".", "node", "actionMap", "[", "actionType", "]", "=", "actionMap", "[", "actionType", "]", "||", "createActionNode", "(", "actionType", ")", ";", "actionMap", "[", "actionType", "]", ".", "action", "=", "{", "name", ":", "action", ",", "path", ":", "`", "${", "filePath", "}", "${", "loc", ".", "start", ".", "line", "}", "${", "loc", ".", "end", ".", "line", "}", "`", "}", ";", "}", "}" ]
Parse createAction function to add action to action type @param {*} path @param {*} actionMap @param {*} filePath
[ "Parse", "createAction", "function", "to", "add", "action", "to", "action", "type" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/scripts/action-table-maker.js#L99-L112
996
keplergl/kepler.gl
src/utils/filter-utils.js
getHistogram
function getHistogram(domain, mappedValue) { const histogram = histogramConstruct(domain, mappedValue, histogramBins); const enlargedHistogram = histogramConstruct( domain, mappedValue, enlargedHistogramBins ); return {histogram, enlargedHistogram}; }
javascript
function getHistogram(domain, mappedValue) { const histogram = histogramConstruct(domain, mappedValue, histogramBins); const enlargedHistogram = histogramConstruct( domain, mappedValue, enlargedHistogramBins ); return {histogram, enlargedHistogram}; }
[ "function", "getHistogram", "(", "domain", ",", "mappedValue", ")", "{", "const", "histogram", "=", "histogramConstruct", "(", "domain", ",", "mappedValue", ",", "histogramBins", ")", ";", "const", "enlargedHistogram", "=", "histogramConstruct", "(", "domain", ",", "mappedValue", ",", "enlargedHistogramBins", ")", ";", "return", "{", "histogram", ",", "enlargedHistogram", "}", ";", "}" ]
Calculate histogram from domain and array of values @param {number[]} domain @param {Object[]} mappedValue @returns {Array[]} histogram
[ "Calculate", "histogram", "from", "domain", "and", "array", "of", "values" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/utils/filter-utils.js#L457-L466
997
keplergl/kepler.gl
src/deckgl-layers/3d-building-layer/3d-building-utils.js
classifyRings
function classifyRings(rings) { const len = rings.length; if (len <= 1) return [rings]; const polygons = []; let polygon; let ccw; for (let i = 0; i < len; i++) { const area = signedArea(rings[i]); if (area === 0) { continue; } if (ccw === undefined) { ccw = area < 0; } if (ccw === area < 0) { if (polygon) { polygons.push(polygon); } polygon = [rings[i]]; } else { polygon.push(rings[i]); } } if (polygon) { polygons.push(polygon); } return polygons; }
javascript
function classifyRings(rings) { const len = rings.length; if (len <= 1) return [rings]; const polygons = []; let polygon; let ccw; for (let i = 0; i < len; i++) { const area = signedArea(rings[i]); if (area === 0) { continue; } if (ccw === undefined) { ccw = area < 0; } if (ccw === area < 0) { if (polygon) { polygons.push(polygon); } polygon = [rings[i]]; } else { polygon.push(rings[i]); } } if (polygon) { polygons.push(polygon); } return polygons; }
[ "function", "classifyRings", "(", "rings", ")", "{", "const", "len", "=", "rings", ".", "length", ";", "if", "(", "len", "<=", "1", ")", "return", "[", "rings", "]", ";", "const", "polygons", "=", "[", "]", ";", "let", "polygon", ";", "let", "ccw", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "const", "area", "=", "signedArea", "(", "rings", "[", "i", "]", ")", ";", "if", "(", "area", "===", "0", ")", "{", "continue", ";", "}", "if", "(", "ccw", "===", "undefined", ")", "{", "ccw", "=", "area", "<", "0", ";", "}", "if", "(", "ccw", "===", "area", "<", "0", ")", "{", "if", "(", "polygon", ")", "{", "polygons", ".", "push", "(", "polygon", ")", ";", "}", "polygon", "=", "[", "rings", "[", "i", "]", "]", ";", "}", "else", "{", "polygon", ".", "push", "(", "rings", "[", "i", "]", ")", ";", "}", "}", "if", "(", "polygon", ")", "{", "polygons", ".", "push", "(", "polygon", ")", ";", "}", "return", "polygons", ";", "}" ]
classifies an array of rings into polygons with outer rings and holes
[ "classifies", "an", "array", "of", "rings", "into", "polygons", "with", "outer", "rings", "and", "holes" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/deckgl-layers/3d-building-layer/3d-building-utils.js#L148-L181
998
keplergl/kepler.gl
examples/replace-component/src/components/side-bar.js
CustomSidebarFactory
function CustomSidebarFactory(CloseButton) { const SideBar = SidebarFactory(CloseButton); const CustomSidebar = (props) => ( <StyledSideBarContainer> <SideBar {...props}/> </StyledSideBarContainer> ); return CustomSidebar; }
javascript
function CustomSidebarFactory(CloseButton) { const SideBar = SidebarFactory(CloseButton); const CustomSidebar = (props) => ( <StyledSideBarContainer> <SideBar {...props}/> </StyledSideBarContainer> ); return CustomSidebar; }
[ "function", "CustomSidebarFactory", "(", "CloseButton", ")", "{", "const", "SideBar", "=", "SidebarFactory", "(", "CloseButton", ")", ";", "const", "CustomSidebar", "=", "(", "props", ")", "=>", "(", "<", "StyledSideBarContainer", ">", "\n ", "<", "SideBar", "{", "...", "props", "}", "/", ">", "\n ", "<", "/", "StyledSideBarContainer", ">", ")", ";", "return", "CustomSidebar", ";", "}" ]
Custom sidebar will render kepler.gl default side bar adding a wrapper component to edit its style
[ "Custom", "sidebar", "will", "render", "kepler", ".", "gl", "default", "side", "bar", "adding", "a", "wrapper", "component", "to", "edit", "its", "style" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/replace-component/src/components/side-bar.js#L72-L80
999
keplergl/kepler.gl
src/processors/data-processor.js
cleanUpFalsyCsvValue
function cleanUpFalsyCsvValue(rows) { for (let i = 0; i < rows.length; i++) { for (let j = 0; j < rows[i].length; j++) { // analyzer will set any fields to 'string' if there are empty values // which will be parsed as '' by d3.csv // here we parse empty data as null // TODO: create warning when deltect `CSV_NULLS` in the data if (!rows[i][j] || CSV_NULLS.includes(rows[i][j])) { rows[i][j] = null; } } } }
javascript
function cleanUpFalsyCsvValue(rows) { for (let i = 0; i < rows.length; i++) { for (let j = 0; j < rows[i].length; j++) { // analyzer will set any fields to 'string' if there are empty values // which will be parsed as '' by d3.csv // here we parse empty data as null // TODO: create warning when deltect `CSV_NULLS` in the data if (!rows[i][j] || CSV_NULLS.includes(rows[i][j])) { rows[i][j] = null; } } } }
[ "function", "cleanUpFalsyCsvValue", "(", "rows", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "rows", ".", "length", ";", "i", "++", ")", "{", "for", "(", "let", "j", "=", "0", ";", "j", "<", "rows", "[", "i", "]", ".", "length", ";", "j", "++", ")", "{", "// analyzer will set any fields to 'string' if there are empty values", "// which will be parsed as '' by d3.csv", "// here we parse empty data as null", "// TODO: create warning when deltect `CSV_NULLS` in the data", "if", "(", "!", "rows", "[", "i", "]", "[", "j", "]", "||", "CSV_NULLS", ".", "includes", "(", "rows", "[", "i", "]", "[", "j", "]", ")", ")", "{", "rows", "[", "i", "]", "[", "j", "]", "=", "null", ";", "}", "}", "}", "}" ]
Convert falsy value in csv including `'', 'null', 'NULL', 'Null', 'NaN'` to `null`, so that type-analyzer won't detect it as string @param {Array<Array>} rows
[ "Convert", "falsy", "value", "in", "csv", "including", "null", "NULL", "Null", "NaN", "to", "null", "so", "that", "type", "-", "analyzer", "won", "t", "detect", "it", "as", "string" ]
779238435707cc54335c2d00001e4b9334b314aa
https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/processors/data-processor.js#L138-L150