Separate scripts about checking updates from HTML

This commit is contained in:
printempw 2017-08-06 23:08:09 +08:00
parent a55f150eac
commit 1852e9f4fb
3 changed files with 16 additions and 12 deletions

View File

@ -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 = `<span class="label label-primary pull-right">v${data.latest}</span>`;
$(`[href="${url('admin/update')}"]`).append(dom);
}
});
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
module.exports = {
checkForUpdates,
downloadUpdates,
};
}

View File

@ -92,16 +92,7 @@
@include('common.dependencies.script', ['module' => 'admin'])
@if (option('check_update'))
<script>
$(document).ready(function() {
// check for updates
$.getJSON("{{ url('admin/update/check') }}", function(data) {
if (data.available == true) {
$('[href="{{ url('admin/update') }}"]').append('<span class="label label-primary pull-right">v'+data.latest+'</span>');
}
});
});
</script>
<script>$(document).ready(checkForUpdates);</script>
@endif
@if (option('allow_sending_statistics'))