Skip to content

允许用户在登录时自动加载个人简介 #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ See license [here](https://github.com/CodeforcesContestHelper/CCHv2/blob/main/LI
## Donation
https://afdian.net/@cfcontesthelper

## Chatting
## Star History

- Discord: [click here](https://discord.gg/natZEphAmS)
- QQ: group number: 458610798
[![Star History Chart](https://api.star-history.com/svg?repos=CodeforcesContestHelper/CCHv2&type=Date)](https://star-history.com/#CodeforcesContestHelper/CCHv2)
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1102,6 +1102,16 @@
<i class="fas fa-check-square"></i>
</div>
</div>
<div class="settingsUI settingsRadio" for="loadMyInfoWhenLogin">
<div class="settingsRadioInfo">
<div class="settingsRadioInfoMain">Radio Name</div>
<div class="settingsRadioInfoAddition">Radio Addition</div>
</div>
<div class="settingsRadioButton">
<i class="far fa-square"></i>
<i class="fas fa-check-square"></i>
</div>
</div>
<div class="settingsHeader" info="settingsProblemPage"></div>
<div class="settingsUI settingsInput" for="statementFontFamily">
<div class="settingsInputInfo">
8 changes: 8 additions & 0 deletions js/authorize.js
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@ function loadLoginType(){
currentLoginHandle = hdl;
if(problemNewWinLoaded) initProblemNewWin();
$(".settingsLoginType").html(`<span info='currentUser' argv=["${hdl}"]>${languageOption.general.currentUser.format([hdl])}</span>`);
if(settings.loadMyInfoWhenLogin)
{
infoLoadUsername(currentLoginHandle,true);
}
}
else{
currentLoginHandle = "";
@@ -122,6 +126,10 @@ function submitLogin(){
currentLoginHandle = hdl;
if(problemNewWinLoaded) initProblemNewWin();
$(".settingsLoginType").html(`<span info='currentUser' argv=["${hdl}"]>${languageOption.general.currentUser.format([hdl])}</span>`);
if(settings.loadMyInfoWhenLogin)
{
infoLoadUsername(currentLoginHandle,true);
}
},
error: function(){
$(".settingsLoginButton").html(`<span info='errorLoginFailed'>${languageOption.error.errorLoginFailed}</span>`);
8 changes: 8 additions & 0 deletions js/locale.js
Original file line number Diff line number Diff line change
@@ -322,6 +322,10 @@ var lang_en = {
"<span class='settingsInfoIcon fas fa-bell'></span> Open Notification",
"Choose if notifications of hacks, contest notifications or submission results should be sent."
],
loadMyInfoWhenLogin: [
"<span class='settingsInfoIcon fas fa-th-list'></span> Load introduction when logging in",
"In order to avoid opening the profile to see a blank, but also click to change the user.<span class='red'>It may consume a little bit of mobile data.</span>"
],
useApiKeys: [
"<span class='settingsInfoIcon fas fa-user-secret'></span> Use API Keys",
"Enable to authorize APIs to fetch private informations. You can go to /settings/api to generate API keys. <span class='red'>We will not use your keys for other purposes.</span>"
@@ -708,6 +712,10 @@ var lang_zh = {
"<span class='settingsInfoIcon fas fa-bell'></span> 开启提醒",
"选择是否发送包含 hack,比赛通知或者提交结果的提醒。"
],
loadMyInfoWhenLogin: [
"<span class='settingsInfoIcon fas fa-th-list'></span> 登录时自动加载个人简介",
"免得打开个人简介时看到一片空白,还要点击更换用户。<span class='red'>这可能会需要一点流量。</span>"
],
useApiKeys: [
"<span class='settingsInfoIcon fas fa-user-secret'></span> 使用 API Keys",
"开启后可以给 API 授权以加载私人内容。你可以前往 /settings/api 生成 API Keys。<span class='red'>我们保证不会将其用于其他用途。</span>"
15 changes: 9 additions & 6 deletions js/profile.js
Original file line number Diff line number Diff line change
@@ -1013,12 +1013,15 @@ $(".profileSubmissionPageRight").click(function(){
profileRefreshSubmissionListPages();
});

function infoLoadUsername(un){
$(".infoContent > .contentRowInfo").css("left", "-920px");
$("[for=infoContent]").click();
for(var i=0; i<=2; i++)
if(profileInfoLoaders[i] != null)
profileInfoLoaders[i].abort();
function infoLoadUsername(un,donot_jump=false){
if(!donot_jump)
{
$(".infoContent > .contentRowInfo").css("left", "-920px");
$("[for=infoContent]").click();
for(var i=0; i<=2; i++)
if(profileInfoLoaders[i] != null)
profileInfoLoaders[i].abort();
}
var hCode = (new Date()).getTime();
profileInfoCurrentAsked = un + '#' + hCode;
delete(profileInfoDatas[0]);
11 changes: 11 additions & 0 deletions js/settings.js
Original file line number Diff line number Diff line change
@@ -454,6 +454,16 @@ var settingsFunctions = {
return settings.openNotification;
}
},
loadMyInfoWhenLogin: {
initial: function(){
return settings.loadMyInfoWhenLogin;
},
change: function(){
settings.loadMyInfoWhenLogin = !settings.loadMyInfoWhenLogin;
saveSettings();
return settings.loadMyInfoWhenLogin;
}
},
useApiKeys: {
initial: function(){
return settings.useApiKeys;
@@ -530,6 +540,7 @@ var currentDefaultSettings = {
statementFontSize: 16,
statementDefaultLanguage: 50,
openNotification: true,
loadMyInfoWhenLogin: false,
useApiKeys: false,
apiKey: "",
apiSecret: "",