Function keynav
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.keynav = function (onClass,offClass) {
//Initialization
var kn = $.keynav;
if(!kn.init) {
kn.el = new Array();
Function getPos
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
$.keynav.getPos = function (e)
{
var l = 0;
var t = 0;
var w = $.intval($.css(e,'width'));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 4 locations. Consider refactoring. Open
$.keynav.goLeft = function () {
var cur = $.keynav.getCurrent();
var quad = $.keynav.quad(cur,function (dx,dy) {
if((dy >= 0) && (Math.abs(dx) - dy) <= 0)
return true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
$.keynav.goRight = function () {
var cur = $.keynav.getCurrent();
var quad = $.keynav.quad(cur,function (dx,dy) {
if((dy <= 0) && (Math.abs(dx) + dy) <= 0)
return true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
$.keynav.goUp = function () {
var cur = $.keynav.getCurrent();
var quad = $.keynav.quad(cur,function (dx,dy) {
if((dx >= 0) && (Math.abs(dy) - dx) <= 0)
return true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
$.keynav.goDown = function () {
var cur = $.keynav.getCurrent();
var quad = $.keynav.quad(cur,function (dx,dy) {
if((dx <= 0) && (Math.abs(dy) + dx) <= 0)
return true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Unexpected spaces found. Open
break;
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected spaces found. Open
$.fn.keynav_sethover = function(onClass,offClass) {
- Exclude checks
Unexpected spaces found. Open
return this.each(function() {
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
var cur = $.keynav.getCurrent();
- Exclude checks
Unexpected spaces found. Open
if(kn.currentEl) {
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected spaces found. Open
if (e == null) {
- Exclude checks
Unexpected spaces found. Open
$.keynav.goLeft();
- Exclude checks
Unexpected spaces found. Open
break;
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected spaces found. Open
if(found)
- Exclude checks
Unexpected spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected spaces found. Open
$.keynav = new Object();
- Exclude checks
Unexpected spaces found. Open
key = e.which;
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected spaces found. Open
$(e).removeClass(e.offClass).addClass(e.onClass);
- Exclude checks
Unexpected spaces found. Open
kn.currentEl = e;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
if(!kn.init) {
- Exclude checks
Unexpected spaces found. Open
var key = 0;
- Exclude checks
Unexpected trailing spaces found. Open
case 39:
- Exclude checks
Unexpected spaces found. Open
$.keynav.goDown();
- Exclude checks
Unexpected spaces found. Open
//Initialization
- Exclude checks
Unexpected spaces found. Open
$.keynav.goUp();
- Exclude checks
Unexpected spaces found. Open
break;
- Exclude checks
Unexpected spaces found. Open
$.keynav.reset = function() {
- Exclude checks
Unexpected spaces found. Open
e.pos = $.keynav.getPos(e);
- Exclude checks
Unexpected spaces found. Open
kn.el.push(e);
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
return true;
- Exclude checks
Unexpected spaces found. Open
} else { // mozilla
- Exclude checks
Unexpected spaces found. Open
$.keynav.goRight();
- Exclude checks
Unexpected spaces found. Open
kn.init = true;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
l += e.offsetLeft + (e.currentStyle?$.intval(e.currentStyle.borderLeftWidth):0);
- Exclude checks
Unexpected spaces found. Open
return isNaN(v) ? 0 : v;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
case 40:
- Exclude checks
Unexpected spaces found. Open
$.keynav.reg = function(e,onClass,offClass) {
- Exclude checks
Unexpected spaces found. Open
$(cur).trigger('blur');
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
var cur = $.keynav.getCurrent();
- Exclude checks
Unexpected spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected spaces found. Open
var cur = $.keynav.getCurrent();
- Exclude checks
Unexpected trailing spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected trailing spaces found. Open
return true;
- Exclude checks
Unexpected spaces found. Open
l += e.offsetLeft + (e.currentStyle?$.intval(e.currentStyle.borderLeftWidth):0);
- Exclude checks
Unexpected spaces found. Open
break;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$.keynav.activateClosest(cur,quad);
- Exclude checks
Unexpected spaces found. Open
/**
- Exclude checks
Unexpected spaces found. Open
var l = 0;
- Exclude checks
Unexpected spaces found. Open
var h = $.intval($.css(e,'height'));
- Exclude checks
Unexpected spaces found. Open
return quad;
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected spaces found. Open
$.keynav.activateClosest(cur,quad);
- Exclude checks
Unexpected spaces found. Open
$.keynav.goDown = function () {
- Exclude checks
Unexpected spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected spaces found. Open
$.keynav.activate = function () {
- Exclude checks
Unexpected spaces found. Open
$.intval = function (v)
- Exclude checks
Unexpected trailing spaces found. Open
case 38:
- Exclude checks
Unexpected spaces found. Open
$(e).trigger('focus');
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
else {
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected trailing spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected spaces found. Open
$.keynav.getPos = function (e)
- Exclude checks
Unexpected spaces found. Open
var w = $.intval($.css(e,'width'));
- Exclude checks
Unexpected spaces found. Open
$(document).keydown(function(e) {
- Exclude checks
Unexpected spaces found. Open
$.keynav.getCurrent = function () {
- Exclude checks
Unexpected spaces found. Open
while (e.offsetParent){
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
/**
- Exclude checks
Unexpected spaces found. Open
kn.el = new Array();
- Exclude checks
Unexpected trailing spaces found. Open
case 37:
- Exclude checks
Unexpected spaces found. Open
$.keynav.activate();
- Exclude checks
Unexpected spaces found. Open
return this.each(function() {
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$.keynav.setActive = function(e) {
- Exclude checks
Unexpected spaces found. Open
for(var i=0;i<kn.el.length;i++) {
- Exclude checks
Unexpected spaces found. Open
for(i=0;i<kn.el.length;i++) {
- Exclude checks
Unexpected spaces found. Open
$.keynav.goRight = function () {
- Exclude checks
Unexpected spaces found. Open
var cur = $.keynav.getCurrent();
- Exclude checks
Unexpected spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected trailing spaces found. Open
*
- Exclude checks
Unexpected spaces found. Open
v = parseInt(v);
- Exclude checks
Unexpected spaces found. Open
};
- Exclude checks
Unexpected spaces found. Open
$.fn.keynav = function (onClass,offClass) {
- Exclude checks
Unexpected spaces found. Open
e.onClass = onClass;
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected spaces found. Open
var cur = kn.el[0];
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$.keynav.activateClosest(cur,quad);
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
t += e.offsetTop + (e.currentStyle?$.intval(e.currentStyle.borderTopWidth):0);
- Exclude checks
Unexpected spaces found. Open
return {x:l, y:t, w:w, h:h, cx:cx, cy:cy};
- Exclude checks
Unexpected spaces found. Open
{
- Exclude checks
Unexpected spaces found. Open
break;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
e.offClass = offClass;
- Exclude checks
Unexpected spaces found. Open
e.onmouseover = function (e) { $.keynav.setActive(this); };
- Exclude checks
Unexpected spaces found. Open
$(tmp).removeClass(tmp.onClass).addClass(tmp.offClass);
- Exclude checks
Unexpected spaces found. Open
return cur;
- Exclude checks
Unexpected spaces found. Open
var kn = $.keynav;
- Exclude checks
Unexpected spaces found. Open
quad.push(el);
- Exclude checks
Unexpected spaces found. Open
$.keynav.activateClosest = function(cur,quad) {
- Exclude checks
Unexpected spaces found. Open
var od = 1000000;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
var t = 0;
- Exclude checks
Unexpected spaces found. Open
};
- Exclude checks
Unexpected spaces found. Open
var found = false;
- Exclude checks
Unexpected trailing spaces found. Open
return true;
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected spaces found. Open
{
- Exclude checks
Unexpected spaces found. Open
e = e.offsetParent;
- Exclude checks
Unexpected spaces found. Open
key = event.keyCode;
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected spaces found. Open
kn.el = new Array();
- Exclude checks
Unexpected spaces found. Open
$.keynav.quad = function(cur,fQuad) {
- Exclude checks
Unexpected spaces found. Open
var closest;
- Exclude checks
Unexpected spaces found. Open
$.keynav.activateClosest(cur,quad);
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
case 13:
- Exclude checks
Unexpected spaces found. Open
$.keynav.goLeft = function () {
- Exclude checks
Unexpected spaces found. Open
$.keynav.goUp = function () {
- Exclude checks
Unexpected spaces found. Open
t += e.offsetTop + (e.currentStyle?$.intval(e.currentStyle.borderTopWidth):0);
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
var tmp = kn.el[i];
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
var cur = kn.currentEl;
- Exclude checks
Unexpected spaces found. Open
var quad = Array();
- Exclude checks
Unexpected spaces found. Open
var nd = 0;
- Exclude checks
Unexpected spaces found. Open
for(i=0;i<quad.length;i++) {
- Exclude checks
Unexpected spaces found. Open
var cur = $.keynav.getCurrent();
- Exclude checks
Unexpected trailing spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected spaces found. Open
$(kn.currentEl).trigger('click');
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
var quad = $.keynav.quad(cur,function (dx,dy) {
- Exclude checks
Unexpected trailing spaces found. Open
return true;
- Exclude checks
Unexpected spaces found. Open
});
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks