Skip to content
Permalink
Browse files

remove the querySelectorAll optimization since it's not getting used

  • Loading branch information...
jasoncalabrese committed May 31, 2015
1 parent 2ca9c8a commit db85587df7896d9689fcca7a58e4df852dd7a99f
Showing with 2 additions and 41 deletions.
  1. +2 −41 static/js/client.js
@@ -1,45 +1,6 @@
//TODO: clean up
var app = {}, browserSettings = {}, browserStorage = $.localStorage;

/*
* query
* Abstraction to querySelectorAll for increased
* performance and greater usability
* @param {String} selector
* @param {Element} context (optional)
* @return {Array}
*/

(function(win){
'use strict';

var simpleRe = /^(#?[\w-]+|\.[\w-.]+)$/,
periodRe = /\./g,
slice = [].slice;

win.query = function(selector, context){
console.info('win.query() called');
context = context || document;
// Redirect call to the more performant function
// if it's a simple selector and return an array
// for easier usage
if(simpleRe.test(selector)){
switch(selector[0]){
case '#':
return [context.getElementById(selector.substr(1))];
case '.':
return slice.call(context.getElementsByClassName(selector.substr(1).replace(periodRe, ' ')));
default:
return slice.call(context.getElementsByTagName(selector));
}
}
// If not a simple selector, query the DOM as usual
// and return an array for easier usage
return slice.call(context.querySelectorAll(selector));
};

})(this);

(function () {
'use strict';

@@ -1338,8 +1299,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage;

if (!treatment.carbs && !treatment.insulin) return;

// don't render the treatment if it's not visible
if (Math.abs(xScale(treatment.created_at.getTime())) > window.innerWidth) return;
// don't render the treatment if it's not visible
if (Math.abs(xScale(treatment.created_at.getTime())) > window.innerWidth) return;

var CR = treatment.CR || 20;
var carbs = treatment.carbs || CR;

0 comments on commit db85587

Please sign in to comment.
You can’t perform that action at this time.