Added user agent detection to distinguish Android vs non-Android devices

This commit is contained in:
Noah Moroze 2014-08-26 22:29:50 -04:00
parent f591dafcc0
commit 400d9f566d
2 changed files with 8 additions and 3 deletions

View file

@ -77,6 +77,7 @@ function initialize(a) {
if (/Mobile|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
settings = {
os: "other",
platform: "mobile",
startDist: 227,
creationDt: 60,
@ -94,6 +95,7 @@ function initialize(a) {
};
} else {
settings = {
os: "other",
platform: "nonmobile",
baseScale: 1,
startDist: 340,
@ -112,6 +114,9 @@ function initialize(a) {
$("#inst_main_body").html("The goal of Hextris is to stop blocks from leaving the inside of the outer gray hexagon<br><br>" + (settings.platform != 'mobile' ? 'Press the right and left arrow keys' : 'tap the left and right sides of the screen') + " to rotate the Hexagon<br><br>Clear blocks and get points by making 3 or more blocks of the same color touch<br><br>Time left before your combo streak disappears is indicated shown by <span style='color:#f1c40f;'>the</span> <span style='color:#e74c3c'>colored</span> <span style='color:#3498db'>lines</span> <span style='color:#2ecc71'>in</span> the outer hexagon<br><br> " + (settings.platform == 'mobile' ? 'Toggle speeding up the game by tapping the inner hexagon' : "Speed up the game 2x by holding the down arrow"));
}
if(/Android/i.test(navigator.userAgent)) {
settings.os = "android";
}
window.canvas = document.getElementById('canvas');
window.ctx = canvas.getContext('2d');

View file

@ -98,14 +98,14 @@ function toggleClass(element, active) {
function showText(text) {
var messages = {
'paused': "<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press p to resume</div><div style='height:100px;line-height:100px;cursor:pointer;'></div>",
'pausedMobile': "<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press <i class='fa fa-play'></i> to resume</div><div style='height:100px;line-height:100px;cursor:pointer;'></div><div class='unselectable centeredSubHeader' style='margin-top:-50px;'><a href = 'http://hextris.github.io/adfree' target='_blank'>Don't like ads? Want to support the developer? Tap for the ad-free version.</a></div>",
'pausedAndroid': "<div class='centeredHeader unselectable'>Paused</div><br><div class='unselectable centeredSubHeader'>Press <i class='fa fa-play'></i> to resume</div><div style='height:100px;line-height:100px;cursor:pointer;'></div><div class='unselectable centeredSubHeader' style='margin-top:-50px;'><a href = 'https://play.google.com/store/apps/details?id=com.hextris.hextrisadfree' target='_blank'>Don't like ads? Want to support the developer? Tap for the ad-free version.</a></div>",
'start': "<div class='centeredHeader unselectable' style='line-height:80px;'>Press enter to start</div>",
'gameover': "<div class='centeredHeader unselectable'> Game Over: " + score + " pts</div><br><div style='font-size:24px;' class='centeredHeader unselectable'> High Scores:</div><table class='tg' style='margin:0px auto'> "
};
if (text == 'paused') {
if (settings.platform == 'mobile') {
text = 'pausedMobile';
if (settings.os == 'android') {
text = 'pausedAndroid';
}
}