mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
a737090442
- add User.staff scope - inject MessageBus into Ember views (so it can be used by the poll plugin) - REFACTOR: use more accurate is_first_post? method instead of post_number == 1 - FEATURE: add support for JSON-typed custom fields - FEATURE: allow plugins to add validation - FEATURE: add post_custom_fields to PostSerializer - FEATURE: allow plugins to whitelist post_custom_fields - FIX: don't bump when post did not save successfully - FEATURE: polls are supported in any post - FEATURE: allow for multiple polls in the same post - FEATURE: multiple choice polls - FEATURE: rating polls - FEATURE: new dialect allowing users to preview polls in the composer
16 lines
700 B
JavaScript
16 lines
700 B
JavaScript
// from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor
|
|
|
|
export default function(type, value, exp) {
|
|
// If the exp is undefined or zero...
|
|
if (typeof exp === 'undefined' || +exp === 0) { return Math[type](value); }
|
|
value = +value;
|
|
exp = +exp;
|
|
// If the value is not a number or the exp is not an integer...
|
|
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { return NaN; }
|
|
// Shift
|
|
value = value.toString().split('e');
|
|
value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
|
|
// Shift back
|
|
value = value.toString().split('e');
|
|
return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
|
|
}
|