Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated files to pass curly and bitwise tests in jshint #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/kothic.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ var Kothic = {

for (i = 0; i < layerIds.length; i++) {
queue = layersToRender[layerIds[i]];
if (!queue)
if (!queue) {
continue;
}

if (queue.polygons) {
for (j = 0, len = queue.polygons.length; j < len; j++) {
Expand Down
36 changes: 24 additions & 12 deletions src/renderer/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ Kothic.path = (function () {
// returns bitmask of affected tile boundaries
function isTileBoundary(p, size) {
var r = 0;
if (p[0] === 0)
/*jslint bitwise: true */
if (p[0] === 0) {
r |= 1;
else if (p[0] === size)
}
else if (p[0] === size) {
r |= 2;
if (p[1] === 0)
}
if (p[1] === 0) {
r |= 4;
else if (p[1] === size)
}
else if (p[1] === size) {
r |= 8;
}
return r;
}

Expand All @@ -26,9 +31,10 @@ Kothic.path = (function () {
*/
function checkSameBoundary(p, q, size) {
var bp = isTileBoundary(p, size);
if (!bp)
if (!bp) {
return 0;

}
/*jslint bitwise: true */
return (bp & isTileBoundary(q, size));
}

Expand Down Expand Up @@ -64,10 +70,12 @@ Kothic.path = (function () {

if (j === 0) {
ctx.moveTo(screenPoint[0], screenPoint[1]);
if (dashes)
if (dashes) {
ctx.setLineDash(dashes);
else
}
else {
ctx.setLineDash([]);
}
} else if (!fill && checkSameBoundary(point, prevPoint, granularity)) {
ctx.moveTo(screenPoint[0], screenPoint[1]);
} else {
Expand All @@ -93,8 +101,9 @@ Kothic.path = (function () {
k = j;
do {
k = j ? k - 1 : k + 1;
if (k < 0 || k >= pointsLen)
if (k < 0 || k >= pointsLen) {
break;
}
prevPoint = points[k];

dx = point[0] - prevPoint[0];
Expand All @@ -105,8 +114,9 @@ Kothic.path = (function () {
// all points are so close to each other that it doesn't make sense to
// draw the line beyond the tile border, simply skip the entire line from
// here
if (k < 0 || k >= pointsLen)
if (k < 0 || k >= pointsLen) {
break;
}

point[0] = point[0] + pad * dx / dist;
point[1] = point[1] + pad * dy / dist;
Expand All @@ -115,10 +125,12 @@ Kothic.path = (function () {

if (j === 0) {
ctx.moveTo(screenPoint[0], screenPoint[1]);
if (dashes)
if (dashes) {
ctx.setLineDash(dashes);
else
}
else {
ctx.setLineDash([]);
}
} else {
ctx.lineTo(screenPoint[0], screenPoint[1]);
}
Expand Down
9 changes: 6 additions & 3 deletions src/renderer/texticons.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ Kothic.texticons = {
textBaseline: 'middle'
});

if (style['text-transform'] === 'uppercase')
if (style['text-transform'] === 'uppercase') {
text = text.toUpperCase();
else if (style['text-transform'] === 'lowercase')
}
else if (style['text-transform'] === 'lowercase') {
text = text.toLowerCase();
else if (style['text-transform'] === 'capitalize')
}
else if (style['text-transform'] === 'capitalize') {
text = text.replace(/(^|\s)\S/g, function(ch) { return ch.toUpperCase(); });
}

if (feature.type === 'Polygon' || feature.type === 'Point') {
var textWidth = ctx.measureText(text).width,
Expand Down
30 changes: 20 additions & 10 deletions src/style/mapcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ var MapCSS = {
} else {
var tagString = "";

for (var i = 1; i < arguments.length; i++)
for (var i = 1; i < arguments.length; i++) {
tagString = tagString.concat(arguments[0]).concat(arguments[i]);
}

return tagString.substr(arguments[0].length);
}
Expand All @@ -147,30 +148,35 @@ var MapCSS = {
},

e_get: function(arr, index) {
if (Object.prototype.toString.call(arr) !== '[object Array]')
if (Object.prototype.toString.call(arr) !== '[object Array]') {
return "";
}

if (!/^[0-9]+$/.test(index) || index >= arr.length())
if (!/^[0-9]+$/.test(index) || index >= arr.length()) {
return "";
}

return arr[index];
},

e_set: function(arr, index, text) {
if (Object.prototype.toString.call(arr) !== '[object Array]')
if (Object.prototype.toString.call(arr) !== '[object Array]') {
return [];
}

if (!/^[0-9]+$/.test(index))
if (!/^[0-9]+$/.test(index)) {
return [];
}

arr[index] = text;

return arr;
},

e_count: function(arr) {
if (Object.prototype.toString.call(arr) !== '[object Array]')
if (Object.prototype.toString.call(arr) !== '[object Array]') {
return 0;
}

return arr.length();
},
Expand All @@ -180,33 +186,37 @@ var MapCSS = {
},

e_append: function(lst, v) {
if (Object.prototype.toString.call(lst) !== '[object Array]')
if (Object.prototype.toString.call(lst) !== '[object Array]') {
return [];
}

lst.push(v);

return lst;
},

e_contains: function(lst, v) {
if (Object.prototype.toString.call(lst) !== '[object Array]')
if (Object.prototype.toString.call(lst) !== '[object Array]') {
return false;
}

return (lst.indexOf(v) >= 0);
},

e_sort: function(lst) {
if (Object.prototype.toString.call(lst) !== '[object Array]')
if (Object.prototype.toString.call(lst) !== '[object Array]') {
return [];
}

lst.sort();

return lst;
},

e_reverse: function(lst) {
if (Object.prototype.toString.call(lst) !== '[object Array]')
if (Object.prototype.toString.call(lst) !== '[object Array]') {
return [];
}

lst.reverse();

Expand Down