Skip to content

Instantly share code, notes, and snippets.

View 303182519's full-sized avatar

xiaolong 303182519

  • www.huya.com
  • guangzhou
View GitHub Profile
@303182519
303182519 / 1.js
Created August 10, 2017 11:22
职责链模式
// 职责链模式
var Chain = function( fn ){
this.fn = fn;
this.successor = null;
};
Chain.prototype.setNextSuccessor = function( successor ){
return this.successor = successor;
};
Chain.prototype.passRequest = function(){
var ret = this.fn.apply( this, arguments );
@303182519
303182519 / danmaku.js
Created August 8, 2017 06:31
danmaku
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Danmaku = factory());
}(this, (function () { 'use strict';
function collidableRange() {
var max = 9007199254740991;
return [{
range: 0,
@303182519
303182519 / gist:54dc0a5e8e61dd6dc675c88aa1c3e08e
Last active August 8, 2017 06:31
播放器卡顿检测
var checkVideoBuffer = (function(){
var timer = null;
var timerOut = null;
var timerNum = 2000;
function checkBufferIng(oParam){
@303182519
303182519 / 一个多进程的通道
Created May 23, 2016 01:48
一个多进程的通道
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.way {
overflow:hidden;
margin-bottom:10px;
}
@303182519
303182519 / javascript
Created February 24, 2016 02:12
jScrollPane源码阅读
/*!
* jScrollPane - v2.0.22 - 2015-04-25
* http://jscrollpane.kelvinluck.com/
*
* Copyright (c) 2014 Kelvin Luck
* Dual licensed under the MIT or GPL licenses.
*/
// Script: jScrollPane - cross browser customisable scrollbars
//
@303182519
303182519 / gist:1a3fa02b501d47cf21ba
Created January 27, 2016 10:08
一个关于执行localstorage的js方法
!function (globals, document) {
var storagePrefix = "mbox_";
globals.LocalJs = {
require: function (file, callback) {
/*
如果无法使用localstorage,则使用document.write把需要请求的脚本写在页面上
作为fallback,使用document.write确保已经加载了所需要的类库
*/
if (!localStorage.getItem(storagePrefix + "jq")) {
@303182519
303182519 / 检查IE的版本
Last active November 26, 2015 02:17
检查IE的版本
var IE = (function() {
if (document.documentMode) {
return document.documentMode;
} else {
for (var i = 7; i > 4; i--) {
var div = document.createElement("div");
div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->";
if (div.getElementsByTagName("span").length) {
@303182519
303182519 / error.md
Created November 11, 2014 03:05
用window.onerror捕获并上报Js错误

#用window.onerror捕获并上报Js错误


demo例子

<!DOCTYPE html>
<html>
@303182519
303182519 / test.html
Created October 28, 2014 09:10
一个解绑的测试
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}