Fall back to old edit mode if typed arrays are not supported.
This commit is contained in:
@@ -32,12 +32,9 @@ module Precious
|
|||||||
# Detect unsupported browsers.
|
# Detect unsupported browsers.
|
||||||
@@supported_browsers = ['Firefox', 'Chrome', 'Safari']
|
@@supported_browsers = ['Firefox', 'Chrome', 'Safari']
|
||||||
Browser = Struct.new(:browser, :version)
|
Browser = Struct.new(:browser, :version)
|
||||||
# ie9 support is a work in progress.
|
|
||||||
# @@ie9 = Browser.new('Internet Explorer', '9.0')
|
|
||||||
|
|
||||||
def supported_useragent?(user_agent)
|
def supported_useragent?(user_agent)
|
||||||
ua = UserAgent.parse(user_agent)
|
ua = UserAgent.parse(user_agent)
|
||||||
# return true if ua >= @@ie9
|
|
||||||
@@supported_browsers.include? ua.browser
|
@@supported_browsers.include? ua.browser
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,22 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Live Preview</title>
|
<title>Live Preview</title>
|
||||||
|
<script>
|
||||||
|
(function( win ){
|
||||||
|
var location = win.location;
|
||||||
|
|
||||||
|
// RegExp from http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
|
||||||
|
function pageName() {
|
||||||
|
var value = new RegExp( '[\\?&]' + 'page' + '=([^&#]*)' ).exec( location.href );
|
||||||
|
return ( !value ) ? 0 : value[ 1 ] || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to old edit mode on browsers that do not support typed arrays.
|
||||||
|
if ( typeof Int32Array == 'undefined' ) {
|
||||||
|
win.location = location.protocol + '//' + location.host + '/edit/' + pageName();
|
||||||
|
}
|
||||||
|
})(window);
|
||||||
|
</script>
|
||||||
<link rel='stylesheet' type='text/css' href='../css/template.css' />
|
<link rel='stylesheet' type='text/css' href='../css/template.css' />
|
||||||
<link rel='stylesheet' type='text/css' href='css/custom.css' />
|
<link rel='stylesheet' type='text/css' href='css/custom.css' />
|
||||||
</head>
|
</head>
|
||||||
@@ -24,7 +40,7 @@
|
|||||||
<div id='comment'></div>
|
<div id='comment'></div>
|
||||||
<div id='darkness'></div>
|
<div id='darkness'></div>
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script>
|
||||||
var require = {
|
var require = {
|
||||||
paths: {
|
paths: {
|
||||||
ace: 'js/ace/lib/ace'
|
ace: 'js/ace/lib/ace'
|
||||||
|
|||||||
Reference in New Issue
Block a user