Skip to content

Instantly share code, notes, and snippets.

View lbj96347's full-sized avatar

lbjhk lbj96347

View GitHub Profile
@lbj96347
lbj96347 / get-parameter-demo
Last active August 29, 2015 14:20
javascript-get-url-parameter
function getParameter( name, url ) {
if (!url) url = location.href
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( url );
return results == null ? null : results[1];
}
getParameter('q', 'hxxp://example.com/?q=abc');
@lbj96347
lbj96347 / iscroll-simple-setup
Created January 10, 2012 13:57
iscoll simple setup
If you have only text and all images have fixed dimensions (ie: explicit width/height) you may use the DOMContentLoaded event.
Besides: header/footer/wrapper/scroller all these elements should be position-absolute.
In the document HEAD add:
<style>
#wrapper {
position:absolute; z-index:1;
top:45px; bottom:48px; left:0;
@lbj96347
lbj96347 / DealChar.html
Created February 1, 2012 03:26
JS处理中英文字符
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>hello world</title>
<script src='library/jquery-1.7.min.js' type='text/javascript'></script>
</head>
@lbj96347
lbj96347 / rmDelayOnclick.js
Created February 6, 2012 07:09
RemoveDedayOnclick
/*when you use an onclick event in an html element,iPhone webkit browser would have a delay.So you should deal with it.This part of js would help you.You just need to add this file in your html page and use ontouchstart/ontouchend/ontouchmove to replace onclick event */
/* 当你在使用onclick事件的时候,iPhone手机上面的safari浏览器会对事件产生一个延误(大概是0.3秒左右),这个时候你必须对这个事件作出一些处理。 然后用ontouchstart ontouchend ontouchmove去代替原本的onclick事件即可*/
/* how to use it? <a onclick="alert('touch me');">Touch Me</a> that's it */
/* 怎么用它,<a ontouchstart="alert('摸我一下');">摸我</a> that's it */
function NoClickDelay(el) {
this.element = el;
@lbj96347
lbj96347 / sqlFieldType.txt
Created February 13, 2012 14:29
sqlFieldType
bit:1位,0或1的整型数字
int:(integer )4字节,从-2^31(-2,147,483,648)到2^31(2,147,483,647)的整型数字
smallint:2字节,从-2^15(-32,768)到2^15(32,767)的整型数字
tinyint:1字节,从0到255的整型数字
decimal(p,s):数字数据,固定精度为p,宽度为s。从-10^38到10^38-1的定精度与有效位数的数字
numeric:decimal的同义词
money:8字节,从-2^63(-922,337,203,685,477.5808)到2^63-1(922,337,203,685,477.5807)的货币数据,最小货币单位千分之十
smallmoney:4字节,从-214,748.3648到214,748.3647的货币数据,最小货币单位千分之十
float(n):n在1~24之间,4字节,7位精度。从-1.79E+308到1.79E+308可变精度的数字
@lbj96347
lbj96347 / jsScrollupEffect.js
Created March 6, 2012 14:32
Javascript ScrollUp Effect
function scrollUp(nowHeight,scrollHeight) {
//window scroll animation
function moveScroller(){
function outPut(arg){
window.scrollTo(0,arg);
}
for(var i = nowHeight; i <= scrollHeight; i++){
setTimeout((function(pos){
return function(){ outPut(pos); }
})(i), i * 2);
@lbj96347
lbj96347 / javascriptfadeeffect.js
Created March 6, 2012 14:21
Javascript Fade Effect
//how to use it?you just need to use this words : 'fadeEffect.init(theID,0)' or 'fadeEffect.init(theID,1);'
//*theID is which element you want to add the effect in.
//*the 0/1 is the Parameter for the effect.0 stands for Transparent;1 stands for Visible
//besides you should set opacity in your html tags
//怎样用它?你只要写这个语句就可以了: 'fadeEffect.init(theID,0)' 或者 'fadeEffect.init(theID,1);'
//0 或者 1 这个这个效果的参数。0代表透明,1代表可见。
//此外,建议你再你的html标签里面设定好初始值
fadeEffect=function(){
return{
@lbj96347
lbj96347 / RestructuringJson.js
Created March 6, 2012 14:10
Restructuring JSON
var m = [{a:'a',b:'b'},{a:'c',b:'d'}];
//regard m as a JSON
var img = new Array();
for (x in m )
{
var val = m[x].a;
img[x]={img:val,name:val}
}
//img[0]={img:'a', name :'a'}
//img[1]={img:'c', name :'c'}
@lbj96347
lbj96347 / StringToJSON.html
Created March 14, 2012 09:50
StringToJSON
<!-- 今天搜集了一下google weather的all condition,然后要把这些数据翻译成为中文,然后把这些固定的文字保存下来,打算用json格式。无奈的是这些字符串毫无规律,于是就想到了用正则去匹配,生成一段json代码。 -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>一段正则函数方便转换纯字符串为json</title>
</head>
@lbj96347
lbj96347 / JsAudioControl.html
Created March 24, 2012 08:04
JavascriptAudioControl
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Audio Player </title>
<!-- Uncomment the following meta tag if you have issues rendering this page on an intranet site. -->
<!-- <meta http-equiv="X-UA-Compatible" content="IE=9"/> -->
<script type="text/javascript">
// Global variable to track current file name.
var currentFile = "";