first browser check version
This commit is contained in:
parent
fb26aa4bda
commit
27f5202097
3 changed files with 142 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
class App.BrowsercheckWidget extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
# bind on event to show message
|
||||
App.Event.bind 'session:browscheckfailed', (data) =>
|
||||
console.log('hannes was here')
|
||||
new Message(data)
|
||||
|
||||
|
||||
class Message extends App.ControllerModal
|
||||
constructor: ->
|
||||
super
|
||||
@render()
|
||||
|
||||
render: ->
|
||||
@html App.view('modal')(
|
||||
title: @title,
|
||||
message: @message
|
||||
detail: @detail
|
||||
close: @close
|
||||
)
|
||||
@modalShow(
|
||||
backdrop: false,
|
||||
keyboard: false,
|
||||
)
|
||||
|
||||
App.Config.set( 'browscheckfailed', App.BrowsercheckWidget, 'Widgets' )
|
112
app/assets/javascripts/app/lib/app_post/browser.coffee
Normal file
112
app/assets/javascripts/app/lib/app_post/browser.coffee
Normal file
|
@ -0,0 +1,112 @@
|
|||
class App.Browser extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
@init: ->
|
||||
@browser = @searchString(@dataBrowser) or "An unknown browser"
|
||||
@version = @searchVersion(navigator.userAgent) or @searchVersion(navigator.appVersion) or "an unknown version"
|
||||
@OS = @searchString(@dataOS) or "an unknown OS"
|
||||
return @check()
|
||||
|
||||
|
||||
@searchString: (data) ->
|
||||
i = 0
|
||||
|
||||
while i < data.length
|
||||
dataString = data[i].string
|
||||
dataProp = data[i].prop
|
||||
@versionSearchString = data[i].versionSearch or data[i].identity
|
||||
if dataString
|
||||
return data[i].identity unless dataString.indexOf(data[i].subString) is -1
|
||||
else return data[i].identity if dataProp
|
||||
i++
|
||||
|
||||
@searchVersion: (dataString) ->
|
||||
index = dataString.indexOf(@versionSearchString)
|
||||
return if index is -1
|
||||
parseFloat dataString.substring(index + @versionSearchString.length + 1)
|
||||
|
||||
@dataBrowser: [
|
||||
string: navigator.userAgent
|
||||
subString: "Chrome"
|
||||
identity: "Chrome"
|
||||
,
|
||||
string: navigator.userAgent
|
||||
subString: "OmniWeb"
|
||||
versionSearch: "OmniWeb/"
|
||||
identity: "OmniWeb"
|
||||
,
|
||||
string: navigator.vendor
|
||||
subString: "Apple"
|
||||
identity: "Safari"
|
||||
versionSearch: "Version"
|
||||
,
|
||||
prop: window.opera
|
||||
identity: "Opera"
|
||||
versionSearch: "Version"
|
||||
,
|
||||
string: navigator.vendor
|
||||
subString: "iCab"
|
||||
identity: "iCab"
|
||||
,
|
||||
string: navigator.vendor
|
||||
subString: "KDE"
|
||||
identity: "Konqueror"
|
||||
,
|
||||
string: navigator.userAgent
|
||||
subString: "Firefox"
|
||||
identity: "Firefox"
|
||||
,
|
||||
string: navigator.vendor
|
||||
subString: "Camino"
|
||||
identity: "Camino"
|
||||
,
|
||||
# for newer Netscapes (6+)
|
||||
string: navigator.userAgent
|
||||
subString: "Netscape"
|
||||
identity: "Netscape"
|
||||
,
|
||||
string: navigator.userAgent
|
||||
subString: "MSIE"
|
||||
identity: "Explorer"
|
||||
versionSearch: "MSIE"
|
||||
,
|
||||
string: navigator.userAgent
|
||||
subString: "Gecko"
|
||||
identity: "Mozilla"
|
||||
versionSearch: "rv"
|
||||
,
|
||||
# for older Netscapes (4-)
|
||||
string: navigator.userAgent
|
||||
subString: "Mozilla"
|
||||
identity: "Netscape"
|
||||
versionSearch: "Mozilla"
|
||||
]
|
||||
@dataOS: [
|
||||
string: navigator.platform
|
||||
subString: "Win"
|
||||
identity: "Windows"
|
||||
,
|
||||
string: navigator.platform
|
||||
subString: "Mac"
|
||||
identity: "Mac"
|
||||
,
|
||||
string: navigator.userAgent
|
||||
subString: "iPhone"
|
||||
identity: "iPhone/iPod"
|
||||
,
|
||||
string: navigator.platform
|
||||
subString: "Linux"
|
||||
identity: "Linux"
|
||||
]
|
||||
|
||||
@check: ->
|
||||
if @browser == 'Chrome' && @version <= 27
|
||||
App.Event.trigger('session:browscheckfailed', {title: 'Error', message: 'Your Browser is not supported!'})
|
||||
return false
|
||||
else
|
||||
return true
|
||||
|
||||
|
||||
|
||||
|
|
@ -44,6 +44,8 @@ class App.Content extends App.Controller
|
|||
|
||||
@log 'Content', 'notice', 'execute page controller', route, params
|
||||
|
||||
if !App.Browser.init()
|
||||
return
|
||||
# remove observers for page
|
||||
App.Collection.observeUnbindLevel('page')
|
||||
|
||||
|
|
Loading…
Reference in a new issue