Skip to content

Instantly share code, notes, and snippets.

@swainet
swainet / async-seajs.js
Created July 25, 2013 08:34
seajs异步载入
// sea.js 的异步载入代码:
;(function(m, o, d, u, l, a, r) {
if(m[o]) return
function f(n) { return function() { r.push(n, arguments); return a } }
m[o] = a = { args: (r = []), config: f(1), use: f(2), on: f(3) }
m.define = f(0)
window.addEventListener('load', function () {
u = d.createElement("script")
u.id = o + "node"
<!DOCTYPE html>
<html>
<head>
<meta charset="GBK"/>
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0;" name="viewport" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<title></title>
</head>
<body>
@swainet
swainet / connection-debug.js
Last active December 17, 2015 21:39
网速检测
window.addEventListener('load', function () {
var interval = 500, begin = Date.now(), img = new Image(), timer = setTimeout(handler, interval);
window.removeEventListener('load', arguments.callee);
img.addEventListener('load', handler, false);
img.src = 'https://i.alipayobjects.com/e/201305/Q9jNoeIir.gif?t=' + begin;
function handler() {
clearTimeout(timer);
img.removeEventListener('load', handler);
//响应在500ms以内算高速网络 高清(HD)标清(SD)
@swainet
swainet / global-debug.css
Last active December 17, 2015 15:38
CSS for Mobile
body {
-webkit-touch-callout: none; /*当手指按住(Touch hold)某个可点击的DOM节点时,禁止呼出操作面板,比如链接。*/
-webkit-user-select: none; /*无法选择文本*/
-ms-touch-select: none; /*WP8 实测无效果,理论作用同上*/
-webkit-tap-highlight-color: transparent; /*点击链接高亮的时候设置颜色为透明*/
-ms-touch-action: none; /*WP8 作用同上*/
/*WP8 还可以通过 <meta name="msapplication-tap-highlight" content="no" /> 实现*/
}
@media only screen and (max-width: 480px) {