GithubHelp home page GithubHelp logo

nodebb-plugin-bboj's Introduction

nodebb-plugin-bboj

BBOJ配套使用的插件,用于利用nodebb提供oj前端

关于题目发布

要求发布者为problem-makers小组的成员

在文章中添加如下内容加载题目:

!<@hash>

其中,hash指代题目的hash值,访问bboj后端的/list查看

关于查看题目的权限

要求在bboj单独进行报名

报名可采用以下方法实现:

添加窗口部件:

<div class="list-group">
<button id="enroll" type="button" class="list-group-item disabled" style="width:100%;" disabled>日常训练</button>
</div>

container如下:

<div class="panel panel-default"><div class="panel-heading"><h3 class="panel-title">{{title}}</h3></div>{{body}}</div>

添加如下Js自定义代码:

fetch(`http://localhost:3000/has-user?uid=${app.user.uid}`,{method:'GET',mode:'cors'})
.then((res)=>{
    return res.json()
}).then((res)=>{
    if(res){
        $('#enroll').html($('#enroll').text()+'<span class="badge">已参与</sapn>')
    }else{
        $('#enroll').removeAttr('disabled')
        $('#enroll').removeClass('disabled')
    }
})
$('#enroll').click(()=>{
    $('#enroll').attr('disabled','disabled')
    $('#enroll').addClass('disabled')
    fetch(`http://localhost:3000/enroll?uid=${app.user.uid}&name=${btoa(app.user.username)}`,
    {method:'GET',mode:'cors'})
    .then((res)=>{
        return res.json()
    }).then((res)=>{
        if(!res.success){
            $('#enroll').removeAttr('disabled')
            $('#enroll').removeClass('disabled')
            alert(res.reason)
        }else{
            $('#enroll').html($('#enroll').text()+'<span class="badge">已参与</sapn>')
        }
    })
})

关于添加积分榜

可采用以下方法实现:

添加窗口部件:

<ul class="list-group" id="scoreboard">
</ul>

container如下:

<div class="panel panel-default"><div class="panel-heading"><h3 class="panel-title">{{title}}</h3></div>{{body}}</div>

添加如下Js自定义代码:(此处每10s刷新一次)

function renewScoreboard(){
    fetch('http://localhost:3000/scoreboard',{method:'GET',mode:'cors'})
    .then((res)=>{
        return res.json()
    }).then((data)=>{
        $('#scoreboard').empty()
        for(let it of data){
            $('#scoreboard').append(`
            <li class="list-group-item">
                ${it.name}<span class="badge">${it.score}</span>
            </li>`)
        }
        setTimeout(renewScoreboard,10*1000)
    })
}

renewScoreboard()

nodebb-plugin-bboj's People

Contributors

azurity avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.