From bdfeae20f20d8b7e8ff9b293fec4587a294ab353 Mon Sep 17 00:00:00 2001 From: cutls Date: Sun, 18 Oct 2020 18:04:31 +0900 Subject: [PATCH] #317 disabled toot button when offline --- app/js/platform/end.js | 12 +++++++++++- app/js/ui/post-box.js | 2 +- app/view/make/index.sample.html | 2 +- app/view/make/setting.sample.html | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/js/platform/end.js b/app/js/platform/end.js index 62fc2e57..4e9eb1a8 100644 --- a/app/js/platform/end.js +++ b/app/js/platform/end.js @@ -215,4 +215,14 @@ if(pwa) { } } } -} \ No newline at end of file +} +const connection = function (event) { + console.log(navigator.onLine, 'network state') + if(!navigator.onLine) { + $('#toot-post-btn').addClass('disabled') + } else { + $('#toot-post-btn').removeClass('disabled') + } +} +window.onoffline = connection +window.ononline = connection \ No newline at end of file diff --git a/app/js/ui/post-box.js b/app/js/ui/post-box.js index cec48573..64334e58 100644 --- a/app/js/ui/post-box.js +++ b/app/js/ui/post-box.js @@ -101,7 +101,7 @@ if (location.search) { $('.mini-btn').text('expand_less') } } -window.onload = initPostbox +window.onload = function () { initPostbox(); connection() } function initPostbox() { $('#posttgl').click(function (e) { if (!$('#post-box').hasClass('appear')) { diff --git a/app/view/make/index.sample.html b/app/view/make/index.sample.html index fef4b6ed..20b535ab 100644 --- a/app/view/make/index.sample.html +++ b/app/view/make/index.sample.html @@ -1085,7 +1085,7 @@
- +
diff --git a/app/view/make/setting.sample.html b/app/view/make/setting.sample.html index 646ce7ff..15f468b8 100644 --- a/app/view/make/setting.sample.html +++ b/app/view/make/setting.sample.html @@ -43,6 +43,7 @@ +

@@setting@@