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