// locale uojLocaleData = { "username": { "en": "Username", "zh-cn": "用户名" }, "contests::total score": { "en": "Score", "zh-cn": "总分" }, "contests::n participants": { "en": function(n) { return n + " participant" + (n <= 1 ? '' : 's'); }, "zh-cn": function(n) { return "共 " + n + " 名参赛者"; } }, "click-zan::good": { "en": "Good", "zh-cn": "好评" }, "click-zan::bad": { "en": "Bad", "zh-cn": "差评" }, "editor::language": { "en": "Language", "zh-cn": "语言" }, "editor::browse": { "en": "Browse", "zh-cn": "浏览" }, "editor::upload source": { "en": "Source", "zh-cn": "来源" }, "editor::upload by editor": { "en": "Editor", "zh-cn": "编辑器" }, "editor::upload from local": { "en": "Local file", "zh-cn": "本地文件" } }; function uojLocale(name) { locale = $.cookie('uoj_locale'); if (uojLocaleData[name] === undefined) { return ''; } if (uojLocaleData[name][locale] === undefined) { locale = 'zh-cn'; } val = uojLocaleData[name][locale]; if (!$.isFunction(val)) { return val; } else { var args = []; for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); } return val.apply(this, args); } } // utility function strToDate(str) { var a = str.split(/[^0-9]/); return new Date( parseInt(a[0]), parseInt(a[1]) - 1, parseInt(a[2]), parseInt(a[3]), parseInt(a[4]), parseInt(a[5]), 0); } function dateToStr(date) { return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); } function toFilledStr(o, f, l) { var s = o.toString(); while (s.length < l) { s = f.toString() + s; } return s; } function getPenaltyTimeStr(x) { var ss = toFilledStr(x % 60, '0', 2); x = Math.floor(x / 60); var mm = toFilledStr(x % 60, '0', 2); x = Math.floor(x / 60); var hh = x.toString(); return hh + ':' + mm + ':' + ss; } function htmlspecialchars(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(//g, ">"); s = s.replace(/"/g, """); return s; } function getColOfScore(score) { if (score == 0) { return ColorConverter.toStr(ColorConverter.toRGB(new HSV(0, 100, 80))); } else if (score == 100) { return ColorConverter.toStr(ColorConverter.toRGB(new HSV(120, 100, 80))); } else { return ColorConverter.toStr(ColorConverter.toRGB(new HSV(30 + score * 60 / 100, 100, 90))); } } function getUserLink(username, realname, color) { if (!username) { return ''; } var text = username; var style = ''; if (username.charAt(0) == '@') { username = username.substr(1); } if (realname) { text = text + ' (' + realname + ')'; } if (color) { style += 'color: ' + color + ';'; } return '' + text + ''; } function getUserSpan(username, realname, color) { if (!username) { return ''; } var text = username; var style = ''; if (username.charAt(0) == '@') { username = username.substr(1); } if (realname) { text = text + ' (' + realname + ')'; } if (color) { style += 'color: ' + color + ';'; } return '' + text + ''; } function replaceWithHighlightUsername() { var username = $(this).text(); var realname = $(this).data("realname"); var color = $(this).data("color"); if ($(this).data("link") != 0) { $(this).replaceWith(getUserLink(username, realname, color)); } else { $(this).replaceWith(getUserSpan(username, realname, color)); } } $.fn.uoj_honor = function() { return this.each(function() { var honor = $(this).text(); var realname = $(this).data("realname"); if (realname) { honor = honor + ' (' + realname + ')'; } $(this).css('color', '#007bff').html(honor); }); } function showErrorHelp(name, err) { if (err) { $('#div-' + name).addClass('has-validation has-error'); $('#div-' + name).addClass('is-invalid'); $('#input-' + name).addClass('is-invalid'); $('#help-' + name).text(err); return false; } else { $('#div-' + name).removeClass('has-validation has-error'); $('#div-' + name).removeClass('is-invalid'); $('#input-' + name).removeClass('is-invalid'); $('#help-' + name).text(''); return true; } } function getFormErrorAndShowHelp(name, val) { var err = val($('#input-' + name).val()); return showErrorHelp(name, err); } function validateSettingPassword(str) { if (str.length < 6) { return '密码长度不应小于6。'; } else if (! /^[!-~]+$/.test(str)) { return '密码应只包含可见ASCII字符。'; } else if (str != $('#input-confirm_password').val()) { return '两次输入的密码不一致。'; } else { return ''; } } function validatePassword(str) { if (str.length < 6) { return '密码长度不应小于6。'; } else if (! /^[!-~]+$/.test(str)) { return '密码应只包含可见ASCII字符。'; } else { return ''; } } function validateEmail(str) { if (str.length > 50) { return '电子邮箱地址太长。'; } else if (! /^(.+)@(.+)$/.test(str)) { return '电子邮箱地址非法。'; } else { return ''; } } function validateUsername(str) { if (str.length == 0) { return '用户名不能为空。'; } else if (! /^[a-zA-Z0-9_]+$/.test(str)) { return '用户名应只包含大小写英文字母、数字和下划线。'; } else { return ''; } } function validateQQ(str) { if (str.length < 5) { return 'QQ的长度不应小于5。'; } else if (str.length > 15) { return 'QQ的长度不应大于15。'; } else if (/\D/.test(str)) { return 'QQ应只包含0~9的数字。'; } else { return ''; } } function validateMotto(str) { if (str.length > 1024) { return '不能超过 1024 个字符。'; } else { return ''; } } // tags $.fn.uoj_problem_tag = function() { return this.each(function() { $(this).attr('href', uojHome + '/problems?tag=' + encodeURIComponent($(this).text())); }); } $.fn.uoj_list_tag = function() { return this.each(function() { $(this).attr('href', uojHome + '/lists?tag=' + encodeURIComponent($(this).text())); }); } $.fn.uoj_blog_tag = function() { return this.each(function() { $(this).attr('href', uojBlogUrl + '/archive?tag=' + encodeURIComponent($(this).text())); }); } // click zan function click_zan(zan_id, zan_type, zan_delta, node) { var loading_node = $('
_uid
。')))
).append(
$('')
.append($('').append(''))
.append($('').append(input_luogu_client_id))
.append($('').append($('').append('请填入 Cookie 中的 __client_id
。')))
).append(input_my_account_data);
}
$(this).append(
$('').append(
$('')
.append(input_submit_type_bot)
.append($('').append(' 公用账号'))
).append(
$('')
.append(input_submit_type_my)
.append($('').append(' 自有账号'))
)
).append(div_submit_type_bot).append(div_submit_type_my);
});
}
// custom test
function custom_test_onsubmit(response_text, div_result, url) {
if (response_text != '') {
$(div_result).html('