UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

91 lines (90 loc) 2.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.titleBack = titleBack; exports.GetUrlObject = GetUrlObject; exports.yyBrowserVersions = yyBrowserVersions; exports.evil = evil; exports.isJsonStr = isJsonStr; exports.getAppointDate = getAppointDate; function titleBack() { if (history.length > 1) { history.back(); } else { if (typeof window.Bridge_YYPlugin != 'undefined') { window.Bridge_YYPlugin.call("CommonPlugin", "closewindow"); } else { console.log('无回退,且未加载YYPlus!'); } } } function GetUrlObject() { var url = location.href; var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.split('?')[1]; str = str.split('#')[0]; if (url.split('?').length > 2) { var str2 = url.split('?')[2]; str = str + '&' + str2; } var strs = str.split("&"); for (var i = 0; i < strs.length; i++) { var eqIndex = strs[i].indexOf("="); theRequest[strs[i].split("=")[0]] = unescape(strs[i].substr(eqIndex + 1)); } } else { console.log(location.href); } return theRequest; } function yyBrowserVersions() { var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, presto: u.indexOf('Presto') > -1, webKit: u.indexOf('AppleWebKit') > -1, gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, mobile: !!u.match(/AppleWebKit.*Mobile/) || !!u.match(/Windows Phone/) || !!u.match(/Android/) || !!u.match(/MQQBrowser/), ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, iPad: u.indexOf('iPad') > -1, microMessenger: u.indexOf('MicroMessenger') > -1, webApp: u.indexOf('Safari') == -1 }; } function evil(fn) { var Fn = Function; return new Fn('return ' + fn)(); } function isJsonStr(val) { return typeof val === "string" && /^\{.*\}$/.test(val); } function getAppointDate(timestamp) { var timestr = new Date(timestamp || null), y = timestr.getFullYear(), m = timestr.getMonth() + 1, a = timestr.getDate(), b = timestr.getHours(), c = timestr.getMinutes(), d = timestr.getSeconds(); if (m < 10) { m = "0" + m; } if (a < 10) { a = "0" + a; } if (b < 10) { b = "0" + b; } if (c < 10) { c = "0" + c; } if (d < 10) { d = "0" + d; } var TimeStr = y + "-" + m + "-" + a + " " + b + ":" + c + ":" + d; return { fullYear: y, Month: m, day: a, hours: b, Minutes: c, second: d, TimeStr: TimeStr }; }