mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 13:07:19 +08:00
DEV: Provide radix argument to parseInt (#8281)
* DEV: Provide radix 10 argument to parseInt * DEV: Provide radix 16 argument to parseInt * DEV: Remove unnecessary parseInt calls * Fix year formatting parseInt was used here to convert decimals to ints
This commit is contained in:
@ -36,7 +36,7 @@ export default Controller.extend({
|
||||
|
||||
@discourseComputed("colorSchemeId", "model.color_scheme_id")
|
||||
colorSchemeChanged(colorSchemeId, existingId) {
|
||||
colorSchemeId = colorSchemeId === null ? null : parseInt(colorSchemeId);
|
||||
colorSchemeId = colorSchemeId === null ? null : parseInt(colorSchemeId, 10);
|
||||
return colorSchemeId !== existingId;
|
||||
},
|
||||
|
||||
@ -189,7 +189,7 @@ export default Controller.extend({
|
||||
let schemeId = this.colorSchemeId;
|
||||
this.set(
|
||||
"model.color_scheme_id",
|
||||
schemeId === null ? null : parseInt(schemeId)
|
||||
schemeId === null ? null : parseInt(schemeId, 10)
|
||||
);
|
||||
this.model.saveChanges("color_scheme_id");
|
||||
},
|
||||
@ -239,7 +239,7 @@ export default Controller.extend({
|
||||
},
|
||||
|
||||
addChildTheme() {
|
||||
let themeId = parseInt(this.selectedChildThemeId);
|
||||
let themeId = parseInt(this.selectedChildThemeId, 10);
|
||||
let theme = this.allThemes.findBy("id", themeId);
|
||||
this.model.addChildTheme(theme);
|
||||
},
|
||||
|
@ -80,9 +80,9 @@ const ColorSchemeColor = EmberObject.extend({
|
||||
hex.substr(2, 1);
|
||||
}
|
||||
return Math.round(
|
||||
(parseInt("0x" + hex.substr(0, 2)) * 299 +
|
||||
parseInt("0x" + hex.substr(2, 2)) * 587 +
|
||||
parseInt("0x" + hex.substr(4, 2)) * 114) /
|
||||
(parseInt(hex.substr(0, 2), 16) * 299 +
|
||||
parseInt(hex.substr(2, 2), 16) * 587 +
|
||||
parseInt(hex.substr(4, 2), 16) * 114) /
|
||||
1000
|
||||
);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export default Route.extend({
|
||||
name: I18n.t("admin.badges.new_badge")
|
||||
});
|
||||
}
|
||||
return this.modelFor("adminBadges").findBy("id", parseInt(params.badge_id));
|
||||
return this.modelFor("adminBadges").findBy("id", parseInt(params.badge_id, 10));
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -2,7 +2,7 @@ import Route from "@ember/routing/route";
|
||||
export default Route.extend({
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomize.colors");
|
||||
const model = all.findBy("id", parseInt(params.scheme_id));
|
||||
const model = all.findBy("id", parseInt(params.scheme_id, 10));
|
||||
return model ? model : this.replaceWith("adminCustomize.colors.index");
|
||||
},
|
||||
|
||||
|
@ -2,7 +2,7 @@ import Route from "@ember/routing/route";
|
||||
export default Route.extend({
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomizeThemes");
|
||||
const model = all.findBy("id", parseInt(params.theme_id));
|
||||
const model = all.findBy("id", parseInt(params.theme_id, 10));
|
||||
return model
|
||||
? {
|
||||
model,
|
||||
|
@ -9,7 +9,7 @@ export default Route.extend({
|
||||
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomizeThemes");
|
||||
const model = all.findBy("id", parseInt(params.theme_id));
|
||||
const model = all.findBy("id", parseInt(params.theme_id, 10));
|
||||
return model ? model : this.replaceWith("adminCustomizeTheme.index");
|
||||
},
|
||||
|
||||
|
@ -10,7 +10,7 @@ export default Component.extend({
|
||||
|
||||
@discourseComputed("selectableUserBadges", "selectedUserBadgeId")
|
||||
selectedUserBadge(selectableUserBadges, selectedUserBadgeId) {
|
||||
return selectableUserBadges.findBy("id", parseInt(selectedUserBadgeId));
|
||||
return selectableUserBadges.findBy("id", parseInt(selectedUserBadgeId, 10));
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -105,7 +105,7 @@ export default Component.extend({
|
||||
}
|
||||
}
|
||||
|
||||
const topic = this.topics.findBy("id", parseInt(topicId));
|
||||
const topic = this.topics.findBy("id", parseInt(topicId, 10));
|
||||
this.appEvents.trigger("topic-entrance:show", {
|
||||
topic,
|
||||
position: target.offset()
|
||||
|
@ -273,7 +273,7 @@ export default Component.extend({
|
||||
const lastMatch = matchingPlaceholder[matchingPlaceholder.length - 1];
|
||||
const regex = new RegExp(regexString);
|
||||
const orderNr = regex.exec(lastMatch)[1]
|
||||
? parseInt(regex.exec(lastMatch)[1]) + 1
|
||||
? parseInt(regex.exec(lastMatch)[1], 10) + 1
|
||||
: 1;
|
||||
data.orderNr = orderNr;
|
||||
const filenameWithOrderNr = `${filename}(${orderNr})`;
|
||||
@ -823,7 +823,7 @@ export default Component.extend({
|
||||
$(e.target)
|
||||
.parent()
|
||||
.attr("data-image-index")
|
||||
);
|
||||
, 10);
|
||||
|
||||
const scale = e.target.attributes["data-scale"].value;
|
||||
const matchingPlaceholder = this.get("composer.reply").match(
|
||||
|
@ -138,7 +138,7 @@ class Toolbar {
|
||||
shortcut: "Shift+7",
|
||||
title: "composer.olist_title",
|
||||
perform: e =>
|
||||
e.applyList(i => (!i ? "1. " : `${parseInt(i) + 1}. `), "list_item")
|
||||
e.applyList(i => (!i ? "1. " : `${parseInt(i, 10) + 1}. `), "list_item")
|
||||
});
|
||||
|
||||
if (siteSettings.support_mixed_text_direction) {
|
||||
|
@ -76,7 +76,7 @@ export default buildCategoryPanel("general", {
|
||||
name,
|
||||
color,
|
||||
text_color: textColor,
|
||||
parent_category_id: parseInt(parentCategoryId),
|
||||
parent_category_id: parseInt(parentCategoryId, 10),
|
||||
read_restricted: category.get("read_restricted")
|
||||
});
|
||||
return categoryBadgeHTML(c, { link: false });
|
||||
|
@ -38,7 +38,7 @@ export default buildCategoryPanel("security", {
|
||||
if (!this.get("category.is_special")) {
|
||||
this.category.addPermission({
|
||||
group_name: group + "",
|
||||
permission: PermissionType.create({ id: parseInt(id) })
|
||||
permission: PermissionType.create({ id: parseInt(id, 10) })
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ export default Component.extend({
|
||||
);
|
||||
$diversityScales.on("click", event => {
|
||||
const $selectedDiversity = $(event.currentTarget);
|
||||
this.set("selectedDiversity", parseInt($selectedDiversity.data("level")));
|
||||
this.set("selectedDiversity", parseInt($selectedDiversity.data("level"), 10));
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
@ -19,7 +19,7 @@ export default Component.extend({
|
||||
|
||||
@discourseComputed("model.visibility_level", "model.public_admission")
|
||||
disableMembershipRequestSetting(visibility_level, publicAdmission) {
|
||||
visibility_level = parseInt(visibility_level);
|
||||
visibility_level = parseInt(visibility_level, 10);
|
||||
return publicAdmission || visibility_level > 1;
|
||||
},
|
||||
|
||||
@ -28,7 +28,7 @@ export default Component.extend({
|
||||
"model.allow_membership_requests"
|
||||
)
|
||||
disablePublicSetting(visibility_level, allowMembershipRequests) {
|
||||
visibility_level = parseInt(visibility_level);
|
||||
visibility_level = parseInt(visibility_level, 10);
|
||||
return allowMembershipRequests || visibility_level > 1;
|
||||
}
|
||||
});
|
||||
|
@ -6,10 +6,10 @@ export default Ember.TextField.extend({
|
||||
@discourseComputed("number")
|
||||
value: {
|
||||
get(number) {
|
||||
return parseInt(number);
|
||||
return parseInt(number, 10);
|
||||
},
|
||||
set(value) {
|
||||
const num = parseInt(value);
|
||||
const num = parseInt(value, 10);
|
||||
if (isNaN(num)) {
|
||||
this.set("invalid", true);
|
||||
return value;
|
||||
|
@ -65,7 +65,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
|
||||
|
||||
_handlePanDone(offset, event) {
|
||||
const $window = $(window);
|
||||
const windowWidth = parseInt($window.width());
|
||||
const windowWidth = $window.width();
|
||||
const $menuPanels = $(".menu-panel");
|
||||
const menuOrigin = this._panMenuOrigin;
|
||||
this._shouldMenuClose(event, menuOrigin)
|
||||
@ -246,16 +246,16 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
|
||||
}
|
||||
|
||||
const $window = $(window);
|
||||
const windowWidth = parseInt($window.width());
|
||||
const windowWidth = $window.width();
|
||||
|
||||
const headerWidth = $("#main-outlet .container").width() || 1100;
|
||||
const remaining = parseInt((windowWidth - headerWidth) / 2);
|
||||
const remaining = (windowWidth - headerWidth) / 2;
|
||||
const viewMode = remaining < 50 ? "slide-in" : "drop-down";
|
||||
|
||||
$menuPanels.each((idx, panel) => {
|
||||
const $panel = $(panel);
|
||||
const $headerCloak = $(".header-cloak");
|
||||
let width = parseInt($panel.attr("data-max-width") || 300);
|
||||
let width = parseInt($panel.attr("data-max-width"), 10) || 300;
|
||||
if (windowWidth - width < 50) {
|
||||
width = windowWidth - 50;
|
||||
}
|
||||
@ -281,7 +281,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
|
||||
const $panelBody = $(".panel-body", $panel);
|
||||
// 2 pixel fudge allows for firefox subpixel sizing stuff causing scrollbar
|
||||
let contentHeight =
|
||||
parseInt($(".panel-body-contents", $panel).height()) + 2;
|
||||
$(".panel-body-contents", $panel).height() + 2;
|
||||
|
||||
// We use a mutationObserver to check for style changes, so it's important
|
||||
// we don't set it if it doesn't change. Same goes for the $panelBody!
|
||||
@ -300,7 +300,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
|
||||
}
|
||||
|
||||
// adjust panel height
|
||||
const fullHeight = parseInt($window.height());
|
||||
const fullHeight = $window.height();
|
||||
const offsetTop = $panel.offset().top;
|
||||
const scrollTop = $window.scrollTop();
|
||||
|
||||
@ -373,14 +373,12 @@ export function headerHeight() {
|
||||
|
||||
const headerOffset = $header.offset();
|
||||
const headerOffsetTop = headerOffset ? headerOffset.top : 0;
|
||||
return parseInt(
|
||||
$header.outerHeight() + headerOffsetTop - $(window).scrollTop()
|
||||
);
|
||||
return $header.outerHeight() + headerOffsetTop - $(window).scrollTop();
|
||||
}
|
||||
|
||||
export function headerTop() {
|
||||
const $header = $("header.d-header");
|
||||
const headerOffset = $header.offset();
|
||||
const headerOffsetTop = headerOffset ? headerOffset.top : 0;
|
||||
return parseInt(headerOffsetTop - $(window).scrollTop());
|
||||
return headerOffsetTop - $(window).scrollTop();
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ export default Component.extend(CleansUp, {
|
||||
const $self = $(this.element);
|
||||
const width = $self.width();
|
||||
const height = $self.height();
|
||||
pos.left = parseInt(pos.left) - width / 2;
|
||||
pos.top = parseInt(pos.top) - height / 2;
|
||||
pos.left = parseInt(pos.left, 10) - width / 2;
|
||||
pos.top = parseInt(pos.top, 10) - height / 2;
|
||||
|
||||
const windowWidth = $(window).width();
|
||||
if (pos.left + width > windowWidth) {
|
||||
|
@ -5,7 +5,7 @@ import { observes } from "discourse-common/utils/decorators";
|
||||
import optionalService from "discourse/lib/optional-service";
|
||||
|
||||
const headerPadding = () => {
|
||||
let topPadding = parseInt($("#main-outlet").css("padding-top")) + 3;
|
||||
let topPadding = parseInt($("#main-outlet").css("padding-top"), 10) + 3;
|
||||
const iPadNavHeight = $(".footer-nav-ipad .footer-nav").height();
|
||||
if (iPadNavHeight) {
|
||||
topPadding += iPadNavHeight;
|
||||
|
@ -702,7 +702,7 @@ export default Controller.extend({
|
||||
|
||||
if (this.get("model.editingPost")) {
|
||||
this.appEvents.trigger("post-stream:refresh", {
|
||||
id: parseInt(result.responseJson.id)
|
||||
id: parseInt(result.responseJson.id, 10)
|
||||
});
|
||||
if (result.responseJson.post.post_number === 1) {
|
||||
this.appEvents.trigger("header:update-topic", composer.topic);
|
||||
|
@ -24,7 +24,7 @@ export default Controller.extend(ModalFunctionality, {
|
||||
},
|
||||
|
||||
_jumpToIndex(postsCounts, postNumber) {
|
||||
const where = Math.min(postsCounts, Math.max(1, parseInt(postNumber)));
|
||||
const where = Math.min(postsCounts, Math.max(1, parseInt(postNumber, 10)));
|
||||
this.jumpToIndex(where);
|
||||
this._close();
|
||||
},
|
||||
|
@ -115,7 +115,7 @@ export default Controller.extend(ModalFunctionality, Ember.Evented, {
|
||||
|
||||
actions: {
|
||||
change(cat, e) {
|
||||
let position = parseInt($(e.target).val());
|
||||
let position = parseInt($(e.target).val(), 10);
|
||||
let amount = Math.min(
|
||||
Math.max(position, 0),
|
||||
this.categoriesOrdered.length - 1
|
||||
|
@ -22,7 +22,7 @@ registerUnbound("number", (orig, params) => {
|
||||
|
||||
let title = I18n.toNumber(orig, { precision: 0 });
|
||||
if (params.numberKey) {
|
||||
title = I18n.t(params.numberKey, { number: title, count: parseInt(orig) });
|
||||
title = I18n.t(params.numberKey, { number: title, count: parseInt(orig, 10) });
|
||||
}
|
||||
|
||||
let classNames = "number";
|
||||
|
@ -13,7 +13,7 @@ export default {
|
||||
window.location.search.indexOf("?preview_theme_id=") === 0
|
||||
) {
|
||||
// force preview theme id to always be carried along
|
||||
const themeId = parseInt(window.location.search.slice(18).split("&")[0]);
|
||||
const themeId = parseInt(window.location.search.slice(18).split("&")[0], 10);
|
||||
if (!isNaN(themeId)) {
|
||||
const patchState = function(f) {
|
||||
const patched = window.history[f];
|
||||
|
@ -26,7 +26,7 @@ export default {
|
||||
const players = $("audio", $elem);
|
||||
if (players.length) {
|
||||
players.on("play", () => {
|
||||
const postId = parseInt($elem.closest("article").data("post-id"));
|
||||
const postId = parseInt($elem.closest("article").data("post-id"), 10);
|
||||
if (postId) {
|
||||
api.preventCloak(postId);
|
||||
}
|
||||
|
@ -195,11 +195,11 @@ export function durationTiny(distance, ageOpts) {
|
||||
const numYears = distanceInMinutes / 525600.0;
|
||||
const remainder = numYears % 1;
|
||||
if (remainder < 0.25) {
|
||||
formatted = t("about_x_years", { count: parseInt(numYears) });
|
||||
formatted = t("about_x_years", { count: Math.floor(numYears) });
|
||||
} else if (remainder < 0.75) {
|
||||
formatted = t("over_x_years", { count: parseInt(numYears) });
|
||||
formatted = t("over_x_years", { count: Math.floor(numYears) });
|
||||
} else {
|
||||
formatted = t("almost_x_years", { count: parseInt(numYears) + 1 });
|
||||
formatted = t("almost_x_years", { count: Math.floor(numYears) + 1 });
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -67,7 +67,7 @@ KeyValueStore.prototype = {
|
||||
if (!safeLocalStorage) {
|
||||
return def;
|
||||
}
|
||||
const result = parseInt(this.get(key));
|
||||
const result = parseInt(this.get(key), 10);
|
||||
if (!isFinite(result)) {
|
||||
return def;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ function userAgentVersionChecker(agent, version, mobileView) {
|
||||
new RegExp(`${agent}\/(\\d+)\\.\\d`)
|
||||
);
|
||||
if (uaMatch && mobileView) return false;
|
||||
if (!uaMatch || parseInt(uaMatch[1]) < version) return false;
|
||||
if (!uaMatch || parseInt(uaMatch[1], 10) < version) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ export default class {
|
||||
// Save unique topic IDs up to a max
|
||||
let topicIds = storage.get("anon-topic-ids");
|
||||
if (topicIds) {
|
||||
topicIds = topicIds.split(",").map(e => parseInt(e));
|
||||
topicIds = topicIds.split(",").map(e => parseInt(e, 10));
|
||||
} else {
|
||||
topicIds = [];
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ export class Tag {
|
||||
try {
|
||||
const level = parseInt(
|
||||
attrs.style.match(/level./)[0].replace("level", "")
|
||||
);
|
||||
, 10);
|
||||
indent = Array(level).join("\t") + indent;
|
||||
} finally {
|
||||
if (attrs.class === "MsoListParagraphCxSpFirst") {
|
||||
@ -448,7 +448,7 @@ export class Tag {
|
||||
const bullet = text.match(/\n\t*\*/)[0];
|
||||
|
||||
for (
|
||||
let i = parseInt(this.element.attributes.start || 1);
|
||||
let i = parseInt(this.element.attributes.start || 1, 10);
|
||||
text.includes(bullet);
|
||||
i++
|
||||
) {
|
||||
|
@ -61,10 +61,10 @@ export default RestModel.extend({
|
||||
}
|
||||
const remaining = parseInt(
|
||||
data.xhr.getResponseHeader("Discourse-Actions-Remaining") || 0
|
||||
);
|
||||
, 10);
|
||||
const max = parseInt(
|
||||
data.xhr.getResponseHeader("Discourse-Actions-Max") || 0
|
||||
);
|
||||
, 10);
|
||||
return { acted: true, remaining, max };
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -236,7 +236,7 @@ const Group = RestModel.extend({
|
||||
}
|
||||
|
||||
if (opts.categoryId) {
|
||||
data.category_id = parseInt(opts.categoryId);
|
||||
data.category_id = parseInt(opts.categoryId, 10);
|
||||
}
|
||||
|
||||
return ajax(`/groups/${this.name}/${type}.json`, { data }).then(posts => {
|
||||
|
@ -339,7 +339,7 @@ export default createWidget("hamburger-menu", {
|
||||
this.sendWidgetAction("toggleHamburger");
|
||||
} else {
|
||||
const $window = $(window);
|
||||
const windowWidth = parseInt($window.width(), 10);
|
||||
const windowWidth = $window.width();
|
||||
const $panel = $(".menu-panel");
|
||||
$panel.addClass("animate");
|
||||
const panelOffsetDirection = this.site.mobileView ? "left" : "right";
|
||||
|
@ -22,7 +22,7 @@ createWidgetFrom(
|
||||
const description = I18n.t(
|
||||
"notifications.liked_consolidated_description",
|
||||
{
|
||||
count: parseInt(data.count)
|
||||
count: parseInt(data.count, 10)
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -79,7 +79,7 @@ export default createWidget("link", {
|
||||
|
||||
const currentUser = this.currentUser;
|
||||
if (currentUser && attrs.badgeCount) {
|
||||
const val = parseInt(currentUser.get(attrs.badgeCount));
|
||||
const val = parseInt(currentUser.get(attrs.badgeCount), 10);
|
||||
if (val > 0) {
|
||||
const title = attrs.badgeTitle ? I18n.t(attrs.badgeTitle) : "";
|
||||
result.push(" ");
|
||||
|
@ -709,7 +709,7 @@ export default createWidget("post", {
|
||||
|
||||
// only warn once per day
|
||||
const yesterday = new Date().getTime() - 1000 * 60 * 60 * 24;
|
||||
if (lastWarnedLikes && parseInt(lastWarnedLikes) > yesterday) {
|
||||
if (lastWarnedLikes && parseInt(lastWarnedLikes, 10) > yesterday) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ export default createWidget("user-menu", {
|
||||
this.sendWidgetAction("toggleUserMenu");
|
||||
} else {
|
||||
const $window = $(window);
|
||||
const windowWidth = parseInt($window.width(), 10);
|
||||
const windowWidth = $window.width();
|
||||
const $panel = $(".menu-panel");
|
||||
$panel.addClass("animate");
|
||||
$panel.css("right", -windowWidth);
|
||||
|
@ -145,22 +145,22 @@ function renderImage(tokens, idx, options, env, slf) {
|
||||
// calculate using percentage
|
||||
if (match[5] && match[6] && match[6] === "%") {
|
||||
let percent = parseFloat(match[5]) / 100.0;
|
||||
width = parseInt(width * percent);
|
||||
height = parseInt(height * percent);
|
||||
width = parseInt(width * percent, 10);
|
||||
height = parseInt(height * percent, 10);
|
||||
}
|
||||
|
||||
// calculate using only given width
|
||||
if (match[5] && match[6] && match[6] === "x") {
|
||||
let wr = parseFloat(match[5]) / width;
|
||||
width = parseInt(match[5]);
|
||||
height = parseInt(height * wr);
|
||||
width = parseInt(match[5], 10);
|
||||
height = parseInt(height * wr, 10);
|
||||
}
|
||||
|
||||
// calculate using only given height
|
||||
if (match[5] && match[4] && match[4] === "x" && !match[6]) {
|
||||
let hr = parseFloat(match[5]) / height;
|
||||
height = parseInt(match[5]);
|
||||
width = parseInt(width * hr);
|
||||
height = parseInt(match[5], 10);
|
||||
width = parseInt(width * hr, 10);
|
||||
}
|
||||
|
||||
if (token.attrIndex("width") === -1) {
|
||||
|
@ -52,7 +52,7 @@ export default ComboBox.extend(TagsMixin, {
|
||||
this.limit ||
|
||||
this.maximum ||
|
||||
this.get("siteSettings.max_tags_per_topic")
|
||||
)
|
||||
, 10)
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -47,7 +47,7 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
||||
this.limit ||
|
||||
this.maximum ||
|
||||
this.get("siteSettings.max_tags_per_topic")
|
||||
)
|
||||
, 10)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -14,7 +14,7 @@ export default {
|
||||
$(".lazyYT", $elem).lazyYT({
|
||||
onPlay(e, $el) {
|
||||
// don't cloak posts that have playing videos in them
|
||||
const postId = parseInt($el.closest("article").data("post-id"));
|
||||
const postId = parseInt($el.closest("article").data("post-id"), 10);
|
||||
if (postId) {
|
||||
api.preventCloak(postId);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ export default Controller.extend({
|
||||
)
|
||||
pollMaxOptions(isRegular, isMultiple, isNumber, count, pollMin, pollStep) {
|
||||
if (isRegular) return;
|
||||
const pollMinInt = parseInt(pollMin) || 1;
|
||||
const pollMinInt = parseInt(pollMin, 10) || 1;
|
||||
|
||||
if (isMultiple) {
|
||||
return this._comboboxOptions(pollMinInt + 1, count + 1);
|
||||
@ -159,7 +159,7 @@ export default Controller.extend({
|
||||
@computed("isNumber", "pollMax")
|
||||
pollStepOptions(isNumber, pollMax) {
|
||||
if (!isNumber) return;
|
||||
return this._comboboxOptions(1, (parseInt(pollMax) || 1) + 1);
|
||||
return this._comboboxOptions(1, (parseInt(pollMax, 10) || 1) + 1);
|
||||
},
|
||||
|
||||
@computed(
|
||||
|
@ -436,25 +436,25 @@ export default function() {
|
||||
|
||||
this.get("/t/:topic_id/posts.json", request => {
|
||||
const postIds = request.queryParams.post_ids;
|
||||
const postNumber = parseInt(request.queryParams.post_number);
|
||||
const postNumber = parseInt(request.queryParams.post_number, 10);
|
||||
let posts;
|
||||
|
||||
if (postIds) {
|
||||
posts = postIds.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "true") {
|
||||
posts = _.range(postNumber + 1, postNumber + 6).map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
}));
|
||||
} else if (postNumber && request.queryParams.asc === "false") {
|
||||
posts = _.range(postNumber - 5, postNumber)
|
||||
.reverse()
|
||||
.map(p => ({
|
||||
id: parseInt(p),
|
||||
post_number: parseInt(p)
|
||||
id: parseInt(p, 10),
|
||||
post_number: parseInt(p, 10)
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ export default function(helpers) {
|
||||
return response(200, {
|
||||
reviewable_perform_result: {
|
||||
success: true,
|
||||
remove_reviewable_ids: [parseInt(request.params.id)]
|
||||
remove_reviewable_ids: [parseInt(request.params.id, 10)]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ export default function(helpers) {
|
||||
const { response, success, parsePostData } = helpers;
|
||||
|
||||
this.get("/fruits/:id", function(request) {
|
||||
const fruit = fruits.find(f => f.id === parseInt(request.params.id));
|
||||
const fruit = fruits.find(f => f.id === parseInt(request.params.id, 10));
|
||||
return response({ __rest_serializer: "1", fruit, farmers, colors });
|
||||
});
|
||||
|
||||
@ -58,7 +58,7 @@ export default function(helpers) {
|
||||
});
|
||||
|
||||
this.get("/widgets/:widget_id", function(request) {
|
||||
const w = _widgets.findBy("id", parseInt(request.params.widget_id));
|
||||
const w = _widgets.findBy("id", parseInt(request.params.widget_id, 10));
|
||||
if (w) {
|
||||
return response({ widget: w, extras: { hello: "world" } });
|
||||
} else {
|
||||
@ -91,7 +91,7 @@ export default function(helpers) {
|
||||
result = result.filterBy("name", qp.name);
|
||||
}
|
||||
if (qp.id) {
|
||||
result = result.filterBy("id", parseInt(qp.id));
|
||||
result = result.filterBy("id", parseInt(qp.id, 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user