mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-21 07:28:26 +03:00
parent
28984500fb
commit
c962253c33
25
docs/_static/utils.js
vendored
Normal file
25
docs/_static/utils.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
const hasuraUtils = {
|
||||
formatNumber: function(number) {
|
||||
if (typeof number !== "number") return number;
|
||||
|
||||
const SIsymbol = ["", "k", "M", "G", "T", "P", "E"];
|
||||
const absNumber = Math.abs(number);
|
||||
const sign = Math.sign(number);
|
||||
|
||||
// what tier? (determines SI symbol)
|
||||
const tier = Math.log10(absNumber) / 3 | 0;
|
||||
|
||||
// if zero, we don't need a suffix
|
||||
if (tier === 0) return sign * absNumber;
|
||||
|
||||
// get suffix and determine scale
|
||||
const suffix = SIsymbol[tier];
|
||||
const scale = Math.pow(10, tier * 3);
|
||||
|
||||
// scale the number
|
||||
const scaled = absNumber / scale;
|
||||
|
||||
// format number and add suffix
|
||||
return sign * scaled.toFixed(1) + suffix;
|
||||
}
|
||||
}
|
4
docs/_theme/djangodocs/layout.html
vendored
4
docs/_theme/djangodocs/layout.html
vendored
@ -6,6 +6,8 @@
|
||||
|
||||
{% set css_files = css_files + ['_static/djangosite.css', '_static/hasura-custom.css'] %}
|
||||
|
||||
{% set script_files = script_files + ['_static/utils.js'] %}
|
||||
|
||||
{%- if is_landing_page %}
|
||||
{% set css_files = css_files + ['_static/landing.css'] %}
|
||||
{%- endif %}
|
||||
@ -751,7 +753,7 @@
|
||||
})
|
||||
.then(data => {
|
||||
const githubStar = data[0].star_count
|
||||
$(".gitHubCount").html(githubStar);
|
||||
$(".gitHubCount").html(hasuraUtils.formatNumber(githubStar));
|
||||
$(".gitHubBtn").removeClass("hide");
|
||||
})
|
||||
.catch(e => {
|
||||
|
Loading…
Reference in New Issue
Block a user