Skip to content

Instantly share code, notes, and snippets.

View huang-x-h's full-sized avatar
💭
I may be slow to respond.

huang.xinghui huang-x-h

💭
I may be slow to respond.
View GitHub Profile
(function () {
if (window.ActiveXObject) {
var ua = navigator.userAgent.toLowerCase();
var ie = ua.match(/msie ([\d.]+)/)[1];
if (ie == "6.0") {
var oBox = document.createElement('div');
var oBack = document.createElement('div');
oBox.id = "noie6-wrap";
oBox.innerHTML = '<div class="box"><div class="ico fl"></div><div class="text fl"><p class="px1"></p><p class="px2"></p><div class="link ovl"><a class="fl" href="http://www.firefox.com.cn/download/" id="ff-link" title="下载火狐浏览器"></a><a class="fl" href="https://www.google.com/chrome/" id="chrome-link" title="下载Chrome浏览器"></a><a class="fl" href="http://www.apple.com.cn/safari/" id="safari-link" title="下载Safari浏览器"></a><a class="fl" href="http://windows.microsoft.com/zh-CN/internet-explorer/downloads/ie" id="ie-link" title="下载新版IE浏览器"></a><a class="fl" href="http://www.opera.com/" id="opera-link" title="下载Opera浏览器"></a></div></div></div>';
oBack.id = 'SB-overlayer';
@huang-x-h
huang-x-h / mkdir_recursive.js
Last active August 9, 2020 00:41
mkdir recursive
// path需以斜杠结尾
var fs = require('fs'),
path = 'base/base/base/';
path.split('/').reduce(function(prev, next) {
if (!fs.existsSync(prev))
fs.mkdirSync(prev);
return prev + '/' + next;
});
@huang-x-h
huang-x-h / convert.js
Last active August 29, 2015 14:05
convert template file to variable string
var fs = require('fs'),
Buffer = require('buffer').Buffer;
fs.readFile('base.tpl', function(err, data) {
if (err) return;
var srcArray = data.toString().split('\r\n'),
destArray = [];
srcArray.forEach(function(content) {
destArray.push(content.replace(/(\t*).*/, function(match, $1, offset, string) {
@huang-x-h
huang-x-h / isInteger.js
Last active August 29, 2015 14:05
常用一些js处理函数
function isInteger(x) { return (x^0) === x; }
function isInteger(x) { return Math.round(x) === x; }
function isInteger(x) { return (typeof x === 'number') && (x % 1 === 0); }
@huang-x-h
huang-x-h / amd.js
Last active August 29, 2015 14:05
Making Your Library Support AMD and CommonJS
(function (root, factory) {
if(typeof define === "function" && define.amd) {
// Now we're wrapping the factory and assigning the return
// value to the root (window) and returning it as well to
// the AMD loader.
define(["postal"], function(postal){
return (root.myModule = factory(postal));
});
} else if(typeof module === "object" && module.exports) {
// I've not encountered a need for this yet, since I haven't