{"id":220,"date":"2011-02-02T12:34:11","date_gmt":"2011-02-02T17:34:11","guid":{"rendered":"http:\/\/blogs.cae.tntech.edu\/mwr\/?p=220"},"modified":"2024-10-27T14:26:19","modified_gmt":"2024-10-27T14:26:19","slug":"one-more-update-to-the-door-sign-javascript","status":"publish","type":"post","link":"https:\/\/sites.tntech.edu\/renfro\/2011\/02\/02\/one-more-update-to-the-door-sign-javascript\/","title":{"rendered":"One More Update to the Door Sign Javascript"},"content":{"rendered":"<p>One more set of bug fixes for <a href=\"http:\/\/blogs.cae.tntech.edu\/mwr\/2011\/01\/01\/work-in-progress-tweetable-office-door-sign\/\">this original post<\/a>.<\/p>\n<p>Sometime early this week, Twitter broke some redirection I had been relying on. That is, if I was on my phone, URLs on twitter.com automatically redirected to mobile.twitter.com and kept all my parameters for status and such. mobile.twitter.com had no problem handling the request if I went there explicitly, though.<\/p>\n<p>So here&#8217;s the code that lets the phone automatically run to the mobile site, and keeps the PC on the regular site. Yes, it&#8217;s browser detection and not feature detection, but I&#8217;m the only user, and anyone else wanting to do this kind of thing will probably be similarly relaxed on requirements.<\/p>\n<p><!--more--><\/p>\n<pre>&lt;script type=\"text\/javascript\"&gt;\n \/\/ Detects if the current browser is a Palm Pre\/Pixi of some sort. Adapted from\n \/\/ http:\/\/www.hand-interactive.com\/resources\/detect-mobile-javascript.htm\n \/\/ Initialize our user agent string to lower case.\n var devicewebos = \"webos\";\n var uagent = navigator.userAgent.toLowerCase();\n function DetectWebOS() {\u00a0\u00a0 \u00a0\n if (uagent.search(devicewebos) &gt; -1)\n return true;\u00a0\u00a0\u00a0 else\n return false;\n }\n\n function gotostatuspage(message) {\n \/\/ Navigate to the status page, append a pseudo-random number to\n \/\/ trick Twitter into letting us post the same status message\n \/\/ repeatedly. The feed filter will edit out the added number.\n var d = new Date();\n var ms = d.getMilliseconds();\n if (DetectWebOS()) {\n \/\/ Twitter didn't like getting redirects from the regular site\n \/\/ to the mobile one, it seems.\n var urlvar = \"http:\/\/mobile.twitter.com\/home?status=\"+message+\" {\"+ms+\"}\";\n\n } else {\n var urlvar = \"http:\/\/twitter.com\/home?status=\"+message+\" {\"+ms+\"}\";\n }\n window.location.assign(urlvar);\n \/\/ Refs:\n \/\/ http:\/\/stackoverflow.com\/questions\/743129\/mobile-detection-using-javascript\n \/\/ http:\/\/stackoverflow.com\/questions\/1691781\/i-need-to-build-my-url-in-a-javascript-function-then-return-the-string-back-to-hr\n \/\/ http:\/\/www.w3schools.com\/jsref\/met_loc_assign.asp\n }\n &lt;\/script&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>One more set of bug fixes for this original post. Sometime early this week, Twitter broke some redirection I had been relying on. That is, if I was on my phone, URLs on twitter.com automatically redirected to mobile.twitter.com and kept all my parameters for status and such. mobile.twitter.com had no problem handling the request if &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/sites.tntech.edu\/renfro\/2011\/02\/02\/one-more-update-to-the-door-sign-javascript\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;One More Update to the Door Sign Javascript&#8221;<\/span><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,13],"tags":[],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-javascript","category-organization","entry"],"_links":{"self":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":1,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":444,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/posts\/220\/revisions\/444"}],"wp:attachment":[{"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.tntech.edu\/renfro\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}