diff --git a/admin/index.php b/admin/index.php index 1ee87fc2..71edbc37 100644 --- a/admin/index.php +++ b/admin/index.php @@ -136,18 +136,17 @@ $(document).ready(function () { function applyUpdate(update) { if (update.available) { - $('

' + $('

' + ''.replace('%s', update.current) + '
' + '' + ''.replace('%s', update.latest) + '

') - .appendTo('.welcome-board').effect('highlight'); + .insertAfter('.typecho-page-title').effect('highlight'); } } if (!!update) { applyUpdate($.parseJSON(update)); } else { - update = ''; $.get('index('/action/ajax?do=checkVersion'); ?>', function (o, status, resp) { applyUpdate(o); cache.setItem('update', resp.responseText); diff --git a/admin/write-js.php b/admin/write-js.php index 0cbc80a1..b0c6a26d 100644 --- a/admin/write-js.php +++ b/admin/write-js.php @@ -163,11 +163,11 @@ $(document).ready(function() { })(); if (dstOffset > 0) { - $('').insertAfter(form).val(dstOffset); + $('').appendTo(form).val(dstOffset); } // 时区 - $('').insertAfter(form).val(Math.floor((Date.now() - Date.UTC()) / 1000)); + $('').appendTo(form).val(- (new Date).getTimezoneOffset() * 60); // 自动保存 autoSave): ?> diff --git a/var/Typecho/Common.php b/var/Typecho/Common.php index b6250b18..134b22f6 100644 --- a/var/Typecho/Common.php +++ b/var/Typecho/Common.php @@ -22,7 +22,7 @@ define('__TYPECHO_MB_SUPPORTED__', function_exists('mb_get_info') && function_ex class Typecho_Common { /** 程序版本 */ - const VERSION = '1.1/17.10.28'; + const VERSION = '1.1/17.10.29'; /** * 允许的属性 diff --git a/var/Widget/Ajax.php b/var/Widget/Ajax.php index 4775c617..8cc22394 100644 --- a/var/Widget/Ajax.php +++ b/var/Widget/Ajax.php @@ -44,31 +44,27 @@ class Widget_Ajax extends Widget_Abstract_Options implements Widget_Interface_Do if ($client) { $client->setHeader('User-Agent', $this->options->generator) ->setTimeout(10) - ->send('https://github.com/typecho/typecho/releases.atom'); + ->send('http://typecho.org/version.json'); /** 匹配内容体 */ $response = $client->getResponseBody(); - preg_match_all("/]+href=\"([^>]*)\"\s*\/>/is", $response, $matches); - $result = array('available' => 0); + $json = json_decode($response, true); - list($soft, $version) = explode(' ', $this->options->generator); - $current = explode('/', $version); + if (!empty($json)) { + list($soft, $version) = explode(' ', $this->options->generator); + $current = explode('/', $version); - if ($matches) { - foreach ($matches[0] as $key => $val) { - $title = trim($matches[1][$key]); - if (preg_match("/v([0-9\.]+)\-([0-9\.]+)\-release$/is", $title, $out)) { - if (version_compare($out[1], $current[0], '>=') - && version_compare($out[2], $current[1], '>')) { - $result = array( - 'available' => 1, - 'latest' => $out[1] . '-' . $out[2], - 'current' => $current[0] . '-' . $current[1], - 'link' => 'https://github.com' . $matches[1][$key] - ); - break; - } - } + if (isset($json['release']) && isset($json['version']) + && preg_match("/^[0-9\.]+$/", $json['release']) + && preg_match("/^[0-9\.]+$/", $json['version']) + && version_compare($json['release'], $current[0], '>=') + && version_compare($json['version'], $current[1], '>')) { + $result = array( + 'available' => 1, + 'latest' => $json['release'] . '-' . $json['version'], + 'current' => $current[0] . '-' . $current[1], + 'link' => 'http://typecho.org/download' + ); } }