fix: display error
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
[简体中文](README_zh.md)
|
||||
|
||||
OI Contest Schedule is a lightweight WordPress plugin that displays upcoming competitive programming contests in the WordPress dashboard or on any post or page.
|
||||
OI Contest Schedule is a lightweight WordPress plugin that displays currently running and upcoming competitive programming contests in the WordPress dashboard or on any post or page. Contests that have ended are not displayed.
|
||||
|
||||
Contest data is provided by [OI-contest-fetch](https://github.com/hanyixuanten/OI-contest-fetch) and displayed in each visitor's device time zone.
|
||||
Contest data is provided by [OI-contest-fetch](https://github.com/hanyixuanten/OI-contest-fetch) and displayed in each visitor's client device time zone, not the time zone configured in WordPress. The schedule identifies the client time zone by its IANA name, such as `Asia/Shanghai`.
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
|
||||
[English](README.md)
|
||||
|
||||
OI Contest Schedule 是一款轻量级 WordPress 插件,可在 WordPress 仪表盘、文章或页面中展示即将开始的程序设计竞赛。
|
||||
OI Contest Schedule 是一款轻量级 WordPress 插件,可在 WordPress 仪表盘、文章或页面中展示正在进行和即将开始的程序设计竞赛,不显示已结束的赛事。
|
||||
|
||||
比赛数据由 [OI-contest-fetch](https://github.com/hanyixuanten/OI-contest-fetch) 提供,时间会根据访客设备的时区显示。
|
||||
比赛数据由 [OI-contest-fetch](https://github.com/hanyixuanten/OI-contest-fetch) 提供,时间会根据访客客户端设备的时区显示,而非 WordPress 中设置的站点时区。日程中会标明客户端时区的 IANA 名称,例如 `Asia/Shanghai`。
|
||||
|
||||
## 功能特性
|
||||
|
||||
|
||||
@@ -29,6 +29,13 @@
|
||||
} );
|
||||
}
|
||||
|
||||
function updateTimeZones() {
|
||||
var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
|
||||
document.querySelectorAll( '[data-oics-time-zone]' ).forEach( function ( element ) {
|
||||
element.textContent = timeZone;
|
||||
} );
|
||||
}
|
||||
|
||||
function countdownText( startTimestamp, endTimestamp ) {
|
||||
var now = Date.now();
|
||||
if ( endTimestamp * 1000 <= now ) {
|
||||
@@ -57,8 +64,25 @@
|
||||
|
||||
function initialize() {
|
||||
updateTimes();
|
||||
updateTimeZones();
|
||||
updateCountdowns();
|
||||
window.setInterval( updateCountdowns, 1000 );
|
||||
|
||||
if ( 'MutationObserver' in window ) {
|
||||
new MutationObserver( function ( mutations ) {
|
||||
var hasAddedElements = mutations.some( function ( mutation ) {
|
||||
return Array.prototype.some.call( mutation.addedNodes, function ( node ) {
|
||||
return 1 === node.nodeType;
|
||||
} );
|
||||
} );
|
||||
|
||||
if ( hasAddedElements ) {
|
||||
updateTimes();
|
||||
updateTimeZones();
|
||||
updateCountdowns();
|
||||
}
|
||||
} ).observe( document.body, { childList: true, subtree: true } );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'loading' === document.readyState ) {
|
||||
|
||||
@@ -29,7 +29,7 @@ final class OICS_Plugin {
|
||||
wp_register_script(
|
||||
'oics-schedule-editor',
|
||||
OICS_URL . 'assets/js/schedule-editor.js',
|
||||
array( 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-server-side-render' ),
|
||||
array( 'oics-schedule', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-server-side-render' ),
|
||||
OICS_VERSION,
|
||||
true
|
||||
);
|
||||
@@ -68,8 +68,11 @@ final class OICS_Plugin {
|
||||
}
|
||||
|
||||
private function register_assets() {
|
||||
wp_register_style( 'oics-schedule', OICS_URL . 'assets/css/schedule.css', array(), OICS_VERSION );
|
||||
wp_register_script( 'oics-schedule', OICS_URL . 'assets/js/schedule.js', array(), OICS_VERSION, true );
|
||||
$style_version = OICS_VERSION . '.' . filemtime( OICS_PATH . 'assets/css/schedule.css' );
|
||||
$script_version = OICS_VERSION . '.' . filemtime( OICS_PATH . 'assets/js/schedule.js' );
|
||||
|
||||
wp_register_style( 'oics-schedule', OICS_URL . 'assets/css/schedule.css', array(), $style_version );
|
||||
wp_register_script( 'oics-schedule', OICS_URL . 'assets/js/schedule.js', array(), $script_version, true );
|
||||
wp_localize_script(
|
||||
'oics-schedule',
|
||||
'oicsScheduleL10n',
|
||||
|
||||
@@ -32,7 +32,8 @@ final class OICS_Schedule_Renderer {
|
||||
<div>
|
||||
<h2 class="oics-schedule__heading"><?php esc_html_e( 'Upcoming OI Contests', 'oi-contest-schedule' ); ?></h2>
|
||||
<p class="oics-schedule__meta">
|
||||
<?php esc_html_e( 'Times use your device time zone.', 'oi-contest-schedule' ); ?>
|
||||
<?php esc_html_e( 'Device time zone', 'oi-contest-schedule' ); ?>:
|
||||
<span data-oics-time-zone>UTC</span>
|
||||
</p>
|
||||
</div>
|
||||
<span class="oics-schedule__count"><?php echo esc_html( sprintf( _n( '%d contest', '%d contests', count( $contests ), 'oi-contest-schedule' ), count( $contests ) ) ); ?></span>
|
||||
|
||||
@@ -64,8 +64,8 @@ msgstr "暂时无法加载赛事数据,请稍后再试。"
|
||||
msgid "No upcoming contests."
|
||||
msgstr "暂无即将开始的赛事。"
|
||||
|
||||
msgid "Times use your device time zone."
|
||||
msgstr "时间按设备时区显示。"
|
||||
msgid "Device time zone"
|
||||
msgstr "设备时区"
|
||||
|
||||
msgid "%d contest"
|
||||
msgid_plural "%d contests"
|
||||
|
||||
@@ -59,7 +59,7 @@ msgstr ""
|
||||
msgid "No upcoming contests."
|
||||
msgstr ""
|
||||
|
||||
msgid "Times use your device time zone."
|
||||
msgid "Device time zone"
|
||||
msgstr ""
|
||||
|
||||
msgid "%d contest"
|
||||
|
||||
+4
-4
@@ -8,11 +8,11 @@ Stable tag: 0.1.0
|
||||
License: GPL-3.0-only
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Display upcoming OI and competitive programming contests in the WordPress dashboard or with an editor block.
|
||||
Display currently running and upcoming OI contests in the WordPress dashboard or with an editor block.
|
||||
|
||||
== Description ==
|
||||
|
||||
OI Contest Schedule displays upcoming competitive programming contests with local times and live countdowns.
|
||||
OI Contest Schedule displays currently running and upcoming competitive programming contests with local times and live countdowns. Contests that have ended are not displayed.
|
||||
|
||||
The plugin adds an **Upcoming OI Contests** widget to the WordPress dashboard. To display the schedule on the front end, add the **OI Contest Schedule** block to a post or page.
|
||||
|
||||
@@ -20,7 +20,7 @@ Features include:
|
||||
|
||||
* Upcoming and currently running contests ordered by start time.
|
||||
* Contest platform, title, start time, end time, and live countdown.
|
||||
* Dates formatted in each visitor's device time zone.
|
||||
* Dates formatted in each visitor's client device time zone, rather than the time zone configured in WordPress, and identified by its IANA name (for example, `Asia/Shanghai`).
|
||||
* Responsive and compact layouts.
|
||||
* A five-minute cache using the WordPress Transients API.
|
||||
* English and Simplified Chinese translations.
|
||||
@@ -58,7 +58,7 @@ The plugin shows contests whose end time is still in the future, including conte
|
||||
|
||||
= Which time zone is used? =
|
||||
|
||||
Dates are formatted in the visitor's device time zone using the browser's internationalization API.
|
||||
Dates are formatted in the visitor's client device time zone using the browser's internationalization API. The time zone configured in the WordPress site settings is not used.
|
||||
|
||||
= How often is the contest data refreshed? =
|
||||
|
||||
|
||||
Reference in New Issue
Block a user