Skip to content

Instantly share code, notes, and snippets.

View hehongwei44's full-sized avatar
🎯
Focusing

两仪 hehongwei44

🎯
Focusing
View GitHub Profile
@hehongwei44
hehongwei44 / index.html
Created August 26, 2014 07:59
jQuery Mobile模版页面(多个page的使用)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>jQuery Mobile模版页面</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css"/>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>
@hehongwei44
hehongwei44 / index.php
Last active August 29, 2015 14:05
jQuery Mobile模版页面(单个page页面)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>jQuery Mobile模版页面</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css"/>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>
@hehongwei44
hehongwei44 / demo.js
Created August 21, 2014 11:49
通过数组,拓展字符串拼接容易导致性能的问题。
function StringBuffer() {
this.__strings__ = new Array();
}
StringBuffer.prototype.append = function (str) {
this.__strings__.push(str);
return this;
}
StringBuffer.prototype.toString = function () {
return this.__strings__.join("");
}
@hehongwei44
hehongwei44 / npm.md
Last active August 29, 2015 14:04
npm相关的知识点介绍

##本地环境安装一个包

示例:npm install express 或者 npm i express。

##全局环境安装一个包

示例:npm install -g express 或者 npm i -g express。

@hehongwei44
hehongwei44 / package.json
Created August 2, 2014 06:18
npm包的模版样例
/**
*
* 线上环境的package.json是不能添加任何注释,该例子仅注释说明字段的含义
* @url: https://www.npmjs.org/doc/files/package.json.html
* */
{
"name": "micro-dialog", //包的名称,必填选项
"version": "0.0.1", //包的版本号,必填选项
"description": "简易对话框", //包的描述
@hehongwei44
hehongwei44 / demo.js
Created July 27, 2014 09:22
页面 视口 滚动条的位置的辅助函数
/*确定当前页面高度和宽度的两个函数*/
function pageHeight() {
return document.body.scrollHeight;
}
function pageWidth() {
return document.body.scrollWidth;
}
@hehongwei44
hehongwei44 / demo.js
Created July 27, 2014 09:07
获取鼠标位置的几个通用的函数
/*两个通用函数,用于获取鼠标相对于整个页面的当前位置*/
function getX(e) {
e = e || window.event;
return e.pageX || e.clientX + document.body.scrollLeft;
}
function getY(e) {
e = e || window.event;
@hehongwei44
hehongwei44 / demo.js
Created July 27, 2014 08:46
调节元素透明度的函数
/*调节元素透明度的函数*/
function setOpacity(elem, level) {
//IE处理透明度
if (elem.filters) {
elem.style.filters = 'alpha(opacity=' + level + ')';
} else {
elem.style.opacity = level / 100;
}
}
@hehongwei44
hehongwei44 / demo.js
Created July 27, 2014 08:40
使用cssdisplay属性来切换元素可见性的一组函数
/*使用cssdisplay属性来切换元素可见性的一组函数*/
/**
* 使用display来隐藏元素的函数
* */
function hide(elem) {
var curDisplay = getStyle(elem, 'display');
if (curDisplay != 'none') {
elem.$oldDisplay = curDisplay;
@hehongwei44
hehongwei44 / demo.js
Created July 27, 2014 07:59
获取元素当前的高度和宽度
/*获取元素当前的高度和宽度*/
/**
* 获取元素的真实高度
* */
function getHeight(elem) {
return parseInt(getStyle(elem, 'height'));
}
/**
* 获取元素的真实宽度