');
}
function SetBanned(IsBanned, EndBanTime = null)
{
if (IsBanned && EndBanTime != "Ended") {
if (EndBanTime == null || EndBanTime == "") {
$("#BannedNav").html('あなたは永久BANされています。詳細はこちら
')
} else
{
let bandate = new Date(EndBanTime)
bandate.setTime(bandate.getTime() + 1000 * 60 * 60 * 9);// JSTに変換
let bandatestring =
bandate.getFullYear() + "年" + (bandate.getMonth() + 1) + "月" +
bandate.getDate() + "日" + bandate.getHours() + "時" +
bandate.getMinutes() + "分" + bandate.getSeconds()+"秒"
$("#BannedNav").html('あなたは'+bandatestring+'までBANされています。詳細はこちら
')
}
console.log("Set Banned");
} else
{
$("#BannedNav").html("")
console.log("Set Not Banned");
}
}
//$(document).ready(function () {
var Account_IsLogined = false;
var Account_Banned_Data = $.cookie('cached_banned');
var Account_Banned = Account_Banned_Data != null;
var Account_name = $.cookie('cached_name');
if (Account_name) {
SetBanned(Account_Banned, Account_Banned_Data);
console.log("Updated Logined By Cache");
SetAccountLogined(Account_name);
Account_IsLogined = true;
} else {
$("HEADER_NAV").html(
'登録' +
'ログイン')
Account_IsLogined = false;
}
try {
// Cookieのsessionを参照する
var session = $.cookie('Id');
// sessionがある場合
if (session) {
$.ajax({
//名前をキャッシュ済みのAPIから取得する
url: "/capi/userdatabyid?id=" + session + "&needdata=nb",
type: "GET",
success: function (data) {
console.log("Ajax successed");
//成功したら、dataを取得
if (data.endsWith("\nBanned")) {
Account_Banned = true;
let BanReason = data.split("\n")[1];
let EndBanTime = new Date(BanReason);
SetBanned(true, BanReason);
if (BanReason == "Ended") {
if (!location.href.endsWith(".supernewroles.com/banned")) {
location.href = "/banned";
}
$.removeCookie('cached_banned');
} else {
if (!Account_Banned && !location.href.endsWith(".supernewroles.com/banned")) {
location.href = "/banned";
}
$.cookie('cached_banned', toISOStringWithTimezone(EndBanTime), { expires: EndBanTime, path: '/' });
}
data = data.split("\n")[0];
} else
{
Account_Banned = false;
SetBanned(false, null);
$.removeCookie('cached_banned');
}
var name = data;
//nameを取得したら、Account_nameに代入
Account_name = name;
//Account_IsLoginedをtrueにする
Account_IsLogined = true;
SetAccountLogined(Account_name);
// 1分でCookieを削除
var date = new Date();
date.setTime(date.getTime() + (60 * 1000));
$.cookie('cached_name', Account_name, { expires: date, path: '/'});
},
error: function (data) {
console.log("Ajas failed");
//失敗したら、Account_IsLoginedをfalseにする
Account_IsLogined = false;
$.removeCookie('cached_name');
$.removeCookie('cached_banned');
}
});
} else {
console.log("Session failed");
$.removeCookie('cached_name');
}
} catch (e) {
console.log("error:" + e)
Account_IsLogined = false;
Account_name = "";
}
if (Account_name) {
console.log("Updated Logined By Cache");
SetAccountLogined(Account_name);
Account_IsLogined = true;
} else {
console.log("Removed Header");
$("HEADER_NAV").html(
'登録' +
'ログイン')
Account_IsLogined = false;
}
//});
-->