summaryrefslogtreecommitdiffstats
path: root/static/functions
diff options
context:
space:
mode:
authorGit <git@what.cd>2014-02-02 08:01:00 +0000
committerGit <git@what.cd>2014-02-02 08:01:00 +0000
commiteba3ae7f3377bbdf1ce8a0983d18071389fa76f0 (patch)
tree02762dcd9471770aece654b32be9f519c437162f /static/functions
parent330dbf84c39aad3f1da07e385917e91cb59f3d17 (diff)
downloadGazelle-eba3ae7f3377bbdf1ce8a0983d18071389fa76f0.zip
Gazelle-eba3ae7f3377bbdf1ce8a0983d18071389fa76f0.tar.gz
Gazelle-eba3ae7f3377bbdf1ce8a0983d18071389fa76f0.tar.bz2
Empty commit
Diffstat (limited to 'static/functions')
-rw-r--r--static/functions/detect_mobile.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/static/functions/detect_mobile.js b/static/functions/detect_mobile.js
index 1911a26..3e2d7d0 100644
--- a/static/functions/detect_mobile.js
+++ b/static/functions/detect_mobile.js
@@ -1,5 +1,6 @@
var ANDROID_COOKIE_NAME = "mobile_checked_android";
var OTHER_COOKIE_NAME = "mobile_checked_other";
+var MOBILE_SITE_HOSTNAME = "m.what.cd";
var MOBILE_SITE_URL = "https://m.what.cd/";
var ANDROID_APP_URL = "http://bit.ly/whatandroid";
@@ -24,26 +25,29 @@ var isMobile = {
}
};
-if (isMobile.Android()) {
- if (!hasCookie(ANDROID_COOKIE_NAME)) {
- setCookie(ANDROID_COOKIE_NAME, true, 365);
- var result = confirm("An Android app is available for What.CD. Would you like to download it?");
- if (result == true) {
- window.location = ANDROID_APP_URL;
+if (window.location.hostname == MOBILE_SITE_HOSTNAME) {
+ setCookie(OTHER_COOKIE_NAME, true, 365);
+} else {
+ if (isMobile.Android()) {
+ if (!hasCookie(ANDROID_COOKIE_NAME)) {
+ setCookie(ANDROID_COOKIE_NAME, true, 365);
+ var result = confirm("An Android app is available for What.CD. Would you like to download it?");
+ if (result == true) {
+ window.location = ANDROID_APP_URL;
+ }
}
- }
-} else if (isMobile.NotAndroid()) {
- if (!hasCookie(OTHER_COOKIE_NAME)) {
- setCookie(OTHER_COOKIE_NAME, true, 365);
- var result = confirm("A mobile version of What.CD is available. Would you like to use it?");
- if (result == true) {
- window.location = MOBILE_SITE_URL;
+ } else if (isMobile.NotAndroid()) {
+ if (!hasCookie(OTHER_COOKIE_NAME)) {
+ setCookie(OTHER_COOKIE_NAME, true, 365);
+ var result = confirm("A mobile version of What.CD is available. Would you like to use it?");
+ if (result == true) {
+ window.location = MOBILE_SITE_URL;
+ }
}
}
}
-
-function setCookie(c_name,value,exdays) {
+function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
@@ -51,10 +55,10 @@ function setCookie(c_name,value,exdays) {
}
function getCookie(c_name) {
- var i,x,y,ARRcookies=document.cookie.split(";");
+ var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
- y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
+ y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g,"");
if (x == c_name) {
return unescape(y);
@@ -63,7 +67,7 @@ function getCookie(c_name) {
}
function hasCookie(c_name) {
- var checked=getCookie(c_name);
+ var checked = getCookie(c_name);
if (checked != null) {
return true;
}