Skip to content

Instantly share code, notes, and snippets.

View CooLNuanfeng's full-sized avatar
😀
I may be slow to respond.

NewCoder CooLNuanfeng

😀
I may be slow to respond.
View GitHub Profile
@CooLNuanfeng
CooLNuanfeng / javascript awake App
Created November 23, 2016 09:17
JavaScript 拉起 App
function openApp(openUrl, callback) {
//检查app是否打开
function checkOpen(cb){
var _clickTime = +(new Date());
function check(elsTime) {
if ( elsTime > 7000) { // 7000 = 5000 + toast的 2000
cb(1);
} else {
cb(0);
@CooLNuanfeng
CooLNuanfeng / javascript awake App
Created November 23, 2016 09:16
JavaScript 拉起 App
function openApp(openUrl, callback) {
//检查app是否打开
function checkOpen(cb){
var _clickTime = +(new Date());
function check(elsTime) {
if ( elsTime > 7000) { // 7000 = 5000 + toast的 2000
cb(1);
} else {
cb(0);
@CooLNuanfeng
CooLNuanfeng / 01-gulpfile.js
Created February 22, 2016 02:12 — forked from markgoodyear/01-gulpfile.js
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@CooLNuanfeng
CooLNuanfeng / Jade 简单使用示例
Created November 16, 2015 03:47
Jade 简单使用示例
###Jade 简单使用示例
####**安装**
`npm install jade -g`
####**指令**
`jade --help`
@CooLNuanfeng
CooLNuanfeng / window-onuload-event
Created July 29, 2015 01:28
监听窗口关闭事件
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
var warning="确认退出?";
return warning;
}
function onunload_handler(){
var warning="谢谢光临";
alert(warning);
@CooLNuanfeng
CooLNuanfeng / array_norepeat.js
Created July 28, 2014 12:53
一维数组去重
var arr = [1,2,2,4,2];
for(var i =0; i< arr.length; i++){
for(var j=i+1; j<arr.length; j++){
if( arr[i] == arr[j] ){
arr.splice(j,1);
j--;
}
}
}
评分
@CooLNuanfeng
CooLNuanfeng / Ajax_javascript.js
Created July 23, 2014 08:08
原生ajax封装(get/post)
function ajax(url, fnOnSucc, fnOnFaild)
{
var oAjax=null;
//1.初始化Ajax对象
if(window.ActiveXObject)
{
oAjax=new ActiveXObject("Msxml2.XMLHTTP")||new ActiveXObject("Microsoft.XMLHTTP");
}
else
@CooLNuanfeng
CooLNuanfeng / randomString.js
Last active August 29, 2015 14:04
生成随机字符串(0~9,a~z)
/**
* @function:generateRandomAlphaNum->生成随机的字符串
* @param:len->生存随机字符串的长度
* @tdd->IE6-9 chrome Firefox通过测试
*
*/
function generateRandomAlphaNum(len) {
var rdmString = "";
//toSting接受的参数表示进制,默认为10进制。36进制为0-9 a-z
for (var i=0; rdmString.length < len; rdmString += Math.random().toString(36).substr(2));
@CooLNuanfeng
CooLNuanfeng / objtoArray.js
Created July 23, 2014 07:59
将伪数组转化为数组
/**
* 这里把符合以下条件的对象称为伪数组
* 1,具有length属性
* 2,按索引方式存储数据
* 3,不具有数组的push,pop等方法
*
*/
//将伪数组转换成数组,ps:已测试IE6-10、chrome、Firefox
function toArray(arg){