mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 17:27:57 +01:00
somewhat robust detection of desktop, tablet or smartphone. This mainly w.r.t. the help tour, which we don't want to show on smartphones.
This commit is contained in:
parent
7cc5b01b37
commit
099711b33e
@ -173,7 +173,7 @@ function initButtonBehavior() {
|
|||||||
btnInfo.mouseup(function(e) {
|
btnInfo.mouseup(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("btnInfo mouse up");
|
console.log("btnInfo mouse up");
|
||||||
helpTours.startTour(helpTours.WELCOMETOUR);
|
if (!clientInfo.isSmartphone) helpTours.startTour(helpTours.WELCOMETOUR);
|
||||||
});
|
});
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
@ -20,6 +20,8 @@ var $drawAreaContainer, $doodleCanvas, doodleCanvas, doodleCanvasContext, $previ
|
|||||||
var showhideInterval;
|
var showhideInterval;
|
||||||
var showOrHide = false;
|
var showOrHide = false;
|
||||||
|
|
||||||
|
var clientInfo = {};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
console.log("ready");
|
console.log("ready");
|
||||||
|
|
||||||
@ -48,13 +50,17 @@ $(function() {
|
|||||||
console.log("wifiboxIsRemote: " + wifiboxIsRemote);
|
console.log("wifiboxIsRemote: " + wifiboxIsRemote);
|
||||||
console.log("wifibox URL: " + wifiboxURL);
|
console.log("wifibox URL: " + wifiboxURL);
|
||||||
|
|
||||||
|
// rudimentary client info
|
||||||
|
clientInfo.isMobileDevice = isMobileDevice();
|
||||||
|
clientInfo.isSmartphone = isSmartphone();
|
||||||
|
|
||||||
initDoodleDrawing();
|
initDoodleDrawing();
|
||||||
initPreviewRendering();
|
initPreviewRendering();
|
||||||
initLayouting();
|
initLayouting();
|
||||||
initSidebars();
|
initSidebars();
|
||||||
initButtonBehavior();
|
initButtonBehavior();
|
||||||
initVerticalShapes();
|
initVerticalShapes();
|
||||||
initHelp();
|
if (!clientInfo.isSmartphone) initHelp();
|
||||||
|
|
||||||
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
|
thermometer.init($("#thermometerCanvas"), $("#thermometerContainer"));
|
||||||
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
|
progressbar.init($("#progressbarCanvas"), $("#progressbarCanvasContainer"));
|
||||||
|
@ -5,3 +5,24 @@ function getURLParameter(name) {
|
|||||||
(new RegExp('[&?]'+name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
|
(new RegExp('[&?]'+name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true for all smartphones and tablets
|
||||||
|
function isMobileDevice() {
|
||||||
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Mobile/i.test(navigator.userAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns true for smartphones (Android will be a bit dodgy (tablet or phone, all depends on pixels vs devicePixelRatio...)
|
||||||
|
function isSmartphone() {
|
||||||
|
var returnBool = false;
|
||||||
|
if( /Android/i.test(navigator.userAgent) && window.devicePixelRatio > 1) {
|
||||||
|
var w = $(window).width() / window.devicePixelRatio;
|
||||||
|
console.log("Android device >> ratio'd width: " + w);
|
||||||
|
if (w < 480) {
|
||||||
|
returnBool = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
returnBool = /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini|Windows Mobile/i.test(navigator.userAgent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnBool;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user