From 1852e9f4fb1dd3cc6060d4c856510bacc8feeca6 Mon Sep 17 00:00:00 2001 From: printempw Date: Sun, 6 Aug 2017 23:08:09 +0800 Subject: [PATCH] Separate scripts about checking updates from HTML --- .../assets/src/js/admin/{index.js => common.js} | 0 resources/assets/src/js/admin/update.js | 17 +++++++++++++++-- resources/views/admin/master.tpl | 11 +---------- 3 files changed, 16 insertions(+), 12 deletions(-) rename resources/assets/src/js/admin/{index.js => common.js} (100%) diff --git a/resources/assets/src/js/admin/index.js b/resources/assets/src/js/admin/common.js similarity index 100% rename from resources/assets/src/js/admin/index.js rename to resources/assets/src/js/admin/common.js diff --git a/resources/assets/src/js/admin/update.js b/resources/assets/src/js/admin/update.js index e7c088ab..6147b82c 100644 --- a/resources/assets/src/js/admin/update.js +++ b/resources/assets/src/js/admin/update.js @@ -88,6 +88,19 @@ function downloadUpdates() { } -if (typeof require !== 'undefined' && typeof module !== 'undefined') { - module.exports = downloadUpdates; +function checkForUpdates() { + fetch({ url: url('admin/update/check') }).then(data => { + if (data.available == true) { + let dom = `v${data.latest}`; + + $(`[href="${url('admin/update')}"]`).append(dom); + } + }); +} + +if (typeof require !== 'undefined' && typeof module !== 'undefined') { + module.exports = { + checkForUpdates, + downloadUpdates, + }; } diff --git a/resources/views/admin/master.tpl b/resources/views/admin/master.tpl index cadd88e4..a540ee12 100644 --- a/resources/views/admin/master.tpl +++ b/resources/views/admin/master.tpl @@ -92,16 +92,7 @@ @include('common.dependencies.script', ['module' => 'admin']) @if (option('check_update')) - + @endif @if (option('allow_sending_statistics'))