Chgtaxihe's blog Chgtaxihe's blog
首页
练习
算法学习
读书笔记
小玩意

Chgtaxihe

首页
练习
算法学习
读书笔记
小玩意
  • 网络测试
  • Codeforces 做题情况展示
    • Codeforces做题情况展示
  • 手写图片生成器

Codeforces 做题情况展示

# Codeforces做题情况展示

其实就是一个小网页而已啦

<script src="https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    <script>
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份 
                "d+": this.getDate(), //日 
                "h+": this.getHours(), //小时 
                "m+": this.getMinutes(), //分 
                "s+": this.getSeconds(), //秒 
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
                "S": this.getMilliseconds() //毫秒 
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        };
        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == variable){return pair[1];}
            }
            return(false);
        };
        $(document).ready(function(){
            var url = 'https://codeforces.com/api/user.status?handle=' + getQueryVariable('handle') + '&from=1&count=99999999';
            $.get(url, dataType='JSON', success=function(data,status){
                if (status == "success"){
                    submission = data.result;
                    accepted = submission.filter(function(e){
                        return e.verdict == "OK";
                    });
                    var dates = {};
                    for(var i=0; i<accepted.length; i++){
                        var date = new Date(parseInt(accepted[i].creationTimeSeconds) * 1000);
                        var dateStr = date.Format("yyyy-MM-dd");
                        if(!dates[dateStr]){
                            dates[dateStr] = 0;
                        }
                        dates[dateStr]++;
                    }
                    var keys = Array();
                    var values = Array();
                    for (var k in dates){
                        keys.push(k);
                        values.push(dates[k]);
                    }
                    var ctx = $("#myChart").get(0).getContext("2d");
                    var myChart = new Chart(ctx, {
                        type: 'bar',
                        data: {
                            labels: keys,
                            datasets: [{
                                label: 'Codeforces 做题统计',
                                backgroundColor: 'rgb(56, 134, 230)',
                                borderColor: 'rgb(56, 134, 230)',
                                data: values
                            }]
                        },
                        options: {
                            scales: {
                                yAxes: [{
                                    ticks: {
                                        beginAtZero:true
                                    }
                                }],
                                xAxes: [{
                                    display: false
                                }]
                            }
                        }
                    });
                }
            });
        })
    </script>

<div style="position: relative; height:400; width:600">
            <canvas id="myChart" width="600" height="400"></canvas>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
上次更新: 2021/02/24, 03:37:30
网络测试
手写图片生成器

← 网络测试 手写图片生成器→

最近更新
01
深入理解Java虚拟机
03-04
02
DNS工作原理
02-27
03
改用VuePress啦
02-23
更多文章>
Theme by Vdoing | Copyright © 2019-2021
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式