Skip to content

Instantly share code, notes, and snippets.

View gucheen's full-sized avatar

Cheng Gu gucheen

View GitHub Profile
@gucheen
gucheen / gist:8879984
Created February 8, 2014 09:25
兼容性疑难解答注册表项
HKEY_CLASSES_ROOT\lnkfile\shellex\ContextMenuHandlers\Compatibility
HKEY_CLASSES_ROOT\exefile\shellex\ContextMenuHandlers\Compatibility
HKEY_CLASSES_ROOT\batfile\ShellEx\ContextMenuHandlers\Compatibility
@gucheen
gucheen / docCookies.js
Created March 12, 2014 08:27
A little framework: a complete cookies reader/writer with full unicode support
/*\
|*|
|*| :: cookies.js ::
|*|
|*| A complete cookies reader/writer framework with full unicode support.
|*|
|*| https://developer.mozilla.org/en-US/docs/DOM/document.cookie
|*|
|*| This framework is released under the GNU Public License, version 3 or later.
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
/* 编辑器初始化代码 start */
var editor;
KindEditor.ready(function(K) {
editor = K.create('#tougao_content', {
width: '580px',
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false, /* 开启图片上传功能,不需要就将true改成false */
items : [
'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
var getQueryStringRegExp = function(name) {
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " "));
return null;
};
@gucheen
gucheen / sticky-menu.js
Created August 19, 2014 02:31
Creating a sticky menu
var menu = document.querySelector('.menu');
var menuPosition = menu.getBoundingClientRect();
var placeholder = document.createElement('div');
placeholder.style.width = menuPosition.width + 'px';
placeholder.style.height = menuPosition.height + 'px';
var isAdded = false;
window.addEventListener('scroll', function() {
if (window.pageYOffset >= menuPosition.top && !isAdded) {
menu.classList.add('sticky');
development:
closure-library/closure/bin/build/closurebuilder.py --root=closure-library/ --root=js/ --namespace="YourRootNameSpace" --output_mode=compiled --compiler_jar=compiler.jar > compiled.js
production:
closure-library/closure/bin/build/closurebuilder.py --root=closure-library/ --root=js/ --namespace="YourRootNameSpace" --output_mode=compiled --compiler_jar=compiler.jar --compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" > compiled.js
all:
development
@gucheen
gucheen / scrollToBottom.js
Created January 3, 2015 02:33
detect page scroll to bottom
window.innerHeight+(window.scrollY || document.documentElement.scrollTop) > document.documentElement.scrollHeight
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
height: 3000px;
}
.scroll {
@gucheen
gucheen / mouse-idle.js
Created March 9, 2015 11:12
detect mouse idle
var timeoutID;
function setup() {
this.addEventListener("mousemove", resetTimer, false);
this.addEventListener("mousedown", resetTimer, false);
this.addEventListener("keypress", resetTimer, false);
this.addEventListener("DOMMouseScroll", resetTimer, false);
this.addEventListener("mousewheel", resetTimer, false);
this.addEventListener("touchmove", resetTimer, false);
this.addEventListener("MSPointerMove", resetTimer, false);
@gucheen
gucheen / debounce.js
Created June 4, 2015 02:31
JavaScript 防抖
function debounce(func, wait, options) {
var args,
maxTimeoutId,
result,
stamp,
thisArg,
timeoutId,
trailingCall,
lastCalled = 0,
maxWait = false,