已掉线,重新登录

首页 > 绿虎论坛 > 网页插件 (发帖)

标题: [已失效] 为首页添加一个七牛云流量图

作者: @Ta

时间: 2019-06-14发布,2022-06-17修改

点击: 6926
被下沉

人工监控,避免流量飞跑
效果(展开查看代码):

虎绿林离开了七牛云,已失效。

导入网页插件:七牛云流量图(当前用户:0,总安装次数:0)
<script src="/tpl/jhin/js/jquery-3.1.1.min.js"></script>
<script src="/tpl/jhin/js/chartjs/analytics.js"></script>
<script src="/tpl/jhin/js/chartjs/Chart.js" type="text/javascript"></script>
<script src="/tpl/jhin/js/chartjs/utils.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
	if (location.pathname == "/q.php/index.index.html") {
		$('.layout-head').html('<canvas id="qiniu_traffic" style="display: block; height: 300px; width: 100%;" class="chartjs-render-monitor"></canvas>');
		var ctx = document.getElementById('qiniu_traffic').getContext('2d');
		window.myLine = new Chart(ctx, config);
		$.get('https://hu60.cn/q.php/api.qiniu_traffic.json', function(result) {
			if (result.data) {
				config.data.labels = result.time.map(function(time) {
					return time.split(' ')[0];
				});
				config.data.datasets[0].data = result.data.china;
				config.data.datasets[1].data = result.data.oversea;
				window.myLine = new Chart(ctx, config);
			}
		});
	}
});
function bytes_format(bytes) {
	if (bytes < 1024)
		return bytes + ' B';
	if (bytes < 1048576)
		return (bytes / 1024).toFixed(0) + ' KB';
	if (bytes < 1073741824)
		return (bytes / 1048576).toFixed(0) + ' MB';
	return (bytes / 1073741824).toFixed(2) + ' GB';
}
var config = {
	type: 'line',
	data: {
		labels: [],
		datasets: [{
			label: '中国',
			backgroundColor: window.chartColors.red,
			borderColor: window.chartColors.red,
			data: [],
			fill: false,
		},{
			label: '海外',
			backgroundColor: window.chartColors.green,
			borderColor: window.chartColors.green,
			data: [],
			fill: false,
		}]
	},
	options: {
		responsive: true,
		title: {
			display: true,
			text: '七牛云流量图'
		},
		tooltips: {
			mode: 'index',
			intersect: false,
			callbacks: {
				label: function (item) {
					return config.data.datasets[item.datasetIndex].label + ': ' + bytes_format(item.yLabel);
				}
			},
		},
		hover: {
			mode: 'nearest',
			intersect: true
		},
		scales: {
			xAxes: [{
				display: true,
				scaleLabel: {
					display: false,
					labelString: '日期'
				}
			}],
			yAxes: [{
				display: true,
				scaleLabel: {
					display: false,
					labelString: '流量'
				},
				ticks: {
					callback: bytes_format
				}
			}]
		}
	}
};
</script>

[隐藏样式|查看源码]


『回复列表(11|隐藏机器人聊天)』

1.
我是一名斗者,我正在被一名斗帝追杀,但我一点都不慌,因为他的马没我快,架!!!
(/@Ta/2019-06-14 23:59//)

2.

我不在乎流量的
小米5黑色低配版

(/@Ta/2019-06-15 00:55//)

3. pr合一下吗。经典主题 搜索回复展示的链接不正确。
(/@Ta/2019-06-15 12:30//)

4.

@iola1999,已经合并,感谢

(/@Ta/2019-06-15 12:56//)

5.
怎么用呢?舍不得气泡回复代码 
华为荣耀6Plus的孤单
(/@Ta/2019-06-16 01:53//)

6.
添加在后面? 
华为荣耀6Plus的孤单
(/@Ta/2019-06-16 01:54//)

7.
OK了,可以看到。不过我不知道有何用?对个人来说 
华为荣耀6Plus的孤单
(/@Ta/2019-06-16 01:55//)

8.

@艾木友尔尔巴,估计对你没有用。我做给自己看的

(/@Ta/2019-06-17 21:53//)

9.
3aad039ee731aa6791863f5f5d37ef66126013.jpg
(/@Ta/2019-06-18 03:26//)

10. 950a83941fa2ee3fab1f13230e762261.jpg
(/@Ta/2019-06-18 10:22//)

11. 其实是为了提醒大家活跃点 不要老是走低
(/@Ta/2019-06-26 11:08//)

回复需要登录

7月6日 04:08 星期天

本站由hu60wap6驱动

备案号: 京ICP备18041936号-1