From da48712cf35154ea09be01982cf75f5d29dc9c4b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 7 Sep 2017 02:47:27 +0900 Subject: [PATCH] web: Add IsEdgeBrowser --- internal/web/{mobile.go => js.go} | 5 +++++ internal/web/notjs.go | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) rename internal/web/{mobile.go => js.go} (89%) create mode 100644 internal/web/notjs.go diff --git a/internal/web/mobile.go b/internal/web/js.go similarity index 89% rename from internal/web/mobile.go rename to internal/web/js.go index c9a2e4f5d..0e323f0fb 100644 --- a/internal/web/mobile.go +++ b/internal/web/js.go @@ -44,3 +44,8 @@ func isAndroidChrome() bool { func IsMobileBrowser() bool { return isIOS() || isAndroidChrome() } + +func IsEdgeBrowser() bool { + ua := js.Global.Get("navigator").Get("userAgent").String() + return strings.Contains(ua, "Edge") +} diff --git a/internal/web/notjs.go b/internal/web/notjs.go new file mode 100644 index 000000000..3250b9ce0 --- /dev/null +++ b/internal/web/notjs.go @@ -0,0 +1,25 @@ +// Copyright 2017 The Ebiten Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !js + +package web + +func IsMobileBrowser() bool { + return false +} + +func IsEdgeBrowser() bool { + return false +}