use base 10 in parseInt, use Math.floor for numbers
This commit is contained in:
parent
79bb322112
commit
8bc8c57373
19 changed files with 44 additions and 45 deletions
|
@ -143,7 +143,7 @@ Ox.load.Image = function(options, callback) {
|
|||
rgb = i == 0
|
||||
? Ox.rgb([val, 1, 0.5])
|
||||
: Ox.range(3).map(function() {
|
||||
return parseInt(val * 255);
|
||||
return Math.floor(val * 255);
|
||||
});
|
||||
return rgb.concat(rgba[3]);
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ Ox.DateInput = function(options, self) {
|
|||
autocomplete: Ox.range(1, days + 1).map(function(i) {
|
||||
return self.options.format == 'short' ? Ox.pad(i, 2) : i.toString();
|
||||
}),
|
||||
value: self.options.format == 'short' ? Ox.pad(parseInt(day), 2) : day.toString()
|
||||
value: self.options.format == 'short' ? Ox.pad(parseInt(day, 10), 2) : day.toString()
|
||||
});
|
||||
self.options.value = join();
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ Ox.Spreadsheet = function(options, self) {
|
|||
.appendTo(that);
|
||||
!isSum && self.$input[id].bindEvent({
|
||||
change: function(data) {
|
||||
self.options.value.values[r][c] = parseInt(data.value);
|
||||
self.options.value.values[r][c] = parseInt(data.value, 10);
|
||||
self.sums = getSums();
|
||||
self.$input[c + ',' + self.rows].value(self.sums.column[c]);
|
||||
self.$input[self.columns + ',' + r].value(self.sums.row[r]);
|
||||
|
|
4
source/Ox.UI/js/List/Chart.js
vendored
4
source/Ox.UI/js/List/Chart.js
vendored
|
@ -74,7 +74,7 @@ Ox.Chart = function(options, self) {
|
|||
});
|
||||
}
|
||||
self.sort[key] = key.replace(/(\d+)/g, function(number) {
|
||||
return Ox.pad(parseInt(number), 16);
|
||||
return Ox.pad(parseInt(number, 10), 16);
|
||||
});
|
||||
});
|
||||
self.max = Ox.max(self.totals);
|
||||
|
@ -83,7 +83,7 @@ Ox.Chart = function(options, self) {
|
|||
if (self.subData) {
|
||||
Ox.forEach(self.subData, function(subValue, subKey) {
|
||||
self.sort[subKey] = subKey.replace(/(\d+)/g, function(number) {
|
||||
return Ox.pad(parseInt(number), 16);
|
||||
return Ox.pad(parseInt(number, 10), 16);
|
||||
});
|
||||
});
|
||||
self.subKeys = Object.keys(self.subData).sort(function(a, b) {
|
||||
|
|
|
@ -598,7 +598,7 @@ Ox.List = function(options, self) {
|
|||
}
|
||||
|
||||
function getPageByPosition(pos) {
|
||||
return parseInt(pos / self.options.pageLength);
|
||||
return Math.floor(pos / self.options.pageLength);
|
||||
}
|
||||
|
||||
function getPageByScrollPosition(pos) {
|
||||
|
@ -709,7 +709,7 @@ Ox.List = function(options, self) {
|
|||
function getScrollPosition() {
|
||||
// if orientation is both, this returns the
|
||||
// element position at the current scroll position
|
||||
return parseInt(
|
||||
return Math.floor(
|
||||
that.scrollTop() / (self.options.itemHeight + self.itemMargin)
|
||||
) * self.rowLength;
|
||||
}
|
||||
|
@ -930,7 +930,7 @@ Ox.List = function(options, self) {
|
|||
function move(data) {
|
||||
var clientY = data.clientY - that.offset()['top'],
|
||||
offset = clientY % 16,
|
||||
position = Ox.limit(parseInt(clientY / 16), 0, self.$items.length - 1);
|
||||
position = Ox.limit(Math.floor(clientY / 16), 0, self.$items.length - 1);
|
||||
if (position < self.drag.pos) {
|
||||
self.drag.stopPos = position + (offset > 8 ? 1 : 0);
|
||||
} else if (position > self.drag.pos) {
|
||||
|
|
|
@ -414,7 +414,7 @@ Ox.Menu = function(options, self) {
|
|||
function scrollMenu(speed) {
|
||||
var containerHeight = that.$container.height(),
|
||||
contentHeight = that.$content.height(),
|
||||
top = parseInt(that.$content.css('top')) || 0,
|
||||
top = parseInt(that.$content.css('top'), 10) || 0,
|
||||
min = containerHeight - contentHeight + self.itemHeight,
|
||||
max = 0;
|
||||
top += speed * self.scrollSpeed * -self.itemHeight;
|
||||
|
@ -516,7 +516,7 @@ Ox.Menu = function(options, self) {
|
|||
that.$container.height(that.$container.height() + self.itemHeight);
|
||||
} else {
|
||||
that.$content.css({
|
||||
top: ((parseInt(that.$content.css('top')) || 0) - offset) + 'px'
|
||||
top: ((parseInt(that.$content.css('top'), 10) || 0) - offset) + 'px'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ Ox.Menu = function(options, self) {
|
|||
that.$container.height(that.$container.height() + self.itemHeight);
|
||||
}
|
||||
that.$content.css({
|
||||
top: ((parseInt(that.$content.css('top')) || 0) - offset) + 'px'
|
||||
top: ((parseInt(that.$content.css('top'), 10) || 0) - offset) + 'px'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ Ox.SplitPanel = function(options, self) {
|
|||
size: 'auto'
|
||||
}, element);
|
||||
that.$elements[i] = element.element
|
||||
.css(self.edges[2], (parseInt(element.element.css(self.edges[2])) || 0) + 'px')
|
||||
.css(self.edges[3], (parseInt(element.element.css(self.edges[3])) || 0) + 'px');
|
||||
.css(self.edges[2], (parseInt(element.element.css(self.edges[2]), 10) || 0) + 'px')
|
||||
.css(self.edges[3], (parseInt(element.element.css(self.edges[3]), 10) || 0) + 'px');
|
||||
});
|
||||
|
||||
// create resizebars
|
||||
|
@ -123,8 +123,8 @@ Ox.SplitPanel = function(options, self) {
|
|||
// is about elements that are collapsed splitpanels
|
||||
var css = {},
|
||||
edges = [
|
||||
(init && parseInt(that.$elements[i].css(self.edges[0]))) || 0,
|
||||
(init && parseInt(that.$elements[i].css(self.edges[1]))) || 0
|
||||
(init && parseInt(that.$elements[i].css(self.edges[0]), 10)) || 0,
|
||||
(init && parseInt(that.$elements[i].css(self.edges[1]), 10)) || 0
|
||||
];
|
||||
if (element.size != 'auto') {
|
||||
css[self.dimensions[0]] = element.size + 'px';
|
||||
|
@ -207,8 +207,8 @@ Ox.SplitPanel = function(options, self) {
|
|||
// one can pass pos instead of id
|
||||
var pos = Ox.isNumber(id) ? id : getPositionById(id);
|
||||
that.$elements[pos] = element
|
||||
.css(self.edges[2], (parseInt(element.css(self.edges[2])) || 0) + 'px')
|
||||
.css(self.edges[3], (parseInt(element.css(self.edges[3])) || 0) + 'px');
|
||||
.css(self.edges[2], (parseInt(element.css(self.edges[2]), 10) || 0) + 'px')
|
||||
.css(self.edges[3], (parseInt(element.css(self.edges[3]), 10) || 0) + 'px');
|
||||
Ox.Log('Panel', 'REPLACE ELEMENT')
|
||||
self.options.elements[pos].element.replaceWith(
|
||||
self.options.elements[pos].element = element
|
||||
|
@ -307,9 +307,8 @@ Ox.SplitPanel = function(options, self) {
|
|||
// one can pass pos instead of id
|
||||
var pos = Ox.isNumber(id) ? id : getPositionById(id),
|
||||
element = self.options.elements[pos],
|
||||
value = parseInt(that.css(self.edges[pos == 0 ? 0 : 1])) +
|
||||
element.element[self.dimensions[0]]() *
|
||||
(element.collapsed ? 1 : -1),
|
||||
value = parseInt(that.css(self.edges[pos == 0 ? 0 : 1]), 10)
|
||||
+ element.element[self.dimensions[0]]() * (element.collapsed ? 1 : -1),
|
||||
animate = {};
|
||||
animate[self.edges[pos == 0 ? 0 : 1]] = value;
|
||||
that.animate(animate, 250, function() {
|
||||
|
|
|
@ -241,7 +241,7 @@ Ox.BlockVideoTimeline = function(options, self) {
|
|||
var position = Math.round(self.options[point]);
|
||||
self.$pointMarker[point].css({
|
||||
left: (position % self.options.width) + 'px',
|
||||
top: (parseInt(position / self.options.width) *
|
||||
top: (Math.floor(position / self.options.width) *
|
||||
(self.height + self.margin) + 15) + 'px'
|
||||
});
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ Ox.BlockVideoTimeline = function(options, self) {
|
|||
var position = Math.round(self.options.position);
|
||||
self.$positionMarker.css({
|
||||
left: (position % self.options.width) - 1 + 'px',
|
||||
top: (parseInt(position / self.options.width) *
|
||||
top: (Math.floor(position / self.options.width) *
|
||||
(self.height + self.margin) + 2) + 'px'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ Ox.LargeVideoTimeline = function(options, self) {
|
|||
$tooltip: Ox.Tooltip({
|
||||
animate: false
|
||||
}),
|
||||
center: parseInt(self.options.width / 2),
|
||||
center: Math.floor(self.options.width / 2),
|
||||
element: that.$element[0],
|
||||
fps: 25,
|
||||
height: 64,
|
||||
|
@ -154,7 +154,7 @@ Ox.LargeVideoTimeline = function(options, self) {
|
|||
}
|
||||
|
||||
function setPosition() {
|
||||
self.tile = parseInt(self.options.position * self.fps / self.tileWidth);
|
||||
self.tile = Math.floor(self.options.position * self.fps / self.tileWidth);
|
||||
self.$timeline.css({
|
||||
marginLeft: (-self.options.position * self.fps) + 'px'
|
||||
});
|
||||
|
@ -199,7 +199,7 @@ Ox.LargeVideoTimeline = function(options, self) {
|
|||
}
|
||||
|
||||
function setWidth() {
|
||||
self.center = parseInt(self.options.width / 2);
|
||||
self.center = Math.floor(self.options.width / 2);
|
||||
that.css({
|
||||
width: self.options.width + 'px'
|
||||
});
|
||||
|
|
|
@ -559,7 +559,7 @@ Ox.VideoEditor = function(options, self) {
|
|||
change: function(data) {
|
||||
var id = data.id;
|
||||
if (id == 'resolution') {
|
||||
self.options.resolution = parseInt(data.checked[0].id);
|
||||
self.options.resolution = parseInt(data.checked[0].id, 10);
|
||||
self.$player[0].options({resolution: self.options.resolution});
|
||||
} else if (id == 'size') {
|
||||
toggleSize();
|
||||
|
@ -1183,8 +1183,8 @@ Ox.VideoEditor = function(options, self) {
|
|||
}
|
||||
|
||||
function setPosition(position, playing) {
|
||||
var minute = minute = parseInt(position / 60),
|
||||
previousMinute = parseInt(self.options.position / 60);
|
||||
var minute = Math.floor(position / 60),
|
||||
previousMinute = Math.floor(self.options.position / 60);
|
||||
self.options.position = position;
|
||||
!playing && self.$player[0].options({
|
||||
position: self.options.position
|
||||
|
|
|
@ -330,9 +330,9 @@ Ox.VideoEditorPlayer = function(options, self) {
|
|||
|
||||
function setSubtitleSize() {
|
||||
self.$subtitle.css({
|
||||
bottom: parseInt(self.controlsHeight + self.options.height / 16) + 'px',
|
||||
bottom: Math.floor(self.controlsHeight + self.options.height / 16) + 'px',
|
||||
width: self.options.width + 'px',
|
||||
fontSize: parseInt(self.options.height / 20) + 'px',
|
||||
fontSize: Math.floor(self.options.height / 20) + 'px',
|
||||
WebkitTextStroke: (self.options.height / 1000) + 'px rgb(0, 0, 0)'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -416,8 +416,8 @@ Ox.VideoPanel = function(options, self) {
|
|||
}
|
||||
|
||||
function setPosition(position, playing) {
|
||||
var minute = parseInt(position / 60),
|
||||
previousMinute = parseInt(self.options.position / 60);
|
||||
var minute = Math.floor(position / 60),
|
||||
previousMinute = Math.floor(self.options.position / 60);
|
||||
self.options.position = position;
|
||||
!playing && self.$video.options({position: self.options.position});
|
||||
self.$timeline.options({position: self.options.position});
|
||||
|
|
|
@ -1338,9 +1338,9 @@ Ox.VideoPlayer = function(options, self) {
|
|||
};
|
||||
} else if (element == 'subtitle') {
|
||||
css = {
|
||||
bottom: (parseInt(self.height / 16) + !!self.controlsBottomAreVisible * 16) + 'px',
|
||||
bottom: (Math.floor(self.height / 16) + !!self.controlsBottomAreVisible * 16) + 'px',
|
||||
width: self.width + 'px',
|
||||
fontSize: parseInt(self.height / 20) + 'px',
|
||||
fontSize: Math.floor(self.height / 20) + 'px',
|
||||
WebkitTextStroke: (self.height / 1000) + 'px rgb(0, 0, 0)'
|
||||
};
|
||||
} else if (element == 'spaceBottom' || element == 'timeline') {
|
||||
|
@ -1543,8 +1543,8 @@ Ox.VideoPlayer = function(options, self) {
|
|||
width = Math.round(width);
|
||||
height = Math.round(height);
|
||||
return {
|
||||
left: parseInt((playerWidth - width) / 2),
|
||||
top: parseInt((playerHeight - height) / 2),
|
||||
left: Math.floor((playerWidth - width) / 2),
|
||||
top: Math.floor((playerHeight - height) / 2),
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
|
@ -1823,7 +1823,7 @@ Ox.VideoPlayer = function(options, self) {
|
|||
} else if (title == 'Subtitles') {
|
||||
toggleSubtitles();
|
||||
} else {
|
||||
resolution = parseInt(title);
|
||||
resolution = parseInt(title, 10);
|
||||
if (resolution != self.options.resolution) {
|
||||
self.options.resolution = resolution;
|
||||
setResolution();
|
||||
|
@ -1837,7 +1837,7 @@ Ox.VideoPlayer = function(options, self) {
|
|||
&& self.options.enableSubtitles
|
||||
) || (
|
||||
Ox.last(title) == 'p'
|
||||
&& parseInt(title) == self.options.resolution
|
||||
&& parseInt(title, 10) == self.options.resolution
|
||||
);
|
||||
$(children[1]).attr({
|
||||
src: Ox.UI.getImageURL(
|
||||
|
|
|
@ -255,8 +255,8 @@ Ox.VideoTimelinePanel = function(options, self) {
|
|||
}
|
||||
|
||||
function setPosition(position, playing) {
|
||||
var minute = parseInt(position / 60),
|
||||
previousMinute = parseInt(self.options.position / 60);
|
||||
var minute = Math.floor(position / 60),
|
||||
previousMinute = Math.floor(self.options.position / 60);
|
||||
self.options.position = position;
|
||||
!playing && self.$player.options({position: self.options.position});
|
||||
self.$annotationPanel.options({position: self.options.position});
|
||||
|
|
|
@ -95,7 +95,7 @@ window.Ox = {
|
|||
} else {
|
||||
element.onload = callback;
|
||||
}
|
||||
element.src = path + script + '?' + parseInt(Math.random() * 1000000);
|
||||
element.src = path + script + '?' + Math.floor(Math.random() * 1000000);
|
||||
element.type = 'text/javascript';
|
||||
head.appendChild(element);
|
||||
}
|
||||
|
|
|
@ -570,7 +570,7 @@ Ox.range = function() {
|
|||
sort[value] = mappedValue.toLowerCase()
|
||||
.replace(/^\W+/, '')
|
||||
.replace(/\d+/g, function(match) {
|
||||
return Ox.pad(parseInt(match), length);
|
||||
return Ox.pad(parseInt(match, 10), length);
|
||||
});
|
||||
Ox.forEach(['a', 'an', 'the'], function(article) {
|
||||
var length;
|
||||
|
|
|
@ -261,7 +261,7 @@ Ox.makeYear <f> Takes a date, number or string, returns a year
|
|||
1970
|
||||
@*/
|
||||
Ox.makeYear = function(date, utc) {
|
||||
return Ox.isDate(date) ? Ox.getFullYear(date, utc) : parseInt(date);
|
||||
return Ox.isDate(date) ? Ox.getFullYear(date, utc) : parseInt(date, 10);
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
|
@ -341,7 +341,7 @@ Ox.formatDateRange = function(start, end, utc) {
|
|||
);
|
||||
parts.shift();
|
||||
return parts.map(function(part) {
|
||||
return parseInt(part);
|
||||
return parseInt(part, 10);
|
||||
});
|
||||
}),
|
||||
precision = parts.map(function(parts) {
|
||||
|
|
|
@ -62,7 +62,7 @@ Ox.divideInt <f> Divides a number by another and returns an array of integers
|
|||
@*/
|
||||
// fixme: is splitInt a better name?
|
||||
Ox.divideInt = function(number, by) {
|
||||
var div = parseInt(number / by),
|
||||
var div = Math.floor(number / by),
|
||||
mod = number % by;
|
||||
return Ox.range(by).map(function(i) {
|
||||
return div + (i > by - 1 - mod);
|
||||
|
|
Loading…
Reference in a new issue