Skip to content

Instantly share code, notes, and snippets.

View 6174's full-sized avatar

Marc Chen 6174

View GitHub Profile
@6174
6174 / throttle1.js
Created August 21, 2013 09:01
throttle 函数啦 *_*
/**
* 版本1
* Throttles a call to a method based on the time between calls.
* @param {Function} fn The function call to throttle.
* @param {Object} [context] context fn to run
* @param {Number} [ms] The number of milliseconds to throttle the method call.
* Passing a -1 will disable the throttle. Defaults to 150.
* @return {Function} Returns a wrapped function that calls fn throttled.
* @member KISSY
*/
@6174
6174 / arrayUtil.js
Created August 22, 2013 12:12
array util.js
*
jQuery array utils - 0.1
http://code.google.com/p/jquery-utils/
(c) Maxime Haineault <[email protected]>
http://haineault.com
MIT License (http://www.opensource.org/licenses/mit-license.php
*/

捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。

window.onerror 讲接收3个参数:

  • msg:错误描述,比如:a is not defined
  • url:出错脚本所在的url
  • lineNumber:出错脚本的行数

本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。

@6174
6174 / resourDef.js
Last active December 23, 2015 23:39
resource manager
/**
* @object -- game resource
*/
KISSY.add('khc/mods/game/carnival/gameResource', function(S) {
var BASE_PATH = '../src/image/game/carnival/';
var X_SIZE = 10;
var Y_SIZE = 10;
var carnivalCfg = [{
name: 'map',
@6174
6174 / bezier.js
Last active December 24, 2015 03:29
javascript matrix vector bezier***
/**
* @class bezier
*/
KISSY.add('khc/lib/bezier', function(S) {
var TOTAL_SIMPSON_STEP = 100;
/**
* @class bezier
*/
@6174
6174 / seed.js
Created October 18, 2013 02:08
kissy seed.js
/*
Copyright 2013, KISSY UI Library v1.40dev
MIT Licensed
build time: Aug 13 19:05
*/
/**
* @ignore
* A seed where KISSY grows up from, KISS Yeah !
* @author https://github.com/kissyteam?tab=members
*/
@6174
6174 / hello-sweet.js
Created November 13, 2013 03:18
sweet
macro varr {
rule {$name:ident(,)... = $val:expr(,)...} => {
$(var $name = $val;)...
}
}
varr a, b, c = 1, 2, 3
@6174
6174 / fishEye.html
Last active December 28, 2015 07:19
fisheye
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>FishEye</title>
<style>
html {
@6174
6174 / github_stacktrace.js
Last active April 26, 2024 10:20
stackTracejs
// Domain Public by Eric Wendelin http://eriwen.com/ (2008)
// Luke Smith http://lucassmith.name/ (2008)
// Loic Dachary <[email protected]> (2008)
// Johan Euphrosine <[email protected]> (2008)
// Oyvind Sean Kinsey http://kinsey.no/blog (2010)
// Victor Homyakov <[email protected]> (2010)
/*global module, exports, define, ActiveXObject*/
(function(global, factory) {
if (typeof exports === 'object') {
// Node
@6174
6174 / diff.js
Created January 3, 2014 11:05
diff.js
/*
* Javascript Diff Algorithm
* By John Resig (http://ejohn.org/)
* Modified by Chu Alan "sprite"
*
* Released under the MIT license.
*
* More Info:
* http://ejohn.org/projects/javascript-diff-algorithm/
*