From f1528326bee3d33fdb6e32791fba9b8b584b79e5 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 22 Jan 2019 14:48:56 +0800 Subject: [PATCH] 1 --- chapter2/mysite/myapp/static/scripts/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chapter2/mysite/myapp/static/scripts/index.js b/chapter2/mysite/myapp/static/scripts/index.js index 5ec6d67..60abf9a 100755 --- a/chapter2/mysite/myapp/static/scripts/index.js +++ b/chapter2/mysite/myapp/static/scripts/index.js @@ -2,6 +2,10 @@ var symptomName = last_month_day(); $(function(){ + var to_g = function(v){ + return (parseInt(v)/1024/1024).toFixed(1); + } + //更新抓取信息 setInterval(function(){ @@ -18,8 +22,8 @@ $(function(){ $.ajax('/myapp/api/platform_info.json').done(function(data){ $('#disk_freed').html(data.disk_freed+'G'); $('#disk_used').html(data.disk_used+'G'); - $('#mem_free').html(data.mem_free+'G'); - $('#mem_used').html(data.mem_used+'G'); + $('#mem_free').html(to_g(data.mem_total-data.mem_used)+'G'); + $('#mem_used').html(to_g(data.mem_used)+'G'); $('#tasks_count').html(data.tasks); });