Skip to content

Commit

Permalink
[feat]Update IsPhone
Browse files Browse the repository at this point in the history
  • Loading branch information
renyuzhuo committed Aug 15, 2019
1 parent a55403e commit a25c3c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1>{{title}}</h1>
<a target="_blank" href="mailto:[email protected]" class="icon-mail">Email</a>
</div>
<script type="text/javascript">
if (os.isAndroid || os.isPhone) {
if (IsPhone()) {
alert("in");
$(".side-bar").hide();
} else {
Expand Down
22 changes: 11 additions & 11 deletions zzuhtzy/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ function goBack() {
window.history.back();
}


const os = function () {
const ua = navigator.userAgent,
isAndroid = /(?:Android)/.test(ua),
isFireFox = /(?:Firefox)/.test(ua),
isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
isPhone = /(?:iPhone)/.test(ua) && !isTablet;
return {
isPhone: isPhone,
isAndroid: isAndroid,
};
/**
* @return {boolean}
*/
function IsPhone(){
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
}
return !flag;
}

0 comments on commit a25c3c0

Please sign in to comment.